@series-inc/venus-sdk 3.0.4 → 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";
@@ -1758,13 +1546,8 @@ var MockNotificationsApi = class {
1758
1546
  async cancelNotification(notificationId) {
1759
1547
  const venusApi = this.venusApi;
1760
1548
  if (isWebPlatform()) {
1761
- console.log(
1762
- "[Venus Mock] Cancel notification on web platform (simulated):",
1763
- notificationId
1764
- );
1765
1549
  return true;
1766
1550
  }
1767
- console.log("[Venus Mock] Cancel local notification:", notificationId);
1768
1551
  await createMockDelay(MOCK_DELAYS.short);
1769
1552
  if (venusApi._mock.scheduledNotifications && venusApi._mock.scheduledNotifications[notificationId]) {
1770
1553
  delete venusApi._mock.scheduledNotifications[notificationId];
@@ -1774,12 +1557,8 @@ var MockNotificationsApi = class {
1774
1557
  }
1775
1558
  async getAllScheduledLocalNotifications() {
1776
1559
  if (isWebPlatform()) {
1777
- console.log(
1778
- "[Venus Mock] Get notifications on web platform (returning empty list)"
1779
- );
1780
1560
  return [];
1781
1561
  }
1782
- console.log("[Venus Mock] Get all scheduled local notifications");
1783
1562
  await createMockDelay(MOCK_DELAYS.short);
1784
1563
  const venusApi = this.venusApi;
1785
1564
  const notifications = venusApi._mock.scheduledNotifications || {};
@@ -1787,10 +1566,8 @@ var MockNotificationsApi = class {
1787
1566
  }
1788
1567
  async isLocalNotificationsEnabled() {
1789
1568
  if (isWebPlatform()) {
1790
- console.log("[Venus Mock] Notifications not available on web platform");
1791
1569
  return false;
1792
1570
  }
1793
- console.log("[Venus Mock] Check if local notifications are enabled");
1794
1571
  await createMockDelay(MOCK_DELAYS.short);
1795
1572
  const venusApi = this.venusApi;
1796
1573
  const isEnabled = venusApi._mock.notificationsEnabled !== false;
@@ -1799,9 +1576,6 @@ var MockNotificationsApi = class {
1799
1576
  async scheduleAsync(title, body, seconds, notificationId, options) {
1800
1577
  const { priority = 50, groupId, payload } = options || {};
1801
1578
  if (isWebPlatform()) {
1802
- console.log(
1803
- "[Venus Mock] Notifications not supported on web platform, simulating success"
1804
- );
1805
1579
  console.info(
1806
1580
  "\u{1F514} [Venus Mock] Notification would be scheduled:",
1807
1581
  title || "Untitled",
@@ -1812,14 +1586,11 @@ var MockNotificationsApi = class {
1812
1586
  const mockId = `mock-web-notification-${Date.now()}`;
1813
1587
  return mockId;
1814
1588
  }
1815
- console.log("[Venus Mock] Schedule local notification:", { title, body, seconds, options });
1816
1589
  const venusApi = this.venusApi;
1817
1590
  if (!venusApi._mock.pendingRequests) {
1818
- console.log("[Venus Mock] Initializing pendingRequests");
1819
1591
  venusApi._mock.pendingRequests = {};
1820
1592
  }
1821
1593
  const requestId = Date.now().toString();
1822
- console.log("[Venus Mock] Creating request with ID:", requestId);
1823
1594
  return new Promise((resolve) => {
1824
1595
  venusApi._mock.pendingRequests[requestId] = { resolve };
1825
1596
  const id = notificationId || `mock-notification-${Date.now()}`;
@@ -1841,13 +1612,8 @@ var MockNotificationsApi = class {
1841
1612
  async setLocalNotificationsEnabled(enabled) {
1842
1613
  const venusApi = this.venusApi;
1843
1614
  if (isWebPlatform()) {
1844
- console.log(
1845
- "[Venus Mock] Set notifications enabled on web platform (simulated):",
1846
- enabled
1847
- );
1848
1615
  return true;
1849
1616
  }
1850
- console.log("[Venus Mock] Set local notifications enabled:", enabled);
1851
1617
  await createMockDelay(MOCK_DELAYS.short);
1852
1618
  venusApi._mock.notificationsEnabled = enabled;
1853
1619
  return enabled;
@@ -2112,6 +1878,11 @@ function initializeProfile(venusApi, host) {
2112
1878
  };
2113
1879
  }
2114
1880
 
1881
+ // src/utils/idGenerator.ts
1882
+ function generateId() {
1883
+ return `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
1884
+ }
1885
+
2115
1886
  // src/rpc/RpcClient.ts
2116
1887
  var RpcClient = class {
2117
1888
  constructor() {
@@ -2154,7 +1925,7 @@ var RpcClient = class {
2154
1925
  }
2155
1926
  async call(method, args, timeout = 5e3) {
2156
1927
  return new Promise((resolve, reject) => {
2157
- const id = this.generateId();
1928
+ const id = generateId();
2158
1929
  this.addPendingCall(id, resolve, reject);
2159
1930
  const request = {
2160
1931
  type: "rpc-request",
@@ -2191,9 +1962,6 @@ var RpcClient = class {
2191
1962
  getPendingCall(id) {
2192
1963
  return this.pendingCalls.get(id);
2193
1964
  }
2194
- generateId() {
2195
- return `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
2196
- }
2197
1965
  handleRpcResponse(response) {
2198
1966
  const pending = this.getPendingCall(response.id);
2199
1967
  if (!pending) {
@@ -2215,107 +1983,527 @@ var RpcClient = class {
2215
1983
  }
2216
1984
  };
2217
1985
 
2218
- // src/storage/MockStorageApi.ts
2219
- function createMockStorageApi(storageType, appUrl) {
2220
- const appIdentifier = appUrl ? generateAppIdentifier(appUrl) : null;
2221
- let prefix;
2222
- let syncDelay = 0;
2223
- switch (storageType) {
2224
- case "deviceCache":
2225
- prefix = "venus:app";
2226
- syncDelay = 0;
2227
- break;
2228
- case "appStorage":
2229
- prefix = "venus:app";
2230
- syncDelay = 100;
2231
- break;
2232
- case "globalStorage":
2233
- prefix = "venus:global";
2234
- syncDelay = 100;
2235
- break;
2236
- default:
2237
- 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;
2238
2025
  }
2239
- prefix = storageType === "globalStorage" || !appIdentifier ? `${prefix}:` : `${prefix}:${appIdentifier}:`;
2240
- 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
+ });
2241
2038
  }
2242
- var MockStorageApi = class {
2243
- constructor(prefix, syncDelay) {
2244
- __publicField(this, "prefix");
2245
- __publicField(this, "syncDelay");
2246
- this.prefix = prefix;
2247
- this.syncDelay = syncDelay;
2248
- }
2249
- async clear() {
2250
- const fullLength = localStorage.length;
2251
- for (let i = 0; i < fullLength; i++) {
2252
- const fullKey = localStorage.key(i);
2253
- if (fullKey && fullKey.startsWith(this.prefix)) {
2254
- localStorage.removeItem(fullKey);
2255
- }
2039
+ function setupRoomNotifications(transport, getSubscriptions) {
2040
+ return transport.onVenusMessage((message) => {
2041
+ const subscriptions = getSubscriptions();
2042
+ if (!subscriptions) {
2043
+ return;
2256
2044
  }
2257
- await this.simulateSyncDelay();
2258
- }
2259
- async getAllItems() {
2260
- const items = new Array();
2261
- const fullLength = localStorage.length;
2262
- for (let i = 0; i < fullLength; i++) {
2263
- const fullKey = localStorage.key(i);
2264
- if (fullKey && fullKey.startsWith(this.prefix)) {
2265
- const item = localStorage.getItem(fullKey);
2266
- if (item) {
2267
- items.push(item);
2268
- }
2269
- }
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");
2270
2057
  }
2271
- return items;
2272
- }
2273
- async getItem(key) {
2274
- const fullKey = this.buildKey(key);
2275
- await this.simulateSyncDelay();
2276
- return localStorage.getItem(fullKey);
2277
- }
2278
- async key(index) {
2279
- const keys = this.keys();
2280
- if (index < 0 || index >= keys.length) {
2281
- 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");
2282
2070
  }
2283
- await this.simulateSyncDelay();
2284
- return keys[index];
2285
- }
2286
- async length() {
2287
- 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
+ };
2288
2100
  }
2289
- async removeItem(key) {
2290
- const fullKey = this.buildKey(key);
2291
- await this.simulateSyncDelay();
2292
- localStorage.removeItem(fullKey);
2101
+ /**
2102
+ * Get the subscription state for external access (used by setupRoomNotifications)
2103
+ */
2104
+ getSubscriptions() {
2105
+ return this.subscriptions;
2293
2106
  }
2294
- async setItem(key, item) {
2295
- const fullKey = this.buildKey(key);
2296
- await this.simulateSyncDelay();
2297
- localStorage.setItem(fullKey, item);
2107
+ /**
2108
+ * Set up room notification routing from the transport
2109
+ */
2110
+ setupNotifications(transport) {
2111
+ setupRoomNotifications(transport, () => this.getSubscriptions());
2298
2112
  }
2299
- async setMultipleItems(entries) {
2300
- for (const entry of entries) {
2301
- const fullKey = this.buildKey(entry.key);
2302
- 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);
2303
2123
  }
2304
- await this.simulateSyncDelay();
2124
+ const room = new VenusRoom(response.roomData);
2125
+ return room;
2305
2126
  }
2306
- async removeMultipleItems(keys) {
2307
- for (const key of keys) {
2308
- const fullKey = this.buildKey(key);
2309
- 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);
2310
2137
  }
2311
- await this.simulateSyncDelay();
2312
- }
2313
- buildKey(key) {
2314
- const prefix = this.prefix;
2315
- 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
+ };
2316
2144
  }
2317
- extractKey(fullKey) {
2318
- const prefix = this.prefix;
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) {
2506
+ const prefix = this.prefix;
2319
2507
  return fullKey.substring(prefix.length);
2320
2508
  }
2321
2509
  keys() {
@@ -2448,24 +2636,20 @@ function initializeStorage(venusApiInstance, host) {
2448
2636
  venusApiInstance.globalStorage = host.globalStorage;
2449
2637
  }
2450
2638
 
2451
- // src/simulation/utils.ts
2452
- function sumContributions(contributions) {
2453
- const totals = {};
2454
- for (const profileId in contributions) {
2455
- for (const entityId in contributions[profileId]) {
2456
- const amount = contributions[profileId][entityId] || 0;
2457
- totals[entityId] = (totals[entityId] || 0) + amount;
2458
- }
2459
- }
2460
- return totals;
2461
- }
2462
-
2463
2639
  // src/simulation/RpcSimulationApi.ts
2464
2640
  var RpcSimulationApi = class {
2465
2641
  constructor(rpcClient) {
2466
2642
  __publicField(this, "rpcClient");
2467
2643
  __publicField(this, "_simulationConfig", null);
2644
+ __publicField(this, "subscriptionCallbacks", /* @__PURE__ */ new Map());
2468
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;
2469
2653
  }
2470
2654
  async validateSlotAssignmentAsync(containerId, slotId, itemId) {
2471
2655
  return this.rpcClient.call(
@@ -2477,14 +2661,47 @@ var RpcSimulationApi = class {
2477
2661
  }
2478
2662
  );
2479
2663
  }
2480
- sumContributions(contributions) {
2481
- 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
+ };
2482
2696
  }
2483
2697
  executeBatchOperationsAsync(operations, validateOnly) {
2484
- return this.rpcClient.call("H5_SIMULATION_BATCH_OPERATIONS" /* H5_SIMULATION_BATCH_OPERATIONS */, {
2485
- operations,
2486
- validateOnly
2487
- });
2698
+ return this.rpcClient.call(
2699
+ "H5_SIMULATION_BATCH_OPERATIONS" /* H5_SIMULATION_BATCH_OPERATIONS */,
2700
+ {
2701
+ operations,
2702
+ validateOnly
2703
+ }
2704
+ );
2488
2705
  }
2489
2706
  async getAvailableItemsAsync(containerId, slotId) {
2490
2707
  const response = await this.rpcClient.call(
@@ -2507,17 +2724,23 @@ var RpcSimulationApi = class {
2507
2724
  );
2508
2725
  }
2509
2726
  assignItemToSlotAsync(containerId, slotId, itemId) {
2510
- return this.rpcClient.call("H5_SIMULATION_ASSIGN_ITEM" /* H5_SIMULATION_ASSIGN_ITEM */, {
2511
- containerId,
2512
- slotId,
2513
- itemId
2514
- });
2727
+ return this.rpcClient.call(
2728
+ "H5_SIMULATION_ASSIGN_ITEM" /* H5_SIMULATION_ASSIGN_ITEM */,
2729
+ {
2730
+ containerId,
2731
+ slotId,
2732
+ itemId
2733
+ }
2734
+ );
2515
2735
  }
2516
2736
  removeItemFromSlotAsync(containerId, slotId) {
2517
- return this.rpcClient.call("H5_SIMULATION_REMOVE_ITEM" /* H5_SIMULATION_REMOVE_ITEM */, {
2518
- containerId,
2519
- slotId
2520
- });
2737
+ return this.rpcClient.call(
2738
+ "H5_SIMULATION_REMOVE_ITEM" /* H5_SIMULATION_REMOVE_ITEM */,
2739
+ {
2740
+ containerId,
2741
+ slotId
2742
+ }
2743
+ );
2521
2744
  }
2522
2745
  async getSlotContainersAsync() {
2523
2746
  const response = await this.rpcClient.call(
@@ -2542,7 +2765,6 @@ var RpcSimulationApi = class {
2542
2765
  roomId
2543
2766
  }
2544
2767
  );
2545
- console.log("[Venus SDK] getStateAsync", response);
2546
2768
  if (response.configuration) {
2547
2769
  this._simulationConfig = response.configuration;
2548
2770
  }
@@ -2554,9 +2776,10 @@ var RpcSimulationApi = class {
2554
2776
  }
2555
2777
  const config = await this.rpcClient.call(
2556
2778
  "H5_SIMULATION_GET_CONFIG" /* H5_SIMULATION_GET_CONFIG */,
2557
- {}
2779
+ {
2780
+ roomId
2781
+ }
2558
2782
  );
2559
- console.log("[Venus SDK] getConfigAsync", config);
2560
2783
  if (config) {
2561
2784
  this._simulationConfig = config;
2562
2785
  return config;
@@ -2564,14 +2787,17 @@ var RpcSimulationApi = class {
2564
2787
  throw new Error("No simulation configuration available");
2565
2788
  }
2566
2789
  executeRecipeAsync(recipeId, inputs, options) {
2567
- return this.rpcClient.call("H5_SIMULATION_EXECUTE_RECIPE" /* H5_SIMULATION_EXECUTE_RECIPE */, {
2568
- recipeId,
2569
- inputs,
2570
- roomId: options?.roomId,
2571
- batchAmount: options?.batchAmount,
2572
- allowPartialBatch: options?.allowPartialBatch,
2573
- entity: options?.entity
2574
- });
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
+ );
2575
2801
  }
2576
2802
  collectRecipeAsync(runId) {
2577
2803
  return this.rpcClient.call("H5_SIMULATION_COLLECT_RECIPE" /* H5_SIMULATION_COLLECT_RECIPE */, {
@@ -2579,9 +2805,12 @@ var RpcSimulationApi = class {
2579
2805
  });
2580
2806
  }
2581
2807
  getActiveRunsAsync(options) {
2582
- return this.rpcClient.call("H5_SIMULATION_GET_ACTIVE_RUNS" /* H5_SIMULATION_GET_ACTIVE_RUNS */, {
2583
- roomId: options?.roomId
2584
- });
2808
+ return this.rpcClient.call(
2809
+ "H5_SIMULATION_GET_ACTIVE_RUNS" /* H5_SIMULATION_GET_ACTIVE_RUNS */,
2810
+ {
2811
+ roomId: options?.roomId
2812
+ }
2813
+ );
2585
2814
  }
2586
2815
  executeScopedRecipeAsync(recipeId, entity, inputs, options) {
2587
2816
  return this.rpcClient.call(
@@ -2651,583 +2880,52 @@ var RpcSimulationApi = class {
2651
2880
  );
2652
2881
  return response.value;
2653
2882
  }
2654
- };
2655
-
2656
- // src/simulation/MockSimulationApi.ts
2657
- function generateAppIdentifier2() {
2658
- if (typeof window === "undefined") return "unknown-app";
2659
- const url = window.location.href;
2660
- const match = url.match(/\/H5\/([^\/]+)/);
2661
- return match ? match[1] : "unknown-app";
2662
- }
2663
- var MockSimulationApi = class {
2664
- constructor(simulationConfig = null) {
2665
- __publicField(this, "mockSimulationConfigs", /* @__PURE__ */ new Map());
2666
- // appIdentifier -> config
2667
- __publicField(this, "mockSimulationStates", /* @__PURE__ */ new Map());
2668
- // appIdentifier -> config
2669
- __publicField(this, "mockActiveTimers", /* @__PURE__ */ new Map());
2670
- // appIdentifier -> timers[]
2671
- __publicField(this, "appId");
2672
- __publicField(this, "providedSimulationConfig");
2673
- this.appId = generateAppIdentifier2();
2674
- this.providedSimulationConfig = simulationConfig;
2675
- }
2676
- sumContributions(contributions) {
2677
- return sumContributions(contributions);
2678
- }
2679
- async validateSlotAssignmentAsync(containerId, slotId, itemId) {
2680
- this.log("validateSlotAssignmentAsync called:", {
2681
- containerId,
2682
- slotId,
2683
- itemId
2684
- });
2685
- return { valid: true, message: "Mock validation successful" };
2686
- }
2687
- async executeBatchOperationsAsync(operations, validateOnly) {
2688
- this.log("executeBatchOperationsAsync called:", {
2689
- operations,
2690
- validateOnly
2691
- });
2692
- return {
2693
- success: true,
2694
- results: operations.map(() => ({ success: true }))
2695
- };
2696
- }
2697
- async getAvailableItemsAsync(containerId, slotId) {
2698
- console.log("[Venus Simulation Mock] getAvailableItemsAsync called:", {
2699
- containerId,
2700
- slotId
2701
- });
2702
- const appIdentifier = generateAppIdentifier2();
2703
- const mockSimulationConfigs = this.mockSimulationConfigs;
2704
- const config = mockSimulationConfigs.get(appIdentifier) || {
2705
- entities: {}
2706
- };
2707
- const availableItems = Object.entries(config.entities).slice(0, 3).map(([entityId, entity]) => ({
2708
- entityId,
2709
- quantity: 1,
2710
- metadata: entity.metadata,
2711
- powerPreview: 100
2712
- // Mock power value
2713
- }));
2714
- return availableItems;
2715
- }
2716
- async calculatePowerPreviewAsync(containerId, slotId, candidateItemId) {
2717
- this.log("calculatePowerPreviewAsync called:", {
2718
- containerId,
2719
- slotId,
2720
- candidateItemId
2721
- });
2722
- return {
2723
- currentPower: 1e3,
2724
- previewPower: 1200,
2725
- powerDelta: 200,
2726
- breakdown: { base: 800, weapon: 200, armor: 200 }
2727
- };
2728
- }
2729
- async getSlotContainersAsync() {
2730
- this.log("getSlotContainersAsync called");
2731
- const appIdentifier = this.appId;
2732
- const mockSimulationConfigs = this.mockSimulationConfigs;
2733
- const config = mockSimulationConfigs.get(appIdentifier) || {
2734
- entities: {}
2735
- };
2736
- const containers = Object.entries(config.entities).filter(([_, entity]) => entity.metadata?.slots).map(([entityId, entity]) => ({
2737
- entityId,
2738
- slots: entity.metadata?.slots,
2739
- isOwned: true
2740
- // Mock: assume all containers are owned
2741
- }));
2742
- return containers;
2743
- }
2744
- async getSlotAssignmentsAsync(containerId) {
2745
- this.log("getSlotAssignmentsAsync called for:", containerId);
2746
- return [];
2747
- }
2748
- async resolveFieldValueAsync(entityId, fieldPath, entity) {
2749
- this.log("resolveFieldValueAsync called:", {
2750
- entityId,
2751
- fieldPath,
2752
- entity
2753
- });
2754
- const mockValues = {
2755
- basePower: 850,
2756
- weaponPower: 300,
2757
- armorPower: 150,
2758
- total_power: 1300,
2759
- total_defense_power: 5e3
2760
- };
2761
- return mockValues[fieldPath] || 100;
2762
- }
2763
- async getEntityMetadataAsync(entityId) {
2764
- this.log("getEntityMetadataAsync called for:", entityId);
2765
- const mockSimulationConfigs = this.mockSimulationConfigs;
2766
- const appIdentifier = this.appId;
2767
- const config = mockSimulationConfigs.get(
2768
- appIdentifier
2769
- ) || {
2770
- entities: {}};
2771
- const entity = config.entities[entityId];
2772
- return entity?.metadata || {};
2773
- }
2774
- async collectRecipeAsync(runId) {
2775
- this.log("collectRecipeAsync called:", { runId });
2776
- const mockRewards = {
2777
- cash: Math.floor(Math.random() * 1e3) + 500,
2778
- experience: Math.floor(Math.random() * 50) + 25
2779
- };
2780
- return {
2781
- success: true,
2782
- runId,
2783
- rewards: mockRewards,
2784
- message: "Rewards collected successfully"
2785
- };
2786
- }
2787
- executeRecipeAsync(recipeId, inputs, options) {
2788
- this.log("executeRecipeAsync called:", {
2789
- recipeId,
2790
- inputs,
2791
- options
2792
- });
2793
- const appIdentifier = this.appId;
2794
- return this.executeRecipe(appIdentifier, recipeId, inputs);
2795
- }
2796
- async executeScopedRecipeAsync(recipeId, entity, inputs, options) {
2797
- this.log("executeScopedRecipeAsync called:", {
2798
- recipeId,
2799
- entity,
2800
- inputs,
2801
- roomId: options?.roomId,
2802
- options
2803
- });
2804
- return {
2805
- success: true,
2806
- message: "Mock scoped recipe execution successful"
2807
- };
2808
- }
2809
- async getActiveRunsAsync(options) {
2810
- this.log("getActiveRunsAsync called:", options);
2811
- const appIdentifier = this.appId;
2812
- let state = this.mockSimulationStates.get(appIdentifier);
2813
- if (!state) {
2814
- state = await this.initializeSimulationState(appIdentifier);
2815
- }
2816
- return state.activeRuns || [];
2817
- }
2818
- async getAvailableRecipesAsync(options) {
2819
- this.log("getAvailableRecipesAsync called:", options);
2820
- const baseRecipes = [
2821
- { id: "collect_resources", scope: "player", clientViewable: true },
2822
- { id: "upgrade_equipment", scope: "player", clientViewable: true }
2823
- ];
2824
- if (options?.roomId) {
2825
- baseRecipes.push(
2826
- { id: "room_upgrade", scope: "room", clientViewable: true },
2827
- { id: "cooperative_project", scope: "room", clientViewable: true }
2828
- );
2883
+ handleSimulationUpdate(notification) {
2884
+ if (!notification || !notification.subscriptionId) {
2885
+ console.warn("[Venus SDK] Received malformed simulation update");
2886
+ return;
2829
2887
  }
2830
- if (options?.includeActorRecipes && options?.roomId) {
2831
- baseRecipes.push(
2832
- { id: "trade_with_npc", scope: "actor", clientViewable: true },
2833
- { 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
2834
2893
  );
2894
+ return;
2835
2895
  }
2836
- return { success: true, recipes: baseRecipes };
2837
- }
2838
- async getBatchRecipeRequirementsAsync(recipes) {
2839
- this.log("getBatchRecipeRequirementsAsync called:", {
2840
- count: recipes?.length
2841
- });
2842
- const results = (recipes || []).map((q) => ({
2843
- recipeId: q.recipeId,
2844
- entity: q.entity || null,
2845
- amount: q.batchAmount || 1,
2846
- inputs: { cash: "BE:0" },
2847
- canAfford: true,
2848
- disabled: false
2849
- }));
2850
- return { success: true, results };
2851
- }
2852
- async getRecipeRequirementsAsync(recipe) {
2853
- this.log("getRecipeRequirementsAsync called:", recipe);
2854
- return {
2855
- recipeId: recipe.recipeId,
2856
- entity: recipe.entity || null,
2857
- amount: recipe.batchAmount,
2858
- inputs: { cash: "BE:0" },
2859
- canAfford: true,
2860
- disabled: false
2861
- };
2862
- }
2863
- async triggerRecipeChainAsync(recipeId, options) {
2864
- this.log("triggerRecipeChainAsync called:", { recipeId, ...options });
2865
- return {
2866
- success: true,
2867
- message: "Mock recipe chain triggered successfully"
2868
- };
2869
- }
2870
- log(message, ...args) {
2871
- console.log(`[Venus Sim Mock] ${message}`, args);
2872
- }
2873
- async executeRecipe(appIdentifier, recipeId, inputs) {
2874
- this.log(`Executing recipe ${recipeId} for ${appIdentifier}`, inputs);
2875
- const mockSimulationConfigs = this.mockSimulationConfigs;
2876
- const mockSimulationStates = this.mockSimulationStates;
2877
- let config = mockSimulationConfigs.get(appIdentifier);
2878
- let state = mockSimulationStates.get(appIdentifier);
2879
- if (!config || !state) {
2880
- state = await this.initializeSimulationState(appIdentifier);
2881
- config = mockSimulationConfigs.get(appIdentifier);
2882
- if (!config) {
2883
- throw new Error("Failed to initialize simulation config");
2884
- }
2885
- }
2886
- const recipe = config.recipes?.[recipeId];
2887
- if (!recipe) {
2888
- throw new Error(`Recipe ${recipeId} not found`);
2889
- }
2890
- if (state.disabledRecipes?.includes(recipeId)) {
2891
- throw new Error(`Recipe ${recipeId} is disabled`);
2892
- }
2893
- if (recipe.inputs) {
2894
- for (const [entityId, required] of Object.entries(recipe.inputs)) {
2895
- const available = state.inventory[entityId] || 0;
2896
- if (available < required) {
2897
- throw new Error(
2898
- `Insufficient ${entityId}: required ${required}, available ${available}`
2899
- );
2900
- }
2901
- }
2902
- }
2903
- if (recipe.inputs) {
2904
- for (const [entityId, input] of Object.entries(recipe.inputs)) {
2905
- const inventoryValue = state.inventory[entityId] || 0;
2906
- if (typeof input === "number" && typeof inventoryValue === "number") {
2907
- state.inventory[entityId] = inventoryValue - input;
2908
- }
2909
- }
2910
- }
2911
- if (recipe.beginEffects) {
2912
- this.applyEffects(state, recipe.beginEffects);
2913
- }
2914
- const runId = this.generateRunId();
2915
- const now = Date.now();
2916
- const expiresAt = now + (recipe.duration || 0);
2917
- const run = {
2918
- id: runId,
2919
- recipeId,
2920
- status: "running",
2921
- startTime: now,
2922
- expiresAt,
2923
- inputs: recipe.inputs || {}
2924
- };
2925
- state.activeRuns.push(run);
2926
- if (recipe.duration === 0) {
2927
- this.completeRun(appIdentifier, runId);
2928
- return { status: "completed", runId };
2929
- } else {
2930
- const mockActiveTimers = this.mockActiveTimers;
2931
- const timer = setTimeout(() => {
2932
- this.completeRun(appIdentifier, runId);
2933
- }, recipe.duration);
2934
- const timers = mockActiveTimers.get(appIdentifier) || [];
2935
- timers.push(timer);
2936
- mockActiveTimers.set(appIdentifier, timers);
2937
- return {
2938
- status: "running",
2939
- runId,
2940
- expiresAt: new Date(expiresAt).toISOString()
2941
- };
2896
+ try {
2897
+ callback(notification.updates);
2898
+ } catch (error) {
2899
+ console.error("[Venus SDK] Error in simulation subscription callback", error);
2942
2900
  }
2943
2901
  }
2944
- async initializeSimulationState(appIdentifier) {
2945
- this.log(`Initializing simulation state for ${appIdentifier}`);
2946
- const providedSimulationConfig = this.providedSimulationConfig;
2947
- const mockSimulationConfigs = this.mockSimulationConfigs;
2948
- const mockSimulationStates = this.mockSimulationStates;
2949
- const mockActiveTimers = this.mockActiveTimers;
2950
- const config = providedSimulationConfig || {
2951
- version: "1.0",
2952
- entities: {},
2953
- recipes: {}
2954
- };
2955
- mockSimulationConfigs.set(appIdentifier, config);
2956
- const initialInventory = {};
2957
- if (providedSimulationConfig && config.entities) {
2958
- Object.keys(config.entities).forEach((entityId) => {
2959
- initialInventory[entityId] = 0;
2960
- });
2961
- }
2962
- const state = {
2963
- inventory: initialInventory,
2964
- activeRuns: [],
2965
- disabledRecipes: new Array()
2966
- };
2967
- if (config.recipes) {
2968
- Object.entries(config.recipes).forEach(([recipeId, recipe]) => {
2969
- if (recipe.metadata?.startsDisabled) {
2970
- state.disabledRecipes.push(recipeId);
2971
- }
2972
- });
2973
- }
2974
- mockSimulationStates.set(appIdentifier, state);
2975
- mockActiveTimers.set(appIdentifier, []);
2976
- console.log(
2977
- `[Venus Simulation Mock] Initialized state for ${appIdentifier}:`,
2978
- state
2979
- );
2980
- if (config.recipes) {
2981
- Object.entries(config.recipes).forEach(([recipeId, recipe]) => {
2982
- const isAutoRestart = recipe.autoRestart || recipe.metadata?.autoRestart;
2983
- if (isAutoRestart && recipe.outputs) {
2984
- this.log(`Found auto-restart recipe: ${recipeId}`, {
2985
- topLevelAutoRestart: recipe.autoRestart,
2986
- metadataAutoRestart: recipe.metadata?.autoRestart,
2987
- hasOutputs: !!recipe.outputs,
2988
- duration: recipe.duration
2989
- });
2990
- const condition = recipe.maxRestartCondition || recipe.metadata?.maxRestartCondition;
2991
- if (condition && condition.entity) {
2992
- const currentAmount = initialInventory[condition.entity] || 0;
2993
- if (currentAmount < condition.maxValue) {
2994
- console.log(
2995
- `[Venus Simulation Mock] Auto-starting ${recipeId} at initialization`,
2996
- {
2997
- currentAmount,
2998
- maxValue: condition.maxValue,
2999
- entity: condition.entity
3000
- }
3001
- );
3002
- setTimeout(() => {
3003
- this.executeRecipe(appIdentifier, recipeId, {});
3004
- }, 1e3);
3005
- }
3006
- } else {
3007
- console.log(
3008
- `[Venus Simulation Mock] Auto-starting ${recipeId} at initialization (no condition)`
3009
- );
3010
- setTimeout(() => {
3011
- this.executeRecipe(appIdentifier, recipeId, {});
3012
- }, 1e3);
3013
- }
3014
- }
3015
- });
2902
+ ensureValidSubscribeOptions(options) {
2903
+ if (typeof options !== "object" || options === null) {
2904
+ throw new Error("Simulation subscribe requires an options object");
3016
2905
  }
3017
- return state;
3018
- }
3019
- generateRunId() {
3020
- return "run_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9);
3021
- }
3022
- completeRun(appIdentifier, runId) {
3023
- this.log(`Completing run ${runId} for ${appIdentifier}`);
3024
- const mockSimulationConfigs = this.mockSimulationConfigs;
3025
- const mockSimulationStates = this.mockSimulationStates;
3026
- const config = mockSimulationConfigs.get(appIdentifier);
3027
- const state = mockSimulationStates.get(appIdentifier);
3028
- if (!config || !state) return;
3029
- const runIndex = state.activeRuns.findIndex((r) => r.id === runId);
3030
- if (runIndex === -1) return;
3031
- const run = state.activeRuns[runIndex];
3032
- const recipe = config.recipes?.[run.recipeId];
3033
- if (!recipe) return;
3034
- const outputs = {};
3035
- const rng = this.createSeededRandom(runId);
3036
- if (recipe.outputs) {
3037
- for (const [entityId, value] of Object.entries(recipe.outputs)) {
3038
- if (typeof value === "number") {
3039
- outputs[entityId] = value;
3040
- } else if (typeof value === "object" && value != null && "min" in value && "max" in value && typeof value.min == "number" && typeof value.max === "number") {
3041
- outputs[entityId] = Math.floor(rng() * (value.max - value.min + 1)) + value.min;
3042
- }
3043
- }
3044
- }
3045
- for (const [entityId, amount] of Object.entries(outputs)) {
3046
- state.inventory[entityId] = (state.inventory[entityId] || 0) + amount;
3047
- }
3048
- if (recipe.endEffects) {
3049
- 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");
3050
2909
  }
3051
- run.status = "completed";
3052
- run.outputs = outputs;
3053
- state.activeRuns.splice(runIndex, 1);
3054
- const isAutoRestart = recipe.autoRestart || recipe.metadata?.autoRestart;
3055
- if (isAutoRestart) {
3056
- console.log(
3057
- `[Venus Simulation Mock] Checking auto-restart for ${run.recipeId}`,
3058
- {
3059
- topLevelAutoRestart: recipe.autoRestart,
3060
- metadataAutoRestart: recipe.metadata?.autoRestart,
3061
- hasCondition: !!(recipe.maxRestartCondition || recipe.metadata?.maxRestartCondition)
3062
- }
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)"
3063
2914
  );
3064
- const condition = recipe.maxRestartCondition || recipe.metadata?.maxRestartCondition;
3065
- if (condition) {
3066
- const currentAmount = state.inventory[condition.entity] || 0;
3067
- if (currentAmount < condition.maxValue) {
3068
- console.log(
3069
- `[Venus Simulation Mock] Auto-restarting ${run.recipeId}`,
3070
- {
3071
- currentAmount,
3072
- maxValue: condition.maxValue,
3073
- entity: condition.entity
3074
- }
3075
- );
3076
- setTimeout(() => {
3077
- this.executeRecipe(appIdentifier, run.recipeId, recipe.inputs || {});
3078
- }, 1e3);
3079
- }
3080
- } else {
3081
- console.log(
3082
- `[Venus Simulation Mock] Auto-restarting ${run.recipeId} (no condition)`
3083
- );
3084
- setTimeout(() => {
3085
- this.executeRecipe(appIdentifier, run.recipeId, recipe.inputs || {});
3086
- }, 1e3);
3087
- }
3088
- }
3089
- console.log(
3090
- `[Venus Simulation Mock] Completed run ${runId}, outputs:`,
3091
- outputs
3092
- );
3093
- }
3094
- createSeededRandom(seed) {
3095
- let hash = 0;
3096
- for (let i = 0; i < seed.length; i++) {
3097
- const char = seed.charCodeAt(i);
3098
- hash = (hash << 5) - hash + char;
3099
- hash = hash & hash;
3100
- }
3101
- return () => {
3102
- hash = (hash * 9301 + 49297) % 233280;
3103
- return hash / 233280;
3104
- };
3105
- }
3106
- applyEffects(state, effects) {
3107
- if (!effects || !Array.isArray(effects)) return;
3108
- for (const effect of effects) {
3109
- switch (effect.type) {
3110
- case "set":
3111
- state.inventory[effect.target] = effect.value;
3112
- console.log(
3113
- `[Venus Simulation Mock] Effect: Set ${effect.target} = ${effect.value}`
3114
- );
3115
- break;
3116
- case "add":
3117
- state.inventory[effect.target] = (state.inventory[effect.target] || 0) + effect.value;
3118
- console.log(
3119
- `[Venus Simulation Mock] Effect: Add ${effect.value} to ${effect.target} (new value: ${state.inventory[effect.target]})`
3120
- );
3121
- break;
3122
- case "multiply":
3123
- state.inventory[effect.target] = (state.inventory[effect.target] || 0) * effect.value;
3124
- console.log(
3125
- `[Venus Simulation Mock] Effect: Multiply ${effect.target} by ${effect.value} (new value: ${state.inventory[effect.target]})`
3126
- );
3127
- break;
3128
- case "min":
3129
- state.inventory[effect.target] = Math.max(
3130
- state.inventory[effect.target] || 0,
3131
- effect.value
3132
- );
3133
- console.log(
3134
- `[Venus Simulation Mock] Effect: Set ${effect.target} min ${effect.value} (new value: ${state.inventory[effect.target]})`
3135
- );
3136
- break;
3137
- case "max":
3138
- state.inventory[effect.target] = Math.min(
3139
- state.inventory[effect.target] || 0,
3140
- effect.value
3141
- );
3142
- console.log(
3143
- `[Venus Simulation Mock] Effect: Set ${effect.target} max ${effect.value} (new value: ${state.inventory[effect.target]})`
3144
- );
3145
- break;
3146
- case "enable_recipe":
3147
- if (state.disabledRecipes?.includes(effect.target)) {
3148
- state.disabledRecipes = state.disabledRecipes.filter(
3149
- (r) => r !== effect.target
3150
- );
3151
- console.log(
3152
- `[Venus Simulation Mock] Effect: Enabled recipe ${effect.target}`
3153
- );
3154
- }
3155
- break;
3156
- case "disable_recipe":
3157
- if (!state.disabledRecipes) state.disabledRecipes = [];
3158
- if (!state.disabledRecipes.includes(effect.target)) {
3159
- state.disabledRecipes.push(effect.target);
3160
- console.log(
3161
- `[Venus Simulation Mock] Effect: Disabled recipe ${effect.target}`
3162
- );
3163
- }
3164
- break;
3165
- case "trigger_recipe":
3166
- console.log(
3167
- `[Venus Simulation Mock] Effect: Trigger recipe ${effect.target} (not implemented)`
3168
- );
3169
- break;
3170
- default:
3171
- console.warn(
3172
- `[Venus Simulation Mock] Unknown effect type: ${effect.type}`
3173
- );
3174
- }
3175
2915
  }
3176
2916
  }
3177
- async getConfigAsync() {
3178
- console.log("[Venus Simulation Mock] getConfigAsync called");
3179
- const appIdentifier = this.appId;
3180
- const mockSimulationConfigs = this.mockSimulationConfigs;
3181
- const config = mockSimulationConfigs.get(appIdentifier) || {
3182
- version: "1.0",
3183
- entities: {},
3184
- recipes: {}
3185
- };
3186
- return config;
3187
- }
3188
- async getStateAsync(roomId) {
3189
- this.log("getStateAsync called:", roomId);
3190
- const appIdentifier = this.appId;
3191
- const mockSimulationStates = this.mockSimulationStates;
3192
- let state = mockSimulationStates.get(appIdentifier);
3193
- if (!state) {
3194
- state = await this.initializeSimulationState(appIdentifier);
3195
- }
3196
- const mockSimulationConfigs = this.mockSimulationConfigs;
3197
- return {
3198
- ...state,
3199
- roomId,
3200
- configuration: mockSimulationConfigs.get(appIdentifier)
3201
- };
3202
- }
3203
- async assignItemToSlotAsync(containerId, slotId, itemId) {
3204
- this.log("assignItemToSlotAsync called:", {
3205
- containerId,
3206
- slotId,
3207
- itemId
3208
- });
3209
- return { success: true, message: "Mock assignment successful" };
3210
- }
3211
- async removeItemFromSlotAsync(containerId, slotId) {
3212
- this.log("removeItemFromSlotAsync called:", {
3213
- containerId,
3214
- slotId
3215
- });
3216
- return { success: true, message: "Mock removal successful" };
3217
- }
3218
2917
  };
3219
2918
 
3220
2919
  // src/simulation/index.ts
3221
2920
  function initializeSimulation(venusApi, host) {
3222
- console.log("[Venus SDK] Initializing new Simulation Api");
3223
2921
  venusApi.simulation = {
3224
2922
  isEnabled: () => true
3225
2923
  };
3226
2924
  venusApi.simulation.getConfigAsync = () => {
3227
2925
  return host.simulation.getConfigAsync();
3228
2926
  };
3229
- venusApi.simulation.getStateAsync = (options) => {
3230
- return host.simulation.getStateAsync(options?.roomId);
2927
+ venusApi.simulation.getStateAsync = (roomId) => {
2928
+ return host.simulation.getStateAsync(roomId);
3231
2929
  };
3232
2930
  venusApi.simulation.executeRecipeAsync = (recipeId, inputs, options) => {
3233
2931
  return host.simulation.executeRecipeAsync(recipeId, inputs, options);
@@ -3238,31 +2936,17 @@ function initializeSimulation(venusApi, host) {
3238
2936
  venusApi.simulation.collectRecipeAsync = (runId) => {
3239
2937
  return host.simulation.collectRecipeAsync(runId);
3240
2938
  };
3241
- venusApi.simulation.executeScopedRecipeAsync = (recipeId, entity, inputs, roomId, options) => {
3242
- return host.simulation.executeScopedRecipeAsync(recipeId, entity, inputs, {
3243
- roomId,
3244
- ...options
3245
- });
2939
+ venusApi.simulation.executeScopedRecipeAsync = (recipeId, entity, inputs, options) => {
2940
+ return host.simulation.executeScopedRecipeAsync(recipeId, entity, inputs, options);
3246
2941
  };
3247
- venusApi.simulation.triggerRecipeChainAsync = (recipeId, context, roomId) => {
3248
- return host.simulation.triggerRecipeChainAsync(recipeId, {
3249
- context,
3250
- roomId
3251
- });
2942
+ venusApi.simulation.triggerRecipeChainAsync = (recipeId, options) => {
2943
+ return host.simulation.triggerRecipeChainAsync(recipeId, options);
3252
2944
  };
3253
- venusApi.simulation.getAvailableRecipesAsync = async (roomId, includeActorRecipes) => {
3254
- const result = await host.simulation.getAvailableRecipesAsync({
3255
- roomId,
3256
- includeActorRecipes
3257
- });
3258
- return result.recipes;
2945
+ venusApi.simulation.getAvailableRecipesAsync = async (options) => {
2946
+ return host.simulation.getAvailableRecipesAsync(options);
3259
2947
  };
3260
- venusApi.simulation.getRecipeRequirementsAsync = (recipeId, entity, amount) => {
3261
- return host.simulation.getRecipeRequirementsAsync({
3262
- recipeId,
3263
- entity,
3264
- batchAmount: amount
3265
- });
2948
+ venusApi.simulation.getRecipeRequirementsAsync = (recipe) => {
2949
+ return host.simulation.getRecipeRequirementsAsync(recipe);
3266
2950
  };
3267
2951
  venusApi.simulation.getBatchRecipeRequirementsAsync = (recipes) => {
3268
2952
  return host.simulation.getBatchRecipeRequirementsAsync(recipes);
@@ -3305,9 +2989,6 @@ function initializeSimulation(venusApi, host) {
3305
2989
  itemId
3306
2990
  );
3307
2991
  };
3308
- venusApi.simulation.sumContributions = (contributions) => {
3309
- return host.simulation.sumContributions(contributions);
3310
- };
3311
2992
  }
3312
2993
 
3313
2994
  // src/time/utils.ts
@@ -3326,9 +3007,11 @@ function isPacificDaylightTime(date) {
3326
3007
 
3327
3008
  // src/time/HostTimeApi.ts
3328
3009
  var HostTimeApi = class {
3329
- constructor(rpcClient) {
3010
+ constructor(rpcClient, venusApi) {
3330
3011
  __publicField(this, "rpcClient");
3012
+ __publicField(this, "venusApi");
3331
3013
  this.rpcClient = rpcClient;
3014
+ this.venusApi = venusApi;
3332
3015
  }
3333
3016
  async requestTimeAsync() {
3334
3017
  const response = await this.rpcClient.call(
@@ -3338,13 +3021,7 @@ var HostTimeApi = class {
3338
3021
  return response;
3339
3022
  }
3340
3023
  formatTime(timestamp, options) {
3341
- let locale = "en-US";
3342
- const windowVenus = window.venus;
3343
- if (windowVenus._config.locale) {
3344
- locale = windowVenus._config.locale;
3345
- } else if (windowVenus._config.environment && windowVenus._config.environment.browserInfo && windowVenus._config.environment.browserInfo.language) {
3346
- locale = windowVenus._config.environment.browserInfo.language;
3347
- }
3024
+ const locale = this.venusApi.getLocale();
3348
3025
  const date = new Date(timestamp);
3349
3026
  const dateTimeOptions = {
3350
3027
  dateStyle: options.dateStyle || "medium",
@@ -3356,13 +3033,7 @@ var HostTimeApi = class {
3356
3033
  }
3357
3034
  formatNumber(value, options) {
3358
3035
  try {
3359
- let locale = "en-US";
3360
- const windowVenus = window.venus;
3361
- if (windowVenus._config.locale) {
3362
- locale = windowVenus._config.locale;
3363
- } else if (windowVenus._config.environment && windowVenus._config.environment.browserInfo && windowVenus._config.environment.browserInfo.language) {
3364
- locale = windowVenus._config.environment.browserInfo.language;
3365
- }
3036
+ const locale = this.venusApi.getLocale();
3366
3037
  const numberOptions = {
3367
3038
  style: options?.style || "decimal",
3368
3039
  minimumFractionDigits: options?.minimumFractionDigits || 0,
@@ -3425,18 +3096,17 @@ var MockTimeApi = class {
3425
3096
  this.venusApi = venusApi;
3426
3097
  }
3427
3098
  formatNumber(value, options) {
3428
- const locale = this.getLocale();
3099
+ const locale = this.venusApi.getLocale();
3429
3100
  const numberOptions = {
3430
3101
  style: options?.style || "decimal",
3431
3102
  minimumFractionDigits: options?.minimumFractionDigits || 0,
3432
3103
  maximumFractionDigits: options?.maximumFractionDigits || 2,
3433
3104
  ...options
3434
3105
  };
3435
- console.log(`[Venus Mock] Formatting number ${value} with locale ${locale}`);
3436
3106
  return value.toLocaleString(locale, numberOptions);
3437
3107
  }
3438
3108
  formatTime(timestamp, options) {
3439
- const locale = this.getLocale();
3109
+ const locale = this.venusApi.getLocale();
3440
3110
  const date = new Date(timestamp);
3441
3111
  const dateTimeOptions = {
3442
3112
  dateStyle: options.dateStyle || "medium",
@@ -3444,13 +3114,9 @@ var MockTimeApi = class {
3444
3114
  hour12: options.hour12 !== void 0 ? options.hour12 : true,
3445
3115
  ...options
3446
3116
  };
3447
- console.log(
3448
- `[Venus Mock] Formatting time ${timestamp} with locale ${locale}`
3449
- );
3450
3117
  return date.toLocaleString(locale, dateTimeOptions);
3451
3118
  }
3452
3119
  async getFutureTimeAsync(options) {
3453
- console.log("[Venus Mock] Getting future time with options:", options);
3454
3120
  const timeInfo = await this.requestTimeAsync();
3455
3121
  const serverTime = new Date(timeInfo.serverTime);
3456
3122
  const result = new Date(serverTime);
@@ -3495,7 +3161,6 @@ var MockTimeApi = class {
3495
3161
  return result.getTime();
3496
3162
  }
3497
3163
  async requestTimeAsync() {
3498
- console.log("[Venus Mock] Requesting time");
3499
3164
  await createMockDelay(MOCK_DELAYS.short);
3500
3165
  const venusApi = this.venusApi;
3501
3166
  const mockOffset = venusApi._mock.serverTimeOffset || 2500;
@@ -3509,23 +3174,8 @@ var MockTimeApi = class {
3509
3174
  formattedTime: new Date(localTime).toISOString(),
3510
3175
  locale: venusApi._mock.user?.locale || "en-US"
3511
3176
  };
3512
- console.log("[Venus Mock] Time response:", {
3513
- serverTime: new Date(timeInfo.serverTime).toISOString(),
3514
- localTime: new Date(timeInfo.localTime).toISOString(),
3515
- timezoneOffset: timeInfo.timezoneOffset
3516
- });
3517
3177
  return timeInfo;
3518
3178
  }
3519
- getLocale() {
3520
- const venusApi = this.venusApi;
3521
- let locale = "en-US";
3522
- if (venusApi._mock.user && venusApi._mock.user.locale) {
3523
- locale = venusApi._mock.user.locale;
3524
- } else if (venusApi._mock.environment && venusApi._mock.environment.browserInfo.language) {
3525
- locale = venusApi._mock.environment.browserInfo.language;
3526
- }
3527
- return locale;
3528
- }
3529
3179
  };
3530
3180
 
3531
3181
  // src/time/index.ts
@@ -3545,7 +3195,7 @@ function initializeTime(venusApi, host) {
3545
3195
  }
3546
3196
 
3547
3197
  // src/version.ts
3548
- var SDK_VERSION = "3.0.4";
3198
+ var SDK_VERSION = "3.0.5";
3549
3199
 
3550
3200
  // src/shared-assets/consts.ts
3551
3201
  var BurgerTimeAssetsCdnPath = "burger-time/Core.stow";
@@ -3616,47 +3266,106 @@ var MockSharedAssetsApi = class {
3616
3266
  }
3617
3267
  };
3618
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
+
3619
3289
  // src/leaderboard/RpcLeaderboardApi.ts
3620
3290
  var RpcLeaderboardApi = class {
3621
3291
  constructor(rpcClient) {
3622
3292
  __publicField(this, "rpcClient");
3293
+ /** Cache of score tokens for automatic hash computation */
3294
+ __publicField(this, "tokenCache", /* @__PURE__ */ new Map());
3623
3295
  this.rpcClient = rpcClient;
3624
3296
  }
3625
- startRun(mode) {
3626
- return this.rpcClient.call(
3627
- "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 */,
3628
3307
  mode ? { mode } : {}
3629
3308
  );
3309
+ this.tokenCache.set(token.token, token);
3310
+ return token;
3630
3311
  }
3631
- 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
+ }
3632
3340
  return this.rpcClient.call(
3633
3341
  "H5_LEADERBOARD_SUBMIT_SCORE" /* H5_LEADERBOARD_SUBMIT_SCORE */,
3634
3342
  {
3635
- sessionId,
3636
- score,
3637
- durationSec,
3638
- mode: options?.mode,
3639
- telemetry: options?.telemetry,
3640
- metadata: options?.metadata,
3641
- 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
3642
3351
  }
3643
3352
  );
3644
3353
  }
3645
- getLeaderboard(options) {
3354
+ getPagedScores(options) {
3646
3355
  return this.rpcClient.call(
3647
- "H5_LEADERBOARD_GET" /* H5_LEADERBOARD_GET */,
3356
+ "H5_LEADERBOARD_GET_PAGED_SCORES" /* H5_LEADERBOARD_GET_PAGED_SCORES */,
3648
3357
  options ?? {}
3649
3358
  );
3650
3359
  }
3651
- getPlayerStats(options) {
3360
+ getMyRank(options) {
3652
3361
  return this.rpcClient.call(
3653
- "H5_LEADERBOARD_GET_PLAYER_STATS" /* H5_LEADERBOARD_GET_PLAYER_STATS */,
3362
+ "H5_LEADERBOARD_GET_MY_RANK" /* H5_LEADERBOARD_GET_MY_RANK */,
3654
3363
  options ?? {}
3655
3364
  );
3656
3365
  }
3657
- getLeaderboardHighlight(options) {
3366
+ getPodiumScores(options) {
3658
3367
  return this.rpcClient.call(
3659
- "H5_LEADERBOARD_GET_HIGHLIGHT" /* H5_LEADERBOARD_GET_HIGHLIGHT */,
3368
+ "H5_LEADERBOARD_GET_PODIUM_SCORES" /* H5_LEADERBOARD_GET_PODIUM_SCORES */,
3660
3369
  options ?? {}
3661
3370
  );
3662
3371
  }
@@ -3665,17 +3374,31 @@ var RpcLeaderboardApi = class {
3665
3374
  // src/leaderboard/MockLeaderboardApi.ts
3666
3375
  var MockLeaderboardApi = class {
3667
3376
  constructor(options) {
3668
- __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());
3669
3380
  __publicField(this, "entriesByMode", /* @__PURE__ */ new Map());
3670
- __publicField(this, "sessionCounter", 0);
3671
- __publicField(this, "requiresHash", false);
3672
- if (options?.requiresHash) {
3673
- 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;
3674
3389
  }
3675
3390
  }
3391
+ /**
3392
+ * Configure mock leaderboard settings
3393
+ *
3394
+ * @param options - Configuration options
3395
+ */
3676
3396
  configure(options) {
3677
- if (typeof options.requiresHash === "boolean") {
3678
- 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;
3679
3402
  }
3680
3403
  }
3681
3404
  generateNonce() {
@@ -3692,83 +3415,149 @@ var MockLeaderboardApi = class {
3692
3415
  }
3693
3416
  return this.entriesByMode.get(key);
3694
3417
  }
3695
- async startRun(mode) {
3696
- 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}`;
3697
3427
  const startTime = Date.now();
3698
3428
  const expiresAt = startTime + 36e5;
3699
3429
  const resolvedMode = mode || "default";
3700
- const hashNonce = this.requiresHash ? this.generateNonce() : null;
3701
- this.sessions.set(sessionId, {
3702
- 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,
3703
3434
  expiresAt,
3704
3435
  mode: resolvedMode,
3705
- hashNonce,
3436
+ sealingNonce,
3706
3437
  used: false
3707
3438
  });
3708
- return {
3709
- sessionId,
3439
+ const result = {
3440
+ token,
3710
3441
  startTime,
3711
3442
  expiresAt,
3712
- hashNonce,
3443
+ sealingNonce,
3444
+ sealingSecret,
3713
3445
  mode: resolvedMode
3714
3446
  };
3447
+ this.tokenCache.set(token, result);
3448
+ return result;
3715
3449
  }
3716
- async submitScore(sessionId, score, durationSec, options) {
3717
- const session = this.sessions.get(sessionId);
3718
- if (!session) {
3719
- 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");
3720
3513
  }
3721
- if (session.expiresAt < Date.now()) {
3722
- throw new Error("Invalid or expired leaderboard session");
3514
+ if (scoreToken.expiresAt < Date.now()) {
3515
+ throw new Error("Invalid or expired score token");
3723
3516
  }
3724
- if (session.used) {
3725
- throw new Error("Leaderboard session already used");
3517
+ if (scoreToken.used) {
3518
+ throw new Error("Score token already used");
3726
3519
  }
3727
- if (options?.mode && options.mode !== session.mode) {
3728
- 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");
3729
3522
  }
3730
- if (session.hashNonce && !options?.hash) {
3731
- 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");
3732
3525
  }
3733
3526
  const submittedAt = Date.now();
3734
3527
  const entry = {
3735
3528
  profileId: `mock_profile`,
3736
3529
  username: "Mock Player",
3737
3530
  avatarUrl: null,
3738
- score,
3739
- durationSec,
3531
+ score: params.score,
3532
+ duration: params.duration,
3740
3533
  submittedAt,
3741
- sessionId,
3534
+ token: params.token,
3742
3535
  rank: null,
3743
3536
  zScore: null,
3744
3537
  isAnomaly: false,
3745
3538
  trustScore: 50,
3746
- metadata: options?.metadata ?? null,
3539
+ metadata: params.metadata ?? null,
3747
3540
  isSeed: false
3748
3541
  };
3749
- const modeEntries = this.getEntriesForMode(session.mode);
3542
+ const modeEntries = this.getEntriesForMode(scoreToken.mode);
3750
3543
  modeEntries.push(entry);
3751
3544
  modeEntries.sort((a, b) => {
3752
- if (b.score !== a.score) {
3753
- return b.score - a.score;
3754
- }
3545
+ if (b.score !== a.score) return b.score - a.score;
3755
3546
  return a.submittedAt - b.submittedAt;
3756
3547
  });
3757
3548
  modeEntries.forEach((e, index) => {
3758
- modeEntries[index] = {
3759
- ...e,
3760
- rank: index + 1
3761
- };
3549
+ modeEntries[index] = { ...e, rank: index + 1 };
3762
3550
  });
3763
- session.used = true;
3764
- session.hashNonce = null;
3765
- 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);
3766
3555
  return {
3767
3556
  accepted: true,
3768
3557
  rank: inserted?.rank ?? null
3769
3558
  };
3770
3559
  }
3771
- async getLeaderboard(options) {
3560
+ async getPagedScores(options) {
3772
3561
  const limit = options?.limit ?? 10;
3773
3562
  const mode = options?.mode ?? "default";
3774
3563
  const modeEntries = [...this.getEntriesForMode(mode)];
@@ -3784,7 +3573,7 @@ var MockLeaderboardApi = class {
3784
3573
  periodInstance: options?.period ?? "alltime"
3785
3574
  };
3786
3575
  }
3787
- async getPlayerStats(_options) {
3576
+ async getMyRank(_options) {
3788
3577
  const mode = _options?.mode ?? "default";
3789
3578
  const modeEntries = this.getEntriesForMode(mode);
3790
3579
  const playerEntry = modeEntries[0] ?? null;
@@ -3797,7 +3586,7 @@ var MockLeaderboardApi = class {
3797
3586
  periodInstance: _options?.period ?? "alltime"
3798
3587
  };
3799
3588
  }
3800
- async getLeaderboardHighlight(options) {
3589
+ async getPodiumScores(options) {
3801
3590
  const mode = options?.mode ?? "default";
3802
3591
  const modeEntries = [...this.getEntriesForMode(mode)];
3803
3592
  const topCount = Math.max(1, Math.min(options?.topCount ?? 3, 10));
@@ -3909,7 +3698,6 @@ var MockPostApi = class {
3909
3698
  }
3910
3699
  async toggleFollowAsync() {
3911
3700
  const venusApi = this.venusApi;
3912
- console.log("[Venus Mock] *Toggling follow status");
3913
3701
  await createMockDelay(MOCK_DELAYS.short);
3914
3702
  venusApi._mock.currentPostInteractions.isFollowing = !venusApi._mock.currentPostInteractions.isFollowing;
3915
3703
  const isFollowing = venusApi._mock.currentPostInteractions.isFollowing;
@@ -4080,6 +3868,16 @@ var VenusTransport = class {
4080
3868
  this.isProcessingMessage = false;
4081
3869
  return;
4082
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
+ }
4083
3881
  const requestId = messageData.requestId;
4084
3882
  if (!requestId) {
4085
3883
  this.logWarn("No requestId. Ignoring message...");
@@ -4246,294 +4044,6 @@ var VenusTransport = class {
4246
4044
  }
4247
4045
  };
4248
4046
 
4249
- // src/RemoteHost.ts
4250
- init_rooms();
4251
-
4252
- // src/rooms/RpcRoomsApi.ts
4253
- init_VenusRoom();
4254
- var RpcRoomsApi = class {
4255
- constructor(rpcClient) {
4256
- __publicField(this, "rpcClient");
4257
- __publicField(this, "subscriptions");
4258
- __publicField(this, "transportSubscription", null);
4259
- this.rpcClient = rpcClient;
4260
- this.subscriptions = {
4261
- data: {},
4262
- messages: {},
4263
- gameEvents: {},
4264
- allEvents: {}
4265
- };
4266
- }
4267
- /**
4268
- * Get the subscription state for external access (used by setupRoomNotifications)
4269
- */
4270
- getSubscriptions() {
4271
- return this.subscriptions;
4272
- }
4273
- /**
4274
- * Set up room notification routing from the transport
4275
- */
4276
- setupNotifications(transport) {
4277
- const { setupRoomNotifications: setupRoomNotifications2 } = (init_rooms(), __toCommonJS(rooms_exports));
4278
- this.transportSubscription = setupRoomNotifications2(
4279
- transport,
4280
- () => this.getSubscriptions()
4281
- );
4282
- }
4283
- /**
4284
- * Clean up subscriptions and resources
4285
- */
4286
- dispose() {
4287
- if (this.transportSubscription) {
4288
- this.transportSubscription.unsubscribe();
4289
- this.transportSubscription = null;
4290
- console.log("[Venus Rooms] Cleaned up room notification subscription");
4291
- }
4292
- }
4293
- async createRoom(options) {
4294
- const response = await this.rpcClient.call(
4295
- "H5_ROOM_CREATE" /* H5_ROOM_CREATE */,
4296
- {
4297
- options
4298
- }
4299
- );
4300
- if (response.success === false) {
4301
- throw new Error(response.error || "Failed to create room");
4302
- }
4303
- const roomData = response.roomData || response;
4304
- const room = new VenusRoom(roomData);
4305
- return room;
4306
- }
4307
- async joinOrCreateRoom(options) {
4308
- const response = await this.rpcClient.call(
4309
- "H5_ROOM_JOIN_OR_CREATE" /* H5_ROOM_JOIN_OR_CREATE */,
4310
- {
4311
- options
4312
- }
4313
- );
4314
- if (response.success === false) {
4315
- throw new Error(response.error || "Failed to join or create room");
4316
- }
4317
- const data = response.value || response;
4318
- const room = new VenusRoom(data.roomData);
4319
- return {
4320
- action: data.action,
4321
- room,
4322
- playersJoined: data.playersJoined
4323
- };
4324
- }
4325
- async joinRoomByCode(roomCode) {
4326
- const response = await this.rpcClient.call(
4327
- "H5_ROOM_JOIN_BY_CODE" /* H5_ROOM_JOIN_BY_CODE */,
4328
- {
4329
- roomCode
4330
- }
4331
- );
4332
- if (response?.success === false) {
4333
- throw new Error(response.error || "Failed to join room by code");
4334
- }
4335
- const roomData = response.roomData || response;
4336
- const room = new VenusRoom(roomData);
4337
- return room;
4338
- }
4339
- // Get user's rooms with optional filtering
4340
- async getUserRooms(includeArchived = false) {
4341
- const response = await this.rpcClient.call(
4342
- "H5_ROOM_GET_USER_ROOMS" /* H5_ROOM_GET_USER_ROOMS */,
4343
- {
4344
- includeArchived
4345
- }
4346
- );
4347
- if (response?.success === false) {
4348
- throw new Error(response.error || "Failed to get user rooms");
4349
- }
4350
- const rawRooms = response.rooms || [];
4351
- const venusRooms = [];
4352
- for (const roomData of rawRooms) {
4353
- if (!roomData.id) {
4354
- console.warn("getUserRooms: Skipping room with missing ID:", roomData);
4355
- continue;
4356
- }
4357
- try {
4358
- const venusRoom = new VenusRoom(roomData);
4359
- venusRooms.push(venusRoom);
4360
- } catch (error) {
4361
- console.warn(
4362
- "getUserRooms: Failed to create VenusRoom object:",
4363
- error,
4364
- roomData
4365
- );
4366
- }
4367
- }
4368
- return venusRooms;
4369
- }
4370
- async updateData(room, updates, merge = true) {
4371
- const response = await this.rpcClient.call(
4372
- "H5_ROOM_UPDATE_DATA" /* H5_ROOM_UPDATE_DATA */,
4373
- {
4374
- roomId: room.id,
4375
- updates,
4376
- merge
4377
- }
4378
- );
4379
- if (response?.success === false) {
4380
- throw new Error(response.error || "Failed to update room data");
4381
- }
4382
- return response.data;
4383
- }
4384
- async getData(room) {
4385
- const response = await this.rpcClient.call(
4386
- "H5_ROOM_GET_DATA" /* H5_ROOM_GET_DATA */,
4387
- {
4388
- roomId: room.id
4389
- }
4390
- );
4391
- if (response?.success === false) {
4392
- throw new Error(response.error || "Failed to get room data");
4393
- }
4394
- return response.data;
4395
- }
4396
- async sendMessage(venusRoom, messageData) {
4397
- const response = await this.rpcClient.call(
4398
- "H5_ROOM_SEND_MESSAGE" /* H5_ROOM_SEND_MESSAGE */,
4399
- {
4400
- roomId: venusRoom.id,
4401
- message: messageData
4402
- }
4403
- );
4404
- if (response?.success === false) {
4405
- throw new Error(response.error || "Failed to send message");
4406
- }
4407
- return response.messageId;
4408
- }
4409
- async leave(room) {
4410
- const response = await this.rpcClient.call(
4411
- "H5_ROOM_LEAVE" /* H5_ROOM_LEAVE */,
4412
- {
4413
- roomId: room.id
4414
- }
4415
- );
4416
- if (response?.success === false) {
4417
- throw new Error(response.error || "Failed to leave room");
4418
- }
4419
- return response;
4420
- }
4421
- async startGame(room, gameConfig = {}, turnOrder = null) {
4422
- const response = await this.rpcClient.call(
4423
- "H5_ROOM_START_GAME" /* H5_ROOM_START_GAME */,
4424
- {
4425
- roomId: room.id,
4426
- gameConfig,
4427
- turnOrder
4428
- }
4429
- );
4430
- if (response?.success === false) {
4431
- throw new Error(response.error || "Failed to start game");
4432
- }
4433
- return response.data;
4434
- }
4435
- async proposeMove(room, proposalPayload) {
4436
- const response = await this.rpcClient.call(
4437
- "h5:room:proposeMove" /* H5_ROOM_PROPOSE_MOVE */,
4438
- {
4439
- roomId: room.id,
4440
- gameSpecificState: proposalPayload.gameSpecificState,
4441
- moveType: proposalPayload.moveType,
4442
- clientContext: proposalPayload.clientContext,
4443
- clientProposalId: proposalPayload.clientProposalId
4444
- }
4445
- );
4446
- if (response?.success === false) {
4447
- throw new Error(response.error || "Failed to propose move");
4448
- }
4449
- return response.data;
4450
- }
4451
- async validateMove(room, moveId, isValid, reason = null, validatorId = null) {
4452
- console.log(`[Venus Rooms] Validating move ${moveId}: ${isValid}`);
4453
- return { success: true, moveId, isValid, reason };
4454
- }
4455
- async roomSubscribeToGameEvents(room, callback) {
4456
- "game_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9);
4457
- if (!this.subscriptions.gameEvents[room.id]) {
4458
- this.subscriptions.gameEvents[room.id] = [];
4459
- }
4460
- this.subscriptions.gameEvents[room.id].push(callback);
4461
- }
4462
- subscribe(room, options = {}) {
4463
- const subscriptionIds = [];
4464
- const roomId = room.id;
4465
- if (options.onData) {
4466
- const dataSubId = "data_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9);
4467
- if (!this.subscriptions.data[roomId]) {
4468
- this.subscriptions.data[roomId] = [];
4469
- }
4470
- this.subscriptions.data[roomId].push(options.onData);
4471
- subscriptionIds.push({
4472
- type: "data",
4473
- id: dataSubId,
4474
- callback: options.onData
4475
- });
4476
- }
4477
- if (options.onMessages) {
4478
- const msgSubId = "messages_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9);
4479
- if (!this.subscriptions.messages[roomId]) {
4480
- this.subscriptions.messages[roomId] = [];
4481
- }
4482
- this.subscriptions.messages[roomId].push(options.onMessages);
4483
- subscriptionIds.push({
4484
- type: "messages",
4485
- id: msgSubId,
4486
- callback: options.onMessages
4487
- });
4488
- }
4489
- if (options.onMoves || options.onGameEvents) {
4490
- const handler = options.onMoves || options.onGameEvents;
4491
- if (handler) {
4492
- const gameSubId = "game_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9);
4493
- if (!this.subscriptions.gameEvents[roomId]) {
4494
- this.subscriptions.gameEvents[roomId] = [];
4495
- }
4496
- this.subscriptions.gameEvents[roomId].push(handler);
4497
- subscriptionIds.push({
4498
- type: "gameEvents",
4499
- id: gameSubId,
4500
- callback: handler
4501
- });
4502
- }
4503
- }
4504
- 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;
4505
- if (needsSubscription) {
4506
- this.rpcClient.call("H5_ROOM_SUBSCRIBE" /* H5_ROOM_SUBSCRIBE */, {
4507
- roomId,
4508
- subscribeToData: !!options.onData,
4509
- subscribeToMessages: !!options.onMessages,
4510
- subscribeToProposedMoves: !!(options.onMoves || options.onGameEvents)
4511
- }).catch((error) => {
4512
- console.error("Failed to set up room subscription:", error);
4513
- });
4514
- }
4515
- let called = false;
4516
- return () => {
4517
- if (called) return;
4518
- called = true;
4519
- subscriptionIds.forEach((sub) => {
4520
- const bucket = this.subscriptions[sub.type];
4521
- const callbacks = bucket && bucket[roomId] || [];
4522
- const index = callbacks.indexOf(sub.callback);
4523
- if (index > -1) callbacks.splice(index, 1);
4524
- });
4525
- const hasNoCallbacks = (this.subscriptions.data[roomId]?.length ?? 0) === 0 && (this.subscriptions.messages[roomId]?.length ?? 0) === 0 && (this.subscriptions.gameEvents[roomId]?.length ?? 0) === 0;
4526
- if (hasNoCallbacks) {
4527
- this.rpcClient.call("H5_ROOM_UNSUBSCRIBE" /* H5_ROOM_UNSUBSCRIBE */, {
4528
- roomId
4529
- }).catch((error) => {
4530
- console.error("Failed to clean up room subscription:", error);
4531
- });
4532
- }
4533
- };
4534
- }
4535
- };
4536
-
4537
4047
  // src/RemoteHost.ts
4538
4048
  var getCdnBaseUrl = () => {
4539
4049
  return "https://venus-static-01293ak.web.app/";
@@ -4608,7 +4118,7 @@ var RemoteHost = class {
4608
4118
  this.popups = new RpcPopupsApi(rpcClient);
4609
4119
  this.profile = new HostProfileApi();
4610
4120
  this.cdn = new HostCdnApi(getCdnBaseUrl());
4611
- this.time = new HostTimeApi(rpcClient);
4121
+ this.time = new HostTimeApi(rpcClient, venusApi);
4612
4122
  this.post = new RpcPostApi(rpcClient);
4613
4123
  this.ai = new RpcAiApi(rpcClient);
4614
4124
  this.haptics = new RpcHapticsApi(rpcClient);
@@ -4624,7 +4134,6 @@ var RemoteHost = class {
4624
4134
  venusApi.isMock = () => false;
4625
4135
  this.venusApi.sharedAssets = new RpcSharedAssetsApi(rpcClient, venusApi);
4626
4136
  initializeRoomsApi(this.venusApi, this);
4627
- console.log("[Venus SDK] Remote host created");
4628
4137
  }
4629
4138
  get isInitialized() {
4630
4139
  return this._isInitialized;
@@ -4681,49 +4190,120 @@ var RemoteHost = class {
4681
4190
  };
4682
4191
 
4683
4192
  // src/MockHost.ts
4684
- init_rooms();
4685
4193
  var ROOMS_UNAVAILABLE_MESSAGE = "[Venus SDK] Rooms API is only available when running inside the Venus host environment.";
4686
4194
  function createUnavailableRoomsApi() {
4687
4195
  const roomsUnavailableError = () => new Error(ROOMS_UNAVAILABLE_MESSAGE);
4688
4196
  return {
4689
- async createRoom() {
4197
+ async createRoomAsync() {
4690
4198
  throw roomsUnavailableError();
4691
4199
  },
4692
- async joinOrCreateRoom() {
4200
+ async joinOrCreateRoomAsync() {
4693
4201
  throw roomsUnavailableError();
4694
4202
  },
4695
- async getUserRooms() {
4203
+ async joinRoomByCodeAsync() {
4696
4204
  throw roomsUnavailableError();
4697
4205
  },
4698
- async joinRoomByCode() {
4206
+ async getUserRoomsAsync() {
4699
4207
  throw roomsUnavailableError();
4700
4208
  },
4701
- subscribe() {
4209
+ async subscribeAsync() {
4702
4210
  throw roomsUnavailableError();
4703
4211
  },
4704
- async updateData() {
4212
+ async updateRoomDataAsync() {
4705
4213
  throw roomsUnavailableError();
4706
4214
  },
4707
- async getData() {
4215
+ async getRoomDataAsync() {
4708
4216
  throw roomsUnavailableError();
4709
4217
  },
4710
- async sendMessage() {
4218
+ async sendRoomMessageAsync() {
4711
4219
  throw roomsUnavailableError();
4712
4220
  },
4713
- async leave() {
4221
+ async leaveRoomAsync() {
4714
4222
  throw roomsUnavailableError();
4715
4223
  },
4716
- async startGame() {
4224
+ async startRoomGameAsync() {
4717
4225
  throw roomsUnavailableError();
4718
4226
  },
4719
- async proposeMove() {
4227
+ async proposeMoveAsync() {
4720
4228
  throw roomsUnavailableError();
4721
4229
  },
4722
- async validateMove() {
4230
+ async validateMoveAsync() {
4723
4231
  throw roomsUnavailableError();
4724
4232
  }
4725
4233
  };
4726
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
+ }
4727
4307
  var MockHost = class {
4728
4308
  constructor(venusApi) {
4729
4309
  __publicField(this, "ads");
@@ -4778,7 +4358,7 @@ var MockHost = class {
4778
4358
  this.haptics = new MockHapticsApi(venusApi);
4779
4359
  this.features = new MockFeaturesApi();
4780
4360
  this.lifecycle = this._mockLifecyclesApi;
4781
- this.simulation = new MockSimulationApi();
4361
+ this.simulation = createUnavailableSimulationApi();
4782
4362
  this.rooms = createUnavailableRoomsApi();
4783
4363
  this.logging = new MockLoggingApi();
4784
4364
  this.iap = new MockIapApi();
@@ -5273,10 +4853,8 @@ var MockHost = class {
5273
4853
  // src/Host.ts
5274
4854
  function createHost(venusApi, isMock) {
5275
4855
  if (isMock) {
5276
- console.log("[Venus SDK] Creating Local Host");
5277
4856
  return new MockHost(venusApi);
5278
4857
  } else {
5279
- console.log("[Venus SDK] Creating Remote Host");
5280
4858
  return new RemoteHost(venusApi);
5281
4859
  }
5282
4860
  }
@@ -5289,6 +4867,6 @@ function initializeSocial(venusApi, host) {
5289
4867
  };
5290
4868
  }
5291
4869
 
5292
- 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 };
5293
- //# sourceMappingURL=chunk-PXWCNWJ6.mjs.map
5294
- //# sourceMappingURL=chunk-PXWCNWJ6.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