@series-inc/venus-sdk 3.1.1-beta.0 → 3.1.1
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/dist/{AdsApi-meVfUcZy.d.mts → AdsApi-BV_VKgMO.d.mts} +467 -269
- package/dist/{AdsApi-meVfUcZy.d.ts → AdsApi-BV_VKgMO.d.ts} +467 -269
- package/dist/{chunk-EMVTVSGL.mjs → chunk-FTIFUYDL.mjs} +978 -1412
- package/dist/chunk-FTIFUYDL.mjs.map +1 -0
- package/dist/chunk-NSSMTXJJ.mjs +7 -0
- package/dist/{chunk-2PDL7CQK.mjs.map → chunk-NSSMTXJJ.mjs.map} +1 -1
- package/dist/chunk-UXY5CKKG.mjs +12 -0
- package/dist/chunk-UXY5CKKG.mjs.map +1 -0
- package/dist/{core-5JLON75E.mjs → core-62LWDHN7.mjs} +3 -3
- package/dist/{core-5JLON75E.mjs.map → core-62LWDHN7.mjs.map} +1 -1
- package/dist/index.cjs +1018 -1783
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +142 -68
- package/dist/index.d.ts +142 -68
- package/dist/index.mjs +3 -7
- package/dist/index.mjs.map +1 -1
- package/dist/venus-api/index.cjs +1091 -1883
- 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 +76 -418
- package/dist/venus-api/index.mjs.map +1 -1
- package/dist/vite/index.cjs.map +1 -1
- package/dist/vite/index.mjs.map +1 -1
- package/dist/webview/index.cjs +4 -335
- package/dist/webview/index.cjs.map +1 -1
- package/dist/webview/index.d.mts +7 -9
- package/dist/webview/index.d.ts +7 -9
- package/dist/webview/index.mjs +2 -2
- package/package.json +1 -1
- package/dist/chunk-2PDL7CQK.mjs +0 -26
- package/dist/chunk-EMVTVSGL.mjs.map +0 -1
- package/dist/chunk-IZLOB7DV.mjs +0 -343
- package/dist/chunk-IZLOB7DV.mjs.map +0 -1
package/dist/venus-api/index.cjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
6
|
var __esm = (fn, res) => function __init() {
|
|
9
7
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
@@ -12,15 +10,6 @@ var __export = (target, all) => {
|
|
|
12
10
|
for (var name in all)
|
|
13
11
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
12
|
};
|
|
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);
|
|
24
13
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
25
14
|
|
|
26
15
|
// src/venus-api/systems/core.js
|
|
@@ -111,221 +100,6 @@ var init_core = __esm({
|
|
|
111
100
|
}
|
|
112
101
|
});
|
|
113
102
|
|
|
114
|
-
// src/rooms/RoomsApi.ts
|
|
115
|
-
var init_RoomsApi = __esm({
|
|
116
|
-
"src/rooms/RoomsApi.ts"() {
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
// src/rooms/VenusRoom.ts
|
|
121
|
-
var VenusRoom;
|
|
122
|
-
var init_VenusRoom = __esm({
|
|
123
|
-
"src/rooms/VenusRoom.ts"() {
|
|
124
|
-
VenusRoom = class {
|
|
125
|
-
constructor(roomData) {
|
|
126
|
-
__publicField(this, "id");
|
|
127
|
-
__publicField(this, "name");
|
|
128
|
-
__publicField(this, "players");
|
|
129
|
-
__publicField(this, "maxPlayers");
|
|
130
|
-
__publicField(this, "gameType");
|
|
131
|
-
__publicField(this, "appId");
|
|
132
|
-
__publicField(this, "type");
|
|
133
|
-
__publicField(this, "createdBy");
|
|
134
|
-
__publicField(this, "createdAt");
|
|
135
|
-
__publicField(this, "updatedAt");
|
|
136
|
-
__publicField(this, "isPrivate");
|
|
137
|
-
__publicField(this, "currentPlayers");
|
|
138
|
-
__publicField(this, "status");
|
|
139
|
-
__publicField(this, "customMetadata");
|
|
140
|
-
__publicField(this, "admins");
|
|
141
|
-
__publicField(this, "roomCode");
|
|
142
|
-
__publicField(this, "description");
|
|
143
|
-
__publicField(this, "data");
|
|
144
|
-
__publicField(this, "version");
|
|
145
|
-
__publicField(this, "_subscriptions", /* @__PURE__ */ new Map());
|
|
146
|
-
this.id = roomData.id;
|
|
147
|
-
this.name = roomData.name;
|
|
148
|
-
this.players = roomData.currentPlayers || [];
|
|
149
|
-
this.maxPlayers = roomData.maxPlayers;
|
|
150
|
-
this.gameType = roomData.gameType;
|
|
151
|
-
this.appId = roomData.appId;
|
|
152
|
-
this.type = roomData.type;
|
|
153
|
-
this.createdBy = roomData.createdBy;
|
|
154
|
-
this.createdAt = roomData.createdAt;
|
|
155
|
-
this.updatedAt = roomData.updatedAt;
|
|
156
|
-
this.isPrivate = roomData.isPrivate;
|
|
157
|
-
this.currentPlayers = roomData.currentPlayers || [];
|
|
158
|
-
this.status = roomData.status;
|
|
159
|
-
this.customMetadata = roomData.customMetadata || {};
|
|
160
|
-
this.admins = roomData.admins || [];
|
|
161
|
-
this.roomCode = roomData.roomCode;
|
|
162
|
-
this.description = roomData.description;
|
|
163
|
-
this.data = roomData.data || {};
|
|
164
|
-
this.version = roomData.version;
|
|
165
|
-
console.log(`VenusRoom: Created room object for ${this.id}`, {
|
|
166
|
-
hasCustomMetadata: !!this.customMetadata,
|
|
167
|
-
hasGameState: !!this.customMetadata?.rules?.gameState,
|
|
168
|
-
gamePhase: this.customMetadata?.rules?.gameState?.phase,
|
|
169
|
-
currentPlayer: this.customMetadata?.rules?.gameState?.currentPlayer
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
updateFromRoomData(newRoomData) {
|
|
173
|
-
if (newRoomData.id === this.id) {
|
|
174
|
-
this.name = newRoomData.name || this.name;
|
|
175
|
-
this.players = newRoomData.currentPlayers || this.players;
|
|
176
|
-
this.maxPlayers = newRoomData.maxPlayers || this.maxPlayers;
|
|
177
|
-
this.gameType = newRoomData.gameType || this.gameType;
|
|
178
|
-
this.currentPlayers = newRoomData.currentPlayers || this.currentPlayers;
|
|
179
|
-
this.customMetadata = newRoomData.customMetadata || this.customMetadata;
|
|
180
|
-
this.data = newRoomData.data || this.data;
|
|
181
|
-
this.status = newRoomData.status || this.status;
|
|
182
|
-
this.updatedAt = newRoomData.updatedAt || this.updatedAt;
|
|
183
|
-
console.log(`VenusRoom: Updated room object ${this.id} with fresh data`, {
|
|
184
|
-
hasCustomMetadata: !!this.customMetadata,
|
|
185
|
-
hasGameState: !!this.customMetadata?.rules?.gameState,
|
|
186
|
-
gamePhase: this.customMetadata?.rules?.gameState?.phase,
|
|
187
|
-
currentPlayer: this.customMetadata?.rules?.gameState?.currentPlayer
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
// src/rooms/index.ts
|
|
196
|
-
var rooms_exports = {};
|
|
197
|
-
__export(rooms_exports, {
|
|
198
|
-
VenusRoom: () => VenusRoom,
|
|
199
|
-
initializeRoomsApi: () => initializeRoomsApi,
|
|
200
|
-
setupRoomNotifications: () => setupRoomNotifications
|
|
201
|
-
});
|
|
202
|
-
function bindMethod(target, targetKey, source, sourceKey) {
|
|
203
|
-
const key = sourceKey ?? targetKey;
|
|
204
|
-
const fn = source?.[key];
|
|
205
|
-
if (typeof fn === "function") {
|
|
206
|
-
target[targetKey] = fn.bind(source);
|
|
207
|
-
return true;
|
|
208
|
-
}
|
|
209
|
-
return false;
|
|
210
|
-
}
|
|
211
|
-
function setupRoomNotifications(transport, getSubscriptions) {
|
|
212
|
-
console.log("[Venus Rooms] Setting up room notification listeners");
|
|
213
|
-
return transport.onVenusMessage((message) => {
|
|
214
|
-
const subscriptions = getSubscriptions();
|
|
215
|
-
if (!subscriptions) {
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
if (message.type === "H5_ROOM_DATA_UPDATED") {
|
|
219
|
-
const messageData = message.data;
|
|
220
|
-
const { roomId, roomData } = messageData;
|
|
221
|
-
if (!roomId) return;
|
|
222
|
-
const callbacks = subscriptions.data?.[roomId] || [];
|
|
223
|
-
const allEventsCallbacks = subscriptions.allEvents?.[roomId] || [];
|
|
224
|
-
console.log(`[Venus Rooms] \u{1F514} Room data updated for ${roomId}, notifying ${callbacks.length} callbacks`, roomData);
|
|
225
|
-
callbacks.forEach((callback) => {
|
|
226
|
-
try {
|
|
227
|
-
callback(roomData);
|
|
228
|
-
} catch (error) {
|
|
229
|
-
console.error("[Venus Rooms] Error in room data callback:", error);
|
|
230
|
-
throw error;
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
allEventsCallbacks.forEach((callback) => {
|
|
234
|
-
try {
|
|
235
|
-
callback({ type: message.type, ...messageData });
|
|
236
|
-
} catch (error) {
|
|
237
|
-
console.error("[Venus Rooms] Error in allEvents callback:", error);
|
|
238
|
-
throw error;
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
if (message.type === "H5_ROOM_MESSAGE_RECEIVED" || message.type === "H5_ROOM_MESSAGE_UPDATED" || message.type === "H5_ROOM_MESSAGE_DELETED") {
|
|
243
|
-
const messageData = message.data;
|
|
244
|
-
const { roomId } = messageData;
|
|
245
|
-
if (!roomId) return;
|
|
246
|
-
const callbacks = subscriptions.messages?.[roomId] || [];
|
|
247
|
-
const allEventsCallbacks = subscriptions.allEvents?.[roomId] || [];
|
|
248
|
-
console.log(`[Venus Rooms] \u{1F514} Room message event for ${roomId}, notifying ${callbacks.length} callbacks`);
|
|
249
|
-
callbacks.forEach((callback) => {
|
|
250
|
-
try {
|
|
251
|
-
callback(messageData);
|
|
252
|
-
} catch (error) {
|
|
253
|
-
console.error("[Venus Rooms] Error in room message callback:", error);
|
|
254
|
-
throw error;
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
allEventsCallbacks.forEach((callback) => {
|
|
258
|
-
try {
|
|
259
|
-
callback({ type: message.type, ...messageData });
|
|
260
|
-
} catch (error) {
|
|
261
|
-
console.error("[Venus Rooms] Error in allEvents callback:", error);
|
|
262
|
-
throw error;
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
if (message.type === "app:h5:proposedMoveValidationUpdated") {
|
|
267
|
-
const messageData = message.data;
|
|
268
|
-
const { roomId } = messageData;
|
|
269
|
-
if (!roomId) return;
|
|
270
|
-
const callbacks = subscriptions.gameEvents?.[roomId] || [];
|
|
271
|
-
const allEventsCallbacks = subscriptions.allEvents?.[roomId] || [];
|
|
272
|
-
console.log(`[Venus Rooms] \u{1F514} Proposed move validation updated for ${roomId}, notifying ${callbacks.length} callbacks`);
|
|
273
|
-
callbacks.forEach((callback) => {
|
|
274
|
-
try {
|
|
275
|
-
callback(messageData);
|
|
276
|
-
} catch (error) {
|
|
277
|
-
console.error("[Venus Rooms] Error in game event callback:", error);
|
|
278
|
-
throw error;
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
allEventsCallbacks.forEach((callback) => {
|
|
282
|
-
try {
|
|
283
|
-
callback({ type: message.type, ...messageData });
|
|
284
|
-
} catch (error) {
|
|
285
|
-
console.error("[Venus Rooms] Error in allEvents callback:", error);
|
|
286
|
-
throw error;
|
|
287
|
-
}
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
function initializeRoomsApi(venusApi, host) {
|
|
293
|
-
const roomsApi = host?.rooms;
|
|
294
|
-
if (!roomsApi) {
|
|
295
|
-
console.warn(
|
|
296
|
-
"[Venus SDK] Host did not provide a rooms implementation. Rooms API will be unavailable."
|
|
297
|
-
);
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
const venus = venusApi;
|
|
301
|
-
const existingNamespace = venus.rooms || {};
|
|
302
|
-
const roomsNamespace = Object.assign({}, existingNamespace);
|
|
303
|
-
const namespaceBindings = [
|
|
304
|
-
["create", "createRoom"],
|
|
305
|
-
["joinOrCreate", "joinOrCreateRoom"],
|
|
306
|
-
["joinByCode", "joinRoomByCode"],
|
|
307
|
-
["list", "getUserRooms"],
|
|
308
|
-
["subscribeToRoom", "subscribe"],
|
|
309
|
-
["updateRoomData", "updateData"],
|
|
310
|
-
["getRoomData", "getData"],
|
|
311
|
-
["sendRoomMessage", "sendMessage"],
|
|
312
|
-
["leaveRoom", "leave"],
|
|
313
|
-
["startRoomGame", "startGame"],
|
|
314
|
-
["proposeMove"],
|
|
315
|
-
["validateMove"]
|
|
316
|
-
];
|
|
317
|
-
namespaceBindings.forEach(([targetKey, sourceKey]) => {
|
|
318
|
-
bindMethod(roomsNamespace, targetKey, roomsApi, sourceKey);
|
|
319
|
-
});
|
|
320
|
-
venus.rooms = roomsNamespace;
|
|
321
|
-
}
|
|
322
|
-
var init_rooms = __esm({
|
|
323
|
-
"src/rooms/index.ts"() {
|
|
324
|
-
init_RoomsApi();
|
|
325
|
-
init_VenusRoom();
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
|
|
329
103
|
// src/storage/MockStorageApi.ts
|
|
330
104
|
function createMockStorageApi(storageType, appUrl) {
|
|
331
105
|
const appIdentifier = appUrl ? generateAppIdentifier(appUrl) : null;
|
|
@@ -635,190 +409,6 @@ function initializeAds(venusApiInstance, host) {
|
|
|
635
409
|
venusApiInstance.ads = host.ads;
|
|
636
410
|
}
|
|
637
411
|
|
|
638
|
-
// src/venus-api/systems/theme.js
|
|
639
|
-
init_core();
|
|
640
|
-
var DEFAULT_TYPOGRAPHY = {
|
|
641
|
-
fontFamily: {
|
|
642
|
-
base: "Plus Jakarta Sans, Roboto, sans-serif",
|
|
643
|
-
heading: "Plus Jakarta Sans, Roboto, sans-serif",
|
|
644
|
-
mono: "monospace"
|
|
645
|
-
},
|
|
646
|
-
fontSize: {
|
|
647
|
-
"2xs": "10px",
|
|
648
|
-
xs: "12px",
|
|
649
|
-
sm: "14px",
|
|
650
|
-
md: "16px",
|
|
651
|
-
lg: "18px",
|
|
652
|
-
xl: "20px",
|
|
653
|
-
"2xl": "24px",
|
|
654
|
-
"3xl": "30px",
|
|
655
|
-
"4xl": "36px",
|
|
656
|
-
"5xl": "48px",
|
|
657
|
-
"6xl": "60px"
|
|
658
|
-
},
|
|
659
|
-
fontWeight: {
|
|
660
|
-
thin: "100",
|
|
661
|
-
extralight: "200",
|
|
662
|
-
light: "300",
|
|
663
|
-
regular: "400",
|
|
664
|
-
medium: "500",
|
|
665
|
-
semibold: "600",
|
|
666
|
-
bold: "700",
|
|
667
|
-
extrabold: "800",
|
|
668
|
-
black: "900",
|
|
669
|
-
extrablack: "950"
|
|
670
|
-
},
|
|
671
|
-
lineHeight: {
|
|
672
|
-
none: "1",
|
|
673
|
-
tight: "1.25",
|
|
674
|
-
snug: "1.375",
|
|
675
|
-
normal: "1.5",
|
|
676
|
-
relaxed: "1.625",
|
|
677
|
-
loose: "2"
|
|
678
|
-
}
|
|
679
|
-
};
|
|
680
|
-
var DEFAULT_THEME = {
|
|
681
|
-
background: {
|
|
682
|
-
default: "#131419",
|
|
683
|
-
// Dark background
|
|
684
|
-
muted: "#1b1d25",
|
|
685
|
-
// Mid-dark background
|
|
686
|
-
dark: "#0d0e11"
|
|
687
|
-
// Darker background
|
|
688
|
-
},
|
|
689
|
-
text: {
|
|
690
|
-
primary: "#ffffff",
|
|
691
|
-
// White
|
|
692
|
-
muted: "#808080",
|
|
693
|
-
// Gray
|
|
694
|
-
inverted: "#000000"
|
|
695
|
-
// Black
|
|
696
|
-
},
|
|
697
|
-
theme: {
|
|
698
|
-
primary: "#f6c833",
|
|
699
|
-
// Different yellow for testing (slightly lighter)
|
|
700
|
-
secondary: "#6366f1",
|
|
701
|
-
// Different secondary for testing (purple)
|
|
702
|
-
background: "#131419",
|
|
703
|
-
// Dark background
|
|
704
|
-
border: "#262626",
|
|
705
|
-
// Dark border
|
|
706
|
-
card: "#1b1d25",
|
|
707
|
-
// Dark card
|
|
708
|
-
"card-glass": "rgba(27, 29, 37, 0.8)"
|
|
709
|
-
// Translucent dark card
|
|
710
|
-
},
|
|
711
|
-
typography: DEFAULT_TYPOGRAPHY
|
|
712
|
-
};
|
|
713
|
-
function initializeTheme(venusApiInstance) {
|
|
714
|
-
if (!venusApiInstance._mock.theme) {
|
|
715
|
-
venusApiInstance._mock.theme = DEFAULT_THEME;
|
|
716
|
-
}
|
|
717
|
-
if (!venusApiInstance._mock.typography) {
|
|
718
|
-
venusApiInstance._mock.typography = DEFAULT_TYPOGRAPHY;
|
|
719
|
-
}
|
|
720
|
-
if (!venusApiInstance._mock.safeArea) {
|
|
721
|
-
venusApiInstance._mock.safeArea = { top: 0, bottom: 0, left: 0, right: 0 };
|
|
722
|
-
}
|
|
723
|
-
venusApiInstance.applyVenusThemeToCSS = function(theme) {
|
|
724
|
-
if (!theme) return;
|
|
725
|
-
const root = document.documentElement;
|
|
726
|
-
if (theme.background) {
|
|
727
|
-
if (theme.background.default)
|
|
728
|
-
root.style.setProperty("--color-background", theme.background.default);
|
|
729
|
-
if (theme.background.muted)
|
|
730
|
-
root.style.setProperty(
|
|
731
|
-
"--color-background-muted",
|
|
732
|
-
theme.background.muted
|
|
733
|
-
);
|
|
734
|
-
if (theme.background.dark)
|
|
735
|
-
root.style.setProperty(
|
|
736
|
-
"--color-background-dark",
|
|
737
|
-
theme.background.dark
|
|
738
|
-
);
|
|
739
|
-
}
|
|
740
|
-
if (theme.text) {
|
|
741
|
-
if (theme.text.primary)
|
|
742
|
-
root.style.setProperty("--color-text-primary", theme.text.primary);
|
|
743
|
-
if (theme.text.muted)
|
|
744
|
-
root.style.setProperty("--color-text-muted", theme.text.muted);
|
|
745
|
-
}
|
|
746
|
-
if (theme.theme) {
|
|
747
|
-
if (theme.theme.primary)
|
|
748
|
-
root.style.setProperty("--color-primary", theme.theme.primary);
|
|
749
|
-
if (theme.theme.secondary)
|
|
750
|
-
root.style.setProperty("--color-secondary", theme.theme.secondary);
|
|
751
|
-
if (theme.theme.border)
|
|
752
|
-
root.style.setProperty("--color-border", theme.theme.border);
|
|
753
|
-
}
|
|
754
|
-
if (theme.typography && theme.typography.fontFamily) {
|
|
755
|
-
if (theme.typography.fontFamily.base) {
|
|
756
|
-
root.style.setProperty(
|
|
757
|
-
"--font-family",
|
|
758
|
-
theme.typography.fontFamily.base
|
|
759
|
-
);
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
document.body.style.backgroundColor = root.style.getPropertyValue(
|
|
763
|
-
"--color-background-dark"
|
|
764
|
-
);
|
|
765
|
-
};
|
|
766
|
-
venusApiInstance.applyTheme = createProxiedMethod("applyTheme", function() {
|
|
767
|
-
let apiTheme = null;
|
|
768
|
-
apiTheme = this.config.theme;
|
|
769
|
-
if (apiTheme) {
|
|
770
|
-
this.applyVenusThemeToCSS(apiTheme);
|
|
771
|
-
this.colors = {
|
|
772
|
-
primary: apiTheme.theme?.primary || "#FF2877",
|
|
773
|
-
secondary: apiTheme.theme?.secondary || "#4755FF",
|
|
774
|
-
dark: apiTheme.background?.dark || "#0D0E11",
|
|
775
|
-
darkLight: apiTheme.background?.muted || "#1B1D25",
|
|
776
|
-
darkLighter: apiTheme.background?.default || "#23252F",
|
|
777
|
-
textPrimary: apiTheme.text?.primary || "#FFFFFF",
|
|
778
|
-
textMuted: apiTheme.text?.muted || "#808080",
|
|
779
|
-
border: apiTheme.theme?.border || "#262626"
|
|
780
|
-
};
|
|
781
|
-
} else {
|
|
782
|
-
this.colors = {
|
|
783
|
-
primary: "#FF2877",
|
|
784
|
-
secondary: "#4755FF",
|
|
785
|
-
dark: "#0D0E11",
|
|
786
|
-
darkLight: "#1B1D25",
|
|
787
|
-
darkLighter: "#23252F",
|
|
788
|
-
textPrimary: "#FFFFFF",
|
|
789
|
-
textMuted: "#808080",
|
|
790
|
-
border: "#262626"
|
|
791
|
-
};
|
|
792
|
-
}
|
|
793
|
-
this.log("Theme applied successfully");
|
|
794
|
-
});
|
|
795
|
-
venusApiInstance.applySafeArea = createProxiedMethod("applySafeArea", function() {
|
|
796
|
-
try {
|
|
797
|
-
const safeArea = this.config.ui.safeArea;
|
|
798
|
-
if (safeArea) {
|
|
799
|
-
this.log("Applying safe area insets: " + JSON.stringify(safeArea));
|
|
800
|
-
if (this.tapToStartScreen) {
|
|
801
|
-
this.tapToStartScreen.style.marginTop = `${safeArea.top}px`;
|
|
802
|
-
this.tapToStartScreen.style.marginBottom = `${safeArea.bottom}px`;
|
|
803
|
-
}
|
|
804
|
-
if (this.gameOverScreen) {
|
|
805
|
-
this.gameOverScreen.style.marginTop = `${safeArea.top}px`;
|
|
806
|
-
this.gameOverScreen.style.marginBottom = `${safeArea.bottom}px`;
|
|
807
|
-
}
|
|
808
|
-
if (this.maxScoreContainer) {
|
|
809
|
-
this.maxScoreContainer.style.marginTop = `${safeArea.top}px`;
|
|
810
|
-
this.maxScoreContainer.style.marginRight = `${safeArea.right}px`;
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
} catch (error) {
|
|
814
|
-
this.error("Error applying safe area: " + error.message);
|
|
815
|
-
console.error("Error applying safe area:", error);
|
|
816
|
-
}
|
|
817
|
-
});
|
|
818
|
-
venusApiInstance.DEFAULT_THEME = DEFAULT_THEME;
|
|
819
|
-
venusApiInstance.DEFAULT_TYPOGRAPHY = DEFAULT_TYPOGRAPHY;
|
|
820
|
-
}
|
|
821
|
-
|
|
822
412
|
// src/popups/RpcPopupsApi.ts
|
|
823
413
|
var RpcPopupsApi = class {
|
|
824
414
|
constructor(rpcClient) {
|
|
@@ -971,13 +561,8 @@ var MockNotificationsApi = class {
|
|
|
971
561
|
async cancelNotification(notificationId) {
|
|
972
562
|
const venusApi = this.venusApi;
|
|
973
563
|
if (isWebPlatform()) {
|
|
974
|
-
console.log(
|
|
975
|
-
"[Venus Mock] Cancel notification on web platform (simulated):",
|
|
976
|
-
notificationId
|
|
977
|
-
);
|
|
978
564
|
return true;
|
|
979
565
|
}
|
|
980
|
-
console.log("[Venus Mock] Cancel local notification:", notificationId);
|
|
981
566
|
await createMockDelay(MOCK_DELAYS.short);
|
|
982
567
|
if (venusApi._mock.scheduledNotifications && venusApi._mock.scheduledNotifications[notificationId]) {
|
|
983
568
|
delete venusApi._mock.scheduledNotifications[notificationId];
|
|
@@ -987,12 +572,8 @@ var MockNotificationsApi = class {
|
|
|
987
572
|
}
|
|
988
573
|
async getAllScheduledLocalNotifications() {
|
|
989
574
|
if (isWebPlatform()) {
|
|
990
|
-
console.log(
|
|
991
|
-
"[Venus Mock] Get notifications on web platform (returning empty list)"
|
|
992
|
-
);
|
|
993
575
|
return [];
|
|
994
576
|
}
|
|
995
|
-
console.log("[Venus Mock] Get all scheduled local notifications");
|
|
996
577
|
await createMockDelay(MOCK_DELAYS.short);
|
|
997
578
|
const venusApi = this.venusApi;
|
|
998
579
|
const notifications = venusApi._mock.scheduledNotifications || {};
|
|
@@ -1000,10 +581,8 @@ var MockNotificationsApi = class {
|
|
|
1000
581
|
}
|
|
1001
582
|
async isLocalNotificationsEnabled() {
|
|
1002
583
|
if (isWebPlatform()) {
|
|
1003
|
-
console.log("[Venus Mock] Notifications not available on web platform");
|
|
1004
584
|
return false;
|
|
1005
585
|
}
|
|
1006
|
-
console.log("[Venus Mock] Check if local notifications are enabled");
|
|
1007
586
|
await createMockDelay(MOCK_DELAYS.short);
|
|
1008
587
|
const venusApi = this.venusApi;
|
|
1009
588
|
const isEnabled = venusApi._mock.notificationsEnabled !== false;
|
|
@@ -1012,9 +591,6 @@ var MockNotificationsApi = class {
|
|
|
1012
591
|
async scheduleAsync(title, body, seconds, notificationId, options) {
|
|
1013
592
|
const { priority = 50, groupId, payload } = options || {};
|
|
1014
593
|
if (isWebPlatform()) {
|
|
1015
|
-
console.log(
|
|
1016
|
-
"[Venus Mock] Notifications not supported on web platform, simulating success"
|
|
1017
|
-
);
|
|
1018
594
|
console.info(
|
|
1019
595
|
"\u{1F514} [Venus Mock] Notification would be scheduled:",
|
|
1020
596
|
title || "Untitled",
|
|
@@ -1025,14 +601,11 @@ var MockNotificationsApi = class {
|
|
|
1025
601
|
const mockId = `mock-web-notification-${Date.now()}`;
|
|
1026
602
|
return mockId;
|
|
1027
603
|
}
|
|
1028
|
-
console.log("[Venus Mock] Schedule local notification:", { title, body, seconds, options });
|
|
1029
604
|
const venusApi = this.venusApi;
|
|
1030
605
|
if (!venusApi._mock.pendingRequests) {
|
|
1031
|
-
console.log("[Venus Mock] Initializing pendingRequests");
|
|
1032
606
|
venusApi._mock.pendingRequests = {};
|
|
1033
607
|
}
|
|
1034
608
|
const requestId = Date.now().toString();
|
|
1035
|
-
console.log("[Venus Mock] Creating request with ID:", requestId);
|
|
1036
609
|
return new Promise((resolve) => {
|
|
1037
610
|
venusApi._mock.pendingRequests[requestId] = { resolve };
|
|
1038
611
|
const id = notificationId || `mock-notification-${Date.now()}`;
|
|
@@ -1054,13 +627,8 @@ var MockNotificationsApi = class {
|
|
|
1054
627
|
async setLocalNotificationsEnabled(enabled) {
|
|
1055
628
|
const venusApi = this.venusApi;
|
|
1056
629
|
if (isWebPlatform()) {
|
|
1057
|
-
console.log(
|
|
1058
|
-
"[Venus Mock] Set notifications enabled on web platform (simulated):",
|
|
1059
|
-
enabled
|
|
1060
|
-
);
|
|
1061
630
|
return true;
|
|
1062
631
|
}
|
|
1063
|
-
console.log("[Venus Mock] Set local notifications enabled:", enabled);
|
|
1064
632
|
await createMockDelay(MOCK_DELAYS.short);
|
|
1065
633
|
venusApi._mock.notificationsEnabled = enabled;
|
|
1066
634
|
return enabled;
|
|
@@ -1254,7 +822,6 @@ var MockTimeApi = class {
|
|
|
1254
822
|
maximumFractionDigits: options?.maximumFractionDigits || 2,
|
|
1255
823
|
...options
|
|
1256
824
|
};
|
|
1257
|
-
console.log(`[Venus Mock] Formatting number ${value} with locale ${locale}`);
|
|
1258
825
|
return value.toLocaleString(locale, numberOptions);
|
|
1259
826
|
}
|
|
1260
827
|
formatTime(timestamp, options) {
|
|
@@ -1266,13 +833,9 @@ var MockTimeApi = class {
|
|
|
1266
833
|
hour12: options.hour12 !== void 0 ? options.hour12 : true,
|
|
1267
834
|
...options
|
|
1268
835
|
};
|
|
1269
|
-
console.log(
|
|
1270
|
-
`[Venus Mock] Formatting time ${timestamp} with locale ${locale}`
|
|
1271
|
-
);
|
|
1272
836
|
return date.toLocaleString(locale, dateTimeOptions);
|
|
1273
837
|
}
|
|
1274
838
|
async getFutureTimeAsync(options) {
|
|
1275
|
-
console.log("[Venus Mock] Getting future time with options:", options);
|
|
1276
839
|
const timeInfo = await this.requestTimeAsync();
|
|
1277
840
|
const serverTime = new Date(timeInfo.serverTime);
|
|
1278
841
|
const result = new Date(serverTime);
|
|
@@ -1317,7 +880,6 @@ var MockTimeApi = class {
|
|
|
1317
880
|
return result.getTime();
|
|
1318
881
|
}
|
|
1319
882
|
async requestTimeAsync() {
|
|
1320
|
-
console.log("[Venus Mock] Requesting time");
|
|
1321
883
|
await createMockDelay(MOCK_DELAYS.short);
|
|
1322
884
|
const venusApi = this.venusApi;
|
|
1323
885
|
const mockOffset = venusApi._mock.serverTimeOffset || 2500;
|
|
@@ -1331,11 +893,6 @@ var MockTimeApi = class {
|
|
|
1331
893
|
formattedTime: new Date(localTime).toISOString(),
|
|
1332
894
|
locale: venusApi._mock.user?.locale || "en-US"
|
|
1333
895
|
};
|
|
1334
|
-
console.log("[Venus Mock] Time response:", {
|
|
1335
|
-
serverTime: new Date(timeInfo.serverTime).toISOString(),
|
|
1336
|
-
localTime: new Date(timeInfo.localTime).toISOString(),
|
|
1337
|
-
timezoneOffset: timeInfo.timezoneOffset
|
|
1338
|
-
});
|
|
1339
896
|
return timeInfo;
|
|
1340
897
|
}
|
|
1341
898
|
};
|
|
@@ -1372,7 +929,7 @@ var MockAvatarApi = class {
|
|
|
1372
929
|
async deleteAvatar() {
|
|
1373
930
|
console.log(`[Venus Mock] Deleting avatar3d config`);
|
|
1374
931
|
const venusApi = this._venusApi;
|
|
1375
|
-
const currentProfile = venusApi.
|
|
932
|
+
const currentProfile = venusApi.getProfile();
|
|
1376
933
|
const profileId = currentProfile?.id || "default_profile";
|
|
1377
934
|
localStorage.removeItem(`venus-mock-avatar3d-${profileId}`);
|
|
1378
935
|
console.log(
|
|
@@ -1387,7 +944,7 @@ var MockAvatarApi = class {
|
|
|
1387
944
|
console.log(`[Venus Mock] Loading shared avatar3d by ID: ${avatar3dId}`);
|
|
1388
945
|
config = await this.selectAvatarConfig(avatar3dId, false);
|
|
1389
946
|
} else {
|
|
1390
|
-
const currentProfile = venusApi.
|
|
947
|
+
const currentProfile = venusApi.getProfile();
|
|
1391
948
|
const profileId = currentProfile?.id || "default_profile";
|
|
1392
949
|
console.log(`[Venus Mock] Loading avatar3d for profile: ${profileId}`);
|
|
1393
950
|
console.log(
|
|
@@ -1404,7 +961,7 @@ var MockAvatarApi = class {
|
|
|
1404
961
|
async saveAvatar(config) {
|
|
1405
962
|
console.log(`[Venus Mock] Saving avatar3d config:`, config);
|
|
1406
963
|
const venusApi = this._venusApi;
|
|
1407
|
-
const currentProfile = venusApi.
|
|
964
|
+
const currentProfile = venusApi.getProfile();
|
|
1408
965
|
const profileId = currentProfile?.id || "default_profile";
|
|
1409
966
|
localStorage.setItem(
|
|
1410
967
|
`venus-mock-avatar3d-${profileId}`,
|
|
@@ -2065,7 +1622,7 @@ var VenusAssetLoader = class {
|
|
|
2065
1622
|
// Set the VenusAPI reference during initialization
|
|
2066
1623
|
setVenusAPI(api) {
|
|
2067
1624
|
this.venusAPI = api;
|
|
2068
|
-
this.isWebView =
|
|
1625
|
+
this.isWebView = typeof window !== "undefined" && typeof window.ReactNativeWebView !== "undefined";
|
|
2069
1626
|
}
|
|
2070
1627
|
/**
|
|
2071
1628
|
* Load any asset with automatic optimization
|
|
@@ -2186,14 +1743,11 @@ var VenusAssetLoader = class {
|
|
|
2186
1743
|
}, 1e4);
|
|
2187
1744
|
if (type === "image") {
|
|
2188
1745
|
const img = new Image();
|
|
2189
|
-
console.log(`\u{1F5BC}\uFE0F [Asset Verification] Verifying image: ${url}`);
|
|
2190
1746
|
img.onload = () => {
|
|
2191
|
-
console.log(`\u2705 [Asset Verification] Image verified successfully: ${url}`);
|
|
2192
1747
|
clearTimeout(timeout);
|
|
2193
1748
|
resolve();
|
|
2194
1749
|
};
|
|
2195
1750
|
img.onerror = (error) => {
|
|
2196
|
-
console.log(`\u274C [Asset Verification] Image verification failed: ${url}`, error);
|
|
2197
1751
|
clearTimeout(timeout);
|
|
2198
1752
|
reject(new Error("Failed to load image"));
|
|
2199
1753
|
};
|
|
@@ -2245,7 +1799,6 @@ var VenusAssetLoader = class {
|
|
|
2245
1799
|
const CDN_BASE_URL = "https://venus-static-01293ak.web.app/";
|
|
2246
1800
|
const cleanUrl = url.startsWith("/") ? url.slice(1) : url;
|
|
2247
1801
|
const fullUrl = CDN_BASE_URL + cleanUrl;
|
|
2248
|
-
console.log(`\u{1F310} [Asset Loader] Force remote CDN: ${url} -> ${fullUrl}`);
|
|
2249
1802
|
return fullUrl;
|
|
2250
1803
|
}
|
|
2251
1804
|
if (this.venusAPI && this.venusAPI.isMock && this.venusAPI.isMock()) {
|
|
@@ -4328,16 +3881,20 @@ function initializeLeaderboard(venusApiInstance, host) {
|
|
|
4328
3881
|
|
|
4329
3882
|
// src/profile/HostProfileApi.ts
|
|
4330
3883
|
var HostProfileApi = class {
|
|
3884
|
+
constructor(venusApi) {
|
|
3885
|
+
__publicField(this, "venusApi");
|
|
3886
|
+
this.venusApi = venusApi;
|
|
3887
|
+
}
|
|
4331
3888
|
getCurrentProfile() {
|
|
4332
|
-
const profile =
|
|
3889
|
+
const profile = this.venusApi._profileData;
|
|
4333
3890
|
if (!profile) {
|
|
4334
3891
|
throw new Error(
|
|
4335
|
-
"[Venus SDK]
|
|
3892
|
+
"[Venus SDK] Profile not available. You must await VenusAPI.initializeAsync() before calling getProfile(). INIT_SDK has not completed."
|
|
4336
3893
|
);
|
|
4337
3894
|
}
|
|
4338
3895
|
if (!profile.id || !profile.username) {
|
|
4339
3896
|
throw new Error(
|
|
4340
|
-
"[Venus SDK] INIT_SDK returned an incomplete profile (missing id/username). The host must supply
|
|
3897
|
+
"[Venus SDK] INIT_SDK returned an incomplete profile (missing id/username). The host must supply valid profile data."
|
|
4341
3898
|
);
|
|
4342
3899
|
}
|
|
4343
3900
|
return {
|
|
@@ -4351,6 +3908,10 @@ var HostProfileApi = class {
|
|
|
4351
3908
|
|
|
4352
3909
|
// src/profile/MockProfileApi.ts
|
|
4353
3910
|
var MockProfileApi = class {
|
|
3911
|
+
constructor(venusApi) {
|
|
3912
|
+
__publicField(this, "venusApi");
|
|
3913
|
+
this.venusApi = venusApi;
|
|
3914
|
+
}
|
|
4354
3915
|
getCurrentProfile() {
|
|
4355
3916
|
return {
|
|
4356
3917
|
id: "mock_profile_123",
|
|
@@ -4363,11 +3924,223 @@ var MockProfileApi = class {
|
|
|
4363
3924
|
|
|
4364
3925
|
// src/profile/index.ts
|
|
4365
3926
|
function initializeProfile(venusApi, host) {
|
|
3927
|
+
venusApi.getProfile = () => {
|
|
3928
|
+
return host.profile.getCurrentProfile();
|
|
3929
|
+
};
|
|
4366
3930
|
venusApi.getCurrentProfile = () => {
|
|
3931
|
+
console.warn(
|
|
3932
|
+
"[Venus SDK] DEPRECATED: VenusAPI.getCurrentProfile() is deprecated. Use VenusAPI.getProfile() instead. See migration guide: https://docs.venus.com/migration/profile-api"
|
|
3933
|
+
);
|
|
4367
3934
|
return host.profile.getCurrentProfile();
|
|
4368
3935
|
};
|
|
4369
3936
|
}
|
|
4370
3937
|
|
|
3938
|
+
// src/system/HostSystemApi.ts
|
|
3939
|
+
var HostSystemApi = class {
|
|
3940
|
+
constructor(deviceApi, environmentApi, venusApi) {
|
|
3941
|
+
__publicField(this, "deviceApi");
|
|
3942
|
+
__publicField(this, "environmentApi");
|
|
3943
|
+
__publicField(this, "venusApi");
|
|
3944
|
+
this.deviceApi = deviceApi;
|
|
3945
|
+
this.environmentApi = environmentApi;
|
|
3946
|
+
this.venusApi = venusApi;
|
|
3947
|
+
}
|
|
3948
|
+
getDevice() {
|
|
3949
|
+
return this.deviceApi.getDevice();
|
|
3950
|
+
}
|
|
3951
|
+
getEnvironment() {
|
|
3952
|
+
return this.environmentApi.getEnvironment();
|
|
3953
|
+
}
|
|
3954
|
+
getSafeArea() {
|
|
3955
|
+
const safeArea = this.venusApi._safeAreaData;
|
|
3956
|
+
if (!safeArea) {
|
|
3957
|
+
throw new Error(
|
|
3958
|
+
"[Venus SDK] getSafeArea() called before initialization. Call VenusAPI.initializeAsync() first."
|
|
3959
|
+
);
|
|
3960
|
+
}
|
|
3961
|
+
return { ...safeArea };
|
|
3962
|
+
}
|
|
3963
|
+
isMobile() {
|
|
3964
|
+
const environment = this.environmentApi.getEnvironment();
|
|
3965
|
+
if (environment.platform === "ios" || environment.platform === "android") {
|
|
3966
|
+
return true;
|
|
3967
|
+
}
|
|
3968
|
+
if (environment.browserInfo) {
|
|
3969
|
+
return environment.browserInfo.isMobile;
|
|
3970
|
+
}
|
|
3971
|
+
return true;
|
|
3972
|
+
}
|
|
3973
|
+
isWeb() {
|
|
3974
|
+
const environment = this.environmentApi.getEnvironment();
|
|
3975
|
+
if (environment.platform === "web") {
|
|
3976
|
+
return true;
|
|
3977
|
+
}
|
|
3978
|
+
if (environment.browserInfo && !environment.browserInfo.isMobile) {
|
|
3979
|
+
return true;
|
|
3980
|
+
}
|
|
3981
|
+
return false;
|
|
3982
|
+
}
|
|
3983
|
+
};
|
|
3984
|
+
|
|
3985
|
+
// src/system/MockSystemApi.ts
|
|
3986
|
+
var MockSystemApi = class {
|
|
3987
|
+
constructor(deviceApi, environmentApi, venusApi) {
|
|
3988
|
+
__publicField(this, "deviceApi");
|
|
3989
|
+
__publicField(this, "environmentApi");
|
|
3990
|
+
__publicField(this, "venusApi");
|
|
3991
|
+
this.deviceApi = deviceApi;
|
|
3992
|
+
this.environmentApi = environmentApi;
|
|
3993
|
+
this.venusApi = venusApi;
|
|
3994
|
+
}
|
|
3995
|
+
getDevice() {
|
|
3996
|
+
return this.deviceApi.getDevice();
|
|
3997
|
+
}
|
|
3998
|
+
getEnvironment() {
|
|
3999
|
+
return this.environmentApi.getEnvironment();
|
|
4000
|
+
}
|
|
4001
|
+
getSafeArea() {
|
|
4002
|
+
const safeArea = this.venusApi._safeAreaData;
|
|
4003
|
+
if (!safeArea) {
|
|
4004
|
+
return {
|
|
4005
|
+
top: 0,
|
|
4006
|
+
right: 0,
|
|
4007
|
+
bottom: 34,
|
|
4008
|
+
left: 0
|
|
4009
|
+
};
|
|
4010
|
+
}
|
|
4011
|
+
return { ...safeArea };
|
|
4012
|
+
}
|
|
4013
|
+
isMobile() {
|
|
4014
|
+
const environment = this.environmentApi.getEnvironment();
|
|
4015
|
+
if (environment.platform === "ios" || environment.platform === "android") {
|
|
4016
|
+
return true;
|
|
4017
|
+
}
|
|
4018
|
+
if (environment.browserInfo) {
|
|
4019
|
+
return environment.browserInfo.isMobile;
|
|
4020
|
+
}
|
|
4021
|
+
return true;
|
|
4022
|
+
}
|
|
4023
|
+
isWeb() {
|
|
4024
|
+
const environment = this.environmentApi.getEnvironment();
|
|
4025
|
+
if (environment.platform === "web") {
|
|
4026
|
+
return true;
|
|
4027
|
+
}
|
|
4028
|
+
if (environment.browserInfo && !environment.browserInfo.isMobile) {
|
|
4029
|
+
return true;
|
|
4030
|
+
}
|
|
4031
|
+
return false;
|
|
4032
|
+
}
|
|
4033
|
+
};
|
|
4034
|
+
|
|
4035
|
+
// src/system/index.ts
|
|
4036
|
+
function initializeSystem(venusApi, host) {
|
|
4037
|
+
venusApi.system = host.system;
|
|
4038
|
+
venusApi.isMobile = () => {
|
|
4039
|
+
console.warn(
|
|
4040
|
+
"[Venus SDK] DEPRECATED: VenusAPI.isMobile() is deprecated. Use VenusAPI.system.isMobile() instead."
|
|
4041
|
+
);
|
|
4042
|
+
return host.system.isMobile();
|
|
4043
|
+
};
|
|
4044
|
+
venusApi.isWeb = () => {
|
|
4045
|
+
console.warn(
|
|
4046
|
+
"[Venus SDK] DEPRECATED: VenusAPI.isWeb() is deprecated. Use VenusAPI.system.isWeb() instead."
|
|
4047
|
+
);
|
|
4048
|
+
return host.system.isWeb();
|
|
4049
|
+
};
|
|
4050
|
+
}
|
|
4051
|
+
|
|
4052
|
+
// src/device/HostDeviceApi.ts
|
|
4053
|
+
var HostDeviceApi = class {
|
|
4054
|
+
constructor(venusApi) {
|
|
4055
|
+
__publicField(this, "venusApi");
|
|
4056
|
+
this.venusApi = venusApi;
|
|
4057
|
+
}
|
|
4058
|
+
getDevice() {
|
|
4059
|
+
const device = this.venusApi._deviceData;
|
|
4060
|
+
if (!device) {
|
|
4061
|
+
throw new Error(
|
|
4062
|
+
"[Venus SDK] Device info not available. You must await VenusAPI.initializeAsync() before calling getDevice(). INIT_SDK has not completed."
|
|
4063
|
+
);
|
|
4064
|
+
}
|
|
4065
|
+
return device;
|
|
4066
|
+
}
|
|
4067
|
+
};
|
|
4068
|
+
|
|
4069
|
+
// src/device/MockDeviceApi.ts
|
|
4070
|
+
var MockDeviceApi = class {
|
|
4071
|
+
constructor(venusApi) {
|
|
4072
|
+
__publicField(this, "venusApi");
|
|
4073
|
+
this.venusApi = venusApi;
|
|
4074
|
+
}
|
|
4075
|
+
getDevice() {
|
|
4076
|
+
const width = typeof window !== "undefined" ? window.innerWidth : 400;
|
|
4077
|
+
const height = typeof window !== "undefined" ? window.innerHeight : 800;
|
|
4078
|
+
return {
|
|
4079
|
+
screenSize: { width, height },
|
|
4080
|
+
viewportSize: {
|
|
4081
|
+
width: width - 20,
|
|
4082
|
+
// account for safe area
|
|
4083
|
+
height: height - 20
|
|
4084
|
+
},
|
|
4085
|
+
orientation: width > height ? "landscape" : "portrait",
|
|
4086
|
+
pixelRatio: typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1,
|
|
4087
|
+
fontScale: 1,
|
|
4088
|
+
deviceType: width > 768 ? "tablet" : "phone",
|
|
4089
|
+
hapticsEnabled: false,
|
|
4090
|
+
haptics: { supported: false, enabled: false }
|
|
4091
|
+
};
|
|
4092
|
+
}
|
|
4093
|
+
};
|
|
4094
|
+
|
|
4095
|
+
// src/environment/HostEnvironmentApi.ts
|
|
4096
|
+
var HostEnvironmentApi = class {
|
|
4097
|
+
constructor(venusApi) {
|
|
4098
|
+
__publicField(this, "venusApi");
|
|
4099
|
+
this.venusApi = venusApi;
|
|
4100
|
+
}
|
|
4101
|
+
getEnvironment() {
|
|
4102
|
+
const environment = this.venusApi._environmentData;
|
|
4103
|
+
if (!environment) {
|
|
4104
|
+
throw new Error(
|
|
4105
|
+
"[Venus SDK] Environment info not available. You must await VenusAPI.initializeAsync() before calling getEnvironment(). INIT_SDK has not completed."
|
|
4106
|
+
);
|
|
4107
|
+
}
|
|
4108
|
+
return environment;
|
|
4109
|
+
}
|
|
4110
|
+
};
|
|
4111
|
+
|
|
4112
|
+
// src/environment/MockEnvironmentApi.ts
|
|
4113
|
+
var MockEnvironmentApi = class {
|
|
4114
|
+
constructor(venusApi) {
|
|
4115
|
+
__publicField(this, "venusApi");
|
|
4116
|
+
this.venusApi = venusApi;
|
|
4117
|
+
}
|
|
4118
|
+
getEnvironment() {
|
|
4119
|
+
const getBrowser = () => {
|
|
4120
|
+
if (typeof navigator === "undefined") return "unknown";
|
|
4121
|
+
const userAgent = navigator.userAgent;
|
|
4122
|
+
if (/chrome|chromium|crios/i.test(userAgent)) return "chrome";
|
|
4123
|
+
if (/firefox|fxios/i.test(userAgent)) return "firefox";
|
|
4124
|
+
if (/safari/i.test(userAgent)) return "safari";
|
|
4125
|
+
if (/edg/i.test(userAgent)) return "edge";
|
|
4126
|
+
if (/opera|opr/i.test(userAgent)) return "opera";
|
|
4127
|
+
return "unknown";
|
|
4128
|
+
};
|
|
4129
|
+
return {
|
|
4130
|
+
isDevelopment: true,
|
|
4131
|
+
platform: "web",
|
|
4132
|
+
platformVersion: "mock-1.0",
|
|
4133
|
+
browserInfo: {
|
|
4134
|
+
browser: getBrowser(),
|
|
4135
|
+
userAgent: typeof navigator !== "undefined" ? navigator.userAgent : "mock-agent",
|
|
4136
|
+
isMobile: typeof navigator !== "undefined" ? /Mobi|Android/i.test(navigator.userAgent) : false,
|
|
4137
|
+
isTablet: typeof navigator !== "undefined" ? /iPad|Tablet|Pad/i.test(navigator.userAgent) : false,
|
|
4138
|
+
language: typeof navigator !== "undefined" ? navigator.language || "en-US" : "en-US"
|
|
4139
|
+
}
|
|
4140
|
+
};
|
|
4141
|
+
}
|
|
4142
|
+
};
|
|
4143
|
+
|
|
4371
4144
|
// src/cdn/HostCdnApi.ts
|
|
4372
4145
|
var HostCdnApi = class {
|
|
4373
4146
|
constructor(baseUrl) {
|
|
@@ -4440,9 +4213,15 @@ var HostCdnApi = class {
|
|
|
4440
4213
|
|
|
4441
4214
|
// src/cdn/MockCdnApi.ts
|
|
4442
4215
|
var MockCdnApi = class {
|
|
4443
|
-
constructor() {
|
|
4444
|
-
__publicField(this, "
|
|
4445
|
-
this.
|
|
4216
|
+
constructor(venusApi) {
|
|
4217
|
+
__publicField(this, "venusApi");
|
|
4218
|
+
this.venusApi = venusApi;
|
|
4219
|
+
}
|
|
4220
|
+
get baseUrl() {
|
|
4221
|
+
return this.venusApi._mock?.cdnBaseUrl ?? "https://venus-static-01293ak.web.app/";
|
|
4222
|
+
}
|
|
4223
|
+
get forceRemoteCdn() {
|
|
4224
|
+
return this.venusApi._mock?.cdnForceRemote ?? false;
|
|
4446
4225
|
}
|
|
4447
4226
|
async fetchBlob(path, options) {
|
|
4448
4227
|
const controller = new AbortController();
|
|
@@ -4479,6 +4258,10 @@ var MockCdnApi = class {
|
|
|
4479
4258
|
return subPath;
|
|
4480
4259
|
}
|
|
4481
4260
|
const cleanSubPath = subPath.startsWith("/") ? subPath.slice(1) : subPath;
|
|
4261
|
+
const isLocalhost = typeof window !== "undefined" && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1");
|
|
4262
|
+
if (isLocalhost && !this.forceRemoteCdn) {
|
|
4263
|
+
return `/${cleanSubPath}`;
|
|
4264
|
+
}
|
|
4482
4265
|
const pathParts = cleanSubPath.split("/");
|
|
4483
4266
|
const encodedParts = pathParts.map((part, index) => {
|
|
4484
4267
|
return index === pathParts.length - 1 ? encodeURIComponent(part) : part;
|
|
@@ -4600,96 +4383,6 @@ function initializeCdn(venusApi, host) {
|
|
|
4600
4383
|
venusApi.cdn = host.cdn;
|
|
4601
4384
|
}
|
|
4602
4385
|
|
|
4603
|
-
// src/post/MockPostApi.ts
|
|
4604
|
-
init_core();
|
|
4605
|
-
var MockPostApi = class {
|
|
4606
|
-
constructor(venusApi) {
|
|
4607
|
-
__publicField(this, "venusApi");
|
|
4608
|
-
this.venusApi = venusApi;
|
|
4609
|
-
}
|
|
4610
|
-
async getPostInfo() {
|
|
4611
|
-
const venusApi = this.venusApi;
|
|
4612
|
-
await createMockDelay(MOCK_DELAYS.short);
|
|
4613
|
-
return venusApi._mock.currentPostInteractions;
|
|
4614
|
-
}
|
|
4615
|
-
async openCommentsAsync() {
|
|
4616
|
-
await createMockDelay(MOCK_DELAYS.short);
|
|
4617
|
-
return {
|
|
4618
|
-
opened: true,
|
|
4619
|
-
commentsCount: 0
|
|
4620
|
-
};
|
|
4621
|
-
}
|
|
4622
|
-
async toggleFollowAsync() {
|
|
4623
|
-
const venusApi = this.venusApi;
|
|
4624
|
-
console.log("[Venus Mock] *Toggling follow status");
|
|
4625
|
-
await createMockDelay(MOCK_DELAYS.short);
|
|
4626
|
-
venusApi._mock.currentPostInteractions.isFollowing = !venusApi._mock.currentPostInteractions.isFollowing;
|
|
4627
|
-
const isFollowing = venusApi._mock.currentPostInteractions.isFollowing;
|
|
4628
|
-
return {
|
|
4629
|
-
isFollowing,
|
|
4630
|
-
action: isFollowing ? "followed" : "unfollowed"
|
|
4631
|
-
};
|
|
4632
|
-
}
|
|
4633
|
-
async toggleLikeAsync() {
|
|
4634
|
-
const venusApi = this.venusApi;
|
|
4635
|
-
await createMockDelay(MOCK_DELAYS.short);
|
|
4636
|
-
venusApi._mock.currentPostInteractions.isLiked = !venusApi._mock.currentPostInteractions.isLiked;
|
|
4637
|
-
const isLiked = venusApi._mock.currentPostInteractions.isLiked;
|
|
4638
|
-
if (isLiked) {
|
|
4639
|
-
venusApi._mock.currentPostInteractions.likesCount++;
|
|
4640
|
-
} else {
|
|
4641
|
-
venusApi._mock.currentPostInteractions.likesCount = Math.max(
|
|
4642
|
-
0,
|
|
4643
|
-
venusApi._mock.currentPostInteractions.likesCount - 1
|
|
4644
|
-
);
|
|
4645
|
-
}
|
|
4646
|
-
return {
|
|
4647
|
-
isLiked,
|
|
4648
|
-
likesCount: venusApi._mock.currentPostInteractions.likesCount,
|
|
4649
|
-
action: isLiked ? "liked" : "unliked"
|
|
4650
|
-
};
|
|
4651
|
-
}
|
|
4652
|
-
};
|
|
4653
|
-
|
|
4654
|
-
// src/post/RpcPostApi.ts
|
|
4655
|
-
var RpcPostApi = class {
|
|
4656
|
-
constructor(rpcClient) {
|
|
4657
|
-
__publicField(this, "rpcClient");
|
|
4658
|
-
this.rpcClient = rpcClient;
|
|
4659
|
-
}
|
|
4660
|
-
getPostInfo() {
|
|
4661
|
-
return this.rpcClient.call("H5_GET_POST_INTERACTIONS" /* GET_POST_INTERACTIONS */, {});
|
|
4662
|
-
}
|
|
4663
|
-
openCommentsAsync() {
|
|
4664
|
-
return this.rpcClient.call("H5_OPEN_COMMENTS" /* OPEN_COMMENTS */, {});
|
|
4665
|
-
}
|
|
4666
|
-
toggleFollowAsync() {
|
|
4667
|
-
return this.rpcClient.call(
|
|
4668
|
-
"H5_TOGGLE_FOLLOW" /* TOGGLE_FOLLOW */,
|
|
4669
|
-
{}
|
|
4670
|
-
);
|
|
4671
|
-
}
|
|
4672
|
-
toggleLikeAsync() {
|
|
4673
|
-
return this.rpcClient.call("H5_TOGGLE_LIKE" /* TOGGLE_LIKE */, {});
|
|
4674
|
-
}
|
|
4675
|
-
};
|
|
4676
|
-
|
|
4677
|
-
// src/post/index.ts
|
|
4678
|
-
function initializePost(venusApi, host) {
|
|
4679
|
-
venusApi.getPostInteractionsAsync = () => {
|
|
4680
|
-
return host.post.getPostInfo();
|
|
4681
|
-
};
|
|
4682
|
-
venusApi.toggleFollowAsync = () => {
|
|
4683
|
-
return host.post.toggleFollowAsync();
|
|
4684
|
-
};
|
|
4685
|
-
venusApi.toggleLikeAsync = () => {
|
|
4686
|
-
return host.post.toggleLikeAsync();
|
|
4687
|
-
};
|
|
4688
|
-
venusApi.openCommentsAsync = async () => {
|
|
4689
|
-
await host.post.openCommentsAsync();
|
|
4690
|
-
};
|
|
4691
|
-
}
|
|
4692
|
-
|
|
4693
4386
|
// src/haptics/RpcHapticsApi.ts
|
|
4694
4387
|
var RpcHapticsApi = class {
|
|
4695
4388
|
constructor(rpcClient) {
|
|
@@ -4880,871 +4573,426 @@ function initializeLifecycleApi(venusApi, host) {
|
|
|
4880
4573
|
venusApi.lifecycles = host.lifecycle;
|
|
4881
4574
|
}
|
|
4882
4575
|
|
|
4883
|
-
// src/
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4576
|
+
// src/rooms/VenusRoom.ts
|
|
4577
|
+
var VenusRoom = class {
|
|
4578
|
+
constructor(roomData) {
|
|
4579
|
+
__publicField(this, "id");
|
|
4580
|
+
__publicField(this, "name");
|
|
4581
|
+
__publicField(this, "players");
|
|
4582
|
+
__publicField(this, "maxPlayers");
|
|
4583
|
+
__publicField(this, "gameType");
|
|
4584
|
+
__publicField(this, "appId");
|
|
4585
|
+
__publicField(this, "type");
|
|
4586
|
+
__publicField(this, "createdBy");
|
|
4587
|
+
__publicField(this, "createdAt");
|
|
4588
|
+
__publicField(this, "updatedAt");
|
|
4589
|
+
__publicField(this, "isPrivate");
|
|
4590
|
+
__publicField(this, "status");
|
|
4591
|
+
__publicField(this, "customMetadata");
|
|
4592
|
+
__publicField(this, "admins");
|
|
4593
|
+
__publicField(this, "roomCode");
|
|
4594
|
+
__publicField(this, "description");
|
|
4595
|
+
__publicField(this, "data");
|
|
4596
|
+
__publicField(this, "version");
|
|
4597
|
+
this.id = roomData.id;
|
|
4598
|
+
this.name = roomData.name;
|
|
4599
|
+
this.players = Array.isArray(roomData.currentPlayers) ? [...roomData.currentPlayers] : [];
|
|
4600
|
+
this.maxPlayers = roomData.maxPlayers;
|
|
4601
|
+
this.gameType = roomData.gameType;
|
|
4602
|
+
this.appId = roomData.appId;
|
|
4603
|
+
this.type = roomData.type;
|
|
4604
|
+
this.createdBy = roomData.createdBy;
|
|
4605
|
+
this.createdAt = roomData.createdAt;
|
|
4606
|
+
this.updatedAt = roomData.updatedAt;
|
|
4607
|
+
this.isPrivate = roomData.isPrivate;
|
|
4608
|
+
this.status = roomData.status;
|
|
4609
|
+
this.customMetadata = roomData.customMetadata || {};
|
|
4610
|
+
this.admins = Array.isArray(roomData.admins) ? [...roomData.admins] : [];
|
|
4611
|
+
this.roomCode = roomData.roomCode;
|
|
4612
|
+
this.description = roomData.description;
|
|
4613
|
+
this.data = roomData.data || {};
|
|
4614
|
+
this.version = roomData.version;
|
|
4891
4615
|
}
|
|
4892
|
-
|
|
4616
|
+
};
|
|
4617
|
+
|
|
4618
|
+
// src/rooms/setupRoomNotifications.ts
|
|
4619
|
+
function invokeCallbacks(callbacks, event, context) {
|
|
4620
|
+
callbacks.forEach((callback) => {
|
|
4621
|
+
try {
|
|
4622
|
+
callback(event);
|
|
4623
|
+
} catch (error) {
|
|
4624
|
+
console.error(`[Venus SDK] Error in ${context} callback:`, error);
|
|
4625
|
+
throw error;
|
|
4626
|
+
}
|
|
4627
|
+
});
|
|
4628
|
+
}
|
|
4629
|
+
function setupRoomNotifications(transport, getSubscriptions) {
|
|
4630
|
+
return transport.onVenusMessage((message) => {
|
|
4631
|
+
const subscriptions = getSubscriptions();
|
|
4632
|
+
if (!subscriptions) {
|
|
4633
|
+
return;
|
|
4634
|
+
}
|
|
4635
|
+
if (message.type === "H5_ROOM_DATA_UPDATED") {
|
|
4636
|
+
const messageData = message.data;
|
|
4637
|
+
const { roomId, roomData } = messageData;
|
|
4638
|
+
if (!roomId) return;
|
|
4639
|
+
const callbacks = subscriptions.data[roomId] || [];
|
|
4640
|
+
const event = {
|
|
4641
|
+
type: "H5_ROOM_DATA_UPDATED",
|
|
4642
|
+
roomId,
|
|
4643
|
+
roomData,
|
|
4644
|
+
timestamp: messageData.timestamp
|
|
4645
|
+
};
|
|
4646
|
+
invokeCallbacks(callbacks, event, "room data");
|
|
4647
|
+
}
|
|
4648
|
+
if (message.type === "H5_ROOM_MESSAGE_RECEIVED" || message.type === "H5_ROOM_MESSAGE_UPDATED" || message.type === "H5_ROOM_MESSAGE_DELETED") {
|
|
4649
|
+
const messageData = message.data;
|
|
4650
|
+
const { roomId } = messageData;
|
|
4651
|
+
if (!roomId) return;
|
|
4652
|
+
const callbacks = subscriptions.messages[roomId] || [];
|
|
4653
|
+
const event = {
|
|
4654
|
+
type: message.type,
|
|
4655
|
+
roomId,
|
|
4656
|
+
message: messageData.message,
|
|
4657
|
+
timestamp: messageData.timestamp
|
|
4658
|
+
};
|
|
4659
|
+
invokeCallbacks(callbacks, event, "room message");
|
|
4660
|
+
}
|
|
4661
|
+
if (message.type === "app:h5:proposedMoveValidationUpdated") {
|
|
4662
|
+
const messageData = message.data;
|
|
4663
|
+
const { roomId } = messageData;
|
|
4664
|
+
if (!roomId) return;
|
|
4665
|
+
const callbacks = subscriptions.gameEvents[roomId] || [];
|
|
4666
|
+
const event = {
|
|
4667
|
+
type: "app:h5:proposedMoveValidationUpdated",
|
|
4668
|
+
roomId,
|
|
4669
|
+
proposedMoveData: messageData.proposedMoveData,
|
|
4670
|
+
proposedMoveId: messageData.proposedMoveId,
|
|
4671
|
+
changeType: messageData.changeType,
|
|
4672
|
+
timestamp: messageData.timestamp
|
|
4673
|
+
};
|
|
4674
|
+
invokeCallbacks(callbacks, event, "game event");
|
|
4675
|
+
}
|
|
4676
|
+
});
|
|
4893
4677
|
}
|
|
4894
4678
|
|
|
4895
|
-
// src/
|
|
4896
|
-
var
|
|
4679
|
+
// src/rooms/RpcRoomsApi.ts
|
|
4680
|
+
var RpcRoomsApi = class {
|
|
4897
4681
|
constructor(rpcClient) {
|
|
4898
4682
|
__publicField(this, "rpcClient");
|
|
4899
|
-
__publicField(this, "
|
|
4683
|
+
__publicField(this, "subscriptions");
|
|
4900
4684
|
this.rpcClient = rpcClient;
|
|
4685
|
+
this.subscriptions = {
|
|
4686
|
+
data: {},
|
|
4687
|
+
messages: {},
|
|
4688
|
+
gameEvents: {}
|
|
4689
|
+
};
|
|
4901
4690
|
}
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
slotId,
|
|
4908
|
-
itemId
|
|
4909
|
-
}
|
|
4910
|
-
);
|
|
4911
|
-
}
|
|
4912
|
-
sumContributions(contributions) {
|
|
4913
|
-
return sumContributions(contributions);
|
|
4691
|
+
/**
|
|
4692
|
+
* Get the subscription state for external access (used by setupRoomNotifications)
|
|
4693
|
+
*/
|
|
4694
|
+
getSubscriptions() {
|
|
4695
|
+
return this.subscriptions;
|
|
4914
4696
|
}
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4697
|
+
/**
|
|
4698
|
+
* Set up room notification routing from the transport
|
|
4699
|
+
*/
|
|
4700
|
+
setupNotifications(transport) {
|
|
4701
|
+
setupRoomNotifications(transport, () => this.getSubscriptions());
|
|
4920
4702
|
}
|
|
4921
|
-
async
|
|
4703
|
+
async createRoomAsync(options) {
|
|
4922
4704
|
const response = await this.rpcClient.call(
|
|
4923
|
-
"
|
|
4705
|
+
"H5_ROOM_CREATE" /* H5_ROOM_CREATE */,
|
|
4924
4706
|
{
|
|
4925
|
-
|
|
4926
|
-
slotId
|
|
4707
|
+
options
|
|
4927
4708
|
}
|
|
4928
4709
|
);
|
|
4929
|
-
|
|
4710
|
+
if (response.success === false) {
|
|
4711
|
+
const errorMessage = typeof response.error === "string" ? response.error : "Failed to create room";
|
|
4712
|
+
throw new Error(errorMessage);
|
|
4713
|
+
}
|
|
4714
|
+
const room = new VenusRoom(response.roomData);
|
|
4715
|
+
return room;
|
|
4930
4716
|
}
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
"
|
|
4717
|
+
async joinOrCreateRoomAsync(options) {
|
|
4718
|
+
const response = await this.rpcClient.call(
|
|
4719
|
+
"H5_ROOM_JOIN_OR_CREATE" /* H5_ROOM_JOIN_OR_CREATE */,
|
|
4934
4720
|
{
|
|
4935
|
-
|
|
4936
|
-
slotId,
|
|
4937
|
-
candidateItemId
|
|
4721
|
+
options
|
|
4938
4722
|
}
|
|
4939
4723
|
);
|
|
4724
|
+
if (response.success === false) {
|
|
4725
|
+
const errorMessage = typeof response.error === "string" ? response.error : "Failed to join or create room";
|
|
4726
|
+
throw new Error(errorMessage);
|
|
4727
|
+
}
|
|
4728
|
+
const room = new VenusRoom(response.value.roomData);
|
|
4729
|
+
return {
|
|
4730
|
+
action: response.value.action,
|
|
4731
|
+
room,
|
|
4732
|
+
playersJoined: response.value.playersJoined
|
|
4733
|
+
};
|
|
4940
4734
|
}
|
|
4941
|
-
|
|
4942
|
-
return this.rpcClient.call("H5_SIMULATION_ASSIGN_ITEM" /* H5_SIMULATION_ASSIGN_ITEM */, {
|
|
4943
|
-
containerId,
|
|
4944
|
-
slotId,
|
|
4945
|
-
itemId
|
|
4946
|
-
});
|
|
4947
|
-
}
|
|
4948
|
-
removeItemFromSlotAsync(containerId, slotId) {
|
|
4949
|
-
return this.rpcClient.call("H5_SIMULATION_REMOVE_ITEM" /* H5_SIMULATION_REMOVE_ITEM */, {
|
|
4950
|
-
containerId,
|
|
4951
|
-
slotId
|
|
4952
|
-
});
|
|
4953
|
-
}
|
|
4954
|
-
async getSlotContainersAsync() {
|
|
4735
|
+
async joinRoomByCodeAsync(roomCode) {
|
|
4955
4736
|
const response = await this.rpcClient.call(
|
|
4956
|
-
"
|
|
4957
|
-
{
|
|
4737
|
+
"H5_ROOM_JOIN_BY_CODE" /* H5_ROOM_JOIN_BY_CODE */,
|
|
4738
|
+
{
|
|
4739
|
+
roomCode
|
|
4740
|
+
}
|
|
4958
4741
|
);
|
|
4959
|
-
|
|
4742
|
+
if (response?.success === false) {
|
|
4743
|
+
const errorMessage = typeof response.error === "string" ? response.error : "Failed to join room by code";
|
|
4744
|
+
throw new Error(errorMessage);
|
|
4745
|
+
}
|
|
4746
|
+
const room = new VenusRoom(response.roomData);
|
|
4747
|
+
return room;
|
|
4960
4748
|
}
|
|
4961
|
-
|
|
4749
|
+
// Get user's rooms with optional filtering
|
|
4750
|
+
async getUserRoomsAsync(options = {}) {
|
|
4962
4751
|
const response = await this.rpcClient.call(
|
|
4963
|
-
"
|
|
4752
|
+
"H5_ROOM_GET_USER_ROOMS" /* H5_ROOM_GET_USER_ROOMS */,
|
|
4964
4753
|
{
|
|
4965
|
-
|
|
4754
|
+
includeArchived: options.includeArchived ?? false
|
|
4966
4755
|
}
|
|
4967
4756
|
);
|
|
4968
|
-
|
|
4757
|
+
if (response?.success === false) {
|
|
4758
|
+
const errorMessage = typeof response.error === "string" ? response.error : "Failed to get user rooms";
|
|
4759
|
+
throw new Error(errorMessage);
|
|
4760
|
+
}
|
|
4761
|
+
const venusRooms = [];
|
|
4762
|
+
for (const roomData of response.rooms) {
|
|
4763
|
+
if (!roomData.id) {
|
|
4764
|
+
console.warn("[Venus SDK] getUserRooms: Skipping room with missing ID:", roomData);
|
|
4765
|
+
continue;
|
|
4766
|
+
}
|
|
4767
|
+
try {
|
|
4768
|
+
const venusRoom = new VenusRoom(roomData);
|
|
4769
|
+
venusRooms.push(venusRoom);
|
|
4770
|
+
} catch (error) {
|
|
4771
|
+
console.warn(
|
|
4772
|
+
"[Venus SDK] getUserRooms: Failed to create VenusRoom object:",
|
|
4773
|
+
error,
|
|
4774
|
+
roomData
|
|
4775
|
+
);
|
|
4776
|
+
}
|
|
4777
|
+
}
|
|
4778
|
+
return venusRooms;
|
|
4969
4779
|
}
|
|
4970
|
-
async
|
|
4780
|
+
async updateRoomDataAsync(room, updates, options = {}) {
|
|
4971
4781
|
const response = await this.rpcClient.call(
|
|
4972
|
-
"
|
|
4782
|
+
"H5_ROOM_UPDATE_DATA" /* H5_ROOM_UPDATE_DATA */,
|
|
4973
4783
|
{
|
|
4974
|
-
roomId
|
|
4784
|
+
roomId: room.id,
|
|
4785
|
+
updates,
|
|
4786
|
+
merge: options.merge ?? true
|
|
4975
4787
|
}
|
|
4976
4788
|
);
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4789
|
+
if (response?.success === false) {
|
|
4790
|
+
const errorMessage = typeof response.error === "string" ? response.error : "Failed to update room data";
|
|
4791
|
+
throw new Error(errorMessage);
|
|
4980
4792
|
}
|
|
4981
|
-
return response;
|
|
4982
4793
|
}
|
|
4983
|
-
async
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
{}
|
|
4794
|
+
async getRoomDataAsync(room) {
|
|
4795
|
+
const response = await this.rpcClient.call(
|
|
4796
|
+
"H5_ROOM_GET_DATA" /* H5_ROOM_GET_DATA */,
|
|
4797
|
+
{
|
|
4798
|
+
roomId: room.id
|
|
4799
|
+
}
|
|
4990
4800
|
);
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
return config;
|
|
4801
|
+
if (response?.success === false) {
|
|
4802
|
+
const errorMessage = typeof response.error === "string" ? response.error : "Failed to get room data";
|
|
4803
|
+
throw new Error(errorMessage);
|
|
4995
4804
|
}
|
|
4996
|
-
|
|
4997
|
-
}
|
|
4998
|
-
executeRecipeAsync(recipeId, inputs, options) {
|
|
4999
|
-
return this.rpcClient.call("H5_SIMULATION_EXECUTE_RECIPE" /* H5_SIMULATION_EXECUTE_RECIPE */, {
|
|
5000
|
-
recipeId,
|
|
5001
|
-
inputs,
|
|
5002
|
-
roomId: options?.roomId,
|
|
5003
|
-
batchAmount: options?.batchAmount,
|
|
5004
|
-
allowPartialBatch: options?.allowPartialBatch,
|
|
5005
|
-
entity: options?.entity
|
|
5006
|
-
});
|
|
5007
|
-
}
|
|
5008
|
-
collectRecipeAsync(runId) {
|
|
5009
|
-
return this.rpcClient.call("H5_SIMULATION_COLLECT_RECIPE" /* H5_SIMULATION_COLLECT_RECIPE */, {
|
|
5010
|
-
runId
|
|
5011
|
-
});
|
|
5012
|
-
}
|
|
5013
|
-
getActiveRunsAsync(options) {
|
|
5014
|
-
return this.rpcClient.call("H5_SIMULATION_GET_ACTIVE_RUNS" /* H5_SIMULATION_GET_ACTIVE_RUNS */, {
|
|
5015
|
-
roomId: options?.roomId
|
|
5016
|
-
});
|
|
4805
|
+
return response.data;
|
|
5017
4806
|
}
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
"
|
|
4807
|
+
async sendRoomMessageAsync(venusRoom, request) {
|
|
4808
|
+
const response = await this.rpcClient.call(
|
|
4809
|
+
"H5_ROOM_SEND_MESSAGE" /* H5_ROOM_SEND_MESSAGE */,
|
|
5021
4810
|
{
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
roomId: options?.roomId ?? null,
|
|
5026
|
-
options
|
|
4811
|
+
roomId: venusRoom.id,
|
|
4812
|
+
message: request.message,
|
|
4813
|
+
metadata: request.metadata
|
|
5027
4814
|
}
|
|
5028
4815
|
);
|
|
4816
|
+
if (response?.success === false) {
|
|
4817
|
+
const errorMessage = typeof response.error === "string" ? response.error : "Failed to send message";
|
|
4818
|
+
throw new Error(errorMessage);
|
|
4819
|
+
}
|
|
4820
|
+
return response.messageId;
|
|
5029
4821
|
}
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
"
|
|
4822
|
+
async leaveRoomAsync(room) {
|
|
4823
|
+
const response = await this.rpcClient.call(
|
|
4824
|
+
"H5_ROOM_LEAVE" /* H5_ROOM_LEAVE */,
|
|
5033
4825
|
{
|
|
5034
|
-
roomId:
|
|
5035
|
-
includeActorRecipes: options?.includeActorRecipes || false
|
|
4826
|
+
roomId: room.id
|
|
5036
4827
|
}
|
|
5037
4828
|
);
|
|
4829
|
+
if (response?.success === false) {
|
|
4830
|
+
const errorMessage = typeof response.error === "string" ? response.error : "Failed to leave room";
|
|
4831
|
+
throw new Error(errorMessage);
|
|
4832
|
+
}
|
|
5038
4833
|
}
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
"
|
|
4834
|
+
async startRoomGameAsync(room, options = {}) {
|
|
4835
|
+
const response = await this.rpcClient.call(
|
|
4836
|
+
"H5_ROOM_START_GAME" /* H5_ROOM_START_GAME */,
|
|
5042
4837
|
{
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
}
|
|
5047
|
-
);
|
|
5048
|
-
}
|
|
5049
|
-
getBatchRecipeRequirementsAsync(recipes) {
|
|
5050
|
-
return this.rpcClient.call(
|
|
5051
|
-
"H5_SIMULATION_GET_BATCH_RECIPE_REQUIREMENTS" /* H5_SIMULATION_GET_BATCH_RECIPE_REQUIREMENTS */,
|
|
5052
|
-
{
|
|
5053
|
-
recipes
|
|
5054
|
-
}
|
|
5055
|
-
);
|
|
5056
|
-
}
|
|
5057
|
-
triggerRecipeChainAsync(recipeId, options) {
|
|
5058
|
-
return this.rpcClient.call(
|
|
5059
|
-
"H5_SIMULATION_TRIGGER_RECIPE_CHAIN" /* H5_SIMULATION_TRIGGER_RECIPE_CHAIN */,
|
|
5060
|
-
{
|
|
5061
|
-
triggerRecipeId: recipeId,
|
|
5062
|
-
context: options?.context,
|
|
5063
|
-
roomId: options?.roomId
|
|
5064
|
-
}
|
|
5065
|
-
);
|
|
5066
|
-
}
|
|
5067
|
-
getEntityMetadataAsync(entityId) {
|
|
5068
|
-
return this.rpcClient.call(
|
|
5069
|
-
"H5_SIMULATION_GET_ENTITY_METADATA" /* H5_SIMULATION_GET_ENTITY_METADATA */,
|
|
5070
|
-
{
|
|
5071
|
-
entityId
|
|
4838
|
+
roomId: room.id,
|
|
4839
|
+
gameConfig: options.gameConfig ?? {},
|
|
4840
|
+
turnOrder: options.turnOrder ?? null
|
|
5072
4841
|
}
|
|
5073
4842
|
);
|
|
4843
|
+
if (response?.success === false) {
|
|
4844
|
+
const errorMessage = typeof response.error === "string" ? response.error : "Failed to start game";
|
|
4845
|
+
throw new Error(errorMessage);
|
|
4846
|
+
}
|
|
5074
4847
|
}
|
|
5075
|
-
async
|
|
4848
|
+
async proposeMoveAsync(room, proposalPayload) {
|
|
5076
4849
|
const response = await this.rpcClient.call(
|
|
5077
|
-
"
|
|
4850
|
+
"h5:room:proposeMove" /* H5_ROOM_PROPOSE_MOVE */,
|
|
5078
4851
|
{
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
4852
|
+
roomId: room.id,
|
|
4853
|
+
gameSpecificState: proposalPayload.gameSpecificState,
|
|
4854
|
+
moveType: proposalPayload.moveType,
|
|
4855
|
+
clientContext: proposalPayload.clientContext,
|
|
4856
|
+
clientProposalId: proposalPayload.clientProposalId
|
|
5082
4857
|
}
|
|
5083
4858
|
);
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
// src/simulation/MockSimulationApi.ts
|
|
5089
|
-
function generateAppIdentifier2() {
|
|
5090
|
-
if (typeof window === "undefined") return "unknown-app";
|
|
5091
|
-
const url = window.location.href;
|
|
5092
|
-
const match = url.match(/\/H5\/([^\/]+)/);
|
|
5093
|
-
return match ? match[1] : "unknown-app";
|
|
5094
|
-
}
|
|
5095
|
-
var MockSimulationApi = class {
|
|
5096
|
-
constructor(simulationConfig = null) {
|
|
5097
|
-
__publicField(this, "mockSimulationConfigs", /* @__PURE__ */ new Map());
|
|
5098
|
-
// appIdentifier -> config
|
|
5099
|
-
__publicField(this, "mockSimulationStates", /* @__PURE__ */ new Map());
|
|
5100
|
-
// appIdentifier -> config
|
|
5101
|
-
__publicField(this, "mockActiveTimers", /* @__PURE__ */ new Map());
|
|
5102
|
-
// appIdentifier -> timers[]
|
|
5103
|
-
__publicField(this, "appId");
|
|
5104
|
-
__publicField(this, "providedSimulationConfig");
|
|
5105
|
-
this.appId = generateAppIdentifier2();
|
|
5106
|
-
this.providedSimulationConfig = simulationConfig;
|
|
5107
|
-
}
|
|
5108
|
-
sumContributions(contributions) {
|
|
5109
|
-
return sumContributions(contributions);
|
|
5110
|
-
}
|
|
5111
|
-
async validateSlotAssignmentAsync(containerId, slotId, itemId) {
|
|
5112
|
-
this.log("validateSlotAssignmentAsync called:", {
|
|
5113
|
-
containerId,
|
|
5114
|
-
slotId,
|
|
5115
|
-
itemId
|
|
5116
|
-
});
|
|
5117
|
-
return { valid: true, message: "Mock validation successful" };
|
|
5118
|
-
}
|
|
5119
|
-
async executeBatchOperationsAsync(operations, validateOnly) {
|
|
5120
|
-
this.log("executeBatchOperationsAsync called:", {
|
|
5121
|
-
operations,
|
|
5122
|
-
validateOnly
|
|
5123
|
-
});
|
|
5124
|
-
return {
|
|
5125
|
-
success: true,
|
|
5126
|
-
results: operations.map(() => ({ success: true }))
|
|
5127
|
-
};
|
|
5128
|
-
}
|
|
5129
|
-
async getAvailableItemsAsync(containerId, slotId) {
|
|
5130
|
-
console.log("[Venus Simulation Mock] getAvailableItemsAsync called:", {
|
|
5131
|
-
containerId,
|
|
5132
|
-
slotId
|
|
5133
|
-
});
|
|
5134
|
-
const appIdentifier = generateAppIdentifier2();
|
|
5135
|
-
const mockSimulationConfigs = this.mockSimulationConfigs;
|
|
5136
|
-
const config = mockSimulationConfigs.get(appIdentifier) || {
|
|
5137
|
-
entities: {}
|
|
5138
|
-
};
|
|
5139
|
-
const availableItems = Object.entries(config.entities).slice(0, 3).map(([entityId, entity]) => ({
|
|
5140
|
-
entityId,
|
|
5141
|
-
quantity: 1,
|
|
5142
|
-
metadata: entity.metadata,
|
|
5143
|
-
powerPreview: 100
|
|
5144
|
-
// Mock power value
|
|
5145
|
-
}));
|
|
5146
|
-
return availableItems;
|
|
5147
|
-
}
|
|
5148
|
-
async calculatePowerPreviewAsync(containerId, slotId, candidateItemId) {
|
|
5149
|
-
this.log("calculatePowerPreviewAsync called:", {
|
|
5150
|
-
containerId,
|
|
5151
|
-
slotId,
|
|
5152
|
-
candidateItemId
|
|
5153
|
-
});
|
|
5154
|
-
return {
|
|
5155
|
-
currentPower: 1e3,
|
|
5156
|
-
previewPower: 1200,
|
|
5157
|
-
powerDelta: 200,
|
|
5158
|
-
breakdown: { base: 800, weapon: 200, armor: 200 }
|
|
5159
|
-
};
|
|
5160
|
-
}
|
|
5161
|
-
async getSlotContainersAsync() {
|
|
5162
|
-
this.log("getSlotContainersAsync called");
|
|
5163
|
-
const appIdentifier = this.appId;
|
|
5164
|
-
const mockSimulationConfigs = this.mockSimulationConfigs;
|
|
5165
|
-
const config = mockSimulationConfigs.get(appIdentifier) || {
|
|
5166
|
-
entities: {}
|
|
5167
|
-
};
|
|
5168
|
-
const containers = Object.entries(config.entities).filter(([_2, entity]) => entity.metadata?.slots).map(([entityId, entity]) => ({
|
|
5169
|
-
entityId,
|
|
5170
|
-
slots: entity.metadata?.slots,
|
|
5171
|
-
isOwned: true
|
|
5172
|
-
// Mock: assume all containers are owned
|
|
5173
|
-
}));
|
|
5174
|
-
return containers;
|
|
5175
|
-
}
|
|
5176
|
-
async getSlotAssignmentsAsync(containerId) {
|
|
5177
|
-
this.log("getSlotAssignmentsAsync called for:", containerId);
|
|
5178
|
-
return [];
|
|
5179
|
-
}
|
|
5180
|
-
async resolveFieldValueAsync(entityId, fieldPath, entity) {
|
|
5181
|
-
this.log("resolveFieldValueAsync called:", {
|
|
5182
|
-
entityId,
|
|
5183
|
-
fieldPath,
|
|
5184
|
-
entity
|
|
5185
|
-
});
|
|
5186
|
-
const mockValues = {
|
|
5187
|
-
basePower: 850,
|
|
5188
|
-
weaponPower: 300,
|
|
5189
|
-
armorPower: 150,
|
|
5190
|
-
total_power: 1300,
|
|
5191
|
-
total_defense_power: 5e3
|
|
5192
|
-
};
|
|
5193
|
-
return mockValues[fieldPath] || 100;
|
|
5194
|
-
}
|
|
5195
|
-
async getEntityMetadataAsync(entityId) {
|
|
5196
|
-
this.log("getEntityMetadataAsync called for:", entityId);
|
|
5197
|
-
const mockSimulationConfigs = this.mockSimulationConfigs;
|
|
5198
|
-
const appIdentifier = this.appId;
|
|
5199
|
-
const config = mockSimulationConfigs.get(
|
|
5200
|
-
appIdentifier
|
|
5201
|
-
) || {
|
|
5202
|
-
entities: {}};
|
|
5203
|
-
const entity = config.entities[entityId];
|
|
5204
|
-
return entity?.metadata || {};
|
|
5205
|
-
}
|
|
5206
|
-
async collectRecipeAsync(runId) {
|
|
5207
|
-
this.log("collectRecipeAsync called:", { runId });
|
|
5208
|
-
const mockRewards = {
|
|
5209
|
-
cash: Math.floor(Math.random() * 1e3) + 500,
|
|
5210
|
-
experience: Math.floor(Math.random() * 50) + 25
|
|
5211
|
-
};
|
|
5212
|
-
return {
|
|
5213
|
-
success: true,
|
|
5214
|
-
runId,
|
|
5215
|
-
rewards: mockRewards,
|
|
5216
|
-
message: "Rewards collected successfully"
|
|
5217
|
-
};
|
|
5218
|
-
}
|
|
5219
|
-
executeRecipeAsync(recipeId, inputs, options) {
|
|
5220
|
-
this.log("executeRecipeAsync called:", {
|
|
5221
|
-
recipeId,
|
|
5222
|
-
inputs,
|
|
5223
|
-
options
|
|
5224
|
-
});
|
|
5225
|
-
const appIdentifier = this.appId;
|
|
5226
|
-
return this.executeRecipe(appIdentifier, recipeId, inputs);
|
|
5227
|
-
}
|
|
5228
|
-
async executeScopedRecipeAsync(recipeId, entity, inputs, options) {
|
|
5229
|
-
this.log("executeScopedRecipeAsync called:", {
|
|
5230
|
-
recipeId,
|
|
5231
|
-
entity,
|
|
5232
|
-
inputs,
|
|
5233
|
-
roomId: options?.roomId,
|
|
5234
|
-
options
|
|
5235
|
-
});
|
|
5236
|
-
return {
|
|
5237
|
-
success: true,
|
|
5238
|
-
message: "Mock scoped recipe execution successful"
|
|
5239
|
-
};
|
|
5240
|
-
}
|
|
5241
|
-
async getActiveRunsAsync(options) {
|
|
5242
|
-
this.log("getActiveRunsAsync called:", options);
|
|
5243
|
-
const appIdentifier = this.appId;
|
|
5244
|
-
let state = this.mockSimulationStates.get(appIdentifier);
|
|
5245
|
-
if (!state) {
|
|
5246
|
-
state = await this.initializeSimulationState(appIdentifier);
|
|
5247
|
-
}
|
|
5248
|
-
return state.activeRuns || [];
|
|
5249
|
-
}
|
|
5250
|
-
async getAvailableRecipesAsync(options) {
|
|
5251
|
-
this.log("getAvailableRecipesAsync called:", options);
|
|
5252
|
-
const baseRecipes = [
|
|
5253
|
-
{ id: "collect_resources", scope: "player", clientViewable: true },
|
|
5254
|
-
{ id: "upgrade_equipment", scope: "player", clientViewable: true }
|
|
5255
|
-
];
|
|
5256
|
-
if (options?.roomId) {
|
|
5257
|
-
baseRecipes.push(
|
|
5258
|
-
{ id: "room_upgrade", scope: "room", clientViewable: true },
|
|
5259
|
-
{ id: "cooperative_project", scope: "room", clientViewable: true }
|
|
5260
|
-
);
|
|
5261
|
-
}
|
|
5262
|
-
if (options?.includeActorRecipes && options?.roomId) {
|
|
5263
|
-
baseRecipes.push(
|
|
5264
|
-
{ id: "trade_with_npc", scope: "actor", clientViewable: true },
|
|
5265
|
-
{ id: "attack_monster", scope: "actor", clientViewable: true }
|
|
5266
|
-
);
|
|
4859
|
+
if (response?.success === false) {
|
|
4860
|
+
const errorMessage = typeof response.error === "string" ? response.error : "Failed to propose move";
|
|
4861
|
+
throw new Error(errorMessage);
|
|
5267
4862
|
}
|
|
5268
|
-
return
|
|
5269
|
-
}
|
|
5270
|
-
async getBatchRecipeRequirementsAsync(recipes) {
|
|
5271
|
-
this.log("getBatchRecipeRequirementsAsync called:", {
|
|
5272
|
-
count: recipes?.length
|
|
5273
|
-
});
|
|
5274
|
-
const results = (recipes || []).map((q) => ({
|
|
5275
|
-
recipeId: q.recipeId,
|
|
5276
|
-
entity: q.entity || null,
|
|
5277
|
-
amount: q.batchAmount || 1,
|
|
5278
|
-
inputs: { cash: "BE:0" },
|
|
5279
|
-
canAfford: true,
|
|
5280
|
-
disabled: false
|
|
5281
|
-
}));
|
|
5282
|
-
return { success: true, results };
|
|
5283
|
-
}
|
|
5284
|
-
async getRecipeRequirementsAsync(recipe) {
|
|
5285
|
-
this.log("getRecipeRequirementsAsync called:", recipe);
|
|
5286
|
-
return {
|
|
5287
|
-
recipeId: recipe.recipeId,
|
|
5288
|
-
entity: recipe.entity || null,
|
|
5289
|
-
amount: recipe.batchAmount,
|
|
5290
|
-
inputs: { cash: "BE:0" },
|
|
5291
|
-
canAfford: true,
|
|
5292
|
-
disabled: false
|
|
5293
|
-
};
|
|
4863
|
+
return response.data;
|
|
5294
4864
|
}
|
|
5295
|
-
async
|
|
5296
|
-
this.log("triggerRecipeChainAsync called:", { recipeId, ...options });
|
|
4865
|
+
async validateMoveAsync(_room, moveId, verdict) {
|
|
5297
4866
|
return {
|
|
5298
4867
|
success: true,
|
|
5299
|
-
|
|
4868
|
+
moveId,
|
|
4869
|
+
isValid: verdict.isValid,
|
|
4870
|
+
reason: verdict.reason
|
|
5300
4871
|
};
|
|
5301
4872
|
}
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
const
|
|
5308
|
-
const
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
}
|
|
5322
|
-
if (state.disabledRecipes?.includes(recipeId)) {
|
|
5323
|
-
throw new Error(`Recipe ${recipeId} is disabled`);
|
|
5324
|
-
}
|
|
5325
|
-
if (recipe.inputs) {
|
|
5326
|
-
for (const [entityId, required] of Object.entries(recipe.inputs)) {
|
|
5327
|
-
const available = state.inventory[entityId] || 0;
|
|
5328
|
-
if (available < required) {
|
|
5329
|
-
throw new Error(
|
|
5330
|
-
`Insufficient ${entityId}: required ${required}, available ${available}`
|
|
5331
|
-
);
|
|
5332
|
-
}
|
|
4873
|
+
async subscribeAsync(room, options = {}) {
|
|
4874
|
+
const roomId = room.id;
|
|
4875
|
+
const existingData = this.subscriptions.data[roomId];
|
|
4876
|
+
const existingMessages = this.subscriptions.messages[roomId];
|
|
4877
|
+
const existingGameEvents = this.subscriptions.gameEvents[roomId];
|
|
4878
|
+
const subscribeToData = Boolean(options.onData) && (existingData?.length ?? 0) === 0;
|
|
4879
|
+
const subscribeToMessages = Boolean(options.onMessages) && (existingMessages?.length ?? 0) === 0;
|
|
4880
|
+
const subscribeToProposedMoves = Boolean(options.onGameEvents) && (existingGameEvents?.length ?? 0) === 0;
|
|
4881
|
+
if (subscribeToData || subscribeToMessages || subscribeToProposedMoves) {
|
|
4882
|
+
try {
|
|
4883
|
+
await this.rpcClient.call("H5_ROOM_SUBSCRIBE" /* H5_ROOM_SUBSCRIBE */, {
|
|
4884
|
+
roomId,
|
|
4885
|
+
subscribeToData,
|
|
4886
|
+
subscribeToMessages,
|
|
4887
|
+
subscribeToProposedMoves
|
|
4888
|
+
});
|
|
4889
|
+
} catch (error) {
|
|
4890
|
+
console.error("[Venus SDK] Failed to set up room subscription:", error);
|
|
4891
|
+
throw error;
|
|
5333
4892
|
}
|
|
5334
4893
|
}
|
|
5335
|
-
if (
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
if (typeof input === "number" && typeof inventoryValue === "number") {
|
|
5339
|
-
state.inventory[entityId] = inventoryValue - input;
|
|
5340
|
-
}
|
|
4894
|
+
if (options.onData) {
|
|
4895
|
+
if (!this.subscriptions.data[roomId]) {
|
|
4896
|
+
this.subscriptions.data[roomId] = [];
|
|
5341
4897
|
}
|
|
4898
|
+
this.subscriptions.data[roomId].push(options.onData);
|
|
5342
4899
|
}
|
|
5343
|
-
if (
|
|
5344
|
-
this.
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
const expiresAt = now + (recipe.duration || 0);
|
|
5349
|
-
const run = {
|
|
5350
|
-
id: runId,
|
|
5351
|
-
recipeId,
|
|
5352
|
-
status: "running",
|
|
5353
|
-
startTime: now,
|
|
5354
|
-
expiresAt,
|
|
5355
|
-
inputs: recipe.inputs || {}
|
|
5356
|
-
};
|
|
5357
|
-
state.activeRuns.push(run);
|
|
5358
|
-
if (recipe.duration === 0) {
|
|
5359
|
-
this.completeRun(appIdentifier, runId);
|
|
5360
|
-
return { status: "completed", runId };
|
|
5361
|
-
} else {
|
|
5362
|
-
const mockActiveTimers = this.mockActiveTimers;
|
|
5363
|
-
const timer = setTimeout(() => {
|
|
5364
|
-
this.completeRun(appIdentifier, runId);
|
|
5365
|
-
}, recipe.duration);
|
|
5366
|
-
const timers = mockActiveTimers.get(appIdentifier) || [];
|
|
5367
|
-
timers.push(timer);
|
|
5368
|
-
mockActiveTimers.set(appIdentifier, timers);
|
|
5369
|
-
return {
|
|
5370
|
-
status: "running",
|
|
5371
|
-
runId,
|
|
5372
|
-
expiresAt: new Date(expiresAt).toISOString()
|
|
5373
|
-
};
|
|
5374
|
-
}
|
|
5375
|
-
}
|
|
5376
|
-
async initializeSimulationState(appIdentifier) {
|
|
5377
|
-
this.log(`Initializing simulation state for ${appIdentifier}`);
|
|
5378
|
-
const providedSimulationConfig = this.providedSimulationConfig;
|
|
5379
|
-
const mockSimulationConfigs = this.mockSimulationConfigs;
|
|
5380
|
-
const mockSimulationStates = this.mockSimulationStates;
|
|
5381
|
-
const mockActiveTimers = this.mockActiveTimers;
|
|
5382
|
-
const config = providedSimulationConfig || {
|
|
5383
|
-
version: "1.0",
|
|
5384
|
-
entities: {},
|
|
5385
|
-
recipes: {}
|
|
5386
|
-
};
|
|
5387
|
-
mockSimulationConfigs.set(appIdentifier, config);
|
|
5388
|
-
const initialInventory = {};
|
|
5389
|
-
if (providedSimulationConfig && config.entities) {
|
|
5390
|
-
Object.keys(config.entities).forEach((entityId) => {
|
|
5391
|
-
initialInventory[entityId] = 0;
|
|
5392
|
-
});
|
|
4900
|
+
if (options.onMessages) {
|
|
4901
|
+
if (!this.subscriptions.messages[roomId]) {
|
|
4902
|
+
this.subscriptions.messages[roomId] = [];
|
|
4903
|
+
}
|
|
4904
|
+
this.subscriptions.messages[roomId].push(options.onMessages);
|
|
5393
4905
|
}
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
if (config.recipes) {
|
|
5400
|
-
Object.entries(config.recipes).forEach(([recipeId, recipe]) => {
|
|
5401
|
-
if (recipe.metadata?.startsDisabled) {
|
|
5402
|
-
state.disabledRecipes.push(recipeId);
|
|
5403
|
-
}
|
|
5404
|
-
});
|
|
4906
|
+
if (options.onGameEvents) {
|
|
4907
|
+
if (!this.subscriptions.gameEvents[roomId]) {
|
|
4908
|
+
this.subscriptions.gameEvents[roomId] = [];
|
|
4909
|
+
}
|
|
4910
|
+
this.subscriptions.gameEvents[roomId].push(options.onGameEvents);
|
|
5405
4911
|
}
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
this.log(`Found auto-restart recipe: ${recipeId}`, {
|
|
5417
|
-
topLevelAutoRestart: recipe.autoRestart,
|
|
5418
|
-
metadataAutoRestart: recipe.metadata?.autoRestart,
|
|
5419
|
-
hasOutputs: !!recipe.outputs,
|
|
5420
|
-
duration: recipe.duration
|
|
5421
|
-
});
|
|
5422
|
-
const condition = recipe.maxRestartCondition || recipe.metadata?.maxRestartCondition;
|
|
5423
|
-
if (condition && condition.entity) {
|
|
5424
|
-
const currentAmount = initialInventory[condition.entity] || 0;
|
|
5425
|
-
if (currentAmount < condition.maxValue) {
|
|
5426
|
-
console.log(
|
|
5427
|
-
`[Venus Simulation Mock] Auto-starting ${recipeId} at initialization`,
|
|
5428
|
-
{
|
|
5429
|
-
currentAmount,
|
|
5430
|
-
maxValue: condition.maxValue,
|
|
5431
|
-
entity: condition.entity
|
|
5432
|
-
}
|
|
5433
|
-
);
|
|
5434
|
-
setTimeout(() => {
|
|
5435
|
-
this.executeRecipe(appIdentifier, recipeId, {});
|
|
5436
|
-
}, 1e3);
|
|
5437
|
-
}
|
|
5438
|
-
} else {
|
|
5439
|
-
console.log(
|
|
5440
|
-
`[Venus Simulation Mock] Auto-starting ${recipeId} at initialization (no condition)`
|
|
5441
|
-
);
|
|
5442
|
-
setTimeout(() => {
|
|
5443
|
-
this.executeRecipe(appIdentifier, recipeId, {});
|
|
5444
|
-
}, 1e3);
|
|
4912
|
+
let disposed = false;
|
|
4913
|
+
return () => {
|
|
4914
|
+
if (disposed) return;
|
|
4915
|
+
disposed = true;
|
|
4916
|
+
if (options.onData) {
|
|
4917
|
+
const callbacks = this.subscriptions.data[roomId];
|
|
4918
|
+
if (callbacks) {
|
|
4919
|
+
const index = callbacks.indexOf(options.onData);
|
|
4920
|
+
if (index > -1) {
|
|
4921
|
+
callbacks.splice(index, 1);
|
|
5445
4922
|
}
|
|
5446
4923
|
}
|
|
5447
|
-
});
|
|
5448
|
-
}
|
|
5449
|
-
return state;
|
|
5450
|
-
}
|
|
5451
|
-
generateRunId() {
|
|
5452
|
-
return "run_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9);
|
|
5453
|
-
}
|
|
5454
|
-
completeRun(appIdentifier, runId) {
|
|
5455
|
-
this.log(`Completing run ${runId} for ${appIdentifier}`);
|
|
5456
|
-
const mockSimulationConfigs = this.mockSimulationConfigs;
|
|
5457
|
-
const mockSimulationStates = this.mockSimulationStates;
|
|
5458
|
-
const config = mockSimulationConfigs.get(appIdentifier);
|
|
5459
|
-
const state = mockSimulationStates.get(appIdentifier);
|
|
5460
|
-
if (!config || !state) return;
|
|
5461
|
-
const runIndex = state.activeRuns.findIndex((r2) => r2.id === runId);
|
|
5462
|
-
if (runIndex === -1) return;
|
|
5463
|
-
const run = state.activeRuns[runIndex];
|
|
5464
|
-
const recipe = config.recipes?.[run.recipeId];
|
|
5465
|
-
if (!recipe) return;
|
|
5466
|
-
const outputs = {};
|
|
5467
|
-
const rng = this.createSeededRandom(runId);
|
|
5468
|
-
if (recipe.outputs) {
|
|
5469
|
-
for (const [entityId, value] of Object.entries(recipe.outputs)) {
|
|
5470
|
-
if (typeof value === "number") {
|
|
5471
|
-
outputs[entityId] = value;
|
|
5472
|
-
} else if (typeof value === "object" && value != null && "min" in value && "max" in value && typeof value.min == "number" && typeof value.max === "number") {
|
|
5473
|
-
outputs[entityId] = Math.floor(rng() * (value.max - value.min + 1)) + value.min;
|
|
5474
|
-
}
|
|
5475
4924
|
}
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
run.status = "completed";
|
|
5484
|
-
run.outputs = outputs;
|
|
5485
|
-
state.activeRuns.splice(runIndex, 1);
|
|
5486
|
-
const isAutoRestart = recipe.autoRestart || recipe.metadata?.autoRestart;
|
|
5487
|
-
if (isAutoRestart) {
|
|
5488
|
-
console.log(
|
|
5489
|
-
`[Venus Simulation Mock] Checking auto-restart for ${run.recipeId}`,
|
|
5490
|
-
{
|
|
5491
|
-
topLevelAutoRestart: recipe.autoRestart,
|
|
5492
|
-
metadataAutoRestart: recipe.metadata?.autoRestart,
|
|
5493
|
-
hasCondition: !!(recipe.maxRestartCondition || recipe.metadata?.maxRestartCondition)
|
|
5494
|
-
}
|
|
5495
|
-
);
|
|
5496
|
-
const condition = recipe.maxRestartCondition || recipe.metadata?.maxRestartCondition;
|
|
5497
|
-
if (condition) {
|
|
5498
|
-
const currentAmount = state.inventory[condition.entity] || 0;
|
|
5499
|
-
if (currentAmount < condition.maxValue) {
|
|
5500
|
-
console.log(
|
|
5501
|
-
`[Venus Simulation Mock] Auto-restarting ${run.recipeId}`,
|
|
5502
|
-
{
|
|
5503
|
-
currentAmount,
|
|
5504
|
-
maxValue: condition.maxValue,
|
|
5505
|
-
entity: condition.entity
|
|
5506
|
-
}
|
|
5507
|
-
);
|
|
5508
|
-
setTimeout(() => {
|
|
5509
|
-
this.executeRecipe(appIdentifier, run.recipeId, recipe.inputs || {});
|
|
5510
|
-
}, 1e3);
|
|
4925
|
+
if (options.onMessages) {
|
|
4926
|
+
const callbacks = this.subscriptions.messages[roomId];
|
|
4927
|
+
if (callbacks) {
|
|
4928
|
+
const index = callbacks.indexOf(options.onMessages);
|
|
4929
|
+
if (index > -1) {
|
|
4930
|
+
callbacks.splice(index, 1);
|
|
4931
|
+
}
|
|
5511
4932
|
}
|
|
5512
|
-
} else {
|
|
5513
|
-
console.log(
|
|
5514
|
-
`[Venus Simulation Mock] Auto-restarting ${run.recipeId} (no condition)`
|
|
5515
|
-
);
|
|
5516
|
-
setTimeout(() => {
|
|
5517
|
-
this.executeRecipe(appIdentifier, run.recipeId, recipe.inputs || {});
|
|
5518
|
-
}, 1e3);
|
|
5519
4933
|
}
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
createSeededRandom(seed) {
|
|
5527
|
-
let hash = 0;
|
|
5528
|
-
for (let i = 0; i < seed.length; i++) {
|
|
5529
|
-
const char = seed.charCodeAt(i);
|
|
5530
|
-
hash = (hash << 5) - hash + char;
|
|
5531
|
-
hash = hash & hash;
|
|
5532
|
-
}
|
|
5533
|
-
return () => {
|
|
5534
|
-
hash = (hash * 9301 + 49297) % 233280;
|
|
5535
|
-
return hash / 233280;
|
|
5536
|
-
};
|
|
5537
|
-
}
|
|
5538
|
-
applyEffects(state, effects) {
|
|
5539
|
-
if (!effects || !Array.isArray(effects)) return;
|
|
5540
|
-
for (const effect of effects) {
|
|
5541
|
-
switch (effect.type) {
|
|
5542
|
-
case "set":
|
|
5543
|
-
state.inventory[effect.target] = effect.value;
|
|
5544
|
-
console.log(
|
|
5545
|
-
`[Venus Simulation Mock] Effect: Set ${effect.target} = ${effect.value}`
|
|
5546
|
-
);
|
|
5547
|
-
break;
|
|
5548
|
-
case "add":
|
|
5549
|
-
state.inventory[effect.target] = (state.inventory[effect.target] || 0) + effect.value;
|
|
5550
|
-
console.log(
|
|
5551
|
-
`[Venus Simulation Mock] Effect: Add ${effect.value} to ${effect.target} (new value: ${state.inventory[effect.target]})`
|
|
5552
|
-
);
|
|
5553
|
-
break;
|
|
5554
|
-
case "multiply":
|
|
5555
|
-
state.inventory[effect.target] = (state.inventory[effect.target] || 0) * effect.value;
|
|
5556
|
-
console.log(
|
|
5557
|
-
`[Venus Simulation Mock] Effect: Multiply ${effect.target} by ${effect.value} (new value: ${state.inventory[effect.target]})`
|
|
5558
|
-
);
|
|
5559
|
-
break;
|
|
5560
|
-
case "min":
|
|
5561
|
-
state.inventory[effect.target] = Math.max(
|
|
5562
|
-
state.inventory[effect.target] || 0,
|
|
5563
|
-
effect.value
|
|
5564
|
-
);
|
|
5565
|
-
console.log(
|
|
5566
|
-
`[Venus Simulation Mock] Effect: Set ${effect.target} min ${effect.value} (new value: ${state.inventory[effect.target]})`
|
|
5567
|
-
);
|
|
5568
|
-
break;
|
|
5569
|
-
case "max":
|
|
5570
|
-
state.inventory[effect.target] = Math.min(
|
|
5571
|
-
state.inventory[effect.target] || 0,
|
|
5572
|
-
effect.value
|
|
5573
|
-
);
|
|
5574
|
-
console.log(
|
|
5575
|
-
`[Venus Simulation Mock] Effect: Set ${effect.target} max ${effect.value} (new value: ${state.inventory[effect.target]})`
|
|
5576
|
-
);
|
|
5577
|
-
break;
|
|
5578
|
-
case "enable_recipe":
|
|
5579
|
-
if (state.disabledRecipes?.includes(effect.target)) {
|
|
5580
|
-
state.disabledRecipes = state.disabledRecipes.filter(
|
|
5581
|
-
(r2) => r2 !== effect.target
|
|
5582
|
-
);
|
|
5583
|
-
console.log(
|
|
5584
|
-
`[Venus Simulation Mock] Effect: Enabled recipe ${effect.target}`
|
|
5585
|
-
);
|
|
4934
|
+
if (options.onGameEvents) {
|
|
4935
|
+
const callbacks = this.subscriptions.gameEvents[roomId];
|
|
4936
|
+
if (callbacks) {
|
|
4937
|
+
const index = callbacks.indexOf(options.onGameEvents);
|
|
4938
|
+
if (index > -1) {
|
|
4939
|
+
callbacks.splice(index, 1);
|
|
5586
4940
|
}
|
|
5587
|
-
|
|
5588
|
-
case "disable_recipe":
|
|
5589
|
-
if (!state.disabledRecipes) state.disabledRecipes = [];
|
|
5590
|
-
if (!state.disabledRecipes.includes(effect.target)) {
|
|
5591
|
-
state.disabledRecipes.push(effect.target);
|
|
5592
|
-
console.log(
|
|
5593
|
-
`[Venus Simulation Mock] Effect: Disabled recipe ${effect.target}`
|
|
5594
|
-
);
|
|
5595
|
-
}
|
|
5596
|
-
break;
|
|
5597
|
-
case "trigger_recipe":
|
|
5598
|
-
console.log(
|
|
5599
|
-
`[Venus Simulation Mock] Effect: Trigger recipe ${effect.target} (not implemented)`
|
|
5600
|
-
);
|
|
5601
|
-
break;
|
|
5602
|
-
default:
|
|
5603
|
-
console.warn(
|
|
5604
|
-
`[Venus Simulation Mock] Unknown effect type: ${effect.type}`
|
|
5605
|
-
);
|
|
4941
|
+
}
|
|
5606
4942
|
}
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
}
|
|
5635
|
-
async assignItemToSlotAsync(containerId, slotId, itemId) {
|
|
5636
|
-
this.log("assignItemToSlotAsync called:", {
|
|
5637
|
-
containerId,
|
|
5638
|
-
slotId,
|
|
5639
|
-
itemId
|
|
5640
|
-
});
|
|
5641
|
-
return { success: true, message: "Mock assignment successful" };
|
|
5642
|
-
}
|
|
5643
|
-
async removeItemFromSlotAsync(containerId, slotId) {
|
|
5644
|
-
this.log("removeItemFromSlotAsync called:", {
|
|
5645
|
-
containerId,
|
|
5646
|
-
slotId
|
|
5647
|
-
});
|
|
5648
|
-
return { success: true, message: "Mock removal successful" };
|
|
5649
|
-
}
|
|
5650
|
-
};
|
|
5651
|
-
|
|
5652
|
-
// src/simulation/index.ts
|
|
5653
|
-
function initializeSimulation(venusApi, host) {
|
|
5654
|
-
console.log("[Venus SDK] Initializing new Simulation Api");
|
|
5655
|
-
venusApi.simulation = {
|
|
5656
|
-
isEnabled: () => true
|
|
5657
|
-
};
|
|
5658
|
-
venusApi.simulation.getConfigAsync = () => {
|
|
5659
|
-
return host.simulation.getConfigAsync();
|
|
5660
|
-
};
|
|
5661
|
-
venusApi.simulation.getStateAsync = (options) => {
|
|
5662
|
-
return host.simulation.getStateAsync(options?.roomId);
|
|
5663
|
-
};
|
|
5664
|
-
venusApi.simulation.executeRecipeAsync = (recipeId, inputs, options) => {
|
|
5665
|
-
return host.simulation.executeRecipeAsync(recipeId, inputs, options);
|
|
5666
|
-
};
|
|
5667
|
-
venusApi.simulation.getActiveRunsAsync = () => {
|
|
5668
|
-
return host.simulation.getActiveRunsAsync();
|
|
5669
|
-
};
|
|
5670
|
-
venusApi.simulation.collectRecipeAsync = (runId) => {
|
|
5671
|
-
return host.simulation.collectRecipeAsync(runId);
|
|
5672
|
-
};
|
|
5673
|
-
venusApi.simulation.executeScopedRecipeAsync = (recipeId, entity, inputs, roomId, options) => {
|
|
5674
|
-
return host.simulation.executeScopedRecipeAsync(recipeId, entity, inputs, {
|
|
5675
|
-
roomId,
|
|
5676
|
-
...options
|
|
5677
|
-
});
|
|
5678
|
-
};
|
|
5679
|
-
venusApi.simulation.triggerRecipeChainAsync = (recipeId, context, roomId) => {
|
|
5680
|
-
return host.simulation.triggerRecipeChainAsync(recipeId, {
|
|
5681
|
-
context,
|
|
5682
|
-
roomId
|
|
5683
|
-
});
|
|
5684
|
-
};
|
|
5685
|
-
venusApi.simulation.getAvailableRecipesAsync = async (roomId, includeActorRecipes) => {
|
|
5686
|
-
const result = await host.simulation.getAvailableRecipesAsync({
|
|
5687
|
-
roomId,
|
|
5688
|
-
includeActorRecipes
|
|
5689
|
-
});
|
|
5690
|
-
return result.recipes;
|
|
5691
|
-
};
|
|
5692
|
-
venusApi.simulation.getRecipeRequirementsAsync = (recipeId, entity, amount) => {
|
|
5693
|
-
return host.simulation.getRecipeRequirementsAsync({
|
|
5694
|
-
recipeId,
|
|
5695
|
-
entity,
|
|
5696
|
-
batchAmount: amount
|
|
5697
|
-
});
|
|
5698
|
-
};
|
|
5699
|
-
venusApi.simulation.getBatchRecipeRequirementsAsync = (recipes) => {
|
|
5700
|
-
return host.simulation.getBatchRecipeRequirementsAsync(recipes);
|
|
5701
|
-
};
|
|
5702
|
-
venusApi.simulation.resolveFieldValueAsync = (entityId, fieldPath, entity) => {
|
|
5703
|
-
return host.simulation.resolveFieldValueAsync(entityId, fieldPath, entity);
|
|
5704
|
-
};
|
|
5705
|
-
venusApi.simulation.getEntityMetadataAsync = (entityId) => {
|
|
5706
|
-
return host.simulation.getEntityMetadataAsync(entityId);
|
|
5707
|
-
};
|
|
5708
|
-
venusApi.simulation.getSlotAssignmentsAsync = (containerId) => {
|
|
5709
|
-
return host.simulation.getSlotAssignmentsAsync(containerId);
|
|
5710
|
-
};
|
|
5711
|
-
venusApi.simulation.getSlotContainersAsync = () => {
|
|
5712
|
-
return host.simulation.getSlotContainersAsync();
|
|
5713
|
-
};
|
|
5714
|
-
venusApi.simulation.assignItemToSlotAsync = (containerId, slotId, itemId) => {
|
|
5715
|
-
return host.simulation.assignItemToSlotAsync(containerId, slotId, itemId);
|
|
5716
|
-
};
|
|
5717
|
-
venusApi.simulation.removeItemFromSlotAsync = (containerId, slotId) => {
|
|
5718
|
-
return host.simulation.removeItemFromSlotAsync(containerId, slotId);
|
|
5719
|
-
};
|
|
5720
|
-
venusApi.simulation.getAvailableItemsAsync = (containerId, slotId) => {
|
|
5721
|
-
return host.simulation.getAvailableItemsAsync(containerId, slotId);
|
|
5722
|
-
};
|
|
5723
|
-
venusApi.simulation.calculatePowerPreviewAsync = (containerId, slotId, candidateItemId) => {
|
|
5724
|
-
return host.simulation.calculatePowerPreviewAsync(
|
|
5725
|
-
containerId,
|
|
5726
|
-
slotId,
|
|
5727
|
-
candidateItemId
|
|
5728
|
-
);
|
|
5729
|
-
};
|
|
5730
|
-
venusApi.simulation.executeBatchOperationsAsync = (operations, validateOnly) => {
|
|
5731
|
-
return host.simulation.executeBatchOperationsAsync(operations, validateOnly);
|
|
5732
|
-
};
|
|
5733
|
-
venusApi.simulation.validateSlotAssignmentAsync = (containerId, slotId, itemId) => {
|
|
5734
|
-
return host.simulation.validateSlotAssignmentAsync(
|
|
5735
|
-
containerId,
|
|
5736
|
-
slotId,
|
|
5737
|
-
itemId
|
|
4943
|
+
const hasAnySubscriptions = (this.subscriptions.data[roomId]?.length ?? 0) > 0 || (this.subscriptions.messages[roomId]?.length ?? 0) > 0 || (this.subscriptions.gameEvents[roomId]?.length ?? 0) > 0;
|
|
4944
|
+
if (!hasAnySubscriptions) {
|
|
4945
|
+
this.rpcClient.call("H5_ROOM_UNSUBSCRIBE" /* H5_ROOM_UNSUBSCRIBE */, {
|
|
4946
|
+
roomId
|
|
4947
|
+
}).catch((error) => {
|
|
4948
|
+
console.error("[Venus SDK] Failed to clean up room subscription:", error);
|
|
4949
|
+
});
|
|
4950
|
+
}
|
|
4951
|
+
};
|
|
4952
|
+
}
|
|
4953
|
+
};
|
|
4954
|
+
|
|
4955
|
+
// src/rooms/index.ts
|
|
4956
|
+
function bindMethod(target, targetKey, source, sourceKey) {
|
|
4957
|
+
const key = sourceKey ?? targetKey;
|
|
4958
|
+
const fn = source?.[key];
|
|
4959
|
+
if (typeof fn === "function") {
|
|
4960
|
+
target[targetKey] = fn.bind(source);
|
|
4961
|
+
return true;
|
|
4962
|
+
}
|
|
4963
|
+
return false;
|
|
4964
|
+
}
|
|
4965
|
+
function initializeRoomsApi(venusApi, host) {
|
|
4966
|
+
const roomsApi = host?.rooms;
|
|
4967
|
+
if (!roomsApi) {
|
|
4968
|
+
console.warn(
|
|
4969
|
+
"[Venus SDK] Host did not provide a rooms implementation. Rooms API will be unavailable."
|
|
5738
4970
|
);
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
};
|
|
4971
|
+
return;
|
|
4972
|
+
}
|
|
4973
|
+
const venus = venusApi;
|
|
4974
|
+
const existingNamespace = venus.rooms || {};
|
|
4975
|
+
const roomsNamespace = Object.assign({}, existingNamespace);
|
|
4976
|
+
const namespaceBindings = [
|
|
4977
|
+
["createRoomAsync"],
|
|
4978
|
+
["joinOrCreateRoomAsync"],
|
|
4979
|
+
["joinRoomByCodeAsync"],
|
|
4980
|
+
["getUserRoomsAsync"],
|
|
4981
|
+
["subscribeAsync"],
|
|
4982
|
+
["updateRoomDataAsync"],
|
|
4983
|
+
["getRoomDataAsync"],
|
|
4984
|
+
["sendRoomMessageAsync"],
|
|
4985
|
+
["leaveRoomAsync"],
|
|
4986
|
+
["startRoomGameAsync"],
|
|
4987
|
+
["proposeMoveAsync"],
|
|
4988
|
+
["validateMoveAsync"]
|
|
4989
|
+
];
|
|
4990
|
+
namespaceBindings.forEach(([targetKey, sourceKey]) => {
|
|
4991
|
+
bindMethod(roomsNamespace, targetKey, roomsApi, sourceKey);
|
|
4992
|
+
});
|
|
4993
|
+
venus.rooms = roomsNamespace;
|
|
5743
4994
|
}
|
|
5744
4995
|
|
|
5745
|
-
// src/MockHost.ts
|
|
5746
|
-
init_rooms();
|
|
5747
|
-
|
|
5748
4996
|
// src/logging/MockLoggingApi.ts
|
|
5749
4997
|
var MockLoggingApi = class {
|
|
5750
4998
|
logDebug(message, ...args) {
|
|
@@ -6157,44 +5405,116 @@ var ROOMS_UNAVAILABLE_MESSAGE = "[Venus SDK] Rooms API is only available when ru
|
|
|
6157
5405
|
function createUnavailableRoomsApi() {
|
|
6158
5406
|
const roomsUnavailableError = () => new Error(ROOMS_UNAVAILABLE_MESSAGE);
|
|
6159
5407
|
return {
|
|
6160
|
-
async
|
|
5408
|
+
async createRoomAsync() {
|
|
6161
5409
|
throw roomsUnavailableError();
|
|
6162
5410
|
},
|
|
6163
|
-
async
|
|
5411
|
+
async joinOrCreateRoomAsync() {
|
|
6164
5412
|
throw roomsUnavailableError();
|
|
6165
5413
|
},
|
|
6166
|
-
async
|
|
5414
|
+
async joinRoomByCodeAsync() {
|
|
6167
5415
|
throw roomsUnavailableError();
|
|
6168
5416
|
},
|
|
6169
|
-
async
|
|
5417
|
+
async getUserRoomsAsync() {
|
|
6170
5418
|
throw roomsUnavailableError();
|
|
6171
5419
|
},
|
|
6172
|
-
|
|
5420
|
+
async subscribeAsync() {
|
|
6173
5421
|
throw roomsUnavailableError();
|
|
6174
5422
|
},
|
|
6175
|
-
async
|
|
5423
|
+
async updateRoomDataAsync() {
|
|
6176
5424
|
throw roomsUnavailableError();
|
|
6177
5425
|
},
|
|
6178
|
-
async
|
|
5426
|
+
async getRoomDataAsync() {
|
|
6179
5427
|
throw roomsUnavailableError();
|
|
6180
5428
|
},
|
|
6181
|
-
async
|
|
5429
|
+
async sendRoomMessageAsync() {
|
|
6182
5430
|
throw roomsUnavailableError();
|
|
6183
5431
|
},
|
|
6184
|
-
async
|
|
5432
|
+
async leaveRoomAsync() {
|
|
6185
5433
|
throw roomsUnavailableError();
|
|
6186
5434
|
},
|
|
6187
|
-
async
|
|
5435
|
+
async startRoomGameAsync() {
|
|
6188
5436
|
throw roomsUnavailableError();
|
|
6189
5437
|
},
|
|
6190
|
-
async
|
|
5438
|
+
async proposeMoveAsync() {
|
|
6191
5439
|
throw roomsUnavailableError();
|
|
6192
5440
|
},
|
|
6193
|
-
async
|
|
5441
|
+
async validateMoveAsync() {
|
|
6194
5442
|
throw roomsUnavailableError();
|
|
6195
5443
|
}
|
|
6196
5444
|
};
|
|
6197
5445
|
}
|
|
5446
|
+
var SIMULATION_UNAVAILABLE_MESSAGE = "[Venus SDK] Simulation API is only available when running inside the Venus host environment.";
|
|
5447
|
+
function createUnavailableSimulationApi() {
|
|
5448
|
+
const simulationUnavailableError = () => new Error(SIMULATION_UNAVAILABLE_MESSAGE);
|
|
5449
|
+
return {
|
|
5450
|
+
isEnabled() {
|
|
5451
|
+
return false;
|
|
5452
|
+
},
|
|
5453
|
+
async getStateAsync() {
|
|
5454
|
+
throw simulationUnavailableError();
|
|
5455
|
+
},
|
|
5456
|
+
async getConfigAsync() {
|
|
5457
|
+
throw simulationUnavailableError();
|
|
5458
|
+
},
|
|
5459
|
+
async executeRecipeAsync() {
|
|
5460
|
+
throw simulationUnavailableError();
|
|
5461
|
+
},
|
|
5462
|
+
async getActiveRunsAsync() {
|
|
5463
|
+
throw simulationUnavailableError();
|
|
5464
|
+
},
|
|
5465
|
+
async collectRecipeAsync() {
|
|
5466
|
+
throw simulationUnavailableError();
|
|
5467
|
+
},
|
|
5468
|
+
async executeScopedRecipeAsync() {
|
|
5469
|
+
throw simulationUnavailableError();
|
|
5470
|
+
},
|
|
5471
|
+
async triggerRecipeChainAsync() {
|
|
5472
|
+
throw simulationUnavailableError();
|
|
5473
|
+
},
|
|
5474
|
+
async getAvailableRecipesAsync() {
|
|
5475
|
+
throw simulationUnavailableError();
|
|
5476
|
+
},
|
|
5477
|
+
async getRecipeRequirementsAsync() {
|
|
5478
|
+
throw simulationUnavailableError();
|
|
5479
|
+
},
|
|
5480
|
+
async getBatchRecipeRequirementsAsync() {
|
|
5481
|
+
throw simulationUnavailableError();
|
|
5482
|
+
},
|
|
5483
|
+
async resolveFieldValueAsync() {
|
|
5484
|
+
throw simulationUnavailableError();
|
|
5485
|
+
},
|
|
5486
|
+
async getEntityMetadataAsync() {
|
|
5487
|
+
throw simulationUnavailableError();
|
|
5488
|
+
},
|
|
5489
|
+
async getSlotContainersAsync() {
|
|
5490
|
+
throw simulationUnavailableError();
|
|
5491
|
+
},
|
|
5492
|
+
async getSlotAssignmentsAsync() {
|
|
5493
|
+
throw simulationUnavailableError();
|
|
5494
|
+
},
|
|
5495
|
+
async assignItemToSlotAsync() {
|
|
5496
|
+
throw simulationUnavailableError();
|
|
5497
|
+
},
|
|
5498
|
+
async removeItemFromSlotAsync() {
|
|
5499
|
+
throw simulationUnavailableError();
|
|
5500
|
+
},
|
|
5501
|
+
async getAvailableItemsAsync() {
|
|
5502
|
+
throw simulationUnavailableError();
|
|
5503
|
+
},
|
|
5504
|
+
async calculatePowerPreviewAsync() {
|
|
5505
|
+
throw simulationUnavailableError();
|
|
5506
|
+
},
|
|
5507
|
+
async validateSlotAssignmentAsync() {
|
|
5508
|
+
throw simulationUnavailableError();
|
|
5509
|
+
},
|
|
5510
|
+
async executeBatchOperationsAsync() {
|
|
5511
|
+
throw simulationUnavailableError();
|
|
5512
|
+
},
|
|
5513
|
+
async subscribeAsync() {
|
|
5514
|
+
throw simulationUnavailableError();
|
|
5515
|
+
}
|
|
5516
|
+
};
|
|
5517
|
+
}
|
|
6198
5518
|
var MockHost = class {
|
|
6199
5519
|
constructor(venusApi) {
|
|
6200
5520
|
__publicField(this, "ads");
|
|
@@ -6207,9 +5527,9 @@ var MockHost = class {
|
|
|
6207
5527
|
__publicField(this, "notifications");
|
|
6208
5528
|
__publicField(this, "popups");
|
|
6209
5529
|
__publicField(this, "profile");
|
|
5530
|
+
__publicField(this, "system");
|
|
6210
5531
|
__publicField(this, "cdn");
|
|
6211
5532
|
__publicField(this, "time");
|
|
6212
|
-
__publicField(this, "post");
|
|
6213
5533
|
__publicField(this, "ai");
|
|
6214
5534
|
__publicField(this, "haptics");
|
|
6215
5535
|
__publicField(this, "features");
|
|
@@ -6241,15 +5561,17 @@ var MockHost = class {
|
|
|
6241
5561
|
this.navigation = new MockNavigationApi(venusApi);
|
|
6242
5562
|
this.notifications = new MockNotificationsApi(venusApi);
|
|
6243
5563
|
this.popups = new MockPopupsApi(this._overlay);
|
|
6244
|
-
this.profile = new MockProfileApi();
|
|
6245
|
-
|
|
5564
|
+
this.profile = new MockProfileApi(venusApi);
|
|
5565
|
+
const deviceApi = new MockDeviceApi(venusApi);
|
|
5566
|
+
const environmentApi = new MockEnvironmentApi(venusApi);
|
|
5567
|
+
this.system = new MockSystemApi(deviceApi, environmentApi, venusApi);
|
|
5568
|
+
this.cdn = new MockCdnApi(venusApi);
|
|
6246
5569
|
this.time = new MockTimeApi(venusApi);
|
|
6247
|
-
this.post = new MockPostApi(venusApi);
|
|
6248
5570
|
this.ai = new MockAiApi();
|
|
6249
5571
|
this.haptics = new MockHapticsApi(venusApi);
|
|
6250
5572
|
this.features = new MockFeaturesApi();
|
|
6251
5573
|
this.lifecycle = this._mockLifecyclesApi;
|
|
6252
|
-
this.simulation =
|
|
5574
|
+
this.simulation = createUnavailableSimulationApi();
|
|
6253
5575
|
this.rooms = createUnavailableRoomsApi();
|
|
6254
5576
|
this.logging = new MockLoggingApi();
|
|
6255
5577
|
this.iap = new MockIapApi();
|
|
@@ -6265,40 +5587,17 @@ var MockHost = class {
|
|
|
6265
5587
|
}
|
|
6266
5588
|
initialize(options) {
|
|
6267
5589
|
this._isInitialized = true;
|
|
6268
|
-
|
|
5590
|
+
this.venusApi._profileData = this.profile.getCurrentProfile();
|
|
5591
|
+
this.venusApi._deviceData = this.system.getDevice();
|
|
5592
|
+
this.venusApi._environmentData = this.system.getEnvironment();
|
|
5593
|
+
this.venusApi._localeData = this.venusApi._mock?.locale || "en-US";
|
|
5594
|
+
this.venusApi._languageCodeData = this.venusApi._mock?.languageCode || "en";
|
|
6269
5595
|
return Promise.resolve({
|
|
6270
5596
|
initializeAsleep: false,
|
|
6271
|
-
|
|
6272
|
-
top: controls.feedHeader.height,
|
|
6273
|
-
bottom: 0,
|
|
6274
|
-
left: 0,
|
|
6275
|
-
right: 0
|
|
6276
|
-
}
|
|
5597
|
+
safeArea: this.venusApi._safeAreaData
|
|
6277
5598
|
});
|
|
6278
5599
|
}
|
|
6279
|
-
updateUiControls() {
|
|
6280
|
-
const controls = {
|
|
6281
|
-
closeButton: { x: 16, y: 16, width: 32, height: 32 },
|
|
6282
|
-
menuButton: {
|
|
6283
|
-
x: window.innerWidth - 48,
|
|
6284
|
-
y: 16,
|
|
6285
|
-
width: 32,
|
|
6286
|
-
height: 32
|
|
6287
|
-
},
|
|
6288
|
-
feedHeader: { x: 0, y: 0, width: window.innerWidth, height: 56 },
|
|
6289
|
-
playButton: {
|
|
6290
|
-
x: 0,
|
|
6291
|
-
y: window.innerHeight - 60,
|
|
6292
|
-
width: window.innerWidth,
|
|
6293
|
-
height: 60
|
|
6294
|
-
}
|
|
6295
|
-
};
|
|
6296
|
-
return controls;
|
|
6297
|
-
}
|
|
6298
5600
|
createOverlay() {
|
|
6299
|
-
const venusApi = this.venusApi;
|
|
6300
|
-
venusApi.config.ui.controls = this.updateUiControls();
|
|
6301
|
-
const uiControls = venusApi.config.ui.controls;
|
|
6302
5601
|
const overlayContainer = document.createElement("div");
|
|
6303
5602
|
overlayContainer.id = "venus-mock-overlay";
|
|
6304
5603
|
overlayContainer.style.cssText = `
|
|
@@ -6314,7 +5613,7 @@ var MockHost = class {
|
|
|
6314
5613
|
const menuButton = this.createOverlayButton(
|
|
6315
5614
|
"close",
|
|
6316
5615
|
"Menu",
|
|
6317
|
-
|
|
5616
|
+
{ x: window.innerWidth - 48, y: 16, width: 32, height: 32 },
|
|
6318
5617
|
() => {
|
|
6319
5618
|
this.handleMenuButtonClicked();
|
|
6320
5619
|
},
|
|
@@ -6543,17 +5842,13 @@ var MockHost = class {
|
|
|
6543
5842
|
return button;
|
|
6544
5843
|
}
|
|
6545
5844
|
updateOverlayLayout() {
|
|
6546
|
-
const venusApi = this.venusApi;
|
|
6547
5845
|
const overlay = this._overlay;
|
|
6548
|
-
venusApi.config.ui.controls = this.updateUiControls();
|
|
6549
|
-
const uiControls = venusApi.config.ui.controls;
|
|
6550
5846
|
const menuBtn = overlay.elements.menuButton;
|
|
6551
|
-
|
|
6552
|
-
menuBtn.style.
|
|
6553
|
-
menuBtn.style.
|
|
6554
|
-
menuBtn.style.
|
|
6555
|
-
menuBtn.style.
|
|
6556
|
-
menuBtn.style.height = `${menuPos.height}px`;
|
|
5847
|
+
menuBtn.style.left = `${window.innerWidth - 48}px`;
|
|
5848
|
+
menuBtn.style.top = "16px";
|
|
5849
|
+
menuBtn.style.width = "32px";
|
|
5850
|
+
menuBtn.style.minWidth = "32px";
|
|
5851
|
+
menuBtn.style.height = "32px";
|
|
6557
5852
|
}
|
|
6558
5853
|
triggerLifecycleEvent(name) {
|
|
6559
5854
|
console.log("Trigger Lifecycle Event: ", name);
|
|
@@ -6741,6 +6036,11 @@ var MockHost = class {
|
|
|
6741
6036
|
}
|
|
6742
6037
|
};
|
|
6743
6038
|
|
|
6039
|
+
// src/utils/idGenerator.ts
|
|
6040
|
+
function generateId() {
|
|
6041
|
+
return `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
6042
|
+
}
|
|
6043
|
+
|
|
6744
6044
|
// src/rpc/RpcClient.ts
|
|
6745
6045
|
var RpcClient = class {
|
|
6746
6046
|
constructor() {
|
|
@@ -6783,7 +6083,7 @@ var RpcClient = class {
|
|
|
6783
6083
|
}
|
|
6784
6084
|
async call(method, args, timeout = 5e3) {
|
|
6785
6085
|
return new Promise((resolve, reject) => {
|
|
6786
|
-
const id =
|
|
6086
|
+
const id = generateId();
|
|
6787
6087
|
this.addPendingCall(id, resolve, reject);
|
|
6788
6088
|
const request = {
|
|
6789
6089
|
type: "rpc-request",
|
|
@@ -6820,9 +6120,6 @@ var RpcClient = class {
|
|
|
6820
6120
|
getPendingCall(id) {
|
|
6821
6121
|
return this.pendingCalls.get(id);
|
|
6822
6122
|
}
|
|
6823
|
-
generateId() {
|
|
6824
|
-
return `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
6825
|
-
}
|
|
6826
6123
|
handleRpcResponse(response) {
|
|
6827
6124
|
const pending = this.getPendingCall(response.id);
|
|
6828
6125
|
if (!pending) {
|
|
@@ -6885,6 +6182,16 @@ var VenusTransport = class {
|
|
|
6885
6182
|
this.isProcessingMessage = false;
|
|
6886
6183
|
return;
|
|
6887
6184
|
}
|
|
6185
|
+
if (message.type === "H5_SIMULATION_UPDATE" /* H5_SIMULATION_UPDATE */) {
|
|
6186
|
+
const notification = {
|
|
6187
|
+
type: "rpc-notification",
|
|
6188
|
+
id: message.type,
|
|
6189
|
+
payload: message.data
|
|
6190
|
+
};
|
|
6191
|
+
this.handleNotification(notification);
|
|
6192
|
+
this.isProcessingMessage = false;
|
|
6193
|
+
return;
|
|
6194
|
+
}
|
|
6888
6195
|
const requestId = messageData.requestId;
|
|
6889
6196
|
if (!requestId) {
|
|
6890
6197
|
this.logWarn("No requestId. Ignoring message...");
|
|
@@ -7051,294 +6358,361 @@ var VenusTransport = class {
|
|
|
7051
6358
|
}
|
|
7052
6359
|
};
|
|
7053
6360
|
|
|
7054
|
-
// src/
|
|
7055
|
-
|
|
7056
|
-
|
|
7057
|
-
// src/rooms/RpcRoomsApi.ts
|
|
7058
|
-
init_VenusRoom();
|
|
7059
|
-
var RpcRoomsApi = class {
|
|
6361
|
+
// src/simulation/RpcSimulationApi.ts
|
|
6362
|
+
var RpcSimulationApi = class {
|
|
7060
6363
|
constructor(rpcClient) {
|
|
7061
6364
|
__publicField(this, "rpcClient");
|
|
7062
|
-
__publicField(this, "
|
|
7063
|
-
__publicField(this, "
|
|
6365
|
+
__publicField(this, "_simulationConfig", null);
|
|
6366
|
+
__publicField(this, "subscriptionCallbacks", /* @__PURE__ */ new Map());
|
|
7064
6367
|
this.rpcClient = rpcClient;
|
|
7065
|
-
this.
|
|
7066
|
-
|
|
7067
|
-
|
|
7068
|
-
|
|
7069
|
-
allEvents: {}
|
|
7070
|
-
};
|
|
6368
|
+
this.rpcClient.onNotification(
|
|
6369
|
+
"H5_SIMULATION_UPDATE" /* H5_SIMULATION_UPDATE */,
|
|
6370
|
+
this.handleSimulationUpdate.bind(this)
|
|
6371
|
+
);
|
|
7071
6372
|
}
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
*/
|
|
7075
|
-
getSubscriptions() {
|
|
7076
|
-
return this.subscriptions;
|
|
6373
|
+
isEnabled() {
|
|
6374
|
+
return true;
|
|
7077
6375
|
}
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
|
|
7084
|
-
|
|
7085
|
-
|
|
6376
|
+
async validateSlotAssignmentAsync(containerId, slotId, itemId) {
|
|
6377
|
+
return this.rpcClient.call(
|
|
6378
|
+
"H5_SIMULATION_VALIDATE_ASSIGNMENT" /* H5_SIMULATION_VALIDATE_ASSIGNMENT */,
|
|
6379
|
+
{
|
|
6380
|
+
containerId,
|
|
6381
|
+
slotId,
|
|
6382
|
+
itemId
|
|
6383
|
+
}
|
|
7086
6384
|
);
|
|
7087
6385
|
}
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7091
|
-
|
|
7092
|
-
|
|
7093
|
-
this.
|
|
7094
|
-
|
|
7095
|
-
|
|
6386
|
+
async subscribeAsync(options) {
|
|
6387
|
+
this.ensureValidSubscribeOptions(options);
|
|
6388
|
+
const subscriptionId = generateId();
|
|
6389
|
+
this.subscriptionCallbacks.set(subscriptionId, options.onUpdate);
|
|
6390
|
+
try {
|
|
6391
|
+
await this.rpcClient.call("H5_SIMULATION_SUBSCRIBE" /* H5_SIMULATION_SUBSCRIBE */, {
|
|
6392
|
+
subscriptionId,
|
|
6393
|
+
entities: options.entities,
|
|
6394
|
+
tags: options.tags,
|
|
6395
|
+
activeRuns: options.activeRuns,
|
|
6396
|
+
roomId: options.roomId
|
|
6397
|
+
});
|
|
6398
|
+
} catch (error) {
|
|
6399
|
+
this.subscriptionCallbacks.delete(subscriptionId);
|
|
6400
|
+
throw error;
|
|
7096
6401
|
}
|
|
6402
|
+
let unsubscribed = false;
|
|
6403
|
+
return () => {
|
|
6404
|
+
if (unsubscribed) {
|
|
6405
|
+
return;
|
|
6406
|
+
}
|
|
6407
|
+
unsubscribed = true;
|
|
6408
|
+
this.subscriptionCallbacks.delete(subscriptionId);
|
|
6409
|
+
void this.rpcClient.call("H5_SIMULATION_UNSUBSCRIBE" /* H5_SIMULATION_UNSUBSCRIBE */, {
|
|
6410
|
+
subscriptionId
|
|
6411
|
+
}).catch((error) => {
|
|
6412
|
+
console.error(
|
|
6413
|
+
"[Venus SDK] Failed to unsubscribe simulation listener",
|
|
6414
|
+
error
|
|
6415
|
+
);
|
|
6416
|
+
});
|
|
6417
|
+
};
|
|
6418
|
+
}
|
|
6419
|
+
executeBatchOperationsAsync(operations, validateOnly) {
|
|
6420
|
+
return this.rpcClient.call(
|
|
6421
|
+
"H5_SIMULATION_BATCH_OPERATIONS" /* H5_SIMULATION_BATCH_OPERATIONS */,
|
|
6422
|
+
{
|
|
6423
|
+
operations,
|
|
6424
|
+
validateOnly
|
|
6425
|
+
}
|
|
6426
|
+
);
|
|
7097
6427
|
}
|
|
7098
|
-
async
|
|
6428
|
+
async getAvailableItemsAsync(containerId, slotId) {
|
|
7099
6429
|
const response = await this.rpcClient.call(
|
|
7100
|
-
"
|
|
6430
|
+
"H5_SIMULATION_GET_AVAILABLE_ITEMS" /* H5_SIMULATION_GET_AVAILABLE_ITEMS */,
|
|
7101
6431
|
{
|
|
7102
|
-
|
|
6432
|
+
containerId,
|
|
6433
|
+
slotId
|
|
6434
|
+
}
|
|
6435
|
+
);
|
|
6436
|
+
return response.availableItems || [];
|
|
6437
|
+
}
|
|
6438
|
+
calculatePowerPreviewAsync(containerId, slotId, candidateItemId) {
|
|
6439
|
+
return this.rpcClient.call(
|
|
6440
|
+
"H5_SIMULATION_CALCULATE_POWER_PREVIEW" /* H5_SIMULATION_CALCULATE_POWER_PREVIEW */,
|
|
6441
|
+
{
|
|
6442
|
+
containerId,
|
|
6443
|
+
slotId,
|
|
6444
|
+
candidateItemId
|
|
6445
|
+
}
|
|
6446
|
+
);
|
|
6447
|
+
}
|
|
6448
|
+
assignItemToSlotAsync(containerId, slotId, itemId) {
|
|
6449
|
+
return this.rpcClient.call(
|
|
6450
|
+
"H5_SIMULATION_ASSIGN_ITEM" /* H5_SIMULATION_ASSIGN_ITEM */,
|
|
6451
|
+
{
|
|
6452
|
+
containerId,
|
|
6453
|
+
slotId,
|
|
6454
|
+
itemId
|
|
6455
|
+
}
|
|
6456
|
+
);
|
|
6457
|
+
}
|
|
6458
|
+
removeItemFromSlotAsync(containerId, slotId) {
|
|
6459
|
+
return this.rpcClient.call(
|
|
6460
|
+
"H5_SIMULATION_REMOVE_ITEM" /* H5_SIMULATION_REMOVE_ITEM */,
|
|
6461
|
+
{
|
|
6462
|
+
containerId,
|
|
6463
|
+
slotId
|
|
7103
6464
|
}
|
|
7104
6465
|
);
|
|
7105
|
-
if (response.success === false) {
|
|
7106
|
-
throw new Error(response.error || "Failed to create room");
|
|
7107
|
-
}
|
|
7108
|
-
const roomData = response.roomData || response;
|
|
7109
|
-
const room = new VenusRoom(roomData);
|
|
7110
|
-
return room;
|
|
7111
6466
|
}
|
|
7112
|
-
async
|
|
6467
|
+
async getSlotContainersAsync() {
|
|
7113
6468
|
const response = await this.rpcClient.call(
|
|
7114
|
-
"
|
|
6469
|
+
"H5_SIMULATION_GET_CONTAINERS" /* H5_SIMULATION_GET_CONTAINERS */,
|
|
6470
|
+
{}
|
|
6471
|
+
);
|
|
6472
|
+
return response.containers || [];
|
|
6473
|
+
}
|
|
6474
|
+
async getSlotAssignmentsAsync(containerId) {
|
|
6475
|
+
const response = await this.rpcClient.call(
|
|
6476
|
+
"H5_SIMULATION_GET_ASSIGNMENTS" /* H5_SIMULATION_GET_ASSIGNMENTS */,
|
|
7115
6477
|
{
|
|
7116
|
-
|
|
6478
|
+
containerId
|
|
7117
6479
|
}
|
|
7118
6480
|
);
|
|
7119
|
-
|
|
7120
|
-
throw new Error(response.error || "Failed to join or create room");
|
|
7121
|
-
}
|
|
7122
|
-
const data = response.value || response;
|
|
7123
|
-
const room = new VenusRoom(data.roomData);
|
|
7124
|
-
return {
|
|
7125
|
-
action: data.action,
|
|
7126
|
-
room,
|
|
7127
|
-
playersJoined: data.playersJoined
|
|
7128
|
-
};
|
|
6481
|
+
return Array.isArray(response) ? response : response.assignments || [];
|
|
7129
6482
|
}
|
|
7130
|
-
async
|
|
6483
|
+
async getStateAsync(roomId) {
|
|
7131
6484
|
const response = await this.rpcClient.call(
|
|
7132
|
-
"
|
|
6485
|
+
"H5_SIMULATION_GET_STATE" /* H5_SIMULATION_GET_STATE */,
|
|
7133
6486
|
{
|
|
7134
|
-
|
|
6487
|
+
roomId
|
|
7135
6488
|
}
|
|
7136
6489
|
);
|
|
7137
|
-
if (response
|
|
7138
|
-
|
|
6490
|
+
if (response.configuration) {
|
|
6491
|
+
this._simulationConfig = response.configuration;
|
|
7139
6492
|
}
|
|
7140
|
-
|
|
7141
|
-
const room = new VenusRoom(roomData);
|
|
7142
|
-
return room;
|
|
6493
|
+
return response;
|
|
7143
6494
|
}
|
|
7144
|
-
|
|
7145
|
-
|
|
7146
|
-
|
|
7147
|
-
|
|
6495
|
+
async getConfigAsync(roomId) {
|
|
6496
|
+
if (this._simulationConfig) {
|
|
6497
|
+
return this._simulationConfig;
|
|
6498
|
+
}
|
|
6499
|
+
const config = await this.rpcClient.call(
|
|
6500
|
+
"H5_SIMULATION_GET_CONFIG" /* H5_SIMULATION_GET_CONFIG */,
|
|
7148
6501
|
{
|
|
7149
|
-
|
|
6502
|
+
roomId
|
|
7150
6503
|
}
|
|
7151
6504
|
);
|
|
7152
|
-
if (
|
|
7153
|
-
|
|
6505
|
+
if (config) {
|
|
6506
|
+
this._simulationConfig = config;
|
|
6507
|
+
return config;
|
|
7154
6508
|
}
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
|
|
6509
|
+
throw new Error("No simulation configuration available");
|
|
6510
|
+
}
|
|
6511
|
+
executeRecipeAsync(recipeId, inputs, options) {
|
|
6512
|
+
return this.rpcClient.call(
|
|
6513
|
+
"H5_SIMULATION_EXECUTE_RECIPE" /* H5_SIMULATION_EXECUTE_RECIPE */,
|
|
6514
|
+
{
|
|
6515
|
+
recipeId,
|
|
6516
|
+
inputs,
|
|
6517
|
+
roomId: options?.roomId,
|
|
6518
|
+
batchAmount: options?.batchAmount,
|
|
6519
|
+
allowPartialBatch: options?.allowPartialBatch,
|
|
6520
|
+
entity: options?.entity
|
|
7161
6521
|
}
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
|
|
7167
|
-
|
|
7168
|
-
|
|
7169
|
-
|
|
7170
|
-
|
|
6522
|
+
);
|
|
6523
|
+
}
|
|
6524
|
+
collectRecipeAsync(runId) {
|
|
6525
|
+
return this.rpcClient.call("H5_SIMULATION_COLLECT_RECIPE" /* H5_SIMULATION_COLLECT_RECIPE */, {
|
|
6526
|
+
runId
|
|
6527
|
+
});
|
|
6528
|
+
}
|
|
6529
|
+
getActiveRunsAsync(options) {
|
|
6530
|
+
return this.rpcClient.call(
|
|
6531
|
+
"H5_SIMULATION_GET_ACTIVE_RUNS" /* H5_SIMULATION_GET_ACTIVE_RUNS */,
|
|
6532
|
+
{
|
|
6533
|
+
roomId: options?.roomId
|
|
7171
6534
|
}
|
|
7172
|
-
|
|
7173
|
-
|
|
6535
|
+
);
|
|
6536
|
+
}
|
|
6537
|
+
executeScopedRecipeAsync(recipeId, entity, inputs, options) {
|
|
6538
|
+
return this.rpcClient.call(
|
|
6539
|
+
"H5_SIMULATION_EXECUTE_SCOPED_RECIPE" /* H5_SIMULATION_EXECUTE_SCOPED_RECIPE */,
|
|
6540
|
+
{
|
|
6541
|
+
recipeId,
|
|
6542
|
+
entity,
|
|
6543
|
+
inputs,
|
|
6544
|
+
roomId: options?.roomId ?? null,
|
|
6545
|
+
options
|
|
6546
|
+
}
|
|
6547
|
+
);
|
|
7174
6548
|
}
|
|
7175
|
-
|
|
7176
|
-
|
|
7177
|
-
"
|
|
6549
|
+
getAvailableRecipesAsync(options) {
|
|
6550
|
+
return this.rpcClient.call(
|
|
6551
|
+
"H5_SIMULATION_GET_AVAILABLE_RECIPES" /* H5_SIMULATION_GET_AVAILABLE_RECIPES */,
|
|
7178
6552
|
{
|
|
7179
|
-
roomId:
|
|
7180
|
-
|
|
7181
|
-
merge
|
|
6553
|
+
roomId: options?.roomId || null,
|
|
6554
|
+
includeActorRecipes: options?.includeActorRecipes || false
|
|
7182
6555
|
}
|
|
7183
6556
|
);
|
|
7184
|
-
if (response?.success === false) {
|
|
7185
|
-
throw new Error(response.error || "Failed to update room data");
|
|
7186
|
-
}
|
|
7187
|
-
return response.data;
|
|
7188
6557
|
}
|
|
7189
|
-
|
|
7190
|
-
|
|
7191
|
-
"
|
|
6558
|
+
getRecipeRequirementsAsync(recipe) {
|
|
6559
|
+
return this.rpcClient.call(
|
|
6560
|
+
"H5_SIMULATION_GET_RECIPE_REQUIREMENTS" /* H5_SIMULATION_GET_RECIPE_REQUIREMENTS */,
|
|
7192
6561
|
{
|
|
7193
|
-
|
|
6562
|
+
recipeId: recipe.recipeId,
|
|
6563
|
+
entity: recipe.entity,
|
|
6564
|
+
batchAmount: recipe.batchAmount
|
|
7194
6565
|
}
|
|
7195
6566
|
);
|
|
7196
|
-
if (response?.success === false) {
|
|
7197
|
-
throw new Error(response.error || "Failed to get room data");
|
|
7198
|
-
}
|
|
7199
|
-
return response.data;
|
|
7200
6567
|
}
|
|
7201
|
-
|
|
7202
|
-
|
|
7203
|
-
"
|
|
6568
|
+
getBatchRecipeRequirementsAsync(recipes) {
|
|
6569
|
+
return this.rpcClient.call(
|
|
6570
|
+
"H5_SIMULATION_GET_BATCH_RECIPE_REQUIREMENTS" /* H5_SIMULATION_GET_BATCH_RECIPE_REQUIREMENTS */,
|
|
7204
6571
|
{
|
|
7205
|
-
|
|
7206
|
-
message: messageData
|
|
6572
|
+
recipes
|
|
7207
6573
|
}
|
|
7208
6574
|
);
|
|
7209
|
-
if (response?.success === false) {
|
|
7210
|
-
throw new Error(response.error || "Failed to send message");
|
|
7211
|
-
}
|
|
7212
|
-
return response.messageId;
|
|
7213
6575
|
}
|
|
7214
|
-
|
|
7215
|
-
|
|
7216
|
-
"
|
|
6576
|
+
triggerRecipeChainAsync(recipeId, options) {
|
|
6577
|
+
return this.rpcClient.call(
|
|
6578
|
+
"H5_SIMULATION_TRIGGER_RECIPE_CHAIN" /* H5_SIMULATION_TRIGGER_RECIPE_CHAIN */,
|
|
7217
6579
|
{
|
|
7218
|
-
|
|
6580
|
+
triggerRecipeId: recipeId,
|
|
6581
|
+
context: options?.context,
|
|
6582
|
+
roomId: options?.roomId
|
|
7219
6583
|
}
|
|
7220
6584
|
);
|
|
7221
|
-
if (response?.success === false) {
|
|
7222
|
-
throw new Error(response.error || "Failed to leave room");
|
|
7223
|
-
}
|
|
7224
|
-
return response;
|
|
7225
6585
|
}
|
|
7226
|
-
|
|
7227
|
-
|
|
7228
|
-
"
|
|
6586
|
+
getEntityMetadataAsync(entityId) {
|
|
6587
|
+
return this.rpcClient.call(
|
|
6588
|
+
"H5_SIMULATION_GET_ENTITY_METADATA" /* H5_SIMULATION_GET_ENTITY_METADATA */,
|
|
7229
6589
|
{
|
|
7230
|
-
|
|
7231
|
-
gameConfig,
|
|
7232
|
-
turnOrder
|
|
6590
|
+
entityId
|
|
7233
6591
|
}
|
|
7234
6592
|
);
|
|
7235
|
-
if (response?.success === false) {
|
|
7236
|
-
throw new Error(response.error || "Failed to start game");
|
|
7237
|
-
}
|
|
7238
|
-
return response.data;
|
|
7239
6593
|
}
|
|
7240
|
-
async
|
|
6594
|
+
async resolveFieldValueAsync(entityId, fieldPath, entity) {
|
|
7241
6595
|
const response = await this.rpcClient.call(
|
|
7242
|
-
"
|
|
6596
|
+
"H5_SIMULATION_RESOLVE_VALUE" /* H5_SIMULATION_RESOLVE_VALUE */,
|
|
7243
6597
|
{
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
|
|
7247
|
-
clientContext: proposalPayload.clientContext,
|
|
7248
|
-
clientProposalId: proposalPayload.clientProposalId
|
|
6598
|
+
entityId,
|
|
6599
|
+
fieldPath,
|
|
6600
|
+
entity
|
|
7249
6601
|
}
|
|
7250
6602
|
);
|
|
7251
|
-
|
|
7252
|
-
throw new Error(response.error || "Failed to propose move");
|
|
7253
|
-
}
|
|
7254
|
-
return response.data;
|
|
7255
|
-
}
|
|
7256
|
-
async validateMove(room, moveId, isValid, reason = null, validatorId = null) {
|
|
7257
|
-
console.log(`[Venus Rooms] Validating move ${moveId}: ${isValid}`);
|
|
7258
|
-
return { success: true, moveId, isValid, reason };
|
|
6603
|
+
return response.value;
|
|
7259
6604
|
}
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
|
|
6605
|
+
handleSimulationUpdate(notification) {
|
|
6606
|
+
if (!notification || !notification.subscriptionId) {
|
|
6607
|
+
console.warn("[Venus SDK] Received malformed simulation update");
|
|
6608
|
+
return;
|
|
7264
6609
|
}
|
|
7265
|
-
this.
|
|
7266
|
-
|
|
7267
|
-
|
|
7268
|
-
|
|
7269
|
-
|
|
7270
|
-
|
|
7271
|
-
|
|
7272
|
-
if (!this.subscriptions.data[roomId]) {
|
|
7273
|
-
this.subscriptions.data[roomId] = [];
|
|
7274
|
-
}
|
|
7275
|
-
this.subscriptions.data[roomId].push(options.onData);
|
|
7276
|
-
subscriptionIds.push({
|
|
7277
|
-
type: "data",
|
|
7278
|
-
id: dataSubId,
|
|
7279
|
-
callback: options.onData
|
|
7280
|
-
});
|
|
6610
|
+
const callback = this.subscriptionCallbacks.get(notification.subscriptionId);
|
|
6611
|
+
if (!callback) {
|
|
6612
|
+
console.warn(
|
|
6613
|
+
"[Venus SDK] Received update for unknown subscription:",
|
|
6614
|
+
notification.subscriptionId
|
|
6615
|
+
);
|
|
6616
|
+
return;
|
|
7281
6617
|
}
|
|
7282
|
-
|
|
7283
|
-
|
|
7284
|
-
|
|
7285
|
-
|
|
7286
|
-
}
|
|
7287
|
-
this.subscriptions.messages[roomId].push(options.onMessages);
|
|
7288
|
-
subscriptionIds.push({
|
|
7289
|
-
type: "messages",
|
|
7290
|
-
id: msgSubId,
|
|
7291
|
-
callback: options.onMessages
|
|
7292
|
-
});
|
|
6618
|
+
try {
|
|
6619
|
+
callback(notification.updates);
|
|
6620
|
+
} catch (error) {
|
|
6621
|
+
console.error("[Venus SDK] Error in simulation subscription callback", error);
|
|
7293
6622
|
}
|
|
7294
|
-
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
|
|
7298
|
-
if (!this.subscriptions.gameEvents[roomId]) {
|
|
7299
|
-
this.subscriptions.gameEvents[roomId] = [];
|
|
7300
|
-
}
|
|
7301
|
-
this.subscriptions.gameEvents[roomId].push(handler);
|
|
7302
|
-
subscriptionIds.push({
|
|
7303
|
-
type: "gameEvents",
|
|
7304
|
-
id: gameSubId,
|
|
7305
|
-
callback: handler
|
|
7306
|
-
});
|
|
7307
|
-
}
|
|
6623
|
+
}
|
|
6624
|
+
ensureValidSubscribeOptions(options) {
|
|
6625
|
+
if (typeof options !== "object" || options === null) {
|
|
6626
|
+
throw new Error("Simulation subscribe requires an options object");
|
|
7308
6627
|
}
|
|
7309
|
-
const
|
|
7310
|
-
if (
|
|
7311
|
-
|
|
7312
|
-
|
|
7313
|
-
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
|
|
7317
|
-
|
|
7318
|
-
});
|
|
6628
|
+
const opts = options;
|
|
6629
|
+
if (typeof opts.onUpdate !== "function") {
|
|
6630
|
+
throw new Error("Simulation subscribe requires an onUpdate callback");
|
|
6631
|
+
}
|
|
6632
|
+
const hasFilter = Array.isArray(opts.entities) && opts.entities.length > 0 || Array.isArray(opts.tags) && opts.tags.length > 0 || Boolean(opts.activeRuns);
|
|
6633
|
+
if (!hasFilter) {
|
|
6634
|
+
throw new Error(
|
|
6635
|
+
"Simulation subscribe requires at least one filter (entities, tags, activeRuns)"
|
|
6636
|
+
);
|
|
7319
6637
|
}
|
|
7320
|
-
let called = false;
|
|
7321
|
-
return () => {
|
|
7322
|
-
if (called) return;
|
|
7323
|
-
called = true;
|
|
7324
|
-
subscriptionIds.forEach((sub) => {
|
|
7325
|
-
const bucket = this.subscriptions[sub.type];
|
|
7326
|
-
const callbacks = bucket && bucket[roomId] || [];
|
|
7327
|
-
const index = callbacks.indexOf(sub.callback);
|
|
7328
|
-
if (index > -1) callbacks.splice(index, 1);
|
|
7329
|
-
});
|
|
7330
|
-
const hasNoCallbacks = (this.subscriptions.data[roomId]?.length ?? 0) === 0 && (this.subscriptions.messages[roomId]?.length ?? 0) === 0 && (this.subscriptions.gameEvents[roomId]?.length ?? 0) === 0;
|
|
7331
|
-
if (hasNoCallbacks) {
|
|
7332
|
-
this.rpcClient.call("H5_ROOM_UNSUBSCRIBE" /* H5_ROOM_UNSUBSCRIBE */, {
|
|
7333
|
-
roomId
|
|
7334
|
-
}).catch((error) => {
|
|
7335
|
-
console.error("Failed to clean up room subscription:", error);
|
|
7336
|
-
});
|
|
7337
|
-
}
|
|
7338
|
-
};
|
|
7339
6638
|
}
|
|
7340
6639
|
};
|
|
7341
6640
|
|
|
6641
|
+
// src/simulation/index.ts
|
|
6642
|
+
function initializeSimulation(venusApi, host) {
|
|
6643
|
+
venusApi.simulation = {
|
|
6644
|
+
isEnabled: () => true
|
|
6645
|
+
};
|
|
6646
|
+
venusApi.simulation.getConfigAsync = () => {
|
|
6647
|
+
return host.simulation.getConfigAsync();
|
|
6648
|
+
};
|
|
6649
|
+
venusApi.simulation.getStateAsync = (roomId) => {
|
|
6650
|
+
return host.simulation.getStateAsync(roomId);
|
|
6651
|
+
};
|
|
6652
|
+
venusApi.simulation.executeRecipeAsync = (recipeId, inputs, options) => {
|
|
6653
|
+
return host.simulation.executeRecipeAsync(recipeId, inputs, options);
|
|
6654
|
+
};
|
|
6655
|
+
venusApi.simulation.getActiveRunsAsync = () => {
|
|
6656
|
+
return host.simulation.getActiveRunsAsync();
|
|
6657
|
+
};
|
|
6658
|
+
venusApi.simulation.collectRecipeAsync = (runId) => {
|
|
6659
|
+
return host.simulation.collectRecipeAsync(runId);
|
|
6660
|
+
};
|
|
6661
|
+
venusApi.simulation.executeScopedRecipeAsync = (recipeId, entity, inputs, options) => {
|
|
6662
|
+
return host.simulation.executeScopedRecipeAsync(recipeId, entity, inputs, options);
|
|
6663
|
+
};
|
|
6664
|
+
venusApi.simulation.triggerRecipeChainAsync = (recipeId, options) => {
|
|
6665
|
+
return host.simulation.triggerRecipeChainAsync(recipeId, options);
|
|
6666
|
+
};
|
|
6667
|
+
venusApi.simulation.getAvailableRecipesAsync = async (options) => {
|
|
6668
|
+
return host.simulation.getAvailableRecipesAsync(options);
|
|
6669
|
+
};
|
|
6670
|
+
venusApi.simulation.getRecipeRequirementsAsync = (recipe) => {
|
|
6671
|
+
return host.simulation.getRecipeRequirementsAsync(recipe);
|
|
6672
|
+
};
|
|
6673
|
+
venusApi.simulation.getBatchRecipeRequirementsAsync = (recipes) => {
|
|
6674
|
+
return host.simulation.getBatchRecipeRequirementsAsync(recipes);
|
|
6675
|
+
};
|
|
6676
|
+
venusApi.simulation.resolveFieldValueAsync = (entityId, fieldPath, entity) => {
|
|
6677
|
+
return host.simulation.resolveFieldValueAsync(entityId, fieldPath, entity);
|
|
6678
|
+
};
|
|
6679
|
+
venusApi.simulation.getEntityMetadataAsync = (entityId) => {
|
|
6680
|
+
return host.simulation.getEntityMetadataAsync(entityId);
|
|
6681
|
+
};
|
|
6682
|
+
venusApi.simulation.getSlotAssignmentsAsync = (containerId) => {
|
|
6683
|
+
return host.simulation.getSlotAssignmentsAsync(containerId);
|
|
6684
|
+
};
|
|
6685
|
+
venusApi.simulation.getSlotContainersAsync = () => {
|
|
6686
|
+
return host.simulation.getSlotContainersAsync();
|
|
6687
|
+
};
|
|
6688
|
+
venusApi.simulation.assignItemToSlotAsync = (containerId, slotId, itemId) => {
|
|
6689
|
+
return host.simulation.assignItemToSlotAsync(containerId, slotId, itemId);
|
|
6690
|
+
};
|
|
6691
|
+
venusApi.simulation.removeItemFromSlotAsync = (containerId, slotId) => {
|
|
6692
|
+
return host.simulation.removeItemFromSlotAsync(containerId, slotId);
|
|
6693
|
+
};
|
|
6694
|
+
venusApi.simulation.getAvailableItemsAsync = (containerId, slotId) => {
|
|
6695
|
+
return host.simulation.getAvailableItemsAsync(containerId, slotId);
|
|
6696
|
+
};
|
|
6697
|
+
venusApi.simulation.calculatePowerPreviewAsync = (containerId, slotId, candidateItemId) => {
|
|
6698
|
+
return host.simulation.calculatePowerPreviewAsync(
|
|
6699
|
+
containerId,
|
|
6700
|
+
slotId,
|
|
6701
|
+
candidateItemId
|
|
6702
|
+
);
|
|
6703
|
+
};
|
|
6704
|
+
venusApi.simulation.executeBatchOperationsAsync = (operations, validateOnly) => {
|
|
6705
|
+
return host.simulation.executeBatchOperationsAsync(operations, validateOnly);
|
|
6706
|
+
};
|
|
6707
|
+
venusApi.simulation.validateSlotAssignmentAsync = (containerId, slotId, itemId) => {
|
|
6708
|
+
return host.simulation.validateSlotAssignmentAsync(
|
|
6709
|
+
containerId,
|
|
6710
|
+
slotId,
|
|
6711
|
+
itemId
|
|
6712
|
+
);
|
|
6713
|
+
};
|
|
6714
|
+
}
|
|
6715
|
+
|
|
7342
6716
|
// src/social/RpcSocialApi.ts
|
|
7343
6717
|
var RpcSocialApi = class {
|
|
7344
6718
|
constructor(rpcClient) {
|
|
@@ -7385,9 +6759,9 @@ var RemoteHost = class {
|
|
|
7385
6759
|
__publicField(this, "notifications");
|
|
7386
6760
|
__publicField(this, "popups");
|
|
7387
6761
|
__publicField(this, "profile");
|
|
6762
|
+
__publicField(this, "system");
|
|
7388
6763
|
__publicField(this, "cdn");
|
|
7389
6764
|
__publicField(this, "time");
|
|
7390
|
-
__publicField(this, "post");
|
|
7391
6765
|
__publicField(this, "ai");
|
|
7392
6766
|
__publicField(this, "haptics");
|
|
7393
6767
|
__publicField(this, "features");
|
|
@@ -7441,10 +6815,12 @@ var RemoteHost = class {
|
|
|
7441
6815
|
this.navigation = new RpcNavigationApi(rpcClient, venusApi);
|
|
7442
6816
|
this.notifications = new RpcNotificationsApi(rpcClient);
|
|
7443
6817
|
this.popups = new RpcPopupsApi(rpcClient);
|
|
7444
|
-
this.profile = new HostProfileApi();
|
|
6818
|
+
this.profile = new HostProfileApi(venusApi);
|
|
6819
|
+
const deviceApi = new HostDeviceApi(venusApi);
|
|
6820
|
+
const environmentApi = new HostEnvironmentApi(venusApi);
|
|
6821
|
+
this.system = new HostSystemApi(deviceApi, environmentApi, venusApi);
|
|
7445
6822
|
this.cdn = new HostCdnApi(getCdnBaseUrl());
|
|
7446
6823
|
this.time = new HostTimeApi(rpcClient, venusApi);
|
|
7447
|
-
this.post = new RpcPostApi(rpcClient);
|
|
7448
6824
|
this.ai = new RpcAiApi(rpcClient);
|
|
7449
6825
|
this.haptics = new RpcHapticsApi(rpcClient);
|
|
7450
6826
|
this.features = new RpcFeaturesApi(rpcClient);
|
|
@@ -7459,7 +6835,6 @@ var RemoteHost = class {
|
|
|
7459
6835
|
venusApi.isMock = () => false;
|
|
7460
6836
|
this.venusApi.sharedAssets = new RpcSharedAssetsApi(rpcClient, venusApi);
|
|
7461
6837
|
initializeRoomsApi(this.venusApi, this);
|
|
7462
|
-
console.log("[Venus SDK] Remote host created");
|
|
7463
6838
|
}
|
|
7464
6839
|
get isInitialized() {
|
|
7465
6840
|
return this._isInitialized;
|
|
@@ -7478,35 +6853,27 @@ var RemoteHost = class {
|
|
|
7478
6853
|
);
|
|
7479
6854
|
transport.instanceId = response.instanceId;
|
|
7480
6855
|
this.log(`Remote Host Initialized with id: ${transport.instanceId}`);
|
|
7481
|
-
|
|
7482
|
-
|
|
7483
|
-
|
|
7484
|
-
|
|
7485
|
-
|
|
7486
|
-
|
|
7487
|
-
|
|
7488
|
-
|
|
7489
|
-
|
|
7490
|
-
|
|
7491
|
-
|
|
7492
|
-
|
|
7493
|
-
if (venus._config) {
|
|
7494
|
-
venus._config.profile = sanitizedProfile;
|
|
7495
|
-
}
|
|
7496
|
-
if (venus.config) {
|
|
7497
|
-
venus.config.profile = sanitizedProfile;
|
|
7498
|
-
}
|
|
7499
|
-
}
|
|
7500
|
-
}
|
|
6856
|
+
const profile = response.profile;
|
|
6857
|
+
const sanitizedProfile = {
|
|
6858
|
+
id: profile.id,
|
|
6859
|
+
username: profile.username,
|
|
6860
|
+
avatarUrl: profile.avatarUrl ?? null,
|
|
6861
|
+
isAnonymous: Boolean(profile.isAnonymous)
|
|
6862
|
+
};
|
|
6863
|
+
this.venusApi._profileData = sanitizedProfile;
|
|
6864
|
+
this.venusApi._deviceData = response.device;
|
|
6865
|
+
this.venusApi._environmentData = response.environment;
|
|
6866
|
+
this.venusApi._localeData = response.locale;
|
|
6867
|
+
this.venusApi._languageCodeData = response.languageCode;
|
|
7501
6868
|
this._isInitialized = true;
|
|
7502
|
-
this.venusApi.launchParams = response.launchParams
|
|
6869
|
+
this.venusApi.launchParams = response.launchParams;
|
|
7503
6870
|
await this.rpcClient.call("READY" /* READY */, {});
|
|
7504
|
-
const
|
|
7505
|
-
if (
|
|
7506
|
-
this.venusApi.
|
|
6871
|
+
const safeArea = response.safeArea;
|
|
6872
|
+
if (safeArea) {
|
|
6873
|
+
this.venusApi._safeAreaData = safeArea;
|
|
7507
6874
|
}
|
|
7508
6875
|
return {
|
|
7509
|
-
|
|
6876
|
+
safeArea,
|
|
7510
6877
|
initializeAsleep: response.initializeAsleep
|
|
7511
6878
|
};
|
|
7512
6879
|
}
|
|
@@ -7518,19 +6885,14 @@ var RemoteHost = class {
|
|
|
7518
6885
|
// src/Host.ts
|
|
7519
6886
|
function createHost(venusApi, isMock) {
|
|
7520
6887
|
if (isMock) {
|
|
7521
|
-
console.log("[Venus SDK] Creating Local Host");
|
|
7522
6888
|
return new MockHost(venusApi);
|
|
7523
6889
|
} else {
|
|
7524
|
-
console.log("[Venus SDK] Creating Remote Host");
|
|
7525
6890
|
return new RemoteHost(venusApi);
|
|
7526
6891
|
}
|
|
7527
6892
|
}
|
|
7528
6893
|
|
|
7529
|
-
// src/venus-api/index.js
|
|
7530
|
-
init_rooms();
|
|
7531
|
-
|
|
7532
6894
|
// src/version.ts
|
|
7533
|
-
var SDK_VERSION = "3.1.
|
|
6895
|
+
var SDK_VERSION = "3.1.1";
|
|
7534
6896
|
|
|
7535
6897
|
// src/social/index.ts
|
|
7536
6898
|
function initializeSocial(venusApi, host) {
|
|
@@ -7580,82 +6942,8 @@ var VenusAPI2 = class {
|
|
|
7580
6942
|
bottom: 10,
|
|
7581
6943
|
left: 0
|
|
7582
6944
|
},
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
menuButton: { x: window.innerWidth - 48, y: 16, width: 32, height: 32 },
|
|
7586
|
-
feedHeader: { x: 0, y: 0, width: window.innerWidth, height: 66 },
|
|
7587
|
-
playButton: {
|
|
7588
|
-
x: 0,
|
|
7589
|
-
y: window.innerHeight - 60,
|
|
7590
|
-
width: window.innerWidth,
|
|
7591
|
-
height: 60
|
|
7592
|
-
}
|
|
7593
|
-
},
|
|
7594
|
-
// Complete theme structure (matching createH5Theme output)
|
|
7595
|
-
theme: {
|
|
7596
|
-
background: {
|
|
7597
|
-
default: "#131419",
|
|
7598
|
-
muted: "#1b1d25",
|
|
7599
|
-
dark: "#0d0e11"
|
|
7600
|
-
},
|
|
7601
|
-
text: {
|
|
7602
|
-
primary: "#ffffff",
|
|
7603
|
-
muted: "#808080",
|
|
7604
|
-
inverted: "#000000"
|
|
7605
|
-
},
|
|
7606
|
-
theme: {
|
|
7607
|
-
primary: "#f6c833",
|
|
7608
|
-
secondary: "#6366f1",
|
|
7609
|
-
background: "#131419",
|
|
7610
|
-
border: "#262626",
|
|
7611
|
-
card: "#1b1d25",
|
|
7612
|
-
"card-glass": "rgba(27, 29, 37, 0.8)"
|
|
7613
|
-
},
|
|
7614
|
-
typography: {
|
|
7615
|
-
fontFamily: {
|
|
7616
|
-
base: "Plus Jakarta Sans, Roboto, sans-serif",
|
|
7617
|
-
heading: "Plus Jakarta Sans, Roboto, sans-serif",
|
|
7618
|
-
mono: "monospace"
|
|
7619
|
-
},
|
|
7620
|
-
fontSize: {
|
|
7621
|
-
"2xs": "10px",
|
|
7622
|
-
xs: "12px",
|
|
7623
|
-
sm: "14px",
|
|
7624
|
-
md: "16px",
|
|
7625
|
-
lg: "18px",
|
|
7626
|
-
xl: "20px",
|
|
7627
|
-
"2xl": "24px",
|
|
7628
|
-
"3xl": "30px",
|
|
7629
|
-
"4xl": "36px",
|
|
7630
|
-
"5xl": "48px",
|
|
7631
|
-
"6xl": "60px"
|
|
7632
|
-
},
|
|
7633
|
-
fontWeight: {
|
|
7634
|
-
thin: "100",
|
|
7635
|
-
extralight: "200",
|
|
7636
|
-
light: "300",
|
|
7637
|
-
regular: "400",
|
|
7638
|
-
medium: "500",
|
|
7639
|
-
semibold: "600",
|
|
7640
|
-
bold: "700",
|
|
7641
|
-
extrabold: "800",
|
|
7642
|
-
black: "900",
|
|
7643
|
-
extrablack: "950"
|
|
7644
|
-
},
|
|
7645
|
-
lineHeight: {
|
|
7646
|
-
none: "1",
|
|
7647
|
-
tight: "1.25",
|
|
7648
|
-
snug: "1.375",
|
|
7649
|
-
normal: "1.5",
|
|
7650
|
-
relaxed: "1.625",
|
|
7651
|
-
loose: "2"
|
|
7652
|
-
}
|
|
7653
|
-
}
|
|
7654
|
-
},
|
|
7655
|
-
// Static locale data at top level
|
|
7656
|
-
locale: "en-US",
|
|
7657
|
-
languageCode: "en",
|
|
7658
|
-
// Note: Profile is now separate from config and accessed via getCurrentProfile()
|
|
6945
|
+
// NOTE: locale and languageCode are NOT part of static config
|
|
6946
|
+
// They are delivered via INIT_SDK handshake and accessed via getLocale()/getLanguageCode()
|
|
7659
6947
|
// Complete environment info (matching buildStaticConfig)
|
|
7660
6948
|
environment: {
|
|
7661
6949
|
isDevelopment: true,
|
|
@@ -7709,12 +6997,6 @@ var VenusAPI2 = class {
|
|
|
7709
6997
|
onHide: null,
|
|
7710
6998
|
onShow: null
|
|
7711
6999
|
},
|
|
7712
|
-
currentPostInteractions: {
|
|
7713
|
-
isLiked: false,
|
|
7714
|
-
isFollowing: false,
|
|
7715
|
-
likesCount: 42,
|
|
7716
|
-
commentsCount: 7
|
|
7717
|
-
},
|
|
7718
7000
|
// Platform overrides for testing different environments
|
|
7719
7001
|
platformOverrides: {
|
|
7720
7002
|
isMobile: true,
|
|
@@ -7723,137 +7005,74 @@ var VenusAPI2 = class {
|
|
|
7723
7005
|
};
|
|
7724
7006
|
this._detectHostedEnvironment();
|
|
7725
7007
|
this.launchParams = {};
|
|
7726
|
-
this.config = createProxiedObject.call(this, "config", {
|
|
7727
|
-
locale: "en-US",
|
|
7728
|
-
languageCode: "en",
|
|
7729
|
-
// Note: Profile is no longer in config - use getCurrentProfile() instead
|
|
7730
|
-
environment: {
|
|
7731
|
-
isDevelopment: true,
|
|
7732
|
-
platform: typeof navigator !== "undefined" ? navigator.platform : "unknown",
|
|
7733
|
-
platformVersion: "unknown",
|
|
7734
|
-
browserInfo: {
|
|
7735
|
-
browser: "unknown",
|
|
7736
|
-
userAgent: typeof navigator !== "undefined" ? navigator.userAgent : "unknown",
|
|
7737
|
-
isMobile: true,
|
|
7738
|
-
isTablet: false,
|
|
7739
|
-
language: typeof navigator !== "undefined" ? navigator.language : "en-US"
|
|
7740
|
-
}
|
|
7741
|
-
},
|
|
7742
|
-
ui: {
|
|
7743
|
-
controls: {
|
|
7744
|
-
closeButton: { x: 16, y: 16, width: 32, height: 32 },
|
|
7745
|
-
menuButton: {
|
|
7746
|
-
x: typeof window !== "undefined" ? window.innerWidth - 48 : 352,
|
|
7747
|
-
y: 16,
|
|
7748
|
-
width: 32,
|
|
7749
|
-
height: 32
|
|
7750
|
-
},
|
|
7751
|
-
feedHeader: {
|
|
7752
|
-
x: 0,
|
|
7753
|
-
y: 0,
|
|
7754
|
-
width: typeof window !== "undefined" ? window.innerWidth : 400,
|
|
7755
|
-
height: 66
|
|
7756
|
-
},
|
|
7757
|
-
playButton: {
|
|
7758
|
-
x: 0,
|
|
7759
|
-
y: typeof window !== "undefined" ? window.innerHeight - 60 : 740,
|
|
7760
|
-
width: typeof window !== "undefined" ? window.innerWidth : 400,
|
|
7761
|
-
height: 60
|
|
7762
|
-
}
|
|
7763
|
-
},
|
|
7764
|
-
safeArea: { top: 44, left: 0, right: 0, bottom: 34 },
|
|
7765
|
-
hudInsets: {
|
|
7766
|
-
preview: { top: 60, left: 0, right: 0, bottom: 40 },
|
|
7767
|
-
fullscreen: { top: 44, left: 0, right: 0, bottom: 34 }
|
|
7768
|
-
}
|
|
7769
|
-
},
|
|
7770
|
-
device: {
|
|
7771
|
-
screenSize: {
|
|
7772
|
-
width: typeof window !== "undefined" ? window.screen?.width || 0 : 0,
|
|
7773
|
-
height: typeof window !== "undefined" ? window.screen?.height || 0 : 0
|
|
7774
|
-
},
|
|
7775
|
-
viewportSize: {
|
|
7776
|
-
width: typeof window !== "undefined" ? window.innerWidth : 0,
|
|
7777
|
-
height: typeof window !== "undefined" ? window.innerHeight : 0
|
|
7778
|
-
},
|
|
7779
|
-
orientation: "portrait",
|
|
7780
|
-
pixelRatio: typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1,
|
|
7781
|
-
fontScale: 1,
|
|
7782
|
-
deviceType: "phone",
|
|
7783
|
-
hapticsEnabled: false,
|
|
7784
|
-
haptics: { supported: false, enabled: false }
|
|
7785
|
-
},
|
|
7786
|
-
theme: {
|
|
7787
|
-
background: { default: "#131419", muted: "#1b1d25", dark: "#0d0e11" },
|
|
7788
|
-
text: { primary: "#ffffff", muted: "#808080", inverted: "#000000" },
|
|
7789
|
-
theme: {
|
|
7790
|
-
primary: "#f6c833",
|
|
7791
|
-
secondary: "#6366f1",
|
|
7792
|
-
background: "#131419",
|
|
7793
|
-
border: "#262626",
|
|
7794
|
-
card: "#1b1d25",
|
|
7795
|
-
"card-glass": "rgba(27, 29, 37, 0.8)"
|
|
7796
|
-
},
|
|
7797
|
-
typography: {
|
|
7798
|
-
fontFamily: {
|
|
7799
|
-
base: "Plus Jakarta Sans, Roboto, sans-serif",
|
|
7800
|
-
heading: "Plus Jakarta Sans, Roboto, sans-serif",
|
|
7801
|
-
mono: "monospace"
|
|
7802
|
-
},
|
|
7803
|
-
fontSize: {
|
|
7804
|
-
"2xs": "10px",
|
|
7805
|
-
xs: "12px",
|
|
7806
|
-
sm: "14px",
|
|
7807
|
-
md: "16px",
|
|
7808
|
-
lg: "18px",
|
|
7809
|
-
xl: "20px",
|
|
7810
|
-
"2xl": "24px",
|
|
7811
|
-
"3xl": "30px",
|
|
7812
|
-
"4xl": "36px",
|
|
7813
|
-
"5xl": "48px",
|
|
7814
|
-
"6xl": "60px"
|
|
7815
|
-
},
|
|
7816
|
-
fontWeight: {
|
|
7817
|
-
thin: "100",
|
|
7818
|
-
extralight: "200",
|
|
7819
|
-
light: "300",
|
|
7820
|
-
regular: "400",
|
|
7821
|
-
medium: "500",
|
|
7822
|
-
semibold: "600",
|
|
7823
|
-
bold: "700",
|
|
7824
|
-
extrabold: "800",
|
|
7825
|
-
black: "900",
|
|
7826
|
-
extrablack: "950"
|
|
7827
|
-
},
|
|
7828
|
-
lineHeight: {
|
|
7829
|
-
none: "1",
|
|
7830
|
-
tight: "1.25",
|
|
7831
|
-
snug: "1.375",
|
|
7832
|
-
normal: "1.5",
|
|
7833
|
-
relaxed: "1.625",
|
|
7834
|
-
loose: "2"
|
|
7835
|
-
}
|
|
7836
|
-
}
|
|
7837
|
-
}
|
|
7838
|
-
});
|
|
7008
|
+
this.config = createProxiedObject.call(this, "config", {});
|
|
7839
7009
|
const originalConfig = this.config;
|
|
7840
7010
|
this.config = new Proxy(originalConfig, {
|
|
7841
7011
|
get(target, prop) {
|
|
7842
|
-
if (prop === "locale"
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
|
|
7012
|
+
if (prop === "locale") {
|
|
7013
|
+
throw new Error("Use VenusAPI.getLocale() instead.");
|
|
7014
|
+
}
|
|
7015
|
+
if (prop === "languageCode") {
|
|
7016
|
+
throw new Error("Use VenusAPI.getLanguageCode() instead.");
|
|
7017
|
+
}
|
|
7018
|
+
if (prop === "user") {
|
|
7019
|
+
throw new Error("Use VenusAPI.getLocale() and VenusAPI.getLanguageCode() instead.");
|
|
7020
|
+
}
|
|
7021
|
+
if (prop === "device") {
|
|
7022
|
+
throw new Error("Use VenusAPI.system.getDevice() instead.");
|
|
7023
|
+
}
|
|
7024
|
+
if (prop === "environment") {
|
|
7025
|
+
throw new Error("Use VenusAPI.system.getEnvironment() instead.");
|
|
7026
|
+
}
|
|
7027
|
+
if (prop === "profile") {
|
|
7028
|
+
throw new Error("Use VenusAPI.getProfile() instead.");
|
|
7029
|
+
}
|
|
7030
|
+
if (prop === "rooms") {
|
|
7031
|
+
throw new Error("Rooms configuration is internal. Use VenusAPI.rooms methods instead.");
|
|
7032
|
+
}
|
|
7033
|
+
if (prop === "ui") {
|
|
7034
|
+
return new Proxy({}, {
|
|
7035
|
+
get(uiTarget, uiProp) {
|
|
7036
|
+
if (uiProp === "safeArea") {
|
|
7037
|
+
throw new Error("Use VenusAPI.system.getSafeArea() instead.");
|
|
7038
|
+
}
|
|
7039
|
+
if (uiProp === "hudInsets") {
|
|
7040
|
+
throw new Error("Use VenusAPI.system.getSafeArea() instead.");
|
|
7041
|
+
}
|
|
7042
|
+
if (uiProp === "controls") {
|
|
7043
|
+
throw new Error("UI controls are no longer supported.");
|
|
7044
|
+
}
|
|
7045
|
+
throw new Error(`VenusAPI.config.ui.${uiProp} is not supported.`);
|
|
7046
|
+
}
|
|
7047
|
+
});
|
|
7846
7048
|
}
|
|
7847
7049
|
return target[prop];
|
|
7848
7050
|
},
|
|
7849
7051
|
set(target, prop, value) {
|
|
7850
|
-
if (prop === "locale" || prop === "languageCode") {
|
|
7851
|
-
|
|
7852
|
-
|
|
7853
|
-
|
|
7052
|
+
if (prop === "locale" || prop === "languageCode" || prop === "user" || prop === "device" || prop === "environment" || prop === "profile") {
|
|
7053
|
+
throw new Error(`VenusAPI.config.${prop} cannot be set. Configuration is read-only.`);
|
|
7054
|
+
}
|
|
7055
|
+
if (prop === "ui") {
|
|
7056
|
+
console.warn("[Venus SDK] Cannot set config.ui");
|
|
7057
|
+
return true;
|
|
7854
7058
|
}
|
|
7855
7059
|
target[prop] = value;
|
|
7856
7060
|
return true;
|
|
7061
|
+
},
|
|
7062
|
+
has(target, prop) {
|
|
7063
|
+
if (prop === "ui") {
|
|
7064
|
+
return false;
|
|
7065
|
+
}
|
|
7066
|
+
return prop in target;
|
|
7067
|
+
},
|
|
7068
|
+
ownKeys(target) {
|
|
7069
|
+
return Reflect.ownKeys(target).filter((key) => key !== "ui");
|
|
7070
|
+
},
|
|
7071
|
+
getOwnPropertyDescriptor(target, prop) {
|
|
7072
|
+
if (prop === "ui") {
|
|
7073
|
+
return void 0;
|
|
7074
|
+
}
|
|
7075
|
+
return Reflect.getOwnPropertyDescriptor(target, prop);
|
|
7857
7076
|
}
|
|
7858
7077
|
});
|
|
7859
7078
|
const isInsideHostedEnv = this._bootstrap.isInsideHostedEnvironment;
|
|
@@ -7862,7 +7081,6 @@ var VenusAPI2 = class {
|
|
|
7862
7081
|
initializeStorage(this, host);
|
|
7863
7082
|
initializeRoomsApi(this, host);
|
|
7864
7083
|
initializeAds(this, host);
|
|
7865
|
-
initializeTheme(this);
|
|
7866
7084
|
initializePopups(this, host);
|
|
7867
7085
|
initializeAnalytics(this, host);
|
|
7868
7086
|
initializeIap(this, host);
|
|
@@ -7877,27 +7095,18 @@ var VenusAPI2 = class {
|
|
|
7877
7095
|
initializeLoggingApi(this, host);
|
|
7878
7096
|
const isAvatar3dDisabled = typeof window !== "undefined" && window.location.search.includes("EXPO_PUBLIC_DISABLE_3D_AVATARS=true");
|
|
7879
7097
|
initializeProfile(this, host);
|
|
7098
|
+
initializeSystem(this, host);
|
|
7880
7099
|
if (!isAvatar3dDisabled) {
|
|
7881
7100
|
initializeAvatar3d(this, host);
|
|
7882
7101
|
}
|
|
7883
7102
|
initializeStackNavigation(this, host);
|
|
7884
|
-
initializePost(this, host);
|
|
7885
7103
|
initializeAi(this, host);
|
|
7886
7104
|
initializeSimulation(this, host);
|
|
7887
7105
|
initializeSocial(this, host);
|
|
7888
7106
|
initializeAssetLoader(this, createProxiedMethod);
|
|
7889
7107
|
this.getLocale = () => {
|
|
7890
|
-
if (
|
|
7891
|
-
|
|
7892
|
-
if (venus.config && venus.config.locale) {
|
|
7893
|
-
return venus.config.locale;
|
|
7894
|
-
}
|
|
7895
|
-
if (venus._config && venus._config.locale) {
|
|
7896
|
-
return venus._config.locale;
|
|
7897
|
-
}
|
|
7898
|
-
if (venus.config?.environment?.browserInfo?.language) {
|
|
7899
|
-
return venus.config.environment.browserInfo.language;
|
|
7900
|
-
}
|
|
7108
|
+
if (this._localeData) {
|
|
7109
|
+
return this._localeData;
|
|
7901
7110
|
}
|
|
7902
7111
|
if (typeof navigator !== "undefined" && navigator.language) {
|
|
7903
7112
|
return navigator.language;
|
|
@@ -7905,6 +7114,9 @@ var VenusAPI2 = class {
|
|
|
7905
7114
|
return "en-US";
|
|
7906
7115
|
};
|
|
7907
7116
|
this.getLanguageCode = () => {
|
|
7117
|
+
if (this._languageCodeData) {
|
|
7118
|
+
return this._languageCodeData;
|
|
7119
|
+
}
|
|
7908
7120
|
const locale = this.getLocale();
|
|
7909
7121
|
return locale.split("-")[0];
|
|
7910
7122
|
};
|
|
@@ -7944,21 +7156,14 @@ var VenusAPI2 = class {
|
|
|
7944
7156
|
// BOOTSTRAP METHODS
|
|
7945
7157
|
//---------------------------------------
|
|
7946
7158
|
_detectHostedEnvironment() {
|
|
7947
|
-
console.log("[Venus SDK] Detecting host environment...");
|
|
7948
7159
|
const isInIframe = window.self !== window.top;
|
|
7949
7160
|
const hasReactNativeWebView = typeof window.ReactNativeWebView !== "undefined";
|
|
7950
7161
|
this._bootstrap.isInsideHostedEnvironment = isInIframe || hasReactNativeWebView;
|
|
7951
|
-
console.log(
|
|
7952
|
-
`[Venus SDK] isInIframe: ${isInIframe}, hasReactNativeWebView: ${hasReactNativeWebView}`
|
|
7953
|
-
);
|
|
7954
|
-
}
|
|
7955
|
-
isMobile() {
|
|
7956
|
-
return typeof window.ReactNativeWebView !== "undefined";
|
|
7957
7162
|
}
|
|
7958
7163
|
_initializeMockMode() {
|
|
7959
7164
|
if (this._mock.localeOverride) {
|
|
7960
|
-
this.
|
|
7961
|
-
this.
|
|
7165
|
+
this._localeData = this._mock.localeOverride;
|
|
7166
|
+
this._languageCodeData = this._mock.localeOverride.split("-")[0];
|
|
7962
7167
|
}
|
|
7963
7168
|
if (this._mock.roomsData) {
|
|
7964
7169
|
console.warn(
|
|
@@ -7978,6 +7183,10 @@ var VenusAPI2 = class {
|
|
|
7978
7183
|
}
|
|
7979
7184
|
this._shared.initPromise = new Promise(async (resolve, reject) => {
|
|
7980
7185
|
try {
|
|
7186
|
+
if (this.isMock() && options?.mock) {
|
|
7187
|
+
Object.assign(this._mock, options.mock);
|
|
7188
|
+
console.log("[VenusAPI] Mock options applied:", options.mock);
|
|
7189
|
+
}
|
|
7981
7190
|
const result = await this.host.initialize(options);
|
|
7982
7191
|
this._shared.initialized = true;
|
|
7983
7192
|
if (!options || !options.usePreloader) {
|
|
@@ -8005,7 +7214,6 @@ instance.isAvailable = function() {
|
|
|
8005
7214
|
(async () => {
|
|
8006
7215
|
try {
|
|
8007
7216
|
await initializeNumbers(instance);
|
|
8008
|
-
console.log("[Venus SDK] Numbers system initialized");
|
|
8009
7217
|
} catch (error) {
|
|
8010
7218
|
console.error("[Venus SDK] Failed to initialize numbers system:", error);
|
|
8011
7219
|
}
|