@series-inc/venus-sdk 3.0.6 → 3.1.1-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 +1 -1
- 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 +23 -3
- package/dist/chunk-LBJFUHOH.mjs.map +0 -1
- package/dist/chunk-MWUS3A7C.mjs.map +0 -1
- package/dist/core-RDMPQV6U.mjs +0 -3
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,243 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
7
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
5
24
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6
25
|
|
|
26
|
+
// src/rooms/RoomsApi.ts
|
|
27
|
+
var init_RoomsApi = __esm({
|
|
28
|
+
"src/rooms/RoomsApi.ts"() {
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// src/rooms/VenusRoom.ts
|
|
33
|
+
exports.VenusRoom = void 0;
|
|
34
|
+
var init_VenusRoom = __esm({
|
|
35
|
+
"src/rooms/VenusRoom.ts"() {
|
|
36
|
+
exports.VenusRoom = class {
|
|
37
|
+
constructor(roomData) {
|
|
38
|
+
__publicField(this, "id");
|
|
39
|
+
__publicField(this, "name");
|
|
40
|
+
__publicField(this, "players");
|
|
41
|
+
__publicField(this, "maxPlayers");
|
|
42
|
+
__publicField(this, "gameType");
|
|
43
|
+
__publicField(this, "appId");
|
|
44
|
+
__publicField(this, "type");
|
|
45
|
+
__publicField(this, "createdBy");
|
|
46
|
+
__publicField(this, "createdAt");
|
|
47
|
+
__publicField(this, "updatedAt");
|
|
48
|
+
__publicField(this, "isPrivate");
|
|
49
|
+
__publicField(this, "currentPlayers");
|
|
50
|
+
__publicField(this, "status");
|
|
51
|
+
__publicField(this, "customMetadata");
|
|
52
|
+
__publicField(this, "admins");
|
|
53
|
+
__publicField(this, "roomCode");
|
|
54
|
+
__publicField(this, "description");
|
|
55
|
+
__publicField(this, "data");
|
|
56
|
+
__publicField(this, "version");
|
|
57
|
+
__publicField(this, "_subscriptions", /* @__PURE__ */ new Map());
|
|
58
|
+
this.id = roomData.id;
|
|
59
|
+
this.name = roomData.name;
|
|
60
|
+
this.players = roomData.currentPlayers || [];
|
|
61
|
+
this.maxPlayers = roomData.maxPlayers;
|
|
62
|
+
this.gameType = roomData.gameType;
|
|
63
|
+
this.appId = roomData.appId;
|
|
64
|
+
this.type = roomData.type;
|
|
65
|
+
this.createdBy = roomData.createdBy;
|
|
66
|
+
this.createdAt = roomData.createdAt;
|
|
67
|
+
this.updatedAt = roomData.updatedAt;
|
|
68
|
+
this.isPrivate = roomData.isPrivate;
|
|
69
|
+
this.currentPlayers = roomData.currentPlayers || [];
|
|
70
|
+
this.status = roomData.status;
|
|
71
|
+
this.customMetadata = roomData.customMetadata || {};
|
|
72
|
+
this.admins = roomData.admins || [];
|
|
73
|
+
this.roomCode = roomData.roomCode;
|
|
74
|
+
this.description = roomData.description;
|
|
75
|
+
this.data = roomData.data || {};
|
|
76
|
+
this.version = roomData.version;
|
|
77
|
+
console.log(`VenusRoom: Created room object for ${this.id}`, {
|
|
78
|
+
hasCustomMetadata: !!this.customMetadata,
|
|
79
|
+
hasGameState: !!this.customMetadata?.rules?.gameState,
|
|
80
|
+
gamePhase: this.customMetadata?.rules?.gameState?.phase,
|
|
81
|
+
currentPlayer: this.customMetadata?.rules?.gameState?.currentPlayer
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
updateFromRoomData(newRoomData) {
|
|
85
|
+
if (newRoomData.id === this.id) {
|
|
86
|
+
this.name = newRoomData.name || this.name;
|
|
87
|
+
this.players = newRoomData.currentPlayers || this.players;
|
|
88
|
+
this.maxPlayers = newRoomData.maxPlayers || this.maxPlayers;
|
|
89
|
+
this.gameType = newRoomData.gameType || this.gameType;
|
|
90
|
+
this.currentPlayers = newRoomData.currentPlayers || this.currentPlayers;
|
|
91
|
+
this.customMetadata = newRoomData.customMetadata || this.customMetadata;
|
|
92
|
+
this.data = newRoomData.data || this.data;
|
|
93
|
+
this.status = newRoomData.status || this.status;
|
|
94
|
+
this.updatedAt = newRoomData.updatedAt || this.updatedAt;
|
|
95
|
+
console.log(`VenusRoom: Updated room object ${this.id} with fresh data`, {
|
|
96
|
+
hasCustomMetadata: !!this.customMetadata,
|
|
97
|
+
hasGameState: !!this.customMetadata?.rules?.gameState,
|
|
98
|
+
gamePhase: this.customMetadata?.rules?.gameState?.phase,
|
|
99
|
+
currentPlayer: this.customMetadata?.rules?.gameState?.currentPlayer
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// src/rooms/index.ts
|
|
108
|
+
var rooms_exports = {};
|
|
109
|
+
__export(rooms_exports, {
|
|
110
|
+
VenusRoom: () => exports.VenusRoom,
|
|
111
|
+
initializeRoomsApi: () => initializeRoomsApi,
|
|
112
|
+
setupRoomNotifications: () => setupRoomNotifications
|
|
113
|
+
});
|
|
114
|
+
function bindMethod(target, targetKey, source, sourceKey) {
|
|
115
|
+
const key = sourceKey ?? targetKey;
|
|
116
|
+
const fn = source?.[key];
|
|
117
|
+
if (typeof fn === "function") {
|
|
118
|
+
target[targetKey] = fn.bind(source);
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
function setupRoomNotifications(transport, getSubscriptions) {
|
|
124
|
+
console.log("[Venus Rooms] Setting up room notification listeners");
|
|
125
|
+
return transport.onVenusMessage((message) => {
|
|
126
|
+
const subscriptions = getSubscriptions();
|
|
127
|
+
if (!subscriptions) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (message.type === "H5_ROOM_DATA_UPDATED") {
|
|
131
|
+
const messageData = message.data;
|
|
132
|
+
const { roomId, roomData } = messageData;
|
|
133
|
+
if (!roomId) return;
|
|
134
|
+
const callbacks = subscriptions.data?.[roomId] || [];
|
|
135
|
+
const allEventsCallbacks = subscriptions.allEvents?.[roomId] || [];
|
|
136
|
+
console.log(`[Venus Rooms] \u{1F514} Room data updated for ${roomId}, notifying ${callbacks.length} callbacks`, roomData);
|
|
137
|
+
callbacks.forEach((callback) => {
|
|
138
|
+
try {
|
|
139
|
+
callback(roomData);
|
|
140
|
+
} catch (error) {
|
|
141
|
+
console.error("[Venus Rooms] Error in room data callback:", error);
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
allEventsCallbacks.forEach((callback) => {
|
|
146
|
+
try {
|
|
147
|
+
callback({ type: message.type, ...messageData });
|
|
148
|
+
} catch (error) {
|
|
149
|
+
console.error("[Venus Rooms] Error in allEvents callback:", error);
|
|
150
|
+
throw error;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
if (message.type === "H5_ROOM_MESSAGE_RECEIVED" || message.type === "H5_ROOM_MESSAGE_UPDATED" || message.type === "H5_ROOM_MESSAGE_DELETED") {
|
|
155
|
+
const messageData = message.data;
|
|
156
|
+
const { roomId } = messageData;
|
|
157
|
+
if (!roomId) return;
|
|
158
|
+
const callbacks = subscriptions.messages?.[roomId] || [];
|
|
159
|
+
const allEventsCallbacks = subscriptions.allEvents?.[roomId] || [];
|
|
160
|
+
console.log(`[Venus Rooms] \u{1F514} Room message event for ${roomId}, notifying ${callbacks.length} callbacks`);
|
|
161
|
+
callbacks.forEach((callback) => {
|
|
162
|
+
try {
|
|
163
|
+
callback(messageData);
|
|
164
|
+
} catch (error) {
|
|
165
|
+
console.error("[Venus Rooms] Error in room message callback:", error);
|
|
166
|
+
throw error;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
allEventsCallbacks.forEach((callback) => {
|
|
170
|
+
try {
|
|
171
|
+
callback({ type: message.type, ...messageData });
|
|
172
|
+
} catch (error) {
|
|
173
|
+
console.error("[Venus Rooms] Error in allEvents callback:", error);
|
|
174
|
+
throw error;
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
if (message.type === "app:h5:proposedMoveValidationUpdated") {
|
|
179
|
+
const messageData = message.data;
|
|
180
|
+
const { roomId } = messageData;
|
|
181
|
+
if (!roomId) return;
|
|
182
|
+
const callbacks = subscriptions.gameEvents?.[roomId] || [];
|
|
183
|
+
const allEventsCallbacks = subscriptions.allEvents?.[roomId] || [];
|
|
184
|
+
console.log(`[Venus Rooms] \u{1F514} Proposed move validation updated for ${roomId}, notifying ${callbacks.length} callbacks`);
|
|
185
|
+
callbacks.forEach((callback) => {
|
|
186
|
+
try {
|
|
187
|
+
callback(messageData);
|
|
188
|
+
} catch (error) {
|
|
189
|
+
console.error("[Venus Rooms] Error in game event callback:", error);
|
|
190
|
+
throw error;
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
allEventsCallbacks.forEach((callback) => {
|
|
194
|
+
try {
|
|
195
|
+
callback({ type: message.type, ...messageData });
|
|
196
|
+
} catch (error) {
|
|
197
|
+
console.error("[Venus Rooms] Error in allEvents callback:", error);
|
|
198
|
+
throw error;
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
function initializeRoomsApi(venusApi, host) {
|
|
205
|
+
const roomsApi = host?.rooms;
|
|
206
|
+
if (!roomsApi) {
|
|
207
|
+
console.warn(
|
|
208
|
+
"[Venus SDK] Host did not provide a rooms implementation. Rooms API will be unavailable."
|
|
209
|
+
);
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const venus = venusApi;
|
|
213
|
+
const existingNamespace = venus.rooms || {};
|
|
214
|
+
const roomsNamespace = Object.assign({}, existingNamespace);
|
|
215
|
+
const namespaceBindings = [
|
|
216
|
+
["create", "createRoom"],
|
|
217
|
+
["joinOrCreate", "joinOrCreateRoom"],
|
|
218
|
+
["joinByCode", "joinRoomByCode"],
|
|
219
|
+
["list", "getUserRooms"],
|
|
220
|
+
["subscribeToRoom", "subscribe"],
|
|
221
|
+
["updateRoomData", "updateData"],
|
|
222
|
+
["getRoomData", "getData"],
|
|
223
|
+
["sendRoomMessage", "sendMessage"],
|
|
224
|
+
["leaveRoom", "leave"],
|
|
225
|
+
["startRoomGame", "startGame"],
|
|
226
|
+
["proposeMove"],
|
|
227
|
+
["validateMove"]
|
|
228
|
+
];
|
|
229
|
+
namespaceBindings.forEach(([targetKey, sourceKey]) => {
|
|
230
|
+
bindMethod(roomsNamespace, targetKey, roomsApi, sourceKey);
|
|
231
|
+
});
|
|
232
|
+
venus.rooms = roomsNamespace;
|
|
233
|
+
}
|
|
234
|
+
var init_rooms = __esm({
|
|
235
|
+
"src/rooms/index.ts"() {
|
|
236
|
+
init_RoomsApi();
|
|
237
|
+
init_VenusRoom();
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
|
|
7
241
|
// src/VenusMessageId.ts
|
|
8
242
|
var VenusMessageId = /* @__PURE__ */ ((VenusMessageId2) => {
|
|
9
243
|
VenusMessageId2["H5_RESPONSE"] = "H5_RESPONSE";
|
|
@@ -95,9 +329,6 @@ var VenusMessageId = /* @__PURE__ */ ((VenusMessageId2) => {
|
|
|
95
329
|
VenusMessageId2["H5_SIMULATION_GET_AVAILABLE_ITEMS"] = "H5_SIMULATION_GET_AVAILABLE_ITEMS";
|
|
96
330
|
VenusMessageId2["H5_SIMULATION_VALIDATE_ASSIGNMENT"] = "H5_SIMULATION_VALIDATE_ASSIGNMENT";
|
|
97
331
|
VenusMessageId2["H5_SIMULATION_BATCH_OPERATIONS"] = "H5_SIMULATION_BATCH_OPERATIONS";
|
|
98
|
-
VenusMessageId2["H5_SIMULATION_SUBSCRIBE"] = "H5_SIMULATION_SUBSCRIBE";
|
|
99
|
-
VenusMessageId2["H5_SIMULATION_UNSUBSCRIBE"] = "H5_SIMULATION_UNSUBSCRIBE";
|
|
100
|
-
VenusMessageId2["H5_SIMULATION_UPDATE"] = "H5_SIMULATION_UPDATE";
|
|
101
332
|
VenusMessageId2["H5_LEADERBOARD_CREATE_SCORE_TOKEN"] = "H5_LEADERBOARD_CREATE_SCORE_TOKEN";
|
|
102
333
|
VenusMessageId2["H5_LEADERBOARD_SUBMIT_SCORE"] = "H5_LEADERBOARD_SUBMIT_SCORE";
|
|
103
334
|
VenusMessageId2["H5_LEADERBOARD_GET_PAGED_SCORES"] = "H5_LEADERBOARD_GET_PAGED_SCORES";
|
|
@@ -1562,8 +1793,13 @@ var MockNotificationsApi = class {
|
|
|
1562
1793
|
async cancelNotification(notificationId) {
|
|
1563
1794
|
const venusApi = this.venusApi;
|
|
1564
1795
|
if (isWebPlatform()) {
|
|
1796
|
+
console.log(
|
|
1797
|
+
"[Venus Mock] Cancel notification on web platform (simulated):",
|
|
1798
|
+
notificationId
|
|
1799
|
+
);
|
|
1565
1800
|
return true;
|
|
1566
1801
|
}
|
|
1802
|
+
console.log("[Venus Mock] Cancel local notification:", notificationId);
|
|
1567
1803
|
await createMockDelay(MOCK_DELAYS.short);
|
|
1568
1804
|
if (venusApi._mock.scheduledNotifications && venusApi._mock.scheduledNotifications[notificationId]) {
|
|
1569
1805
|
delete venusApi._mock.scheduledNotifications[notificationId];
|
|
@@ -1573,8 +1809,12 @@ var MockNotificationsApi = class {
|
|
|
1573
1809
|
}
|
|
1574
1810
|
async getAllScheduledLocalNotifications() {
|
|
1575
1811
|
if (isWebPlatform()) {
|
|
1812
|
+
console.log(
|
|
1813
|
+
"[Venus Mock] Get notifications on web platform (returning empty list)"
|
|
1814
|
+
);
|
|
1576
1815
|
return [];
|
|
1577
1816
|
}
|
|
1817
|
+
console.log("[Venus Mock] Get all scheduled local notifications");
|
|
1578
1818
|
await createMockDelay(MOCK_DELAYS.short);
|
|
1579
1819
|
const venusApi = this.venusApi;
|
|
1580
1820
|
const notifications = venusApi._mock.scheduledNotifications || {};
|
|
@@ -1582,8 +1822,10 @@ var MockNotificationsApi = class {
|
|
|
1582
1822
|
}
|
|
1583
1823
|
async isLocalNotificationsEnabled() {
|
|
1584
1824
|
if (isWebPlatform()) {
|
|
1825
|
+
console.log("[Venus Mock] Notifications not available on web platform");
|
|
1585
1826
|
return false;
|
|
1586
1827
|
}
|
|
1828
|
+
console.log("[Venus Mock] Check if local notifications are enabled");
|
|
1587
1829
|
await createMockDelay(MOCK_DELAYS.short);
|
|
1588
1830
|
const venusApi = this.venusApi;
|
|
1589
1831
|
const isEnabled = venusApi._mock.notificationsEnabled !== false;
|
|
@@ -1592,6 +1834,9 @@ var MockNotificationsApi = class {
|
|
|
1592
1834
|
async scheduleAsync(title, body, seconds, notificationId, options) {
|
|
1593
1835
|
const { priority = 50, groupId, payload } = options || {};
|
|
1594
1836
|
if (isWebPlatform()) {
|
|
1837
|
+
console.log(
|
|
1838
|
+
"[Venus Mock] Notifications not supported on web platform, simulating success"
|
|
1839
|
+
);
|
|
1595
1840
|
console.info(
|
|
1596
1841
|
"\u{1F514} [Venus Mock] Notification would be scheduled:",
|
|
1597
1842
|
title || "Untitled",
|
|
@@ -1602,11 +1847,14 @@ var MockNotificationsApi = class {
|
|
|
1602
1847
|
const mockId = `mock-web-notification-${Date.now()}`;
|
|
1603
1848
|
return mockId;
|
|
1604
1849
|
}
|
|
1850
|
+
console.log("[Venus Mock] Schedule local notification:", { title, body, seconds, options });
|
|
1605
1851
|
const venusApi = this.venusApi;
|
|
1606
1852
|
if (!venusApi._mock.pendingRequests) {
|
|
1853
|
+
console.log("[Venus Mock] Initializing pendingRequests");
|
|
1607
1854
|
venusApi._mock.pendingRequests = {};
|
|
1608
1855
|
}
|
|
1609
1856
|
const requestId = Date.now().toString();
|
|
1857
|
+
console.log("[Venus Mock] Creating request with ID:", requestId);
|
|
1610
1858
|
return new Promise((resolve) => {
|
|
1611
1859
|
venusApi._mock.pendingRequests[requestId] = { resolve };
|
|
1612
1860
|
const id = notificationId || `mock-notification-${Date.now()}`;
|
|
@@ -1628,8 +1876,13 @@ var MockNotificationsApi = class {
|
|
|
1628
1876
|
async setLocalNotificationsEnabled(enabled) {
|
|
1629
1877
|
const venusApi = this.venusApi;
|
|
1630
1878
|
if (isWebPlatform()) {
|
|
1879
|
+
console.log(
|
|
1880
|
+
"[Venus Mock] Set notifications enabled on web platform (simulated):",
|
|
1881
|
+
enabled
|
|
1882
|
+
);
|
|
1631
1883
|
return true;
|
|
1632
1884
|
}
|
|
1885
|
+
console.log("[Venus Mock] Set local notifications enabled:", enabled);
|
|
1633
1886
|
await createMockDelay(MOCK_DELAYS.short);
|
|
1634
1887
|
venusApi._mock.notificationsEnabled = enabled;
|
|
1635
1888
|
return enabled;
|
|
@@ -1894,11 +2147,6 @@ function initializeProfile(venusApi, host) {
|
|
|
1894
2147
|
};
|
|
1895
2148
|
}
|
|
1896
2149
|
|
|
1897
|
-
// src/utils/idGenerator.ts
|
|
1898
|
-
function generateId() {
|
|
1899
|
-
return `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
1900
|
-
}
|
|
1901
|
-
|
|
1902
2150
|
// src/rpc/RpcClient.ts
|
|
1903
2151
|
var RpcClient = class {
|
|
1904
2152
|
constructor() {
|
|
@@ -1941,7 +2189,7 @@ var RpcClient = class {
|
|
|
1941
2189
|
}
|
|
1942
2190
|
async call(method, args, timeout = 5e3) {
|
|
1943
2191
|
return new Promise((resolve, reject) => {
|
|
1944
|
-
const id = generateId();
|
|
2192
|
+
const id = this.generateId();
|
|
1945
2193
|
this.addPendingCall(id, resolve, reject);
|
|
1946
2194
|
const request = {
|
|
1947
2195
|
type: "rpc-request",
|
|
@@ -1978,6 +2226,9 @@ var RpcClient = class {
|
|
|
1978
2226
|
getPendingCall(id) {
|
|
1979
2227
|
return this.pendingCalls.get(id);
|
|
1980
2228
|
}
|
|
2229
|
+
generateId() {
|
|
2230
|
+
return `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
2231
|
+
}
|
|
1981
2232
|
handleRpcResponse(response) {
|
|
1982
2233
|
const pending = this.getPendingCall(response.id);
|
|
1983
2234
|
if (!pending) {
|
|
@@ -1999,520 +2250,103 @@ var RpcClient = class {
|
|
|
1999
2250
|
}
|
|
2000
2251
|
};
|
|
2001
2252
|
|
|
2002
|
-
// src/
|
|
2003
|
-
|
|
2004
|
-
constructor(roomData) {
|
|
2005
|
-
__publicField(this, "id");
|
|
2006
|
-
__publicField(this, "name");
|
|
2007
|
-
__publicField(this, "players");
|
|
2008
|
-
__publicField(this, "maxPlayers");
|
|
2009
|
-
__publicField(this, "gameType");
|
|
2010
|
-
__publicField(this, "appId");
|
|
2011
|
-
__publicField(this, "type");
|
|
2012
|
-
__publicField(this, "createdBy");
|
|
2013
|
-
__publicField(this, "createdAt");
|
|
2014
|
-
__publicField(this, "updatedAt");
|
|
2015
|
-
__publicField(this, "isPrivate");
|
|
2016
|
-
__publicField(this, "status");
|
|
2017
|
-
__publicField(this, "customMetadata");
|
|
2018
|
-
__publicField(this, "admins");
|
|
2019
|
-
__publicField(this, "roomCode");
|
|
2020
|
-
__publicField(this, "description");
|
|
2021
|
-
__publicField(this, "data");
|
|
2022
|
-
__publicField(this, "version");
|
|
2023
|
-
this.id = roomData.id;
|
|
2024
|
-
this.name = roomData.name;
|
|
2025
|
-
this.players = Array.isArray(roomData.currentPlayers) ? [...roomData.currentPlayers] : [];
|
|
2026
|
-
this.maxPlayers = roomData.maxPlayers;
|
|
2027
|
-
this.gameType = roomData.gameType;
|
|
2028
|
-
this.appId = roomData.appId;
|
|
2029
|
-
this.type = roomData.type;
|
|
2030
|
-
this.createdBy = roomData.createdBy;
|
|
2031
|
-
this.createdAt = roomData.createdAt;
|
|
2032
|
-
this.updatedAt = roomData.updatedAt;
|
|
2033
|
-
this.isPrivate = roomData.isPrivate;
|
|
2034
|
-
this.status = roomData.status;
|
|
2035
|
-
this.customMetadata = roomData.customMetadata || {};
|
|
2036
|
-
this.admins = Array.isArray(roomData.admins) ? [...roomData.admins] : [];
|
|
2037
|
-
this.roomCode = roomData.roomCode;
|
|
2038
|
-
this.description = roomData.description;
|
|
2039
|
-
this.data = roomData.data || {};
|
|
2040
|
-
this.version = roomData.version;
|
|
2041
|
-
}
|
|
2042
|
-
};
|
|
2253
|
+
// src/index.ts
|
|
2254
|
+
init_rooms();
|
|
2043
2255
|
|
|
2044
|
-
// src/
|
|
2045
|
-
function
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2256
|
+
// src/storage/MockStorageApi.ts
|
|
2257
|
+
function createMockStorageApi(storageType, appUrl) {
|
|
2258
|
+
const appIdentifier = appUrl ? generateAppIdentifier(appUrl) : null;
|
|
2259
|
+
let prefix;
|
|
2260
|
+
let syncDelay = 0;
|
|
2261
|
+
switch (storageType) {
|
|
2262
|
+
case "deviceCache":
|
|
2263
|
+
prefix = "venus:app";
|
|
2264
|
+
syncDelay = 0;
|
|
2265
|
+
break;
|
|
2266
|
+
case "appStorage":
|
|
2267
|
+
prefix = "venus:app";
|
|
2268
|
+
syncDelay = 100;
|
|
2269
|
+
break;
|
|
2270
|
+
case "globalStorage":
|
|
2271
|
+
prefix = "venus:global";
|
|
2272
|
+
syncDelay = 100;
|
|
2273
|
+
break;
|
|
2274
|
+
default:
|
|
2275
|
+
throw new Error(`Unknown storage type: ${storageType}`);
|
|
2276
|
+
}
|
|
2277
|
+
prefix = storageType === "globalStorage" || !appIdentifier ? `${prefix}:` : `${prefix}:${appIdentifier}:`;
|
|
2278
|
+
return new MockStorageApi(prefix, syncDelay);
|
|
2054
2279
|
}
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
const
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
roomData,
|
|
2070
|
-
timestamp: messageData.timestamp
|
|
2071
|
-
};
|
|
2072
|
-
invokeCallbacks(callbacks, event, "room data");
|
|
2280
|
+
var MockStorageApi = class {
|
|
2281
|
+
constructor(prefix, syncDelay) {
|
|
2282
|
+
__publicField(this, "prefix");
|
|
2283
|
+
__publicField(this, "syncDelay");
|
|
2284
|
+
this.prefix = prefix;
|
|
2285
|
+
this.syncDelay = syncDelay;
|
|
2286
|
+
}
|
|
2287
|
+
async clear() {
|
|
2288
|
+
const fullLength = localStorage.length;
|
|
2289
|
+
for (let i = 0; i < fullLength; i++) {
|
|
2290
|
+
const fullKey = localStorage.key(i);
|
|
2291
|
+
if (fullKey && fullKey.startsWith(this.prefix)) {
|
|
2292
|
+
localStorage.removeItem(fullKey);
|
|
2293
|
+
}
|
|
2073
2294
|
}
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2295
|
+
await this.simulateSyncDelay();
|
|
2296
|
+
}
|
|
2297
|
+
async getAllItems() {
|
|
2298
|
+
const items = new Array();
|
|
2299
|
+
const fullLength = localStorage.length;
|
|
2300
|
+
for (let i = 0; i < fullLength; i++) {
|
|
2301
|
+
const fullKey = localStorage.key(i);
|
|
2302
|
+
if (fullKey && fullKey.startsWith(this.prefix)) {
|
|
2303
|
+
const item = localStorage.getItem(fullKey);
|
|
2304
|
+
if (item) {
|
|
2305
|
+
items.push(item);
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2086
2308
|
}
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
timestamp: messageData.timestamp
|
|
2099
|
-
};
|
|
2100
|
-
invokeCallbacks(callbacks, event, "game event");
|
|
2309
|
+
return items;
|
|
2310
|
+
}
|
|
2311
|
+
async getItem(key) {
|
|
2312
|
+
const fullKey = this.buildKey(key);
|
|
2313
|
+
await this.simulateSyncDelay();
|
|
2314
|
+
return localStorage.getItem(fullKey);
|
|
2315
|
+
}
|
|
2316
|
+
async key(index) {
|
|
2317
|
+
const keys = this.keys();
|
|
2318
|
+
if (index < 0 || index >= keys.length) {
|
|
2319
|
+
return null;
|
|
2101
2320
|
}
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
// src/rooms/RpcRoomsApi.ts
|
|
2106
|
-
var RpcRoomsApi = class {
|
|
2107
|
-
constructor(rpcClient) {
|
|
2108
|
-
__publicField(this, "rpcClient");
|
|
2109
|
-
__publicField(this, "subscriptions");
|
|
2110
|
-
this.rpcClient = rpcClient;
|
|
2111
|
-
this.subscriptions = {
|
|
2112
|
-
data: {},
|
|
2113
|
-
messages: {},
|
|
2114
|
-
gameEvents: {}
|
|
2115
|
-
};
|
|
2321
|
+
await this.simulateSyncDelay();
|
|
2322
|
+
return keys[index];
|
|
2116
2323
|
}
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
*/
|
|
2120
|
-
getSubscriptions() {
|
|
2121
|
-
return this.subscriptions;
|
|
2324
|
+
async length() {
|
|
2325
|
+
return this.keys().length;
|
|
2122
2326
|
}
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
setupRoomNotifications(transport, () => this.getSubscriptions());
|
|
2327
|
+
async removeItem(key) {
|
|
2328
|
+
const fullKey = this.buildKey(key);
|
|
2329
|
+
await this.simulateSyncDelay();
|
|
2330
|
+
localStorage.removeItem(fullKey);
|
|
2128
2331
|
}
|
|
2129
|
-
async
|
|
2130
|
-
const
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
)
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
throw new Error(errorMessage);
|
|
2332
|
+
async setItem(key, item) {
|
|
2333
|
+
const fullKey = this.buildKey(key);
|
|
2334
|
+
await this.simulateSyncDelay();
|
|
2335
|
+
localStorage.setItem(fullKey, item);
|
|
2336
|
+
}
|
|
2337
|
+
async setMultipleItems(entries) {
|
|
2338
|
+
for (const entry of entries) {
|
|
2339
|
+
const fullKey = this.buildKey(entry.key);
|
|
2340
|
+
localStorage.setItem(fullKey, entry.value);
|
|
2139
2341
|
}
|
|
2140
|
-
|
|
2141
|
-
return room;
|
|
2342
|
+
await this.simulateSyncDelay();
|
|
2142
2343
|
}
|
|
2143
|
-
async
|
|
2144
|
-
const
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
options
|
|
2148
|
-
}
|
|
2149
|
-
);
|
|
2150
|
-
if (response.success === false) {
|
|
2151
|
-
const errorMessage = typeof response.error === "string" ? response.error : "Failed to join or create room";
|
|
2152
|
-
throw new Error(errorMessage);
|
|
2344
|
+
async removeMultipleItems(keys) {
|
|
2345
|
+
for (const key of keys) {
|
|
2346
|
+
const fullKey = this.buildKey(key);
|
|
2347
|
+
localStorage.removeItem(fullKey);
|
|
2153
2348
|
}
|
|
2154
|
-
|
|
2155
|
-
return {
|
|
2156
|
-
action: response.value.action,
|
|
2157
|
-
room,
|
|
2158
|
-
playersJoined: response.value.playersJoined
|
|
2159
|
-
};
|
|
2160
|
-
}
|
|
2161
|
-
async joinRoomByCodeAsync(roomCode) {
|
|
2162
|
-
const response = await this.rpcClient.call(
|
|
2163
|
-
"H5_ROOM_JOIN_BY_CODE" /* H5_ROOM_JOIN_BY_CODE */,
|
|
2164
|
-
{
|
|
2165
|
-
roomCode
|
|
2166
|
-
}
|
|
2167
|
-
);
|
|
2168
|
-
if (response?.success === false) {
|
|
2169
|
-
const errorMessage = typeof response.error === "string" ? response.error : "Failed to join room by code";
|
|
2170
|
-
throw new Error(errorMessage);
|
|
2171
|
-
}
|
|
2172
|
-
const room = new VenusRoom(response.roomData);
|
|
2173
|
-
return room;
|
|
2174
|
-
}
|
|
2175
|
-
// Get user's rooms with optional filtering
|
|
2176
|
-
async getUserRoomsAsync(options = {}) {
|
|
2177
|
-
const response = await this.rpcClient.call(
|
|
2178
|
-
"H5_ROOM_GET_USER_ROOMS" /* H5_ROOM_GET_USER_ROOMS */,
|
|
2179
|
-
{
|
|
2180
|
-
includeArchived: options.includeArchived ?? false
|
|
2181
|
-
}
|
|
2182
|
-
);
|
|
2183
|
-
if (response?.success === false) {
|
|
2184
|
-
const errorMessage = typeof response.error === "string" ? response.error : "Failed to get user rooms";
|
|
2185
|
-
throw new Error(errorMessage);
|
|
2186
|
-
}
|
|
2187
|
-
const venusRooms = [];
|
|
2188
|
-
for (const roomData of response.rooms) {
|
|
2189
|
-
if (!roomData.id) {
|
|
2190
|
-
console.warn("[Venus SDK] getUserRooms: Skipping room with missing ID:", roomData);
|
|
2191
|
-
continue;
|
|
2192
|
-
}
|
|
2193
|
-
try {
|
|
2194
|
-
const venusRoom = new VenusRoom(roomData);
|
|
2195
|
-
venusRooms.push(venusRoom);
|
|
2196
|
-
} catch (error) {
|
|
2197
|
-
console.warn(
|
|
2198
|
-
"[Venus SDK] getUserRooms: Failed to create VenusRoom object:",
|
|
2199
|
-
error,
|
|
2200
|
-
roomData
|
|
2201
|
-
);
|
|
2202
|
-
}
|
|
2203
|
-
}
|
|
2204
|
-
return venusRooms;
|
|
2205
|
-
}
|
|
2206
|
-
async updateRoomDataAsync(room, updates, options = {}) {
|
|
2207
|
-
const response = await this.rpcClient.call(
|
|
2208
|
-
"H5_ROOM_UPDATE_DATA" /* H5_ROOM_UPDATE_DATA */,
|
|
2209
|
-
{
|
|
2210
|
-
roomId: room.id,
|
|
2211
|
-
updates,
|
|
2212
|
-
merge: options.merge ?? true
|
|
2213
|
-
}
|
|
2214
|
-
);
|
|
2215
|
-
if (response?.success === false) {
|
|
2216
|
-
const errorMessage = typeof response.error === "string" ? response.error : "Failed to update room data";
|
|
2217
|
-
throw new Error(errorMessage);
|
|
2218
|
-
}
|
|
2219
|
-
}
|
|
2220
|
-
async getRoomDataAsync(room) {
|
|
2221
|
-
const response = await this.rpcClient.call(
|
|
2222
|
-
"H5_ROOM_GET_DATA" /* H5_ROOM_GET_DATA */,
|
|
2223
|
-
{
|
|
2224
|
-
roomId: room.id
|
|
2225
|
-
}
|
|
2226
|
-
);
|
|
2227
|
-
if (response?.success === false) {
|
|
2228
|
-
const errorMessage = typeof response.error === "string" ? response.error : "Failed to get room data";
|
|
2229
|
-
throw new Error(errorMessage);
|
|
2230
|
-
}
|
|
2231
|
-
return response.data;
|
|
2232
|
-
}
|
|
2233
|
-
async sendRoomMessageAsync(venusRoom, request) {
|
|
2234
|
-
const response = await this.rpcClient.call(
|
|
2235
|
-
"H5_ROOM_SEND_MESSAGE" /* H5_ROOM_SEND_MESSAGE */,
|
|
2236
|
-
{
|
|
2237
|
-
roomId: venusRoom.id,
|
|
2238
|
-
message: request.message,
|
|
2239
|
-
metadata: request.metadata
|
|
2240
|
-
}
|
|
2241
|
-
);
|
|
2242
|
-
if (response?.success === false) {
|
|
2243
|
-
const errorMessage = typeof response.error === "string" ? response.error : "Failed to send message";
|
|
2244
|
-
throw new Error(errorMessage);
|
|
2245
|
-
}
|
|
2246
|
-
return response.messageId;
|
|
2247
|
-
}
|
|
2248
|
-
async leaveRoomAsync(room) {
|
|
2249
|
-
const response = await this.rpcClient.call(
|
|
2250
|
-
"H5_ROOM_LEAVE" /* H5_ROOM_LEAVE */,
|
|
2251
|
-
{
|
|
2252
|
-
roomId: room.id
|
|
2253
|
-
}
|
|
2254
|
-
);
|
|
2255
|
-
if (response?.success === false) {
|
|
2256
|
-
const errorMessage = typeof response.error === "string" ? response.error : "Failed to leave room";
|
|
2257
|
-
throw new Error(errorMessage);
|
|
2258
|
-
}
|
|
2259
|
-
}
|
|
2260
|
-
async startRoomGameAsync(room, options = {}) {
|
|
2261
|
-
const response = await this.rpcClient.call(
|
|
2262
|
-
"H5_ROOM_START_GAME" /* H5_ROOM_START_GAME */,
|
|
2263
|
-
{
|
|
2264
|
-
roomId: room.id,
|
|
2265
|
-
gameConfig: options.gameConfig ?? {},
|
|
2266
|
-
turnOrder: options.turnOrder ?? null
|
|
2267
|
-
}
|
|
2268
|
-
);
|
|
2269
|
-
if (response?.success === false) {
|
|
2270
|
-
const errorMessage = typeof response.error === "string" ? response.error : "Failed to start game";
|
|
2271
|
-
throw new Error(errorMessage);
|
|
2272
|
-
}
|
|
2273
|
-
}
|
|
2274
|
-
async proposeMoveAsync(room, proposalPayload) {
|
|
2275
|
-
const response = await this.rpcClient.call(
|
|
2276
|
-
"h5:room:proposeMove" /* H5_ROOM_PROPOSE_MOVE */,
|
|
2277
|
-
{
|
|
2278
|
-
roomId: room.id,
|
|
2279
|
-
gameSpecificState: proposalPayload.gameSpecificState,
|
|
2280
|
-
moveType: proposalPayload.moveType,
|
|
2281
|
-
clientContext: proposalPayload.clientContext,
|
|
2282
|
-
clientProposalId: proposalPayload.clientProposalId
|
|
2283
|
-
}
|
|
2284
|
-
);
|
|
2285
|
-
if (response?.success === false) {
|
|
2286
|
-
const errorMessage = typeof response.error === "string" ? response.error : "Failed to propose move";
|
|
2287
|
-
throw new Error(errorMessage);
|
|
2288
|
-
}
|
|
2289
|
-
return response.data;
|
|
2290
|
-
}
|
|
2291
|
-
async validateMoveAsync(_room, moveId, verdict) {
|
|
2292
|
-
return {
|
|
2293
|
-
success: true,
|
|
2294
|
-
moveId,
|
|
2295
|
-
isValid: verdict.isValid,
|
|
2296
|
-
reason: verdict.reason
|
|
2297
|
-
};
|
|
2298
|
-
}
|
|
2299
|
-
async subscribeAsync(room, options = {}) {
|
|
2300
|
-
const roomId = room.id;
|
|
2301
|
-
const existingData = this.subscriptions.data[roomId];
|
|
2302
|
-
const existingMessages = this.subscriptions.messages[roomId];
|
|
2303
|
-
const existingGameEvents = this.subscriptions.gameEvents[roomId];
|
|
2304
|
-
const subscribeToData = Boolean(options.onData) && (existingData?.length ?? 0) === 0;
|
|
2305
|
-
const subscribeToMessages = Boolean(options.onMessages) && (existingMessages?.length ?? 0) === 0;
|
|
2306
|
-
const subscribeToProposedMoves = Boolean(options.onGameEvents) && (existingGameEvents?.length ?? 0) === 0;
|
|
2307
|
-
if (subscribeToData || subscribeToMessages || subscribeToProposedMoves) {
|
|
2308
|
-
try {
|
|
2309
|
-
await this.rpcClient.call("H5_ROOM_SUBSCRIBE" /* H5_ROOM_SUBSCRIBE */, {
|
|
2310
|
-
roomId,
|
|
2311
|
-
subscribeToData,
|
|
2312
|
-
subscribeToMessages,
|
|
2313
|
-
subscribeToProposedMoves
|
|
2314
|
-
});
|
|
2315
|
-
} catch (error) {
|
|
2316
|
-
console.error("[Venus SDK] Failed to set up room subscription:", error);
|
|
2317
|
-
throw error;
|
|
2318
|
-
}
|
|
2319
|
-
}
|
|
2320
|
-
if (options.onData) {
|
|
2321
|
-
if (!this.subscriptions.data[roomId]) {
|
|
2322
|
-
this.subscriptions.data[roomId] = [];
|
|
2323
|
-
}
|
|
2324
|
-
this.subscriptions.data[roomId].push(options.onData);
|
|
2325
|
-
}
|
|
2326
|
-
if (options.onMessages) {
|
|
2327
|
-
if (!this.subscriptions.messages[roomId]) {
|
|
2328
|
-
this.subscriptions.messages[roomId] = [];
|
|
2329
|
-
}
|
|
2330
|
-
this.subscriptions.messages[roomId].push(options.onMessages);
|
|
2331
|
-
}
|
|
2332
|
-
if (options.onGameEvents) {
|
|
2333
|
-
if (!this.subscriptions.gameEvents[roomId]) {
|
|
2334
|
-
this.subscriptions.gameEvents[roomId] = [];
|
|
2335
|
-
}
|
|
2336
|
-
this.subscriptions.gameEvents[roomId].push(options.onGameEvents);
|
|
2337
|
-
}
|
|
2338
|
-
let disposed = false;
|
|
2339
|
-
return () => {
|
|
2340
|
-
if (disposed) return;
|
|
2341
|
-
disposed = true;
|
|
2342
|
-
if (options.onData) {
|
|
2343
|
-
const callbacks = this.subscriptions.data[roomId];
|
|
2344
|
-
if (callbacks) {
|
|
2345
|
-
const index = callbacks.indexOf(options.onData);
|
|
2346
|
-
if (index > -1) {
|
|
2347
|
-
callbacks.splice(index, 1);
|
|
2348
|
-
}
|
|
2349
|
-
}
|
|
2350
|
-
}
|
|
2351
|
-
if (options.onMessages) {
|
|
2352
|
-
const callbacks = this.subscriptions.messages[roomId];
|
|
2353
|
-
if (callbacks) {
|
|
2354
|
-
const index = callbacks.indexOf(options.onMessages);
|
|
2355
|
-
if (index > -1) {
|
|
2356
|
-
callbacks.splice(index, 1);
|
|
2357
|
-
}
|
|
2358
|
-
}
|
|
2359
|
-
}
|
|
2360
|
-
if (options.onGameEvents) {
|
|
2361
|
-
const callbacks = this.subscriptions.gameEvents[roomId];
|
|
2362
|
-
if (callbacks) {
|
|
2363
|
-
const index = callbacks.indexOf(options.onGameEvents);
|
|
2364
|
-
if (index > -1) {
|
|
2365
|
-
callbacks.splice(index, 1);
|
|
2366
|
-
}
|
|
2367
|
-
}
|
|
2368
|
-
}
|
|
2369
|
-
const hasAnySubscriptions = (this.subscriptions.data[roomId]?.length ?? 0) > 0 || (this.subscriptions.messages[roomId]?.length ?? 0) > 0 || (this.subscriptions.gameEvents[roomId]?.length ?? 0) > 0;
|
|
2370
|
-
if (!hasAnySubscriptions) {
|
|
2371
|
-
this.rpcClient.call("H5_ROOM_UNSUBSCRIBE" /* H5_ROOM_UNSUBSCRIBE */, {
|
|
2372
|
-
roomId
|
|
2373
|
-
}).catch((error) => {
|
|
2374
|
-
console.error("[Venus SDK] Failed to clean up room subscription:", error);
|
|
2375
|
-
});
|
|
2376
|
-
}
|
|
2377
|
-
};
|
|
2378
|
-
}
|
|
2379
|
-
};
|
|
2380
|
-
|
|
2381
|
-
// src/rooms/index.ts
|
|
2382
|
-
function bindMethod(target, targetKey, source, sourceKey) {
|
|
2383
|
-
const key = sourceKey ?? targetKey;
|
|
2384
|
-
const fn = source?.[key];
|
|
2385
|
-
if (typeof fn === "function") {
|
|
2386
|
-
target[targetKey] = fn.bind(source);
|
|
2387
|
-
return true;
|
|
2388
|
-
}
|
|
2389
|
-
return false;
|
|
2390
|
-
}
|
|
2391
|
-
function initializeRoomsApi(venusApi, host) {
|
|
2392
|
-
const roomsApi = host?.rooms;
|
|
2393
|
-
if (!roomsApi) {
|
|
2394
|
-
console.warn(
|
|
2395
|
-
"[Venus SDK] Host did not provide a rooms implementation. Rooms API will be unavailable."
|
|
2396
|
-
);
|
|
2397
|
-
return;
|
|
2398
|
-
}
|
|
2399
|
-
const venus = venusApi;
|
|
2400
|
-
const existingNamespace = venus.rooms || {};
|
|
2401
|
-
const roomsNamespace = Object.assign({}, existingNamespace);
|
|
2402
|
-
const namespaceBindings = [
|
|
2403
|
-
["createRoomAsync"],
|
|
2404
|
-
["joinOrCreateRoomAsync"],
|
|
2405
|
-
["joinRoomByCodeAsync"],
|
|
2406
|
-
["getUserRoomsAsync"],
|
|
2407
|
-
["subscribeAsync"],
|
|
2408
|
-
["updateRoomDataAsync"],
|
|
2409
|
-
["getRoomDataAsync"],
|
|
2410
|
-
["sendRoomMessageAsync"],
|
|
2411
|
-
["leaveRoomAsync"],
|
|
2412
|
-
["startRoomGameAsync"],
|
|
2413
|
-
["proposeMoveAsync"],
|
|
2414
|
-
["validateMoveAsync"]
|
|
2415
|
-
];
|
|
2416
|
-
namespaceBindings.forEach(([targetKey, sourceKey]) => {
|
|
2417
|
-
bindMethod(roomsNamespace, targetKey, roomsApi, sourceKey);
|
|
2418
|
-
});
|
|
2419
|
-
venus.rooms = roomsNamespace;
|
|
2420
|
-
}
|
|
2421
|
-
|
|
2422
|
-
// src/storage/MockStorageApi.ts
|
|
2423
|
-
function createMockStorageApi(storageType, appUrl) {
|
|
2424
|
-
const appIdentifier = appUrl ? generateAppIdentifier(appUrl) : null;
|
|
2425
|
-
let prefix;
|
|
2426
|
-
let syncDelay = 0;
|
|
2427
|
-
switch (storageType) {
|
|
2428
|
-
case "deviceCache":
|
|
2429
|
-
prefix = "venus:app";
|
|
2430
|
-
syncDelay = 0;
|
|
2431
|
-
break;
|
|
2432
|
-
case "appStorage":
|
|
2433
|
-
prefix = "venus:app";
|
|
2434
|
-
syncDelay = 100;
|
|
2435
|
-
break;
|
|
2436
|
-
case "globalStorage":
|
|
2437
|
-
prefix = "venus:global";
|
|
2438
|
-
syncDelay = 100;
|
|
2439
|
-
break;
|
|
2440
|
-
default:
|
|
2441
|
-
throw new Error(`Unknown storage type: ${storageType}`);
|
|
2442
|
-
}
|
|
2443
|
-
prefix = storageType === "globalStorage" || !appIdentifier ? `${prefix}:` : `${prefix}:${appIdentifier}:`;
|
|
2444
|
-
return new MockStorageApi(prefix, syncDelay);
|
|
2445
|
-
}
|
|
2446
|
-
var MockStorageApi = class {
|
|
2447
|
-
constructor(prefix, syncDelay) {
|
|
2448
|
-
__publicField(this, "prefix");
|
|
2449
|
-
__publicField(this, "syncDelay");
|
|
2450
|
-
this.prefix = prefix;
|
|
2451
|
-
this.syncDelay = syncDelay;
|
|
2452
|
-
}
|
|
2453
|
-
async clear() {
|
|
2454
|
-
const fullLength = localStorage.length;
|
|
2455
|
-
for (let i = 0; i < fullLength; i++) {
|
|
2456
|
-
const fullKey = localStorage.key(i);
|
|
2457
|
-
if (fullKey && fullKey.startsWith(this.prefix)) {
|
|
2458
|
-
localStorage.removeItem(fullKey);
|
|
2459
|
-
}
|
|
2460
|
-
}
|
|
2461
|
-
await this.simulateSyncDelay();
|
|
2462
|
-
}
|
|
2463
|
-
async getAllItems() {
|
|
2464
|
-
const items = new Array();
|
|
2465
|
-
const fullLength = localStorage.length;
|
|
2466
|
-
for (let i = 0; i < fullLength; i++) {
|
|
2467
|
-
const fullKey = localStorage.key(i);
|
|
2468
|
-
if (fullKey && fullKey.startsWith(this.prefix)) {
|
|
2469
|
-
const item = localStorage.getItem(fullKey);
|
|
2470
|
-
if (item) {
|
|
2471
|
-
items.push(item);
|
|
2472
|
-
}
|
|
2473
|
-
}
|
|
2474
|
-
}
|
|
2475
|
-
return items;
|
|
2476
|
-
}
|
|
2477
|
-
async getItem(key) {
|
|
2478
|
-
const fullKey = this.buildKey(key);
|
|
2479
|
-
await this.simulateSyncDelay();
|
|
2480
|
-
return localStorage.getItem(fullKey);
|
|
2481
|
-
}
|
|
2482
|
-
async key(index) {
|
|
2483
|
-
const keys = this.keys();
|
|
2484
|
-
if (index < 0 || index >= keys.length) {
|
|
2485
|
-
return null;
|
|
2486
|
-
}
|
|
2487
|
-
await this.simulateSyncDelay();
|
|
2488
|
-
return keys[index];
|
|
2489
|
-
}
|
|
2490
|
-
async length() {
|
|
2491
|
-
return this.keys().length;
|
|
2492
|
-
}
|
|
2493
|
-
async removeItem(key) {
|
|
2494
|
-
const fullKey = this.buildKey(key);
|
|
2495
|
-
await this.simulateSyncDelay();
|
|
2496
|
-
localStorage.removeItem(fullKey);
|
|
2497
|
-
}
|
|
2498
|
-
async setItem(key, item) {
|
|
2499
|
-
const fullKey = this.buildKey(key);
|
|
2500
|
-
await this.simulateSyncDelay();
|
|
2501
|
-
localStorage.setItem(fullKey, item);
|
|
2502
|
-
}
|
|
2503
|
-
async setMultipleItems(entries) {
|
|
2504
|
-
for (const entry of entries) {
|
|
2505
|
-
const fullKey = this.buildKey(entry.key);
|
|
2506
|
-
localStorage.setItem(fullKey, entry.value);
|
|
2507
|
-
}
|
|
2508
|
-
await this.simulateSyncDelay();
|
|
2509
|
-
}
|
|
2510
|
-
async removeMultipleItems(keys) {
|
|
2511
|
-
for (const key of keys) {
|
|
2512
|
-
const fullKey = this.buildKey(key);
|
|
2513
|
-
localStorage.removeItem(fullKey);
|
|
2514
|
-
}
|
|
2515
|
-
await this.simulateSyncDelay();
|
|
2349
|
+
await this.simulateSyncDelay();
|
|
2516
2350
|
}
|
|
2517
2351
|
buildKey(key) {
|
|
2518
2352
|
const prefix = this.prefix;
|
|
@@ -2652,20 +2486,24 @@ function initializeStorage(venusApiInstance, host) {
|
|
|
2652
2486
|
venusApiInstance.globalStorage = host.globalStorage;
|
|
2653
2487
|
}
|
|
2654
2488
|
|
|
2489
|
+
// src/simulation/utils.ts
|
|
2490
|
+
function sumContributions(contributions) {
|
|
2491
|
+
const totals = {};
|
|
2492
|
+
for (const profileId in contributions) {
|
|
2493
|
+
for (const entityId in contributions[profileId]) {
|
|
2494
|
+
const amount = contributions[profileId][entityId] || 0;
|
|
2495
|
+
totals[entityId] = (totals[entityId] || 0) + amount;
|
|
2496
|
+
}
|
|
2497
|
+
}
|
|
2498
|
+
return totals;
|
|
2499
|
+
}
|
|
2500
|
+
|
|
2655
2501
|
// src/simulation/RpcSimulationApi.ts
|
|
2656
2502
|
var RpcSimulationApi = class {
|
|
2657
2503
|
constructor(rpcClient) {
|
|
2658
2504
|
__publicField(this, "rpcClient");
|
|
2659
2505
|
__publicField(this, "_simulationConfig", null);
|
|
2660
|
-
__publicField(this, "subscriptionCallbacks", /* @__PURE__ */ new Map());
|
|
2661
2506
|
this.rpcClient = rpcClient;
|
|
2662
|
-
this.rpcClient.onNotification(
|
|
2663
|
-
"H5_SIMULATION_UPDATE" /* H5_SIMULATION_UPDATE */,
|
|
2664
|
-
this.handleSimulationUpdate.bind(this)
|
|
2665
|
-
);
|
|
2666
|
-
}
|
|
2667
|
-
isEnabled() {
|
|
2668
|
-
return true;
|
|
2669
2507
|
}
|
|
2670
2508
|
async validateSlotAssignmentAsync(containerId, slotId, itemId) {
|
|
2671
2509
|
return this.rpcClient.call(
|
|
@@ -2677,47 +2515,14 @@ var RpcSimulationApi = class {
|
|
|
2677
2515
|
}
|
|
2678
2516
|
);
|
|
2679
2517
|
}
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
const subscriptionId = generateId();
|
|
2683
|
-
this.subscriptionCallbacks.set(subscriptionId, options.onUpdate);
|
|
2684
|
-
try {
|
|
2685
|
-
await this.rpcClient.call("H5_SIMULATION_SUBSCRIBE" /* H5_SIMULATION_SUBSCRIBE */, {
|
|
2686
|
-
subscriptionId,
|
|
2687
|
-
entities: options.entities,
|
|
2688
|
-
tags: options.tags,
|
|
2689
|
-
activeRuns: options.activeRuns,
|
|
2690
|
-
roomId: options.roomId
|
|
2691
|
-
});
|
|
2692
|
-
} catch (error) {
|
|
2693
|
-
this.subscriptionCallbacks.delete(subscriptionId);
|
|
2694
|
-
throw error;
|
|
2695
|
-
}
|
|
2696
|
-
let unsubscribed = false;
|
|
2697
|
-
return () => {
|
|
2698
|
-
if (unsubscribed) {
|
|
2699
|
-
return;
|
|
2700
|
-
}
|
|
2701
|
-
unsubscribed = true;
|
|
2702
|
-
this.subscriptionCallbacks.delete(subscriptionId);
|
|
2703
|
-
void this.rpcClient.call("H5_SIMULATION_UNSUBSCRIBE" /* H5_SIMULATION_UNSUBSCRIBE */, {
|
|
2704
|
-
subscriptionId
|
|
2705
|
-
}).catch((error) => {
|
|
2706
|
-
console.error(
|
|
2707
|
-
"[Venus SDK] Failed to unsubscribe simulation listener",
|
|
2708
|
-
error
|
|
2709
|
-
);
|
|
2710
|
-
});
|
|
2711
|
-
};
|
|
2518
|
+
sumContributions(contributions) {
|
|
2519
|
+
return sumContributions(contributions);
|
|
2712
2520
|
}
|
|
2713
2521
|
executeBatchOperationsAsync(operations, validateOnly) {
|
|
2714
|
-
return this.rpcClient.call(
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
validateOnly
|
|
2719
|
-
}
|
|
2720
|
-
);
|
|
2522
|
+
return this.rpcClient.call("H5_SIMULATION_BATCH_OPERATIONS" /* H5_SIMULATION_BATCH_OPERATIONS */, {
|
|
2523
|
+
operations,
|
|
2524
|
+
validateOnly
|
|
2525
|
+
});
|
|
2721
2526
|
}
|
|
2722
2527
|
async getAvailableItemsAsync(containerId, slotId) {
|
|
2723
2528
|
const response = await this.rpcClient.call(
|
|
@@ -2740,23 +2545,17 @@ var RpcSimulationApi = class {
|
|
|
2740
2545
|
);
|
|
2741
2546
|
}
|
|
2742
2547
|
assignItemToSlotAsync(containerId, slotId, itemId) {
|
|
2743
|
-
return this.rpcClient.call(
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
itemId
|
|
2749
|
-
}
|
|
2750
|
-
);
|
|
2548
|
+
return this.rpcClient.call("H5_SIMULATION_ASSIGN_ITEM" /* H5_SIMULATION_ASSIGN_ITEM */, {
|
|
2549
|
+
containerId,
|
|
2550
|
+
slotId,
|
|
2551
|
+
itemId
|
|
2552
|
+
});
|
|
2751
2553
|
}
|
|
2752
2554
|
removeItemFromSlotAsync(containerId, slotId) {
|
|
2753
|
-
return this.rpcClient.call(
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
slotId
|
|
2758
|
-
}
|
|
2759
|
-
);
|
|
2555
|
+
return this.rpcClient.call("H5_SIMULATION_REMOVE_ITEM" /* H5_SIMULATION_REMOVE_ITEM */, {
|
|
2556
|
+
containerId,
|
|
2557
|
+
slotId
|
|
2558
|
+
});
|
|
2760
2559
|
}
|
|
2761
2560
|
async getSlotContainersAsync() {
|
|
2762
2561
|
const response = await this.rpcClient.call(
|
|
@@ -2781,6 +2580,7 @@ var RpcSimulationApi = class {
|
|
|
2781
2580
|
roomId
|
|
2782
2581
|
}
|
|
2783
2582
|
);
|
|
2583
|
+
console.log("[Venus SDK] getStateAsync", response);
|
|
2784
2584
|
if (response.configuration) {
|
|
2785
2585
|
this._simulationConfig = response.configuration;
|
|
2786
2586
|
}
|
|
@@ -2792,10 +2592,9 @@ var RpcSimulationApi = class {
|
|
|
2792
2592
|
}
|
|
2793
2593
|
const config = await this.rpcClient.call(
|
|
2794
2594
|
"H5_SIMULATION_GET_CONFIG" /* H5_SIMULATION_GET_CONFIG */,
|
|
2795
|
-
{
|
|
2796
|
-
roomId
|
|
2797
|
-
}
|
|
2595
|
+
{}
|
|
2798
2596
|
);
|
|
2597
|
+
console.log("[Venus SDK] getConfigAsync", config);
|
|
2799
2598
|
if (config) {
|
|
2800
2599
|
this._simulationConfig = config;
|
|
2801
2600
|
return config;
|
|
@@ -2803,17 +2602,14 @@ var RpcSimulationApi = class {
|
|
|
2803
2602
|
throw new Error("No simulation configuration available");
|
|
2804
2603
|
}
|
|
2805
2604
|
executeRecipeAsync(recipeId, inputs, options) {
|
|
2806
|
-
return this.rpcClient.call(
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
entity: options?.entity
|
|
2815
|
-
}
|
|
2816
|
-
);
|
|
2605
|
+
return this.rpcClient.call("H5_SIMULATION_EXECUTE_RECIPE" /* H5_SIMULATION_EXECUTE_RECIPE */, {
|
|
2606
|
+
recipeId,
|
|
2607
|
+
inputs,
|
|
2608
|
+
roomId: options?.roomId,
|
|
2609
|
+
batchAmount: options?.batchAmount,
|
|
2610
|
+
allowPartialBatch: options?.allowPartialBatch,
|
|
2611
|
+
entity: options?.entity
|
|
2612
|
+
});
|
|
2817
2613
|
}
|
|
2818
2614
|
collectRecipeAsync(runId) {
|
|
2819
2615
|
return this.rpcClient.call("H5_SIMULATION_COLLECT_RECIPE" /* H5_SIMULATION_COLLECT_RECIPE */, {
|
|
@@ -2821,12 +2617,9 @@ var RpcSimulationApi = class {
|
|
|
2821
2617
|
});
|
|
2822
2618
|
}
|
|
2823
2619
|
getActiveRunsAsync(options) {
|
|
2824
|
-
return this.rpcClient.call(
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
roomId: options?.roomId
|
|
2828
|
-
}
|
|
2829
|
-
);
|
|
2620
|
+
return this.rpcClient.call("H5_SIMULATION_GET_ACTIVE_RUNS" /* H5_SIMULATION_GET_ACTIVE_RUNS */, {
|
|
2621
|
+
roomId: options?.roomId
|
|
2622
|
+
});
|
|
2830
2623
|
}
|
|
2831
2624
|
executeScopedRecipeAsync(recipeId, entity, inputs, options) {
|
|
2832
2625
|
return this.rpcClient.call(
|
|
@@ -2896,52 +2689,583 @@ var RpcSimulationApi = class {
|
|
|
2896
2689
|
);
|
|
2897
2690
|
return response.value;
|
|
2898
2691
|
}
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2692
|
+
};
|
|
2693
|
+
|
|
2694
|
+
// src/simulation/MockSimulationApi.ts
|
|
2695
|
+
function generateAppIdentifier2() {
|
|
2696
|
+
if (typeof window === "undefined") return "unknown-app";
|
|
2697
|
+
const url = window.location.href;
|
|
2698
|
+
const match = url.match(/\/H5\/([^\/]+)/);
|
|
2699
|
+
return match ? match[1] : "unknown-app";
|
|
2700
|
+
}
|
|
2701
|
+
var MockSimulationApi = class {
|
|
2702
|
+
constructor(simulationConfig = null) {
|
|
2703
|
+
__publicField(this, "mockSimulationConfigs", /* @__PURE__ */ new Map());
|
|
2704
|
+
// appIdentifier -> config
|
|
2705
|
+
__publicField(this, "mockSimulationStates", /* @__PURE__ */ new Map());
|
|
2706
|
+
// appIdentifier -> config
|
|
2707
|
+
__publicField(this, "mockActiveTimers", /* @__PURE__ */ new Map());
|
|
2708
|
+
// appIdentifier -> timers[]
|
|
2709
|
+
__publicField(this, "appId");
|
|
2710
|
+
__publicField(this, "providedSimulationConfig");
|
|
2711
|
+
this.appId = generateAppIdentifier2();
|
|
2712
|
+
this.providedSimulationConfig = simulationConfig;
|
|
2713
|
+
}
|
|
2714
|
+
sumContributions(contributions) {
|
|
2715
|
+
return sumContributions(contributions);
|
|
2716
|
+
}
|
|
2717
|
+
async validateSlotAssignmentAsync(containerId, slotId, itemId) {
|
|
2718
|
+
this.log("validateSlotAssignmentAsync called:", {
|
|
2719
|
+
containerId,
|
|
2720
|
+
slotId,
|
|
2721
|
+
itemId
|
|
2722
|
+
});
|
|
2723
|
+
return { valid: true, message: "Mock validation successful" };
|
|
2724
|
+
}
|
|
2725
|
+
async executeBatchOperationsAsync(operations, validateOnly) {
|
|
2726
|
+
this.log("executeBatchOperationsAsync called:", {
|
|
2727
|
+
operations,
|
|
2728
|
+
validateOnly
|
|
2729
|
+
});
|
|
2730
|
+
return {
|
|
2731
|
+
success: true,
|
|
2732
|
+
results: operations.map(() => ({ success: true }))
|
|
2733
|
+
};
|
|
2734
|
+
}
|
|
2735
|
+
async getAvailableItemsAsync(containerId, slotId) {
|
|
2736
|
+
console.log("[Venus Simulation Mock] getAvailableItemsAsync called:", {
|
|
2737
|
+
containerId,
|
|
2738
|
+
slotId
|
|
2739
|
+
});
|
|
2740
|
+
const appIdentifier = generateAppIdentifier2();
|
|
2741
|
+
const mockSimulationConfigs = this.mockSimulationConfigs;
|
|
2742
|
+
const config = mockSimulationConfigs.get(appIdentifier) || {
|
|
2743
|
+
entities: {}
|
|
2744
|
+
};
|
|
2745
|
+
const availableItems = Object.entries(config.entities).slice(0, 3).map(([entityId, entity]) => ({
|
|
2746
|
+
entityId,
|
|
2747
|
+
quantity: 1,
|
|
2748
|
+
metadata: entity.metadata,
|
|
2749
|
+
powerPreview: 100
|
|
2750
|
+
// Mock power value
|
|
2751
|
+
}));
|
|
2752
|
+
return availableItems;
|
|
2753
|
+
}
|
|
2754
|
+
async calculatePowerPreviewAsync(containerId, slotId, candidateItemId) {
|
|
2755
|
+
this.log("calculatePowerPreviewAsync called:", {
|
|
2756
|
+
containerId,
|
|
2757
|
+
slotId,
|
|
2758
|
+
candidateItemId
|
|
2759
|
+
});
|
|
2760
|
+
return {
|
|
2761
|
+
currentPower: 1e3,
|
|
2762
|
+
previewPower: 1200,
|
|
2763
|
+
powerDelta: 200,
|
|
2764
|
+
breakdown: { base: 800, weapon: 200, armor: 200 }
|
|
2765
|
+
};
|
|
2766
|
+
}
|
|
2767
|
+
async getSlotContainersAsync() {
|
|
2768
|
+
this.log("getSlotContainersAsync called");
|
|
2769
|
+
const appIdentifier = this.appId;
|
|
2770
|
+
const mockSimulationConfigs = this.mockSimulationConfigs;
|
|
2771
|
+
const config = mockSimulationConfigs.get(appIdentifier) || {
|
|
2772
|
+
entities: {}
|
|
2773
|
+
};
|
|
2774
|
+
const containers = Object.entries(config.entities).filter(([_, entity]) => entity.metadata?.slots).map(([entityId, entity]) => ({
|
|
2775
|
+
entityId,
|
|
2776
|
+
slots: entity.metadata?.slots,
|
|
2777
|
+
isOwned: true
|
|
2778
|
+
// Mock: assume all containers are owned
|
|
2779
|
+
}));
|
|
2780
|
+
return containers;
|
|
2781
|
+
}
|
|
2782
|
+
async getSlotAssignmentsAsync(containerId) {
|
|
2783
|
+
this.log("getSlotAssignmentsAsync called for:", containerId);
|
|
2784
|
+
return [];
|
|
2785
|
+
}
|
|
2786
|
+
async resolveFieldValueAsync(entityId, fieldPath, entity) {
|
|
2787
|
+
this.log("resolveFieldValueAsync called:", {
|
|
2788
|
+
entityId,
|
|
2789
|
+
fieldPath,
|
|
2790
|
+
entity
|
|
2791
|
+
});
|
|
2792
|
+
const mockValues = {
|
|
2793
|
+
basePower: 850,
|
|
2794
|
+
weaponPower: 300,
|
|
2795
|
+
armorPower: 150,
|
|
2796
|
+
total_power: 1300,
|
|
2797
|
+
total_defense_power: 5e3
|
|
2798
|
+
};
|
|
2799
|
+
return mockValues[fieldPath] || 100;
|
|
2800
|
+
}
|
|
2801
|
+
async getEntityMetadataAsync(entityId) {
|
|
2802
|
+
this.log("getEntityMetadataAsync called for:", entityId);
|
|
2803
|
+
const mockSimulationConfigs = this.mockSimulationConfigs;
|
|
2804
|
+
const appIdentifier = this.appId;
|
|
2805
|
+
const config = mockSimulationConfigs.get(
|
|
2806
|
+
appIdentifier
|
|
2807
|
+
) || {
|
|
2808
|
+
entities: {}};
|
|
2809
|
+
const entity = config.entities[entityId];
|
|
2810
|
+
return entity?.metadata || {};
|
|
2811
|
+
}
|
|
2812
|
+
async collectRecipeAsync(runId) {
|
|
2813
|
+
this.log("collectRecipeAsync called:", { runId });
|
|
2814
|
+
const mockRewards = {
|
|
2815
|
+
cash: Math.floor(Math.random() * 1e3) + 500,
|
|
2816
|
+
experience: Math.floor(Math.random() * 50) + 25
|
|
2817
|
+
};
|
|
2818
|
+
return {
|
|
2819
|
+
success: true,
|
|
2820
|
+
runId,
|
|
2821
|
+
rewards: mockRewards,
|
|
2822
|
+
message: "Rewards collected successfully"
|
|
2823
|
+
};
|
|
2824
|
+
}
|
|
2825
|
+
executeRecipeAsync(recipeId, inputs, options) {
|
|
2826
|
+
this.log("executeRecipeAsync called:", {
|
|
2827
|
+
recipeId,
|
|
2828
|
+
inputs,
|
|
2829
|
+
options
|
|
2830
|
+
});
|
|
2831
|
+
const appIdentifier = this.appId;
|
|
2832
|
+
return this.executeRecipe(appIdentifier, recipeId, inputs);
|
|
2833
|
+
}
|
|
2834
|
+
async executeScopedRecipeAsync(recipeId, entity, inputs, options) {
|
|
2835
|
+
this.log("executeScopedRecipeAsync called:", {
|
|
2836
|
+
recipeId,
|
|
2837
|
+
entity,
|
|
2838
|
+
inputs,
|
|
2839
|
+
roomId: options?.roomId,
|
|
2840
|
+
options
|
|
2841
|
+
});
|
|
2842
|
+
return {
|
|
2843
|
+
success: true,
|
|
2844
|
+
message: "Mock scoped recipe execution successful"
|
|
2845
|
+
};
|
|
2846
|
+
}
|
|
2847
|
+
async getActiveRunsAsync(options) {
|
|
2848
|
+
this.log("getActiveRunsAsync called:", options);
|
|
2849
|
+
const appIdentifier = this.appId;
|
|
2850
|
+
let state = this.mockSimulationStates.get(appIdentifier);
|
|
2851
|
+
if (!state) {
|
|
2852
|
+
state = await this.initializeSimulationState(appIdentifier);
|
|
2903
2853
|
}
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2854
|
+
return state.activeRuns || [];
|
|
2855
|
+
}
|
|
2856
|
+
async getAvailableRecipesAsync(options) {
|
|
2857
|
+
this.log("getAvailableRecipesAsync called:", options);
|
|
2858
|
+
const baseRecipes = [
|
|
2859
|
+
{ id: "collect_resources", scope: "player", clientViewable: true },
|
|
2860
|
+
{ id: "upgrade_equipment", scope: "player", clientViewable: true }
|
|
2861
|
+
];
|
|
2862
|
+
if (options?.roomId) {
|
|
2863
|
+
baseRecipes.push(
|
|
2864
|
+
{ id: "room_upgrade", scope: "room", clientViewable: true },
|
|
2865
|
+
{ id: "cooperative_project", scope: "room", clientViewable: true }
|
|
2909
2866
|
);
|
|
2910
|
-
return;
|
|
2911
2867
|
}
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2868
|
+
if (options?.includeActorRecipes && options?.roomId) {
|
|
2869
|
+
baseRecipes.push(
|
|
2870
|
+
{ id: "trade_with_npc", scope: "actor", clientViewable: true },
|
|
2871
|
+
{ id: "attack_monster", scope: "actor", clientViewable: true }
|
|
2872
|
+
);
|
|
2873
|
+
}
|
|
2874
|
+
return { success: true, recipes: baseRecipes };
|
|
2875
|
+
}
|
|
2876
|
+
async getBatchRecipeRequirementsAsync(recipes) {
|
|
2877
|
+
this.log("getBatchRecipeRequirementsAsync called:", {
|
|
2878
|
+
count: recipes?.length
|
|
2879
|
+
});
|
|
2880
|
+
const results = (recipes || []).map((q) => ({
|
|
2881
|
+
recipeId: q.recipeId,
|
|
2882
|
+
entity: q.entity || null,
|
|
2883
|
+
amount: q.batchAmount || 1,
|
|
2884
|
+
inputs: { cash: "BE:0" },
|
|
2885
|
+
canAfford: true,
|
|
2886
|
+
disabled: false
|
|
2887
|
+
}));
|
|
2888
|
+
return { success: true, results };
|
|
2889
|
+
}
|
|
2890
|
+
async getRecipeRequirementsAsync(recipe) {
|
|
2891
|
+
this.log("getRecipeRequirementsAsync called:", recipe);
|
|
2892
|
+
return {
|
|
2893
|
+
recipeId: recipe.recipeId,
|
|
2894
|
+
entity: recipe.entity || null,
|
|
2895
|
+
amount: recipe.batchAmount,
|
|
2896
|
+
inputs: { cash: "BE:0" },
|
|
2897
|
+
canAfford: true,
|
|
2898
|
+
disabled: false
|
|
2899
|
+
};
|
|
2900
|
+
}
|
|
2901
|
+
async triggerRecipeChainAsync(recipeId, options) {
|
|
2902
|
+
this.log("triggerRecipeChainAsync called:", { recipeId, ...options });
|
|
2903
|
+
return {
|
|
2904
|
+
success: true,
|
|
2905
|
+
message: "Mock recipe chain triggered successfully"
|
|
2906
|
+
};
|
|
2907
|
+
}
|
|
2908
|
+
log(message, ...args) {
|
|
2909
|
+
console.log(`[Venus Sim Mock] ${message}`, args);
|
|
2910
|
+
}
|
|
2911
|
+
async executeRecipe(appIdentifier, recipeId, inputs) {
|
|
2912
|
+
this.log(`Executing recipe ${recipeId} for ${appIdentifier}`, inputs);
|
|
2913
|
+
const mockSimulationConfigs = this.mockSimulationConfigs;
|
|
2914
|
+
const mockSimulationStates = this.mockSimulationStates;
|
|
2915
|
+
let config = mockSimulationConfigs.get(appIdentifier);
|
|
2916
|
+
let state = mockSimulationStates.get(appIdentifier);
|
|
2917
|
+
if (!config || !state) {
|
|
2918
|
+
state = await this.initializeSimulationState(appIdentifier);
|
|
2919
|
+
config = mockSimulationConfigs.get(appIdentifier);
|
|
2920
|
+
if (!config) {
|
|
2921
|
+
throw new Error("Failed to initialize simulation config");
|
|
2922
|
+
}
|
|
2923
|
+
}
|
|
2924
|
+
const recipe = config.recipes?.[recipeId];
|
|
2925
|
+
if (!recipe) {
|
|
2926
|
+
throw new Error(`Recipe ${recipeId} not found`);
|
|
2927
|
+
}
|
|
2928
|
+
if (state.disabledRecipes?.includes(recipeId)) {
|
|
2929
|
+
throw new Error(`Recipe ${recipeId} is disabled`);
|
|
2930
|
+
}
|
|
2931
|
+
if (recipe.inputs) {
|
|
2932
|
+
for (const [entityId, required] of Object.entries(recipe.inputs)) {
|
|
2933
|
+
const available = state.inventory[entityId] || 0;
|
|
2934
|
+
if (available < required) {
|
|
2935
|
+
throw new Error(
|
|
2936
|
+
`Insufficient ${entityId}: required ${required}, available ${available}`
|
|
2937
|
+
);
|
|
2938
|
+
}
|
|
2939
|
+
}
|
|
2940
|
+
}
|
|
2941
|
+
if (recipe.inputs) {
|
|
2942
|
+
for (const [entityId, input] of Object.entries(recipe.inputs)) {
|
|
2943
|
+
const inventoryValue = state.inventory[entityId] || 0;
|
|
2944
|
+
if (typeof input === "number" && typeof inventoryValue === "number") {
|
|
2945
|
+
state.inventory[entityId] = inventoryValue - input;
|
|
2946
|
+
}
|
|
2947
|
+
}
|
|
2948
|
+
}
|
|
2949
|
+
if (recipe.beginEffects) {
|
|
2950
|
+
this.applyEffects(state, recipe.beginEffects);
|
|
2951
|
+
}
|
|
2952
|
+
const runId = this.generateRunId();
|
|
2953
|
+
const now = Date.now();
|
|
2954
|
+
const expiresAt = now + (recipe.duration || 0);
|
|
2955
|
+
const run = {
|
|
2956
|
+
id: runId,
|
|
2957
|
+
recipeId,
|
|
2958
|
+
status: "running",
|
|
2959
|
+
startTime: now,
|
|
2960
|
+
expiresAt,
|
|
2961
|
+
inputs: recipe.inputs || {}
|
|
2962
|
+
};
|
|
2963
|
+
state.activeRuns.push(run);
|
|
2964
|
+
if (recipe.duration === 0) {
|
|
2965
|
+
this.completeRun(appIdentifier, runId);
|
|
2966
|
+
return { status: "completed", runId };
|
|
2967
|
+
} else {
|
|
2968
|
+
const mockActiveTimers = this.mockActiveTimers;
|
|
2969
|
+
const timer = setTimeout(() => {
|
|
2970
|
+
this.completeRun(appIdentifier, runId);
|
|
2971
|
+
}, recipe.duration);
|
|
2972
|
+
const timers = mockActiveTimers.get(appIdentifier) || [];
|
|
2973
|
+
timers.push(timer);
|
|
2974
|
+
mockActiveTimers.set(appIdentifier, timers);
|
|
2975
|
+
return {
|
|
2976
|
+
status: "running",
|
|
2977
|
+
runId,
|
|
2978
|
+
expiresAt: new Date(expiresAt).toISOString()
|
|
2979
|
+
};
|
|
2916
2980
|
}
|
|
2917
2981
|
}
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2982
|
+
async initializeSimulationState(appIdentifier) {
|
|
2983
|
+
this.log(`Initializing simulation state for ${appIdentifier}`);
|
|
2984
|
+
const providedSimulationConfig = this.providedSimulationConfig;
|
|
2985
|
+
const mockSimulationConfigs = this.mockSimulationConfigs;
|
|
2986
|
+
const mockSimulationStates = this.mockSimulationStates;
|
|
2987
|
+
const mockActiveTimers = this.mockActiveTimers;
|
|
2988
|
+
const config = providedSimulationConfig || {
|
|
2989
|
+
version: "1.0",
|
|
2990
|
+
entities: {},
|
|
2991
|
+
recipes: {}
|
|
2992
|
+
};
|
|
2993
|
+
mockSimulationConfigs.set(appIdentifier, config);
|
|
2994
|
+
const initialInventory = {};
|
|
2995
|
+
if (providedSimulationConfig && config.entities) {
|
|
2996
|
+
Object.keys(config.entities).forEach((entityId) => {
|
|
2997
|
+
initialInventory[entityId] = 0;
|
|
2998
|
+
});
|
|
2921
2999
|
}
|
|
2922
|
-
const
|
|
2923
|
-
|
|
2924
|
-
|
|
3000
|
+
const state = {
|
|
3001
|
+
inventory: initialInventory,
|
|
3002
|
+
activeRuns: [],
|
|
3003
|
+
disabledRecipes: new Array()
|
|
3004
|
+
};
|
|
3005
|
+
if (config.recipes) {
|
|
3006
|
+
Object.entries(config.recipes).forEach(([recipeId, recipe]) => {
|
|
3007
|
+
if (recipe.metadata?.startsDisabled) {
|
|
3008
|
+
state.disabledRecipes.push(recipeId);
|
|
3009
|
+
}
|
|
3010
|
+
});
|
|
2925
3011
|
}
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
3012
|
+
mockSimulationStates.set(appIdentifier, state);
|
|
3013
|
+
mockActiveTimers.set(appIdentifier, []);
|
|
3014
|
+
console.log(
|
|
3015
|
+
`[Venus Simulation Mock] Initialized state for ${appIdentifier}:`,
|
|
3016
|
+
state
|
|
3017
|
+
);
|
|
3018
|
+
if (config.recipes) {
|
|
3019
|
+
Object.entries(config.recipes).forEach(([recipeId, recipe]) => {
|
|
3020
|
+
const isAutoRestart = recipe.autoRestart || recipe.metadata?.autoRestart;
|
|
3021
|
+
if (isAutoRestart && recipe.outputs) {
|
|
3022
|
+
this.log(`Found auto-restart recipe: ${recipeId}`, {
|
|
3023
|
+
topLevelAutoRestart: recipe.autoRestart,
|
|
3024
|
+
metadataAutoRestart: recipe.metadata?.autoRestart,
|
|
3025
|
+
hasOutputs: !!recipe.outputs,
|
|
3026
|
+
duration: recipe.duration
|
|
3027
|
+
});
|
|
3028
|
+
const condition = recipe.maxRestartCondition || recipe.metadata?.maxRestartCondition;
|
|
3029
|
+
if (condition && condition.entity) {
|
|
3030
|
+
const currentAmount = initialInventory[condition.entity] || 0;
|
|
3031
|
+
if (currentAmount < condition.maxValue) {
|
|
3032
|
+
console.log(
|
|
3033
|
+
`[Venus Simulation Mock] Auto-starting ${recipeId} at initialization`,
|
|
3034
|
+
{
|
|
3035
|
+
currentAmount,
|
|
3036
|
+
maxValue: condition.maxValue,
|
|
3037
|
+
entity: condition.entity
|
|
3038
|
+
}
|
|
3039
|
+
);
|
|
3040
|
+
setTimeout(() => {
|
|
3041
|
+
this.executeRecipe(appIdentifier, recipeId, {});
|
|
3042
|
+
}, 1e3);
|
|
3043
|
+
}
|
|
3044
|
+
} else {
|
|
3045
|
+
console.log(
|
|
3046
|
+
`[Venus Simulation Mock] Auto-starting ${recipeId} at initialization (no condition)`
|
|
3047
|
+
);
|
|
3048
|
+
setTimeout(() => {
|
|
3049
|
+
this.executeRecipe(appIdentifier, recipeId, {});
|
|
3050
|
+
}, 1e3);
|
|
3051
|
+
}
|
|
3052
|
+
}
|
|
3053
|
+
});
|
|
3054
|
+
}
|
|
3055
|
+
return state;
|
|
3056
|
+
}
|
|
3057
|
+
generateRunId() {
|
|
3058
|
+
return "run_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9);
|
|
3059
|
+
}
|
|
3060
|
+
completeRun(appIdentifier, runId) {
|
|
3061
|
+
this.log(`Completing run ${runId} for ${appIdentifier}`);
|
|
3062
|
+
const mockSimulationConfigs = this.mockSimulationConfigs;
|
|
3063
|
+
const mockSimulationStates = this.mockSimulationStates;
|
|
3064
|
+
const config = mockSimulationConfigs.get(appIdentifier);
|
|
3065
|
+
const state = mockSimulationStates.get(appIdentifier);
|
|
3066
|
+
if (!config || !state) return;
|
|
3067
|
+
const runIndex = state.activeRuns.findIndex((r) => r.id === runId);
|
|
3068
|
+
if (runIndex === -1) return;
|
|
3069
|
+
const run = state.activeRuns[runIndex];
|
|
3070
|
+
const recipe = config.recipes?.[run.recipeId];
|
|
3071
|
+
if (!recipe) return;
|
|
3072
|
+
const outputs = {};
|
|
3073
|
+
const rng = this.createSeededRandom(runId);
|
|
3074
|
+
if (recipe.outputs) {
|
|
3075
|
+
for (const [entityId, value] of Object.entries(recipe.outputs)) {
|
|
3076
|
+
if (typeof value === "number") {
|
|
3077
|
+
outputs[entityId] = value;
|
|
3078
|
+
} else if (typeof value === "object" && value != null && "min" in value && "max" in value && typeof value.min == "number" && typeof value.max === "number") {
|
|
3079
|
+
outputs[entityId] = Math.floor(rng() * (value.max - value.min + 1)) + value.min;
|
|
3080
|
+
}
|
|
3081
|
+
}
|
|
3082
|
+
}
|
|
3083
|
+
for (const [entityId, amount] of Object.entries(outputs)) {
|
|
3084
|
+
state.inventory[entityId] = (state.inventory[entityId] || 0) + amount;
|
|
3085
|
+
}
|
|
3086
|
+
if (recipe.endEffects) {
|
|
3087
|
+
this.applyEffects(state, recipe.endEffects);
|
|
3088
|
+
}
|
|
3089
|
+
run.status = "completed";
|
|
3090
|
+
run.outputs = outputs;
|
|
3091
|
+
state.activeRuns.splice(runIndex, 1);
|
|
3092
|
+
const isAutoRestart = recipe.autoRestart || recipe.metadata?.autoRestart;
|
|
3093
|
+
if (isAutoRestart) {
|
|
3094
|
+
console.log(
|
|
3095
|
+
`[Venus Simulation Mock] Checking auto-restart for ${run.recipeId}`,
|
|
3096
|
+
{
|
|
3097
|
+
topLevelAutoRestart: recipe.autoRestart,
|
|
3098
|
+
metadataAutoRestart: recipe.metadata?.autoRestart,
|
|
3099
|
+
hasCondition: !!(recipe.maxRestartCondition || recipe.metadata?.maxRestartCondition)
|
|
3100
|
+
}
|
|
2930
3101
|
);
|
|
3102
|
+
const condition = recipe.maxRestartCondition || recipe.metadata?.maxRestartCondition;
|
|
3103
|
+
if (condition) {
|
|
3104
|
+
const currentAmount = state.inventory[condition.entity] || 0;
|
|
3105
|
+
if (currentAmount < condition.maxValue) {
|
|
3106
|
+
console.log(
|
|
3107
|
+
`[Venus Simulation Mock] Auto-restarting ${run.recipeId}`,
|
|
3108
|
+
{
|
|
3109
|
+
currentAmount,
|
|
3110
|
+
maxValue: condition.maxValue,
|
|
3111
|
+
entity: condition.entity
|
|
3112
|
+
}
|
|
3113
|
+
);
|
|
3114
|
+
setTimeout(() => {
|
|
3115
|
+
this.executeRecipe(appIdentifier, run.recipeId, recipe.inputs || {});
|
|
3116
|
+
}, 1e3);
|
|
3117
|
+
}
|
|
3118
|
+
} else {
|
|
3119
|
+
console.log(
|
|
3120
|
+
`[Venus Simulation Mock] Auto-restarting ${run.recipeId} (no condition)`
|
|
3121
|
+
);
|
|
3122
|
+
setTimeout(() => {
|
|
3123
|
+
this.executeRecipe(appIdentifier, run.recipeId, recipe.inputs || {});
|
|
3124
|
+
}, 1e3);
|
|
3125
|
+
}
|
|
3126
|
+
}
|
|
3127
|
+
console.log(
|
|
3128
|
+
`[Venus Simulation Mock] Completed run ${runId}, outputs:`,
|
|
3129
|
+
outputs
|
|
3130
|
+
);
|
|
3131
|
+
}
|
|
3132
|
+
createSeededRandom(seed) {
|
|
3133
|
+
let hash = 0;
|
|
3134
|
+
for (let i = 0; i < seed.length; i++) {
|
|
3135
|
+
const char = seed.charCodeAt(i);
|
|
3136
|
+
hash = (hash << 5) - hash + char;
|
|
3137
|
+
hash = hash & hash;
|
|
3138
|
+
}
|
|
3139
|
+
return () => {
|
|
3140
|
+
hash = (hash * 9301 + 49297) % 233280;
|
|
3141
|
+
return hash / 233280;
|
|
3142
|
+
};
|
|
3143
|
+
}
|
|
3144
|
+
applyEffects(state, effects) {
|
|
3145
|
+
if (!effects || !Array.isArray(effects)) return;
|
|
3146
|
+
for (const effect of effects) {
|
|
3147
|
+
switch (effect.type) {
|
|
3148
|
+
case "set":
|
|
3149
|
+
state.inventory[effect.target] = effect.value;
|
|
3150
|
+
console.log(
|
|
3151
|
+
`[Venus Simulation Mock] Effect: Set ${effect.target} = ${effect.value}`
|
|
3152
|
+
);
|
|
3153
|
+
break;
|
|
3154
|
+
case "add":
|
|
3155
|
+
state.inventory[effect.target] = (state.inventory[effect.target] || 0) + effect.value;
|
|
3156
|
+
console.log(
|
|
3157
|
+
`[Venus Simulation Mock] Effect: Add ${effect.value} to ${effect.target} (new value: ${state.inventory[effect.target]})`
|
|
3158
|
+
);
|
|
3159
|
+
break;
|
|
3160
|
+
case "multiply":
|
|
3161
|
+
state.inventory[effect.target] = (state.inventory[effect.target] || 0) * effect.value;
|
|
3162
|
+
console.log(
|
|
3163
|
+
`[Venus Simulation Mock] Effect: Multiply ${effect.target} by ${effect.value} (new value: ${state.inventory[effect.target]})`
|
|
3164
|
+
);
|
|
3165
|
+
break;
|
|
3166
|
+
case "min":
|
|
3167
|
+
state.inventory[effect.target] = Math.max(
|
|
3168
|
+
state.inventory[effect.target] || 0,
|
|
3169
|
+
effect.value
|
|
3170
|
+
);
|
|
3171
|
+
console.log(
|
|
3172
|
+
`[Venus Simulation Mock] Effect: Set ${effect.target} min ${effect.value} (new value: ${state.inventory[effect.target]})`
|
|
3173
|
+
);
|
|
3174
|
+
break;
|
|
3175
|
+
case "max":
|
|
3176
|
+
state.inventory[effect.target] = Math.min(
|
|
3177
|
+
state.inventory[effect.target] || 0,
|
|
3178
|
+
effect.value
|
|
3179
|
+
);
|
|
3180
|
+
console.log(
|
|
3181
|
+
`[Venus Simulation Mock] Effect: Set ${effect.target} max ${effect.value} (new value: ${state.inventory[effect.target]})`
|
|
3182
|
+
);
|
|
3183
|
+
break;
|
|
3184
|
+
case "enable_recipe":
|
|
3185
|
+
if (state.disabledRecipes?.includes(effect.target)) {
|
|
3186
|
+
state.disabledRecipes = state.disabledRecipes.filter(
|
|
3187
|
+
(r) => r !== effect.target
|
|
3188
|
+
);
|
|
3189
|
+
console.log(
|
|
3190
|
+
`[Venus Simulation Mock] Effect: Enabled recipe ${effect.target}`
|
|
3191
|
+
);
|
|
3192
|
+
}
|
|
3193
|
+
break;
|
|
3194
|
+
case "disable_recipe":
|
|
3195
|
+
if (!state.disabledRecipes) state.disabledRecipes = [];
|
|
3196
|
+
if (!state.disabledRecipes.includes(effect.target)) {
|
|
3197
|
+
state.disabledRecipes.push(effect.target);
|
|
3198
|
+
console.log(
|
|
3199
|
+
`[Venus Simulation Mock] Effect: Disabled recipe ${effect.target}`
|
|
3200
|
+
);
|
|
3201
|
+
}
|
|
3202
|
+
break;
|
|
3203
|
+
case "trigger_recipe":
|
|
3204
|
+
console.log(
|
|
3205
|
+
`[Venus Simulation Mock] Effect: Trigger recipe ${effect.target} (not implemented)`
|
|
3206
|
+
);
|
|
3207
|
+
break;
|
|
3208
|
+
default:
|
|
3209
|
+
console.warn(
|
|
3210
|
+
`[Venus Simulation Mock] Unknown effect type: ${effect.type}`
|
|
3211
|
+
);
|
|
3212
|
+
}
|
|
2931
3213
|
}
|
|
2932
3214
|
}
|
|
3215
|
+
async getConfigAsync() {
|
|
3216
|
+
console.log("[Venus Simulation Mock] getConfigAsync called");
|
|
3217
|
+
const appIdentifier = this.appId;
|
|
3218
|
+
const mockSimulationConfigs = this.mockSimulationConfigs;
|
|
3219
|
+
const config = mockSimulationConfigs.get(appIdentifier) || {
|
|
3220
|
+
version: "1.0",
|
|
3221
|
+
entities: {},
|
|
3222
|
+
recipes: {}
|
|
3223
|
+
};
|
|
3224
|
+
return config;
|
|
3225
|
+
}
|
|
3226
|
+
async getStateAsync(roomId) {
|
|
3227
|
+
this.log("getStateAsync called:", roomId);
|
|
3228
|
+
const appIdentifier = this.appId;
|
|
3229
|
+
const mockSimulationStates = this.mockSimulationStates;
|
|
3230
|
+
let state = mockSimulationStates.get(appIdentifier);
|
|
3231
|
+
if (!state) {
|
|
3232
|
+
state = await this.initializeSimulationState(appIdentifier);
|
|
3233
|
+
}
|
|
3234
|
+
const mockSimulationConfigs = this.mockSimulationConfigs;
|
|
3235
|
+
return {
|
|
3236
|
+
...state,
|
|
3237
|
+
roomId,
|
|
3238
|
+
configuration: mockSimulationConfigs.get(appIdentifier)
|
|
3239
|
+
};
|
|
3240
|
+
}
|
|
3241
|
+
async assignItemToSlotAsync(containerId, slotId, itemId) {
|
|
3242
|
+
this.log("assignItemToSlotAsync called:", {
|
|
3243
|
+
containerId,
|
|
3244
|
+
slotId,
|
|
3245
|
+
itemId
|
|
3246
|
+
});
|
|
3247
|
+
return { success: true, message: "Mock assignment successful" };
|
|
3248
|
+
}
|
|
3249
|
+
async removeItemFromSlotAsync(containerId, slotId) {
|
|
3250
|
+
this.log("removeItemFromSlotAsync called:", {
|
|
3251
|
+
containerId,
|
|
3252
|
+
slotId
|
|
3253
|
+
});
|
|
3254
|
+
return { success: true, message: "Mock removal successful" };
|
|
3255
|
+
}
|
|
2933
3256
|
};
|
|
2934
3257
|
|
|
2935
3258
|
// src/simulation/index.ts
|
|
2936
3259
|
function initializeSimulation(venusApi, host) {
|
|
3260
|
+
console.log("[Venus SDK] Initializing new Simulation Api");
|
|
2937
3261
|
venusApi.simulation = {
|
|
2938
3262
|
isEnabled: () => true
|
|
2939
3263
|
};
|
|
2940
3264
|
venusApi.simulation.getConfigAsync = () => {
|
|
2941
3265
|
return host.simulation.getConfigAsync();
|
|
2942
3266
|
};
|
|
2943
|
-
venusApi.simulation.getStateAsync = (
|
|
2944
|
-
return host.simulation.getStateAsync(roomId);
|
|
3267
|
+
venusApi.simulation.getStateAsync = (options) => {
|
|
3268
|
+
return host.simulation.getStateAsync(options?.roomId);
|
|
2945
3269
|
};
|
|
2946
3270
|
venusApi.simulation.executeRecipeAsync = (recipeId, inputs, options) => {
|
|
2947
3271
|
return host.simulation.executeRecipeAsync(recipeId, inputs, options);
|
|
@@ -2952,17 +3276,31 @@ function initializeSimulation(venusApi, host) {
|
|
|
2952
3276
|
venusApi.simulation.collectRecipeAsync = (runId) => {
|
|
2953
3277
|
return host.simulation.collectRecipeAsync(runId);
|
|
2954
3278
|
};
|
|
2955
|
-
venusApi.simulation.executeScopedRecipeAsync = (recipeId, entity, inputs, options) => {
|
|
2956
|
-
return host.simulation.executeScopedRecipeAsync(recipeId, entity, inputs,
|
|
3279
|
+
venusApi.simulation.executeScopedRecipeAsync = (recipeId, entity, inputs, roomId, options) => {
|
|
3280
|
+
return host.simulation.executeScopedRecipeAsync(recipeId, entity, inputs, {
|
|
3281
|
+
roomId,
|
|
3282
|
+
...options
|
|
3283
|
+
});
|
|
2957
3284
|
};
|
|
2958
|
-
venusApi.simulation.triggerRecipeChainAsync = (recipeId,
|
|
2959
|
-
return host.simulation.triggerRecipeChainAsync(recipeId,
|
|
3285
|
+
venusApi.simulation.triggerRecipeChainAsync = (recipeId, context, roomId) => {
|
|
3286
|
+
return host.simulation.triggerRecipeChainAsync(recipeId, {
|
|
3287
|
+
context,
|
|
3288
|
+
roomId
|
|
3289
|
+
});
|
|
2960
3290
|
};
|
|
2961
|
-
venusApi.simulation.getAvailableRecipesAsync = async (
|
|
2962
|
-
|
|
3291
|
+
venusApi.simulation.getAvailableRecipesAsync = async (roomId, includeActorRecipes) => {
|
|
3292
|
+
const result = await host.simulation.getAvailableRecipesAsync({
|
|
3293
|
+
roomId,
|
|
3294
|
+
includeActorRecipes
|
|
3295
|
+
});
|
|
3296
|
+
return result.recipes;
|
|
2963
3297
|
};
|
|
2964
|
-
venusApi.simulation.getRecipeRequirementsAsync = (
|
|
2965
|
-
return host.simulation.getRecipeRequirementsAsync(
|
|
3298
|
+
venusApi.simulation.getRecipeRequirementsAsync = (recipeId, entity, amount) => {
|
|
3299
|
+
return host.simulation.getRecipeRequirementsAsync({
|
|
3300
|
+
recipeId,
|
|
3301
|
+
entity,
|
|
3302
|
+
batchAmount: amount
|
|
3303
|
+
});
|
|
2966
3304
|
};
|
|
2967
3305
|
venusApi.simulation.getBatchRecipeRequirementsAsync = (recipes) => {
|
|
2968
3306
|
return host.simulation.getBatchRecipeRequirementsAsync(recipes);
|
|
@@ -3005,6 +3343,9 @@ function initializeSimulation(venusApi, host) {
|
|
|
3005
3343
|
itemId
|
|
3006
3344
|
);
|
|
3007
3345
|
};
|
|
3346
|
+
venusApi.simulation.sumContributions = (contributions) => {
|
|
3347
|
+
return host.simulation.sumContributions(contributions);
|
|
3348
|
+
};
|
|
3008
3349
|
}
|
|
3009
3350
|
|
|
3010
3351
|
// src/time/utils.ts
|
|
@@ -3119,6 +3460,7 @@ var MockTimeApi = class {
|
|
|
3119
3460
|
maximumFractionDigits: options?.maximumFractionDigits || 2,
|
|
3120
3461
|
...options
|
|
3121
3462
|
};
|
|
3463
|
+
console.log(`[Venus Mock] Formatting number ${value} with locale ${locale}`);
|
|
3122
3464
|
return value.toLocaleString(locale, numberOptions);
|
|
3123
3465
|
}
|
|
3124
3466
|
formatTime(timestamp, options) {
|
|
@@ -3130,9 +3472,13 @@ var MockTimeApi = class {
|
|
|
3130
3472
|
hour12: options.hour12 !== void 0 ? options.hour12 : true,
|
|
3131
3473
|
...options
|
|
3132
3474
|
};
|
|
3475
|
+
console.log(
|
|
3476
|
+
`[Venus Mock] Formatting time ${timestamp} with locale ${locale}`
|
|
3477
|
+
);
|
|
3133
3478
|
return date.toLocaleString(locale, dateTimeOptions);
|
|
3134
3479
|
}
|
|
3135
3480
|
async getFutureTimeAsync(options) {
|
|
3481
|
+
console.log("[Venus Mock] Getting future time with options:", options);
|
|
3136
3482
|
const timeInfo = await this.requestTimeAsync();
|
|
3137
3483
|
const serverTime = new Date(timeInfo.serverTime);
|
|
3138
3484
|
const result = new Date(serverTime);
|
|
@@ -3177,6 +3523,7 @@ var MockTimeApi = class {
|
|
|
3177
3523
|
return result.getTime();
|
|
3178
3524
|
}
|
|
3179
3525
|
async requestTimeAsync() {
|
|
3526
|
+
console.log("[Venus Mock] Requesting time");
|
|
3180
3527
|
await createMockDelay(MOCK_DELAYS.short);
|
|
3181
3528
|
const venusApi = this.venusApi;
|
|
3182
3529
|
const mockOffset = venusApi._mock.serverTimeOffset || 2500;
|
|
@@ -3190,6 +3537,11 @@ var MockTimeApi = class {
|
|
|
3190
3537
|
formattedTime: new Date(localTime).toISOString(),
|
|
3191
3538
|
locale: venusApi._mock.user?.locale || "en-US"
|
|
3192
3539
|
};
|
|
3540
|
+
console.log("[Venus Mock] Time response:", {
|
|
3541
|
+
serverTime: new Date(timeInfo.serverTime).toISOString(),
|
|
3542
|
+
localTime: new Date(timeInfo.localTime).toISOString(),
|
|
3543
|
+
timezoneOffset: timeInfo.timezoneOffset
|
|
3544
|
+
});
|
|
3193
3545
|
return timeInfo;
|
|
3194
3546
|
}
|
|
3195
3547
|
};
|
|
@@ -3211,12 +3563,181 @@ function initializeTime(venusApi, host) {
|
|
|
3211
3563
|
}
|
|
3212
3564
|
|
|
3213
3565
|
// src/version.ts
|
|
3214
|
-
var SDK_VERSION = "3.0.
|
|
3566
|
+
var SDK_VERSION = "3.1.0-beta.0";
|
|
3215
3567
|
|
|
3216
3568
|
// src/shared-assets/consts.ts
|
|
3217
3569
|
var BurgerTimeAssetsCdnPath = "burger-time/Core.stow";
|
|
3218
3570
|
var CharacterAssetsCdnPath = "burger-time/Character.stow";
|
|
3219
3571
|
|
|
3572
|
+
// src/shared-assets/embeddedLibrariesManifest.ts
|
|
3573
|
+
var DEFAULT_SHARED_LIB_CDN_BASE = "https://venus-static-01293ak.web.app/libs";
|
|
3574
|
+
var EMBEDDED_LIBRARIES = [
|
|
3575
|
+
{
|
|
3576
|
+
libraryKey: "phaser@3.90.0",
|
|
3577
|
+
assetKey: "library:phaser@3.90.0",
|
|
3578
|
+
packageName: "phaser",
|
|
3579
|
+
version: "3.90.0",
|
|
3580
|
+
globalVar: "Phaser",
|
|
3581
|
+
cdnPath: "phaser/3.90.0/phaser.min.js",
|
|
3582
|
+
moduleSpecifiers: [{ match: "exact", value: "phaser" }],
|
|
3583
|
+
loadStage: 0,
|
|
3584
|
+
enabled: true
|
|
3585
|
+
},
|
|
3586
|
+
{
|
|
3587
|
+
libraryKey: "react@18.3.1",
|
|
3588
|
+
assetKey: "library:react@18.3.1",
|
|
3589
|
+
packageName: "react",
|
|
3590
|
+
version: "18.3.1",
|
|
3591
|
+
globalVar: "React",
|
|
3592
|
+
cdnPath: "react/18.3.1/react.production.min.js",
|
|
3593
|
+
moduleSpecifiers: [
|
|
3594
|
+
{ match: "exact", value: "react", behavior: "namespace" },
|
|
3595
|
+
{ match: "exact", value: "react/jsx-runtime", behavior: "react-jsx-runtime" },
|
|
3596
|
+
{
|
|
3597
|
+
match: "exact",
|
|
3598
|
+
value: "react/jsx-dev-runtime",
|
|
3599
|
+
behavior: "react-jsx-dev-runtime"
|
|
3600
|
+
}
|
|
3601
|
+
],
|
|
3602
|
+
loadStage: 0,
|
|
3603
|
+
// Must load before ReactDOM
|
|
3604
|
+
enabled: true
|
|
3605
|
+
},
|
|
3606
|
+
{
|
|
3607
|
+
libraryKey: "react-dom@18.3.1",
|
|
3608
|
+
assetKey: "library:react-dom@18.3.1",
|
|
3609
|
+
packageName: "react-dom",
|
|
3610
|
+
version: "18.3.1",
|
|
3611
|
+
globalVar: "ReactDOM",
|
|
3612
|
+
cdnPath: "react-dom/18.3.1/react-dom.production.min.js",
|
|
3613
|
+
moduleSpecifiers: [
|
|
3614
|
+
{ match: "exact", value: "react-dom", behavior: "namespace" },
|
|
3615
|
+
{ match: "exact", value: "react-dom/client", behavior: "namespace" }
|
|
3616
|
+
],
|
|
3617
|
+
loadStage: 1,
|
|
3618
|
+
// Depends on React (stage 0)
|
|
3619
|
+
enabled: true
|
|
3620
|
+
},
|
|
3621
|
+
{
|
|
3622
|
+
libraryKey: "three@0.170.0",
|
|
3623
|
+
assetKey: "library:three@0.170.0",
|
|
3624
|
+
packageName: "three",
|
|
3625
|
+
version: "0.170.0",
|
|
3626
|
+
globalVar: "THREE",
|
|
3627
|
+
cdnPath: "three/r170/three.min.js",
|
|
3628
|
+
moduleSpecifiers: [
|
|
3629
|
+
{ match: "exact", value: "three", behavior: "namespace" },
|
|
3630
|
+
{ match: "prefix", value: "three/examples/jsm/", behavior: "namespace" }
|
|
3631
|
+
],
|
|
3632
|
+
loadStage: 0,
|
|
3633
|
+
enabled: true
|
|
3634
|
+
},
|
|
3635
|
+
{
|
|
3636
|
+
libraryKey: "matter-js@0.19.0",
|
|
3637
|
+
assetKey: "library:matter-js@0.19.0",
|
|
3638
|
+
packageName: "matter-js",
|
|
3639
|
+
version: "0.19.0",
|
|
3640
|
+
globalVar: "Matter",
|
|
3641
|
+
cdnPath: "matter-js/0.19.0/matter.min.js",
|
|
3642
|
+
moduleSpecifiers: [{ match: "exact", value: "matter-js" }],
|
|
3643
|
+
loadStage: 0,
|
|
3644
|
+
enabled: true
|
|
3645
|
+
},
|
|
3646
|
+
{
|
|
3647
|
+
libraryKey: "inkjs@2.2.0",
|
|
3648
|
+
assetKey: "library:inkjs@2.2.0",
|
|
3649
|
+
packageName: "inkjs",
|
|
3650
|
+
version: "2.2.0",
|
|
3651
|
+
globalVar: "inkjs",
|
|
3652
|
+
cdnPath: "inkjs/2.2.0/ink.min.js",
|
|
3653
|
+
moduleSpecifiers: [{ match: "exact", value: "inkjs" }],
|
|
3654
|
+
loadStage: 0,
|
|
3655
|
+
enabled: true
|
|
3656
|
+
},
|
|
3657
|
+
{
|
|
3658
|
+
libraryKey: "zustand@5.0.3",
|
|
3659
|
+
assetKey: "library:zustand@5.0.3",
|
|
3660
|
+
packageName: "zustand",
|
|
3661
|
+
version: "5.0.3",
|
|
3662
|
+
globalVar: "zustand",
|
|
3663
|
+
cdnPath: "zustand/5.0.3/zustand.min.js",
|
|
3664
|
+
moduleSpecifiers: [
|
|
3665
|
+
{ match: "exact", value: "zustand" },
|
|
3666
|
+
{ match: "exact", value: "zustand/middleware" }
|
|
3667
|
+
],
|
|
3668
|
+
loadStage: 0,
|
|
3669
|
+
enabled: true
|
|
3670
|
+
},
|
|
3671
|
+
{
|
|
3672
|
+
libraryKey: "ammo.js@2024.11",
|
|
3673
|
+
assetKey: "library:ammo.js@2024.11",
|
|
3674
|
+
packageName: "ammo.js",
|
|
3675
|
+
version: "2024.11",
|
|
3676
|
+
globalVar: "Ammo",
|
|
3677
|
+
cdnPath: "ammo/2024.11/ammo.js",
|
|
3678
|
+
moduleSpecifiers: [
|
|
3679
|
+
{ match: "exact", value: "ammo.js" },
|
|
3680
|
+
{ match: "exact", value: "ammo.js/builds/ammo.wasm.js" }
|
|
3681
|
+
],
|
|
3682
|
+
loadStage: 0,
|
|
3683
|
+
enabled: false
|
|
3684
|
+
// Not ready yet - WASM loading needs additional work
|
|
3685
|
+
}
|
|
3686
|
+
];
|
|
3687
|
+
var EMBEDDED_LIBRARY_BY_KEY = EMBEDDED_LIBRARIES.reduce(
|
|
3688
|
+
(acc, lib) => {
|
|
3689
|
+
acc[lib.libraryKey] = lib;
|
|
3690
|
+
return acc;
|
|
3691
|
+
},
|
|
3692
|
+
{}
|
|
3693
|
+
);
|
|
3694
|
+
var MODULE_TO_LIBRARY_SPECIFIERS = EMBEDDED_LIBRARIES.filter(
|
|
3695
|
+
(lib) => lib.enabled
|
|
3696
|
+
).flatMap(
|
|
3697
|
+
(lib) => lib.moduleSpecifiers.map((specifier) => ({
|
|
3698
|
+
...specifier,
|
|
3699
|
+
libraryKey: lib.libraryKey
|
|
3700
|
+
}))
|
|
3701
|
+
);
|
|
3702
|
+
function getLibraryDefinition(libraryKey) {
|
|
3703
|
+
const definition = EMBEDDED_LIBRARY_BY_KEY[libraryKey];
|
|
3704
|
+
if (!definition) {
|
|
3705
|
+
const availableKeys = Object.keys(EMBEDDED_LIBRARY_BY_KEY).join(", ");
|
|
3706
|
+
throw new Error(
|
|
3707
|
+
`Unsupported embedded library: ${libraryKey}. Available libraries: ${availableKeys}`
|
|
3708
|
+
);
|
|
3709
|
+
}
|
|
3710
|
+
return definition;
|
|
3711
|
+
}
|
|
3712
|
+
|
|
3713
|
+
// src/shared-assets/base64Utils.ts
|
|
3714
|
+
function base64ToArrayBuffer(base64) {
|
|
3715
|
+
const binaryString = atob(base64);
|
|
3716
|
+
const len = binaryString.length;
|
|
3717
|
+
const bytes = new Uint8Array(len);
|
|
3718
|
+
for (let i = 0; i < len; i++) {
|
|
3719
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
3720
|
+
}
|
|
3721
|
+
return bytes.buffer;
|
|
3722
|
+
}
|
|
3723
|
+
function base64ToUtf8(base64) {
|
|
3724
|
+
if (typeof TextDecoder !== "undefined") {
|
|
3725
|
+
const decoder = new TextDecoder("utf-8");
|
|
3726
|
+
const buffer = base64ToArrayBuffer(base64);
|
|
3727
|
+
return decoder.decode(new Uint8Array(buffer));
|
|
3728
|
+
}
|
|
3729
|
+
if (typeof globalThis !== "undefined" && typeof globalThis.Buffer !== "undefined") {
|
|
3730
|
+
const BufferCtor = globalThis.Buffer;
|
|
3731
|
+
return BufferCtor.from(base64, "base64").toString("utf-8");
|
|
3732
|
+
}
|
|
3733
|
+
const binaryString = atob(base64);
|
|
3734
|
+
let result = "";
|
|
3735
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
3736
|
+
result += String.fromCharCode(binaryString.charCodeAt(i));
|
|
3737
|
+
}
|
|
3738
|
+
return decodeURIComponent(escape(result));
|
|
3739
|
+
}
|
|
3740
|
+
|
|
3220
3741
|
// src/shared-assets/RpcSharedAssetsApi.ts
|
|
3221
3742
|
var RpcSharedAssetsApi = class {
|
|
3222
3743
|
constructor(rpcClient, venusApi) {
|
|
@@ -3255,16 +3776,33 @@ var RpcSharedAssetsApi = class {
|
|
|
3255
3776
|
}
|
|
3256
3777
|
}
|
|
3257
3778
|
}
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3779
|
+
async loadLibraryCode(libraryKey) {
|
|
3780
|
+
const definition = getLibraryDefinition(libraryKey);
|
|
3781
|
+
try {
|
|
3782
|
+
const response = await this.rpcClient.callT("H5_LOAD_EMBEDDED_ASSET" /* H5_LOAD_EMBEDDED_ASSET */, {
|
|
3783
|
+
assetKey: definition.assetKey
|
|
3784
|
+
});
|
|
3785
|
+
return base64ToUtf8(response.base64Data);
|
|
3786
|
+
} catch (err) {
|
|
3787
|
+
console.error(
|
|
3788
|
+
`[Venus Libraries] Failed to load ${libraryKey} from host via RPC:`,
|
|
3789
|
+
err
|
|
3790
|
+
);
|
|
3791
|
+
console.warn(
|
|
3792
|
+
`[Venus Libraries] Falling back to CDN for ${libraryKey}. This may indicate an asset packaging issue.`
|
|
3793
|
+
);
|
|
3794
|
+
try {
|
|
3795
|
+
const cdnUrl = this.venusApi.cdn.resolveSharedLibUrl(definition.cdnPath);
|
|
3796
|
+
const response = await this.venusApi.cdn.fetchFromCdn(cdnUrl);
|
|
3797
|
+
return await response.text();
|
|
3798
|
+
} catch (cdnError) {
|
|
3799
|
+
throw new Error(
|
|
3800
|
+
`Failed to load embedded library ${libraryKey}: RPC failed, CDN fallback failed: ${cdnError.message}`
|
|
3801
|
+
);
|
|
3802
|
+
}
|
|
3803
|
+
}
|
|
3265
3804
|
}
|
|
3266
|
-
|
|
3267
|
-
}
|
|
3805
|
+
};
|
|
3268
3806
|
|
|
3269
3807
|
// src/shared-assets/MockSharedAssetsApi.ts
|
|
3270
3808
|
var MockSharedAssetsApi = class {
|
|
@@ -3280,6 +3818,12 @@ var MockSharedAssetsApi = class {
|
|
|
3280
3818
|
const blob = await this.venusApi.cdn.fetchBlob(CharacterAssetsCdnPath);
|
|
3281
3819
|
return await blob.arrayBuffer();
|
|
3282
3820
|
}
|
|
3821
|
+
async loadLibraryCode(libraryKey) {
|
|
3822
|
+
const definition = getLibraryDefinition(libraryKey);
|
|
3823
|
+
const url = this.venusApi.cdn.resolveSharedLibUrl(definition.cdnPath);
|
|
3824
|
+
const response = await this.venusApi.cdn.fetchFromCdn(url);
|
|
3825
|
+
return await response.text();
|
|
3826
|
+
}
|
|
3283
3827
|
};
|
|
3284
3828
|
|
|
3285
3829
|
// src/leaderboard/utils.ts
|
|
@@ -3714,6 +4258,7 @@ var MockPostApi = class {
|
|
|
3714
4258
|
}
|
|
3715
4259
|
async toggleFollowAsync() {
|
|
3716
4260
|
const venusApi = this.venusApi;
|
|
4261
|
+
console.log("[Venus Mock] *Toggling follow status");
|
|
3717
4262
|
await createMockDelay(MOCK_DELAYS.short);
|
|
3718
4263
|
venusApi._mock.currentPostInteractions.isFollowing = !venusApi._mock.currentPostInteractions.isFollowing;
|
|
3719
4264
|
const isFollowing = venusApi._mock.currentPostInteractions.isFollowing;
|
|
@@ -3766,6 +4311,9 @@ var RpcPostApi = class {
|
|
|
3766
4311
|
}
|
|
3767
4312
|
};
|
|
3768
4313
|
|
|
4314
|
+
// src/MockHost.ts
|
|
4315
|
+
init_rooms();
|
|
4316
|
+
|
|
3769
4317
|
// src/social/MockSocialApi.ts
|
|
3770
4318
|
var MOCK_QR_CODE = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==";
|
|
3771
4319
|
var MockSocialApi = class {
|
|
@@ -3802,116 +4350,44 @@ var ROOMS_UNAVAILABLE_MESSAGE = "[Venus SDK] Rooms API is only available when ru
|
|
|
3802
4350
|
function createUnavailableRoomsApi() {
|
|
3803
4351
|
const roomsUnavailableError = () => new Error(ROOMS_UNAVAILABLE_MESSAGE);
|
|
3804
4352
|
return {
|
|
3805
|
-
async
|
|
4353
|
+
async createRoom() {
|
|
3806
4354
|
throw roomsUnavailableError();
|
|
3807
4355
|
},
|
|
3808
|
-
async
|
|
4356
|
+
async joinOrCreateRoom() {
|
|
3809
4357
|
throw roomsUnavailableError();
|
|
3810
4358
|
},
|
|
3811
|
-
async
|
|
4359
|
+
async getUserRooms() {
|
|
3812
4360
|
throw roomsUnavailableError();
|
|
3813
4361
|
},
|
|
3814
|
-
async
|
|
4362
|
+
async joinRoomByCode() {
|
|
3815
4363
|
throw roomsUnavailableError();
|
|
3816
4364
|
},
|
|
3817
|
-
|
|
4365
|
+
subscribe() {
|
|
3818
4366
|
throw roomsUnavailableError();
|
|
3819
4367
|
},
|
|
3820
|
-
async
|
|
4368
|
+
async updateData() {
|
|
3821
4369
|
throw roomsUnavailableError();
|
|
3822
4370
|
},
|
|
3823
|
-
async
|
|
4371
|
+
async getData() {
|
|
3824
4372
|
throw roomsUnavailableError();
|
|
3825
4373
|
},
|
|
3826
|
-
async
|
|
4374
|
+
async sendMessage() {
|
|
3827
4375
|
throw roomsUnavailableError();
|
|
3828
4376
|
},
|
|
3829
|
-
async
|
|
4377
|
+
async leave() {
|
|
3830
4378
|
throw roomsUnavailableError();
|
|
3831
4379
|
},
|
|
3832
|
-
async
|
|
4380
|
+
async startGame() {
|
|
3833
4381
|
throw roomsUnavailableError();
|
|
3834
4382
|
},
|
|
3835
|
-
async
|
|
4383
|
+
async proposeMove() {
|
|
3836
4384
|
throw roomsUnavailableError();
|
|
3837
4385
|
},
|
|
3838
|
-
async
|
|
4386
|
+
async validateMove() {
|
|
3839
4387
|
throw roomsUnavailableError();
|
|
3840
4388
|
}
|
|
3841
4389
|
};
|
|
3842
4390
|
}
|
|
3843
|
-
var SIMULATION_UNAVAILABLE_MESSAGE = "[Venus SDK] Simulation API is only available when running inside the Venus host environment.";
|
|
3844
|
-
function createUnavailableSimulationApi() {
|
|
3845
|
-
const simulationUnavailableError = () => new Error(SIMULATION_UNAVAILABLE_MESSAGE);
|
|
3846
|
-
return {
|
|
3847
|
-
isEnabled() {
|
|
3848
|
-
return false;
|
|
3849
|
-
},
|
|
3850
|
-
async getStateAsync() {
|
|
3851
|
-
throw simulationUnavailableError();
|
|
3852
|
-
},
|
|
3853
|
-
async getConfigAsync() {
|
|
3854
|
-
throw simulationUnavailableError();
|
|
3855
|
-
},
|
|
3856
|
-
async executeRecipeAsync() {
|
|
3857
|
-
throw simulationUnavailableError();
|
|
3858
|
-
},
|
|
3859
|
-
async getActiveRunsAsync() {
|
|
3860
|
-
throw simulationUnavailableError();
|
|
3861
|
-
},
|
|
3862
|
-
async collectRecipeAsync() {
|
|
3863
|
-
throw simulationUnavailableError();
|
|
3864
|
-
},
|
|
3865
|
-
async executeScopedRecipeAsync() {
|
|
3866
|
-
throw simulationUnavailableError();
|
|
3867
|
-
},
|
|
3868
|
-
async triggerRecipeChainAsync() {
|
|
3869
|
-
throw simulationUnavailableError();
|
|
3870
|
-
},
|
|
3871
|
-
async getAvailableRecipesAsync() {
|
|
3872
|
-
throw simulationUnavailableError();
|
|
3873
|
-
},
|
|
3874
|
-
async getRecipeRequirementsAsync() {
|
|
3875
|
-
throw simulationUnavailableError();
|
|
3876
|
-
},
|
|
3877
|
-
async getBatchRecipeRequirementsAsync() {
|
|
3878
|
-
throw simulationUnavailableError();
|
|
3879
|
-
},
|
|
3880
|
-
async resolveFieldValueAsync() {
|
|
3881
|
-
throw simulationUnavailableError();
|
|
3882
|
-
},
|
|
3883
|
-
async getEntityMetadataAsync() {
|
|
3884
|
-
throw simulationUnavailableError();
|
|
3885
|
-
},
|
|
3886
|
-
async getSlotContainersAsync() {
|
|
3887
|
-
throw simulationUnavailableError();
|
|
3888
|
-
},
|
|
3889
|
-
async getSlotAssignmentsAsync() {
|
|
3890
|
-
throw simulationUnavailableError();
|
|
3891
|
-
},
|
|
3892
|
-
async assignItemToSlotAsync() {
|
|
3893
|
-
throw simulationUnavailableError();
|
|
3894
|
-
},
|
|
3895
|
-
async removeItemFromSlotAsync() {
|
|
3896
|
-
throw simulationUnavailableError();
|
|
3897
|
-
},
|
|
3898
|
-
async getAvailableItemsAsync() {
|
|
3899
|
-
throw simulationUnavailableError();
|
|
3900
|
-
},
|
|
3901
|
-
async calculatePowerPreviewAsync() {
|
|
3902
|
-
throw simulationUnavailableError();
|
|
3903
|
-
},
|
|
3904
|
-
async validateSlotAssignmentAsync() {
|
|
3905
|
-
throw simulationUnavailableError();
|
|
3906
|
-
},
|
|
3907
|
-
async executeBatchOperationsAsync() {
|
|
3908
|
-
throw simulationUnavailableError();
|
|
3909
|
-
},
|
|
3910
|
-
async subscribeAsync() {
|
|
3911
|
-
throw simulationUnavailableError();
|
|
3912
|
-
}
|
|
3913
|
-
};
|
|
3914
|
-
}
|
|
3915
4391
|
var MockHost = class {
|
|
3916
4392
|
constructor(venusApi) {
|
|
3917
4393
|
__publicField(this, "ads");
|
|
@@ -3966,7 +4442,7 @@ var MockHost = class {
|
|
|
3966
4442
|
this.haptics = new MockHapticsApi(venusApi);
|
|
3967
4443
|
this.features = new MockFeaturesApi();
|
|
3968
4444
|
this.lifecycle = this._mockLifecyclesApi;
|
|
3969
|
-
this.simulation =
|
|
4445
|
+
this.simulation = new MockSimulationApi();
|
|
3970
4446
|
this.rooms = createUnavailableRoomsApi();
|
|
3971
4447
|
this.logging = new MockLoggingApi();
|
|
3972
4448
|
this.iap = new MockIapApi();
|
|
@@ -4499,16 +4975,6 @@ var VenusTransport = class {
|
|
|
4499
4975
|
this.isProcessingMessage = false;
|
|
4500
4976
|
return;
|
|
4501
4977
|
}
|
|
4502
|
-
if (message.type === "H5_SIMULATION_UPDATE" /* H5_SIMULATION_UPDATE */) {
|
|
4503
|
-
const notification = {
|
|
4504
|
-
type: "rpc-notification",
|
|
4505
|
-
id: message.type,
|
|
4506
|
-
payload: message.data
|
|
4507
|
-
};
|
|
4508
|
-
this.handleNotification(notification);
|
|
4509
|
-
this.isProcessingMessage = false;
|
|
4510
|
-
return;
|
|
4511
|
-
}
|
|
4512
4978
|
const requestId = messageData.requestId;
|
|
4513
4979
|
if (!requestId) {
|
|
4514
4980
|
this.logWarn("No requestId. Ignoring message...");
|
|
@@ -4614,64 +5080,352 @@ var VenusTransport = class {
|
|
|
4614
5080
|
if (!this.isStarted) {
|
|
4615
5081
|
return;
|
|
4616
5082
|
}
|
|
4617
|
-
this.isStarted = false;
|
|
4618
|
-
window.removeEventListener("message", this.messageHandler);
|
|
4619
|
-
this.logInfo(`Stopped`);
|
|
5083
|
+
this.isStarted = false;
|
|
5084
|
+
window.removeEventListener("message", this.messageHandler);
|
|
5085
|
+
this.logInfo(`Stopped`);
|
|
5086
|
+
}
|
|
5087
|
+
handleNotification(notification) {
|
|
5088
|
+
for (const callback of this.onNotificationCallbacks) {
|
|
5089
|
+
callback(notification);
|
|
5090
|
+
}
|
|
5091
|
+
for (const callback of this.onNotificationCallbacksToRemove) {
|
|
5092
|
+
this.removeOnNotificationCallback(callback);
|
|
5093
|
+
}
|
|
5094
|
+
this.onNotificationCallbacksToRemove.length = 0;
|
|
5095
|
+
}
|
|
5096
|
+
async handleResponse(response) {
|
|
5097
|
+
for (const callback of this.onResponseCallbacks) {
|
|
5098
|
+
const consumed = await callback(response);
|
|
5099
|
+
if (consumed) {
|
|
5100
|
+
break;
|
|
5101
|
+
}
|
|
5102
|
+
}
|
|
5103
|
+
for (const callback of this.onResponseCallbacksToRemove) {
|
|
5104
|
+
this.removeOnResponseCallback(callback);
|
|
5105
|
+
}
|
|
5106
|
+
this.onResponseCallbacksToRemove.length = 0;
|
|
5107
|
+
}
|
|
5108
|
+
removeOnResponseCallback(callback) {
|
|
5109
|
+
this.onResponseCallbacks.splice(
|
|
5110
|
+
this.onResponseCallbacks.indexOf(callback),
|
|
5111
|
+
1
|
|
5112
|
+
);
|
|
5113
|
+
}
|
|
5114
|
+
removeOnNotificationCallback(callback) {
|
|
5115
|
+
this.onNotificationCallbacks.splice(
|
|
5116
|
+
this.onNotificationCallbacks.indexOf(callback),
|
|
5117
|
+
1
|
|
5118
|
+
);
|
|
5119
|
+
}
|
|
5120
|
+
logInfo(message, ...params) {
|
|
5121
|
+
console.log(`[Venus Transport] ${message}`, ...params);
|
|
5122
|
+
}
|
|
5123
|
+
logWarn(message, ...params) {
|
|
5124
|
+
console.warn(`[Venus Transport] ${message}`, ...params);
|
|
5125
|
+
}
|
|
5126
|
+
onVenusMessage(callback) {
|
|
5127
|
+
this.onVenusMessageCallbacks.push(callback);
|
|
5128
|
+
return {
|
|
5129
|
+
unsubscribe: () => {
|
|
5130
|
+
this.onVenusMessageCallbacks.splice(
|
|
5131
|
+
this.onVenusMessageCallbacks.indexOf(callback),
|
|
5132
|
+
1
|
|
5133
|
+
);
|
|
5134
|
+
}
|
|
5135
|
+
};
|
|
5136
|
+
}
|
|
5137
|
+
notifyVenusMessageReceived(message) {
|
|
5138
|
+
for (const callback of this.onVenusMessageCallbacks) {
|
|
5139
|
+
callback(message);
|
|
5140
|
+
}
|
|
5141
|
+
}
|
|
5142
|
+
};
|
|
5143
|
+
|
|
5144
|
+
// src/RemoteHost.ts
|
|
5145
|
+
init_rooms();
|
|
5146
|
+
|
|
5147
|
+
// src/rooms/RpcRoomsApi.ts
|
|
5148
|
+
init_VenusRoom();
|
|
5149
|
+
var RpcRoomsApi = class {
|
|
5150
|
+
constructor(rpcClient) {
|
|
5151
|
+
__publicField(this, "rpcClient");
|
|
5152
|
+
__publicField(this, "subscriptions");
|
|
5153
|
+
__publicField(this, "transportSubscription", null);
|
|
5154
|
+
this.rpcClient = rpcClient;
|
|
5155
|
+
this.subscriptions = {
|
|
5156
|
+
data: {},
|
|
5157
|
+
messages: {},
|
|
5158
|
+
gameEvents: {},
|
|
5159
|
+
allEvents: {}
|
|
5160
|
+
};
|
|
5161
|
+
}
|
|
5162
|
+
/**
|
|
5163
|
+
* Get the subscription state for external access (used by setupRoomNotifications)
|
|
5164
|
+
*/
|
|
5165
|
+
getSubscriptions() {
|
|
5166
|
+
return this.subscriptions;
|
|
5167
|
+
}
|
|
5168
|
+
/**
|
|
5169
|
+
* Set up room notification routing from the transport
|
|
5170
|
+
*/
|
|
5171
|
+
setupNotifications(transport) {
|
|
5172
|
+
const { setupRoomNotifications: setupRoomNotifications2 } = (init_rooms(), __toCommonJS(rooms_exports));
|
|
5173
|
+
this.transportSubscription = setupRoomNotifications2(
|
|
5174
|
+
transport,
|
|
5175
|
+
() => this.getSubscriptions()
|
|
5176
|
+
);
|
|
5177
|
+
}
|
|
5178
|
+
/**
|
|
5179
|
+
* Clean up subscriptions and resources
|
|
5180
|
+
*/
|
|
5181
|
+
dispose() {
|
|
5182
|
+
if (this.transportSubscription) {
|
|
5183
|
+
this.transportSubscription.unsubscribe();
|
|
5184
|
+
this.transportSubscription = null;
|
|
5185
|
+
console.log("[Venus Rooms] Cleaned up room notification subscription");
|
|
5186
|
+
}
|
|
5187
|
+
}
|
|
5188
|
+
async createRoom(options) {
|
|
5189
|
+
const response = await this.rpcClient.call(
|
|
5190
|
+
"H5_ROOM_CREATE" /* H5_ROOM_CREATE */,
|
|
5191
|
+
{
|
|
5192
|
+
options
|
|
5193
|
+
}
|
|
5194
|
+
);
|
|
5195
|
+
if (response.success === false) {
|
|
5196
|
+
throw new Error(response.error || "Failed to create room");
|
|
5197
|
+
}
|
|
5198
|
+
const roomData = response.roomData || response;
|
|
5199
|
+
const room = new exports.VenusRoom(roomData);
|
|
5200
|
+
return room;
|
|
5201
|
+
}
|
|
5202
|
+
async joinOrCreateRoom(options) {
|
|
5203
|
+
const response = await this.rpcClient.call(
|
|
5204
|
+
"H5_ROOM_JOIN_OR_CREATE" /* H5_ROOM_JOIN_OR_CREATE */,
|
|
5205
|
+
{
|
|
5206
|
+
options
|
|
5207
|
+
}
|
|
5208
|
+
);
|
|
5209
|
+
if (response.success === false) {
|
|
5210
|
+
throw new Error(response.error || "Failed to join or create room");
|
|
5211
|
+
}
|
|
5212
|
+
const data = response.value || response;
|
|
5213
|
+
const room = new exports.VenusRoom(data.roomData);
|
|
5214
|
+
return {
|
|
5215
|
+
action: data.action,
|
|
5216
|
+
room,
|
|
5217
|
+
playersJoined: data.playersJoined
|
|
5218
|
+
};
|
|
5219
|
+
}
|
|
5220
|
+
async joinRoomByCode(roomCode) {
|
|
5221
|
+
const response = await this.rpcClient.call(
|
|
5222
|
+
"H5_ROOM_JOIN_BY_CODE" /* H5_ROOM_JOIN_BY_CODE */,
|
|
5223
|
+
{
|
|
5224
|
+
roomCode
|
|
5225
|
+
}
|
|
5226
|
+
);
|
|
5227
|
+
if (response?.success === false) {
|
|
5228
|
+
throw new Error(response.error || "Failed to join room by code");
|
|
5229
|
+
}
|
|
5230
|
+
const roomData = response.roomData || response;
|
|
5231
|
+
const room = new exports.VenusRoom(roomData);
|
|
5232
|
+
return room;
|
|
5233
|
+
}
|
|
5234
|
+
// Get user's rooms with optional filtering
|
|
5235
|
+
async getUserRooms(includeArchived = false) {
|
|
5236
|
+
const response = await this.rpcClient.call(
|
|
5237
|
+
"H5_ROOM_GET_USER_ROOMS" /* H5_ROOM_GET_USER_ROOMS */,
|
|
5238
|
+
{
|
|
5239
|
+
includeArchived
|
|
5240
|
+
}
|
|
5241
|
+
);
|
|
5242
|
+
if (response?.success === false) {
|
|
5243
|
+
throw new Error(response.error || "Failed to get user rooms");
|
|
5244
|
+
}
|
|
5245
|
+
const rawRooms = response.rooms || [];
|
|
5246
|
+
const venusRooms = [];
|
|
5247
|
+
for (const roomData of rawRooms) {
|
|
5248
|
+
if (!roomData.id) {
|
|
5249
|
+
console.warn("getUserRooms: Skipping room with missing ID:", roomData);
|
|
5250
|
+
continue;
|
|
5251
|
+
}
|
|
5252
|
+
try {
|
|
5253
|
+
const venusRoom = new exports.VenusRoom(roomData);
|
|
5254
|
+
venusRooms.push(venusRoom);
|
|
5255
|
+
} catch (error) {
|
|
5256
|
+
console.warn(
|
|
5257
|
+
"getUserRooms: Failed to create VenusRoom object:",
|
|
5258
|
+
error,
|
|
5259
|
+
roomData
|
|
5260
|
+
);
|
|
5261
|
+
}
|
|
5262
|
+
}
|
|
5263
|
+
return venusRooms;
|
|
5264
|
+
}
|
|
5265
|
+
async updateData(room, updates, merge = true) {
|
|
5266
|
+
const response = await this.rpcClient.call(
|
|
5267
|
+
"H5_ROOM_UPDATE_DATA" /* H5_ROOM_UPDATE_DATA */,
|
|
5268
|
+
{
|
|
5269
|
+
roomId: room.id,
|
|
5270
|
+
updates,
|
|
5271
|
+
merge
|
|
5272
|
+
}
|
|
5273
|
+
);
|
|
5274
|
+
if (response?.success === false) {
|
|
5275
|
+
throw new Error(response.error || "Failed to update room data");
|
|
5276
|
+
}
|
|
5277
|
+
return response.data;
|
|
4620
5278
|
}
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
5279
|
+
async getData(room) {
|
|
5280
|
+
const response = await this.rpcClient.call(
|
|
5281
|
+
"H5_ROOM_GET_DATA" /* H5_ROOM_GET_DATA */,
|
|
5282
|
+
{
|
|
5283
|
+
roomId: room.id
|
|
5284
|
+
}
|
|
5285
|
+
);
|
|
5286
|
+
if (response?.success === false) {
|
|
5287
|
+
throw new Error(response.error || "Failed to get room data");
|
|
4627
5288
|
}
|
|
4628
|
-
|
|
5289
|
+
return response.data;
|
|
4629
5290
|
}
|
|
4630
|
-
async
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
5291
|
+
async sendMessage(venusRoom, messageData) {
|
|
5292
|
+
const response = await this.rpcClient.call(
|
|
5293
|
+
"H5_ROOM_SEND_MESSAGE" /* H5_ROOM_SEND_MESSAGE */,
|
|
5294
|
+
{
|
|
5295
|
+
roomId: venusRoom.id,
|
|
5296
|
+
message: messageData
|
|
4635
5297
|
}
|
|
5298
|
+
);
|
|
5299
|
+
if (response?.success === false) {
|
|
5300
|
+
throw new Error(response.error || "Failed to send message");
|
|
4636
5301
|
}
|
|
4637
|
-
|
|
4638
|
-
|
|
5302
|
+
return response.messageId;
|
|
5303
|
+
}
|
|
5304
|
+
async leave(room) {
|
|
5305
|
+
const response = await this.rpcClient.call(
|
|
5306
|
+
"H5_ROOM_LEAVE" /* H5_ROOM_LEAVE */,
|
|
5307
|
+
{
|
|
5308
|
+
roomId: room.id
|
|
5309
|
+
}
|
|
5310
|
+
);
|
|
5311
|
+
if (response?.success === false) {
|
|
5312
|
+
throw new Error(response.error || "Failed to leave room");
|
|
4639
5313
|
}
|
|
4640
|
-
|
|
5314
|
+
return response;
|
|
4641
5315
|
}
|
|
4642
|
-
|
|
4643
|
-
this.
|
|
4644
|
-
|
|
4645
|
-
|
|
5316
|
+
async startGame(room, gameConfig = {}, turnOrder = null) {
|
|
5317
|
+
const response = await this.rpcClient.call(
|
|
5318
|
+
"H5_ROOM_START_GAME" /* H5_ROOM_START_GAME */,
|
|
5319
|
+
{
|
|
5320
|
+
roomId: room.id,
|
|
5321
|
+
gameConfig,
|
|
5322
|
+
turnOrder
|
|
5323
|
+
}
|
|
4646
5324
|
);
|
|
5325
|
+
if (response?.success === false) {
|
|
5326
|
+
throw new Error(response.error || "Failed to start game");
|
|
5327
|
+
}
|
|
5328
|
+
return response.data;
|
|
4647
5329
|
}
|
|
4648
|
-
|
|
4649
|
-
this.
|
|
4650
|
-
|
|
4651
|
-
|
|
5330
|
+
async proposeMove(room, proposalPayload) {
|
|
5331
|
+
const response = await this.rpcClient.call(
|
|
5332
|
+
"h5:room:proposeMove" /* H5_ROOM_PROPOSE_MOVE */,
|
|
5333
|
+
{
|
|
5334
|
+
roomId: room.id,
|
|
5335
|
+
gameSpecificState: proposalPayload.gameSpecificState,
|
|
5336
|
+
moveType: proposalPayload.moveType,
|
|
5337
|
+
clientContext: proposalPayload.clientContext,
|
|
5338
|
+
clientProposalId: proposalPayload.clientProposalId
|
|
5339
|
+
}
|
|
4652
5340
|
);
|
|
5341
|
+
if (response?.success === false) {
|
|
5342
|
+
throw new Error(response.error || "Failed to propose move");
|
|
5343
|
+
}
|
|
5344
|
+
return response.data;
|
|
4653
5345
|
}
|
|
4654
|
-
|
|
4655
|
-
console.log(`[Venus
|
|
5346
|
+
async validateMove(room, moveId, isValid, reason = null, validatorId = null) {
|
|
5347
|
+
console.log(`[Venus Rooms] Validating move ${moveId}: ${isValid}`);
|
|
5348
|
+
return { success: true, moveId, isValid, reason };
|
|
4656
5349
|
}
|
|
4657
|
-
|
|
4658
|
-
|
|
5350
|
+
async roomSubscribeToGameEvents(room, callback) {
|
|
5351
|
+
"game_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9);
|
|
5352
|
+
if (!this.subscriptions.gameEvents[room.id]) {
|
|
5353
|
+
this.subscriptions.gameEvents[room.id] = [];
|
|
5354
|
+
}
|
|
5355
|
+
this.subscriptions.gameEvents[room.id].push(callback);
|
|
4659
5356
|
}
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
);
|
|
5357
|
+
subscribe(room, options = {}) {
|
|
5358
|
+
const subscriptionIds = [];
|
|
5359
|
+
const roomId = room.id;
|
|
5360
|
+
if (options.onData) {
|
|
5361
|
+
const dataSubId = "data_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9);
|
|
5362
|
+
if (!this.subscriptions.data[roomId]) {
|
|
5363
|
+
this.subscriptions.data[roomId] = [];
|
|
4668
5364
|
}
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
5365
|
+
this.subscriptions.data[roomId].push(options.onData);
|
|
5366
|
+
subscriptionIds.push({
|
|
5367
|
+
type: "data",
|
|
5368
|
+
id: dataSubId,
|
|
5369
|
+
callback: options.onData
|
|
5370
|
+
});
|
|
5371
|
+
}
|
|
5372
|
+
if (options.onMessages) {
|
|
5373
|
+
const msgSubId = "messages_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9);
|
|
5374
|
+
if (!this.subscriptions.messages[roomId]) {
|
|
5375
|
+
this.subscriptions.messages[roomId] = [];
|
|
5376
|
+
}
|
|
5377
|
+
this.subscriptions.messages[roomId].push(options.onMessages);
|
|
5378
|
+
subscriptionIds.push({
|
|
5379
|
+
type: "messages",
|
|
5380
|
+
id: msgSubId,
|
|
5381
|
+
callback: options.onMessages
|
|
5382
|
+
});
|
|
5383
|
+
}
|
|
5384
|
+
if (options.onMoves || options.onGameEvents) {
|
|
5385
|
+
const handler = options.onMoves || options.onGameEvents;
|
|
5386
|
+
if (handler) {
|
|
5387
|
+
const gameSubId = "game_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9);
|
|
5388
|
+
if (!this.subscriptions.gameEvents[roomId]) {
|
|
5389
|
+
this.subscriptions.gameEvents[roomId] = [];
|
|
5390
|
+
}
|
|
5391
|
+
this.subscriptions.gameEvents[roomId].push(handler);
|
|
5392
|
+
subscriptionIds.push({
|
|
5393
|
+
type: "gameEvents",
|
|
5394
|
+
id: gameSubId,
|
|
5395
|
+
callback: handler
|
|
5396
|
+
});
|
|
5397
|
+
}
|
|
5398
|
+
}
|
|
5399
|
+
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;
|
|
5400
|
+
if (needsSubscription) {
|
|
5401
|
+
this.rpcClient.call("H5_ROOM_SUBSCRIBE" /* H5_ROOM_SUBSCRIBE */, {
|
|
5402
|
+
roomId,
|
|
5403
|
+
subscribeToData: !!options.onData,
|
|
5404
|
+
subscribeToMessages: !!options.onMessages,
|
|
5405
|
+
subscribeToProposedMoves: !!(options.onMoves || options.onGameEvents)
|
|
5406
|
+
}).catch((error) => {
|
|
5407
|
+
console.error("Failed to set up room subscription:", error);
|
|
5408
|
+
});
|
|
4674
5409
|
}
|
|
5410
|
+
let called = false;
|
|
5411
|
+
return () => {
|
|
5412
|
+
if (called) return;
|
|
5413
|
+
called = true;
|
|
5414
|
+
subscriptionIds.forEach((sub) => {
|
|
5415
|
+
const bucket = this.subscriptions[sub.type];
|
|
5416
|
+
const callbacks = bucket && bucket[roomId] || [];
|
|
5417
|
+
const index = callbacks.indexOf(sub.callback);
|
|
5418
|
+
if (index > -1) callbacks.splice(index, 1);
|
|
5419
|
+
});
|
|
5420
|
+
const hasNoCallbacks = (this.subscriptions.data[roomId]?.length ?? 0) === 0 && (this.subscriptions.messages[roomId]?.length ?? 0) === 0 && (this.subscriptions.gameEvents[roomId]?.length ?? 0) === 0;
|
|
5421
|
+
if (hasNoCallbacks) {
|
|
5422
|
+
this.rpcClient.call("H5_ROOM_UNSUBSCRIBE" /* H5_ROOM_UNSUBSCRIBE */, {
|
|
5423
|
+
roomId
|
|
5424
|
+
}).catch((error) => {
|
|
5425
|
+
console.error("Failed to clean up room subscription:", error);
|
|
5426
|
+
});
|
|
5427
|
+
}
|
|
5428
|
+
};
|
|
4675
5429
|
}
|
|
4676
5430
|
};
|
|
4677
5431
|
|
|
@@ -4795,6 +5549,7 @@ var RemoteHost = class {
|
|
|
4795
5549
|
venusApi.isMock = () => false;
|
|
4796
5550
|
this.venusApi.sharedAssets = new RpcSharedAssetsApi(rpcClient, venusApi);
|
|
4797
5551
|
initializeRoomsApi(this.venusApi, this);
|
|
5552
|
+
console.log("[Venus SDK] Remote host created");
|
|
4798
5553
|
}
|
|
4799
5554
|
get isInitialized() {
|
|
4800
5555
|
return this._isInitialized;
|
|
@@ -4853,8 +5608,10 @@ var RemoteHost = class {
|
|
|
4853
5608
|
// src/Host.ts
|
|
4854
5609
|
function createHost(venusApi, isMock) {
|
|
4855
5610
|
if (isMock) {
|
|
5611
|
+
console.log("[Venus SDK] Creating Local Host");
|
|
4856
5612
|
return new MockHost(venusApi);
|
|
4857
5613
|
} else {
|
|
5614
|
+
console.log("[Venus SDK] Creating Remote Host");
|
|
4858
5615
|
return new RemoteHost(venusApi);
|
|
4859
5616
|
}
|
|
4860
5617
|
}
|
|
@@ -4867,12 +5624,356 @@ function initializeSocial(venusApi, host) {
|
|
|
4867
5624
|
};
|
|
4868
5625
|
}
|
|
4869
5626
|
|
|
5627
|
+
// src/webview/webviewLibraryShimSource.ts
|
|
5628
|
+
var WEBVIEW_LIBRARY_SHIM_SOURCE = `
|
|
5629
|
+
(function () {
|
|
5630
|
+
if (typeof window === 'undefined') {
|
|
5631
|
+
return;
|
|
5632
|
+
}
|
|
5633
|
+
|
|
5634
|
+
if (window.__venusLibraryShim && window.__venusLibraryShim.__initialized) {
|
|
5635
|
+
return;
|
|
5636
|
+
}
|
|
5637
|
+
|
|
5638
|
+
var RESPONSE_TYPE = 'H5_RESPONSE';
|
|
5639
|
+
var REQUEST_TYPE = 'H5_LOAD_EMBEDDED_ASSET';
|
|
5640
|
+
var REQUEST_TIMEOUT_MS = 12000;
|
|
5641
|
+
var pendingRequests = new Map();
|
|
5642
|
+
|
|
5643
|
+
function ensureConfig() {
|
|
5644
|
+
if (!window.__venusLibrariesConfig) {
|
|
5645
|
+
window.__venusLibrariesConfig = {
|
|
5646
|
+
enabled: false,
|
|
5647
|
+
required: [],
|
|
5648
|
+
manifest: {},
|
|
5649
|
+
cdnBase: ''
|
|
5650
|
+
};
|
|
5651
|
+
}
|
|
5652
|
+
if (!window.__venusLibrariesConfig.manifest) {
|
|
5653
|
+
window.__venusLibrariesConfig.manifest = {};
|
|
5654
|
+
}
|
|
5655
|
+
if (!Array.isArray(window.__venusLibrariesConfig.required)) {
|
|
5656
|
+
window.__venusLibrariesConfig.required = [];
|
|
5657
|
+
}
|
|
5658
|
+
return window.__venusLibrariesConfig;
|
|
5659
|
+
}
|
|
5660
|
+
|
|
5661
|
+
function ensureExportsRegistry() {
|
|
5662
|
+
if (!window.__venusLibraryExports) {
|
|
5663
|
+
window.__venusLibraryExports = {};
|
|
5664
|
+
}
|
|
5665
|
+
return window.__venusLibraryExports;
|
|
5666
|
+
}
|
|
5667
|
+
|
|
5668
|
+
function hasHostBridge() {
|
|
5669
|
+
return !!(window.ReactNativeWebView && typeof window.ReactNativeWebView.postMessage === 'function');
|
|
5670
|
+
}
|
|
5671
|
+
|
|
5672
|
+
function registerResponseListeners() {
|
|
5673
|
+
if (window.__venusLibraryShim && window.__venusLibraryShim.__listenerRegistered) {
|
|
5674
|
+
return;
|
|
5675
|
+
}
|
|
5676
|
+
|
|
5677
|
+
function handleMessage(event) {
|
|
5678
|
+
var payload = parsePayload(event && event.data);
|
|
5679
|
+
if (!payload || payload.type !== RESPONSE_TYPE || !payload.data) {
|
|
5680
|
+
return;
|
|
5681
|
+
}
|
|
5682
|
+
var requestId = payload.data.requestId;
|
|
5683
|
+
if (!requestId || !pendingRequests.has(requestId)) {
|
|
5684
|
+
return;
|
|
5685
|
+
}
|
|
5686
|
+
var pending = pendingRequests.get(requestId);
|
|
5687
|
+
pendingRequests.delete(requestId);
|
|
5688
|
+
clearTimeout(pending.timeout);
|
|
5689
|
+
|
|
5690
|
+
if (payload.data.success === false) {
|
|
5691
|
+
pending.reject(new Error(payload.data.error || 'Embedded library load failed'));
|
|
5692
|
+
return;
|
|
5693
|
+
}
|
|
5694
|
+
|
|
5695
|
+
var value = payload.data.value || payload.data;
|
|
5696
|
+
if (!value || !value.base64Data) {
|
|
5697
|
+
pending.reject(new Error('Embedded library response was missing base64Data'));
|
|
5698
|
+
return;
|
|
5699
|
+
}
|
|
5700
|
+
|
|
5701
|
+
pending.resolve(value.base64Data);
|
|
5702
|
+
}
|
|
5703
|
+
|
|
5704
|
+
if (typeof document !== 'undefined' && typeof document.addEventListener === 'function') {
|
|
5705
|
+
document.addEventListener('message', handleMessage, false);
|
|
5706
|
+
}
|
|
5707
|
+
if (typeof window !== 'undefined' && typeof window.addEventListener === 'function') {
|
|
5708
|
+
window.addEventListener('message', handleMessage, false);
|
|
5709
|
+
}
|
|
5710
|
+
|
|
5711
|
+
if (!window.__venusLibraryShim) {
|
|
5712
|
+
window.__venusLibraryShim = {};
|
|
5713
|
+
}
|
|
5714
|
+
window.__venusLibraryShim.__listenerRegistered = true;
|
|
5715
|
+
}
|
|
5716
|
+
|
|
5717
|
+
function parsePayload(raw) {
|
|
5718
|
+
if (!raw || typeof raw !== 'string') {
|
|
5719
|
+
return null;
|
|
5720
|
+
}
|
|
5721
|
+
try {
|
|
5722
|
+
return JSON.parse(raw);
|
|
5723
|
+
} catch (error) {
|
|
5724
|
+
return null;
|
|
5725
|
+
}
|
|
5726
|
+
}
|
|
5727
|
+
|
|
5728
|
+
function createRequestId(libraryKey) {
|
|
5729
|
+
var sanitized = '';
|
|
5730
|
+
for (var i = 0; i < libraryKey.length; i++) {
|
|
5731
|
+
var c = libraryKey.charAt(i);
|
|
5732
|
+
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c === '-' || c === '_') {
|
|
5733
|
+
sanitized += c;
|
|
5734
|
+
} else {
|
|
5735
|
+
sanitized += '_';
|
|
5736
|
+
}
|
|
5737
|
+
}
|
|
5738
|
+
return 'embedded-lib-' + sanitized + '-' + Date.now() + '-' + Math.random().toString(36).slice(2);
|
|
5739
|
+
}
|
|
5740
|
+
|
|
5741
|
+
function postHostRequest(assetKey, requestId) {
|
|
5742
|
+
if (!hasHostBridge()) {
|
|
5743
|
+
throw new Error('Host bridge is unavailable');
|
|
5744
|
+
}
|
|
5745
|
+
var bridge = window.ReactNativeWebView;
|
|
5746
|
+
var message = {
|
|
5747
|
+
type: REQUEST_TYPE,
|
|
5748
|
+
direction: 'H5_TO_APP',
|
|
5749
|
+
data: {
|
|
5750
|
+
requestId: requestId,
|
|
5751
|
+
assetKey: assetKey
|
|
5752
|
+
},
|
|
5753
|
+
instanceId: (window._venusInitState && window._venusInitState.poolId) || 'unknown',
|
|
5754
|
+
timestamp: Date.now()
|
|
5755
|
+
};
|
|
5756
|
+
bridge.postMessage(JSON.stringify(message));
|
|
5757
|
+
}
|
|
5758
|
+
|
|
5759
|
+
function loadLibraryViaHost(assetKey, libraryKey) {
|
|
5760
|
+
return new Promise(function (resolve, reject) {
|
|
5761
|
+
var requestId = createRequestId(libraryKey);
|
|
5762
|
+
var timeout = setTimeout(function () {
|
|
5763
|
+
pendingRequests.delete(requestId);
|
|
5764
|
+
reject(new Error('Timed out loading embedded library: ' + libraryKey));
|
|
5765
|
+
}, REQUEST_TIMEOUT_MS);
|
|
5766
|
+
|
|
5767
|
+
pendingRequests.set(requestId, { resolve: resolve, reject: reject, timeout: timeout });
|
|
5768
|
+
|
|
5769
|
+
try {
|
|
5770
|
+
postHostRequest(assetKey, requestId);
|
|
5771
|
+
} catch (error) {
|
|
5772
|
+
pendingRequests.delete(requestId);
|
|
5773
|
+
clearTimeout(timeout);
|
|
5774
|
+
reject(error);
|
|
5775
|
+
}
|
|
5776
|
+
});
|
|
5777
|
+
}
|
|
5778
|
+
|
|
5779
|
+
function buildCdnUrl(config, entry) {
|
|
5780
|
+
var base = config.cdnBase || '';
|
|
5781
|
+
if (!base.endsWith('/')) {
|
|
5782
|
+
base += '/';
|
|
5783
|
+
}
|
|
5784
|
+
var path = entry.cdnPath;
|
|
5785
|
+
if (path.charAt(0) === '/') {
|
|
5786
|
+
path = path.substring(1);
|
|
5787
|
+
}
|
|
5788
|
+
return base + path;
|
|
5789
|
+
}
|
|
5790
|
+
|
|
5791
|
+
async function loadLibraryViaCdn(config, entry, libraryKey) {
|
|
5792
|
+
if (!config.cdnBase) {
|
|
5793
|
+
throw new Error('CDN base URL is not configured');
|
|
5794
|
+
}
|
|
5795
|
+
var url = buildCdnUrl(config, entry);
|
|
5796
|
+
var response = await fetch(url, { credentials: 'omit' });
|
|
5797
|
+
if (!response.ok) {
|
|
5798
|
+
throw new Error('Failed to fetch embedded library from CDN: ' + libraryKey);
|
|
5799
|
+
}
|
|
5800
|
+
return await response.text();
|
|
5801
|
+
}
|
|
5802
|
+
|
|
5803
|
+
function decodeBase64ToUtf8(base64) {
|
|
5804
|
+
if (typeof base64 !== 'string') {
|
|
5805
|
+
throw new Error('Invalid base64 payload');
|
|
5806
|
+
}
|
|
5807
|
+
|
|
5808
|
+
if (typeof atob === 'function') {
|
|
5809
|
+
var binary = atob(base64);
|
|
5810
|
+
if (typeof TextDecoder !== 'undefined') {
|
|
5811
|
+
var len = binary.length;
|
|
5812
|
+
var bytes = new Uint8Array(len);
|
|
5813
|
+
for (var i = 0; i < len; i++) {
|
|
5814
|
+
bytes[i] = binary.charCodeAt(i);
|
|
5815
|
+
}
|
|
5816
|
+
return new TextDecoder('utf-8').decode(bytes);
|
|
5817
|
+
}
|
|
5818
|
+
return decodeURIComponent(escape(binary));
|
|
5819
|
+
}
|
|
5820
|
+
|
|
5821
|
+
var bufferCtor = (typeof globalThis !== 'undefined' && globalThis.Buffer) || (typeof window !== 'undefined' && window.Buffer);
|
|
5822
|
+
if (bufferCtor) {
|
|
5823
|
+
return bufferCtor.from(base64, 'base64').toString('utf-8');
|
|
5824
|
+
}
|
|
5825
|
+
|
|
5826
|
+
throw new Error('No base64 decoder available');
|
|
5827
|
+
}
|
|
5828
|
+
|
|
5829
|
+
function evaluateLibrarySource(libraryKey, globalVar, source) {
|
|
5830
|
+
var registry = ensureExportsRegistry();
|
|
5831
|
+
if (!source) {
|
|
5832
|
+
throw new Error('Embedded library source was empty for ' + libraryKey);
|
|
5833
|
+
}
|
|
5834
|
+
|
|
5835
|
+
var previousValue = window[globalVar];
|
|
5836
|
+
try {
|
|
5837
|
+
var executor = new Function(source + '\\n//# sourceURL=venus-library-' + libraryKey + '.js');
|
|
5838
|
+
executor.call(window);
|
|
5839
|
+
} catch (error) {
|
|
5840
|
+
throw new Error('Failed to evaluate embedded library ' + libraryKey + ': ' + (error && error.message ? error.message : error));
|
|
5841
|
+
}
|
|
5842
|
+
|
|
5843
|
+
var exported = window[globalVar] || previousValue;
|
|
5844
|
+
if (!exported) {
|
|
5845
|
+
throw new Error('Embedded library ' + libraryKey + ' did not register ' + globalVar);
|
|
5846
|
+
}
|
|
5847
|
+
|
|
5848
|
+
registry[libraryKey] = exported;
|
|
5849
|
+
return exported;
|
|
5850
|
+
}
|
|
5851
|
+
|
|
5852
|
+
async function ensureLibraryLoaded(config, libraryKey) {
|
|
5853
|
+
var registry = ensureExportsRegistry();
|
|
5854
|
+
if (registry[libraryKey]) {
|
|
5855
|
+
return registry[libraryKey];
|
|
5856
|
+
}
|
|
5857
|
+
|
|
5858
|
+
var entry = config.manifest && config.manifest[libraryKey];
|
|
5859
|
+
if (!entry) {
|
|
5860
|
+
throw new Error('No manifest entry for embedded library ' + libraryKey);
|
|
5861
|
+
}
|
|
5862
|
+
|
|
5863
|
+
var source = null;
|
|
5864
|
+
if (config.useHost !== false && hasHostBridge()) {
|
|
5865
|
+
try {
|
|
5866
|
+
var base64 = await loadLibraryViaHost(entry.assetKey, libraryKey);
|
|
5867
|
+
source = decodeBase64ToUtf8(base64);
|
|
5868
|
+
} catch (error) {
|
|
5869
|
+
// Log the RPC error loudly before fallback
|
|
5870
|
+
console.error('[Venus Libraries] Failed to load ' + libraryKey + ' from host via RPC:', error);
|
|
5871
|
+
console.warn('[Venus Libraries] Falling back to CDN for ' + libraryKey + '. This may indicate an asset packaging issue.');
|
|
5872
|
+
}
|
|
5873
|
+
}
|
|
5874
|
+
|
|
5875
|
+
if (!source) {
|
|
5876
|
+
source = await loadLibraryViaCdn(config, entry, libraryKey);
|
|
5877
|
+
}
|
|
5878
|
+
|
|
5879
|
+
return evaluateLibrarySource(libraryKey, entry.globalVar, source);
|
|
5880
|
+
}
|
|
5881
|
+
|
|
5882
|
+
async function bootstrap() {
|
|
5883
|
+
try {
|
|
5884
|
+
registerResponseListeners();
|
|
5885
|
+
getBootstrapPromise();
|
|
5886
|
+
|
|
5887
|
+
var config = ensureConfig();
|
|
5888
|
+
|
|
5889
|
+
if (!config.enabled) {
|
|
5890
|
+
if (bootstrapResolve) bootstrapResolve();
|
|
5891
|
+
return;
|
|
5892
|
+
}
|
|
5893
|
+
|
|
5894
|
+
if (!Array.isArray(config.required) || config.required.length === 0) {
|
|
5895
|
+
if (bootstrapResolve) bootstrapResolve();
|
|
5896
|
+
return;
|
|
5897
|
+
}
|
|
5898
|
+
|
|
5899
|
+
// Group libraries by load stage for parallel loading within stages
|
|
5900
|
+
var librariesByStage = {};
|
|
5901
|
+
for (var i = 0; i < config.required.length; i++) {
|
|
5902
|
+
var libraryKey = config.required[i];
|
|
5903
|
+
var entry = config.manifest[libraryKey];
|
|
5904
|
+
var stage = entry.loadStage || 0;
|
|
5905
|
+
if (!librariesByStage[stage]) librariesByStage[stage] = [];
|
|
5906
|
+
librariesByStage[stage].push(libraryKey);
|
|
5907
|
+
}
|
|
5908
|
+
|
|
5909
|
+
// Load stages sequentially, libraries within each stage in parallel
|
|
5910
|
+
var stages = Object.keys(librariesByStage).sort(function(a, b) {
|
|
5911
|
+
return parseInt(a, 10) - parseInt(b, 10);
|
|
5912
|
+
});
|
|
5913
|
+
|
|
5914
|
+
for (var s = 0; s < stages.length; s++) {
|
|
5915
|
+
var stage = stages[s];
|
|
5916
|
+
var libs = librariesByStage[stage];
|
|
5917
|
+
|
|
5918
|
+
// Load all libraries in this stage in parallel
|
|
5919
|
+
var stagePromises = libs.map(function(libraryKey) {
|
|
5920
|
+
return ensureLibraryLoaded(config, libraryKey).catch(function(error) {
|
|
5921
|
+
console.error('[Venus Libraries] Failed to load library ' + libraryKey, error);
|
|
5922
|
+
throw error;
|
|
5923
|
+
});
|
|
5924
|
+
});
|
|
5925
|
+
|
|
5926
|
+
await Promise.all(stagePromises);
|
|
5927
|
+
}
|
|
5928
|
+
|
|
5929
|
+
if (bootstrapResolve) bootstrapResolve();
|
|
5930
|
+
} catch (error) {
|
|
5931
|
+
console.error('[Venus Libraries] Bootstrap error', error);
|
|
5932
|
+
if (bootstrapReject) bootstrapReject(error);
|
|
5933
|
+
throw error;
|
|
5934
|
+
}
|
|
5935
|
+
}
|
|
5936
|
+
|
|
5937
|
+
// Create a promise that resolves when bootstrap completes
|
|
5938
|
+
var bootstrapPromise = null;
|
|
5939
|
+
var bootstrapResolve = null;
|
|
5940
|
+
var bootstrapReject = null;
|
|
5941
|
+
|
|
5942
|
+
function getBootstrapPromise() {
|
|
5943
|
+
if (!bootstrapPromise) {
|
|
5944
|
+
bootstrapPromise = new Promise(function(resolve, reject) {
|
|
5945
|
+
bootstrapResolve = resolve;
|
|
5946
|
+
bootstrapReject = reject;
|
|
5947
|
+
});
|
|
5948
|
+
}
|
|
5949
|
+
return bootstrapPromise;
|
|
5950
|
+
}
|
|
5951
|
+
|
|
5952
|
+
window.__venusLibraryShim = {
|
|
5953
|
+
bootstrap: bootstrap,
|
|
5954
|
+
ready: getBootstrapPromise,
|
|
5955
|
+
getExports: function (libraryKey) {
|
|
5956
|
+
var registry = ensureExportsRegistry();
|
|
5957
|
+
return registry[libraryKey];
|
|
5958
|
+
},
|
|
5959
|
+
__initialized: true,
|
|
5960
|
+
};
|
|
5961
|
+
})();
|
|
5962
|
+
`;
|
|
5963
|
+
function getWebviewLibraryShimSource() {
|
|
5964
|
+
return WEBVIEW_LIBRARY_SHIM_SOURCE;
|
|
5965
|
+
}
|
|
5966
|
+
|
|
5967
|
+
exports.DEFAULT_SHARED_LIB_CDN_BASE = DEFAULT_SHARED_LIB_CDN_BASE;
|
|
5968
|
+
exports.EMBEDDED_LIBRARIES = EMBEDDED_LIBRARIES;
|
|
5969
|
+
exports.EMBEDDED_LIBRARY_BY_KEY = EMBEDDED_LIBRARY_BY_KEY;
|
|
4870
5970
|
exports.HASH_ALGORITHM_NODE = HASH_ALGORITHM_NODE;
|
|
4871
5971
|
exports.HASH_ALGORITHM_WEB_CRYPTO = HASH_ALGORITHM_WEB_CRYPTO;
|
|
4872
5972
|
exports.HapticFeedbackStyle = HapticFeedbackStyle;
|
|
4873
5973
|
exports.HostCdnApi = HostCdnApi;
|
|
4874
5974
|
exports.HostProfileApi = HostProfileApi;
|
|
4875
5975
|
exports.HostTimeApi = HostTimeApi;
|
|
5976
|
+
exports.MODULE_TO_LIBRARY_SPECIFIERS = MODULE_TO_LIBRARY_SPECIFIERS;
|
|
4876
5977
|
exports.MockAdsApi = MockAdsApi;
|
|
4877
5978
|
exports.MockAiApi = MockAiApi;
|
|
4878
5979
|
exports.MockAnalyticsApi = MockAnalyticsApi;
|
|
@@ -4890,6 +5991,7 @@ exports.MockPopupsApi = MockPopupsApi;
|
|
|
4890
5991
|
exports.MockPreloaderApi = MockPreloaderApi;
|
|
4891
5992
|
exports.MockProfileApi = MockProfileApi;
|
|
4892
5993
|
exports.MockSharedAssetsApi = MockSharedAssetsApi;
|
|
5994
|
+
exports.MockSimulationApi = MockSimulationApi;
|
|
4893
5995
|
exports.MockSocialApi = MockSocialApi;
|
|
4894
5996
|
exports.MockStorageApi = MockStorageApi;
|
|
4895
5997
|
exports.MockTimeApi = MockTimeApi;
|
|
@@ -4909,17 +6011,20 @@ exports.RpcNavigationApi = RpcNavigationApi;
|
|
|
4909
6011
|
exports.RpcNotificationsApi = RpcNotificationsApi;
|
|
4910
6012
|
exports.RpcPopupsApi = RpcPopupsApi;
|
|
4911
6013
|
exports.RpcPreloaderApi = RpcPreloaderApi;
|
|
4912
|
-
exports.RpcRoomsApi = RpcRoomsApi;
|
|
4913
6014
|
exports.RpcSharedAssetsApi = RpcSharedAssetsApi;
|
|
4914
6015
|
exports.RpcSimulationApi = RpcSimulationApi;
|
|
4915
6016
|
exports.RpcSocialApi = RpcSocialApi;
|
|
4916
6017
|
exports.RpcStorageApi = RpcStorageApi;
|
|
4917
6018
|
exports.SDK_VERSION = SDK_VERSION;
|
|
4918
6019
|
exports.VenusMessageId = VenusMessageId;
|
|
4919
|
-
exports.
|
|
6020
|
+
exports.WEBVIEW_LIBRARY_SHIM_SOURCE = WEBVIEW_LIBRARY_SHIM_SOURCE;
|
|
6021
|
+
exports.base64ToArrayBuffer = base64ToArrayBuffer;
|
|
6022
|
+
exports.base64ToUtf8 = base64ToUtf8;
|
|
4920
6023
|
exports.computeScoreHash = computeScoreHash;
|
|
4921
6024
|
exports.createHost = createHost;
|
|
4922
6025
|
exports.createMockStorageApi = createMockStorageApi;
|
|
6026
|
+
exports.getLibraryDefinition = getLibraryDefinition;
|
|
6027
|
+
exports.getWebviewLibraryShimSource = getWebviewLibraryShimSource;
|
|
4923
6028
|
exports.initializeAds = initializeAds;
|
|
4924
6029
|
exports.initializeAi = initializeAi;
|
|
4925
6030
|
exports.initializeAnalytics = initializeAnalytics;
|