@series-inc/venus-sdk 3.0.6 → 3.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1180 -14
- package/dist/{AdsApi-CIXV8I_p.d.mts → AdsApi-meVfUcZy.d.mts} +164 -355
- package/dist/{AdsApi-CIXV8I_p.d.ts → AdsApi-meVfUcZy.d.ts} +164 -355
- package/dist/chunk-2PDL7CQK.mjs +26 -0
- package/dist/chunk-2PDL7CQK.mjs.map +1 -0
- package/dist/{chunk-LBJFUHOH.mjs → chunk-EMVTVSGL.mjs} +1471 -737
- package/dist/chunk-EMVTVSGL.mjs.map +1 -0
- package/dist/chunk-IZLOB7DV.mjs +343 -0
- package/dist/chunk-IZLOB7DV.mjs.map +1 -0
- package/dist/{chunk-MWUS3A7C.mjs → chunk-QABXMFND.mjs} +3 -7
- package/dist/chunk-QABXMFND.mjs.map +1 -0
- package/dist/core-5JLON75E.mjs +4 -0
- package/dist/{core-RDMPQV6U.mjs.map → core-5JLON75E.mjs.map} +1 -1
- package/dist/index.cjs +1883 -778
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +113 -61
- package/dist/index.d.ts +113 -61
- package/dist/index.mjs +8 -2
- package/dist/index.mjs.map +1 -1
- package/dist/venus-api/index.cjs +1806 -748
- package/dist/venus-api/index.cjs.map +1 -1
- package/dist/venus-api/index.d.mts +2 -2
- package/dist/venus-api/index.d.ts +2 -2
- package/dist/venus-api/index.mjs +311 -3
- package/dist/venus-api/index.mjs.map +1 -1
- package/dist/vite/index.cjs +534 -0
- package/dist/vite/index.cjs.map +1 -0
- package/dist/vite/index.mjs +527 -0
- package/dist/vite/index.mjs.map +1 -0
- package/dist/webview/index.cjs +346 -0
- package/dist/webview/index.cjs.map +1 -0
- package/dist/webview/index.d.mts +17 -0
- package/dist/webview/index.d.ts +17 -0
- package/dist/webview/index.mjs +4 -0
- package/dist/webview/index.mjs.map +1 -0
- package/package.json +19 -1
- package/dist/chunk-LBJFUHOH.mjs.map +0 -1
- package/dist/chunk-MWUS3A7C.mjs.map +0 -1
- package/dist/core-RDMPQV6U.mjs +0 -3
|
@@ -1,4 +1,220 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createMockDelay, MOCK_DELAYS, isWebPlatform } from './chunk-QABXMFND.mjs';
|
|
2
|
+
import { __esm, __export, __publicField, __toCommonJS } from './chunk-2PDL7CQK.mjs';
|
|
3
|
+
|
|
4
|
+
// src/rooms/VenusRoom.ts
|
|
5
|
+
var VenusRoom;
|
|
6
|
+
var init_VenusRoom = __esm({
|
|
7
|
+
"src/rooms/VenusRoom.ts"() {
|
|
8
|
+
VenusRoom = class {
|
|
9
|
+
constructor(roomData) {
|
|
10
|
+
__publicField(this, "id");
|
|
11
|
+
__publicField(this, "name");
|
|
12
|
+
__publicField(this, "players");
|
|
13
|
+
__publicField(this, "maxPlayers");
|
|
14
|
+
__publicField(this, "gameType");
|
|
15
|
+
__publicField(this, "appId");
|
|
16
|
+
__publicField(this, "type");
|
|
17
|
+
__publicField(this, "createdBy");
|
|
18
|
+
__publicField(this, "createdAt");
|
|
19
|
+
__publicField(this, "updatedAt");
|
|
20
|
+
__publicField(this, "isPrivate");
|
|
21
|
+
__publicField(this, "currentPlayers");
|
|
22
|
+
__publicField(this, "status");
|
|
23
|
+
__publicField(this, "customMetadata");
|
|
24
|
+
__publicField(this, "admins");
|
|
25
|
+
__publicField(this, "roomCode");
|
|
26
|
+
__publicField(this, "description");
|
|
27
|
+
__publicField(this, "data");
|
|
28
|
+
__publicField(this, "version");
|
|
29
|
+
__publicField(this, "_subscriptions", /* @__PURE__ */ new Map());
|
|
30
|
+
this.id = roomData.id;
|
|
31
|
+
this.name = roomData.name;
|
|
32
|
+
this.players = roomData.currentPlayers || [];
|
|
33
|
+
this.maxPlayers = roomData.maxPlayers;
|
|
34
|
+
this.gameType = roomData.gameType;
|
|
35
|
+
this.appId = roomData.appId;
|
|
36
|
+
this.type = roomData.type;
|
|
37
|
+
this.createdBy = roomData.createdBy;
|
|
38
|
+
this.createdAt = roomData.createdAt;
|
|
39
|
+
this.updatedAt = roomData.updatedAt;
|
|
40
|
+
this.isPrivate = roomData.isPrivate;
|
|
41
|
+
this.currentPlayers = roomData.currentPlayers || [];
|
|
42
|
+
this.status = roomData.status;
|
|
43
|
+
this.customMetadata = roomData.customMetadata || {};
|
|
44
|
+
this.admins = roomData.admins || [];
|
|
45
|
+
this.roomCode = roomData.roomCode;
|
|
46
|
+
this.description = roomData.description;
|
|
47
|
+
this.data = roomData.data || {};
|
|
48
|
+
this.version = roomData.version;
|
|
49
|
+
console.log(`VenusRoom: Created room object for ${this.id}`, {
|
|
50
|
+
hasCustomMetadata: !!this.customMetadata,
|
|
51
|
+
hasGameState: !!this.customMetadata?.rules?.gameState,
|
|
52
|
+
gamePhase: this.customMetadata?.rules?.gameState?.phase,
|
|
53
|
+
currentPlayer: this.customMetadata?.rules?.gameState?.currentPlayer
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
updateFromRoomData(newRoomData) {
|
|
57
|
+
if (newRoomData.id === this.id) {
|
|
58
|
+
this.name = newRoomData.name || this.name;
|
|
59
|
+
this.players = newRoomData.currentPlayers || this.players;
|
|
60
|
+
this.maxPlayers = newRoomData.maxPlayers || this.maxPlayers;
|
|
61
|
+
this.gameType = newRoomData.gameType || this.gameType;
|
|
62
|
+
this.currentPlayers = newRoomData.currentPlayers || this.currentPlayers;
|
|
63
|
+
this.customMetadata = newRoomData.customMetadata || this.customMetadata;
|
|
64
|
+
this.data = newRoomData.data || this.data;
|
|
65
|
+
this.status = newRoomData.status || this.status;
|
|
66
|
+
this.updatedAt = newRoomData.updatedAt || this.updatedAt;
|
|
67
|
+
console.log(`VenusRoom: Updated room object ${this.id} with fresh data`, {
|
|
68
|
+
hasCustomMetadata: !!this.customMetadata,
|
|
69
|
+
hasGameState: !!this.customMetadata?.rules?.gameState,
|
|
70
|
+
gamePhase: this.customMetadata?.rules?.gameState?.phase,
|
|
71
|
+
currentPlayer: this.customMetadata?.rules?.gameState?.currentPlayer
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// src/rooms/RoomsApi.ts
|
|
80
|
+
var init_RoomsApi = __esm({
|
|
81
|
+
"src/rooms/RoomsApi.ts"() {
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// src/rooms/index.ts
|
|
86
|
+
var rooms_exports = {};
|
|
87
|
+
__export(rooms_exports, {
|
|
88
|
+
VenusRoom: () => VenusRoom,
|
|
89
|
+
initializeRoomsApi: () => initializeRoomsApi,
|
|
90
|
+
setupRoomNotifications: () => setupRoomNotifications
|
|
91
|
+
});
|
|
92
|
+
function bindMethod(target, targetKey, source, sourceKey) {
|
|
93
|
+
const key = sourceKey ?? targetKey;
|
|
94
|
+
const fn = source?.[key];
|
|
95
|
+
if (typeof fn === "function") {
|
|
96
|
+
target[targetKey] = fn.bind(source);
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
function setupRoomNotifications(transport, getSubscriptions) {
|
|
102
|
+
console.log("[Venus Rooms] Setting up room notification listeners");
|
|
103
|
+
return transport.onVenusMessage((message) => {
|
|
104
|
+
const subscriptions = getSubscriptions();
|
|
105
|
+
if (!subscriptions) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (message.type === "H5_ROOM_DATA_UPDATED") {
|
|
109
|
+
const messageData = message.data;
|
|
110
|
+
const { roomId, roomData } = messageData;
|
|
111
|
+
if (!roomId) return;
|
|
112
|
+
const callbacks = subscriptions.data?.[roomId] || [];
|
|
113
|
+
const allEventsCallbacks = subscriptions.allEvents?.[roomId] || [];
|
|
114
|
+
console.log(`[Venus Rooms] \u{1F514} Room data updated for ${roomId}, notifying ${callbacks.length} callbacks`, roomData);
|
|
115
|
+
callbacks.forEach((callback) => {
|
|
116
|
+
try {
|
|
117
|
+
callback(roomData);
|
|
118
|
+
} catch (error) {
|
|
119
|
+
console.error("[Venus Rooms] Error in room data callback:", error);
|
|
120
|
+
throw error;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
allEventsCallbacks.forEach((callback) => {
|
|
124
|
+
try {
|
|
125
|
+
callback({ type: message.type, ...messageData });
|
|
126
|
+
} catch (error) {
|
|
127
|
+
console.error("[Venus Rooms] Error in allEvents callback:", error);
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
if (message.type === "H5_ROOM_MESSAGE_RECEIVED" || message.type === "H5_ROOM_MESSAGE_UPDATED" || message.type === "H5_ROOM_MESSAGE_DELETED") {
|
|
133
|
+
const messageData = message.data;
|
|
134
|
+
const { roomId } = messageData;
|
|
135
|
+
if (!roomId) return;
|
|
136
|
+
const callbacks = subscriptions.messages?.[roomId] || [];
|
|
137
|
+
const allEventsCallbacks = subscriptions.allEvents?.[roomId] || [];
|
|
138
|
+
console.log(`[Venus Rooms] \u{1F514} Room message event for ${roomId}, notifying ${callbacks.length} callbacks`);
|
|
139
|
+
callbacks.forEach((callback) => {
|
|
140
|
+
try {
|
|
141
|
+
callback(messageData);
|
|
142
|
+
} catch (error) {
|
|
143
|
+
console.error("[Venus Rooms] Error in room message callback:", error);
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
allEventsCallbacks.forEach((callback) => {
|
|
148
|
+
try {
|
|
149
|
+
callback({ type: message.type, ...messageData });
|
|
150
|
+
} catch (error) {
|
|
151
|
+
console.error("[Venus Rooms] Error in allEvents callback:", error);
|
|
152
|
+
throw error;
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
if (message.type === "app:h5:proposedMoveValidationUpdated") {
|
|
157
|
+
const messageData = message.data;
|
|
158
|
+
const { roomId } = messageData;
|
|
159
|
+
if (!roomId) return;
|
|
160
|
+
const callbacks = subscriptions.gameEvents?.[roomId] || [];
|
|
161
|
+
const allEventsCallbacks = subscriptions.allEvents?.[roomId] || [];
|
|
162
|
+
console.log(`[Venus Rooms] \u{1F514} Proposed move validation updated for ${roomId}, notifying ${callbacks.length} callbacks`);
|
|
163
|
+
callbacks.forEach((callback) => {
|
|
164
|
+
try {
|
|
165
|
+
callback(messageData);
|
|
166
|
+
} catch (error) {
|
|
167
|
+
console.error("[Venus Rooms] Error in game event callback:", error);
|
|
168
|
+
throw error;
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
allEventsCallbacks.forEach((callback) => {
|
|
172
|
+
try {
|
|
173
|
+
callback({ type: message.type, ...messageData });
|
|
174
|
+
} catch (error) {
|
|
175
|
+
console.error("[Venus Rooms] Error in allEvents callback:", error);
|
|
176
|
+
throw error;
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
function initializeRoomsApi(venusApi, host) {
|
|
183
|
+
const roomsApi = host?.rooms;
|
|
184
|
+
if (!roomsApi) {
|
|
185
|
+
console.warn(
|
|
186
|
+
"[Venus SDK] Host did not provide a rooms implementation. Rooms API will be unavailable."
|
|
187
|
+
);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
const venus = venusApi;
|
|
191
|
+
const existingNamespace = venus.rooms || {};
|
|
192
|
+
const roomsNamespace = Object.assign({}, existingNamespace);
|
|
193
|
+
const namespaceBindings = [
|
|
194
|
+
["create", "createRoom"],
|
|
195
|
+
["joinOrCreate", "joinOrCreateRoom"],
|
|
196
|
+
["joinByCode", "joinRoomByCode"],
|
|
197
|
+
["list", "getUserRooms"],
|
|
198
|
+
["subscribeToRoom", "subscribe"],
|
|
199
|
+
["updateRoomData", "updateData"],
|
|
200
|
+
["getRoomData", "getData"],
|
|
201
|
+
["sendRoomMessage", "sendMessage"],
|
|
202
|
+
["leaveRoom", "leave"],
|
|
203
|
+
["startRoomGame", "startGame"],
|
|
204
|
+
["proposeMove"],
|
|
205
|
+
["validateMove"]
|
|
206
|
+
];
|
|
207
|
+
namespaceBindings.forEach(([targetKey, sourceKey]) => {
|
|
208
|
+
bindMethod(roomsNamespace, targetKey, roomsApi, sourceKey);
|
|
209
|
+
});
|
|
210
|
+
venus.rooms = roomsNamespace;
|
|
211
|
+
}
|
|
212
|
+
var init_rooms = __esm({
|
|
213
|
+
"src/rooms/index.ts"() {
|
|
214
|
+
init_RoomsApi();
|
|
215
|
+
init_VenusRoom();
|
|
216
|
+
}
|
|
217
|
+
});
|
|
2
218
|
|
|
3
219
|
// src/VenusMessageId.ts
|
|
4
220
|
var VenusMessageId = /* @__PURE__ */ ((VenusMessageId2) => {
|
|
@@ -91,9 +307,6 @@ var VenusMessageId = /* @__PURE__ */ ((VenusMessageId2) => {
|
|
|
91
307
|
VenusMessageId2["H5_SIMULATION_GET_AVAILABLE_ITEMS"] = "H5_SIMULATION_GET_AVAILABLE_ITEMS";
|
|
92
308
|
VenusMessageId2["H5_SIMULATION_VALIDATE_ASSIGNMENT"] = "H5_SIMULATION_VALIDATE_ASSIGNMENT";
|
|
93
309
|
VenusMessageId2["H5_SIMULATION_BATCH_OPERATIONS"] = "H5_SIMULATION_BATCH_OPERATIONS";
|
|
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
310
|
VenusMessageId2["H5_LEADERBOARD_CREATE_SCORE_TOKEN"] = "H5_LEADERBOARD_CREATE_SCORE_TOKEN";
|
|
98
311
|
VenusMessageId2["H5_LEADERBOARD_SUBMIT_SCORE"] = "H5_LEADERBOARD_SUBMIT_SCORE";
|
|
99
312
|
VenusMessageId2["H5_LEADERBOARD_GET_PAGED_SCORES"] = "H5_LEADERBOARD_GET_PAGED_SCORES";
|
|
@@ -1546,8 +1759,13 @@ var MockNotificationsApi = class {
|
|
|
1546
1759
|
async cancelNotification(notificationId) {
|
|
1547
1760
|
const venusApi = this.venusApi;
|
|
1548
1761
|
if (isWebPlatform()) {
|
|
1762
|
+
console.log(
|
|
1763
|
+
"[Venus Mock] Cancel notification on web platform (simulated):",
|
|
1764
|
+
notificationId
|
|
1765
|
+
);
|
|
1549
1766
|
return true;
|
|
1550
1767
|
}
|
|
1768
|
+
console.log("[Venus Mock] Cancel local notification:", notificationId);
|
|
1551
1769
|
await createMockDelay(MOCK_DELAYS.short);
|
|
1552
1770
|
if (venusApi._mock.scheduledNotifications && venusApi._mock.scheduledNotifications[notificationId]) {
|
|
1553
1771
|
delete venusApi._mock.scheduledNotifications[notificationId];
|
|
@@ -1557,8 +1775,12 @@ var MockNotificationsApi = class {
|
|
|
1557
1775
|
}
|
|
1558
1776
|
async getAllScheduledLocalNotifications() {
|
|
1559
1777
|
if (isWebPlatform()) {
|
|
1778
|
+
console.log(
|
|
1779
|
+
"[Venus Mock] Get notifications on web platform (returning empty list)"
|
|
1780
|
+
);
|
|
1560
1781
|
return [];
|
|
1561
1782
|
}
|
|
1783
|
+
console.log("[Venus Mock] Get all scheduled local notifications");
|
|
1562
1784
|
await createMockDelay(MOCK_DELAYS.short);
|
|
1563
1785
|
const venusApi = this.venusApi;
|
|
1564
1786
|
const notifications = venusApi._mock.scheduledNotifications || {};
|
|
@@ -1566,8 +1788,10 @@ var MockNotificationsApi = class {
|
|
|
1566
1788
|
}
|
|
1567
1789
|
async isLocalNotificationsEnabled() {
|
|
1568
1790
|
if (isWebPlatform()) {
|
|
1791
|
+
console.log("[Venus Mock] Notifications not available on web platform");
|
|
1569
1792
|
return false;
|
|
1570
1793
|
}
|
|
1794
|
+
console.log("[Venus Mock] Check if local notifications are enabled");
|
|
1571
1795
|
await createMockDelay(MOCK_DELAYS.short);
|
|
1572
1796
|
const venusApi = this.venusApi;
|
|
1573
1797
|
const isEnabled = venusApi._mock.notificationsEnabled !== false;
|
|
@@ -1576,6 +1800,9 @@ var MockNotificationsApi = class {
|
|
|
1576
1800
|
async scheduleAsync(title, body, seconds, notificationId, options) {
|
|
1577
1801
|
const { priority = 50, groupId, payload } = options || {};
|
|
1578
1802
|
if (isWebPlatform()) {
|
|
1803
|
+
console.log(
|
|
1804
|
+
"[Venus Mock] Notifications not supported on web platform, simulating success"
|
|
1805
|
+
);
|
|
1579
1806
|
console.info(
|
|
1580
1807
|
"\u{1F514} [Venus Mock] Notification would be scheduled:",
|
|
1581
1808
|
title || "Untitled",
|
|
@@ -1586,11 +1813,14 @@ var MockNotificationsApi = class {
|
|
|
1586
1813
|
const mockId = `mock-web-notification-${Date.now()}`;
|
|
1587
1814
|
return mockId;
|
|
1588
1815
|
}
|
|
1816
|
+
console.log("[Venus Mock] Schedule local notification:", { title, body, seconds, options });
|
|
1589
1817
|
const venusApi = this.venusApi;
|
|
1590
1818
|
if (!venusApi._mock.pendingRequests) {
|
|
1819
|
+
console.log("[Venus Mock] Initializing pendingRequests");
|
|
1591
1820
|
venusApi._mock.pendingRequests = {};
|
|
1592
1821
|
}
|
|
1593
1822
|
const requestId = Date.now().toString();
|
|
1823
|
+
console.log("[Venus Mock] Creating request with ID:", requestId);
|
|
1594
1824
|
return new Promise((resolve) => {
|
|
1595
1825
|
venusApi._mock.pendingRequests[requestId] = { resolve };
|
|
1596
1826
|
const id = notificationId || `mock-notification-${Date.now()}`;
|
|
@@ -1612,8 +1842,13 @@ var MockNotificationsApi = class {
|
|
|
1612
1842
|
async setLocalNotificationsEnabled(enabled) {
|
|
1613
1843
|
const venusApi = this.venusApi;
|
|
1614
1844
|
if (isWebPlatform()) {
|
|
1845
|
+
console.log(
|
|
1846
|
+
"[Venus Mock] Set notifications enabled on web platform (simulated):",
|
|
1847
|
+
enabled
|
|
1848
|
+
);
|
|
1615
1849
|
return true;
|
|
1616
1850
|
}
|
|
1851
|
+
console.log("[Venus Mock] Set local notifications enabled:", enabled);
|
|
1617
1852
|
await createMockDelay(MOCK_DELAYS.short);
|
|
1618
1853
|
venusApi._mock.notificationsEnabled = enabled;
|
|
1619
1854
|
return enabled;
|
|
@@ -1878,11 +2113,6 @@ function initializeProfile(venusApi, host) {
|
|
|
1878
2113
|
};
|
|
1879
2114
|
}
|
|
1880
2115
|
|
|
1881
|
-
// src/utils/idGenerator.ts
|
|
1882
|
-
function generateId() {
|
|
1883
|
-
return `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
1884
|
-
}
|
|
1885
|
-
|
|
1886
2116
|
// src/rpc/RpcClient.ts
|
|
1887
2117
|
var RpcClient = class {
|
|
1888
2118
|
constructor() {
|
|
@@ -1925,7 +2155,7 @@ var RpcClient = class {
|
|
|
1925
2155
|
}
|
|
1926
2156
|
async call(method, args, timeout = 5e3) {
|
|
1927
2157
|
return new Promise((resolve, reject) => {
|
|
1928
|
-
const id = generateId();
|
|
2158
|
+
const id = this.generateId();
|
|
1929
2159
|
this.addPendingCall(id, resolve, reject);
|
|
1930
2160
|
const request = {
|
|
1931
2161
|
type: "rpc-request",
|
|
@@ -1962,6 +2192,9 @@ var RpcClient = class {
|
|
|
1962
2192
|
getPendingCall(id) {
|
|
1963
2193
|
return this.pendingCalls.get(id);
|
|
1964
2194
|
}
|
|
2195
|
+
generateId() {
|
|
2196
|
+
return `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
2197
|
+
}
|
|
1965
2198
|
handleRpcResponse(response) {
|
|
1966
2199
|
const pending = this.getPendingCall(response.id);
|
|
1967
2200
|
if (!pending) {
|
|
@@ -1983,518 +2216,98 @@ var RpcClient = class {
|
|
|
1983
2216
|
}
|
|
1984
2217
|
};
|
|
1985
2218
|
|
|
1986
|
-
// src/
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
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;
|
|
2219
|
+
// src/storage/MockStorageApi.ts
|
|
2220
|
+
function createMockStorageApi(storageType, appUrl) {
|
|
2221
|
+
const appIdentifier = appUrl ? generateAppIdentifier(appUrl) : null;
|
|
2222
|
+
let prefix;
|
|
2223
|
+
let syncDelay = 0;
|
|
2224
|
+
switch (storageType) {
|
|
2225
|
+
case "deviceCache":
|
|
2226
|
+
prefix = "venus:app";
|
|
2227
|
+
syncDelay = 0;
|
|
2228
|
+
break;
|
|
2229
|
+
case "appStorage":
|
|
2230
|
+
prefix = "venus:app";
|
|
2231
|
+
syncDelay = 100;
|
|
2232
|
+
break;
|
|
2233
|
+
case "globalStorage":
|
|
2234
|
+
prefix = "venus:global";
|
|
2235
|
+
syncDelay = 100;
|
|
2236
|
+
break;
|
|
2237
|
+
default:
|
|
2238
|
+
throw new Error(`Unknown storage type: ${storageType}`);
|
|
2025
2239
|
}
|
|
2026
|
-
}
|
|
2027
|
-
|
|
2028
|
-
// src/rooms/setupRoomNotifications.ts
|
|
2029
|
-
function invokeCallbacks(callbacks, event, context) {
|
|
2030
|
-
callbacks.forEach((callback) => {
|
|
2031
|
-
try {
|
|
2032
|
-
callback(event);
|
|
2033
|
-
} catch (error) {
|
|
2034
|
-
console.error(`[Venus SDK] Error in ${context} callback:`, error);
|
|
2035
|
-
throw error;
|
|
2036
|
-
}
|
|
2037
|
-
});
|
|
2240
|
+
prefix = storageType === "globalStorage" || !appIdentifier ? `${prefix}:` : `${prefix}:${appIdentifier}:`;
|
|
2241
|
+
return new MockStorageApi(prefix, syncDelay);
|
|
2038
2242
|
}
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
const
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
roomData,
|
|
2054
|
-
timestamp: messageData.timestamp
|
|
2055
|
-
};
|
|
2056
|
-
invokeCallbacks(callbacks, event, "room data");
|
|
2243
|
+
var MockStorageApi = class {
|
|
2244
|
+
constructor(prefix, syncDelay) {
|
|
2245
|
+
__publicField(this, "prefix");
|
|
2246
|
+
__publicField(this, "syncDelay");
|
|
2247
|
+
this.prefix = prefix;
|
|
2248
|
+
this.syncDelay = syncDelay;
|
|
2249
|
+
}
|
|
2250
|
+
async clear() {
|
|
2251
|
+
const fullLength = localStorage.length;
|
|
2252
|
+
for (let i = 0; i < fullLength; i++) {
|
|
2253
|
+
const fullKey = localStorage.key(i);
|
|
2254
|
+
if (fullKey && fullKey.startsWith(this.prefix)) {
|
|
2255
|
+
localStorage.removeItem(fullKey);
|
|
2256
|
+
}
|
|
2057
2257
|
}
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2258
|
+
await this.simulateSyncDelay();
|
|
2259
|
+
}
|
|
2260
|
+
async getAllItems() {
|
|
2261
|
+
const items = new Array();
|
|
2262
|
+
const fullLength = localStorage.length;
|
|
2263
|
+
for (let i = 0; i < fullLength; i++) {
|
|
2264
|
+
const fullKey = localStorage.key(i);
|
|
2265
|
+
if (fullKey && fullKey.startsWith(this.prefix)) {
|
|
2266
|
+
const item = localStorage.getItem(fullKey);
|
|
2267
|
+
if (item) {
|
|
2268
|
+
items.push(item);
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2070
2271
|
}
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
timestamp: messageData.timestamp
|
|
2083
|
-
};
|
|
2084
|
-
invokeCallbacks(callbacks, event, "game event");
|
|
2272
|
+
return items;
|
|
2273
|
+
}
|
|
2274
|
+
async getItem(key) {
|
|
2275
|
+
const fullKey = this.buildKey(key);
|
|
2276
|
+
await this.simulateSyncDelay();
|
|
2277
|
+
return localStorage.getItem(fullKey);
|
|
2278
|
+
}
|
|
2279
|
+
async key(index) {
|
|
2280
|
+
const keys = this.keys();
|
|
2281
|
+
if (index < 0 || index >= keys.length) {
|
|
2282
|
+
return null;
|
|
2085
2283
|
}
|
|
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
|
-
};
|
|
2284
|
+
await this.simulateSyncDelay();
|
|
2285
|
+
return keys[index];
|
|
2100
2286
|
}
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
*/
|
|
2104
|
-
getSubscriptions() {
|
|
2105
|
-
return this.subscriptions;
|
|
2287
|
+
async length() {
|
|
2288
|
+
return this.keys().length;
|
|
2106
2289
|
}
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
setupRoomNotifications(transport, () => this.getSubscriptions());
|
|
2290
|
+
async removeItem(key) {
|
|
2291
|
+
const fullKey = this.buildKey(key);
|
|
2292
|
+
await this.simulateSyncDelay();
|
|
2293
|
+
localStorage.removeItem(fullKey);
|
|
2112
2294
|
}
|
|
2113
|
-
async
|
|
2114
|
-
const
|
|
2115
|
-
|
|
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);
|
|
2123
|
-
}
|
|
2124
|
-
const room = new VenusRoom(response.roomData);
|
|
2125
|
-
return room;
|
|
2295
|
+
async setItem(key, item) {
|
|
2296
|
+
const fullKey = this.buildKey(key);
|
|
2297
|
+
await this.simulateSyncDelay();
|
|
2298
|
+
localStorage.setItem(fullKey, item);
|
|
2126
2299
|
}
|
|
2127
|
-
async
|
|
2128
|
-
const
|
|
2129
|
-
|
|
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);
|
|
2300
|
+
async setMultipleItems(entries) {
|
|
2301
|
+
for (const entry of entries) {
|
|
2302
|
+
const fullKey = this.buildKey(entry.key);
|
|
2303
|
+
localStorage.setItem(fullKey, entry.value);
|
|
2137
2304
|
}
|
|
2138
|
-
|
|
2139
|
-
return {
|
|
2140
|
-
action: response.value.action,
|
|
2141
|
-
room,
|
|
2142
|
-
playersJoined: response.value.playersJoined
|
|
2143
|
-
};
|
|
2305
|
+
await this.simulateSyncDelay();
|
|
2144
2306
|
}
|
|
2145
|
-
async
|
|
2146
|
-
const
|
|
2147
|
-
|
|
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);
|
|
2307
|
+
async removeMultipleItems(keys) {
|
|
2308
|
+
for (const key of keys) {
|
|
2309
|
+
const fullKey = this.buildKey(key);
|
|
2310
|
+
localStorage.removeItem(fullKey);
|
|
2498
2311
|
}
|
|
2499
2312
|
await this.simulateSyncDelay();
|
|
2500
2313
|
}
|
|
@@ -2636,20 +2449,24 @@ function initializeStorage(venusApiInstance, host) {
|
|
|
2636
2449
|
venusApiInstance.globalStorage = host.globalStorage;
|
|
2637
2450
|
}
|
|
2638
2451
|
|
|
2452
|
+
// src/simulation/utils.ts
|
|
2453
|
+
function sumContributions(contributions) {
|
|
2454
|
+
const totals = {};
|
|
2455
|
+
for (const profileId in contributions) {
|
|
2456
|
+
for (const entityId in contributions[profileId]) {
|
|
2457
|
+
const amount = contributions[profileId][entityId] || 0;
|
|
2458
|
+
totals[entityId] = (totals[entityId] || 0) + amount;
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
return totals;
|
|
2462
|
+
}
|
|
2463
|
+
|
|
2639
2464
|
// src/simulation/RpcSimulationApi.ts
|
|
2640
2465
|
var RpcSimulationApi = class {
|
|
2641
2466
|
constructor(rpcClient) {
|
|
2642
2467
|
__publicField(this, "rpcClient");
|
|
2643
2468
|
__publicField(this, "_simulationConfig", null);
|
|
2644
|
-
__publicField(this, "subscriptionCallbacks", /* @__PURE__ */ new Map());
|
|
2645
2469
|
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;
|
|
2653
2470
|
}
|
|
2654
2471
|
async validateSlotAssignmentAsync(containerId, slotId, itemId) {
|
|
2655
2472
|
return this.rpcClient.call(
|
|
@@ -2661,47 +2478,14 @@ var RpcSimulationApi = class {
|
|
|
2661
2478
|
}
|
|
2662
2479
|
);
|
|
2663
2480
|
}
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
const subscriptionId = generateId();
|
|
2667
|
-
this.subscriptionCallbacks.set(subscriptionId, options.onUpdate);
|
|
2668
|
-
try {
|
|
2669
|
-
await this.rpcClient.call("H5_SIMULATION_SUBSCRIBE" /* H5_SIMULATION_SUBSCRIBE */, {
|
|
2670
|
-
subscriptionId,
|
|
2671
|
-
entities: options.entities,
|
|
2672
|
-
tags: options.tags,
|
|
2673
|
-
activeRuns: options.activeRuns,
|
|
2674
|
-
roomId: options.roomId
|
|
2675
|
-
});
|
|
2676
|
-
} catch (error) {
|
|
2677
|
-
this.subscriptionCallbacks.delete(subscriptionId);
|
|
2678
|
-
throw error;
|
|
2679
|
-
}
|
|
2680
|
-
let unsubscribed = false;
|
|
2681
|
-
return () => {
|
|
2682
|
-
if (unsubscribed) {
|
|
2683
|
-
return;
|
|
2684
|
-
}
|
|
2685
|
-
unsubscribed = true;
|
|
2686
|
-
this.subscriptionCallbacks.delete(subscriptionId);
|
|
2687
|
-
void this.rpcClient.call("H5_SIMULATION_UNSUBSCRIBE" /* H5_SIMULATION_UNSUBSCRIBE */, {
|
|
2688
|
-
subscriptionId
|
|
2689
|
-
}).catch((error) => {
|
|
2690
|
-
console.error(
|
|
2691
|
-
"[Venus SDK] Failed to unsubscribe simulation listener",
|
|
2692
|
-
error
|
|
2693
|
-
);
|
|
2694
|
-
});
|
|
2695
|
-
};
|
|
2481
|
+
sumContributions(contributions) {
|
|
2482
|
+
return sumContributions(contributions);
|
|
2696
2483
|
}
|
|
2697
2484
|
executeBatchOperationsAsync(operations, validateOnly) {
|
|
2698
|
-
return this.rpcClient.call(
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
validateOnly
|
|
2703
|
-
}
|
|
2704
|
-
);
|
|
2485
|
+
return this.rpcClient.call("H5_SIMULATION_BATCH_OPERATIONS" /* H5_SIMULATION_BATCH_OPERATIONS */, {
|
|
2486
|
+
operations,
|
|
2487
|
+
validateOnly
|
|
2488
|
+
});
|
|
2705
2489
|
}
|
|
2706
2490
|
async getAvailableItemsAsync(containerId, slotId) {
|
|
2707
2491
|
const response = await this.rpcClient.call(
|
|
@@ -2724,23 +2508,17 @@ var RpcSimulationApi = class {
|
|
|
2724
2508
|
);
|
|
2725
2509
|
}
|
|
2726
2510
|
assignItemToSlotAsync(containerId, slotId, itemId) {
|
|
2727
|
-
return this.rpcClient.call(
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
itemId
|
|
2733
|
-
}
|
|
2734
|
-
);
|
|
2511
|
+
return this.rpcClient.call("H5_SIMULATION_ASSIGN_ITEM" /* H5_SIMULATION_ASSIGN_ITEM */, {
|
|
2512
|
+
containerId,
|
|
2513
|
+
slotId,
|
|
2514
|
+
itemId
|
|
2515
|
+
});
|
|
2735
2516
|
}
|
|
2736
2517
|
removeItemFromSlotAsync(containerId, slotId) {
|
|
2737
|
-
return this.rpcClient.call(
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
slotId
|
|
2742
|
-
}
|
|
2743
|
-
);
|
|
2518
|
+
return this.rpcClient.call("H5_SIMULATION_REMOVE_ITEM" /* H5_SIMULATION_REMOVE_ITEM */, {
|
|
2519
|
+
containerId,
|
|
2520
|
+
slotId
|
|
2521
|
+
});
|
|
2744
2522
|
}
|
|
2745
2523
|
async getSlotContainersAsync() {
|
|
2746
2524
|
const response = await this.rpcClient.call(
|
|
@@ -2765,6 +2543,7 @@ var RpcSimulationApi = class {
|
|
|
2765
2543
|
roomId
|
|
2766
2544
|
}
|
|
2767
2545
|
);
|
|
2546
|
+
console.log("[Venus SDK] getStateAsync", response);
|
|
2768
2547
|
if (response.configuration) {
|
|
2769
2548
|
this._simulationConfig = response.configuration;
|
|
2770
2549
|
}
|
|
@@ -2776,10 +2555,9 @@ var RpcSimulationApi = class {
|
|
|
2776
2555
|
}
|
|
2777
2556
|
const config = await this.rpcClient.call(
|
|
2778
2557
|
"H5_SIMULATION_GET_CONFIG" /* H5_SIMULATION_GET_CONFIG */,
|
|
2779
|
-
{
|
|
2780
|
-
roomId
|
|
2781
|
-
}
|
|
2558
|
+
{}
|
|
2782
2559
|
);
|
|
2560
|
+
console.log("[Venus SDK] getConfigAsync", config);
|
|
2783
2561
|
if (config) {
|
|
2784
2562
|
this._simulationConfig = config;
|
|
2785
2563
|
return config;
|
|
@@ -2787,17 +2565,14 @@ var RpcSimulationApi = class {
|
|
|
2787
2565
|
throw new Error("No simulation configuration available");
|
|
2788
2566
|
}
|
|
2789
2567
|
executeRecipeAsync(recipeId, inputs, options) {
|
|
2790
|
-
return this.rpcClient.call(
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
entity: options?.entity
|
|
2799
|
-
}
|
|
2800
|
-
);
|
|
2568
|
+
return this.rpcClient.call("H5_SIMULATION_EXECUTE_RECIPE" /* H5_SIMULATION_EXECUTE_RECIPE */, {
|
|
2569
|
+
recipeId,
|
|
2570
|
+
inputs,
|
|
2571
|
+
roomId: options?.roomId,
|
|
2572
|
+
batchAmount: options?.batchAmount,
|
|
2573
|
+
allowPartialBatch: options?.allowPartialBatch,
|
|
2574
|
+
entity: options?.entity
|
|
2575
|
+
});
|
|
2801
2576
|
}
|
|
2802
2577
|
collectRecipeAsync(runId) {
|
|
2803
2578
|
return this.rpcClient.call("H5_SIMULATION_COLLECT_RECIPE" /* H5_SIMULATION_COLLECT_RECIPE */, {
|
|
@@ -2805,12 +2580,9 @@ var RpcSimulationApi = class {
|
|
|
2805
2580
|
});
|
|
2806
2581
|
}
|
|
2807
2582
|
getActiveRunsAsync(options) {
|
|
2808
|
-
return this.rpcClient.call(
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
roomId: options?.roomId
|
|
2812
|
-
}
|
|
2813
|
-
);
|
|
2583
|
+
return this.rpcClient.call("H5_SIMULATION_GET_ACTIVE_RUNS" /* H5_SIMULATION_GET_ACTIVE_RUNS */, {
|
|
2584
|
+
roomId: options?.roomId
|
|
2585
|
+
});
|
|
2814
2586
|
}
|
|
2815
2587
|
executeScopedRecipeAsync(recipeId, entity, inputs, options) {
|
|
2816
2588
|
return this.rpcClient.call(
|
|
@@ -2880,52 +2652,583 @@ var RpcSimulationApi = class {
|
|
|
2880
2652
|
);
|
|
2881
2653
|
return response.value;
|
|
2882
2654
|
}
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2655
|
+
};
|
|
2656
|
+
|
|
2657
|
+
// src/simulation/MockSimulationApi.ts
|
|
2658
|
+
function generateAppIdentifier2() {
|
|
2659
|
+
if (typeof window === "undefined") return "unknown-app";
|
|
2660
|
+
const url = window.location.href;
|
|
2661
|
+
const match = url.match(/\/H5\/([^\/]+)/);
|
|
2662
|
+
return match ? match[1] : "unknown-app";
|
|
2663
|
+
}
|
|
2664
|
+
var MockSimulationApi = class {
|
|
2665
|
+
constructor(simulationConfig = null) {
|
|
2666
|
+
__publicField(this, "mockSimulationConfigs", /* @__PURE__ */ new Map());
|
|
2667
|
+
// appIdentifier -> config
|
|
2668
|
+
__publicField(this, "mockSimulationStates", /* @__PURE__ */ new Map());
|
|
2669
|
+
// appIdentifier -> config
|
|
2670
|
+
__publicField(this, "mockActiveTimers", /* @__PURE__ */ new Map());
|
|
2671
|
+
// appIdentifier -> timers[]
|
|
2672
|
+
__publicField(this, "appId");
|
|
2673
|
+
__publicField(this, "providedSimulationConfig");
|
|
2674
|
+
this.appId = generateAppIdentifier2();
|
|
2675
|
+
this.providedSimulationConfig = simulationConfig;
|
|
2676
|
+
}
|
|
2677
|
+
sumContributions(contributions) {
|
|
2678
|
+
return sumContributions(contributions);
|
|
2679
|
+
}
|
|
2680
|
+
async validateSlotAssignmentAsync(containerId, slotId, itemId) {
|
|
2681
|
+
this.log("validateSlotAssignmentAsync called:", {
|
|
2682
|
+
containerId,
|
|
2683
|
+
slotId,
|
|
2684
|
+
itemId
|
|
2685
|
+
});
|
|
2686
|
+
return { valid: true, message: "Mock validation successful" };
|
|
2687
|
+
}
|
|
2688
|
+
async executeBatchOperationsAsync(operations, validateOnly) {
|
|
2689
|
+
this.log("executeBatchOperationsAsync called:", {
|
|
2690
|
+
operations,
|
|
2691
|
+
validateOnly
|
|
2692
|
+
});
|
|
2693
|
+
return {
|
|
2694
|
+
success: true,
|
|
2695
|
+
results: operations.map(() => ({ success: true }))
|
|
2696
|
+
};
|
|
2697
|
+
}
|
|
2698
|
+
async getAvailableItemsAsync(containerId, slotId) {
|
|
2699
|
+
console.log("[Venus Simulation Mock] getAvailableItemsAsync called:", {
|
|
2700
|
+
containerId,
|
|
2701
|
+
slotId
|
|
2702
|
+
});
|
|
2703
|
+
const appIdentifier = generateAppIdentifier2();
|
|
2704
|
+
const mockSimulationConfigs = this.mockSimulationConfigs;
|
|
2705
|
+
const config = mockSimulationConfigs.get(appIdentifier) || {
|
|
2706
|
+
entities: {}
|
|
2707
|
+
};
|
|
2708
|
+
const availableItems = Object.entries(config.entities).slice(0, 3).map(([entityId, entity]) => ({
|
|
2709
|
+
entityId,
|
|
2710
|
+
quantity: 1,
|
|
2711
|
+
metadata: entity.metadata,
|
|
2712
|
+
powerPreview: 100
|
|
2713
|
+
// Mock power value
|
|
2714
|
+
}));
|
|
2715
|
+
return availableItems;
|
|
2716
|
+
}
|
|
2717
|
+
async calculatePowerPreviewAsync(containerId, slotId, candidateItemId) {
|
|
2718
|
+
this.log("calculatePowerPreviewAsync called:", {
|
|
2719
|
+
containerId,
|
|
2720
|
+
slotId,
|
|
2721
|
+
candidateItemId
|
|
2722
|
+
});
|
|
2723
|
+
return {
|
|
2724
|
+
currentPower: 1e3,
|
|
2725
|
+
previewPower: 1200,
|
|
2726
|
+
powerDelta: 200,
|
|
2727
|
+
breakdown: { base: 800, weapon: 200, armor: 200 }
|
|
2728
|
+
};
|
|
2729
|
+
}
|
|
2730
|
+
async getSlotContainersAsync() {
|
|
2731
|
+
this.log("getSlotContainersAsync called");
|
|
2732
|
+
const appIdentifier = this.appId;
|
|
2733
|
+
const mockSimulationConfigs = this.mockSimulationConfigs;
|
|
2734
|
+
const config = mockSimulationConfigs.get(appIdentifier) || {
|
|
2735
|
+
entities: {}
|
|
2736
|
+
};
|
|
2737
|
+
const containers = Object.entries(config.entities).filter(([_, entity]) => entity.metadata?.slots).map(([entityId, entity]) => ({
|
|
2738
|
+
entityId,
|
|
2739
|
+
slots: entity.metadata?.slots,
|
|
2740
|
+
isOwned: true
|
|
2741
|
+
// Mock: assume all containers are owned
|
|
2742
|
+
}));
|
|
2743
|
+
return containers;
|
|
2744
|
+
}
|
|
2745
|
+
async getSlotAssignmentsAsync(containerId) {
|
|
2746
|
+
this.log("getSlotAssignmentsAsync called for:", containerId);
|
|
2747
|
+
return [];
|
|
2748
|
+
}
|
|
2749
|
+
async resolveFieldValueAsync(entityId, fieldPath, entity) {
|
|
2750
|
+
this.log("resolveFieldValueAsync called:", {
|
|
2751
|
+
entityId,
|
|
2752
|
+
fieldPath,
|
|
2753
|
+
entity
|
|
2754
|
+
});
|
|
2755
|
+
const mockValues = {
|
|
2756
|
+
basePower: 850,
|
|
2757
|
+
weaponPower: 300,
|
|
2758
|
+
armorPower: 150,
|
|
2759
|
+
total_power: 1300,
|
|
2760
|
+
total_defense_power: 5e3
|
|
2761
|
+
};
|
|
2762
|
+
return mockValues[fieldPath] || 100;
|
|
2763
|
+
}
|
|
2764
|
+
async getEntityMetadataAsync(entityId) {
|
|
2765
|
+
this.log("getEntityMetadataAsync called for:", entityId);
|
|
2766
|
+
const mockSimulationConfigs = this.mockSimulationConfigs;
|
|
2767
|
+
const appIdentifier = this.appId;
|
|
2768
|
+
const config = mockSimulationConfigs.get(
|
|
2769
|
+
appIdentifier
|
|
2770
|
+
) || {
|
|
2771
|
+
entities: {}};
|
|
2772
|
+
const entity = config.entities[entityId];
|
|
2773
|
+
return entity?.metadata || {};
|
|
2774
|
+
}
|
|
2775
|
+
async collectRecipeAsync(runId) {
|
|
2776
|
+
this.log("collectRecipeAsync called:", { runId });
|
|
2777
|
+
const mockRewards = {
|
|
2778
|
+
cash: Math.floor(Math.random() * 1e3) + 500,
|
|
2779
|
+
experience: Math.floor(Math.random() * 50) + 25
|
|
2780
|
+
};
|
|
2781
|
+
return {
|
|
2782
|
+
success: true,
|
|
2783
|
+
runId,
|
|
2784
|
+
rewards: mockRewards,
|
|
2785
|
+
message: "Rewards collected successfully"
|
|
2786
|
+
};
|
|
2787
|
+
}
|
|
2788
|
+
executeRecipeAsync(recipeId, inputs, options) {
|
|
2789
|
+
this.log("executeRecipeAsync called:", {
|
|
2790
|
+
recipeId,
|
|
2791
|
+
inputs,
|
|
2792
|
+
options
|
|
2793
|
+
});
|
|
2794
|
+
const appIdentifier = this.appId;
|
|
2795
|
+
return this.executeRecipe(appIdentifier, recipeId, inputs);
|
|
2796
|
+
}
|
|
2797
|
+
async executeScopedRecipeAsync(recipeId, entity, inputs, options) {
|
|
2798
|
+
this.log("executeScopedRecipeAsync called:", {
|
|
2799
|
+
recipeId,
|
|
2800
|
+
entity,
|
|
2801
|
+
inputs,
|
|
2802
|
+
roomId: options?.roomId,
|
|
2803
|
+
options
|
|
2804
|
+
});
|
|
2805
|
+
return {
|
|
2806
|
+
success: true,
|
|
2807
|
+
message: "Mock scoped recipe execution successful"
|
|
2808
|
+
};
|
|
2809
|
+
}
|
|
2810
|
+
async getActiveRunsAsync(options) {
|
|
2811
|
+
this.log("getActiveRunsAsync called:", options);
|
|
2812
|
+
const appIdentifier = this.appId;
|
|
2813
|
+
let state = this.mockSimulationStates.get(appIdentifier);
|
|
2814
|
+
if (!state) {
|
|
2815
|
+
state = await this.initializeSimulationState(appIdentifier);
|
|
2887
2816
|
}
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2817
|
+
return state.activeRuns || [];
|
|
2818
|
+
}
|
|
2819
|
+
async getAvailableRecipesAsync(options) {
|
|
2820
|
+
this.log("getAvailableRecipesAsync called:", options);
|
|
2821
|
+
const baseRecipes = [
|
|
2822
|
+
{ id: "collect_resources", scope: "player", clientViewable: true },
|
|
2823
|
+
{ id: "upgrade_equipment", scope: "player", clientViewable: true }
|
|
2824
|
+
];
|
|
2825
|
+
if (options?.roomId) {
|
|
2826
|
+
baseRecipes.push(
|
|
2827
|
+
{ id: "room_upgrade", scope: "room", clientViewable: true },
|
|
2828
|
+
{ id: "cooperative_project", scope: "room", clientViewable: true }
|
|
2893
2829
|
);
|
|
2894
|
-
return;
|
|
2895
2830
|
}
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2831
|
+
if (options?.includeActorRecipes && options?.roomId) {
|
|
2832
|
+
baseRecipes.push(
|
|
2833
|
+
{ id: "trade_with_npc", scope: "actor", clientViewable: true },
|
|
2834
|
+
{ id: "attack_monster", scope: "actor", clientViewable: true }
|
|
2835
|
+
);
|
|
2836
|
+
}
|
|
2837
|
+
return { success: true, recipes: baseRecipes };
|
|
2838
|
+
}
|
|
2839
|
+
async getBatchRecipeRequirementsAsync(recipes) {
|
|
2840
|
+
this.log("getBatchRecipeRequirementsAsync called:", {
|
|
2841
|
+
count: recipes?.length
|
|
2842
|
+
});
|
|
2843
|
+
const results = (recipes || []).map((q) => ({
|
|
2844
|
+
recipeId: q.recipeId,
|
|
2845
|
+
entity: q.entity || null,
|
|
2846
|
+
amount: q.batchAmount || 1,
|
|
2847
|
+
inputs: { cash: "BE:0" },
|
|
2848
|
+
canAfford: true,
|
|
2849
|
+
disabled: false
|
|
2850
|
+
}));
|
|
2851
|
+
return { success: true, results };
|
|
2852
|
+
}
|
|
2853
|
+
async getRecipeRequirementsAsync(recipe) {
|
|
2854
|
+
this.log("getRecipeRequirementsAsync called:", recipe);
|
|
2855
|
+
return {
|
|
2856
|
+
recipeId: recipe.recipeId,
|
|
2857
|
+
entity: recipe.entity || null,
|
|
2858
|
+
amount: recipe.batchAmount,
|
|
2859
|
+
inputs: { cash: "BE:0" },
|
|
2860
|
+
canAfford: true,
|
|
2861
|
+
disabled: false
|
|
2862
|
+
};
|
|
2863
|
+
}
|
|
2864
|
+
async triggerRecipeChainAsync(recipeId, options) {
|
|
2865
|
+
this.log("triggerRecipeChainAsync called:", { recipeId, ...options });
|
|
2866
|
+
return {
|
|
2867
|
+
success: true,
|
|
2868
|
+
message: "Mock recipe chain triggered successfully"
|
|
2869
|
+
};
|
|
2870
|
+
}
|
|
2871
|
+
log(message, ...args) {
|
|
2872
|
+
console.log(`[Venus Sim Mock] ${message}`, args);
|
|
2873
|
+
}
|
|
2874
|
+
async executeRecipe(appIdentifier, recipeId, inputs) {
|
|
2875
|
+
this.log(`Executing recipe ${recipeId} for ${appIdentifier}`, inputs);
|
|
2876
|
+
const mockSimulationConfigs = this.mockSimulationConfigs;
|
|
2877
|
+
const mockSimulationStates = this.mockSimulationStates;
|
|
2878
|
+
let config = mockSimulationConfigs.get(appIdentifier);
|
|
2879
|
+
let state = mockSimulationStates.get(appIdentifier);
|
|
2880
|
+
if (!config || !state) {
|
|
2881
|
+
state = await this.initializeSimulationState(appIdentifier);
|
|
2882
|
+
config = mockSimulationConfigs.get(appIdentifier);
|
|
2883
|
+
if (!config) {
|
|
2884
|
+
throw new Error("Failed to initialize simulation config");
|
|
2885
|
+
}
|
|
2886
|
+
}
|
|
2887
|
+
const recipe = config.recipes?.[recipeId];
|
|
2888
|
+
if (!recipe) {
|
|
2889
|
+
throw new Error(`Recipe ${recipeId} not found`);
|
|
2890
|
+
}
|
|
2891
|
+
if (state.disabledRecipes?.includes(recipeId)) {
|
|
2892
|
+
throw new Error(`Recipe ${recipeId} is disabled`);
|
|
2893
|
+
}
|
|
2894
|
+
if (recipe.inputs) {
|
|
2895
|
+
for (const [entityId, required] of Object.entries(recipe.inputs)) {
|
|
2896
|
+
const available = state.inventory[entityId] || 0;
|
|
2897
|
+
if (available < required) {
|
|
2898
|
+
throw new Error(
|
|
2899
|
+
`Insufficient ${entityId}: required ${required}, available ${available}`
|
|
2900
|
+
);
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
}
|
|
2904
|
+
if (recipe.inputs) {
|
|
2905
|
+
for (const [entityId, input] of Object.entries(recipe.inputs)) {
|
|
2906
|
+
const inventoryValue = state.inventory[entityId] || 0;
|
|
2907
|
+
if (typeof input === "number" && typeof inventoryValue === "number") {
|
|
2908
|
+
state.inventory[entityId] = inventoryValue - input;
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2911
|
+
}
|
|
2912
|
+
if (recipe.beginEffects) {
|
|
2913
|
+
this.applyEffects(state, recipe.beginEffects);
|
|
2914
|
+
}
|
|
2915
|
+
const runId = this.generateRunId();
|
|
2916
|
+
const now = Date.now();
|
|
2917
|
+
const expiresAt = now + (recipe.duration || 0);
|
|
2918
|
+
const run = {
|
|
2919
|
+
id: runId,
|
|
2920
|
+
recipeId,
|
|
2921
|
+
status: "running",
|
|
2922
|
+
startTime: now,
|
|
2923
|
+
expiresAt,
|
|
2924
|
+
inputs: recipe.inputs || {}
|
|
2925
|
+
};
|
|
2926
|
+
state.activeRuns.push(run);
|
|
2927
|
+
if (recipe.duration === 0) {
|
|
2928
|
+
this.completeRun(appIdentifier, runId);
|
|
2929
|
+
return { status: "completed", runId };
|
|
2930
|
+
} else {
|
|
2931
|
+
const mockActiveTimers = this.mockActiveTimers;
|
|
2932
|
+
const timer = setTimeout(() => {
|
|
2933
|
+
this.completeRun(appIdentifier, runId);
|
|
2934
|
+
}, recipe.duration);
|
|
2935
|
+
const timers = mockActiveTimers.get(appIdentifier) || [];
|
|
2936
|
+
timers.push(timer);
|
|
2937
|
+
mockActiveTimers.set(appIdentifier, timers);
|
|
2938
|
+
return {
|
|
2939
|
+
status: "running",
|
|
2940
|
+
runId,
|
|
2941
|
+
expiresAt: new Date(expiresAt).toISOString()
|
|
2942
|
+
};
|
|
2900
2943
|
}
|
|
2901
2944
|
}
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2945
|
+
async initializeSimulationState(appIdentifier) {
|
|
2946
|
+
this.log(`Initializing simulation state for ${appIdentifier}`);
|
|
2947
|
+
const providedSimulationConfig = this.providedSimulationConfig;
|
|
2948
|
+
const mockSimulationConfigs = this.mockSimulationConfigs;
|
|
2949
|
+
const mockSimulationStates = this.mockSimulationStates;
|
|
2950
|
+
const mockActiveTimers = this.mockActiveTimers;
|
|
2951
|
+
const config = providedSimulationConfig || {
|
|
2952
|
+
version: "1.0",
|
|
2953
|
+
entities: {},
|
|
2954
|
+
recipes: {}
|
|
2955
|
+
};
|
|
2956
|
+
mockSimulationConfigs.set(appIdentifier, config);
|
|
2957
|
+
const initialInventory = {};
|
|
2958
|
+
if (providedSimulationConfig && config.entities) {
|
|
2959
|
+
Object.keys(config.entities).forEach((entityId) => {
|
|
2960
|
+
initialInventory[entityId] = 0;
|
|
2961
|
+
});
|
|
2905
2962
|
}
|
|
2906
|
-
const
|
|
2907
|
-
|
|
2908
|
-
|
|
2963
|
+
const state = {
|
|
2964
|
+
inventory: initialInventory,
|
|
2965
|
+
activeRuns: [],
|
|
2966
|
+
disabledRecipes: new Array()
|
|
2967
|
+
};
|
|
2968
|
+
if (config.recipes) {
|
|
2969
|
+
Object.entries(config.recipes).forEach(([recipeId, recipe]) => {
|
|
2970
|
+
if (recipe.metadata?.startsDisabled) {
|
|
2971
|
+
state.disabledRecipes.push(recipeId);
|
|
2972
|
+
}
|
|
2973
|
+
});
|
|
2909
2974
|
}
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2975
|
+
mockSimulationStates.set(appIdentifier, state);
|
|
2976
|
+
mockActiveTimers.set(appIdentifier, []);
|
|
2977
|
+
console.log(
|
|
2978
|
+
`[Venus Simulation Mock] Initialized state for ${appIdentifier}:`,
|
|
2979
|
+
state
|
|
2980
|
+
);
|
|
2981
|
+
if (config.recipes) {
|
|
2982
|
+
Object.entries(config.recipes).forEach(([recipeId, recipe]) => {
|
|
2983
|
+
const isAutoRestart = recipe.autoRestart || recipe.metadata?.autoRestart;
|
|
2984
|
+
if (isAutoRestart && recipe.outputs) {
|
|
2985
|
+
this.log(`Found auto-restart recipe: ${recipeId}`, {
|
|
2986
|
+
topLevelAutoRestart: recipe.autoRestart,
|
|
2987
|
+
metadataAutoRestart: recipe.metadata?.autoRestart,
|
|
2988
|
+
hasOutputs: !!recipe.outputs,
|
|
2989
|
+
duration: recipe.duration
|
|
2990
|
+
});
|
|
2991
|
+
const condition = recipe.maxRestartCondition || recipe.metadata?.maxRestartCondition;
|
|
2992
|
+
if (condition && condition.entity) {
|
|
2993
|
+
const currentAmount = initialInventory[condition.entity] || 0;
|
|
2994
|
+
if (currentAmount < condition.maxValue) {
|
|
2995
|
+
console.log(
|
|
2996
|
+
`[Venus Simulation Mock] Auto-starting ${recipeId} at initialization`,
|
|
2997
|
+
{
|
|
2998
|
+
currentAmount,
|
|
2999
|
+
maxValue: condition.maxValue,
|
|
3000
|
+
entity: condition.entity
|
|
3001
|
+
}
|
|
3002
|
+
);
|
|
3003
|
+
setTimeout(() => {
|
|
3004
|
+
this.executeRecipe(appIdentifier, recipeId, {});
|
|
3005
|
+
}, 1e3);
|
|
3006
|
+
}
|
|
3007
|
+
} else {
|
|
3008
|
+
console.log(
|
|
3009
|
+
`[Venus Simulation Mock] Auto-starting ${recipeId} at initialization (no condition)`
|
|
3010
|
+
);
|
|
3011
|
+
setTimeout(() => {
|
|
3012
|
+
this.executeRecipe(appIdentifier, recipeId, {});
|
|
3013
|
+
}, 1e3);
|
|
3014
|
+
}
|
|
3015
|
+
}
|
|
3016
|
+
});
|
|
3017
|
+
}
|
|
3018
|
+
return state;
|
|
3019
|
+
}
|
|
3020
|
+
generateRunId() {
|
|
3021
|
+
return "run_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9);
|
|
3022
|
+
}
|
|
3023
|
+
completeRun(appIdentifier, runId) {
|
|
3024
|
+
this.log(`Completing run ${runId} for ${appIdentifier}`);
|
|
3025
|
+
const mockSimulationConfigs = this.mockSimulationConfigs;
|
|
3026
|
+
const mockSimulationStates = this.mockSimulationStates;
|
|
3027
|
+
const config = mockSimulationConfigs.get(appIdentifier);
|
|
3028
|
+
const state = mockSimulationStates.get(appIdentifier);
|
|
3029
|
+
if (!config || !state) return;
|
|
3030
|
+
const runIndex = state.activeRuns.findIndex((r) => r.id === runId);
|
|
3031
|
+
if (runIndex === -1) return;
|
|
3032
|
+
const run = state.activeRuns[runIndex];
|
|
3033
|
+
const recipe = config.recipes?.[run.recipeId];
|
|
3034
|
+
if (!recipe) return;
|
|
3035
|
+
const outputs = {};
|
|
3036
|
+
const rng = this.createSeededRandom(runId);
|
|
3037
|
+
if (recipe.outputs) {
|
|
3038
|
+
for (const [entityId, value] of Object.entries(recipe.outputs)) {
|
|
3039
|
+
if (typeof value === "number") {
|
|
3040
|
+
outputs[entityId] = value;
|
|
3041
|
+
} else if (typeof value === "object" && value != null && "min" in value && "max" in value && typeof value.min == "number" && typeof value.max === "number") {
|
|
3042
|
+
outputs[entityId] = Math.floor(rng() * (value.max - value.min + 1)) + value.min;
|
|
3043
|
+
}
|
|
3044
|
+
}
|
|
3045
|
+
}
|
|
3046
|
+
for (const [entityId, amount] of Object.entries(outputs)) {
|
|
3047
|
+
state.inventory[entityId] = (state.inventory[entityId] || 0) + amount;
|
|
3048
|
+
}
|
|
3049
|
+
if (recipe.endEffects) {
|
|
3050
|
+
this.applyEffects(state, recipe.endEffects);
|
|
3051
|
+
}
|
|
3052
|
+
run.status = "completed";
|
|
3053
|
+
run.outputs = outputs;
|
|
3054
|
+
state.activeRuns.splice(runIndex, 1);
|
|
3055
|
+
const isAutoRestart = recipe.autoRestart || recipe.metadata?.autoRestart;
|
|
3056
|
+
if (isAutoRestart) {
|
|
3057
|
+
console.log(
|
|
3058
|
+
`[Venus Simulation Mock] Checking auto-restart for ${run.recipeId}`,
|
|
3059
|
+
{
|
|
3060
|
+
topLevelAutoRestart: recipe.autoRestart,
|
|
3061
|
+
metadataAutoRestart: recipe.metadata?.autoRestart,
|
|
3062
|
+
hasCondition: !!(recipe.maxRestartCondition || recipe.metadata?.maxRestartCondition)
|
|
3063
|
+
}
|
|
2914
3064
|
);
|
|
3065
|
+
const condition = recipe.maxRestartCondition || recipe.metadata?.maxRestartCondition;
|
|
3066
|
+
if (condition) {
|
|
3067
|
+
const currentAmount = state.inventory[condition.entity] || 0;
|
|
3068
|
+
if (currentAmount < condition.maxValue) {
|
|
3069
|
+
console.log(
|
|
3070
|
+
`[Venus Simulation Mock] Auto-restarting ${run.recipeId}`,
|
|
3071
|
+
{
|
|
3072
|
+
currentAmount,
|
|
3073
|
+
maxValue: condition.maxValue,
|
|
3074
|
+
entity: condition.entity
|
|
3075
|
+
}
|
|
3076
|
+
);
|
|
3077
|
+
setTimeout(() => {
|
|
3078
|
+
this.executeRecipe(appIdentifier, run.recipeId, recipe.inputs || {});
|
|
3079
|
+
}, 1e3);
|
|
3080
|
+
}
|
|
3081
|
+
} else {
|
|
3082
|
+
console.log(
|
|
3083
|
+
`[Venus Simulation Mock] Auto-restarting ${run.recipeId} (no condition)`
|
|
3084
|
+
);
|
|
3085
|
+
setTimeout(() => {
|
|
3086
|
+
this.executeRecipe(appIdentifier, run.recipeId, recipe.inputs || {});
|
|
3087
|
+
}, 1e3);
|
|
3088
|
+
}
|
|
3089
|
+
}
|
|
3090
|
+
console.log(
|
|
3091
|
+
`[Venus Simulation Mock] Completed run ${runId}, outputs:`,
|
|
3092
|
+
outputs
|
|
3093
|
+
);
|
|
3094
|
+
}
|
|
3095
|
+
createSeededRandom(seed) {
|
|
3096
|
+
let hash = 0;
|
|
3097
|
+
for (let i = 0; i < seed.length; i++) {
|
|
3098
|
+
const char = seed.charCodeAt(i);
|
|
3099
|
+
hash = (hash << 5) - hash + char;
|
|
3100
|
+
hash = hash & hash;
|
|
2915
3101
|
}
|
|
3102
|
+
return () => {
|
|
3103
|
+
hash = (hash * 9301 + 49297) % 233280;
|
|
3104
|
+
return hash / 233280;
|
|
3105
|
+
};
|
|
3106
|
+
}
|
|
3107
|
+
applyEffects(state, effects) {
|
|
3108
|
+
if (!effects || !Array.isArray(effects)) return;
|
|
3109
|
+
for (const effect of effects) {
|
|
3110
|
+
switch (effect.type) {
|
|
3111
|
+
case "set":
|
|
3112
|
+
state.inventory[effect.target] = effect.value;
|
|
3113
|
+
console.log(
|
|
3114
|
+
`[Venus Simulation Mock] Effect: Set ${effect.target} = ${effect.value}`
|
|
3115
|
+
);
|
|
3116
|
+
break;
|
|
3117
|
+
case "add":
|
|
3118
|
+
state.inventory[effect.target] = (state.inventory[effect.target] || 0) + effect.value;
|
|
3119
|
+
console.log(
|
|
3120
|
+
`[Venus Simulation Mock] Effect: Add ${effect.value} to ${effect.target} (new value: ${state.inventory[effect.target]})`
|
|
3121
|
+
);
|
|
3122
|
+
break;
|
|
3123
|
+
case "multiply":
|
|
3124
|
+
state.inventory[effect.target] = (state.inventory[effect.target] || 0) * effect.value;
|
|
3125
|
+
console.log(
|
|
3126
|
+
`[Venus Simulation Mock] Effect: Multiply ${effect.target} by ${effect.value} (new value: ${state.inventory[effect.target]})`
|
|
3127
|
+
);
|
|
3128
|
+
break;
|
|
3129
|
+
case "min":
|
|
3130
|
+
state.inventory[effect.target] = Math.max(
|
|
3131
|
+
state.inventory[effect.target] || 0,
|
|
3132
|
+
effect.value
|
|
3133
|
+
);
|
|
3134
|
+
console.log(
|
|
3135
|
+
`[Venus Simulation Mock] Effect: Set ${effect.target} min ${effect.value} (new value: ${state.inventory[effect.target]})`
|
|
3136
|
+
);
|
|
3137
|
+
break;
|
|
3138
|
+
case "max":
|
|
3139
|
+
state.inventory[effect.target] = Math.min(
|
|
3140
|
+
state.inventory[effect.target] || 0,
|
|
3141
|
+
effect.value
|
|
3142
|
+
);
|
|
3143
|
+
console.log(
|
|
3144
|
+
`[Venus Simulation Mock] Effect: Set ${effect.target} max ${effect.value} (new value: ${state.inventory[effect.target]})`
|
|
3145
|
+
);
|
|
3146
|
+
break;
|
|
3147
|
+
case "enable_recipe":
|
|
3148
|
+
if (state.disabledRecipes?.includes(effect.target)) {
|
|
3149
|
+
state.disabledRecipes = state.disabledRecipes.filter(
|
|
3150
|
+
(r) => r !== effect.target
|
|
3151
|
+
);
|
|
3152
|
+
console.log(
|
|
3153
|
+
`[Venus Simulation Mock] Effect: Enabled recipe ${effect.target}`
|
|
3154
|
+
);
|
|
3155
|
+
}
|
|
3156
|
+
break;
|
|
3157
|
+
case "disable_recipe":
|
|
3158
|
+
if (!state.disabledRecipes) state.disabledRecipes = [];
|
|
3159
|
+
if (!state.disabledRecipes.includes(effect.target)) {
|
|
3160
|
+
state.disabledRecipes.push(effect.target);
|
|
3161
|
+
console.log(
|
|
3162
|
+
`[Venus Simulation Mock] Effect: Disabled recipe ${effect.target}`
|
|
3163
|
+
);
|
|
3164
|
+
}
|
|
3165
|
+
break;
|
|
3166
|
+
case "trigger_recipe":
|
|
3167
|
+
console.log(
|
|
3168
|
+
`[Venus Simulation Mock] Effect: Trigger recipe ${effect.target} (not implemented)`
|
|
3169
|
+
);
|
|
3170
|
+
break;
|
|
3171
|
+
default:
|
|
3172
|
+
console.warn(
|
|
3173
|
+
`[Venus Simulation Mock] Unknown effect type: ${effect.type}`
|
|
3174
|
+
);
|
|
3175
|
+
}
|
|
3176
|
+
}
|
|
3177
|
+
}
|
|
3178
|
+
async getConfigAsync() {
|
|
3179
|
+
console.log("[Venus Simulation Mock] getConfigAsync called");
|
|
3180
|
+
const appIdentifier = this.appId;
|
|
3181
|
+
const mockSimulationConfigs = this.mockSimulationConfigs;
|
|
3182
|
+
const config = mockSimulationConfigs.get(appIdentifier) || {
|
|
3183
|
+
version: "1.0",
|
|
3184
|
+
entities: {},
|
|
3185
|
+
recipes: {}
|
|
3186
|
+
};
|
|
3187
|
+
return config;
|
|
3188
|
+
}
|
|
3189
|
+
async getStateAsync(roomId) {
|
|
3190
|
+
this.log("getStateAsync called:", roomId);
|
|
3191
|
+
const appIdentifier = this.appId;
|
|
3192
|
+
const mockSimulationStates = this.mockSimulationStates;
|
|
3193
|
+
let state = mockSimulationStates.get(appIdentifier);
|
|
3194
|
+
if (!state) {
|
|
3195
|
+
state = await this.initializeSimulationState(appIdentifier);
|
|
3196
|
+
}
|
|
3197
|
+
const mockSimulationConfigs = this.mockSimulationConfigs;
|
|
3198
|
+
return {
|
|
3199
|
+
...state,
|
|
3200
|
+
roomId,
|
|
3201
|
+
configuration: mockSimulationConfigs.get(appIdentifier)
|
|
3202
|
+
};
|
|
3203
|
+
}
|
|
3204
|
+
async assignItemToSlotAsync(containerId, slotId, itemId) {
|
|
3205
|
+
this.log("assignItemToSlotAsync called:", {
|
|
3206
|
+
containerId,
|
|
3207
|
+
slotId,
|
|
3208
|
+
itemId
|
|
3209
|
+
});
|
|
3210
|
+
return { success: true, message: "Mock assignment successful" };
|
|
3211
|
+
}
|
|
3212
|
+
async removeItemFromSlotAsync(containerId, slotId) {
|
|
3213
|
+
this.log("removeItemFromSlotAsync called:", {
|
|
3214
|
+
containerId,
|
|
3215
|
+
slotId
|
|
3216
|
+
});
|
|
3217
|
+
return { success: true, message: "Mock removal successful" };
|
|
2916
3218
|
}
|
|
2917
3219
|
};
|
|
2918
3220
|
|
|
2919
3221
|
// src/simulation/index.ts
|
|
2920
3222
|
function initializeSimulation(venusApi, host) {
|
|
3223
|
+
console.log("[Venus SDK] Initializing new Simulation Api");
|
|
2921
3224
|
venusApi.simulation = {
|
|
2922
3225
|
isEnabled: () => true
|
|
2923
3226
|
};
|
|
2924
3227
|
venusApi.simulation.getConfigAsync = () => {
|
|
2925
3228
|
return host.simulation.getConfigAsync();
|
|
2926
3229
|
};
|
|
2927
|
-
venusApi.simulation.getStateAsync = (
|
|
2928
|
-
return host.simulation.getStateAsync(roomId);
|
|
3230
|
+
venusApi.simulation.getStateAsync = (options) => {
|
|
3231
|
+
return host.simulation.getStateAsync(options?.roomId);
|
|
2929
3232
|
};
|
|
2930
3233
|
venusApi.simulation.executeRecipeAsync = (recipeId, inputs, options) => {
|
|
2931
3234
|
return host.simulation.executeRecipeAsync(recipeId, inputs, options);
|
|
@@ -2936,17 +3239,31 @@ function initializeSimulation(venusApi, host) {
|
|
|
2936
3239
|
venusApi.simulation.collectRecipeAsync = (runId) => {
|
|
2937
3240
|
return host.simulation.collectRecipeAsync(runId);
|
|
2938
3241
|
};
|
|
2939
|
-
venusApi.simulation.executeScopedRecipeAsync = (recipeId, entity, inputs, options) => {
|
|
2940
|
-
return host.simulation.executeScopedRecipeAsync(recipeId, entity, inputs,
|
|
3242
|
+
venusApi.simulation.executeScopedRecipeAsync = (recipeId, entity, inputs, roomId, options) => {
|
|
3243
|
+
return host.simulation.executeScopedRecipeAsync(recipeId, entity, inputs, {
|
|
3244
|
+
roomId,
|
|
3245
|
+
...options
|
|
3246
|
+
});
|
|
2941
3247
|
};
|
|
2942
|
-
venusApi.simulation.triggerRecipeChainAsync = (recipeId,
|
|
2943
|
-
return host.simulation.triggerRecipeChainAsync(recipeId,
|
|
3248
|
+
venusApi.simulation.triggerRecipeChainAsync = (recipeId, context, roomId) => {
|
|
3249
|
+
return host.simulation.triggerRecipeChainAsync(recipeId, {
|
|
3250
|
+
context,
|
|
3251
|
+
roomId
|
|
3252
|
+
});
|
|
2944
3253
|
};
|
|
2945
|
-
venusApi.simulation.getAvailableRecipesAsync = async (
|
|
2946
|
-
|
|
3254
|
+
venusApi.simulation.getAvailableRecipesAsync = async (roomId, includeActorRecipes) => {
|
|
3255
|
+
const result = await host.simulation.getAvailableRecipesAsync({
|
|
3256
|
+
roomId,
|
|
3257
|
+
includeActorRecipes
|
|
3258
|
+
});
|
|
3259
|
+
return result.recipes;
|
|
2947
3260
|
};
|
|
2948
|
-
venusApi.simulation.getRecipeRequirementsAsync = (
|
|
2949
|
-
return host.simulation.getRecipeRequirementsAsync(
|
|
3261
|
+
venusApi.simulation.getRecipeRequirementsAsync = (recipeId, entity, amount) => {
|
|
3262
|
+
return host.simulation.getRecipeRequirementsAsync({
|
|
3263
|
+
recipeId,
|
|
3264
|
+
entity,
|
|
3265
|
+
batchAmount: amount
|
|
3266
|
+
});
|
|
2950
3267
|
};
|
|
2951
3268
|
venusApi.simulation.getBatchRecipeRequirementsAsync = (recipes) => {
|
|
2952
3269
|
return host.simulation.getBatchRecipeRequirementsAsync(recipes);
|
|
@@ -2989,6 +3306,9 @@ function initializeSimulation(venusApi, host) {
|
|
|
2989
3306
|
itemId
|
|
2990
3307
|
);
|
|
2991
3308
|
};
|
|
3309
|
+
venusApi.simulation.sumContributions = (contributions) => {
|
|
3310
|
+
return host.simulation.sumContributions(contributions);
|
|
3311
|
+
};
|
|
2992
3312
|
}
|
|
2993
3313
|
|
|
2994
3314
|
// src/time/utils.ts
|
|
@@ -3103,6 +3423,7 @@ var MockTimeApi = class {
|
|
|
3103
3423
|
maximumFractionDigits: options?.maximumFractionDigits || 2,
|
|
3104
3424
|
...options
|
|
3105
3425
|
};
|
|
3426
|
+
console.log(`[Venus Mock] Formatting number ${value} with locale ${locale}`);
|
|
3106
3427
|
return value.toLocaleString(locale, numberOptions);
|
|
3107
3428
|
}
|
|
3108
3429
|
formatTime(timestamp, options) {
|
|
@@ -3114,9 +3435,13 @@ var MockTimeApi = class {
|
|
|
3114
3435
|
hour12: options.hour12 !== void 0 ? options.hour12 : true,
|
|
3115
3436
|
...options
|
|
3116
3437
|
};
|
|
3438
|
+
console.log(
|
|
3439
|
+
`[Venus Mock] Formatting time ${timestamp} with locale ${locale}`
|
|
3440
|
+
);
|
|
3117
3441
|
return date.toLocaleString(locale, dateTimeOptions);
|
|
3118
3442
|
}
|
|
3119
3443
|
async getFutureTimeAsync(options) {
|
|
3444
|
+
console.log("[Venus Mock] Getting future time with options:", options);
|
|
3120
3445
|
const timeInfo = await this.requestTimeAsync();
|
|
3121
3446
|
const serverTime = new Date(timeInfo.serverTime);
|
|
3122
3447
|
const result = new Date(serverTime);
|
|
@@ -3161,6 +3486,7 @@ var MockTimeApi = class {
|
|
|
3161
3486
|
return result.getTime();
|
|
3162
3487
|
}
|
|
3163
3488
|
async requestTimeAsync() {
|
|
3489
|
+
console.log("[Venus Mock] Requesting time");
|
|
3164
3490
|
await createMockDelay(MOCK_DELAYS.short);
|
|
3165
3491
|
const venusApi = this.venusApi;
|
|
3166
3492
|
const mockOffset = venusApi._mock.serverTimeOffset || 2500;
|
|
@@ -3174,6 +3500,11 @@ var MockTimeApi = class {
|
|
|
3174
3500
|
formattedTime: new Date(localTime).toISOString(),
|
|
3175
3501
|
locale: venusApi._mock.user?.locale || "en-US"
|
|
3176
3502
|
};
|
|
3503
|
+
console.log("[Venus Mock] Time response:", {
|
|
3504
|
+
serverTime: new Date(timeInfo.serverTime).toISOString(),
|
|
3505
|
+
localTime: new Date(timeInfo.localTime).toISOString(),
|
|
3506
|
+
timezoneOffset: timeInfo.timezoneOffset
|
|
3507
|
+
});
|
|
3177
3508
|
return timeInfo;
|
|
3178
3509
|
}
|
|
3179
3510
|
};
|
|
@@ -3193,9 +3524,178 @@ function initializeTime(venusApi, host) {
|
|
|
3193
3524
|
return host.time.formatNumber(value, options);
|
|
3194
3525
|
};
|
|
3195
3526
|
}
|
|
3196
|
-
|
|
3197
|
-
// src/version.ts
|
|
3198
|
-
var SDK_VERSION = "3.0.
|
|
3527
|
+
|
|
3528
|
+
// src/version.ts
|
|
3529
|
+
var SDK_VERSION = "3.1.0-beta.0";
|
|
3530
|
+
|
|
3531
|
+
// src/shared-assets/embeddedLibrariesManifest.ts
|
|
3532
|
+
var DEFAULT_SHARED_LIB_CDN_BASE = "https://venus-static-01293ak.web.app/libs";
|
|
3533
|
+
var EMBEDDED_LIBRARIES = [
|
|
3534
|
+
{
|
|
3535
|
+
libraryKey: "phaser@3.90.0",
|
|
3536
|
+
assetKey: "library:phaser@3.90.0",
|
|
3537
|
+
packageName: "phaser",
|
|
3538
|
+
version: "3.90.0",
|
|
3539
|
+
globalVar: "Phaser",
|
|
3540
|
+
cdnPath: "phaser/3.90.0/phaser.min.js",
|
|
3541
|
+
moduleSpecifiers: [{ match: "exact", value: "phaser" }],
|
|
3542
|
+
loadStage: 0,
|
|
3543
|
+
enabled: true
|
|
3544
|
+
},
|
|
3545
|
+
{
|
|
3546
|
+
libraryKey: "react@18.3.1",
|
|
3547
|
+
assetKey: "library:react@18.3.1",
|
|
3548
|
+
packageName: "react",
|
|
3549
|
+
version: "18.3.1",
|
|
3550
|
+
globalVar: "React",
|
|
3551
|
+
cdnPath: "react/18.3.1/react.production.min.js",
|
|
3552
|
+
moduleSpecifiers: [
|
|
3553
|
+
{ match: "exact", value: "react", behavior: "namespace" },
|
|
3554
|
+
{ match: "exact", value: "react/jsx-runtime", behavior: "react-jsx-runtime" },
|
|
3555
|
+
{
|
|
3556
|
+
match: "exact",
|
|
3557
|
+
value: "react/jsx-dev-runtime",
|
|
3558
|
+
behavior: "react-jsx-dev-runtime"
|
|
3559
|
+
}
|
|
3560
|
+
],
|
|
3561
|
+
loadStage: 0,
|
|
3562
|
+
// Must load before ReactDOM
|
|
3563
|
+
enabled: true
|
|
3564
|
+
},
|
|
3565
|
+
{
|
|
3566
|
+
libraryKey: "react-dom@18.3.1",
|
|
3567
|
+
assetKey: "library:react-dom@18.3.1",
|
|
3568
|
+
packageName: "react-dom",
|
|
3569
|
+
version: "18.3.1",
|
|
3570
|
+
globalVar: "ReactDOM",
|
|
3571
|
+
cdnPath: "react-dom/18.3.1/react-dom.production.min.js",
|
|
3572
|
+
moduleSpecifiers: [
|
|
3573
|
+
{ match: "exact", value: "react-dom", behavior: "namespace" },
|
|
3574
|
+
{ match: "exact", value: "react-dom/client", behavior: "namespace" }
|
|
3575
|
+
],
|
|
3576
|
+
loadStage: 1,
|
|
3577
|
+
// Depends on React (stage 0)
|
|
3578
|
+
enabled: true
|
|
3579
|
+
},
|
|
3580
|
+
{
|
|
3581
|
+
libraryKey: "three@0.170.0",
|
|
3582
|
+
assetKey: "library:three@0.170.0",
|
|
3583
|
+
packageName: "three",
|
|
3584
|
+
version: "0.170.0",
|
|
3585
|
+
globalVar: "THREE",
|
|
3586
|
+
cdnPath: "three/r170/three.min.js",
|
|
3587
|
+
moduleSpecifiers: [
|
|
3588
|
+
{ match: "exact", value: "three", behavior: "namespace" },
|
|
3589
|
+
{ match: "prefix", value: "three/examples/jsm/", behavior: "namespace" }
|
|
3590
|
+
],
|
|
3591
|
+
loadStage: 0,
|
|
3592
|
+
enabled: true
|
|
3593
|
+
},
|
|
3594
|
+
{
|
|
3595
|
+
libraryKey: "matter-js@0.19.0",
|
|
3596
|
+
assetKey: "library:matter-js@0.19.0",
|
|
3597
|
+
packageName: "matter-js",
|
|
3598
|
+
version: "0.19.0",
|
|
3599
|
+
globalVar: "Matter",
|
|
3600
|
+
cdnPath: "matter-js/0.19.0/matter.min.js",
|
|
3601
|
+
moduleSpecifiers: [{ match: "exact", value: "matter-js" }],
|
|
3602
|
+
loadStage: 0,
|
|
3603
|
+
enabled: true
|
|
3604
|
+
},
|
|
3605
|
+
{
|
|
3606
|
+
libraryKey: "inkjs@2.2.0",
|
|
3607
|
+
assetKey: "library:inkjs@2.2.0",
|
|
3608
|
+
packageName: "inkjs",
|
|
3609
|
+
version: "2.2.0",
|
|
3610
|
+
globalVar: "inkjs",
|
|
3611
|
+
cdnPath: "inkjs/2.2.0/ink.min.js",
|
|
3612
|
+
moduleSpecifiers: [{ match: "exact", value: "inkjs" }],
|
|
3613
|
+
loadStage: 0,
|
|
3614
|
+
enabled: true
|
|
3615
|
+
},
|
|
3616
|
+
{
|
|
3617
|
+
libraryKey: "zustand@5.0.3",
|
|
3618
|
+
assetKey: "library:zustand@5.0.3",
|
|
3619
|
+
packageName: "zustand",
|
|
3620
|
+
version: "5.0.3",
|
|
3621
|
+
globalVar: "zustand",
|
|
3622
|
+
cdnPath: "zustand/5.0.3/zustand.min.js",
|
|
3623
|
+
moduleSpecifiers: [
|
|
3624
|
+
{ match: "exact", value: "zustand" },
|
|
3625
|
+
{ match: "exact", value: "zustand/middleware" }
|
|
3626
|
+
],
|
|
3627
|
+
loadStage: 0,
|
|
3628
|
+
enabled: true
|
|
3629
|
+
},
|
|
3630
|
+
{
|
|
3631
|
+
libraryKey: "ammo.js@2024.11",
|
|
3632
|
+
assetKey: "library:ammo.js@2024.11",
|
|
3633
|
+
packageName: "ammo.js",
|
|
3634
|
+
version: "2024.11",
|
|
3635
|
+
globalVar: "Ammo",
|
|
3636
|
+
cdnPath: "ammo/2024.11/ammo.js",
|
|
3637
|
+
moduleSpecifiers: [
|
|
3638
|
+
{ match: "exact", value: "ammo.js" },
|
|
3639
|
+
{ match: "exact", value: "ammo.js/builds/ammo.wasm.js" }
|
|
3640
|
+
],
|
|
3641
|
+
loadStage: 0,
|
|
3642
|
+
enabled: false
|
|
3643
|
+
// Not ready yet - WASM loading needs additional work
|
|
3644
|
+
}
|
|
3645
|
+
];
|
|
3646
|
+
var EMBEDDED_LIBRARY_BY_KEY = EMBEDDED_LIBRARIES.reduce(
|
|
3647
|
+
(acc, lib) => {
|
|
3648
|
+
acc[lib.libraryKey] = lib;
|
|
3649
|
+
return acc;
|
|
3650
|
+
},
|
|
3651
|
+
{}
|
|
3652
|
+
);
|
|
3653
|
+
var MODULE_TO_LIBRARY_SPECIFIERS = EMBEDDED_LIBRARIES.filter(
|
|
3654
|
+
(lib) => lib.enabled
|
|
3655
|
+
).flatMap(
|
|
3656
|
+
(lib) => lib.moduleSpecifiers.map((specifier) => ({
|
|
3657
|
+
...specifier,
|
|
3658
|
+
libraryKey: lib.libraryKey
|
|
3659
|
+
}))
|
|
3660
|
+
);
|
|
3661
|
+
function getLibraryDefinition(libraryKey) {
|
|
3662
|
+
const definition = EMBEDDED_LIBRARY_BY_KEY[libraryKey];
|
|
3663
|
+
if (!definition) {
|
|
3664
|
+
const availableKeys = Object.keys(EMBEDDED_LIBRARY_BY_KEY).join(", ");
|
|
3665
|
+
throw new Error(
|
|
3666
|
+
`Unsupported embedded library: ${libraryKey}. Available libraries: ${availableKeys}`
|
|
3667
|
+
);
|
|
3668
|
+
}
|
|
3669
|
+
return definition;
|
|
3670
|
+
}
|
|
3671
|
+
|
|
3672
|
+
// src/shared-assets/base64Utils.ts
|
|
3673
|
+
function base64ToArrayBuffer(base64) {
|
|
3674
|
+
const binaryString = atob(base64);
|
|
3675
|
+
const len = binaryString.length;
|
|
3676
|
+
const bytes = new Uint8Array(len);
|
|
3677
|
+
for (let i = 0; i < len; i++) {
|
|
3678
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
3679
|
+
}
|
|
3680
|
+
return bytes.buffer;
|
|
3681
|
+
}
|
|
3682
|
+
function base64ToUtf8(base64) {
|
|
3683
|
+
if (typeof TextDecoder !== "undefined") {
|
|
3684
|
+
const decoder = new TextDecoder("utf-8");
|
|
3685
|
+
const buffer = base64ToArrayBuffer(base64);
|
|
3686
|
+
return decoder.decode(new Uint8Array(buffer));
|
|
3687
|
+
}
|
|
3688
|
+
if (typeof globalThis !== "undefined" && typeof globalThis.Buffer !== "undefined") {
|
|
3689
|
+
const BufferCtor = globalThis.Buffer;
|
|
3690
|
+
return BufferCtor.from(base64, "base64").toString("utf-8");
|
|
3691
|
+
}
|
|
3692
|
+
const binaryString = atob(base64);
|
|
3693
|
+
let result = "";
|
|
3694
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
3695
|
+
result += String.fromCharCode(binaryString.charCodeAt(i));
|
|
3696
|
+
}
|
|
3697
|
+
return decodeURIComponent(escape(result));
|
|
3698
|
+
}
|
|
3199
3699
|
|
|
3200
3700
|
// src/shared-assets/consts.ts
|
|
3201
3701
|
var BurgerTimeAssetsCdnPath = "burger-time/Core.stow";
|
|
@@ -3239,16 +3739,33 @@ var RpcSharedAssetsApi = class {
|
|
|
3239
3739
|
}
|
|
3240
3740
|
}
|
|
3241
3741
|
}
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3742
|
+
async loadLibraryCode(libraryKey) {
|
|
3743
|
+
const definition = getLibraryDefinition(libraryKey);
|
|
3744
|
+
try {
|
|
3745
|
+
const response = await this.rpcClient.callT("H5_LOAD_EMBEDDED_ASSET" /* H5_LOAD_EMBEDDED_ASSET */, {
|
|
3746
|
+
assetKey: definition.assetKey
|
|
3747
|
+
});
|
|
3748
|
+
return base64ToUtf8(response.base64Data);
|
|
3749
|
+
} catch (err) {
|
|
3750
|
+
console.error(
|
|
3751
|
+
`[Venus Libraries] Failed to load ${libraryKey} from host via RPC:`,
|
|
3752
|
+
err
|
|
3753
|
+
);
|
|
3754
|
+
console.warn(
|
|
3755
|
+
`[Venus Libraries] Falling back to CDN for ${libraryKey}. This may indicate an asset packaging issue.`
|
|
3756
|
+
);
|
|
3757
|
+
try {
|
|
3758
|
+
const cdnUrl = this.venusApi.cdn.resolveSharedLibUrl(definition.cdnPath);
|
|
3759
|
+
const response = await this.venusApi.cdn.fetchFromCdn(cdnUrl);
|
|
3760
|
+
return await response.text();
|
|
3761
|
+
} catch (cdnError) {
|
|
3762
|
+
throw new Error(
|
|
3763
|
+
`Failed to load embedded library ${libraryKey}: RPC failed, CDN fallback failed: ${cdnError.message}`
|
|
3764
|
+
);
|
|
3765
|
+
}
|
|
3766
|
+
}
|
|
3249
3767
|
}
|
|
3250
|
-
|
|
3251
|
-
}
|
|
3768
|
+
};
|
|
3252
3769
|
|
|
3253
3770
|
// src/shared-assets/MockSharedAssetsApi.ts
|
|
3254
3771
|
var MockSharedAssetsApi = class {
|
|
@@ -3264,6 +3781,12 @@ var MockSharedAssetsApi = class {
|
|
|
3264
3781
|
const blob = await this.venusApi.cdn.fetchBlob(CharacterAssetsCdnPath);
|
|
3265
3782
|
return await blob.arrayBuffer();
|
|
3266
3783
|
}
|
|
3784
|
+
async loadLibraryCode(libraryKey) {
|
|
3785
|
+
const definition = getLibraryDefinition(libraryKey);
|
|
3786
|
+
const url = this.venusApi.cdn.resolveSharedLibUrl(definition.cdnPath);
|
|
3787
|
+
const response = await this.venusApi.cdn.fetchFromCdn(url);
|
|
3788
|
+
return await response.text();
|
|
3789
|
+
}
|
|
3267
3790
|
};
|
|
3268
3791
|
|
|
3269
3792
|
// src/leaderboard/utils.ts
|
|
@@ -3698,6 +4221,7 @@ var MockPostApi = class {
|
|
|
3698
4221
|
}
|
|
3699
4222
|
async toggleFollowAsync() {
|
|
3700
4223
|
const venusApi = this.venusApi;
|
|
4224
|
+
console.log("[Venus Mock] *Toggling follow status");
|
|
3701
4225
|
await createMockDelay(MOCK_DELAYS.short);
|
|
3702
4226
|
venusApi._mock.currentPostInteractions.isFollowing = !venusApi._mock.currentPostInteractions.isFollowing;
|
|
3703
4227
|
const isFollowing = venusApi._mock.currentPostInteractions.isFollowing;
|
|
@@ -3868,16 +4392,6 @@ var VenusTransport = class {
|
|
|
3868
4392
|
this.isProcessingMessage = false;
|
|
3869
4393
|
return;
|
|
3870
4394
|
}
|
|
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
|
-
}
|
|
3881
4395
|
const requestId = messageData.requestId;
|
|
3882
4396
|
if (!requestId) {
|
|
3883
4397
|
this.logWarn("No requestId. Ignoring message...");
|
|
@@ -4044,6 +4558,294 @@ var VenusTransport = class {
|
|
|
4044
4558
|
}
|
|
4045
4559
|
};
|
|
4046
4560
|
|
|
4561
|
+
// src/RemoteHost.ts
|
|
4562
|
+
init_rooms();
|
|
4563
|
+
|
|
4564
|
+
// src/rooms/RpcRoomsApi.ts
|
|
4565
|
+
init_VenusRoom();
|
|
4566
|
+
var RpcRoomsApi = class {
|
|
4567
|
+
constructor(rpcClient) {
|
|
4568
|
+
__publicField(this, "rpcClient");
|
|
4569
|
+
__publicField(this, "subscriptions");
|
|
4570
|
+
__publicField(this, "transportSubscription", null);
|
|
4571
|
+
this.rpcClient = rpcClient;
|
|
4572
|
+
this.subscriptions = {
|
|
4573
|
+
data: {},
|
|
4574
|
+
messages: {},
|
|
4575
|
+
gameEvents: {},
|
|
4576
|
+
allEvents: {}
|
|
4577
|
+
};
|
|
4578
|
+
}
|
|
4579
|
+
/**
|
|
4580
|
+
* Get the subscription state for external access (used by setupRoomNotifications)
|
|
4581
|
+
*/
|
|
4582
|
+
getSubscriptions() {
|
|
4583
|
+
return this.subscriptions;
|
|
4584
|
+
}
|
|
4585
|
+
/**
|
|
4586
|
+
* Set up room notification routing from the transport
|
|
4587
|
+
*/
|
|
4588
|
+
setupNotifications(transport) {
|
|
4589
|
+
const { setupRoomNotifications: setupRoomNotifications2 } = (init_rooms(), __toCommonJS(rooms_exports));
|
|
4590
|
+
this.transportSubscription = setupRoomNotifications2(
|
|
4591
|
+
transport,
|
|
4592
|
+
() => this.getSubscriptions()
|
|
4593
|
+
);
|
|
4594
|
+
}
|
|
4595
|
+
/**
|
|
4596
|
+
* Clean up subscriptions and resources
|
|
4597
|
+
*/
|
|
4598
|
+
dispose() {
|
|
4599
|
+
if (this.transportSubscription) {
|
|
4600
|
+
this.transportSubscription.unsubscribe();
|
|
4601
|
+
this.transportSubscription = null;
|
|
4602
|
+
console.log("[Venus Rooms] Cleaned up room notification subscription");
|
|
4603
|
+
}
|
|
4604
|
+
}
|
|
4605
|
+
async createRoom(options) {
|
|
4606
|
+
const response = await this.rpcClient.call(
|
|
4607
|
+
"H5_ROOM_CREATE" /* H5_ROOM_CREATE */,
|
|
4608
|
+
{
|
|
4609
|
+
options
|
|
4610
|
+
}
|
|
4611
|
+
);
|
|
4612
|
+
if (response.success === false) {
|
|
4613
|
+
throw new Error(response.error || "Failed to create room");
|
|
4614
|
+
}
|
|
4615
|
+
const roomData = response.roomData || response;
|
|
4616
|
+
const room = new VenusRoom(roomData);
|
|
4617
|
+
return room;
|
|
4618
|
+
}
|
|
4619
|
+
async joinOrCreateRoom(options) {
|
|
4620
|
+
const response = await this.rpcClient.call(
|
|
4621
|
+
"H5_ROOM_JOIN_OR_CREATE" /* H5_ROOM_JOIN_OR_CREATE */,
|
|
4622
|
+
{
|
|
4623
|
+
options
|
|
4624
|
+
}
|
|
4625
|
+
);
|
|
4626
|
+
if (response.success === false) {
|
|
4627
|
+
throw new Error(response.error || "Failed to join or create room");
|
|
4628
|
+
}
|
|
4629
|
+
const data = response.value || response;
|
|
4630
|
+
const room = new VenusRoom(data.roomData);
|
|
4631
|
+
return {
|
|
4632
|
+
action: data.action,
|
|
4633
|
+
room,
|
|
4634
|
+
playersJoined: data.playersJoined
|
|
4635
|
+
};
|
|
4636
|
+
}
|
|
4637
|
+
async joinRoomByCode(roomCode) {
|
|
4638
|
+
const response = await this.rpcClient.call(
|
|
4639
|
+
"H5_ROOM_JOIN_BY_CODE" /* H5_ROOM_JOIN_BY_CODE */,
|
|
4640
|
+
{
|
|
4641
|
+
roomCode
|
|
4642
|
+
}
|
|
4643
|
+
);
|
|
4644
|
+
if (response?.success === false) {
|
|
4645
|
+
throw new Error(response.error || "Failed to join room by code");
|
|
4646
|
+
}
|
|
4647
|
+
const roomData = response.roomData || response;
|
|
4648
|
+
const room = new VenusRoom(roomData);
|
|
4649
|
+
return room;
|
|
4650
|
+
}
|
|
4651
|
+
// Get user's rooms with optional filtering
|
|
4652
|
+
async getUserRooms(includeArchived = false) {
|
|
4653
|
+
const response = await this.rpcClient.call(
|
|
4654
|
+
"H5_ROOM_GET_USER_ROOMS" /* H5_ROOM_GET_USER_ROOMS */,
|
|
4655
|
+
{
|
|
4656
|
+
includeArchived
|
|
4657
|
+
}
|
|
4658
|
+
);
|
|
4659
|
+
if (response?.success === false) {
|
|
4660
|
+
throw new Error(response.error || "Failed to get user rooms");
|
|
4661
|
+
}
|
|
4662
|
+
const rawRooms = response.rooms || [];
|
|
4663
|
+
const venusRooms = [];
|
|
4664
|
+
for (const roomData of rawRooms) {
|
|
4665
|
+
if (!roomData.id) {
|
|
4666
|
+
console.warn("getUserRooms: Skipping room with missing ID:", roomData);
|
|
4667
|
+
continue;
|
|
4668
|
+
}
|
|
4669
|
+
try {
|
|
4670
|
+
const venusRoom = new VenusRoom(roomData);
|
|
4671
|
+
venusRooms.push(venusRoom);
|
|
4672
|
+
} catch (error) {
|
|
4673
|
+
console.warn(
|
|
4674
|
+
"getUserRooms: Failed to create VenusRoom object:",
|
|
4675
|
+
error,
|
|
4676
|
+
roomData
|
|
4677
|
+
);
|
|
4678
|
+
}
|
|
4679
|
+
}
|
|
4680
|
+
return venusRooms;
|
|
4681
|
+
}
|
|
4682
|
+
async updateData(room, updates, merge = true) {
|
|
4683
|
+
const response = await this.rpcClient.call(
|
|
4684
|
+
"H5_ROOM_UPDATE_DATA" /* H5_ROOM_UPDATE_DATA */,
|
|
4685
|
+
{
|
|
4686
|
+
roomId: room.id,
|
|
4687
|
+
updates,
|
|
4688
|
+
merge
|
|
4689
|
+
}
|
|
4690
|
+
);
|
|
4691
|
+
if (response?.success === false) {
|
|
4692
|
+
throw new Error(response.error || "Failed to update room data");
|
|
4693
|
+
}
|
|
4694
|
+
return response.data;
|
|
4695
|
+
}
|
|
4696
|
+
async getData(room) {
|
|
4697
|
+
const response = await this.rpcClient.call(
|
|
4698
|
+
"H5_ROOM_GET_DATA" /* H5_ROOM_GET_DATA */,
|
|
4699
|
+
{
|
|
4700
|
+
roomId: room.id
|
|
4701
|
+
}
|
|
4702
|
+
);
|
|
4703
|
+
if (response?.success === false) {
|
|
4704
|
+
throw new Error(response.error || "Failed to get room data");
|
|
4705
|
+
}
|
|
4706
|
+
return response.data;
|
|
4707
|
+
}
|
|
4708
|
+
async sendMessage(venusRoom, messageData) {
|
|
4709
|
+
const response = await this.rpcClient.call(
|
|
4710
|
+
"H5_ROOM_SEND_MESSAGE" /* H5_ROOM_SEND_MESSAGE */,
|
|
4711
|
+
{
|
|
4712
|
+
roomId: venusRoom.id,
|
|
4713
|
+
message: messageData
|
|
4714
|
+
}
|
|
4715
|
+
);
|
|
4716
|
+
if (response?.success === false) {
|
|
4717
|
+
throw new Error(response.error || "Failed to send message");
|
|
4718
|
+
}
|
|
4719
|
+
return response.messageId;
|
|
4720
|
+
}
|
|
4721
|
+
async leave(room) {
|
|
4722
|
+
const response = await this.rpcClient.call(
|
|
4723
|
+
"H5_ROOM_LEAVE" /* H5_ROOM_LEAVE */,
|
|
4724
|
+
{
|
|
4725
|
+
roomId: room.id
|
|
4726
|
+
}
|
|
4727
|
+
);
|
|
4728
|
+
if (response?.success === false) {
|
|
4729
|
+
throw new Error(response.error || "Failed to leave room");
|
|
4730
|
+
}
|
|
4731
|
+
return response;
|
|
4732
|
+
}
|
|
4733
|
+
async startGame(room, gameConfig = {}, turnOrder = null) {
|
|
4734
|
+
const response = await this.rpcClient.call(
|
|
4735
|
+
"H5_ROOM_START_GAME" /* H5_ROOM_START_GAME */,
|
|
4736
|
+
{
|
|
4737
|
+
roomId: room.id,
|
|
4738
|
+
gameConfig,
|
|
4739
|
+
turnOrder
|
|
4740
|
+
}
|
|
4741
|
+
);
|
|
4742
|
+
if (response?.success === false) {
|
|
4743
|
+
throw new Error(response.error || "Failed to start game");
|
|
4744
|
+
}
|
|
4745
|
+
return response.data;
|
|
4746
|
+
}
|
|
4747
|
+
async proposeMove(room, proposalPayload) {
|
|
4748
|
+
const response = await this.rpcClient.call(
|
|
4749
|
+
"h5:room:proposeMove" /* H5_ROOM_PROPOSE_MOVE */,
|
|
4750
|
+
{
|
|
4751
|
+
roomId: room.id,
|
|
4752
|
+
gameSpecificState: proposalPayload.gameSpecificState,
|
|
4753
|
+
moveType: proposalPayload.moveType,
|
|
4754
|
+
clientContext: proposalPayload.clientContext,
|
|
4755
|
+
clientProposalId: proposalPayload.clientProposalId
|
|
4756
|
+
}
|
|
4757
|
+
);
|
|
4758
|
+
if (response?.success === false) {
|
|
4759
|
+
throw new Error(response.error || "Failed to propose move");
|
|
4760
|
+
}
|
|
4761
|
+
return response.data;
|
|
4762
|
+
}
|
|
4763
|
+
async validateMove(room, moveId, isValid, reason = null, validatorId = null) {
|
|
4764
|
+
console.log(`[Venus Rooms] Validating move ${moveId}: ${isValid}`);
|
|
4765
|
+
return { success: true, moveId, isValid, reason };
|
|
4766
|
+
}
|
|
4767
|
+
async roomSubscribeToGameEvents(room, callback) {
|
|
4768
|
+
"game_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9);
|
|
4769
|
+
if (!this.subscriptions.gameEvents[room.id]) {
|
|
4770
|
+
this.subscriptions.gameEvents[room.id] = [];
|
|
4771
|
+
}
|
|
4772
|
+
this.subscriptions.gameEvents[room.id].push(callback);
|
|
4773
|
+
}
|
|
4774
|
+
subscribe(room, options = {}) {
|
|
4775
|
+
const subscriptionIds = [];
|
|
4776
|
+
const roomId = room.id;
|
|
4777
|
+
if (options.onData) {
|
|
4778
|
+
const dataSubId = "data_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9);
|
|
4779
|
+
if (!this.subscriptions.data[roomId]) {
|
|
4780
|
+
this.subscriptions.data[roomId] = [];
|
|
4781
|
+
}
|
|
4782
|
+
this.subscriptions.data[roomId].push(options.onData);
|
|
4783
|
+
subscriptionIds.push({
|
|
4784
|
+
type: "data",
|
|
4785
|
+
id: dataSubId,
|
|
4786
|
+
callback: options.onData
|
|
4787
|
+
});
|
|
4788
|
+
}
|
|
4789
|
+
if (options.onMessages) {
|
|
4790
|
+
const msgSubId = "messages_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9);
|
|
4791
|
+
if (!this.subscriptions.messages[roomId]) {
|
|
4792
|
+
this.subscriptions.messages[roomId] = [];
|
|
4793
|
+
}
|
|
4794
|
+
this.subscriptions.messages[roomId].push(options.onMessages);
|
|
4795
|
+
subscriptionIds.push({
|
|
4796
|
+
type: "messages",
|
|
4797
|
+
id: msgSubId,
|
|
4798
|
+
callback: options.onMessages
|
|
4799
|
+
});
|
|
4800
|
+
}
|
|
4801
|
+
if (options.onMoves || options.onGameEvents) {
|
|
4802
|
+
const handler = options.onMoves || options.onGameEvents;
|
|
4803
|
+
if (handler) {
|
|
4804
|
+
const gameSubId = "game_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9);
|
|
4805
|
+
if (!this.subscriptions.gameEvents[roomId]) {
|
|
4806
|
+
this.subscriptions.gameEvents[roomId] = [];
|
|
4807
|
+
}
|
|
4808
|
+
this.subscriptions.gameEvents[roomId].push(handler);
|
|
4809
|
+
subscriptionIds.push({
|
|
4810
|
+
type: "gameEvents",
|
|
4811
|
+
id: gameSubId,
|
|
4812
|
+
callback: handler
|
|
4813
|
+
});
|
|
4814
|
+
}
|
|
4815
|
+
}
|
|
4816
|
+
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;
|
|
4817
|
+
if (needsSubscription) {
|
|
4818
|
+
this.rpcClient.call("H5_ROOM_SUBSCRIBE" /* H5_ROOM_SUBSCRIBE */, {
|
|
4819
|
+
roomId,
|
|
4820
|
+
subscribeToData: !!options.onData,
|
|
4821
|
+
subscribeToMessages: !!options.onMessages,
|
|
4822
|
+
subscribeToProposedMoves: !!(options.onMoves || options.onGameEvents)
|
|
4823
|
+
}).catch((error) => {
|
|
4824
|
+
console.error("Failed to set up room subscription:", error);
|
|
4825
|
+
});
|
|
4826
|
+
}
|
|
4827
|
+
let called = false;
|
|
4828
|
+
return () => {
|
|
4829
|
+
if (called) return;
|
|
4830
|
+
called = true;
|
|
4831
|
+
subscriptionIds.forEach((sub) => {
|
|
4832
|
+
const bucket = this.subscriptions[sub.type];
|
|
4833
|
+
const callbacks = bucket && bucket[roomId] || [];
|
|
4834
|
+
const index = callbacks.indexOf(sub.callback);
|
|
4835
|
+
if (index > -1) callbacks.splice(index, 1);
|
|
4836
|
+
});
|
|
4837
|
+
const hasNoCallbacks = (this.subscriptions.data[roomId]?.length ?? 0) === 0 && (this.subscriptions.messages[roomId]?.length ?? 0) === 0 && (this.subscriptions.gameEvents[roomId]?.length ?? 0) === 0;
|
|
4838
|
+
if (hasNoCallbacks) {
|
|
4839
|
+
this.rpcClient.call("H5_ROOM_UNSUBSCRIBE" /* H5_ROOM_UNSUBSCRIBE */, {
|
|
4840
|
+
roomId
|
|
4841
|
+
}).catch((error) => {
|
|
4842
|
+
console.error("Failed to clean up room subscription:", error);
|
|
4843
|
+
});
|
|
4844
|
+
}
|
|
4845
|
+
};
|
|
4846
|
+
}
|
|
4847
|
+
};
|
|
4848
|
+
|
|
4047
4849
|
// src/RemoteHost.ts
|
|
4048
4850
|
var getCdnBaseUrl = () => {
|
|
4049
4851
|
return "https://venus-static-01293ak.web.app/";
|
|
@@ -4134,6 +4936,7 @@ var RemoteHost = class {
|
|
|
4134
4936
|
venusApi.isMock = () => false;
|
|
4135
4937
|
this.venusApi.sharedAssets = new RpcSharedAssetsApi(rpcClient, venusApi);
|
|
4136
4938
|
initializeRoomsApi(this.venusApi, this);
|
|
4939
|
+
console.log("[Venus SDK] Remote host created");
|
|
4137
4940
|
}
|
|
4138
4941
|
get isInitialized() {
|
|
4139
4942
|
return this._isInitialized;
|
|
@@ -4190,120 +4993,49 @@ var RemoteHost = class {
|
|
|
4190
4993
|
};
|
|
4191
4994
|
|
|
4192
4995
|
// src/MockHost.ts
|
|
4996
|
+
init_rooms();
|
|
4193
4997
|
var ROOMS_UNAVAILABLE_MESSAGE = "[Venus SDK] Rooms API is only available when running inside the Venus host environment.";
|
|
4194
4998
|
function createUnavailableRoomsApi() {
|
|
4195
4999
|
const roomsUnavailableError = () => new Error(ROOMS_UNAVAILABLE_MESSAGE);
|
|
4196
5000
|
return {
|
|
4197
|
-
async
|
|
5001
|
+
async createRoom() {
|
|
4198
5002
|
throw roomsUnavailableError();
|
|
4199
5003
|
},
|
|
4200
|
-
async
|
|
5004
|
+
async joinOrCreateRoom() {
|
|
4201
5005
|
throw roomsUnavailableError();
|
|
4202
5006
|
},
|
|
4203
|
-
async
|
|
5007
|
+
async getUserRooms() {
|
|
4204
5008
|
throw roomsUnavailableError();
|
|
4205
5009
|
},
|
|
4206
|
-
async
|
|
5010
|
+
async joinRoomByCode() {
|
|
4207
5011
|
throw roomsUnavailableError();
|
|
4208
5012
|
},
|
|
4209
|
-
|
|
5013
|
+
subscribe() {
|
|
4210
5014
|
throw roomsUnavailableError();
|
|
4211
5015
|
},
|
|
4212
|
-
async
|
|
5016
|
+
async updateData() {
|
|
4213
5017
|
throw roomsUnavailableError();
|
|
4214
5018
|
},
|
|
4215
|
-
async
|
|
5019
|
+
async getData() {
|
|
4216
5020
|
throw roomsUnavailableError();
|
|
4217
5021
|
},
|
|
4218
|
-
async
|
|
5022
|
+
async sendMessage() {
|
|
4219
5023
|
throw roomsUnavailableError();
|
|
4220
5024
|
},
|
|
4221
|
-
async
|
|
5025
|
+
async leave() {
|
|
4222
5026
|
throw roomsUnavailableError();
|
|
4223
5027
|
},
|
|
4224
|
-
async
|
|
5028
|
+
async startGame() {
|
|
4225
5029
|
throw roomsUnavailableError();
|
|
4226
5030
|
},
|
|
4227
|
-
async
|
|
5031
|
+
async proposeMove() {
|
|
4228
5032
|
throw roomsUnavailableError();
|
|
4229
5033
|
},
|
|
4230
|
-
async
|
|
5034
|
+
async validateMove() {
|
|
4231
5035
|
throw roomsUnavailableError();
|
|
4232
5036
|
}
|
|
4233
5037
|
};
|
|
4234
5038
|
}
|
|
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
|
-
}
|
|
4307
5039
|
var MockHost = class {
|
|
4308
5040
|
constructor(venusApi) {
|
|
4309
5041
|
__publicField(this, "ads");
|
|
@@ -4358,7 +5090,7 @@ var MockHost = class {
|
|
|
4358
5090
|
this.haptics = new MockHapticsApi(venusApi);
|
|
4359
5091
|
this.features = new MockFeaturesApi();
|
|
4360
5092
|
this.lifecycle = this._mockLifecyclesApi;
|
|
4361
|
-
this.simulation =
|
|
5093
|
+
this.simulation = new MockSimulationApi();
|
|
4362
5094
|
this.rooms = createUnavailableRoomsApi();
|
|
4363
5095
|
this.logging = new MockLoggingApi();
|
|
4364
5096
|
this.iap = new MockIapApi();
|
|
@@ -4853,8 +5585,10 @@ var MockHost = class {
|
|
|
4853
5585
|
// src/Host.ts
|
|
4854
5586
|
function createHost(venusApi, isMock) {
|
|
4855
5587
|
if (isMock) {
|
|
5588
|
+
console.log("[Venus SDK] Creating Local Host");
|
|
4856
5589
|
return new MockHost(venusApi);
|
|
4857
5590
|
} else {
|
|
5591
|
+
console.log("[Venus SDK] Creating Remote Host");
|
|
4858
5592
|
return new RemoteHost(venusApi);
|
|
4859
5593
|
}
|
|
4860
5594
|
}
|
|
@@ -4867,6 +5601,6 @@ function initializeSocial(venusApi, host) {
|
|
|
4867
5601
|
};
|
|
4868
5602
|
}
|
|
4869
5603
|
|
|
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,
|
|
4871
|
-
//# sourceMappingURL=chunk-
|
|
4872
|
-
//# sourceMappingURL=chunk-
|
|
5604
|
+
export { DEFAULT_SHARED_LIB_CDN_BASE, EMBEDDED_LIBRARIES, EMBEDDED_LIBRARY_BY_KEY, HASH_ALGORITHM_NODE, HASH_ALGORITHM_WEB_CRYPTO, HapticFeedbackStyle, HostCdnApi, HostProfileApi, HostTimeApi, MODULE_TO_LIBRARY_SPECIFIERS, 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, base64ToArrayBuffer, base64ToUtf8, computeScoreHash, createHost, createMockStorageApi, getLibraryDefinition, 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 };
|
|
5605
|
+
//# sourceMappingURL=chunk-EMVTVSGL.mjs.map
|
|
5606
|
+
//# sourceMappingURL=chunk-EMVTVSGL.mjs.map
|