@series-inc/venus-sdk 3.0.3 → 3.0.6

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.
@@ -1,219 +1,4 @@
1
- import { __esm, __export, __publicField, createMockDelay, MOCK_DELAYS, isWebPlatform, __toCommonJS } from './chunk-W7IPHM67.mjs';
2
-
3
- // src/rooms/VenusRoom.ts
4
- var VenusRoom;
5
- var init_VenusRoom = __esm({
6
- "src/rooms/VenusRoom.ts"() {
7
- VenusRoom = class {
8
- constructor(roomData) {
9
- __publicField(this, "id");
10
- __publicField(this, "name");
11
- __publicField(this, "players");
12
- __publicField(this, "maxPlayers");
13
- __publicField(this, "gameType");
14
- __publicField(this, "appId");
15
- __publicField(this, "type");
16
- __publicField(this, "createdBy");
17
- __publicField(this, "createdAt");
18
- __publicField(this, "updatedAt");
19
- __publicField(this, "isPrivate");
20
- __publicField(this, "currentPlayers");
21
- __publicField(this, "status");
22
- __publicField(this, "customMetadata");
23
- __publicField(this, "admins");
24
- __publicField(this, "roomCode");
25
- __publicField(this, "description");
26
- __publicField(this, "data");
27
- __publicField(this, "version");
28
- __publicField(this, "_subscriptions", /* @__PURE__ */ new Map());
29
- this.id = roomData.id;
30
- this.name = roomData.name;
31
- this.players = roomData.currentPlayers || [];
32
- this.maxPlayers = roomData.maxPlayers;
33
- this.gameType = roomData.gameType;
34
- this.appId = roomData.appId;
35
- this.type = roomData.type;
36
- this.createdBy = roomData.createdBy;
37
- this.createdAt = roomData.createdAt;
38
- this.updatedAt = roomData.updatedAt;
39
- this.isPrivate = roomData.isPrivate;
40
- this.currentPlayers = roomData.currentPlayers || [];
41
- this.status = roomData.status;
42
- this.customMetadata = roomData.customMetadata || {};
43
- this.admins = roomData.admins || [];
44
- this.roomCode = roomData.roomCode;
45
- this.description = roomData.description;
46
- this.data = roomData.data || {};
47
- this.version = roomData.version;
48
- console.log(`VenusRoom: Created room object for ${this.id}`, {
49
- hasCustomMetadata: !!this.customMetadata,
50
- hasGameState: !!this.customMetadata?.rules?.gameState,
51
- gamePhase: this.customMetadata?.rules?.gameState?.phase,
52
- currentPlayer: this.customMetadata?.rules?.gameState?.currentPlayer
53
- });
54
- }
55
- updateFromRoomData(newRoomData) {
56
- if (newRoomData.id === this.id) {
57
- this.name = newRoomData.name || this.name;
58
- this.players = newRoomData.currentPlayers || this.players;
59
- this.maxPlayers = newRoomData.maxPlayers || this.maxPlayers;
60
- this.gameType = newRoomData.gameType || this.gameType;
61
- this.currentPlayers = newRoomData.currentPlayers || this.currentPlayers;
62
- this.customMetadata = newRoomData.customMetadata || this.customMetadata;
63
- this.data = newRoomData.data || this.data;
64
- this.status = newRoomData.status || this.status;
65
- this.updatedAt = newRoomData.updatedAt || this.updatedAt;
66
- console.log(`VenusRoom: Updated room object ${this.id} with fresh data`, {
67
- hasCustomMetadata: !!this.customMetadata,
68
- hasGameState: !!this.customMetadata?.rules?.gameState,
69
- gamePhase: this.customMetadata?.rules?.gameState?.phase,
70
- currentPlayer: this.customMetadata?.rules?.gameState?.currentPlayer
71
- });
72
- }
73
- }
74
- };
75
- }
76
- });
77
-
78
- // src/rooms/RoomsApi.ts
79
- var init_RoomsApi = __esm({
80
- "src/rooms/RoomsApi.ts"() {
81
- }
82
- });
83
-
84
- // src/rooms/index.ts
85
- var rooms_exports = {};
86
- __export(rooms_exports, {
87
- VenusRoom: () => VenusRoom,
88
- initializeRoomsApi: () => initializeRoomsApi,
89
- setupRoomNotifications: () => setupRoomNotifications
90
- });
91
- function bindMethod(target, targetKey, source, sourceKey) {
92
- const key = sourceKey ?? targetKey;
93
- const fn = source?.[key];
94
- if (typeof fn === "function") {
95
- target[targetKey] = fn.bind(source);
96
- return true;
97
- }
98
- return false;
99
- }
100
- function setupRoomNotifications(transport, getSubscriptions) {
101
- console.log("[Venus Rooms] Setting up room notification listeners");
102
- return transport.onVenusMessage((message) => {
103
- const subscriptions = getSubscriptions();
104
- if (!subscriptions) {
105
- return;
106
- }
107
- if (message.type === "H5_ROOM_DATA_UPDATED") {
108
- const messageData = message.data;
109
- const { roomId, roomData } = messageData;
110
- if (!roomId) return;
111
- const callbacks = subscriptions.data?.[roomId] || [];
112
- const allEventsCallbacks = subscriptions.allEvents?.[roomId] || [];
113
- console.log(`[Venus Rooms] \u{1F514} Room data updated for ${roomId}, notifying ${callbacks.length} callbacks`, roomData);
114
- callbacks.forEach((callback) => {
115
- try {
116
- callback(roomData);
117
- } catch (error) {
118
- console.error("[Venus Rooms] Error in room data callback:", error);
119
- throw error;
120
- }
121
- });
122
- allEventsCallbacks.forEach((callback) => {
123
- try {
124
- callback({ type: message.type, ...messageData });
125
- } catch (error) {
126
- console.error("[Venus Rooms] Error in allEvents callback:", error);
127
- throw error;
128
- }
129
- });
130
- }
131
- if (message.type === "H5_ROOM_MESSAGE_RECEIVED" || message.type === "H5_ROOM_MESSAGE_UPDATED" || message.type === "H5_ROOM_MESSAGE_DELETED") {
132
- const messageData = message.data;
133
- const { roomId } = messageData;
134
- if (!roomId) return;
135
- const callbacks = subscriptions.messages?.[roomId] || [];
136
- const allEventsCallbacks = subscriptions.allEvents?.[roomId] || [];
137
- console.log(`[Venus Rooms] \u{1F514} Room message event for ${roomId}, notifying ${callbacks.length} callbacks`);
138
- callbacks.forEach((callback) => {
139
- try {
140
- callback(messageData);
141
- } catch (error) {
142
- console.error("[Venus Rooms] Error in room message callback:", error);
143
- throw error;
144
- }
145
- });
146
- allEventsCallbacks.forEach((callback) => {
147
- try {
148
- callback({ type: message.type, ...messageData });
149
- } catch (error) {
150
- console.error("[Venus Rooms] Error in allEvents callback:", error);
151
- throw error;
152
- }
153
- });
154
- }
155
- if (message.type === "app:h5:proposedMoveValidationUpdated") {
156
- const messageData = message.data;
157
- const { roomId } = messageData;
158
- if (!roomId) return;
159
- const callbacks = subscriptions.gameEvents?.[roomId] || [];
160
- const allEventsCallbacks = subscriptions.allEvents?.[roomId] || [];
161
- console.log(`[Venus Rooms] \u{1F514} Proposed move validation updated for ${roomId}, notifying ${callbacks.length} callbacks`);
162
- callbacks.forEach((callback) => {
163
- try {
164
- callback(messageData);
165
- } catch (error) {
166
- console.error("[Venus Rooms] Error in game event callback:", error);
167
- throw error;
168
- }
169
- });
170
- allEventsCallbacks.forEach((callback) => {
171
- try {
172
- callback({ type: message.type, ...messageData });
173
- } catch (error) {
174
- console.error("[Venus Rooms] Error in allEvents callback:", error);
175
- throw error;
176
- }
177
- });
178
- }
179
- });
180
- }
181
- function initializeRoomsApi(venusApi, host) {
182
- const roomsApi = host?.rooms;
183
- if (!roomsApi) {
184
- console.warn(
185
- "[Venus SDK] Host did not provide a rooms implementation. Rooms API will be unavailable."
186
- );
187
- return;
188
- }
189
- const venus = venusApi;
190
- const existingNamespace = venus.rooms || {};
191
- const roomsNamespace = Object.assign({}, existingNamespace);
192
- const namespaceBindings = [
193
- ["create", "createRoom"],
194
- ["joinOrCreate", "joinOrCreateRoom"],
195
- ["joinByCode", "joinRoomByCode"],
196
- ["list", "getUserRooms"],
197
- ["subscribeToRoom", "subscribe"],
198
- ["updateRoomData", "updateData"],
199
- ["getRoomData", "getData"],
200
- ["sendRoomMessage", "sendMessage"],
201
- ["leaveRoom", "leave"],
202
- ["startRoomGame", "startGame"],
203
- ["proposeMove"],
204
- ["validateMove"]
205
- ];
206
- namespaceBindings.forEach(([targetKey, sourceKey]) => {
207
- bindMethod(roomsNamespace, targetKey, roomsApi, sourceKey);
208
- });
209
- venus.rooms = roomsNamespace;
210
- }
211
- var init_rooms = __esm({
212
- "src/rooms/index.ts"() {
213
- init_RoomsApi();
214
- init_VenusRoom();
215
- }
216
- });
1
+ import { __publicField, createMockDelay, MOCK_DELAYS, isWebPlatform } from './chunk-MWUS3A7C.mjs';
217
2
 
218
3
  // src/VenusMessageId.ts
219
4
  var VenusMessageId = /* @__PURE__ */ ((VenusMessageId2) => {
@@ -306,11 +91,14 @@ var VenusMessageId = /* @__PURE__ */ ((VenusMessageId2) => {
306
91
  VenusMessageId2["H5_SIMULATION_GET_AVAILABLE_ITEMS"] = "H5_SIMULATION_GET_AVAILABLE_ITEMS";
307
92
  VenusMessageId2["H5_SIMULATION_VALIDATE_ASSIGNMENT"] = "H5_SIMULATION_VALIDATE_ASSIGNMENT";
308
93
  VenusMessageId2["H5_SIMULATION_BATCH_OPERATIONS"] = "H5_SIMULATION_BATCH_OPERATIONS";
309
- VenusMessageId2["H5_LEADERBOARD_START_RUN"] = "H5_LEADERBOARD_START_RUN";
94
+ VenusMessageId2["H5_SIMULATION_SUBSCRIBE"] = "H5_SIMULATION_SUBSCRIBE";
95
+ VenusMessageId2["H5_SIMULATION_UNSUBSCRIBE"] = "H5_SIMULATION_UNSUBSCRIBE";
96
+ VenusMessageId2["H5_SIMULATION_UPDATE"] = "H5_SIMULATION_UPDATE";
97
+ VenusMessageId2["H5_LEADERBOARD_CREATE_SCORE_TOKEN"] = "H5_LEADERBOARD_CREATE_SCORE_TOKEN";
310
98
  VenusMessageId2["H5_LEADERBOARD_SUBMIT_SCORE"] = "H5_LEADERBOARD_SUBMIT_SCORE";
311
- VenusMessageId2["H5_LEADERBOARD_GET"] = "H5_LEADERBOARD_GET";
312
- VenusMessageId2["H5_LEADERBOARD_GET_HIGHLIGHT"] = "H5_LEADERBOARD_GET_HIGHLIGHT";
313
- VenusMessageId2["H5_LEADERBOARD_GET_PLAYER_STATS"] = "H5_LEADERBOARD_GET_PLAYER_STATS";
99
+ VenusMessageId2["H5_LEADERBOARD_GET_PAGED_SCORES"] = "H5_LEADERBOARD_GET_PAGED_SCORES";
100
+ VenusMessageId2["H5_LEADERBOARD_GET_PODIUM_SCORES"] = "H5_LEADERBOARD_GET_PODIUM_SCORES";
101
+ VenusMessageId2["H5_LEADERBOARD_GET_MY_RANK"] = "H5_LEADERBOARD_GET_MY_RANK";
314
102
  VenusMessageId2["H5_ROOM_CREATE"] = "H5_ROOM_CREATE";
315
103
  VenusMessageId2["H5_ROOM_JOIN"] = "H5_ROOM_JOIN";
316
104
  VenusMessageId2["H5_ROOM_JOIN_OR_CREATE"] = "H5_ROOM_JOIN_OR_CREATE";
@@ -1160,7 +948,8 @@ var MockCdnApi = class {
1160
948
  return index === pathParts.length - 1 ? encodeURIComponent(part) : part;
1161
949
  });
1162
950
  const encodedSubPath = encodedParts.join("/");
1163
- const fullUrl = `${this.baseUrl}${encodedSubPath}`;
951
+ const cacheBust = Date.now();
952
+ const fullUrl = `${this.baseUrl}${encodedSubPath}?cacheBust=${cacheBust}`;
1164
953
  return fullUrl;
1165
954
  }
1166
955
  resolveAvatarAssetUrl(subPath) {
@@ -1553,10 +1342,10 @@ function initializeLifecycleApi(venusApi, host) {
1553
1342
  // src/logging/MockLoggingApi.ts
1554
1343
  var MockLoggingApi = class {
1555
1344
  logDebug(message, ...args) {
1556
- console.log(`[Venus Mock] ${message}`, args);
1345
+ console.log(`[Venus Mock] ${message}`, ...args);
1557
1346
  }
1558
1347
  logError(message, ...args) {
1559
- console.error(`[Venus Mock] ${message}`, args);
1348
+ console.error(`[Venus Mock] ${message}`, ...args);
1560
1349
  }
1561
1350
  };
1562
1351
 
@@ -1757,13 +1546,8 @@ var MockNotificationsApi = class {
1757
1546
  async cancelNotification(notificationId) {
1758
1547
  const venusApi = this.venusApi;
1759
1548
  if (isWebPlatform()) {
1760
- console.log(
1761
- "[Venus Mock] Cancel notification on web platform (simulated):",
1762
- notificationId
1763
- );
1764
1549
  return true;
1765
1550
  }
1766
- console.log("[Venus Mock] Cancel local notification:", notificationId);
1767
1551
  await createMockDelay(MOCK_DELAYS.short);
1768
1552
  if (venusApi._mock.scheduledNotifications && venusApi._mock.scheduledNotifications[notificationId]) {
1769
1553
  delete venusApi._mock.scheduledNotifications[notificationId];
@@ -1773,12 +1557,8 @@ var MockNotificationsApi = class {
1773
1557
  }
1774
1558
  async getAllScheduledLocalNotifications() {
1775
1559
  if (isWebPlatform()) {
1776
- console.log(
1777
- "[Venus Mock] Get notifications on web platform (returning empty list)"
1778
- );
1779
1560
  return [];
1780
1561
  }
1781
- console.log("[Venus Mock] Get all scheduled local notifications");
1782
1562
  await createMockDelay(MOCK_DELAYS.short);
1783
1563
  const venusApi = this.venusApi;
1784
1564
  const notifications = venusApi._mock.scheduledNotifications || {};
@@ -1786,10 +1566,8 @@ var MockNotificationsApi = class {
1786
1566
  }
1787
1567
  async isLocalNotificationsEnabled() {
1788
1568
  if (isWebPlatform()) {
1789
- console.log("[Venus Mock] Notifications not available on web platform");
1790
1569
  return false;
1791
1570
  }
1792
- console.log("[Venus Mock] Check if local notifications are enabled");
1793
1571
  await createMockDelay(MOCK_DELAYS.short);
1794
1572
  const venusApi = this.venusApi;
1795
1573
  const isEnabled = venusApi._mock.notificationsEnabled !== false;
@@ -1798,9 +1576,6 @@ var MockNotificationsApi = class {
1798
1576
  async scheduleAsync(title, body, seconds, notificationId, options) {
1799
1577
  const { priority = 50, groupId, payload } = options || {};
1800
1578
  if (isWebPlatform()) {
1801
- console.log(
1802
- "[Venus Mock] Notifications not supported on web platform, simulating success"
1803
- );
1804
1579
  console.info(
1805
1580
  "\u{1F514} [Venus Mock] Notification would be scheduled:",
1806
1581
  title || "Untitled",
@@ -1811,14 +1586,11 @@ var MockNotificationsApi = class {
1811
1586
  const mockId = `mock-web-notification-${Date.now()}`;
1812
1587
  return mockId;
1813
1588
  }
1814
- console.log("[Venus Mock] Schedule local notification:", { title, body, seconds, options });
1815
1589
  const venusApi = this.venusApi;
1816
1590
  if (!venusApi._mock.pendingRequests) {
1817
- console.log("[Venus Mock] Initializing pendingRequests");
1818
1591
  venusApi._mock.pendingRequests = {};
1819
1592
  }
1820
1593
  const requestId = Date.now().toString();
1821
- console.log("[Venus Mock] Creating request with ID:", requestId);
1822
1594
  return new Promise((resolve) => {
1823
1595
  venusApi._mock.pendingRequests[requestId] = { resolve };
1824
1596
  const id = notificationId || `mock-notification-${Date.now()}`;
@@ -1840,13 +1612,8 @@ var MockNotificationsApi = class {
1840
1612
  async setLocalNotificationsEnabled(enabled) {
1841
1613
  const venusApi = this.venusApi;
1842
1614
  if (isWebPlatform()) {
1843
- console.log(
1844
- "[Venus Mock] Set notifications enabled on web platform (simulated):",
1845
- enabled
1846
- );
1847
1615
  return true;
1848
1616
  }
1849
- console.log("[Venus Mock] Set local notifications enabled:", enabled);
1850
1617
  await createMockDelay(MOCK_DELAYS.short);
1851
1618
  venusApi._mock.notificationsEnabled = enabled;
1852
1619
  return enabled;
@@ -2111,6 +1878,11 @@ function initializeProfile(venusApi, host) {
2111
1878
  };
2112
1879
  }
2113
1880
 
1881
+ // src/utils/idGenerator.ts
1882
+ function generateId() {
1883
+ return `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
1884
+ }
1885
+
2114
1886
  // src/rpc/RpcClient.ts
2115
1887
  var RpcClient = class {
2116
1888
  constructor() {
@@ -2153,7 +1925,7 @@ var RpcClient = class {
2153
1925
  }
2154
1926
  async call(method, args, timeout = 5e3) {
2155
1927
  return new Promise((resolve, reject) => {
2156
- const id = this.generateId();
1928
+ const id = generateId();
2157
1929
  this.addPendingCall(id, resolve, reject);
2158
1930
  const request = {
2159
1931
  type: "rpc-request",
@@ -2190,9 +1962,6 @@ var RpcClient = class {
2190
1962
  getPendingCall(id) {
2191
1963
  return this.pendingCalls.get(id);
2192
1964
  }
2193
- generateId() {
2194
- return `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
2195
- }
2196
1965
  handleRpcResponse(response) {
2197
1966
  const pending = this.getPendingCall(response.id);
2198
1967
  if (!pending) {
@@ -2214,106 +1983,526 @@ var RpcClient = class {
2214
1983
  }
2215
1984
  };
2216
1985
 
2217
- // src/storage/MockStorageApi.ts
2218
- function createMockStorageApi(storageType, appUrl) {
2219
- const appIdentifier = appUrl ? generateAppIdentifier(appUrl) : null;
2220
- let prefix;
2221
- let syncDelay = 0;
2222
- switch (storageType) {
2223
- case "deviceCache":
2224
- prefix = "venus:app";
2225
- syncDelay = 0;
2226
- break;
2227
- case "appStorage":
2228
- prefix = "venus:app";
2229
- syncDelay = 100;
2230
- break;
2231
- case "globalStorage":
2232
- prefix = "venus:global";
2233
- syncDelay = 100;
2234
- break;
2235
- default:
2236
- throw new Error(`Unknown storage type: ${storageType}`);
1986
+ // src/rooms/VenusRoom.ts
1987
+ var VenusRoom = class {
1988
+ constructor(roomData) {
1989
+ __publicField(this, "id");
1990
+ __publicField(this, "name");
1991
+ __publicField(this, "players");
1992
+ __publicField(this, "maxPlayers");
1993
+ __publicField(this, "gameType");
1994
+ __publicField(this, "appId");
1995
+ __publicField(this, "type");
1996
+ __publicField(this, "createdBy");
1997
+ __publicField(this, "createdAt");
1998
+ __publicField(this, "updatedAt");
1999
+ __publicField(this, "isPrivate");
2000
+ __publicField(this, "status");
2001
+ __publicField(this, "customMetadata");
2002
+ __publicField(this, "admins");
2003
+ __publicField(this, "roomCode");
2004
+ __publicField(this, "description");
2005
+ __publicField(this, "data");
2006
+ __publicField(this, "version");
2007
+ this.id = roomData.id;
2008
+ this.name = roomData.name;
2009
+ this.players = Array.isArray(roomData.currentPlayers) ? [...roomData.currentPlayers] : [];
2010
+ this.maxPlayers = roomData.maxPlayers;
2011
+ this.gameType = roomData.gameType;
2012
+ this.appId = roomData.appId;
2013
+ this.type = roomData.type;
2014
+ this.createdBy = roomData.createdBy;
2015
+ this.createdAt = roomData.createdAt;
2016
+ this.updatedAt = roomData.updatedAt;
2017
+ this.isPrivate = roomData.isPrivate;
2018
+ this.status = roomData.status;
2019
+ this.customMetadata = roomData.customMetadata || {};
2020
+ this.admins = Array.isArray(roomData.admins) ? [...roomData.admins] : [];
2021
+ this.roomCode = roomData.roomCode;
2022
+ this.description = roomData.description;
2023
+ this.data = roomData.data || {};
2024
+ this.version = roomData.version;
2237
2025
  }
2238
- prefix = storageType === "globalStorage" || !appIdentifier ? `${prefix}:` : `${prefix}:${appIdentifier}:`;
2239
- return new MockStorageApi(prefix, syncDelay);
2026
+ };
2027
+
2028
+ // src/rooms/setupRoomNotifications.ts
2029
+ function invokeCallbacks(callbacks, event, context) {
2030
+ callbacks.forEach((callback) => {
2031
+ try {
2032
+ callback(event);
2033
+ } catch (error) {
2034
+ console.error(`[Venus SDK] Error in ${context} callback:`, error);
2035
+ throw error;
2036
+ }
2037
+ });
2240
2038
  }
2241
- var MockStorageApi = class {
2242
- constructor(prefix, syncDelay) {
2243
- __publicField(this, "prefix");
2244
- __publicField(this, "syncDelay");
2245
- this.prefix = prefix;
2246
- this.syncDelay = syncDelay;
2247
- }
2248
- async clear() {
2249
- const fullLength = localStorage.length;
2250
- for (let i = 0; i < fullLength; i++) {
2251
- const fullKey = localStorage.key(i);
2252
- if (fullKey && fullKey.startsWith(this.prefix)) {
2253
- localStorage.removeItem(fullKey);
2254
- }
2039
+ function setupRoomNotifications(transport, getSubscriptions) {
2040
+ return transport.onVenusMessage((message) => {
2041
+ const subscriptions = getSubscriptions();
2042
+ if (!subscriptions) {
2043
+ return;
2255
2044
  }
2256
- await this.simulateSyncDelay();
2257
- }
2258
- async getAllItems() {
2259
- const items = new Array();
2260
- const fullLength = localStorage.length;
2261
- for (let i = 0; i < fullLength; i++) {
2262
- const fullKey = localStorage.key(i);
2263
- if (fullKey && fullKey.startsWith(this.prefix)) {
2264
- const item = localStorage.getItem(fullKey);
2265
- if (item) {
2266
- items.push(item);
2267
- }
2268
- }
2045
+ if (message.type === "H5_ROOM_DATA_UPDATED") {
2046
+ const messageData = message.data;
2047
+ const { roomId, roomData } = messageData;
2048
+ if (!roomId) return;
2049
+ const callbacks = subscriptions.data[roomId] || [];
2050
+ const event = {
2051
+ type: "H5_ROOM_DATA_UPDATED",
2052
+ roomId,
2053
+ roomData,
2054
+ timestamp: messageData.timestamp
2055
+ };
2056
+ invokeCallbacks(callbacks, event, "room data");
2269
2057
  }
2270
- return items;
2271
- }
2272
- async getItem(key) {
2273
- const fullKey = this.buildKey(key);
2274
- await this.simulateSyncDelay();
2275
- return localStorage.getItem(fullKey);
2276
- }
2277
- async key(index) {
2278
- const keys = this.keys();
2279
- if (index < 0 || index >= keys.length) {
2280
- return null;
2058
+ if (message.type === "H5_ROOM_MESSAGE_RECEIVED" || message.type === "H5_ROOM_MESSAGE_UPDATED" || message.type === "H5_ROOM_MESSAGE_DELETED") {
2059
+ const messageData = message.data;
2060
+ const { roomId } = messageData;
2061
+ if (!roomId) return;
2062
+ const callbacks = subscriptions.messages[roomId] || [];
2063
+ const event = {
2064
+ type: message.type,
2065
+ roomId,
2066
+ message: messageData.message,
2067
+ timestamp: messageData.timestamp
2068
+ };
2069
+ invokeCallbacks(callbacks, event, "room message");
2281
2070
  }
2282
- await this.simulateSyncDelay();
2283
- return keys[index];
2284
- }
2285
- async length() {
2286
- return this.keys().length;
2071
+ if (message.type === "app:h5:proposedMoveValidationUpdated") {
2072
+ const messageData = message.data;
2073
+ const { roomId } = messageData;
2074
+ if (!roomId) return;
2075
+ const callbacks = subscriptions.gameEvents[roomId] || [];
2076
+ const event = {
2077
+ type: "app:h5:proposedMoveValidationUpdated",
2078
+ roomId,
2079
+ proposedMoveData: messageData.proposedMoveData,
2080
+ proposedMoveId: messageData.proposedMoveId,
2081
+ changeType: messageData.changeType,
2082
+ timestamp: messageData.timestamp
2083
+ };
2084
+ invokeCallbacks(callbacks, event, "game event");
2085
+ }
2086
+ });
2087
+ }
2088
+
2089
+ // src/rooms/RpcRoomsApi.ts
2090
+ var RpcRoomsApi = class {
2091
+ constructor(rpcClient) {
2092
+ __publicField(this, "rpcClient");
2093
+ __publicField(this, "subscriptions");
2094
+ this.rpcClient = rpcClient;
2095
+ this.subscriptions = {
2096
+ data: {},
2097
+ messages: {},
2098
+ gameEvents: {}
2099
+ };
2287
2100
  }
2288
- async removeItem(key) {
2289
- const fullKey = this.buildKey(key);
2290
- await this.simulateSyncDelay();
2291
- localStorage.removeItem(fullKey);
2101
+ /**
2102
+ * Get the subscription state for external access (used by setupRoomNotifications)
2103
+ */
2104
+ getSubscriptions() {
2105
+ return this.subscriptions;
2292
2106
  }
2293
- async setItem(key, item) {
2294
- const fullKey = this.buildKey(key);
2295
- await this.simulateSyncDelay();
2296
- localStorage.setItem(fullKey, item);
2107
+ /**
2108
+ * Set up room notification routing from the transport
2109
+ */
2110
+ setupNotifications(transport) {
2111
+ setupRoomNotifications(transport, () => this.getSubscriptions());
2297
2112
  }
2298
- async setMultipleItems(entries) {
2299
- for (const entry of entries) {
2300
- const fullKey = this.buildKey(entry.key);
2301
- localStorage.setItem(fullKey, entry.value);
2113
+ async createRoomAsync(options) {
2114
+ const response = await this.rpcClient.call(
2115
+ "H5_ROOM_CREATE" /* H5_ROOM_CREATE */,
2116
+ {
2117
+ options
2118
+ }
2119
+ );
2120
+ if (response.success === false) {
2121
+ const errorMessage = typeof response.error === "string" ? response.error : "Failed to create room";
2122
+ throw new Error(errorMessage);
2302
2123
  }
2303
- await this.simulateSyncDelay();
2124
+ const room = new VenusRoom(response.roomData);
2125
+ return room;
2304
2126
  }
2305
- async removeMultipleItems(keys) {
2306
- for (const key of keys) {
2307
- const fullKey = this.buildKey(key);
2308
- localStorage.removeItem(fullKey);
2127
+ async joinOrCreateRoomAsync(options) {
2128
+ const response = await this.rpcClient.call(
2129
+ "H5_ROOM_JOIN_OR_CREATE" /* H5_ROOM_JOIN_OR_CREATE */,
2130
+ {
2131
+ options
2132
+ }
2133
+ );
2134
+ if (response.success === false) {
2135
+ const errorMessage = typeof response.error === "string" ? response.error : "Failed to join or create room";
2136
+ throw new Error(errorMessage);
2309
2137
  }
2310
- await this.simulateSyncDelay();
2311
- }
2312
- buildKey(key) {
2313
- const prefix = this.prefix;
2314
- return `${prefix}${key}`;
2138
+ const room = new VenusRoom(response.value.roomData);
2139
+ return {
2140
+ action: response.value.action,
2141
+ room,
2142
+ playersJoined: response.value.playersJoined
2143
+ };
2315
2144
  }
2316
- extractKey(fullKey) {
2145
+ async joinRoomByCodeAsync(roomCode) {
2146
+ const response = await this.rpcClient.call(
2147
+ "H5_ROOM_JOIN_BY_CODE" /* H5_ROOM_JOIN_BY_CODE */,
2148
+ {
2149
+ roomCode
2150
+ }
2151
+ );
2152
+ if (response?.success === false) {
2153
+ const errorMessage = typeof response.error === "string" ? response.error : "Failed to join room by code";
2154
+ throw new Error(errorMessage);
2155
+ }
2156
+ const room = new VenusRoom(response.roomData);
2157
+ return room;
2158
+ }
2159
+ // Get user's rooms with optional filtering
2160
+ async getUserRoomsAsync(options = {}) {
2161
+ const response = await this.rpcClient.call(
2162
+ "H5_ROOM_GET_USER_ROOMS" /* H5_ROOM_GET_USER_ROOMS */,
2163
+ {
2164
+ includeArchived: options.includeArchived ?? false
2165
+ }
2166
+ );
2167
+ if (response?.success === false) {
2168
+ const errorMessage = typeof response.error === "string" ? response.error : "Failed to get user rooms";
2169
+ throw new Error(errorMessage);
2170
+ }
2171
+ const venusRooms = [];
2172
+ for (const roomData of response.rooms) {
2173
+ if (!roomData.id) {
2174
+ console.warn("[Venus SDK] getUserRooms: Skipping room with missing ID:", roomData);
2175
+ continue;
2176
+ }
2177
+ try {
2178
+ const venusRoom = new VenusRoom(roomData);
2179
+ venusRooms.push(venusRoom);
2180
+ } catch (error) {
2181
+ console.warn(
2182
+ "[Venus SDK] getUserRooms: Failed to create VenusRoom object:",
2183
+ error,
2184
+ roomData
2185
+ );
2186
+ }
2187
+ }
2188
+ return venusRooms;
2189
+ }
2190
+ async updateRoomDataAsync(room, updates, options = {}) {
2191
+ const response = await this.rpcClient.call(
2192
+ "H5_ROOM_UPDATE_DATA" /* H5_ROOM_UPDATE_DATA */,
2193
+ {
2194
+ roomId: room.id,
2195
+ updates,
2196
+ merge: options.merge ?? true
2197
+ }
2198
+ );
2199
+ if (response?.success === false) {
2200
+ const errorMessage = typeof response.error === "string" ? response.error : "Failed to update room data";
2201
+ throw new Error(errorMessage);
2202
+ }
2203
+ }
2204
+ async getRoomDataAsync(room) {
2205
+ const response = await this.rpcClient.call(
2206
+ "H5_ROOM_GET_DATA" /* H5_ROOM_GET_DATA */,
2207
+ {
2208
+ roomId: room.id
2209
+ }
2210
+ );
2211
+ if (response?.success === false) {
2212
+ const errorMessage = typeof response.error === "string" ? response.error : "Failed to get room data";
2213
+ throw new Error(errorMessage);
2214
+ }
2215
+ return response.data;
2216
+ }
2217
+ async sendRoomMessageAsync(venusRoom, request) {
2218
+ const response = await this.rpcClient.call(
2219
+ "H5_ROOM_SEND_MESSAGE" /* H5_ROOM_SEND_MESSAGE */,
2220
+ {
2221
+ roomId: venusRoom.id,
2222
+ message: request.message,
2223
+ metadata: request.metadata
2224
+ }
2225
+ );
2226
+ if (response?.success === false) {
2227
+ const errorMessage = typeof response.error === "string" ? response.error : "Failed to send message";
2228
+ throw new Error(errorMessage);
2229
+ }
2230
+ return response.messageId;
2231
+ }
2232
+ async leaveRoomAsync(room) {
2233
+ const response = await this.rpcClient.call(
2234
+ "H5_ROOM_LEAVE" /* H5_ROOM_LEAVE */,
2235
+ {
2236
+ roomId: room.id
2237
+ }
2238
+ );
2239
+ if (response?.success === false) {
2240
+ const errorMessage = typeof response.error === "string" ? response.error : "Failed to leave room";
2241
+ throw new Error(errorMessage);
2242
+ }
2243
+ }
2244
+ async startRoomGameAsync(room, options = {}) {
2245
+ const response = await this.rpcClient.call(
2246
+ "H5_ROOM_START_GAME" /* H5_ROOM_START_GAME */,
2247
+ {
2248
+ roomId: room.id,
2249
+ gameConfig: options.gameConfig ?? {},
2250
+ turnOrder: options.turnOrder ?? null
2251
+ }
2252
+ );
2253
+ if (response?.success === false) {
2254
+ const errorMessage = typeof response.error === "string" ? response.error : "Failed to start game";
2255
+ throw new Error(errorMessage);
2256
+ }
2257
+ }
2258
+ async proposeMoveAsync(room, proposalPayload) {
2259
+ const response = await this.rpcClient.call(
2260
+ "h5:room:proposeMove" /* H5_ROOM_PROPOSE_MOVE */,
2261
+ {
2262
+ roomId: room.id,
2263
+ gameSpecificState: proposalPayload.gameSpecificState,
2264
+ moveType: proposalPayload.moveType,
2265
+ clientContext: proposalPayload.clientContext,
2266
+ clientProposalId: proposalPayload.clientProposalId
2267
+ }
2268
+ );
2269
+ if (response?.success === false) {
2270
+ const errorMessage = typeof response.error === "string" ? response.error : "Failed to propose move";
2271
+ throw new Error(errorMessage);
2272
+ }
2273
+ return response.data;
2274
+ }
2275
+ async validateMoveAsync(_room, moveId, verdict) {
2276
+ return {
2277
+ success: true,
2278
+ moveId,
2279
+ isValid: verdict.isValid,
2280
+ reason: verdict.reason
2281
+ };
2282
+ }
2283
+ async subscribeAsync(room, options = {}) {
2284
+ const roomId = room.id;
2285
+ const existingData = this.subscriptions.data[roomId];
2286
+ const existingMessages = this.subscriptions.messages[roomId];
2287
+ const existingGameEvents = this.subscriptions.gameEvents[roomId];
2288
+ const subscribeToData = Boolean(options.onData) && (existingData?.length ?? 0) === 0;
2289
+ const subscribeToMessages = Boolean(options.onMessages) && (existingMessages?.length ?? 0) === 0;
2290
+ const subscribeToProposedMoves = Boolean(options.onGameEvents) && (existingGameEvents?.length ?? 0) === 0;
2291
+ if (subscribeToData || subscribeToMessages || subscribeToProposedMoves) {
2292
+ try {
2293
+ await this.rpcClient.call("H5_ROOM_SUBSCRIBE" /* H5_ROOM_SUBSCRIBE */, {
2294
+ roomId,
2295
+ subscribeToData,
2296
+ subscribeToMessages,
2297
+ subscribeToProposedMoves
2298
+ });
2299
+ } catch (error) {
2300
+ console.error("[Venus SDK] Failed to set up room subscription:", error);
2301
+ throw error;
2302
+ }
2303
+ }
2304
+ if (options.onData) {
2305
+ if (!this.subscriptions.data[roomId]) {
2306
+ this.subscriptions.data[roomId] = [];
2307
+ }
2308
+ this.subscriptions.data[roomId].push(options.onData);
2309
+ }
2310
+ if (options.onMessages) {
2311
+ if (!this.subscriptions.messages[roomId]) {
2312
+ this.subscriptions.messages[roomId] = [];
2313
+ }
2314
+ this.subscriptions.messages[roomId].push(options.onMessages);
2315
+ }
2316
+ if (options.onGameEvents) {
2317
+ if (!this.subscriptions.gameEvents[roomId]) {
2318
+ this.subscriptions.gameEvents[roomId] = [];
2319
+ }
2320
+ this.subscriptions.gameEvents[roomId].push(options.onGameEvents);
2321
+ }
2322
+ let disposed = false;
2323
+ return () => {
2324
+ if (disposed) return;
2325
+ disposed = true;
2326
+ if (options.onData) {
2327
+ const callbacks = this.subscriptions.data[roomId];
2328
+ if (callbacks) {
2329
+ const index = callbacks.indexOf(options.onData);
2330
+ if (index > -1) {
2331
+ callbacks.splice(index, 1);
2332
+ }
2333
+ }
2334
+ }
2335
+ if (options.onMessages) {
2336
+ const callbacks = this.subscriptions.messages[roomId];
2337
+ if (callbacks) {
2338
+ const index = callbacks.indexOf(options.onMessages);
2339
+ if (index > -1) {
2340
+ callbacks.splice(index, 1);
2341
+ }
2342
+ }
2343
+ }
2344
+ if (options.onGameEvents) {
2345
+ const callbacks = this.subscriptions.gameEvents[roomId];
2346
+ if (callbacks) {
2347
+ const index = callbacks.indexOf(options.onGameEvents);
2348
+ if (index > -1) {
2349
+ callbacks.splice(index, 1);
2350
+ }
2351
+ }
2352
+ }
2353
+ const hasAnySubscriptions = (this.subscriptions.data[roomId]?.length ?? 0) > 0 || (this.subscriptions.messages[roomId]?.length ?? 0) > 0 || (this.subscriptions.gameEvents[roomId]?.length ?? 0) > 0;
2354
+ if (!hasAnySubscriptions) {
2355
+ this.rpcClient.call("H5_ROOM_UNSUBSCRIBE" /* H5_ROOM_UNSUBSCRIBE */, {
2356
+ roomId
2357
+ }).catch((error) => {
2358
+ console.error("[Venus SDK] Failed to clean up room subscription:", error);
2359
+ });
2360
+ }
2361
+ };
2362
+ }
2363
+ };
2364
+
2365
+ // src/rooms/index.ts
2366
+ function bindMethod(target, targetKey, source, sourceKey) {
2367
+ const key = sourceKey ?? targetKey;
2368
+ const fn = source?.[key];
2369
+ if (typeof fn === "function") {
2370
+ target[targetKey] = fn.bind(source);
2371
+ return true;
2372
+ }
2373
+ return false;
2374
+ }
2375
+ function initializeRoomsApi(venusApi, host) {
2376
+ const roomsApi = host?.rooms;
2377
+ if (!roomsApi) {
2378
+ console.warn(
2379
+ "[Venus SDK] Host did not provide a rooms implementation. Rooms API will be unavailable."
2380
+ );
2381
+ return;
2382
+ }
2383
+ const venus = venusApi;
2384
+ const existingNamespace = venus.rooms || {};
2385
+ const roomsNamespace = Object.assign({}, existingNamespace);
2386
+ const namespaceBindings = [
2387
+ ["createRoomAsync"],
2388
+ ["joinOrCreateRoomAsync"],
2389
+ ["joinRoomByCodeAsync"],
2390
+ ["getUserRoomsAsync"],
2391
+ ["subscribeAsync"],
2392
+ ["updateRoomDataAsync"],
2393
+ ["getRoomDataAsync"],
2394
+ ["sendRoomMessageAsync"],
2395
+ ["leaveRoomAsync"],
2396
+ ["startRoomGameAsync"],
2397
+ ["proposeMoveAsync"],
2398
+ ["validateMoveAsync"]
2399
+ ];
2400
+ namespaceBindings.forEach(([targetKey, sourceKey]) => {
2401
+ bindMethod(roomsNamespace, targetKey, roomsApi, sourceKey);
2402
+ });
2403
+ venus.rooms = roomsNamespace;
2404
+ }
2405
+
2406
+ // src/storage/MockStorageApi.ts
2407
+ function createMockStorageApi(storageType, appUrl) {
2408
+ const appIdentifier = appUrl ? generateAppIdentifier(appUrl) : null;
2409
+ let prefix;
2410
+ let syncDelay = 0;
2411
+ switch (storageType) {
2412
+ case "deviceCache":
2413
+ prefix = "venus:app";
2414
+ syncDelay = 0;
2415
+ break;
2416
+ case "appStorage":
2417
+ prefix = "venus:app";
2418
+ syncDelay = 100;
2419
+ break;
2420
+ case "globalStorage":
2421
+ prefix = "venus:global";
2422
+ syncDelay = 100;
2423
+ break;
2424
+ default:
2425
+ throw new Error(`Unknown storage type: ${storageType}`);
2426
+ }
2427
+ prefix = storageType === "globalStorage" || !appIdentifier ? `${prefix}:` : `${prefix}:${appIdentifier}:`;
2428
+ return new MockStorageApi(prefix, syncDelay);
2429
+ }
2430
+ var MockStorageApi = class {
2431
+ constructor(prefix, syncDelay) {
2432
+ __publicField(this, "prefix");
2433
+ __publicField(this, "syncDelay");
2434
+ this.prefix = prefix;
2435
+ this.syncDelay = syncDelay;
2436
+ }
2437
+ async clear() {
2438
+ const fullLength = localStorage.length;
2439
+ for (let i = 0; i < fullLength; i++) {
2440
+ const fullKey = localStorage.key(i);
2441
+ if (fullKey && fullKey.startsWith(this.prefix)) {
2442
+ localStorage.removeItem(fullKey);
2443
+ }
2444
+ }
2445
+ await this.simulateSyncDelay();
2446
+ }
2447
+ async getAllItems() {
2448
+ const items = new Array();
2449
+ const fullLength = localStorage.length;
2450
+ for (let i = 0; i < fullLength; i++) {
2451
+ const fullKey = localStorage.key(i);
2452
+ if (fullKey && fullKey.startsWith(this.prefix)) {
2453
+ const item = localStorage.getItem(fullKey);
2454
+ if (item) {
2455
+ items.push(item);
2456
+ }
2457
+ }
2458
+ }
2459
+ return items;
2460
+ }
2461
+ async getItem(key) {
2462
+ const fullKey = this.buildKey(key);
2463
+ await this.simulateSyncDelay();
2464
+ return localStorage.getItem(fullKey);
2465
+ }
2466
+ async key(index) {
2467
+ const keys = this.keys();
2468
+ if (index < 0 || index >= keys.length) {
2469
+ return null;
2470
+ }
2471
+ await this.simulateSyncDelay();
2472
+ return keys[index];
2473
+ }
2474
+ async length() {
2475
+ return this.keys().length;
2476
+ }
2477
+ async removeItem(key) {
2478
+ const fullKey = this.buildKey(key);
2479
+ await this.simulateSyncDelay();
2480
+ localStorage.removeItem(fullKey);
2481
+ }
2482
+ async setItem(key, item) {
2483
+ const fullKey = this.buildKey(key);
2484
+ await this.simulateSyncDelay();
2485
+ localStorage.setItem(fullKey, item);
2486
+ }
2487
+ async setMultipleItems(entries) {
2488
+ for (const entry of entries) {
2489
+ const fullKey = this.buildKey(entry.key);
2490
+ localStorage.setItem(fullKey, entry.value);
2491
+ }
2492
+ await this.simulateSyncDelay();
2493
+ }
2494
+ async removeMultipleItems(keys) {
2495
+ for (const key of keys) {
2496
+ const fullKey = this.buildKey(key);
2497
+ localStorage.removeItem(fullKey);
2498
+ }
2499
+ await this.simulateSyncDelay();
2500
+ }
2501
+ buildKey(key) {
2502
+ const prefix = this.prefix;
2503
+ return `${prefix}${key}`;
2504
+ }
2505
+ extractKey(fullKey) {
2317
2506
  const prefix = this.prefix;
2318
2507
  return fullKey.substring(prefix.length);
2319
2508
  }
@@ -2447,24 +2636,20 @@ function initializeStorage(venusApiInstance, host) {
2447
2636
  venusApiInstance.globalStorage = host.globalStorage;
2448
2637
  }
2449
2638
 
2450
- // src/simulation/utils.ts
2451
- function sumContributions(contributions) {
2452
- const totals = {};
2453
- for (const profileId in contributions) {
2454
- for (const entityId in contributions[profileId]) {
2455
- const amount = contributions[profileId][entityId] || 0;
2456
- totals[entityId] = (totals[entityId] || 0) + amount;
2457
- }
2458
- }
2459
- return totals;
2460
- }
2461
-
2462
2639
  // src/simulation/RpcSimulationApi.ts
2463
2640
  var RpcSimulationApi = class {
2464
2641
  constructor(rpcClient) {
2465
2642
  __publicField(this, "rpcClient");
2466
2643
  __publicField(this, "_simulationConfig", null);
2644
+ __publicField(this, "subscriptionCallbacks", /* @__PURE__ */ new Map());
2467
2645
  this.rpcClient = rpcClient;
2646
+ this.rpcClient.onNotification(
2647
+ "H5_SIMULATION_UPDATE" /* H5_SIMULATION_UPDATE */,
2648
+ this.handleSimulationUpdate.bind(this)
2649
+ );
2650
+ }
2651
+ isEnabled() {
2652
+ return true;
2468
2653
  }
2469
2654
  async validateSlotAssignmentAsync(containerId, slotId, itemId) {
2470
2655
  return this.rpcClient.call(
@@ -2476,14 +2661,47 @@ var RpcSimulationApi = class {
2476
2661
  }
2477
2662
  );
2478
2663
  }
2479
- sumContributions(contributions) {
2480
- return sumContributions(contributions);
2664
+ async subscribeAsync(options) {
2665
+ this.ensureValidSubscribeOptions(options);
2666
+ const subscriptionId = generateId();
2667
+ this.subscriptionCallbacks.set(subscriptionId, options.onUpdate);
2668
+ try {
2669
+ await this.rpcClient.call("H5_SIMULATION_SUBSCRIBE" /* H5_SIMULATION_SUBSCRIBE */, {
2670
+ subscriptionId,
2671
+ entities: options.entities,
2672
+ tags: options.tags,
2673
+ activeRuns: options.activeRuns,
2674
+ roomId: options.roomId
2675
+ });
2676
+ } catch (error) {
2677
+ this.subscriptionCallbacks.delete(subscriptionId);
2678
+ throw error;
2679
+ }
2680
+ let unsubscribed = false;
2681
+ return () => {
2682
+ if (unsubscribed) {
2683
+ return;
2684
+ }
2685
+ unsubscribed = true;
2686
+ this.subscriptionCallbacks.delete(subscriptionId);
2687
+ void this.rpcClient.call("H5_SIMULATION_UNSUBSCRIBE" /* H5_SIMULATION_UNSUBSCRIBE */, {
2688
+ subscriptionId
2689
+ }).catch((error) => {
2690
+ console.error(
2691
+ "[Venus SDK] Failed to unsubscribe simulation listener",
2692
+ error
2693
+ );
2694
+ });
2695
+ };
2481
2696
  }
2482
2697
  executeBatchOperationsAsync(operations, validateOnly) {
2483
- return this.rpcClient.call("H5_SIMULATION_BATCH_OPERATIONS" /* H5_SIMULATION_BATCH_OPERATIONS */, {
2484
- operations,
2485
- validateOnly
2486
- });
2698
+ return this.rpcClient.call(
2699
+ "H5_SIMULATION_BATCH_OPERATIONS" /* H5_SIMULATION_BATCH_OPERATIONS */,
2700
+ {
2701
+ operations,
2702
+ validateOnly
2703
+ }
2704
+ );
2487
2705
  }
2488
2706
  async getAvailableItemsAsync(containerId, slotId) {
2489
2707
  const response = await this.rpcClient.call(
@@ -2506,17 +2724,23 @@ var RpcSimulationApi = class {
2506
2724
  );
2507
2725
  }
2508
2726
  assignItemToSlotAsync(containerId, slotId, itemId) {
2509
- return this.rpcClient.call("H5_SIMULATION_ASSIGN_ITEM" /* H5_SIMULATION_ASSIGN_ITEM */, {
2510
- containerId,
2511
- slotId,
2512
- itemId
2513
- });
2727
+ return this.rpcClient.call(
2728
+ "H5_SIMULATION_ASSIGN_ITEM" /* H5_SIMULATION_ASSIGN_ITEM */,
2729
+ {
2730
+ containerId,
2731
+ slotId,
2732
+ itemId
2733
+ }
2734
+ );
2514
2735
  }
2515
2736
  removeItemFromSlotAsync(containerId, slotId) {
2516
- return this.rpcClient.call("H5_SIMULATION_REMOVE_ITEM" /* H5_SIMULATION_REMOVE_ITEM */, {
2517
- containerId,
2518
- slotId
2519
- });
2737
+ return this.rpcClient.call(
2738
+ "H5_SIMULATION_REMOVE_ITEM" /* H5_SIMULATION_REMOVE_ITEM */,
2739
+ {
2740
+ containerId,
2741
+ slotId
2742
+ }
2743
+ );
2520
2744
  }
2521
2745
  async getSlotContainersAsync() {
2522
2746
  const response = await this.rpcClient.call(
@@ -2541,7 +2765,6 @@ var RpcSimulationApi = class {
2541
2765
  roomId
2542
2766
  }
2543
2767
  );
2544
- console.log("[Venus SDK] getStateAsync", response);
2545
2768
  if (response.configuration) {
2546
2769
  this._simulationConfig = response.configuration;
2547
2770
  }
@@ -2553,9 +2776,10 @@ var RpcSimulationApi = class {
2553
2776
  }
2554
2777
  const config = await this.rpcClient.call(
2555
2778
  "H5_SIMULATION_GET_CONFIG" /* H5_SIMULATION_GET_CONFIG */,
2556
- {}
2779
+ {
2780
+ roomId
2781
+ }
2557
2782
  );
2558
- console.log("[Venus SDK] getConfigAsync", config);
2559
2783
  if (config) {
2560
2784
  this._simulationConfig = config;
2561
2785
  return config;
@@ -2563,14 +2787,17 @@ var RpcSimulationApi = class {
2563
2787
  throw new Error("No simulation configuration available");
2564
2788
  }
2565
2789
  executeRecipeAsync(recipeId, inputs, options) {
2566
- return this.rpcClient.call("H5_SIMULATION_EXECUTE_RECIPE" /* H5_SIMULATION_EXECUTE_RECIPE */, {
2567
- recipeId,
2568
- inputs,
2569
- roomId: options?.roomId,
2570
- batchAmount: options?.batchAmount,
2571
- allowPartialBatch: options?.allowPartialBatch,
2572
- entity: options?.entity
2573
- });
2790
+ return this.rpcClient.call(
2791
+ "H5_SIMULATION_EXECUTE_RECIPE" /* H5_SIMULATION_EXECUTE_RECIPE */,
2792
+ {
2793
+ recipeId,
2794
+ inputs,
2795
+ roomId: options?.roomId,
2796
+ batchAmount: options?.batchAmount,
2797
+ allowPartialBatch: options?.allowPartialBatch,
2798
+ entity: options?.entity
2799
+ }
2800
+ );
2574
2801
  }
2575
2802
  collectRecipeAsync(runId) {
2576
2803
  return this.rpcClient.call("H5_SIMULATION_COLLECT_RECIPE" /* H5_SIMULATION_COLLECT_RECIPE */, {
@@ -2578,9 +2805,12 @@ var RpcSimulationApi = class {
2578
2805
  });
2579
2806
  }
2580
2807
  getActiveRunsAsync(options) {
2581
- return this.rpcClient.call("H5_SIMULATION_GET_ACTIVE_RUNS" /* H5_SIMULATION_GET_ACTIVE_RUNS */, {
2582
- roomId: options?.roomId
2583
- });
2808
+ return this.rpcClient.call(
2809
+ "H5_SIMULATION_GET_ACTIVE_RUNS" /* H5_SIMULATION_GET_ACTIVE_RUNS */,
2810
+ {
2811
+ roomId: options?.roomId
2812
+ }
2813
+ );
2584
2814
  }
2585
2815
  executeScopedRecipeAsync(recipeId, entity, inputs, options) {
2586
2816
  return this.rpcClient.call(
@@ -2650,583 +2880,52 @@ var RpcSimulationApi = class {
2650
2880
  );
2651
2881
  return response.value;
2652
2882
  }
2653
- };
2654
-
2655
- // src/simulation/MockSimulationApi.ts
2656
- function generateAppIdentifier2() {
2657
- if (typeof window === "undefined") return "unknown-app";
2658
- const url = window.location.href;
2659
- const match = url.match(/\/H5\/([^\/]+)/);
2660
- return match ? match[1] : "unknown-app";
2661
- }
2662
- var MockSimulationApi = class {
2663
- constructor(simulationConfig = null) {
2664
- __publicField(this, "mockSimulationConfigs", /* @__PURE__ */ new Map());
2665
- // appIdentifier -> config
2666
- __publicField(this, "mockSimulationStates", /* @__PURE__ */ new Map());
2667
- // appIdentifier -> config
2668
- __publicField(this, "mockActiveTimers", /* @__PURE__ */ new Map());
2669
- // appIdentifier -> timers[]
2670
- __publicField(this, "appId");
2671
- __publicField(this, "providedSimulationConfig");
2672
- this.appId = generateAppIdentifier2();
2673
- this.providedSimulationConfig = simulationConfig;
2674
- }
2675
- sumContributions(contributions) {
2676
- return sumContributions(contributions);
2677
- }
2678
- async validateSlotAssignmentAsync(containerId, slotId, itemId) {
2679
- this.log("validateSlotAssignmentAsync called:", {
2680
- containerId,
2681
- slotId,
2682
- itemId
2683
- });
2684
- return { valid: true, message: "Mock validation successful" };
2685
- }
2686
- async executeBatchOperationsAsync(operations, validateOnly) {
2687
- this.log("executeBatchOperationsAsync called:", {
2688
- operations,
2689
- validateOnly
2690
- });
2691
- return {
2692
- success: true,
2693
- results: operations.map(() => ({ success: true }))
2694
- };
2695
- }
2696
- async getAvailableItemsAsync(containerId, slotId) {
2697
- console.log("[Venus Simulation Mock] getAvailableItemsAsync called:", {
2698
- containerId,
2699
- slotId
2700
- });
2701
- const appIdentifier = generateAppIdentifier2();
2702
- const mockSimulationConfigs = this.mockSimulationConfigs;
2703
- const config = mockSimulationConfigs.get(appIdentifier) || {
2704
- entities: {}
2705
- };
2706
- const availableItems = Object.entries(config.entities).slice(0, 3).map(([entityId, entity]) => ({
2707
- entityId,
2708
- quantity: 1,
2709
- metadata: entity.metadata,
2710
- powerPreview: 100
2711
- // Mock power value
2712
- }));
2713
- return availableItems;
2714
- }
2715
- async calculatePowerPreviewAsync(containerId, slotId, candidateItemId) {
2716
- this.log("calculatePowerPreviewAsync called:", {
2717
- containerId,
2718
- slotId,
2719
- candidateItemId
2720
- });
2721
- return {
2722
- currentPower: 1e3,
2723
- previewPower: 1200,
2724
- powerDelta: 200,
2725
- breakdown: { base: 800, weapon: 200, armor: 200 }
2726
- };
2727
- }
2728
- async getSlotContainersAsync() {
2729
- this.log("getSlotContainersAsync called");
2730
- const appIdentifier = this.appId;
2731
- const mockSimulationConfigs = this.mockSimulationConfigs;
2732
- const config = mockSimulationConfigs.get(appIdentifier) || {
2733
- entities: {}
2734
- };
2735
- const containers = Object.entries(config.entities).filter(([_, entity]) => entity.metadata?.slots).map(([entityId, entity]) => ({
2736
- entityId,
2737
- slots: entity.metadata?.slots,
2738
- isOwned: true
2739
- // Mock: assume all containers are owned
2740
- }));
2741
- return containers;
2742
- }
2743
- async getSlotAssignmentsAsync(containerId) {
2744
- this.log("getSlotAssignmentsAsync called for:", containerId);
2745
- return [];
2746
- }
2747
- async resolveFieldValueAsync(entityId, fieldPath, entity) {
2748
- this.log("resolveFieldValueAsync called:", {
2749
- entityId,
2750
- fieldPath,
2751
- entity
2752
- });
2753
- const mockValues = {
2754
- basePower: 850,
2755
- weaponPower: 300,
2756
- armorPower: 150,
2757
- total_power: 1300,
2758
- total_defense_power: 5e3
2759
- };
2760
- return mockValues[fieldPath] || 100;
2761
- }
2762
- async getEntityMetadataAsync(entityId) {
2763
- this.log("getEntityMetadataAsync called for:", entityId);
2764
- const mockSimulationConfigs = this.mockSimulationConfigs;
2765
- const appIdentifier = this.appId;
2766
- const config = mockSimulationConfigs.get(
2767
- appIdentifier
2768
- ) || {
2769
- entities: {}};
2770
- const entity = config.entities[entityId];
2771
- return entity?.metadata || {};
2772
- }
2773
- async collectRecipeAsync(runId) {
2774
- this.log("collectRecipeAsync called:", { runId });
2775
- const mockRewards = {
2776
- cash: Math.floor(Math.random() * 1e3) + 500,
2777
- experience: Math.floor(Math.random() * 50) + 25
2778
- };
2779
- return {
2780
- success: true,
2781
- runId,
2782
- rewards: mockRewards,
2783
- message: "Rewards collected successfully"
2784
- };
2785
- }
2786
- executeRecipeAsync(recipeId, inputs, options) {
2787
- this.log("executeRecipeAsync called:", {
2788
- recipeId,
2789
- inputs,
2790
- options
2791
- });
2792
- const appIdentifier = this.appId;
2793
- return this.executeRecipe(appIdentifier, recipeId, inputs);
2794
- }
2795
- async executeScopedRecipeAsync(recipeId, entity, inputs, options) {
2796
- this.log("executeScopedRecipeAsync called:", {
2797
- recipeId,
2798
- entity,
2799
- inputs,
2800
- roomId: options?.roomId,
2801
- options
2802
- });
2803
- return {
2804
- success: true,
2805
- message: "Mock scoped recipe execution successful"
2806
- };
2807
- }
2808
- async getActiveRunsAsync(options) {
2809
- this.log("getActiveRunsAsync called:", options);
2810
- const appIdentifier = this.appId;
2811
- let state = this.mockSimulationStates.get(appIdentifier);
2812
- if (!state) {
2813
- state = await this.initializeSimulationState(appIdentifier);
2814
- }
2815
- return state.activeRuns || [];
2816
- }
2817
- async getAvailableRecipesAsync(options) {
2818
- this.log("getAvailableRecipesAsync called:", options);
2819
- const baseRecipes = [
2820
- { id: "collect_resources", scope: "player", clientViewable: true },
2821
- { id: "upgrade_equipment", scope: "player", clientViewable: true }
2822
- ];
2823
- if (options?.roomId) {
2824
- baseRecipes.push(
2825
- { id: "room_upgrade", scope: "room", clientViewable: true },
2826
- { id: "cooperative_project", scope: "room", clientViewable: true }
2827
- );
2883
+ handleSimulationUpdate(notification) {
2884
+ if (!notification || !notification.subscriptionId) {
2885
+ console.warn("[Venus SDK] Received malformed simulation update");
2886
+ return;
2828
2887
  }
2829
- if (options?.includeActorRecipes && options?.roomId) {
2830
- baseRecipes.push(
2831
- { id: "trade_with_npc", scope: "actor", clientViewable: true },
2832
- { id: "attack_monster", scope: "actor", clientViewable: true }
2888
+ const callback = this.subscriptionCallbacks.get(notification.subscriptionId);
2889
+ if (!callback) {
2890
+ console.warn(
2891
+ "[Venus SDK] Received update for unknown subscription:",
2892
+ notification.subscriptionId
2833
2893
  );
2894
+ return;
2834
2895
  }
2835
- return { success: true, recipes: baseRecipes };
2836
- }
2837
- async getBatchRecipeRequirementsAsync(recipes) {
2838
- this.log("getBatchRecipeRequirementsAsync called:", {
2839
- count: recipes?.length
2840
- });
2841
- const results = (recipes || []).map((q) => ({
2842
- recipeId: q.recipeId,
2843
- entity: q.entity || null,
2844
- amount: q.batchAmount || 1,
2845
- inputs: { cash: "BE:0" },
2846
- canAfford: true,
2847
- disabled: false
2848
- }));
2849
- return { success: true, results };
2850
- }
2851
- async getRecipeRequirementsAsync(recipe) {
2852
- this.log("getRecipeRequirementsAsync called:", recipe);
2853
- return {
2854
- recipeId: recipe.recipeId,
2855
- entity: recipe.entity || null,
2856
- amount: recipe.batchAmount,
2857
- inputs: { cash: "BE:0" },
2858
- canAfford: true,
2859
- disabled: false
2860
- };
2861
- }
2862
- async triggerRecipeChainAsync(recipeId, options) {
2863
- this.log("triggerRecipeChainAsync called:", { recipeId, ...options });
2864
- return {
2865
- success: true,
2866
- message: "Mock recipe chain triggered successfully"
2867
- };
2868
- }
2869
- log(message, ...args) {
2870
- console.log(`[Venus Sim Mock] ${message}`, args);
2871
- }
2872
- async executeRecipe(appIdentifier, recipeId, inputs) {
2873
- this.log(`Executing recipe ${recipeId} for ${appIdentifier}`, inputs);
2874
- const mockSimulationConfigs = this.mockSimulationConfigs;
2875
- const mockSimulationStates = this.mockSimulationStates;
2876
- let config = mockSimulationConfigs.get(appIdentifier);
2877
- let state = mockSimulationStates.get(appIdentifier);
2878
- if (!config || !state) {
2879
- state = await this.initializeSimulationState(appIdentifier);
2880
- config = mockSimulationConfigs.get(appIdentifier);
2881
- if (!config) {
2882
- throw new Error("Failed to initialize simulation config");
2883
- }
2884
- }
2885
- const recipe = config.recipes?.[recipeId];
2886
- if (!recipe) {
2887
- throw new Error(`Recipe ${recipeId} not found`);
2888
- }
2889
- if (state.disabledRecipes?.includes(recipeId)) {
2890
- throw new Error(`Recipe ${recipeId} is disabled`);
2891
- }
2892
- if (recipe.inputs) {
2893
- for (const [entityId, required] of Object.entries(recipe.inputs)) {
2894
- const available = state.inventory[entityId] || 0;
2895
- if (available < required) {
2896
- throw new Error(
2897
- `Insufficient ${entityId}: required ${required}, available ${available}`
2898
- );
2899
- }
2900
- }
2901
- }
2902
- if (recipe.inputs) {
2903
- for (const [entityId, input] of Object.entries(recipe.inputs)) {
2904
- const inventoryValue = state.inventory[entityId] || 0;
2905
- if (typeof input === "number" && typeof inventoryValue === "number") {
2906
- state.inventory[entityId] = inventoryValue - input;
2907
- }
2908
- }
2909
- }
2910
- if (recipe.beginEffects) {
2911
- this.applyEffects(state, recipe.beginEffects);
2912
- }
2913
- const runId = this.generateRunId();
2914
- const now = Date.now();
2915
- const expiresAt = now + (recipe.duration || 0);
2916
- const run = {
2917
- id: runId,
2918
- recipeId,
2919
- status: "running",
2920
- startTime: now,
2921
- expiresAt,
2922
- inputs: recipe.inputs || {}
2923
- };
2924
- state.activeRuns.push(run);
2925
- if (recipe.duration === 0) {
2926
- this.completeRun(appIdentifier, runId);
2927
- return { status: "completed", runId };
2928
- } else {
2929
- const mockActiveTimers = this.mockActiveTimers;
2930
- const timer = setTimeout(() => {
2931
- this.completeRun(appIdentifier, runId);
2932
- }, recipe.duration);
2933
- const timers = mockActiveTimers.get(appIdentifier) || [];
2934
- timers.push(timer);
2935
- mockActiveTimers.set(appIdentifier, timers);
2936
- return {
2937
- status: "running",
2938
- runId,
2939
- expiresAt: new Date(expiresAt).toISOString()
2940
- };
2896
+ try {
2897
+ callback(notification.updates);
2898
+ } catch (error) {
2899
+ console.error("[Venus SDK] Error in simulation subscription callback", error);
2941
2900
  }
2942
2901
  }
2943
- async initializeSimulationState(appIdentifier) {
2944
- this.log(`Initializing simulation state for ${appIdentifier}`);
2945
- const providedSimulationConfig = this.providedSimulationConfig;
2946
- const mockSimulationConfigs = this.mockSimulationConfigs;
2947
- const mockSimulationStates = this.mockSimulationStates;
2948
- const mockActiveTimers = this.mockActiveTimers;
2949
- const config = providedSimulationConfig || {
2950
- version: "1.0",
2951
- entities: {},
2952
- recipes: {}
2953
- };
2954
- mockSimulationConfigs.set(appIdentifier, config);
2955
- const initialInventory = {};
2956
- if (providedSimulationConfig && config.entities) {
2957
- Object.keys(config.entities).forEach((entityId) => {
2958
- initialInventory[entityId] = 0;
2959
- });
2960
- }
2961
- const state = {
2962
- inventory: initialInventory,
2963
- activeRuns: [],
2964
- disabledRecipes: new Array()
2965
- };
2966
- if (config.recipes) {
2967
- Object.entries(config.recipes).forEach(([recipeId, recipe]) => {
2968
- if (recipe.metadata?.startsDisabled) {
2969
- state.disabledRecipes.push(recipeId);
2970
- }
2971
- });
2972
- }
2973
- mockSimulationStates.set(appIdentifier, state);
2974
- mockActiveTimers.set(appIdentifier, []);
2975
- console.log(
2976
- `[Venus Simulation Mock] Initialized state for ${appIdentifier}:`,
2977
- state
2978
- );
2979
- if (config.recipes) {
2980
- Object.entries(config.recipes).forEach(([recipeId, recipe]) => {
2981
- const isAutoRestart = recipe.autoRestart || recipe.metadata?.autoRestart;
2982
- if (isAutoRestart && recipe.outputs) {
2983
- this.log(`Found auto-restart recipe: ${recipeId}`, {
2984
- topLevelAutoRestart: recipe.autoRestart,
2985
- metadataAutoRestart: recipe.metadata?.autoRestart,
2986
- hasOutputs: !!recipe.outputs,
2987
- duration: recipe.duration
2988
- });
2989
- const condition = recipe.maxRestartCondition || recipe.metadata?.maxRestartCondition;
2990
- if (condition && condition.entity) {
2991
- const currentAmount = initialInventory[condition.entity] || 0;
2992
- if (currentAmount < condition.maxValue) {
2993
- console.log(
2994
- `[Venus Simulation Mock] Auto-starting ${recipeId} at initialization`,
2995
- {
2996
- currentAmount,
2997
- maxValue: condition.maxValue,
2998
- entity: condition.entity
2999
- }
3000
- );
3001
- setTimeout(() => {
3002
- this.executeRecipe(appIdentifier, recipeId, {});
3003
- }, 1e3);
3004
- }
3005
- } else {
3006
- console.log(
3007
- `[Venus Simulation Mock] Auto-starting ${recipeId} at initialization (no condition)`
3008
- );
3009
- setTimeout(() => {
3010
- this.executeRecipe(appIdentifier, recipeId, {});
3011
- }, 1e3);
3012
- }
3013
- }
3014
- });
2902
+ ensureValidSubscribeOptions(options) {
2903
+ if (typeof options !== "object" || options === null) {
2904
+ throw new Error("Simulation subscribe requires an options object");
3015
2905
  }
3016
- return state;
3017
- }
3018
- generateRunId() {
3019
- return "run_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9);
3020
- }
3021
- completeRun(appIdentifier, runId) {
3022
- this.log(`Completing run ${runId} for ${appIdentifier}`);
3023
- const mockSimulationConfigs = this.mockSimulationConfigs;
3024
- const mockSimulationStates = this.mockSimulationStates;
3025
- const config = mockSimulationConfigs.get(appIdentifier);
3026
- const state = mockSimulationStates.get(appIdentifier);
3027
- if (!config || !state) return;
3028
- const runIndex = state.activeRuns.findIndex((r) => r.id === runId);
3029
- if (runIndex === -1) return;
3030
- const run = state.activeRuns[runIndex];
3031
- const recipe = config.recipes?.[run.recipeId];
3032
- if (!recipe) return;
3033
- const outputs = {};
3034
- const rng = this.createSeededRandom(runId);
3035
- if (recipe.outputs) {
3036
- for (const [entityId, value] of Object.entries(recipe.outputs)) {
3037
- if (typeof value === "number") {
3038
- outputs[entityId] = value;
3039
- } else if (typeof value === "object" && value != null && "min" in value && "max" in value && typeof value.min == "number" && typeof value.max === "number") {
3040
- outputs[entityId] = Math.floor(rng() * (value.max - value.min + 1)) + value.min;
3041
- }
3042
- }
3043
- }
3044
- for (const [entityId, amount] of Object.entries(outputs)) {
3045
- state.inventory[entityId] = (state.inventory[entityId] || 0) + amount;
3046
- }
3047
- if (recipe.endEffects) {
3048
- this.applyEffects(state, recipe.endEffects);
2906
+ const opts = options;
2907
+ if (typeof opts.onUpdate !== "function") {
2908
+ throw new Error("Simulation subscribe requires an onUpdate callback");
3049
2909
  }
3050
- run.status = "completed";
3051
- run.outputs = outputs;
3052
- state.activeRuns.splice(runIndex, 1);
3053
- const isAutoRestart = recipe.autoRestart || recipe.metadata?.autoRestart;
3054
- if (isAutoRestart) {
3055
- console.log(
3056
- `[Venus Simulation Mock] Checking auto-restart for ${run.recipeId}`,
3057
- {
3058
- topLevelAutoRestart: recipe.autoRestart,
3059
- metadataAutoRestart: recipe.metadata?.autoRestart,
3060
- hasCondition: !!(recipe.maxRestartCondition || recipe.metadata?.maxRestartCondition)
3061
- }
2910
+ const hasFilter = Array.isArray(opts.entities) && opts.entities.length > 0 || Array.isArray(opts.tags) && opts.tags.length > 0 || Boolean(opts.activeRuns);
2911
+ if (!hasFilter) {
2912
+ throw new Error(
2913
+ "Simulation subscribe requires at least one filter (entities, tags, activeRuns)"
3062
2914
  );
3063
- const condition = recipe.maxRestartCondition || recipe.metadata?.maxRestartCondition;
3064
- if (condition) {
3065
- const currentAmount = state.inventory[condition.entity] || 0;
3066
- if (currentAmount < condition.maxValue) {
3067
- console.log(
3068
- `[Venus Simulation Mock] Auto-restarting ${run.recipeId}`,
3069
- {
3070
- currentAmount,
3071
- maxValue: condition.maxValue,
3072
- entity: condition.entity
3073
- }
3074
- );
3075
- setTimeout(() => {
3076
- this.executeRecipe(appIdentifier, run.recipeId, recipe.inputs || {});
3077
- }, 1e3);
3078
- }
3079
- } else {
3080
- console.log(
3081
- `[Venus Simulation Mock] Auto-restarting ${run.recipeId} (no condition)`
3082
- );
3083
- setTimeout(() => {
3084
- this.executeRecipe(appIdentifier, run.recipeId, recipe.inputs || {});
3085
- }, 1e3);
3086
- }
3087
- }
3088
- console.log(
3089
- `[Venus Simulation Mock] Completed run ${runId}, outputs:`,
3090
- outputs
3091
- );
3092
- }
3093
- createSeededRandom(seed) {
3094
- let hash = 0;
3095
- for (let i = 0; i < seed.length; i++) {
3096
- const char = seed.charCodeAt(i);
3097
- hash = (hash << 5) - hash + char;
3098
- hash = hash & hash;
3099
- }
3100
- return () => {
3101
- hash = (hash * 9301 + 49297) % 233280;
3102
- return hash / 233280;
3103
- };
3104
- }
3105
- applyEffects(state, effects) {
3106
- if (!effects || !Array.isArray(effects)) return;
3107
- for (const effect of effects) {
3108
- switch (effect.type) {
3109
- case "set":
3110
- state.inventory[effect.target] = effect.value;
3111
- console.log(
3112
- `[Venus Simulation Mock] Effect: Set ${effect.target} = ${effect.value}`
3113
- );
3114
- break;
3115
- case "add":
3116
- state.inventory[effect.target] = (state.inventory[effect.target] || 0) + effect.value;
3117
- console.log(
3118
- `[Venus Simulation Mock] Effect: Add ${effect.value} to ${effect.target} (new value: ${state.inventory[effect.target]})`
3119
- );
3120
- break;
3121
- case "multiply":
3122
- state.inventory[effect.target] = (state.inventory[effect.target] || 0) * effect.value;
3123
- console.log(
3124
- `[Venus Simulation Mock] Effect: Multiply ${effect.target} by ${effect.value} (new value: ${state.inventory[effect.target]})`
3125
- );
3126
- break;
3127
- case "min":
3128
- state.inventory[effect.target] = Math.max(
3129
- state.inventory[effect.target] || 0,
3130
- effect.value
3131
- );
3132
- console.log(
3133
- `[Venus Simulation Mock] Effect: Set ${effect.target} min ${effect.value} (new value: ${state.inventory[effect.target]})`
3134
- );
3135
- break;
3136
- case "max":
3137
- state.inventory[effect.target] = Math.min(
3138
- state.inventory[effect.target] || 0,
3139
- effect.value
3140
- );
3141
- console.log(
3142
- `[Venus Simulation Mock] Effect: Set ${effect.target} max ${effect.value} (new value: ${state.inventory[effect.target]})`
3143
- );
3144
- break;
3145
- case "enable_recipe":
3146
- if (state.disabledRecipes?.includes(effect.target)) {
3147
- state.disabledRecipes = state.disabledRecipes.filter(
3148
- (r) => r !== effect.target
3149
- );
3150
- console.log(
3151
- `[Venus Simulation Mock] Effect: Enabled recipe ${effect.target}`
3152
- );
3153
- }
3154
- break;
3155
- case "disable_recipe":
3156
- if (!state.disabledRecipes) state.disabledRecipes = [];
3157
- if (!state.disabledRecipes.includes(effect.target)) {
3158
- state.disabledRecipes.push(effect.target);
3159
- console.log(
3160
- `[Venus Simulation Mock] Effect: Disabled recipe ${effect.target}`
3161
- );
3162
- }
3163
- break;
3164
- case "trigger_recipe":
3165
- console.log(
3166
- `[Venus Simulation Mock] Effect: Trigger recipe ${effect.target} (not implemented)`
3167
- );
3168
- break;
3169
- default:
3170
- console.warn(
3171
- `[Venus Simulation Mock] Unknown effect type: ${effect.type}`
3172
- );
3173
- }
3174
2915
  }
3175
2916
  }
3176
- async getConfigAsync() {
3177
- console.log("[Venus Simulation Mock] getConfigAsync called");
3178
- const appIdentifier = this.appId;
3179
- const mockSimulationConfigs = this.mockSimulationConfigs;
3180
- const config = mockSimulationConfigs.get(appIdentifier) || {
3181
- version: "1.0",
3182
- entities: {},
3183
- recipes: {}
3184
- };
3185
- return config;
3186
- }
3187
- async getStateAsync(roomId) {
3188
- this.log("getStateAsync called:", roomId);
3189
- const appIdentifier = this.appId;
3190
- const mockSimulationStates = this.mockSimulationStates;
3191
- let state = mockSimulationStates.get(appIdentifier);
3192
- if (!state) {
3193
- state = await this.initializeSimulationState(appIdentifier);
3194
- }
3195
- const mockSimulationConfigs = this.mockSimulationConfigs;
3196
- return {
3197
- ...state,
3198
- roomId,
3199
- configuration: mockSimulationConfigs.get(appIdentifier)
3200
- };
3201
- }
3202
- async assignItemToSlotAsync(containerId, slotId, itemId) {
3203
- this.log("assignItemToSlotAsync called:", {
3204
- containerId,
3205
- slotId,
3206
- itemId
3207
- });
3208
- return { success: true, message: "Mock assignment successful" };
3209
- }
3210
- async removeItemFromSlotAsync(containerId, slotId) {
3211
- this.log("removeItemFromSlotAsync called:", {
3212
- containerId,
3213
- slotId
3214
- });
3215
- return { success: true, message: "Mock removal successful" };
3216
- }
3217
2917
  };
3218
2918
 
3219
2919
  // src/simulation/index.ts
3220
2920
  function initializeSimulation(venusApi, host) {
3221
- console.log("[Venus SDK] Initializing new Simulation Api");
3222
2921
  venusApi.simulation = {
3223
2922
  isEnabled: () => true
3224
2923
  };
3225
2924
  venusApi.simulation.getConfigAsync = () => {
3226
2925
  return host.simulation.getConfigAsync();
3227
2926
  };
3228
- venusApi.simulation.getStateAsync = (options) => {
3229
- return host.simulation.getStateAsync(options?.roomId);
2927
+ venusApi.simulation.getStateAsync = (roomId) => {
2928
+ return host.simulation.getStateAsync(roomId);
3230
2929
  };
3231
2930
  venusApi.simulation.executeRecipeAsync = (recipeId, inputs, options) => {
3232
2931
  return host.simulation.executeRecipeAsync(recipeId, inputs, options);
@@ -3237,31 +2936,17 @@ function initializeSimulation(venusApi, host) {
3237
2936
  venusApi.simulation.collectRecipeAsync = (runId) => {
3238
2937
  return host.simulation.collectRecipeAsync(runId);
3239
2938
  };
3240
- venusApi.simulation.executeScopedRecipeAsync = (recipeId, entity, inputs, roomId, options) => {
3241
- return host.simulation.executeScopedRecipeAsync(recipeId, entity, inputs, {
3242
- roomId,
3243
- ...options
3244
- });
2939
+ venusApi.simulation.executeScopedRecipeAsync = (recipeId, entity, inputs, options) => {
2940
+ return host.simulation.executeScopedRecipeAsync(recipeId, entity, inputs, options);
3245
2941
  };
3246
- venusApi.simulation.triggerRecipeChainAsync = (recipeId, context, roomId) => {
3247
- return host.simulation.triggerRecipeChainAsync(recipeId, {
3248
- context,
3249
- roomId
3250
- });
2942
+ venusApi.simulation.triggerRecipeChainAsync = (recipeId, options) => {
2943
+ return host.simulation.triggerRecipeChainAsync(recipeId, options);
3251
2944
  };
3252
- venusApi.simulation.getAvailableRecipesAsync = async (roomId, includeActorRecipes) => {
3253
- const result = await host.simulation.getAvailableRecipesAsync({
3254
- roomId,
3255
- includeActorRecipes
3256
- });
3257
- return result.recipes;
2945
+ venusApi.simulation.getAvailableRecipesAsync = async (options) => {
2946
+ return host.simulation.getAvailableRecipesAsync(options);
3258
2947
  };
3259
- venusApi.simulation.getRecipeRequirementsAsync = (recipeId, entity, amount) => {
3260
- return host.simulation.getRecipeRequirementsAsync({
3261
- recipeId,
3262
- entity,
3263
- batchAmount: amount
3264
- });
2948
+ venusApi.simulation.getRecipeRequirementsAsync = (recipe) => {
2949
+ return host.simulation.getRecipeRequirementsAsync(recipe);
3265
2950
  };
3266
2951
  venusApi.simulation.getBatchRecipeRequirementsAsync = (recipes) => {
3267
2952
  return host.simulation.getBatchRecipeRequirementsAsync(recipes);
@@ -3304,9 +2989,6 @@ function initializeSimulation(venusApi, host) {
3304
2989
  itemId
3305
2990
  );
3306
2991
  };
3307
- venusApi.simulation.sumContributions = (contributions) => {
3308
- return host.simulation.sumContributions(contributions);
3309
- };
3310
2992
  }
3311
2993
 
3312
2994
  // src/time/utils.ts
@@ -3325,9 +3007,11 @@ function isPacificDaylightTime(date) {
3325
3007
 
3326
3008
  // src/time/HostTimeApi.ts
3327
3009
  var HostTimeApi = class {
3328
- constructor(rpcClient) {
3010
+ constructor(rpcClient, venusApi) {
3329
3011
  __publicField(this, "rpcClient");
3012
+ __publicField(this, "venusApi");
3330
3013
  this.rpcClient = rpcClient;
3014
+ this.venusApi = venusApi;
3331
3015
  }
3332
3016
  async requestTimeAsync() {
3333
3017
  const response = await this.rpcClient.call(
@@ -3337,13 +3021,7 @@ var HostTimeApi = class {
3337
3021
  return response;
3338
3022
  }
3339
3023
  formatTime(timestamp, options) {
3340
- let locale = "en-US";
3341
- const windowVenus = window.venus;
3342
- if (windowVenus._config.locale) {
3343
- locale = windowVenus._config.locale;
3344
- } else if (windowVenus._config.environment && windowVenus._config.environment.browserInfo && windowVenus._config.environment.browserInfo.language) {
3345
- locale = windowVenus._config.environment.browserInfo.language;
3346
- }
3024
+ const locale = this.venusApi.getLocale();
3347
3025
  const date = new Date(timestamp);
3348
3026
  const dateTimeOptions = {
3349
3027
  dateStyle: options.dateStyle || "medium",
@@ -3355,13 +3033,7 @@ var HostTimeApi = class {
3355
3033
  }
3356
3034
  formatNumber(value, options) {
3357
3035
  try {
3358
- let locale = "en-US";
3359
- const windowVenus = window.venus;
3360
- if (windowVenus._config.locale) {
3361
- locale = windowVenus._config.locale;
3362
- } else if (windowVenus._config.environment && windowVenus._config.environment.browserInfo && windowVenus._config.environment.browserInfo.language) {
3363
- locale = windowVenus._config.environment.browserInfo.language;
3364
- }
3036
+ const locale = this.venusApi.getLocale();
3365
3037
  const numberOptions = {
3366
3038
  style: options?.style || "decimal",
3367
3039
  minimumFractionDigits: options?.minimumFractionDigits || 0,
@@ -3424,18 +3096,17 @@ var MockTimeApi = class {
3424
3096
  this.venusApi = venusApi;
3425
3097
  }
3426
3098
  formatNumber(value, options) {
3427
- const locale = this.getLocale();
3099
+ const locale = this.venusApi.getLocale();
3428
3100
  const numberOptions = {
3429
3101
  style: options?.style || "decimal",
3430
3102
  minimumFractionDigits: options?.minimumFractionDigits || 0,
3431
3103
  maximumFractionDigits: options?.maximumFractionDigits || 2,
3432
3104
  ...options
3433
3105
  };
3434
- console.log(`[Venus Mock] Formatting number ${value} with locale ${locale}`);
3435
3106
  return value.toLocaleString(locale, numberOptions);
3436
3107
  }
3437
3108
  formatTime(timestamp, options) {
3438
- const locale = this.getLocale();
3109
+ const locale = this.venusApi.getLocale();
3439
3110
  const date = new Date(timestamp);
3440
3111
  const dateTimeOptions = {
3441
3112
  dateStyle: options.dateStyle || "medium",
@@ -3443,13 +3114,9 @@ var MockTimeApi = class {
3443
3114
  hour12: options.hour12 !== void 0 ? options.hour12 : true,
3444
3115
  ...options
3445
3116
  };
3446
- console.log(
3447
- `[Venus Mock] Formatting time ${timestamp} with locale ${locale}`
3448
- );
3449
3117
  return date.toLocaleString(locale, dateTimeOptions);
3450
3118
  }
3451
3119
  async getFutureTimeAsync(options) {
3452
- console.log("[Venus Mock] Getting future time with options:", options);
3453
3120
  const timeInfo = await this.requestTimeAsync();
3454
3121
  const serverTime = new Date(timeInfo.serverTime);
3455
3122
  const result = new Date(serverTime);
@@ -3494,7 +3161,6 @@ var MockTimeApi = class {
3494
3161
  return result.getTime();
3495
3162
  }
3496
3163
  async requestTimeAsync() {
3497
- console.log("[Venus Mock] Requesting time");
3498
3164
  await createMockDelay(MOCK_DELAYS.short);
3499
3165
  const venusApi = this.venusApi;
3500
3166
  const mockOffset = venusApi._mock.serverTimeOffset || 2500;
@@ -3508,23 +3174,8 @@ var MockTimeApi = class {
3508
3174
  formattedTime: new Date(localTime).toISOString(),
3509
3175
  locale: venusApi._mock.user?.locale || "en-US"
3510
3176
  };
3511
- console.log("[Venus Mock] Time response:", {
3512
- serverTime: new Date(timeInfo.serverTime).toISOString(),
3513
- localTime: new Date(timeInfo.localTime).toISOString(),
3514
- timezoneOffset: timeInfo.timezoneOffset
3515
- });
3516
3177
  return timeInfo;
3517
3178
  }
3518
- getLocale() {
3519
- const venusApi = this.venusApi;
3520
- let locale = "en-US";
3521
- if (venusApi._mock.user && venusApi._mock.user.locale) {
3522
- locale = venusApi._mock.user.locale;
3523
- } else if (venusApi._mock.environment && venusApi._mock.environment.browserInfo.language) {
3524
- locale = venusApi._mock.environment.browserInfo.language;
3525
- }
3526
- return locale;
3527
- }
3528
3179
  };
3529
3180
 
3530
3181
  // src/time/index.ts
@@ -3544,7 +3195,7 @@ function initializeTime(venusApi, host) {
3544
3195
  }
3545
3196
 
3546
3197
  // src/version.ts
3547
- var SDK_VERSION = "3.0.3";
3198
+ var SDK_VERSION = "3.0.5";
3548
3199
 
3549
3200
  // src/shared-assets/consts.ts
3550
3201
  var BurgerTimeAssetsCdnPath = "burger-time/Core.stow";
@@ -3615,47 +3266,106 @@ var MockSharedAssetsApi = class {
3615
3266
  }
3616
3267
  };
3617
3268
 
3269
+ // src/leaderboard/utils.ts
3270
+ var HASH_ALGORITHM_WEB_CRYPTO = "SHA-256";
3271
+ var HASH_ALGORITHM_NODE = "sha256";
3272
+ async function computeScoreHash(score, duration, token, sealingNonce, sealingSecret) {
3273
+ const payload = `score:${score}|duration:${duration}|token:${token}`;
3274
+ const fullPayload = `${payload}|nonce:${sealingNonce}`;
3275
+ const encoder = new TextEncoder();
3276
+ const keyData = encoder.encode(sealingSecret);
3277
+ const messageData = encoder.encode(fullPayload);
3278
+ const cryptoKey = await crypto.subtle.importKey(
3279
+ "raw",
3280
+ keyData,
3281
+ { name: "HMAC", hash: HASH_ALGORITHM_WEB_CRYPTO },
3282
+ false,
3283
+ ["sign"]
3284
+ );
3285
+ const signature = await crypto.subtle.sign("HMAC", cryptoKey, messageData);
3286
+ return Array.from(new Uint8Array(signature)).map((b) => b.toString(16).padStart(2, "0")).join("");
3287
+ }
3288
+
3618
3289
  // src/leaderboard/RpcLeaderboardApi.ts
3619
3290
  var RpcLeaderboardApi = class {
3620
3291
  constructor(rpcClient) {
3621
3292
  __publicField(this, "rpcClient");
3293
+ /** Cache of score tokens for automatic hash computation */
3294
+ __publicField(this, "tokenCache", /* @__PURE__ */ new Map());
3622
3295
  this.rpcClient = rpcClient;
3623
3296
  }
3624
- startRun(mode) {
3625
- return this.rpcClient.call(
3626
- "H5_LEADERBOARD_START_RUN" /* H5_LEADERBOARD_START_RUN */,
3297
+ /**
3298
+ * Create a score token for submitting a score.
3299
+ * Token is cached for automatic hash computation if score sealing is enabled.
3300
+ *
3301
+ * @param mode - Optional game mode
3302
+ * @returns Score token with sealing data if enabled
3303
+ */
3304
+ async createScoreToken(mode) {
3305
+ const token = await this.rpcClient.call(
3306
+ "H5_LEADERBOARD_CREATE_SCORE_TOKEN" /* H5_LEADERBOARD_CREATE_SCORE_TOKEN */,
3627
3307
  mode ? { mode } : {}
3628
3308
  );
3309
+ this.tokenCache.set(token.token, token);
3310
+ return token;
3629
3311
  }
3630
- submitScore(sessionId, score, durationSec, options) {
3312
+ /**
3313
+ * Submit a score to the leaderboard.
3314
+ * Automatically computes hash if score sealing is enabled and token was created via createScoreToken().
3315
+ *
3316
+ * @param params - Score submission parameters
3317
+ * @returns Submission result with acceptance status and rank
3318
+ * @throws Error if token not found in cache
3319
+ */
3320
+ async submitScore(params) {
3321
+ let hash;
3322
+ if (params.token) {
3323
+ const cachedToken = this.tokenCache.get(params.token);
3324
+ if (!cachedToken) {
3325
+ throw new Error(
3326
+ "Invalid token: not found in cache. Did you call createScoreToken() first?"
3327
+ );
3328
+ }
3329
+ if (cachedToken.sealingNonce && cachedToken.sealingSecret) {
3330
+ hash = await computeScoreHash(
3331
+ params.score,
3332
+ params.duration,
3333
+ params.token,
3334
+ cachedToken.sealingNonce,
3335
+ cachedToken.sealingSecret
3336
+ );
3337
+ }
3338
+ this.tokenCache.delete(params.token);
3339
+ }
3631
3340
  return this.rpcClient.call(
3632
3341
  "H5_LEADERBOARD_SUBMIT_SCORE" /* H5_LEADERBOARD_SUBMIT_SCORE */,
3633
3342
  {
3634
- sessionId,
3635
- score,
3636
- durationSec,
3637
- mode: options?.mode,
3638
- telemetry: options?.telemetry,
3639
- metadata: options?.metadata,
3640
- hash: options?.hash
3343
+ token: params.token,
3344
+ score: params.score,
3345
+ duration: params.duration,
3346
+ mode: params.mode,
3347
+ telemetry: params.telemetry,
3348
+ metadata: params.metadata,
3349
+ hash
3350
+ // undefined if no sealing, computed if sealing enabled
3641
3351
  }
3642
3352
  );
3643
3353
  }
3644
- getLeaderboard(options) {
3354
+ getPagedScores(options) {
3645
3355
  return this.rpcClient.call(
3646
- "H5_LEADERBOARD_GET" /* H5_LEADERBOARD_GET */,
3356
+ "H5_LEADERBOARD_GET_PAGED_SCORES" /* H5_LEADERBOARD_GET_PAGED_SCORES */,
3647
3357
  options ?? {}
3648
3358
  );
3649
3359
  }
3650
- getPlayerStats(options) {
3360
+ getMyRank(options) {
3651
3361
  return this.rpcClient.call(
3652
- "H5_LEADERBOARD_GET_PLAYER_STATS" /* H5_LEADERBOARD_GET_PLAYER_STATS */,
3362
+ "H5_LEADERBOARD_GET_MY_RANK" /* H5_LEADERBOARD_GET_MY_RANK */,
3653
3363
  options ?? {}
3654
3364
  );
3655
3365
  }
3656
- getLeaderboardHighlight(options) {
3366
+ getPodiumScores(options) {
3657
3367
  return this.rpcClient.call(
3658
- "H5_LEADERBOARD_GET_HIGHLIGHT" /* H5_LEADERBOARD_GET_HIGHLIGHT */,
3368
+ "H5_LEADERBOARD_GET_PODIUM_SCORES" /* H5_LEADERBOARD_GET_PODIUM_SCORES */,
3659
3369
  options ?? {}
3660
3370
  );
3661
3371
  }
@@ -3664,17 +3374,31 @@ var RpcLeaderboardApi = class {
3664
3374
  // src/leaderboard/MockLeaderboardApi.ts
3665
3375
  var MockLeaderboardApi = class {
3666
3376
  constructor(options) {
3667
- __publicField(this, "sessions", /* @__PURE__ */ new Map());
3377
+ __publicField(this, "tokens", /* @__PURE__ */ new Map());
3378
+ /** Cache of score tokens for automatic hash computation */
3379
+ __publicField(this, "tokenCache", /* @__PURE__ */ new Map());
3668
3380
  __publicField(this, "entriesByMode", /* @__PURE__ */ new Map());
3669
- __publicField(this, "sessionCounter", 0);
3670
- __publicField(this, "requiresHash", false);
3671
- if (options?.requiresHash) {
3672
- this.requiresHash = true;
3381
+ __publicField(this, "tokenCounter", 0);
3382
+ __publicField(this, "enableScoreSealing", false);
3383
+ __publicField(this, "scoreSealingSecret", "mock-leaderboard-secret-key");
3384
+ if (options?.enableScoreSealing) {
3385
+ this.enableScoreSealing = true;
3386
+ }
3387
+ if (options?.scoreSealingSecret) {
3388
+ this.scoreSealingSecret = options.scoreSealingSecret;
3673
3389
  }
3674
3390
  }
3391
+ /**
3392
+ * Configure mock leaderboard settings
3393
+ *
3394
+ * @param options - Configuration options
3395
+ */
3675
3396
  configure(options) {
3676
- if (typeof options.requiresHash === "boolean") {
3677
- this.requiresHash = options.requiresHash;
3397
+ if (typeof options.enableScoreSealing === "boolean") {
3398
+ this.enableScoreSealing = options.enableScoreSealing;
3399
+ }
3400
+ if (options.scoreSealingSecret) {
3401
+ this.scoreSealingSecret = options.scoreSealingSecret;
3678
3402
  }
3679
3403
  }
3680
3404
  generateNonce() {
@@ -3691,83 +3415,149 @@ var MockLeaderboardApi = class {
3691
3415
  }
3692
3416
  return this.entriesByMode.get(key);
3693
3417
  }
3694
- async startRun(mode) {
3695
- const sessionId = `mock_session_${++this.sessionCounter}`;
3418
+ /**
3419
+ * Create a mock score token for testing.
3420
+ * Token is cached for automatic hash computation if score sealing is enabled.
3421
+ *
3422
+ * @param mode - Optional game mode
3423
+ * @returns Score token with sealing data if enabled
3424
+ */
3425
+ async createScoreToken(mode) {
3426
+ const token = `mock_token_${++this.tokenCounter}`;
3696
3427
  const startTime = Date.now();
3697
3428
  const expiresAt = startTime + 36e5;
3698
3429
  const resolvedMode = mode || "default";
3699
- const hashNonce = this.requiresHash ? this.generateNonce() : null;
3700
- this.sessions.set(sessionId, {
3701
- id: sessionId,
3430
+ const sealingNonce = this.enableScoreSealing ? this.generateNonce() : null;
3431
+ const sealingSecret = this.enableScoreSealing ? this.scoreSealingSecret : null;
3432
+ this.tokens.set(token, {
3433
+ id: token,
3702
3434
  expiresAt,
3703
3435
  mode: resolvedMode,
3704
- hashNonce,
3436
+ sealingNonce,
3705
3437
  used: false
3706
3438
  });
3707
- return {
3708
- sessionId,
3439
+ const result = {
3440
+ token,
3709
3441
  startTime,
3710
3442
  expiresAt,
3711
- hashNonce,
3443
+ sealingNonce,
3444
+ sealingSecret,
3712
3445
  mode: resolvedMode
3713
3446
  };
3447
+ this.tokenCache.set(token, result);
3448
+ return result;
3714
3449
  }
3715
- async submitScore(sessionId, score, durationSec, options) {
3716
- const session = this.sessions.get(sessionId);
3717
- if (!session) {
3718
- throw new Error("Invalid leaderboard session");
3450
+ /**
3451
+ * Submit a mock score to the leaderboard.
3452
+ * Automatically computes hash if score sealing is enabled and token was created via createScoreToken().
3453
+ *
3454
+ * @param params - Score submission parameters
3455
+ * @returns Submission result with acceptance status and rank
3456
+ * @throws Error if token not found in cache or validation fails
3457
+ */
3458
+ async submitScore(params) {
3459
+ let hash;
3460
+ if (params.token) {
3461
+ const cachedToken = this.tokenCache.get(params.token);
3462
+ if (!cachedToken) {
3463
+ throw new Error(
3464
+ "Invalid token: not found in cache. Did you call createScoreToken() first?"
3465
+ );
3466
+ }
3467
+ if (cachedToken.sealingNonce && cachedToken.sealingSecret) {
3468
+ hash = await computeScoreHash(
3469
+ params.score,
3470
+ params.duration,
3471
+ params.token,
3472
+ cachedToken.sealingNonce,
3473
+ cachedToken.sealingSecret
3474
+ );
3475
+ }
3476
+ }
3477
+ if (!params.token) {
3478
+ const mode = params.mode || "default";
3479
+ const submittedAt2 = Date.now();
3480
+ const entry2 = {
3481
+ profileId: `mock_profile`,
3482
+ username: "Mock Player",
3483
+ avatarUrl: null,
3484
+ score: params.score,
3485
+ duration: params.duration,
3486
+ submittedAt: submittedAt2,
3487
+ token: "simple-mode",
3488
+ rank: null,
3489
+ zScore: null,
3490
+ isAnomaly: false,
3491
+ trustScore: 50,
3492
+ metadata: params.metadata ?? null,
3493
+ isSeed: false
3494
+ };
3495
+ const modeEntries2 = this.getEntriesForMode(mode);
3496
+ modeEntries2.push(entry2);
3497
+ modeEntries2.sort((a, b) => {
3498
+ if (b.score !== a.score) return b.score - a.score;
3499
+ return a.submittedAt - b.submittedAt;
3500
+ });
3501
+ modeEntries2.forEach((e, index) => {
3502
+ modeEntries2[index] = { ...e, rank: index + 1 };
3503
+ });
3504
+ const inserted2 = modeEntries2.find((e) => e.submittedAt === submittedAt2);
3505
+ return {
3506
+ accepted: true,
3507
+ rank: inserted2?.rank ?? null
3508
+ };
3509
+ }
3510
+ const scoreToken = this.tokens.get(params.token);
3511
+ if (!scoreToken) {
3512
+ throw new Error("Invalid score token");
3719
3513
  }
3720
- if (session.expiresAt < Date.now()) {
3721
- throw new Error("Invalid or expired leaderboard session");
3514
+ if (scoreToken.expiresAt < Date.now()) {
3515
+ throw new Error("Invalid or expired score token");
3722
3516
  }
3723
- if (session.used) {
3724
- throw new Error("Leaderboard session already used");
3517
+ if (scoreToken.used) {
3518
+ throw new Error("Score token already used");
3725
3519
  }
3726
- if (options?.mode && options.mode !== session.mode) {
3727
- throw new Error("Submission mode does not match session mode");
3520
+ if (params.mode && params.mode !== scoreToken.mode) {
3521
+ throw new Error("Submission mode does not match token mode");
3728
3522
  }
3729
- if (session.hashNonce && !options?.hash) {
3730
- throw new Error("Score hash is required for sealed leaderboard submissions");
3523
+ if (scoreToken.sealingNonce && !hash) {
3524
+ throw new Error("Score hash required when score sealing is enabled");
3731
3525
  }
3732
3526
  const submittedAt = Date.now();
3733
3527
  const entry = {
3734
3528
  profileId: `mock_profile`,
3735
3529
  username: "Mock Player",
3736
3530
  avatarUrl: null,
3737
- score,
3738
- durationSec,
3531
+ score: params.score,
3532
+ duration: params.duration,
3739
3533
  submittedAt,
3740
- sessionId,
3534
+ token: params.token,
3741
3535
  rank: null,
3742
3536
  zScore: null,
3743
3537
  isAnomaly: false,
3744
3538
  trustScore: 50,
3745
- metadata: options?.metadata ?? null,
3539
+ metadata: params.metadata ?? null,
3746
3540
  isSeed: false
3747
3541
  };
3748
- const modeEntries = this.getEntriesForMode(session.mode);
3542
+ const modeEntries = this.getEntriesForMode(scoreToken.mode);
3749
3543
  modeEntries.push(entry);
3750
3544
  modeEntries.sort((a, b) => {
3751
- if (b.score !== a.score) {
3752
- return b.score - a.score;
3753
- }
3545
+ if (b.score !== a.score) return b.score - a.score;
3754
3546
  return a.submittedAt - b.submittedAt;
3755
3547
  });
3756
3548
  modeEntries.forEach((e, index) => {
3757
- modeEntries[index] = {
3758
- ...e,
3759
- rank: index + 1
3760
- };
3549
+ modeEntries[index] = { ...e, rank: index + 1 };
3761
3550
  });
3762
- session.used = true;
3763
- session.hashNonce = null;
3764
- const inserted = modeEntries.find((e) => e.sessionId === sessionId && e.submittedAt === submittedAt);
3551
+ scoreToken.used = true;
3552
+ scoreToken.sealingNonce = null;
3553
+ this.tokenCache.delete(params.token);
3554
+ const inserted = modeEntries.find((e) => e.token === params.token && e.submittedAt === submittedAt);
3765
3555
  return {
3766
3556
  accepted: true,
3767
3557
  rank: inserted?.rank ?? null
3768
3558
  };
3769
3559
  }
3770
- async getLeaderboard(options) {
3560
+ async getPagedScores(options) {
3771
3561
  const limit = options?.limit ?? 10;
3772
3562
  const mode = options?.mode ?? "default";
3773
3563
  const modeEntries = [...this.getEntriesForMode(mode)];
@@ -3783,7 +3573,7 @@ var MockLeaderboardApi = class {
3783
3573
  periodInstance: options?.period ?? "alltime"
3784
3574
  };
3785
3575
  }
3786
- async getPlayerStats(_options) {
3576
+ async getMyRank(_options) {
3787
3577
  const mode = _options?.mode ?? "default";
3788
3578
  const modeEntries = this.getEntriesForMode(mode);
3789
3579
  const playerEntry = modeEntries[0] ?? null;
@@ -3796,7 +3586,7 @@ var MockLeaderboardApi = class {
3796
3586
  periodInstance: _options?.period ?? "alltime"
3797
3587
  };
3798
3588
  }
3799
- async getLeaderboardHighlight(options) {
3589
+ async getPodiumScores(options) {
3800
3590
  const mode = options?.mode ?? "default";
3801
3591
  const modeEntries = [...this.getEntriesForMode(mode)];
3802
3592
  const topCount = Math.max(1, Math.min(options?.topCount ?? 3, 10));
@@ -3908,7 +3698,6 @@ var MockPostApi = class {
3908
3698
  }
3909
3699
  async toggleFollowAsync() {
3910
3700
  const venusApi = this.venusApi;
3911
- console.log("[Venus Mock] *Toggling follow status");
3912
3701
  await createMockDelay(MOCK_DELAYS.short);
3913
3702
  venusApi._mock.currentPostInteractions.isFollowing = !venusApi._mock.currentPostInteractions.isFollowing;
3914
3703
  const isFollowing = venusApi._mock.currentPostInteractions.isFollowing;
@@ -4079,6 +3868,16 @@ var VenusTransport = class {
4079
3868
  this.isProcessingMessage = false;
4080
3869
  return;
4081
3870
  }
3871
+ if (message.type === "H5_SIMULATION_UPDATE" /* H5_SIMULATION_UPDATE */) {
3872
+ const notification = {
3873
+ type: "rpc-notification",
3874
+ id: message.type,
3875
+ payload: message.data
3876
+ };
3877
+ this.handleNotification(notification);
3878
+ this.isProcessingMessage = false;
3879
+ return;
3880
+ }
4082
3881
  const requestId = messageData.requestId;
4083
3882
  if (!requestId) {
4084
3883
  this.logWarn("No requestId. Ignoring message...");
@@ -4245,294 +4044,6 @@ var VenusTransport = class {
4245
4044
  }
4246
4045
  };
4247
4046
 
4248
- // src/RemoteHost.ts
4249
- init_rooms();
4250
-
4251
- // src/rooms/RpcRoomsApi.ts
4252
- init_VenusRoom();
4253
- var RpcRoomsApi = class {
4254
- constructor(rpcClient) {
4255
- __publicField(this, "rpcClient");
4256
- __publicField(this, "subscriptions");
4257
- __publicField(this, "transportSubscription", null);
4258
- this.rpcClient = rpcClient;
4259
- this.subscriptions = {
4260
- data: {},
4261
- messages: {},
4262
- gameEvents: {},
4263
- allEvents: {}
4264
- };
4265
- }
4266
- /**
4267
- * Get the subscription state for external access (used by setupRoomNotifications)
4268
- */
4269
- getSubscriptions() {
4270
- return this.subscriptions;
4271
- }
4272
- /**
4273
- * Set up room notification routing from the transport
4274
- */
4275
- setupNotifications(transport) {
4276
- const { setupRoomNotifications: setupRoomNotifications2 } = (init_rooms(), __toCommonJS(rooms_exports));
4277
- this.transportSubscription = setupRoomNotifications2(
4278
- transport,
4279
- () => this.getSubscriptions()
4280
- );
4281
- }
4282
- /**
4283
- * Clean up subscriptions and resources
4284
- */
4285
- dispose() {
4286
- if (this.transportSubscription) {
4287
- this.transportSubscription.unsubscribe();
4288
- this.transportSubscription = null;
4289
- console.log("[Venus Rooms] Cleaned up room notification subscription");
4290
- }
4291
- }
4292
- async createRoom(options) {
4293
- const response = await this.rpcClient.call(
4294
- "H5_ROOM_CREATE" /* H5_ROOM_CREATE */,
4295
- {
4296
- options
4297
- }
4298
- );
4299
- if (response.success === false) {
4300
- throw new Error(response.error || "Failed to create room");
4301
- }
4302
- const roomData = response.roomData || response;
4303
- const room = new VenusRoom(roomData);
4304
- return room;
4305
- }
4306
- async joinOrCreateRoom(options) {
4307
- const response = await this.rpcClient.call(
4308
- "H5_ROOM_JOIN_OR_CREATE" /* H5_ROOM_JOIN_OR_CREATE */,
4309
- {
4310
- options
4311
- }
4312
- );
4313
- if (response.success === false) {
4314
- throw new Error(response.error || "Failed to join or create room");
4315
- }
4316
- const data = response.value || response;
4317
- const room = new VenusRoom(data.roomData);
4318
- return {
4319
- action: data.action,
4320
- room,
4321
- playersJoined: data.playersJoined
4322
- };
4323
- }
4324
- async joinRoomByCode(roomCode) {
4325
- const response = await this.rpcClient.call(
4326
- "H5_ROOM_JOIN_BY_CODE" /* H5_ROOM_JOIN_BY_CODE */,
4327
- {
4328
- roomCode
4329
- }
4330
- );
4331
- if (response?.success === false) {
4332
- throw new Error(response.error || "Failed to join room by code");
4333
- }
4334
- const roomData = response.roomData || response;
4335
- const room = new VenusRoom(roomData);
4336
- return room;
4337
- }
4338
- // Get user's rooms with optional filtering
4339
- async getUserRooms(includeArchived = false) {
4340
- const response = await this.rpcClient.call(
4341
- "H5_ROOM_GET_USER_ROOMS" /* H5_ROOM_GET_USER_ROOMS */,
4342
- {
4343
- includeArchived
4344
- }
4345
- );
4346
- if (response?.success === false) {
4347
- throw new Error(response.error || "Failed to get user rooms");
4348
- }
4349
- const rawRooms = response.rooms || [];
4350
- const venusRooms = [];
4351
- for (const roomData of rawRooms) {
4352
- if (!roomData.id) {
4353
- console.warn("getUserRooms: Skipping room with missing ID:", roomData);
4354
- continue;
4355
- }
4356
- try {
4357
- const venusRoom = new VenusRoom(roomData);
4358
- venusRooms.push(venusRoom);
4359
- } catch (error) {
4360
- console.warn(
4361
- "getUserRooms: Failed to create VenusRoom object:",
4362
- error,
4363
- roomData
4364
- );
4365
- }
4366
- }
4367
- return venusRooms;
4368
- }
4369
- async updateData(room, updates, merge = true) {
4370
- const response = await this.rpcClient.call(
4371
- "H5_ROOM_UPDATE_DATA" /* H5_ROOM_UPDATE_DATA */,
4372
- {
4373
- roomId: room.id,
4374
- updates,
4375
- merge
4376
- }
4377
- );
4378
- if (response?.success === false) {
4379
- throw new Error(response.error || "Failed to update room data");
4380
- }
4381
- return response.data;
4382
- }
4383
- async getData(room) {
4384
- const response = await this.rpcClient.call(
4385
- "H5_ROOM_GET_DATA" /* H5_ROOM_GET_DATA */,
4386
- {
4387
- roomId: room.id
4388
- }
4389
- );
4390
- if (response?.success === false) {
4391
- throw new Error(response.error || "Failed to get room data");
4392
- }
4393
- return response.data;
4394
- }
4395
- async sendMessage(venusRoom, messageData) {
4396
- const response = await this.rpcClient.call(
4397
- "H5_ROOM_SEND_MESSAGE" /* H5_ROOM_SEND_MESSAGE */,
4398
- {
4399
- roomId: venusRoom.id,
4400
- message: messageData
4401
- }
4402
- );
4403
- if (response?.success === false) {
4404
- throw new Error(response.error || "Failed to send message");
4405
- }
4406
- return response.messageId;
4407
- }
4408
- async leave(room) {
4409
- const response = await this.rpcClient.call(
4410
- "H5_ROOM_LEAVE" /* H5_ROOM_LEAVE */,
4411
- {
4412
- roomId: room.id
4413
- }
4414
- );
4415
- if (response?.success === false) {
4416
- throw new Error(response.error || "Failed to leave room");
4417
- }
4418
- return response;
4419
- }
4420
- async startGame(room, gameConfig = {}, turnOrder = null) {
4421
- const response = await this.rpcClient.call(
4422
- "H5_ROOM_START_GAME" /* H5_ROOM_START_GAME */,
4423
- {
4424
- roomId: room.id,
4425
- gameConfig,
4426
- turnOrder
4427
- }
4428
- );
4429
- if (response?.success === false) {
4430
- throw new Error(response.error || "Failed to start game");
4431
- }
4432
- return response.data;
4433
- }
4434
- async proposeMove(room, proposalPayload) {
4435
- const response = await this.rpcClient.call(
4436
- "h5:room:proposeMove" /* H5_ROOM_PROPOSE_MOVE */,
4437
- {
4438
- roomId: room.id,
4439
- gameSpecificState: proposalPayload.gameSpecificState,
4440
- moveType: proposalPayload.moveType,
4441
- clientContext: proposalPayload.clientContext,
4442
- clientProposalId: proposalPayload.clientProposalId
4443
- }
4444
- );
4445
- if (response?.success === false) {
4446
- throw new Error(response.error || "Failed to propose move");
4447
- }
4448
- return response.data;
4449
- }
4450
- async validateMove(room, moveId, isValid, reason = null, validatorId = null) {
4451
- console.log(`[Venus Rooms] Validating move ${moveId}: ${isValid}`);
4452
- return { success: true, moveId, isValid, reason };
4453
- }
4454
- async roomSubscribeToGameEvents(room, callback) {
4455
- "game_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9);
4456
- if (!this.subscriptions.gameEvents[room.id]) {
4457
- this.subscriptions.gameEvents[room.id] = [];
4458
- }
4459
- this.subscriptions.gameEvents[room.id].push(callback);
4460
- }
4461
- subscribe(room, options = {}) {
4462
- const subscriptionIds = [];
4463
- const roomId = room.id;
4464
- if (options.onData) {
4465
- const dataSubId = "data_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9);
4466
- if (!this.subscriptions.data[roomId]) {
4467
- this.subscriptions.data[roomId] = [];
4468
- }
4469
- this.subscriptions.data[roomId].push(options.onData);
4470
- subscriptionIds.push({
4471
- type: "data",
4472
- id: dataSubId,
4473
- callback: options.onData
4474
- });
4475
- }
4476
- if (options.onMessages) {
4477
- const msgSubId = "messages_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9);
4478
- if (!this.subscriptions.messages[roomId]) {
4479
- this.subscriptions.messages[roomId] = [];
4480
- }
4481
- this.subscriptions.messages[roomId].push(options.onMessages);
4482
- subscriptionIds.push({
4483
- type: "messages",
4484
- id: msgSubId,
4485
- callback: options.onMessages
4486
- });
4487
- }
4488
- if (options.onMoves || options.onGameEvents) {
4489
- const handler = options.onMoves || options.onGameEvents;
4490
- if (handler) {
4491
- const gameSubId = "game_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9);
4492
- if (!this.subscriptions.gameEvents[roomId]) {
4493
- this.subscriptions.gameEvents[roomId] = [];
4494
- }
4495
- this.subscriptions.gameEvents[roomId].push(handler);
4496
- subscriptionIds.push({
4497
- type: "gameEvents",
4498
- id: gameSubId,
4499
- callback: handler
4500
- });
4501
- }
4502
- }
4503
- const needsSubscription = subscriptionIds.length > 0 && (this.subscriptions.data[roomId]?.length ?? 0) <= 1 && (this.subscriptions.messages[roomId]?.length ?? 0) <= 1 && (this.subscriptions.gameEvents[roomId]?.length ?? 0) <= 1;
4504
- if (needsSubscription) {
4505
- this.rpcClient.call("H5_ROOM_SUBSCRIBE" /* H5_ROOM_SUBSCRIBE */, {
4506
- roomId,
4507
- subscribeToData: !!options.onData,
4508
- subscribeToMessages: !!options.onMessages,
4509
- subscribeToProposedMoves: !!(options.onMoves || options.onGameEvents)
4510
- }).catch((error) => {
4511
- console.error("Failed to set up room subscription:", error);
4512
- });
4513
- }
4514
- let called = false;
4515
- return () => {
4516
- if (called) return;
4517
- called = true;
4518
- subscriptionIds.forEach((sub) => {
4519
- const bucket = this.subscriptions[sub.type];
4520
- const callbacks = bucket && bucket[roomId] || [];
4521
- const index = callbacks.indexOf(sub.callback);
4522
- if (index > -1) callbacks.splice(index, 1);
4523
- });
4524
- const hasNoCallbacks = (this.subscriptions.data[roomId]?.length ?? 0) === 0 && (this.subscriptions.messages[roomId]?.length ?? 0) === 0 && (this.subscriptions.gameEvents[roomId]?.length ?? 0) === 0;
4525
- if (hasNoCallbacks) {
4526
- this.rpcClient.call("H5_ROOM_UNSUBSCRIBE" /* H5_ROOM_UNSUBSCRIBE */, {
4527
- roomId
4528
- }).catch((error) => {
4529
- console.error("Failed to clean up room subscription:", error);
4530
- });
4531
- }
4532
- };
4533
- }
4534
- };
4535
-
4536
4047
  // src/RemoteHost.ts
4537
4048
  var getCdnBaseUrl = () => {
4538
4049
  return "https://venus-static-01293ak.web.app/";
@@ -4607,7 +4118,7 @@ var RemoteHost = class {
4607
4118
  this.popups = new RpcPopupsApi(rpcClient);
4608
4119
  this.profile = new HostProfileApi();
4609
4120
  this.cdn = new HostCdnApi(getCdnBaseUrl());
4610
- this.time = new HostTimeApi(rpcClient);
4121
+ this.time = new HostTimeApi(rpcClient, venusApi);
4611
4122
  this.post = new RpcPostApi(rpcClient);
4612
4123
  this.ai = new RpcAiApi(rpcClient);
4613
4124
  this.haptics = new RpcHapticsApi(rpcClient);
@@ -4623,7 +4134,6 @@ var RemoteHost = class {
4623
4134
  venusApi.isMock = () => false;
4624
4135
  this.venusApi.sharedAssets = new RpcSharedAssetsApi(rpcClient, venusApi);
4625
4136
  initializeRoomsApi(this.venusApi, this);
4626
- console.log("[Venus SDK] Remote host created");
4627
4137
  }
4628
4138
  get isInitialized() {
4629
4139
  return this._isInitialized;
@@ -4680,49 +4190,120 @@ var RemoteHost = class {
4680
4190
  };
4681
4191
 
4682
4192
  // src/MockHost.ts
4683
- init_rooms();
4684
4193
  var ROOMS_UNAVAILABLE_MESSAGE = "[Venus SDK] Rooms API is only available when running inside the Venus host environment.";
4685
4194
  function createUnavailableRoomsApi() {
4686
4195
  const roomsUnavailableError = () => new Error(ROOMS_UNAVAILABLE_MESSAGE);
4687
4196
  return {
4688
- async createRoom() {
4197
+ async createRoomAsync() {
4689
4198
  throw roomsUnavailableError();
4690
4199
  },
4691
- async joinOrCreateRoom() {
4200
+ async joinOrCreateRoomAsync() {
4692
4201
  throw roomsUnavailableError();
4693
4202
  },
4694
- async getUserRooms() {
4203
+ async joinRoomByCodeAsync() {
4695
4204
  throw roomsUnavailableError();
4696
4205
  },
4697
- async joinRoomByCode() {
4206
+ async getUserRoomsAsync() {
4698
4207
  throw roomsUnavailableError();
4699
4208
  },
4700
- subscribe() {
4209
+ async subscribeAsync() {
4701
4210
  throw roomsUnavailableError();
4702
4211
  },
4703
- async updateData() {
4212
+ async updateRoomDataAsync() {
4704
4213
  throw roomsUnavailableError();
4705
4214
  },
4706
- async getData() {
4215
+ async getRoomDataAsync() {
4707
4216
  throw roomsUnavailableError();
4708
4217
  },
4709
- async sendMessage() {
4218
+ async sendRoomMessageAsync() {
4710
4219
  throw roomsUnavailableError();
4711
4220
  },
4712
- async leave() {
4221
+ async leaveRoomAsync() {
4713
4222
  throw roomsUnavailableError();
4714
4223
  },
4715
- async startGame() {
4224
+ async startRoomGameAsync() {
4716
4225
  throw roomsUnavailableError();
4717
4226
  },
4718
- async proposeMove() {
4227
+ async proposeMoveAsync() {
4719
4228
  throw roomsUnavailableError();
4720
4229
  },
4721
- async validateMove() {
4230
+ async validateMoveAsync() {
4722
4231
  throw roomsUnavailableError();
4723
4232
  }
4724
4233
  };
4725
4234
  }
4235
+ var SIMULATION_UNAVAILABLE_MESSAGE = "[Venus SDK] Simulation API is only available when running inside the Venus host environment.";
4236
+ function createUnavailableSimulationApi() {
4237
+ const simulationUnavailableError = () => new Error(SIMULATION_UNAVAILABLE_MESSAGE);
4238
+ return {
4239
+ isEnabled() {
4240
+ return false;
4241
+ },
4242
+ async getStateAsync() {
4243
+ throw simulationUnavailableError();
4244
+ },
4245
+ async getConfigAsync() {
4246
+ throw simulationUnavailableError();
4247
+ },
4248
+ async executeRecipeAsync() {
4249
+ throw simulationUnavailableError();
4250
+ },
4251
+ async getActiveRunsAsync() {
4252
+ throw simulationUnavailableError();
4253
+ },
4254
+ async collectRecipeAsync() {
4255
+ throw simulationUnavailableError();
4256
+ },
4257
+ async executeScopedRecipeAsync() {
4258
+ throw simulationUnavailableError();
4259
+ },
4260
+ async triggerRecipeChainAsync() {
4261
+ throw simulationUnavailableError();
4262
+ },
4263
+ async getAvailableRecipesAsync() {
4264
+ throw simulationUnavailableError();
4265
+ },
4266
+ async getRecipeRequirementsAsync() {
4267
+ throw simulationUnavailableError();
4268
+ },
4269
+ async getBatchRecipeRequirementsAsync() {
4270
+ throw simulationUnavailableError();
4271
+ },
4272
+ async resolveFieldValueAsync() {
4273
+ throw simulationUnavailableError();
4274
+ },
4275
+ async getEntityMetadataAsync() {
4276
+ throw simulationUnavailableError();
4277
+ },
4278
+ async getSlotContainersAsync() {
4279
+ throw simulationUnavailableError();
4280
+ },
4281
+ async getSlotAssignmentsAsync() {
4282
+ throw simulationUnavailableError();
4283
+ },
4284
+ async assignItemToSlotAsync() {
4285
+ throw simulationUnavailableError();
4286
+ },
4287
+ async removeItemFromSlotAsync() {
4288
+ throw simulationUnavailableError();
4289
+ },
4290
+ async getAvailableItemsAsync() {
4291
+ throw simulationUnavailableError();
4292
+ },
4293
+ async calculatePowerPreviewAsync() {
4294
+ throw simulationUnavailableError();
4295
+ },
4296
+ async validateSlotAssignmentAsync() {
4297
+ throw simulationUnavailableError();
4298
+ },
4299
+ async executeBatchOperationsAsync() {
4300
+ throw simulationUnavailableError();
4301
+ },
4302
+ async subscribeAsync() {
4303
+ throw simulationUnavailableError();
4304
+ }
4305
+ };
4306
+ }
4726
4307
  var MockHost = class {
4727
4308
  constructor(venusApi) {
4728
4309
  __publicField(this, "ads");
@@ -4777,7 +4358,7 @@ var MockHost = class {
4777
4358
  this.haptics = new MockHapticsApi(venusApi);
4778
4359
  this.features = new MockFeaturesApi();
4779
4360
  this.lifecycle = this._mockLifecyclesApi;
4780
- this.simulation = new MockSimulationApi();
4361
+ this.simulation = createUnavailableSimulationApi();
4781
4362
  this.rooms = createUnavailableRoomsApi();
4782
4363
  this.logging = new MockLoggingApi();
4783
4364
  this.iap = new MockIapApi();
@@ -5272,10 +4853,8 @@ var MockHost = class {
5272
4853
  // src/Host.ts
5273
4854
  function createHost(venusApi, isMock) {
5274
4855
  if (isMock) {
5275
- console.log("[Venus SDK] Creating Local Host");
5276
4856
  return new MockHost(venusApi);
5277
4857
  } else {
5278
- console.log("[Venus SDK] Creating Remote Host");
5279
4858
  return new RemoteHost(venusApi);
5280
4859
  }
5281
4860
  }
@@ -5288,6 +4867,6 @@ function initializeSocial(venusApi, host) {
5288
4867
  };
5289
4868
  }
5290
4869
 
5291
- export { HapticFeedbackStyle, HostCdnApi, HostProfileApi, HostTimeApi, MockAdsApi, MockAiApi, MockAnalyticsApi, MockAvatarApi, MockCdnApi, MockFeaturesApi, MockHapticsApi, MockIapApi, MockLeaderboardApi, MockLifecycleApi, MockLoggingApi, MockNavigationApi, MockNotificationsApi, MockPopupsApi, MockPreloaderApi, MockProfileApi, MockSharedAssetsApi, MockSimulationApi, MockSocialApi, MockStorageApi, MockTimeApi, RemoteHost, RpcAdsApi, RpcAiApi, RpcAnalyticsApi, RpcAvatarApi, RpcClient, RpcFeaturesApi, RpcHapticsApi, RpcIapApi, RpcLeaderboardApi, RpcLifecycleApi, RpcLoggingApi, RpcNavigationApi, RpcNotificationsApi, RpcPopupsApi, RpcPreloaderApi, RpcSharedAssetsApi, RpcSimulationApi, RpcSocialApi, RpcStorageApi, SDK_VERSION, VenusMessageId, VenusRoom, createHost, createMockStorageApi, init_rooms, initializeAds, initializeAi, initializeAnalytics, initializeAvatar3d, initializeCdn, initializeFeaturesApi, initializeHaptics, initializeIap, initializeLeaderboard, initializeLifecycleApi, initializeLocalNotifications, initializeLoggingApi, initializePopups, initializePost, initializePreloader, initializeProfile, initializeRoomsApi, initializeSimulation, initializeSocial, initializeStackNavigation, initializeStorage, initializeTime, isPacificDaylightTime, setupRoomNotifications };
5292
- //# sourceMappingURL=chunk-JO6V5EXF.mjs.map
5293
- //# sourceMappingURL=chunk-JO6V5EXF.mjs.map
4870
+ export { HASH_ALGORITHM_NODE, HASH_ALGORITHM_WEB_CRYPTO, HapticFeedbackStyle, HostCdnApi, HostProfileApi, HostTimeApi, MockAdsApi, MockAiApi, MockAnalyticsApi, MockAvatarApi, MockCdnApi, MockFeaturesApi, MockHapticsApi, MockIapApi, MockLeaderboardApi, MockLifecycleApi, MockLoggingApi, MockNavigationApi, MockNotificationsApi, MockPopupsApi, MockPreloaderApi, MockProfileApi, MockSharedAssetsApi, MockSocialApi, MockStorageApi, MockTimeApi, RemoteHost, RpcAdsApi, RpcAiApi, RpcAnalyticsApi, RpcAvatarApi, RpcClient, RpcFeaturesApi, RpcHapticsApi, RpcIapApi, RpcLeaderboardApi, RpcLifecycleApi, RpcLoggingApi, RpcNavigationApi, RpcNotificationsApi, RpcPopupsApi, RpcPreloaderApi, RpcRoomsApi, RpcSharedAssetsApi, RpcSimulationApi, RpcSocialApi, RpcStorageApi, SDK_VERSION, VenusMessageId, VenusRoom, computeScoreHash, createHost, createMockStorageApi, initializeAds, initializeAi, initializeAnalytics, initializeAvatar3d, initializeCdn, initializeFeaturesApi, initializeHaptics, initializeIap, initializeLeaderboard, initializeLifecycleApi, initializeLocalNotifications, initializeLoggingApi, initializePopups, initializePost, initializePreloader, initializeProfile, initializeRoomsApi, initializeSimulation, initializeSocial, initializeStackNavigation, initializeStorage, initializeTime, isPacificDaylightTime, setupRoomNotifications };
4871
+ //# sourceMappingURL=chunk-LBJFUHOH.mjs.map
4872
+ //# sourceMappingURL=chunk-LBJFUHOH.mjs.map