@series-inc/venus-sdk 2.6.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +131 -95
- package/dist/{AdsApi-C_GcWmfO.d.mts → AdsApi-3DEYUUuj.d.mts} +529 -60
- package/dist/{AdsApi-C_GcWmfO.d.ts → AdsApi-3DEYUUuj.d.ts} +529 -60
- package/dist/{chunk-YDXFZ2A2.mjs → chunk-6DYG4RFQ.mjs} +1725 -106
- package/dist/chunk-6DYG4RFQ.mjs.map +1 -0
- package/dist/index.cjs +1987 -330
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +208 -359
- package/dist/index.d.ts +208 -359
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/venus-api/index.cjs +511 -306
- 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 +12 -1422
- package/dist/venus-api/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-YDXFZ2A2.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __esm, __export, __publicField, createMockDelay, MOCK_DELAYS, isWebPlatform } from './chunk-W7IPHM67.mjs';
|
|
1
|
+
import { __esm, __export, __publicField, createMockDelay, MOCK_DELAYS, isWebPlatform, __toCommonJS } from './chunk-W7IPHM67.mjs';
|
|
2
2
|
|
|
3
3
|
// src/rooms/VenusRoom.ts
|
|
4
4
|
var VenusRoom;
|
|
@@ -265,7 +265,8 @@ var VenusMessageId = /* @__PURE__ */ ((VenusMessageId2) => {
|
|
|
265
265
|
VenusMessageId2["TOGGLE_LIKE"] = "H5_TOGGLE_LIKE";
|
|
266
266
|
VenusMessageId2["OPEN_COMMENTS"] = "H5_OPEN_COMMENTS";
|
|
267
267
|
VenusMessageId2["TOGGLE_FOLLOW"] = "H5_TOGGLE_FOLLOW";
|
|
268
|
-
VenusMessageId2["
|
|
268
|
+
VenusMessageId2["SHARE_LINK"] = "H5_SHARE_LINK";
|
|
269
|
+
VenusMessageId2["CREATE_SHARE_QRCODE"] = "H5_CREATE_SHARE_QRCODE";
|
|
269
270
|
VenusMessageId2["AI_CHAT_COMPLETION"] = "H5_AI_CHAT_COMPLETION";
|
|
270
271
|
VenusMessageId2["AI_GET_AVAILABLE_MODELS"] = "H5_AI_GET_AVAILABLE_MODELS";
|
|
271
272
|
VenusMessageId2["TRIGGER_HAPTIC"] = "H5_TRIGGER_HAPTIC";
|
|
@@ -277,13 +278,11 @@ var VenusMessageId = /* @__PURE__ */ ((VenusMessageId2) => {
|
|
|
277
278
|
VenusMessageId2["IAP_WALLET_UPDATE"] = "IAP_WALLET_UPDATE";
|
|
278
279
|
VenusMessageId2["READY"] = "READY";
|
|
279
280
|
VenusMessageId2["INIT_SDK"] = "INITIALIZE_SDK";
|
|
280
|
-
VenusMessageId2["PLAY"] = "PLAY";
|
|
281
281
|
VenusMessageId2["PAUSE"] = "PAUSE";
|
|
282
282
|
VenusMessageId2["RESUME"] = "RESUME";
|
|
283
|
-
VenusMessageId2["
|
|
284
|
-
VenusMessageId2["
|
|
283
|
+
VenusMessageId2["AWAKE"] = "AWAKE";
|
|
284
|
+
VenusMessageId2["SLEEP"] = "SLEEP";
|
|
285
285
|
VenusMessageId2["QUIT"] = "QUIT";
|
|
286
|
-
VenusMessageId2["CLEANUP"] = "CLEANUP";
|
|
287
286
|
VenusMessageId2["GET_EXPERIMENT"] = "H5_GET_EXPERIMENT";
|
|
288
287
|
VenusMessageId2["GET_FEATURE_FLAG"] = "H5_GET_FEATURE_FLAG";
|
|
289
288
|
VenusMessageId2["GET_FEATURE_GATE"] = "H5_GET_FEATURE_GATE";
|
|
@@ -307,6 +306,11 @@ var VenusMessageId = /* @__PURE__ */ ((VenusMessageId2) => {
|
|
|
307
306
|
VenusMessageId2["H5_SIMULATION_GET_AVAILABLE_ITEMS"] = "H5_SIMULATION_GET_AVAILABLE_ITEMS";
|
|
308
307
|
VenusMessageId2["H5_SIMULATION_VALIDATE_ASSIGNMENT"] = "H5_SIMULATION_VALIDATE_ASSIGNMENT";
|
|
309
308
|
VenusMessageId2["H5_SIMULATION_BATCH_OPERATIONS"] = "H5_SIMULATION_BATCH_OPERATIONS";
|
|
309
|
+
VenusMessageId2["H5_LEADERBOARD_START_RUN"] = "H5_LEADERBOARD_START_RUN";
|
|
310
|
+
VenusMessageId2["H5_LEADERBOARD_SUBMIT_SCORE"] = "H5_LEADERBOARD_SUBMIT_SCORE";
|
|
311
|
+
VenusMessageId2["H5_LEADERBOARD_GET"] = "H5_LEADERBOARD_GET";
|
|
312
|
+
VenusMessageId2["H5_LEADERBOARD_GET_HIGHLIGHT"] = "H5_LEADERBOARD_GET_HIGHLIGHT";
|
|
313
|
+
VenusMessageId2["H5_LEADERBOARD_GET_PLAYER_STATS"] = "H5_LEADERBOARD_GET_PLAYER_STATS";
|
|
310
314
|
VenusMessageId2["H5_ROOM_CREATE"] = "H5_ROOM_CREATE";
|
|
311
315
|
VenusMessageId2["H5_ROOM_JOIN"] = "H5_ROOM_JOIN";
|
|
312
316
|
VenusMessageId2["H5_ROOM_JOIN_OR_CREATE"] = "H5_ROOM_JOIN_OR_CREATE";
|
|
@@ -345,11 +349,11 @@ var RpcAdsApi = class {
|
|
|
345
349
|
__publicField(this, "rpcClient");
|
|
346
350
|
this.rpcClient = rpcClient;
|
|
347
351
|
}
|
|
348
|
-
async showInterstitialAd() {
|
|
352
|
+
async showInterstitialAd(options) {
|
|
349
353
|
console.log(`[Venus SDK] [RpcAdsApi] showInterstitialAd`);
|
|
350
354
|
const response = await this.rpcClient.call(
|
|
351
355
|
"H5_SHOW_INTERSTITIAL_AD" /* SHOW_INTERSTITIAL_AD */,
|
|
352
|
-
{},
|
|
356
|
+
options || {},
|
|
353
357
|
-1
|
|
354
358
|
);
|
|
355
359
|
return response.shown;
|
|
@@ -361,11 +365,11 @@ var RpcAdsApi = class {
|
|
|
361
365
|
);
|
|
362
366
|
return response.ready;
|
|
363
367
|
}
|
|
364
|
-
async showRewardedAdAsync() {
|
|
368
|
+
async showRewardedAdAsync(options) {
|
|
365
369
|
console.log("[Venus SDK] [RpcAdsApi] showRewardedAdAsync");
|
|
366
370
|
const result = await this.rpcClient.call(
|
|
367
371
|
"H5_SHOW_REWARDED_AD" /* SHOW_REWARDED_AD */,
|
|
368
|
-
{},
|
|
372
|
+
options || {},
|
|
369
373
|
-1
|
|
370
374
|
);
|
|
371
375
|
const resultAsString = JSON.stringify(result, null, 2);
|
|
@@ -388,15 +392,15 @@ var MockAdsApi = class {
|
|
|
388
392
|
await createMockDelay(MOCK_DELAYS.short);
|
|
389
393
|
return true;
|
|
390
394
|
}
|
|
391
|
-
async showRewardedAdAsync() {
|
|
395
|
+
async showRewardedAdAsync(options) {
|
|
392
396
|
this.log("[MockAdsApi] showRewardedAdAsync called");
|
|
393
|
-
await this.mockOverlay.showAdOverlay();
|
|
397
|
+
await this.mockOverlay.showAdOverlay(options);
|
|
394
398
|
this.log("[MockAdsApi] Rewarded ad completed");
|
|
395
399
|
return true;
|
|
396
400
|
}
|
|
397
|
-
async showInterstitialAd() {
|
|
401
|
+
async showInterstitialAd(options) {
|
|
398
402
|
this.log(`[MockAdsApi] showInterstitialAd`);
|
|
399
|
-
await this.mockOverlay.showAdOverlay();
|
|
403
|
+
await this.mockOverlay.showAdOverlay(options);
|
|
400
404
|
this.log("[MockAdsApi] interstitial ad shown");
|
|
401
405
|
return true;
|
|
402
406
|
}
|
|
@@ -1445,59 +1449,73 @@ function initializeIap(venusApiInstance, host) {
|
|
|
1445
1449
|
// src/lifecycles/MockLifecycleApi.ts
|
|
1446
1450
|
var MockLifecycleApi = class {
|
|
1447
1451
|
constructor() {
|
|
1448
|
-
__publicField(this, "
|
|
1449
|
-
__publicField(this, "
|
|
1450
|
-
__publicField(this, "
|
|
1451
|
-
__publicField(this, "
|
|
1452
|
-
__publicField(this, "
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1452
|
+
__publicField(this, "pauseCallbacks", /* @__PURE__ */ new Set());
|
|
1453
|
+
__publicField(this, "resumeCallbacks", /* @__PURE__ */ new Set());
|
|
1454
|
+
__publicField(this, "awakeCallbacks", /* @__PURE__ */ new Set());
|
|
1455
|
+
__publicField(this, "sleepCallbacks", /* @__PURE__ */ new Set());
|
|
1456
|
+
__publicField(this, "quitCallbacks", /* @__PURE__ */ new Set());
|
|
1457
|
+
}
|
|
1458
|
+
onSleep(callback) {
|
|
1459
|
+
this.sleepCallbacks.add(callback);
|
|
1460
|
+
return {
|
|
1461
|
+
unsubscribe: () => {
|
|
1462
|
+
this.sleepCallbacks.delete(callback);
|
|
1463
|
+
}
|
|
1464
|
+
};
|
|
1459
1465
|
}
|
|
1460
|
-
|
|
1461
|
-
this.
|
|
1466
|
+
onAwake(callback) {
|
|
1467
|
+
this.awakeCallbacks.add(callback);
|
|
1468
|
+
return {
|
|
1469
|
+
unsubscribe: () => {
|
|
1470
|
+
this.awakeCallbacks.delete(callback);
|
|
1471
|
+
}
|
|
1472
|
+
};
|
|
1462
1473
|
}
|
|
1463
1474
|
onPause(callback) {
|
|
1464
|
-
this.pauseCallbacks.
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
this.quitCallbacks.push(callback);
|
|
1475
|
+
this.pauseCallbacks.add(callback);
|
|
1476
|
+
return {
|
|
1477
|
+
unsubscribe: () => {
|
|
1478
|
+
this.pauseCallbacks.delete(callback);
|
|
1479
|
+
}
|
|
1480
|
+
};
|
|
1471
1481
|
}
|
|
1472
1482
|
onResume(callback) {
|
|
1473
|
-
this.resumeCallbacks.
|
|
1483
|
+
this.resumeCallbacks.add(callback);
|
|
1484
|
+
return {
|
|
1485
|
+
unsubscribe: () => {
|
|
1486
|
+
this.resumeCallbacks.delete(callback);
|
|
1487
|
+
}
|
|
1488
|
+
};
|
|
1474
1489
|
}
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1490
|
+
onQuit(callback) {
|
|
1491
|
+
this.quitCallbacks.add(callback);
|
|
1492
|
+
return {
|
|
1493
|
+
unsubscribe: () => {
|
|
1494
|
+
this.quitCallbacks.delete(callback);
|
|
1495
|
+
}
|
|
1496
|
+
};
|
|
1479
1497
|
}
|
|
1480
|
-
|
|
1498
|
+
triggerPauseCallbacks() {
|
|
1481
1499
|
for (const callback of this.pauseCallbacks) {
|
|
1482
1500
|
callback();
|
|
1483
1501
|
}
|
|
1484
1502
|
}
|
|
1485
|
-
|
|
1503
|
+
triggerResumeCallbacks() {
|
|
1486
1504
|
for (const callback of this.resumeCallbacks) {
|
|
1487
1505
|
callback();
|
|
1488
1506
|
}
|
|
1489
1507
|
}
|
|
1490
|
-
|
|
1491
|
-
for (const callback of this.
|
|
1492
|
-
callback(
|
|
1508
|
+
triggerAwakeCallbacks() {
|
|
1509
|
+
for (const callback of this.awakeCallbacks) {
|
|
1510
|
+
callback();
|
|
1493
1511
|
}
|
|
1494
1512
|
}
|
|
1495
|
-
|
|
1496
|
-
for (const callback of this.
|
|
1513
|
+
triggerSleepCallbacks() {
|
|
1514
|
+
for (const callback of this.sleepCallbacks) {
|
|
1497
1515
|
callback();
|
|
1498
1516
|
}
|
|
1499
1517
|
}
|
|
1500
|
-
|
|
1518
|
+
triggerQuitCallbacks() {
|
|
1501
1519
|
for (const callback of this.quitCallbacks) {
|
|
1502
1520
|
callback();
|
|
1503
1521
|
}
|
|
@@ -1510,52 +1528,26 @@ var RpcLifecycleApi = class {
|
|
|
1510
1528
|
__publicField(this, "rpcClient");
|
|
1511
1529
|
this.rpcClient = rpcClient;
|
|
1512
1530
|
}
|
|
1513
|
-
|
|
1514
|
-
this.rpcClient.onNotification("
|
|
1515
|
-
}
|
|
1516
|
-
onHide(callback) {
|
|
1517
|
-
this.rpcClient.onNotification("HIDDEN" /* HIDDEN */, callback);
|
|
1518
|
-
}
|
|
1519
|
-
onPause(callback) {
|
|
1520
|
-
this.rpcClient.onNotification("PAUSE" /* PAUSE */, callback);
|
|
1531
|
+
onQuit(callback) {
|
|
1532
|
+
return this.rpcClient.onNotification("QUIT" /* QUIT */, callback);
|
|
1521
1533
|
}
|
|
1522
|
-
|
|
1523
|
-
this.rpcClient.onNotification("
|
|
1534
|
+
onSleep(callback) {
|
|
1535
|
+
return this.rpcClient.onNotification("SLEEP" /* SLEEP */, callback);
|
|
1524
1536
|
}
|
|
1525
|
-
|
|
1526
|
-
this.rpcClient.onNotification("
|
|
1537
|
+
onAwake(callback) {
|
|
1538
|
+
return this.rpcClient.onNotification("AWAKE" /* AWAKE */, callback);
|
|
1527
1539
|
}
|
|
1528
1540
|
onResume(callback) {
|
|
1529
|
-
this.rpcClient.onNotification("RESUME" /* RESUME */, callback);
|
|
1541
|
+
return this.rpcClient.onNotification("RESUME" /* RESUME */, callback);
|
|
1530
1542
|
}
|
|
1531
|
-
|
|
1532
|
-
this.rpcClient.onNotification("
|
|
1543
|
+
onPause(callback) {
|
|
1544
|
+
return this.rpcClient.onNotification("PAUSE" /* PAUSE */, callback);
|
|
1533
1545
|
}
|
|
1534
1546
|
};
|
|
1535
1547
|
|
|
1536
1548
|
// src/lifecycles/index.ts
|
|
1537
1549
|
function initializeLifecycleApi(venusApi, host) {
|
|
1538
|
-
venusApi.
|
|
1539
|
-
host.lifecycle.onPlay(callback);
|
|
1540
|
-
};
|
|
1541
|
-
venusApi.onPause = (callback) => {
|
|
1542
|
-
host.lifecycle.onPause(callback);
|
|
1543
|
-
};
|
|
1544
|
-
venusApi.onResume = (callback) => {
|
|
1545
|
-
host.lifecycle.onResume(callback);
|
|
1546
|
-
};
|
|
1547
|
-
venusApi.onShow = (callback) => {
|
|
1548
|
-
host.lifecycle.onShow(callback);
|
|
1549
|
-
};
|
|
1550
|
-
venusApi.onHide = (callback) => {
|
|
1551
|
-
host.lifecycle.onHide(callback);
|
|
1552
|
-
};
|
|
1553
|
-
venusApi.onQuit = (callback) => {
|
|
1554
|
-
host.lifecycle.onQuit(callback);
|
|
1555
|
-
};
|
|
1556
|
-
venusApi.onCleanup = (callback) => {
|
|
1557
|
-
host.lifecycle.onCleanup(callback);
|
|
1558
|
-
};
|
|
1550
|
+
venusApi.lifecycles = host.lifecycle;
|
|
1559
1551
|
}
|
|
1560
1552
|
|
|
1561
1553
|
// src/logging/MockLoggingApi.ts
|
|
@@ -1803,22 +1795,23 @@ var MockNotificationsApi = class {
|
|
|
1803
1795
|
const isEnabled = venusApi._mock.notificationsEnabled !== false;
|
|
1804
1796
|
return isEnabled;
|
|
1805
1797
|
}
|
|
1806
|
-
async scheduleAsync(options) {
|
|
1798
|
+
async scheduleAsync(title, body, seconds, notificationId, options) {
|
|
1799
|
+
const { priority = 50, groupId, payload } = options || {};
|
|
1807
1800
|
if (isWebPlatform()) {
|
|
1808
1801
|
console.log(
|
|
1809
1802
|
"[Venus Mock] Notifications not supported on web platform, simulating success"
|
|
1810
1803
|
);
|
|
1811
1804
|
console.info(
|
|
1812
1805
|
"\u{1F514} [Venus Mock] Notification would be scheduled:",
|
|
1813
|
-
|
|
1806
|
+
title || "Untitled",
|
|
1814
1807
|
"\n Body:",
|
|
1815
|
-
|
|
1808
|
+
body || "No body",
|
|
1816
1809
|
"\n This is a simulation - real notifications require a native platform."
|
|
1817
1810
|
);
|
|
1818
1811
|
const mockId = `mock-web-notification-${Date.now()}`;
|
|
1819
1812
|
return mockId;
|
|
1820
1813
|
}
|
|
1821
|
-
console.log("[Venus Mock] Schedule local notification:", options);
|
|
1814
|
+
console.log("[Venus Mock] Schedule local notification:", { title, body, seconds, options });
|
|
1822
1815
|
const venusApi = this.venusApi;
|
|
1823
1816
|
if (!venusApi._mock.pendingRequests) {
|
|
1824
1817
|
console.log("[Venus Mock] Initializing pendingRequests");
|
|
@@ -1828,19 +1821,19 @@ var MockNotificationsApi = class {
|
|
|
1828
1821
|
console.log("[Venus Mock] Creating request with ID:", requestId);
|
|
1829
1822
|
return new Promise((resolve) => {
|
|
1830
1823
|
venusApi._mock.pendingRequests[requestId] = { resolve };
|
|
1831
|
-
const
|
|
1824
|
+
const id = notificationId || `mock-notification-${Date.now()}`;
|
|
1832
1825
|
if (!venusApi._mock.scheduledNotifications) {
|
|
1833
1826
|
venusApi._mock.scheduledNotifications = {};
|
|
1834
1827
|
}
|
|
1835
|
-
venusApi._mock.scheduledNotifications[
|
|
1836
|
-
id
|
|
1837
|
-
title
|
|
1838
|
-
body
|
|
1839
|
-
payload
|
|
1840
|
-
|
|
1828
|
+
venusApi._mock.scheduledNotifications[id] = {
|
|
1829
|
+
id,
|
|
1830
|
+
title,
|
|
1831
|
+
body,
|
|
1832
|
+
payload,
|
|
1833
|
+
seconds
|
|
1841
1834
|
};
|
|
1842
1835
|
setTimeout(() => {
|
|
1843
|
-
resolve(
|
|
1836
|
+
resolve(id);
|
|
1844
1837
|
}, MOCK_DELAYS.short);
|
|
1845
1838
|
});
|
|
1846
1839
|
}
|
|
@@ -1866,14 +1859,16 @@ var RpcNotificationsApi = class {
|
|
|
1866
1859
|
__publicField(this, "rpcClient");
|
|
1867
1860
|
this.rpcClient = rpcClient;
|
|
1868
1861
|
}
|
|
1869
|
-
async scheduleAsync(options) {
|
|
1862
|
+
async scheduleAsync(title, body, seconds, notificationId, options) {
|
|
1863
|
+
const { priority = 50, groupId, payload } = options || {};
|
|
1870
1864
|
const request = {
|
|
1871
|
-
title
|
|
1872
|
-
body
|
|
1873
|
-
|
|
1874
|
-
key:
|
|
1875
|
-
|
|
1876
|
-
|
|
1865
|
+
title,
|
|
1866
|
+
body,
|
|
1867
|
+
priority,
|
|
1868
|
+
key: groupId,
|
|
1869
|
+
data: payload,
|
|
1870
|
+
seconds,
|
|
1871
|
+
notificationId
|
|
1877
1872
|
};
|
|
1878
1873
|
const response = await this.rpcClient.call(
|
|
1879
1874
|
"H5_SCHEDULE_LOCAL_NOTIFICATION" /* SCHEDULE_LOCAL_NOTIFICATION */,
|
|
@@ -3549,7 +3544,7 @@ function initializeTime(venusApi, host) {
|
|
|
3549
3544
|
}
|
|
3550
3545
|
|
|
3551
3546
|
// src/version.ts
|
|
3552
|
-
var SDK_VERSION = "
|
|
3547
|
+
var SDK_VERSION = "3.0.0";
|
|
3553
3548
|
|
|
3554
3549
|
// src/shared-assets/consts.ts
|
|
3555
3550
|
var BurgerTimeAssetsCdnPath = "burger-time/Core.stow";
|
|
@@ -3620,6 +3615,238 @@ var MockSharedAssetsApi = class {
|
|
|
3620
3615
|
}
|
|
3621
3616
|
};
|
|
3622
3617
|
|
|
3618
|
+
// src/leaderboard/RpcLeaderboardApi.ts
|
|
3619
|
+
var RpcLeaderboardApi = class {
|
|
3620
|
+
constructor(rpcClient) {
|
|
3621
|
+
__publicField(this, "rpcClient");
|
|
3622
|
+
this.rpcClient = rpcClient;
|
|
3623
|
+
}
|
|
3624
|
+
startRun(mode) {
|
|
3625
|
+
return this.rpcClient.call(
|
|
3626
|
+
"H5_LEADERBOARD_START_RUN" /* H5_LEADERBOARD_START_RUN */,
|
|
3627
|
+
mode ? { mode } : {}
|
|
3628
|
+
);
|
|
3629
|
+
}
|
|
3630
|
+
submitScore(sessionId, score, durationSec, options) {
|
|
3631
|
+
return this.rpcClient.call(
|
|
3632
|
+
"H5_LEADERBOARD_SUBMIT_SCORE" /* H5_LEADERBOARD_SUBMIT_SCORE */,
|
|
3633
|
+
{
|
|
3634
|
+
sessionId,
|
|
3635
|
+
score,
|
|
3636
|
+
durationSec,
|
|
3637
|
+
mode: options?.mode,
|
|
3638
|
+
telemetry: options?.telemetry,
|
|
3639
|
+
metadata: options?.metadata,
|
|
3640
|
+
hash: options?.hash
|
|
3641
|
+
}
|
|
3642
|
+
);
|
|
3643
|
+
}
|
|
3644
|
+
getLeaderboard(options) {
|
|
3645
|
+
return this.rpcClient.call(
|
|
3646
|
+
"H5_LEADERBOARD_GET" /* H5_LEADERBOARD_GET */,
|
|
3647
|
+
options ?? {}
|
|
3648
|
+
);
|
|
3649
|
+
}
|
|
3650
|
+
getPlayerStats(options) {
|
|
3651
|
+
return this.rpcClient.call(
|
|
3652
|
+
"H5_LEADERBOARD_GET_PLAYER_STATS" /* H5_LEADERBOARD_GET_PLAYER_STATS */,
|
|
3653
|
+
options ?? {}
|
|
3654
|
+
);
|
|
3655
|
+
}
|
|
3656
|
+
getLeaderboardHighlight(options) {
|
|
3657
|
+
return this.rpcClient.call(
|
|
3658
|
+
"H5_LEADERBOARD_GET_HIGHLIGHT" /* H5_LEADERBOARD_GET_HIGHLIGHT */,
|
|
3659
|
+
options ?? {}
|
|
3660
|
+
);
|
|
3661
|
+
}
|
|
3662
|
+
};
|
|
3663
|
+
|
|
3664
|
+
// src/leaderboard/MockLeaderboardApi.ts
|
|
3665
|
+
var MockLeaderboardApi = class {
|
|
3666
|
+
constructor(options) {
|
|
3667
|
+
__publicField(this, "sessions", /* @__PURE__ */ new Map());
|
|
3668
|
+
__publicField(this, "entriesByMode", /* @__PURE__ */ new Map());
|
|
3669
|
+
__publicField(this, "sessionCounter", 0);
|
|
3670
|
+
__publicField(this, "requiresHash", false);
|
|
3671
|
+
if (options?.requiresHash) {
|
|
3672
|
+
this.requiresHash = true;
|
|
3673
|
+
}
|
|
3674
|
+
}
|
|
3675
|
+
configure(options) {
|
|
3676
|
+
if (typeof options.requiresHash === "boolean") {
|
|
3677
|
+
this.requiresHash = options.requiresHash;
|
|
3678
|
+
}
|
|
3679
|
+
}
|
|
3680
|
+
generateNonce() {
|
|
3681
|
+
return (Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2)).slice(0, 64);
|
|
3682
|
+
}
|
|
3683
|
+
getModeKey(mode) {
|
|
3684
|
+
const normalizedMode = mode || "default";
|
|
3685
|
+
return `${normalizedMode}`;
|
|
3686
|
+
}
|
|
3687
|
+
getEntriesForMode(mode) {
|
|
3688
|
+
const key = this.getModeKey(mode);
|
|
3689
|
+
if (!this.entriesByMode.has(key)) {
|
|
3690
|
+
this.entriesByMode.set(key, []);
|
|
3691
|
+
}
|
|
3692
|
+
return this.entriesByMode.get(key);
|
|
3693
|
+
}
|
|
3694
|
+
async startRun(mode) {
|
|
3695
|
+
const sessionId = `mock_session_${++this.sessionCounter}`;
|
|
3696
|
+
const startTime = Date.now();
|
|
3697
|
+
const expiresAt = startTime + 36e5;
|
|
3698
|
+
const resolvedMode = mode || "default";
|
|
3699
|
+
const hashNonce = this.requiresHash ? this.generateNonce() : null;
|
|
3700
|
+
this.sessions.set(sessionId, {
|
|
3701
|
+
id: sessionId,
|
|
3702
|
+
expiresAt,
|
|
3703
|
+
mode: resolvedMode,
|
|
3704
|
+
hashNonce,
|
|
3705
|
+
used: false
|
|
3706
|
+
});
|
|
3707
|
+
return {
|
|
3708
|
+
sessionId,
|
|
3709
|
+
startTime,
|
|
3710
|
+
expiresAt,
|
|
3711
|
+
hashNonce,
|
|
3712
|
+
mode: resolvedMode
|
|
3713
|
+
};
|
|
3714
|
+
}
|
|
3715
|
+
async submitScore(sessionId, score, durationSec, options) {
|
|
3716
|
+
const session = this.sessions.get(sessionId);
|
|
3717
|
+
if (!session) {
|
|
3718
|
+
throw new Error("Invalid leaderboard session");
|
|
3719
|
+
}
|
|
3720
|
+
if (session.expiresAt < Date.now()) {
|
|
3721
|
+
throw new Error("Invalid or expired leaderboard session");
|
|
3722
|
+
}
|
|
3723
|
+
if (session.used) {
|
|
3724
|
+
throw new Error("Leaderboard session already used");
|
|
3725
|
+
}
|
|
3726
|
+
if (options?.mode && options.mode !== session.mode) {
|
|
3727
|
+
throw new Error("Submission mode does not match session mode");
|
|
3728
|
+
}
|
|
3729
|
+
if (session.hashNonce && !options?.hash) {
|
|
3730
|
+
throw new Error("Score hash is required for sealed leaderboard submissions");
|
|
3731
|
+
}
|
|
3732
|
+
const submittedAt = Date.now();
|
|
3733
|
+
const entry = {
|
|
3734
|
+
profileId: `mock_profile`,
|
|
3735
|
+
username: "Mock Player",
|
|
3736
|
+
avatarUrl: null,
|
|
3737
|
+
score,
|
|
3738
|
+
durationSec,
|
|
3739
|
+
submittedAt,
|
|
3740
|
+
sessionId,
|
|
3741
|
+
rank: null,
|
|
3742
|
+
zScore: null,
|
|
3743
|
+
isAnomaly: false,
|
|
3744
|
+
trustScore: 50,
|
|
3745
|
+
metadata: options?.metadata ?? null,
|
|
3746
|
+
isSeed: false
|
|
3747
|
+
};
|
|
3748
|
+
const modeEntries = this.getEntriesForMode(session.mode);
|
|
3749
|
+
modeEntries.push(entry);
|
|
3750
|
+
modeEntries.sort((a, b) => {
|
|
3751
|
+
if (b.score !== a.score) {
|
|
3752
|
+
return b.score - a.score;
|
|
3753
|
+
}
|
|
3754
|
+
return a.submittedAt - b.submittedAt;
|
|
3755
|
+
});
|
|
3756
|
+
modeEntries.forEach((e, index) => {
|
|
3757
|
+
modeEntries[index] = {
|
|
3758
|
+
...e,
|
|
3759
|
+
rank: index + 1
|
|
3760
|
+
};
|
|
3761
|
+
});
|
|
3762
|
+
session.used = true;
|
|
3763
|
+
session.hashNonce = null;
|
|
3764
|
+
const inserted = modeEntries.find((e) => e.sessionId === sessionId && e.submittedAt === submittedAt);
|
|
3765
|
+
return {
|
|
3766
|
+
accepted: true,
|
|
3767
|
+
rank: inserted?.rank ?? null
|
|
3768
|
+
};
|
|
3769
|
+
}
|
|
3770
|
+
async getLeaderboard(options) {
|
|
3771
|
+
const limit = options?.limit ?? 10;
|
|
3772
|
+
const mode = options?.mode ?? "default";
|
|
3773
|
+
const modeEntries = [...this.getEntriesForMode(mode)];
|
|
3774
|
+
const entries = modeEntries.slice(0, limit).map((entry) => ({
|
|
3775
|
+
...entry
|
|
3776
|
+
}));
|
|
3777
|
+
return {
|
|
3778
|
+
variant: "standard",
|
|
3779
|
+
entries,
|
|
3780
|
+
totalEntries: modeEntries.length,
|
|
3781
|
+
nextCursor: null,
|
|
3782
|
+
playerRank: null,
|
|
3783
|
+
periodInstance: options?.period ?? "alltime"
|
|
3784
|
+
};
|
|
3785
|
+
}
|
|
3786
|
+
async getPlayerStats(_options) {
|
|
3787
|
+
const mode = _options?.mode ?? "default";
|
|
3788
|
+
const modeEntries = this.getEntriesForMode(mode);
|
|
3789
|
+
const playerEntry = modeEntries[0] ?? null;
|
|
3790
|
+
return {
|
|
3791
|
+
rank: playerEntry?.rank ?? null,
|
|
3792
|
+
score: playerEntry?.score,
|
|
3793
|
+
totalPlayers: modeEntries.length,
|
|
3794
|
+
percentile: playerEntry ? Math.max(0, 1 - ((playerEntry.rank ?? 1) - 1) / Math.max(modeEntries.length, 1)) : void 0,
|
|
3795
|
+
trustScore: 50,
|
|
3796
|
+
periodInstance: _options?.period ?? "alltime"
|
|
3797
|
+
};
|
|
3798
|
+
}
|
|
3799
|
+
async getLeaderboardHighlight(options) {
|
|
3800
|
+
const mode = options?.mode ?? "default";
|
|
3801
|
+
const modeEntries = [...this.getEntriesForMode(mode)];
|
|
3802
|
+
const topCount = Math.max(1, Math.min(options?.topCount ?? 3, 10));
|
|
3803
|
+
const aheadCount = Math.max(0, Math.min(options?.contextAhead ?? 4, 10));
|
|
3804
|
+
const behindCount = Math.max(0, Math.min(options?.contextBehind ?? 2, 10));
|
|
3805
|
+
const topEntries = modeEntries.slice(0, topCount);
|
|
3806
|
+
const playerEntry = modeEntries[0] ?? null;
|
|
3807
|
+
const totalEntries = modeEntries.length;
|
|
3808
|
+
let playerRank = playerEntry?.rank ?? null;
|
|
3809
|
+
let beforePlayer = [];
|
|
3810
|
+
let afterPlayer = [];
|
|
3811
|
+
let totalBefore = playerRank ? playerRank - 1 : 0;
|
|
3812
|
+
let totalAfter = playerRank ? Math.max(totalEntries - playerRank, 0) : 0;
|
|
3813
|
+
let omittedBefore = totalBefore;
|
|
3814
|
+
let omittedAfter = totalAfter;
|
|
3815
|
+
if (playerRank && playerRank > 0) {
|
|
3816
|
+
const beforeStart = Math.max(playerRank - aheadCount - 1, 0);
|
|
3817
|
+
beforePlayer = modeEntries.slice(beforeStart, playerRank - 1);
|
|
3818
|
+
const afterEnd = Math.min(playerRank + behindCount, totalEntries);
|
|
3819
|
+
afterPlayer = modeEntries.slice(playerRank, afterEnd);
|
|
3820
|
+
const shownTopAhead = topEntries.filter((entry) => (entry.rank ?? 0) > 0 && (entry.rank ?? 0) < playerRank).length;
|
|
3821
|
+
omittedBefore = Math.max(totalBefore - (beforePlayer.length + shownTopAhead), 0);
|
|
3822
|
+
omittedAfter = Math.max(totalAfter - afterPlayer.length, 0);
|
|
3823
|
+
}
|
|
3824
|
+
return {
|
|
3825
|
+
variant: "highlight",
|
|
3826
|
+
entries: topEntries,
|
|
3827
|
+
totalEntries,
|
|
3828
|
+
nextCursor: null,
|
|
3829
|
+
playerRank: playerRank ?? null,
|
|
3830
|
+
periodInstance: options?.period ?? "alltime",
|
|
3831
|
+
context: {
|
|
3832
|
+
topEntries,
|
|
3833
|
+
beforePlayer,
|
|
3834
|
+
playerEntry: playerEntry ?? null,
|
|
3835
|
+
afterPlayer,
|
|
3836
|
+
totalBefore,
|
|
3837
|
+
totalAfter,
|
|
3838
|
+
omittedBefore,
|
|
3839
|
+
omittedAfter
|
|
3840
|
+
}
|
|
3841
|
+
};
|
|
3842
|
+
}
|
|
3843
|
+
};
|
|
3844
|
+
|
|
3845
|
+
// src/leaderboard/index.ts
|
|
3846
|
+
function initializeLeaderboard(venusApiInstance, host) {
|
|
3847
|
+
venusApiInstance.leaderboard = host.leaderboard;
|
|
3848
|
+
}
|
|
3849
|
+
|
|
3623
3850
|
// src/game-preloader/MockPreloaderApi.ts
|
|
3624
3851
|
var MockPreloaderApi = class {
|
|
3625
3852
|
async showLoadScreen() {
|
|
@@ -3661,6 +3888,1398 @@ function initializePreloader(venusApi, host) {
|
|
|
3661
3888
|
venusApi.preloader = host.preloader;
|
|
3662
3889
|
}
|
|
3663
3890
|
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3891
|
+
// src/post/MockPostApi.ts
|
|
3892
|
+
var MockPostApi = class {
|
|
3893
|
+
constructor(venusApi) {
|
|
3894
|
+
__publicField(this, "venusApi");
|
|
3895
|
+
this.venusApi = venusApi;
|
|
3896
|
+
}
|
|
3897
|
+
async getPostInfo() {
|
|
3898
|
+
const venusApi = this.venusApi;
|
|
3899
|
+
await createMockDelay(MOCK_DELAYS.short);
|
|
3900
|
+
return venusApi._mock.currentPostInteractions;
|
|
3901
|
+
}
|
|
3902
|
+
async openCommentsAsync() {
|
|
3903
|
+
await createMockDelay(MOCK_DELAYS.short);
|
|
3904
|
+
return {
|
|
3905
|
+
opened: true,
|
|
3906
|
+
commentsCount: 0
|
|
3907
|
+
};
|
|
3908
|
+
}
|
|
3909
|
+
async toggleFollowAsync() {
|
|
3910
|
+
const venusApi = this.venusApi;
|
|
3911
|
+
console.log("[Venus Mock] *Toggling follow status");
|
|
3912
|
+
await createMockDelay(MOCK_DELAYS.short);
|
|
3913
|
+
venusApi._mock.currentPostInteractions.isFollowing = !venusApi._mock.currentPostInteractions.isFollowing;
|
|
3914
|
+
const isFollowing = venusApi._mock.currentPostInteractions.isFollowing;
|
|
3915
|
+
return {
|
|
3916
|
+
isFollowing,
|
|
3917
|
+
action: isFollowing ? "followed" : "unfollowed"
|
|
3918
|
+
};
|
|
3919
|
+
}
|
|
3920
|
+
async toggleLikeAsync() {
|
|
3921
|
+
const venusApi = this.venusApi;
|
|
3922
|
+
await createMockDelay(MOCK_DELAYS.short);
|
|
3923
|
+
venusApi._mock.currentPostInteractions.isLiked = !venusApi._mock.currentPostInteractions.isLiked;
|
|
3924
|
+
const isLiked = venusApi._mock.currentPostInteractions.isLiked;
|
|
3925
|
+
if (isLiked) {
|
|
3926
|
+
venusApi._mock.currentPostInteractions.likesCount++;
|
|
3927
|
+
} else {
|
|
3928
|
+
venusApi._mock.currentPostInteractions.likesCount = Math.max(
|
|
3929
|
+
0,
|
|
3930
|
+
venusApi._mock.currentPostInteractions.likesCount - 1
|
|
3931
|
+
);
|
|
3932
|
+
}
|
|
3933
|
+
return {
|
|
3934
|
+
isLiked,
|
|
3935
|
+
likesCount: venusApi._mock.currentPostInteractions.likesCount,
|
|
3936
|
+
action: isLiked ? "liked" : "unliked"
|
|
3937
|
+
};
|
|
3938
|
+
}
|
|
3939
|
+
};
|
|
3940
|
+
|
|
3941
|
+
// src/post/RpcPostApi.ts
|
|
3942
|
+
var RpcPostApi = class {
|
|
3943
|
+
constructor(rpcClient) {
|
|
3944
|
+
__publicField(this, "rpcClient");
|
|
3945
|
+
this.rpcClient = rpcClient;
|
|
3946
|
+
}
|
|
3947
|
+
getPostInfo() {
|
|
3948
|
+
return this.rpcClient.call("H5_GET_POST_INTERACTIONS" /* GET_POST_INTERACTIONS */, {});
|
|
3949
|
+
}
|
|
3950
|
+
openCommentsAsync() {
|
|
3951
|
+
return this.rpcClient.call("H5_OPEN_COMMENTS" /* OPEN_COMMENTS */, {});
|
|
3952
|
+
}
|
|
3953
|
+
toggleFollowAsync() {
|
|
3954
|
+
return this.rpcClient.call(
|
|
3955
|
+
"H5_TOGGLE_FOLLOW" /* TOGGLE_FOLLOW */,
|
|
3956
|
+
{}
|
|
3957
|
+
);
|
|
3958
|
+
}
|
|
3959
|
+
toggleLikeAsync() {
|
|
3960
|
+
return this.rpcClient.call("H5_TOGGLE_LIKE" /* TOGGLE_LIKE */, {});
|
|
3961
|
+
}
|
|
3962
|
+
};
|
|
3963
|
+
|
|
3964
|
+
// src/post/index.ts
|
|
3965
|
+
function initializePost(venusApi, host) {
|
|
3966
|
+
venusApi.getPostInteractionsAsync = () => {
|
|
3967
|
+
return host.post.getPostInfo();
|
|
3968
|
+
};
|
|
3969
|
+
venusApi.toggleFollowAsync = () => {
|
|
3970
|
+
return host.post.toggleFollowAsync();
|
|
3971
|
+
};
|
|
3972
|
+
venusApi.toggleLikeAsync = () => {
|
|
3973
|
+
return host.post.toggleLikeAsync();
|
|
3974
|
+
};
|
|
3975
|
+
venusApi.openCommentsAsync = async () => {
|
|
3976
|
+
await host.post.openCommentsAsync();
|
|
3977
|
+
};
|
|
3978
|
+
}
|
|
3979
|
+
|
|
3980
|
+
// src/social/MockSocialApi.ts
|
|
3981
|
+
var MOCK_QR_CODE = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==";
|
|
3982
|
+
var MockSocialApi = class {
|
|
3983
|
+
async shareLinkAsync(options) {
|
|
3984
|
+
const shareUrl = this.createMockUrl(options.launchParams);
|
|
3985
|
+
if (typeof navigator !== "undefined" && navigator.clipboard) {
|
|
3986
|
+
try {
|
|
3987
|
+
await navigator.clipboard.writeText(shareUrl);
|
|
3988
|
+
console.log("[Venus SDK] (mock) Copied share URL to clipboard");
|
|
3989
|
+
} catch (error) {
|
|
3990
|
+
console.warn(
|
|
3991
|
+
"[Venus SDK] (mock) Failed to copy share URL to clipboard",
|
|
3992
|
+
error
|
|
3993
|
+
);
|
|
3994
|
+
}
|
|
3995
|
+
}
|
|
3996
|
+
return { shareUrl };
|
|
3997
|
+
}
|
|
3998
|
+
async createQRCodeAsync(options) {
|
|
3999
|
+
const shareUrl = this.createMockUrl(options.launchParams);
|
|
4000
|
+
return {
|
|
4001
|
+
shareUrl,
|
|
4002
|
+
qrCode: MOCK_QR_CODE
|
|
4003
|
+
};
|
|
4004
|
+
}
|
|
4005
|
+
createMockUrl(launchParams) {
|
|
4006
|
+
const params = new URLSearchParams(launchParams);
|
|
4007
|
+
return `https://mock-share.venus.test/share?${params.toString()}`;
|
|
4008
|
+
}
|
|
4009
|
+
};
|
|
4010
|
+
|
|
4011
|
+
// src/social/RpcSocialApi.ts
|
|
4012
|
+
var RpcSocialApi = class {
|
|
4013
|
+
constructor(rpcClient) {
|
|
4014
|
+
this.rpcClient = rpcClient;
|
|
4015
|
+
}
|
|
4016
|
+
async shareLinkAsync(options) {
|
|
4017
|
+
const result = await this.rpcClient.call("H5_SHARE_LINK" /* SHARE_LINK */, {
|
|
4018
|
+
launchParams: options.launchParams,
|
|
4019
|
+
metadata: options.metadata ?? {}
|
|
4020
|
+
});
|
|
4021
|
+
return {
|
|
4022
|
+
shareUrl: result.shareUrl
|
|
4023
|
+
};
|
|
4024
|
+
}
|
|
4025
|
+
async createQRCodeAsync(options) {
|
|
4026
|
+
const result = await this.rpcClient.call(
|
|
4027
|
+
"H5_CREATE_SHARE_QRCODE" /* CREATE_SHARE_QRCODE */,
|
|
4028
|
+
{
|
|
4029
|
+
launchParams: options.launchParams,
|
|
4030
|
+
metadata: options.metadata ?? {},
|
|
4031
|
+
qrOptions: options.qrOptions ?? {}
|
|
4032
|
+
}
|
|
4033
|
+
);
|
|
4034
|
+
return {
|
|
4035
|
+
shareUrl: result.shareUrl,
|
|
4036
|
+
qrCode: result.qrCode
|
|
4037
|
+
};
|
|
4038
|
+
}
|
|
4039
|
+
};
|
|
4040
|
+
|
|
4041
|
+
// src/VenusTransport.ts
|
|
4042
|
+
var VenusTransport = class {
|
|
4043
|
+
constructor() {
|
|
4044
|
+
__publicField(this, "messageHandler");
|
|
4045
|
+
__publicField(this, "onNotificationCallbacks", []);
|
|
4046
|
+
__publicField(this, "onNotificationCallbacksToRemove", []);
|
|
4047
|
+
__publicField(this, "onVenusMessageCallbacks", []);
|
|
4048
|
+
__publicField(this, "onResponseCallbacks", []);
|
|
4049
|
+
__publicField(this, "onResponseCallbacksToRemove", []);
|
|
4050
|
+
__publicField(this, "_instanceId", null);
|
|
4051
|
+
__publicField(this, "isStarted", false);
|
|
4052
|
+
__publicField(this, "isProcessingMessage", false);
|
|
4053
|
+
this.messageHandler = async (event) => {
|
|
4054
|
+
this.isProcessingMessage = true;
|
|
4055
|
+
let message;
|
|
4056
|
+
if (typeof event.data === "string") {
|
|
4057
|
+
message = JSON.parse(event.data);
|
|
4058
|
+
} else {
|
|
4059
|
+
message = event.data;
|
|
4060
|
+
}
|
|
4061
|
+
if (!message) {
|
|
4062
|
+
this.logInfo("No message found. Ignoring message...");
|
|
4063
|
+
return;
|
|
4064
|
+
}
|
|
4065
|
+
this.notifyVenusMessageReceived(message);
|
|
4066
|
+
if (message.type === "PAUSE" /* PAUSE */ || message.type === "RESUME" /* RESUME */ || message.type === "AWAKE" /* AWAKE */ || message.type === "SLEEP" /* SLEEP */ || message.type === "QUIT" /* QUIT */) {
|
|
4067
|
+
const notification = {
|
|
4068
|
+
type: "rpc-notification",
|
|
4069
|
+
id: message.type,
|
|
4070
|
+
payload: message.data
|
|
4071
|
+
};
|
|
4072
|
+
this.handleNotification(notification);
|
|
4073
|
+
this.isProcessingMessage = false;
|
|
4074
|
+
return;
|
|
4075
|
+
}
|
|
4076
|
+
const messageData = message.data;
|
|
4077
|
+
if (!messageData) {
|
|
4078
|
+
this.logWarn("No data found. Ignoring message...");
|
|
4079
|
+
this.isProcessingMessage = false;
|
|
4080
|
+
return;
|
|
4081
|
+
}
|
|
4082
|
+
const requestId = messageData.requestId;
|
|
4083
|
+
if (!requestId) {
|
|
4084
|
+
this.logWarn("No requestId. Ignoring message...");
|
|
4085
|
+
this.isProcessingMessage = false;
|
|
4086
|
+
return;
|
|
4087
|
+
}
|
|
4088
|
+
if (message.type !== "H5_RESPONSE" /* H5_RESPONSE */) {
|
|
4089
|
+
this.logWarn(`Ignoring unknown message type: ${message.type}`);
|
|
4090
|
+
this.isProcessingMessage = false;
|
|
4091
|
+
return;
|
|
4092
|
+
}
|
|
4093
|
+
const success = messageData.success;
|
|
4094
|
+
let error = void 0;
|
|
4095
|
+
if (!success) {
|
|
4096
|
+
error = {
|
|
4097
|
+
message: messageData.error || "Unknown error"
|
|
4098
|
+
};
|
|
4099
|
+
}
|
|
4100
|
+
let result = messageData.value;
|
|
4101
|
+
if (result === void 0) {
|
|
4102
|
+
result = messageData.data;
|
|
4103
|
+
}
|
|
4104
|
+
const response = {
|
|
4105
|
+
type: "rpc-response",
|
|
4106
|
+
id: requestId,
|
|
4107
|
+
result,
|
|
4108
|
+
method: message.type,
|
|
4109
|
+
error
|
|
4110
|
+
};
|
|
4111
|
+
await this.handleResponse(response);
|
|
4112
|
+
this.isProcessingMessage = false;
|
|
4113
|
+
};
|
|
4114
|
+
}
|
|
4115
|
+
onNotification(callback) {
|
|
4116
|
+
this.onNotificationCallbacks.push(callback);
|
|
4117
|
+
return {
|
|
4118
|
+
unsubscribe: () => {
|
|
4119
|
+
if (this.isProcessingMessage) {
|
|
4120
|
+
this.onNotificationCallbacks.push(callback);
|
|
4121
|
+
} else {
|
|
4122
|
+
this.removeOnNotificationCallback(callback);
|
|
4123
|
+
}
|
|
4124
|
+
}
|
|
4125
|
+
};
|
|
4126
|
+
}
|
|
4127
|
+
onRequest(callback) {
|
|
4128
|
+
throw new Error("Method not implemented.");
|
|
4129
|
+
}
|
|
4130
|
+
onResponse(callback) {
|
|
4131
|
+
this.onResponseCallbacks.push(callback);
|
|
4132
|
+
return {
|
|
4133
|
+
unsubscribe: () => {
|
|
4134
|
+
if (this.isProcessingMessage) {
|
|
4135
|
+
this.onResponseCallbacksToRemove.push(callback);
|
|
4136
|
+
} else {
|
|
4137
|
+
this.removeOnResponseCallback(callback);
|
|
4138
|
+
}
|
|
4139
|
+
}
|
|
4140
|
+
};
|
|
4141
|
+
}
|
|
4142
|
+
get instanceId() {
|
|
4143
|
+
return this._instanceId;
|
|
4144
|
+
}
|
|
4145
|
+
set instanceId(instanceId) {
|
|
4146
|
+
this._instanceId = instanceId;
|
|
4147
|
+
}
|
|
4148
|
+
sendRequest(request) {
|
|
4149
|
+
const instanceId = this.instanceId || "unknown";
|
|
4150
|
+
const method = request.method;
|
|
4151
|
+
const message = {
|
|
4152
|
+
type: method,
|
|
4153
|
+
direction: "H5_TO_APP",
|
|
4154
|
+
data: {
|
|
4155
|
+
...request.args,
|
|
4156
|
+
requestId: request.id
|
|
4157
|
+
},
|
|
4158
|
+
instanceId,
|
|
4159
|
+
timestamp: Date.now()
|
|
4160
|
+
};
|
|
4161
|
+
this.sendVenusMessage(message);
|
|
4162
|
+
}
|
|
4163
|
+
sendVenusMessage(message) {
|
|
4164
|
+
const messageAsString = JSON.stringify(message, null, 2);
|
|
4165
|
+
const reactNativeWebView = window.ReactNativeWebView;
|
|
4166
|
+
if (reactNativeWebView) {
|
|
4167
|
+
reactNativeWebView.postMessage(messageAsString);
|
|
4168
|
+
} else {
|
|
4169
|
+
window.parent.postMessage(messageAsString, "*");
|
|
4170
|
+
}
|
|
4171
|
+
}
|
|
4172
|
+
sendResponse(response) {
|
|
4173
|
+
throw new Error("Method not implemented.");
|
|
4174
|
+
}
|
|
4175
|
+
start() {
|
|
4176
|
+
if (this.isStarted) {
|
|
4177
|
+
return;
|
|
4178
|
+
}
|
|
4179
|
+
this.isStarted = true;
|
|
4180
|
+
window.addEventListener("message", this.messageHandler, true);
|
|
4181
|
+
this.logInfo(`Started`);
|
|
4182
|
+
}
|
|
4183
|
+
stop() {
|
|
4184
|
+
if (!this.isStarted) {
|
|
4185
|
+
return;
|
|
4186
|
+
}
|
|
4187
|
+
this.isStarted = false;
|
|
4188
|
+
window.removeEventListener("message", this.messageHandler);
|
|
4189
|
+
this.logInfo(`Stopped`);
|
|
4190
|
+
}
|
|
4191
|
+
handleNotification(notification) {
|
|
4192
|
+
for (const callback of this.onNotificationCallbacks) {
|
|
4193
|
+
callback(notification);
|
|
4194
|
+
}
|
|
4195
|
+
for (const callback of this.onNotificationCallbacksToRemove) {
|
|
4196
|
+
this.removeOnNotificationCallback(callback);
|
|
4197
|
+
}
|
|
4198
|
+
this.onNotificationCallbacksToRemove.length = 0;
|
|
4199
|
+
}
|
|
4200
|
+
async handleResponse(response) {
|
|
4201
|
+
for (const callback of this.onResponseCallbacks) {
|
|
4202
|
+
const consumed = await callback(response);
|
|
4203
|
+
if (consumed) {
|
|
4204
|
+
break;
|
|
4205
|
+
}
|
|
4206
|
+
}
|
|
4207
|
+
for (const callback of this.onResponseCallbacksToRemove) {
|
|
4208
|
+
this.removeOnResponseCallback(callback);
|
|
4209
|
+
}
|
|
4210
|
+
this.onResponseCallbacksToRemove.length = 0;
|
|
4211
|
+
}
|
|
4212
|
+
removeOnResponseCallback(callback) {
|
|
4213
|
+
this.onResponseCallbacks.splice(
|
|
4214
|
+
this.onResponseCallbacks.indexOf(callback),
|
|
4215
|
+
1
|
|
4216
|
+
);
|
|
4217
|
+
}
|
|
4218
|
+
removeOnNotificationCallback(callback) {
|
|
4219
|
+
this.onNotificationCallbacks.splice(
|
|
4220
|
+
this.onNotificationCallbacks.indexOf(callback),
|
|
4221
|
+
1
|
|
4222
|
+
);
|
|
4223
|
+
}
|
|
4224
|
+
logInfo(message, ...params) {
|
|
4225
|
+
console.log(`[Venus Transport] ${message}`, ...params);
|
|
4226
|
+
}
|
|
4227
|
+
logWarn(message, ...params) {
|
|
4228
|
+
console.warn(`[Venus Transport] ${message}`, ...params);
|
|
4229
|
+
}
|
|
4230
|
+
onVenusMessage(callback) {
|
|
4231
|
+
this.onVenusMessageCallbacks.push(callback);
|
|
4232
|
+
return {
|
|
4233
|
+
unsubscribe: () => {
|
|
4234
|
+
this.onVenusMessageCallbacks.splice(
|
|
4235
|
+
this.onVenusMessageCallbacks.indexOf(callback),
|
|
4236
|
+
1
|
|
4237
|
+
);
|
|
4238
|
+
}
|
|
4239
|
+
};
|
|
4240
|
+
}
|
|
4241
|
+
notifyVenusMessageReceived(message) {
|
|
4242
|
+
for (const callback of this.onVenusMessageCallbacks) {
|
|
4243
|
+
callback(message);
|
|
4244
|
+
}
|
|
4245
|
+
}
|
|
4246
|
+
};
|
|
4247
|
+
|
|
4248
|
+
// src/RemoteHost.ts
|
|
4249
|
+
init_rooms();
|
|
4250
|
+
|
|
4251
|
+
// src/rooms/RpcRoomsApi.ts
|
|
4252
|
+
init_VenusRoom();
|
|
4253
|
+
var RpcRoomsApi = class {
|
|
4254
|
+
constructor(rpcClient) {
|
|
4255
|
+
__publicField(this, "rpcClient");
|
|
4256
|
+
__publicField(this, "subscriptions");
|
|
4257
|
+
__publicField(this, "transportSubscription", null);
|
|
4258
|
+
this.rpcClient = rpcClient;
|
|
4259
|
+
this.subscriptions = {
|
|
4260
|
+
data: {},
|
|
4261
|
+
messages: {},
|
|
4262
|
+
gameEvents: {},
|
|
4263
|
+
allEvents: {}
|
|
4264
|
+
};
|
|
4265
|
+
}
|
|
4266
|
+
/**
|
|
4267
|
+
* Get the subscription state for external access (used by setupRoomNotifications)
|
|
4268
|
+
*/
|
|
4269
|
+
getSubscriptions() {
|
|
4270
|
+
return this.subscriptions;
|
|
4271
|
+
}
|
|
4272
|
+
/**
|
|
4273
|
+
* Set up room notification routing from the transport
|
|
4274
|
+
*/
|
|
4275
|
+
setupNotifications(transport) {
|
|
4276
|
+
const { setupRoomNotifications: setupRoomNotifications2 } = (init_rooms(), __toCommonJS(rooms_exports));
|
|
4277
|
+
this.transportSubscription = setupRoomNotifications2(
|
|
4278
|
+
transport,
|
|
4279
|
+
() => this.getSubscriptions()
|
|
4280
|
+
);
|
|
4281
|
+
}
|
|
4282
|
+
/**
|
|
4283
|
+
* Clean up subscriptions and resources
|
|
4284
|
+
*/
|
|
4285
|
+
dispose() {
|
|
4286
|
+
if (this.transportSubscription) {
|
|
4287
|
+
this.transportSubscription.unsubscribe();
|
|
4288
|
+
this.transportSubscription = null;
|
|
4289
|
+
console.log("[Venus Rooms] Cleaned up room notification subscription");
|
|
4290
|
+
}
|
|
4291
|
+
}
|
|
4292
|
+
async createRoom(options) {
|
|
4293
|
+
const response = await this.rpcClient.call(
|
|
4294
|
+
"H5_ROOM_CREATE" /* H5_ROOM_CREATE */,
|
|
4295
|
+
{
|
|
4296
|
+
options
|
|
4297
|
+
}
|
|
4298
|
+
);
|
|
4299
|
+
if (response.success === false) {
|
|
4300
|
+
throw new Error(response.error || "Failed to create room");
|
|
4301
|
+
}
|
|
4302
|
+
const roomData = response.roomData || response;
|
|
4303
|
+
const room = new VenusRoom(roomData);
|
|
4304
|
+
return room;
|
|
4305
|
+
}
|
|
4306
|
+
async joinOrCreateRoom(options) {
|
|
4307
|
+
const response = await this.rpcClient.call(
|
|
4308
|
+
"H5_ROOM_JOIN_OR_CREATE" /* H5_ROOM_JOIN_OR_CREATE */,
|
|
4309
|
+
{
|
|
4310
|
+
options
|
|
4311
|
+
}
|
|
4312
|
+
);
|
|
4313
|
+
if (response.success === false) {
|
|
4314
|
+
throw new Error(response.error || "Failed to join or create room");
|
|
4315
|
+
}
|
|
4316
|
+
const data = response.value || response;
|
|
4317
|
+
const room = new VenusRoom(data.roomData);
|
|
4318
|
+
return {
|
|
4319
|
+
action: data.action,
|
|
4320
|
+
room,
|
|
4321
|
+
playersJoined: data.playersJoined
|
|
4322
|
+
};
|
|
4323
|
+
}
|
|
4324
|
+
async joinRoomByCode(roomCode) {
|
|
4325
|
+
const response = await this.rpcClient.call(
|
|
4326
|
+
"H5_ROOM_JOIN_BY_CODE" /* H5_ROOM_JOIN_BY_CODE */,
|
|
4327
|
+
{
|
|
4328
|
+
roomCode
|
|
4329
|
+
}
|
|
4330
|
+
);
|
|
4331
|
+
if (response?.success === false) {
|
|
4332
|
+
throw new Error(response.error || "Failed to join room by code");
|
|
4333
|
+
}
|
|
4334
|
+
const roomData = response.roomData || response;
|
|
4335
|
+
const room = new VenusRoom(roomData);
|
|
4336
|
+
return room;
|
|
4337
|
+
}
|
|
4338
|
+
// Get user's rooms with optional filtering
|
|
4339
|
+
async getUserRooms(includeArchived = false) {
|
|
4340
|
+
const response = await this.rpcClient.call(
|
|
4341
|
+
"H5_ROOM_GET_USER_ROOMS" /* H5_ROOM_GET_USER_ROOMS */,
|
|
4342
|
+
{
|
|
4343
|
+
includeArchived
|
|
4344
|
+
}
|
|
4345
|
+
);
|
|
4346
|
+
if (response?.success === false) {
|
|
4347
|
+
throw new Error(response.error || "Failed to get user rooms");
|
|
4348
|
+
}
|
|
4349
|
+
const rawRooms = response.rooms || [];
|
|
4350
|
+
const venusRooms = [];
|
|
4351
|
+
for (const roomData of rawRooms) {
|
|
4352
|
+
if (!roomData.id) {
|
|
4353
|
+
console.warn("getUserRooms: Skipping room with missing ID:", roomData);
|
|
4354
|
+
continue;
|
|
4355
|
+
}
|
|
4356
|
+
try {
|
|
4357
|
+
const venusRoom = new VenusRoom(roomData);
|
|
4358
|
+
venusRooms.push(venusRoom);
|
|
4359
|
+
} catch (error) {
|
|
4360
|
+
console.warn(
|
|
4361
|
+
"getUserRooms: Failed to create VenusRoom object:",
|
|
4362
|
+
error,
|
|
4363
|
+
roomData
|
|
4364
|
+
);
|
|
4365
|
+
}
|
|
4366
|
+
}
|
|
4367
|
+
return venusRooms;
|
|
4368
|
+
}
|
|
4369
|
+
async updateData(room, updates, merge = true) {
|
|
4370
|
+
const response = await this.rpcClient.call(
|
|
4371
|
+
"H5_ROOM_UPDATE_DATA" /* H5_ROOM_UPDATE_DATA */,
|
|
4372
|
+
{
|
|
4373
|
+
roomId: room.id,
|
|
4374
|
+
updates,
|
|
4375
|
+
merge
|
|
4376
|
+
}
|
|
4377
|
+
);
|
|
4378
|
+
if (response?.success === false) {
|
|
4379
|
+
throw new Error(response.error || "Failed to update room data");
|
|
4380
|
+
}
|
|
4381
|
+
return response.data;
|
|
4382
|
+
}
|
|
4383
|
+
async getData(room) {
|
|
4384
|
+
const response = await this.rpcClient.call(
|
|
4385
|
+
"H5_ROOM_GET_DATA" /* H5_ROOM_GET_DATA */,
|
|
4386
|
+
{
|
|
4387
|
+
roomId: room.id
|
|
4388
|
+
}
|
|
4389
|
+
);
|
|
4390
|
+
if (response?.success === false) {
|
|
4391
|
+
throw new Error(response.error || "Failed to get room data");
|
|
4392
|
+
}
|
|
4393
|
+
return response.data;
|
|
4394
|
+
}
|
|
4395
|
+
async sendMessage(venusRoom, messageData) {
|
|
4396
|
+
const response = await this.rpcClient.call(
|
|
4397
|
+
"H5_ROOM_SEND_MESSAGE" /* H5_ROOM_SEND_MESSAGE */,
|
|
4398
|
+
{
|
|
4399
|
+
roomId: venusRoom.id,
|
|
4400
|
+
message: messageData
|
|
4401
|
+
}
|
|
4402
|
+
);
|
|
4403
|
+
if (response?.success === false) {
|
|
4404
|
+
throw new Error(response.error || "Failed to send message");
|
|
4405
|
+
}
|
|
4406
|
+
return response.messageId;
|
|
4407
|
+
}
|
|
4408
|
+
async leave(room) {
|
|
4409
|
+
const response = await this.rpcClient.call(
|
|
4410
|
+
"H5_ROOM_LEAVE" /* H5_ROOM_LEAVE */,
|
|
4411
|
+
{
|
|
4412
|
+
roomId: room.id
|
|
4413
|
+
}
|
|
4414
|
+
);
|
|
4415
|
+
if (response?.success === false) {
|
|
4416
|
+
throw new Error(response.error || "Failed to leave room");
|
|
4417
|
+
}
|
|
4418
|
+
return response;
|
|
4419
|
+
}
|
|
4420
|
+
async startGame(room, gameConfig = {}, turnOrder = null) {
|
|
4421
|
+
const response = await this.rpcClient.call(
|
|
4422
|
+
"H5_ROOM_START_GAME" /* H5_ROOM_START_GAME */,
|
|
4423
|
+
{
|
|
4424
|
+
roomId: room.id,
|
|
4425
|
+
gameConfig,
|
|
4426
|
+
turnOrder
|
|
4427
|
+
}
|
|
4428
|
+
);
|
|
4429
|
+
if (response?.success === false) {
|
|
4430
|
+
throw new Error(response.error || "Failed to start game");
|
|
4431
|
+
}
|
|
4432
|
+
return response.data;
|
|
4433
|
+
}
|
|
4434
|
+
async proposeMove(room, proposalPayload) {
|
|
4435
|
+
const response = await this.rpcClient.call(
|
|
4436
|
+
"h5:room:proposeMove" /* H5_ROOM_PROPOSE_MOVE */,
|
|
4437
|
+
{
|
|
4438
|
+
roomId: room.id,
|
|
4439
|
+
gameSpecificState: proposalPayload.gameSpecificState,
|
|
4440
|
+
moveType: proposalPayload.moveType,
|
|
4441
|
+
clientContext: proposalPayload.clientContext,
|
|
4442
|
+
clientProposalId: proposalPayload.clientProposalId
|
|
4443
|
+
}
|
|
4444
|
+
);
|
|
4445
|
+
if (response?.success === false) {
|
|
4446
|
+
throw new Error(response.error || "Failed to propose move");
|
|
4447
|
+
}
|
|
4448
|
+
return response.data;
|
|
4449
|
+
}
|
|
4450
|
+
async validateMove(room, moveId, isValid, reason = null, validatorId = null) {
|
|
4451
|
+
console.log(`[Venus Rooms] Validating move ${moveId}: ${isValid}`);
|
|
4452
|
+
return { success: true, moveId, isValid, reason };
|
|
4453
|
+
}
|
|
4454
|
+
async roomSubscribeToGameEvents(room, callback) {
|
|
4455
|
+
"game_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9);
|
|
4456
|
+
if (!this.subscriptions.gameEvents[room.id]) {
|
|
4457
|
+
this.subscriptions.gameEvents[room.id] = [];
|
|
4458
|
+
}
|
|
4459
|
+
this.subscriptions.gameEvents[room.id].push(callback);
|
|
4460
|
+
}
|
|
4461
|
+
subscribe(room, options = {}) {
|
|
4462
|
+
const subscriptionIds = [];
|
|
4463
|
+
const roomId = room.id;
|
|
4464
|
+
if (options.onData) {
|
|
4465
|
+
const dataSubId = "data_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9);
|
|
4466
|
+
if (!this.subscriptions.data[roomId]) {
|
|
4467
|
+
this.subscriptions.data[roomId] = [];
|
|
4468
|
+
}
|
|
4469
|
+
this.subscriptions.data[roomId].push(options.onData);
|
|
4470
|
+
subscriptionIds.push({
|
|
4471
|
+
type: "data",
|
|
4472
|
+
id: dataSubId,
|
|
4473
|
+
callback: options.onData
|
|
4474
|
+
});
|
|
4475
|
+
}
|
|
4476
|
+
if (options.onMessages) {
|
|
4477
|
+
const msgSubId = "messages_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9);
|
|
4478
|
+
if (!this.subscriptions.messages[roomId]) {
|
|
4479
|
+
this.subscriptions.messages[roomId] = [];
|
|
4480
|
+
}
|
|
4481
|
+
this.subscriptions.messages[roomId].push(options.onMessages);
|
|
4482
|
+
subscriptionIds.push({
|
|
4483
|
+
type: "messages",
|
|
4484
|
+
id: msgSubId,
|
|
4485
|
+
callback: options.onMessages
|
|
4486
|
+
});
|
|
4487
|
+
}
|
|
4488
|
+
if (options.onMoves || options.onGameEvents) {
|
|
4489
|
+
const handler = options.onMoves || options.onGameEvents;
|
|
4490
|
+
if (handler) {
|
|
4491
|
+
const gameSubId = "game_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9);
|
|
4492
|
+
if (!this.subscriptions.gameEvents[roomId]) {
|
|
4493
|
+
this.subscriptions.gameEvents[roomId] = [];
|
|
4494
|
+
}
|
|
4495
|
+
this.subscriptions.gameEvents[roomId].push(handler);
|
|
4496
|
+
subscriptionIds.push({
|
|
4497
|
+
type: "gameEvents",
|
|
4498
|
+
id: gameSubId,
|
|
4499
|
+
callback: handler
|
|
4500
|
+
});
|
|
4501
|
+
}
|
|
4502
|
+
}
|
|
4503
|
+
const needsSubscription = subscriptionIds.length > 0 && (this.subscriptions.data[roomId]?.length ?? 0) <= 1 && (this.subscriptions.messages[roomId]?.length ?? 0) <= 1 && (this.subscriptions.gameEvents[roomId]?.length ?? 0) <= 1;
|
|
4504
|
+
if (needsSubscription) {
|
|
4505
|
+
this.rpcClient.call("H5_ROOM_SUBSCRIBE" /* H5_ROOM_SUBSCRIBE */, {
|
|
4506
|
+
roomId,
|
|
4507
|
+
subscribeToData: !!options.onData,
|
|
4508
|
+
subscribeToMessages: !!options.onMessages,
|
|
4509
|
+
subscribeToProposedMoves: !!(options.onMoves || options.onGameEvents)
|
|
4510
|
+
}).catch((error) => {
|
|
4511
|
+
console.error("Failed to set up room subscription:", error);
|
|
4512
|
+
});
|
|
4513
|
+
}
|
|
4514
|
+
let called = false;
|
|
4515
|
+
return () => {
|
|
4516
|
+
if (called) return;
|
|
4517
|
+
called = true;
|
|
4518
|
+
subscriptionIds.forEach((sub) => {
|
|
4519
|
+
const bucket = this.subscriptions[sub.type];
|
|
4520
|
+
const callbacks = bucket && bucket[roomId] || [];
|
|
4521
|
+
const index = callbacks.indexOf(sub.callback);
|
|
4522
|
+
if (index > -1) callbacks.splice(index, 1);
|
|
4523
|
+
});
|
|
4524
|
+
const hasNoCallbacks = (this.subscriptions.data[roomId]?.length ?? 0) === 0 && (this.subscriptions.messages[roomId]?.length ?? 0) === 0 && (this.subscriptions.gameEvents[roomId]?.length ?? 0) === 0;
|
|
4525
|
+
if (hasNoCallbacks) {
|
|
4526
|
+
this.rpcClient.call("H5_ROOM_UNSUBSCRIBE" /* H5_ROOM_UNSUBSCRIBE */, {
|
|
4527
|
+
roomId
|
|
4528
|
+
}).catch((error) => {
|
|
4529
|
+
console.error("Failed to clean up room subscription:", error);
|
|
4530
|
+
});
|
|
4531
|
+
}
|
|
4532
|
+
};
|
|
4533
|
+
}
|
|
4534
|
+
};
|
|
4535
|
+
|
|
4536
|
+
// src/RemoteHost.ts
|
|
4537
|
+
var getCdnBaseUrl = () => {
|
|
4538
|
+
return "https://venus-static-01293ak.web.app/";
|
|
4539
|
+
};
|
|
4540
|
+
var RemoteHost = class {
|
|
4541
|
+
constructor(venusApi) {
|
|
4542
|
+
__publicField(this, "ads");
|
|
4543
|
+
__publicField(this, "analytics");
|
|
4544
|
+
__publicField(this, "deviceCache");
|
|
4545
|
+
__publicField(this, "appStorage");
|
|
4546
|
+
__publicField(this, "globalStorage");
|
|
4547
|
+
__publicField(this, "avatar3d");
|
|
4548
|
+
__publicField(this, "navigation");
|
|
4549
|
+
__publicField(this, "notifications");
|
|
4550
|
+
__publicField(this, "popups");
|
|
4551
|
+
__publicField(this, "profile");
|
|
4552
|
+
__publicField(this, "cdn");
|
|
4553
|
+
__publicField(this, "time");
|
|
4554
|
+
__publicField(this, "post");
|
|
4555
|
+
__publicField(this, "ai");
|
|
4556
|
+
__publicField(this, "haptics");
|
|
4557
|
+
__publicField(this, "features");
|
|
4558
|
+
__publicField(this, "lifecycle");
|
|
4559
|
+
__publicField(this, "simulation");
|
|
4560
|
+
__publicField(this, "rooms");
|
|
4561
|
+
__publicField(this, "logging");
|
|
4562
|
+
__publicField(this, "iap");
|
|
4563
|
+
__publicField(this, "leaderboard");
|
|
4564
|
+
__publicField(this, "preloader");
|
|
4565
|
+
__publicField(this, "social");
|
|
4566
|
+
__publicField(this, "venusApi");
|
|
4567
|
+
__publicField(this, "rpcClient");
|
|
4568
|
+
__publicField(this, "_isInitialized", false);
|
|
4569
|
+
this.venusApi = venusApi;
|
|
4570
|
+
const rpcClient = new RpcClient();
|
|
4571
|
+
this.rpcClient = rpcClient;
|
|
4572
|
+
this.ads = new RpcAdsApi(rpcClient);
|
|
4573
|
+
this.analytics = new RpcAnalyticsApi(rpcClient);
|
|
4574
|
+
this.deviceCache = new RpcStorageApi(rpcClient, {
|
|
4575
|
+
clear: "H5_DEVICE_CACHE_CLEAR" /* DEVICE_CACHE_CLEAR */,
|
|
4576
|
+
getItem: "H5_DEVICE_CACHE_GET_ITEM" /* DEVICE_CACHE_GET_ITEM */,
|
|
4577
|
+
getKey: "H5_DEVICE_CACHE_KEY" /* DEVICE_CACHE_KEY */,
|
|
4578
|
+
length: "H5_DEVICE_CACHE_LENGTH" /* DEVICE_CACHE_LENGTH */,
|
|
4579
|
+
removeItem: "H5_DEVICE_CACHE_REMOVE_ITEM" /* DEVICE_CACHE_REMOVE_ITEM */,
|
|
4580
|
+
setItem: "H5_DEVICE_CACHE_SET_ITEM" /* DEVICE_CACHE_SET_ITEM */
|
|
4581
|
+
});
|
|
4582
|
+
this.appStorage = new RpcStorageApi(rpcClient, {
|
|
4583
|
+
clear: "H5_APP_STORAGE_CLEAR" /* APP_STORAGE_CLEAR */,
|
|
4584
|
+
getItem: "H5_APP_STORAGE_GET_ITEM" /* APP_STORAGE_GET_ITEM */,
|
|
4585
|
+
getKey: "H5_APP_STORAGE_KEY" /* APP_STORAGE_KEY */,
|
|
4586
|
+
length: "H5_APP_STORAGE_LENGTH" /* APP_STORAGE_LENGTH */,
|
|
4587
|
+
removeItem: "H5_APP_STORAGE_REMOVE_ITEM" /* APP_STORAGE_REMOVE_ITEM */,
|
|
4588
|
+
setItem: "H5_APP_STORAGE_SET_ITEM" /* APP_STORAGE_SET_ITEM */,
|
|
4589
|
+
getAllItems: "H5_APP_STORAGE_GET_ALL_ITEMS" /* APP_STORAGE_GET_ALL_ITEMS */,
|
|
4590
|
+
setMultipleItems: "H5_APP_STORAGE_SET_ITEM" /* APP_STORAGE_SET_ITEM */,
|
|
4591
|
+
removeMultipleItems: "H5_APP_STORAGE_REMOVE_ITEM" /* APP_STORAGE_REMOVE_ITEM */
|
|
4592
|
+
});
|
|
4593
|
+
this.globalStorage = new RpcStorageApi(rpcClient, {
|
|
4594
|
+
clear: "H5_GLOBAL_STORAGE_CLEAR" /* GLOBAL_STORAGE_CLEAR */,
|
|
4595
|
+
getItem: "H5_GLOBAL_STORAGE_GET_ITEM" /* GLOBAL_STORAGE_GET_ITEM */,
|
|
4596
|
+
getKey: "H5_GLOBAL_STORAGE_KEY" /* GLOBAL_STORAGE_KEY */,
|
|
4597
|
+
length: "H5_GLOBAL_STORAGE_LENGTH" /* GLOBAL_STORAGE_LENGTH */,
|
|
4598
|
+
removeItem: "H5_GLOBAL_STORAGE_REMOVE_ITEM" /* GLOBAL_STORAGE_REMOVE_ITEM */,
|
|
4599
|
+
setItem: "H5_GLOBAL_STORAGE_SET_ITEM" /* GLOBAL_STORAGE_SET_ITEM */,
|
|
4600
|
+
getAllItems: "H5_GLOBAL_STORAGE_GET_ALL_ITEMS" /* GLOBAL_STORAGE_GET_ALL_ITEMS */,
|
|
4601
|
+
setMultipleItems: "H5_GLOBAL_STORAGE_SET_MULTIPLE_ITEMS" /* GLOBAL_STORAGE_SET_MULTIPLE_ITEMS */,
|
|
4602
|
+
removeMultipleItems: "H5_GLOBAL_STORAGE_REMOVE_MULTIPLE_ITEMS" /* GLOBAL_STORAGE_REMOVE_MULTIPLE_ITEMS */
|
|
4603
|
+
});
|
|
4604
|
+
this.avatar3d = new RpcAvatarApi(rpcClient, venusApi);
|
|
4605
|
+
this.navigation = new RpcNavigationApi(rpcClient, venusApi);
|
|
4606
|
+
this.notifications = new RpcNotificationsApi(rpcClient);
|
|
4607
|
+
this.popups = new RpcPopupsApi(rpcClient);
|
|
4608
|
+
this.profile = new HostProfileApi();
|
|
4609
|
+
this.cdn = new HostCdnApi(getCdnBaseUrl());
|
|
4610
|
+
this.time = new HostTimeApi(rpcClient);
|
|
4611
|
+
this.post = new RpcPostApi(rpcClient);
|
|
4612
|
+
this.ai = new RpcAiApi(rpcClient);
|
|
4613
|
+
this.haptics = new RpcHapticsApi(rpcClient);
|
|
4614
|
+
this.features = new RpcFeaturesApi(rpcClient);
|
|
4615
|
+
this.lifecycle = new RpcLifecycleApi(rpcClient);
|
|
4616
|
+
this.simulation = new RpcSimulationApi(rpcClient);
|
|
4617
|
+
this.rooms = new RpcRoomsApi(rpcClient);
|
|
4618
|
+
this.logging = new RpcLoggingApi(this, rpcClient);
|
|
4619
|
+
this.iap = new RpcIapApi(rpcClient);
|
|
4620
|
+
this.leaderboard = new RpcLeaderboardApi(rpcClient);
|
|
4621
|
+
this.preloader = new RpcPreloaderApi(rpcClient);
|
|
4622
|
+
this.social = new RpcSocialApi(rpcClient);
|
|
4623
|
+
venusApi.isMock = () => false;
|
|
4624
|
+
this.venusApi.sharedAssets = new RpcSharedAssetsApi(rpcClient, venusApi);
|
|
4625
|
+
initializeRoomsApi(this.venusApi, this);
|
|
4626
|
+
console.log("[Venus SDK] Remote host created");
|
|
4627
|
+
}
|
|
4628
|
+
get isInitialized() {
|
|
4629
|
+
return this._isInitialized;
|
|
4630
|
+
}
|
|
4631
|
+
async initialize(options) {
|
|
4632
|
+
this.log("Initializing Remote Host...");
|
|
4633
|
+
const transport = new VenusTransport();
|
|
4634
|
+
transport.start();
|
|
4635
|
+
this.rpcClient.start(transport);
|
|
4636
|
+
const roomsApi = this.rooms;
|
|
4637
|
+
roomsApi.setupNotifications(transport);
|
|
4638
|
+
const response = await this.rpcClient.call(
|
|
4639
|
+
"INITIALIZE_SDK" /* INIT_SDK */,
|
|
4640
|
+
{},
|
|
4641
|
+
5e3
|
|
4642
|
+
);
|
|
4643
|
+
transport.instanceId = response.instanceId;
|
|
4644
|
+
this.log(`Remote Host Initialized with id: ${transport.instanceId}`);
|
|
4645
|
+
if (response.profile) {
|
|
4646
|
+
const profile = response.profile;
|
|
4647
|
+
const sanitizedProfile = {
|
|
4648
|
+
id: profile.id,
|
|
4649
|
+
username: profile.username,
|
|
4650
|
+
avatarUrl: profile.avatarUrl ?? null,
|
|
4651
|
+
isAnonymous: Boolean(profile.isAnonymous)
|
|
4652
|
+
};
|
|
4653
|
+
if (typeof window !== "undefined") {
|
|
4654
|
+
const globalWindow = window;
|
|
4655
|
+
const venus = globalWindow.venus || (globalWindow.venus = {});
|
|
4656
|
+
venus.profile = sanitizedProfile;
|
|
4657
|
+
if (venus._config) {
|
|
4658
|
+
venus._config.profile = sanitizedProfile;
|
|
4659
|
+
}
|
|
4660
|
+
if (venus.config) {
|
|
4661
|
+
venus.config.profile = sanitizedProfile;
|
|
4662
|
+
}
|
|
4663
|
+
}
|
|
4664
|
+
}
|
|
4665
|
+
this._isInitialized = true;
|
|
4666
|
+
this.venusApi.launchParams = response.launchParams || {};
|
|
4667
|
+
await this.rpcClient.call("READY" /* READY */, {});
|
|
4668
|
+
const hudInsets = response.hudInsets;
|
|
4669
|
+
if (hudInsets) {
|
|
4670
|
+
this.venusApi.config.ui.safeArea = hudInsets;
|
|
4671
|
+
}
|
|
4672
|
+
return {
|
|
4673
|
+
hudInsets,
|
|
4674
|
+
initializeAsleep: response.initializeAsleep
|
|
4675
|
+
};
|
|
4676
|
+
}
|
|
4677
|
+
log(message) {
|
|
4678
|
+
console.log(`[Venus SDK] [Remote Host] ${message}`);
|
|
4679
|
+
}
|
|
4680
|
+
};
|
|
4681
|
+
|
|
4682
|
+
// src/MockHost.ts
|
|
4683
|
+
init_rooms();
|
|
4684
|
+
var ROOMS_UNAVAILABLE_MESSAGE = "[Venus SDK] Rooms API is only available when running inside the Venus host environment.";
|
|
4685
|
+
function createUnavailableRoomsApi() {
|
|
4686
|
+
const roomsUnavailableError = () => new Error(ROOMS_UNAVAILABLE_MESSAGE);
|
|
4687
|
+
return {
|
|
4688
|
+
async createRoom() {
|
|
4689
|
+
throw roomsUnavailableError();
|
|
4690
|
+
},
|
|
4691
|
+
async joinOrCreateRoom() {
|
|
4692
|
+
throw roomsUnavailableError();
|
|
4693
|
+
},
|
|
4694
|
+
async getUserRooms() {
|
|
4695
|
+
throw roomsUnavailableError();
|
|
4696
|
+
},
|
|
4697
|
+
async joinRoomByCode() {
|
|
4698
|
+
throw roomsUnavailableError();
|
|
4699
|
+
},
|
|
4700
|
+
subscribe() {
|
|
4701
|
+
throw roomsUnavailableError();
|
|
4702
|
+
},
|
|
4703
|
+
async updateData() {
|
|
4704
|
+
throw roomsUnavailableError();
|
|
4705
|
+
},
|
|
4706
|
+
async getData() {
|
|
4707
|
+
throw roomsUnavailableError();
|
|
4708
|
+
},
|
|
4709
|
+
async sendMessage() {
|
|
4710
|
+
throw roomsUnavailableError();
|
|
4711
|
+
},
|
|
4712
|
+
async leave() {
|
|
4713
|
+
throw roomsUnavailableError();
|
|
4714
|
+
},
|
|
4715
|
+
async startGame() {
|
|
4716
|
+
throw roomsUnavailableError();
|
|
4717
|
+
},
|
|
4718
|
+
async proposeMove() {
|
|
4719
|
+
throw roomsUnavailableError();
|
|
4720
|
+
},
|
|
4721
|
+
async validateMove() {
|
|
4722
|
+
throw roomsUnavailableError();
|
|
4723
|
+
}
|
|
4724
|
+
};
|
|
4725
|
+
}
|
|
4726
|
+
var MockHost = class {
|
|
4727
|
+
constructor(venusApi) {
|
|
4728
|
+
__publicField(this, "ads");
|
|
4729
|
+
__publicField(this, "analytics");
|
|
4730
|
+
__publicField(this, "deviceCache");
|
|
4731
|
+
__publicField(this, "appStorage");
|
|
4732
|
+
__publicField(this, "globalStorage");
|
|
4733
|
+
__publicField(this, "avatar3d");
|
|
4734
|
+
__publicField(this, "navigation");
|
|
4735
|
+
__publicField(this, "notifications");
|
|
4736
|
+
__publicField(this, "popups");
|
|
4737
|
+
__publicField(this, "profile");
|
|
4738
|
+
__publicField(this, "cdn");
|
|
4739
|
+
__publicField(this, "time");
|
|
4740
|
+
__publicField(this, "post");
|
|
4741
|
+
__publicField(this, "ai");
|
|
4742
|
+
__publicField(this, "haptics");
|
|
4743
|
+
__publicField(this, "features");
|
|
4744
|
+
__publicField(this, "lifecycle");
|
|
4745
|
+
__publicField(this, "simulation");
|
|
4746
|
+
__publicField(this, "rooms");
|
|
4747
|
+
__publicField(this, "logging");
|
|
4748
|
+
__publicField(this, "iap");
|
|
4749
|
+
__publicField(this, "leaderboard");
|
|
4750
|
+
__publicField(this, "preloader");
|
|
4751
|
+
__publicField(this, "social");
|
|
4752
|
+
__publicField(this, "state", 0 /* PLAYING */);
|
|
4753
|
+
__publicField(this, "venusApi");
|
|
4754
|
+
__publicField(this, "_isInitialized", false);
|
|
4755
|
+
__publicField(this, "_overlay");
|
|
4756
|
+
__publicField(this, "_mockLifecyclesApi");
|
|
4757
|
+
__publicField(this, "_mockAdsApi");
|
|
4758
|
+
this.venusApi = venusApi;
|
|
4759
|
+
this._overlay = this.createOverlay();
|
|
4760
|
+
this._mockAdsApi = new MockAdsApi(this._overlay);
|
|
4761
|
+
this._mockLifecyclesApi = new MockLifecycleApi();
|
|
4762
|
+
this.ads = this._mockAdsApi;
|
|
4763
|
+
this.analytics = new MockAnalyticsApi();
|
|
4764
|
+
const appUrl = typeof window !== "undefined" ? window.location.href : "";
|
|
4765
|
+
this.deviceCache = createMockStorageApi("deviceCache", appUrl);
|
|
4766
|
+
this.appStorage = createMockStorageApi("appStorage", appUrl);
|
|
4767
|
+
this.globalStorage = createMockStorageApi("globalStorage");
|
|
4768
|
+
this.avatar3d = new MockAvatarApi(venusApi);
|
|
4769
|
+
this.navigation = new MockNavigationApi(venusApi);
|
|
4770
|
+
this.notifications = new MockNotificationsApi(venusApi);
|
|
4771
|
+
this.popups = new MockPopupsApi(this._overlay);
|
|
4772
|
+
this.profile = new MockProfileApi();
|
|
4773
|
+
this.cdn = new MockCdnApi();
|
|
4774
|
+
this.time = new MockTimeApi(venusApi);
|
|
4775
|
+
this.post = new MockPostApi(venusApi);
|
|
4776
|
+
this.ai = new MockAiApi();
|
|
4777
|
+
this.haptics = new MockHapticsApi(venusApi);
|
|
4778
|
+
this.features = new MockFeaturesApi();
|
|
4779
|
+
this.lifecycle = this._mockLifecyclesApi;
|
|
4780
|
+
this.simulation = new MockSimulationApi();
|
|
4781
|
+
this.rooms = createUnavailableRoomsApi();
|
|
4782
|
+
this.logging = new MockLoggingApi();
|
|
4783
|
+
this.iap = new MockIapApi();
|
|
4784
|
+
this.social = new MockSocialApi();
|
|
4785
|
+
this.leaderboard = new MockLeaderboardApi();
|
|
4786
|
+
initializeRoomsApi(this.venusApi, this);
|
|
4787
|
+
this.preloader = new MockPreloaderApi();
|
|
4788
|
+
venusApi.isMock = () => true;
|
|
4789
|
+
this.venusApi.sharedAssets = new MockSharedAssetsApi(this.venusApi);
|
|
4790
|
+
}
|
|
4791
|
+
get isInitialized() {
|
|
4792
|
+
return this._isInitialized;
|
|
4793
|
+
}
|
|
4794
|
+
initialize(options) {
|
|
4795
|
+
this._isInitialized = true;
|
|
4796
|
+
return Promise.resolve({
|
|
4797
|
+
initializeAsleep: false
|
|
4798
|
+
});
|
|
4799
|
+
}
|
|
4800
|
+
updateUiControls() {
|
|
4801
|
+
const controls = {
|
|
4802
|
+
closeButton: { x: 16, y: 16, width: 32, height: 32 },
|
|
4803
|
+
menuButton: {
|
|
4804
|
+
x: window.innerWidth - 48,
|
|
4805
|
+
y: 16,
|
|
4806
|
+
width: 32,
|
|
4807
|
+
height: 32
|
|
4808
|
+
},
|
|
4809
|
+
feedHeader: { x: 0, y: 0, width: window.innerWidth, height: 56 },
|
|
4810
|
+
playButton: {
|
|
4811
|
+
x: 0,
|
|
4812
|
+
y: window.innerHeight - 60,
|
|
4813
|
+
width: window.innerWidth,
|
|
4814
|
+
height: 60
|
|
4815
|
+
}
|
|
4816
|
+
};
|
|
4817
|
+
return controls;
|
|
4818
|
+
}
|
|
4819
|
+
createOverlay() {
|
|
4820
|
+
const venusApi = this.venusApi;
|
|
4821
|
+
venusApi.config.ui.controls = this.updateUiControls();
|
|
4822
|
+
const uiControls = venusApi.config.ui.controls;
|
|
4823
|
+
const overlayContainer = document.createElement("div");
|
|
4824
|
+
overlayContainer.id = "venus-mock-overlay";
|
|
4825
|
+
overlayContainer.style.cssText = `
|
|
4826
|
+
position: fixed;
|
|
4827
|
+
top: 0;
|
|
4828
|
+
left: 0;
|
|
4829
|
+
width: 100%;
|
|
4830
|
+
height: 100%;
|
|
4831
|
+
pointer-events: none;
|
|
4832
|
+
z-index: 10000;
|
|
4833
|
+
`;
|
|
4834
|
+
document.body.appendChild(overlayContainer);
|
|
4835
|
+
const menuButton = this.createOverlayButton(
|
|
4836
|
+
"close",
|
|
4837
|
+
"Menu",
|
|
4838
|
+
uiControls.menuButton,
|
|
4839
|
+
() => {
|
|
4840
|
+
this.handleMenuButtonClicked();
|
|
4841
|
+
},
|
|
4842
|
+
"rgba(59, 130, 246, 0.7)",
|
|
4843
|
+
// Blue background instead of black
|
|
4844
|
+
"#FFFFFF"
|
|
4845
|
+
);
|
|
4846
|
+
overlayContainer.appendChild(menuButton);
|
|
4847
|
+
const adOverlay = this.setupAdOverlay();
|
|
4848
|
+
const actionSheet = this.setupActionSheetOverlay();
|
|
4849
|
+
window.addEventListener("resize", () => {
|
|
4850
|
+
this.updateOverlayLayout();
|
|
4851
|
+
});
|
|
4852
|
+
return {
|
|
4853
|
+
container: overlayContainer,
|
|
4854
|
+
elements: {
|
|
4855
|
+
menuButton
|
|
4856
|
+
},
|
|
4857
|
+
appVisibilityState: "visible",
|
|
4858
|
+
actionSheetOverlay: actionSheet,
|
|
4859
|
+
adOverlay,
|
|
4860
|
+
showAdOverlay: () => {
|
|
4861
|
+
return this.showAdOverlay("REWARDED VIDEO AD");
|
|
4862
|
+
},
|
|
4863
|
+
showActionSheet: (items, options) => {
|
|
4864
|
+
return this.showActionSheetOverlay(items, options);
|
|
4865
|
+
}
|
|
4866
|
+
};
|
|
4867
|
+
}
|
|
4868
|
+
async handleMenuButtonClicked() {
|
|
4869
|
+
if (this.state === 0 /* PLAYING */) {
|
|
4870
|
+
this.triggerLifecycleEvent("PAUSE" /* PAUSE */);
|
|
4871
|
+
this.state = 1 /* PAUSED */;
|
|
4872
|
+
}
|
|
4873
|
+
const actionSheetItems = [];
|
|
4874
|
+
const awakeAction = {
|
|
4875
|
+
label: "\u23F0 Awake",
|
|
4876
|
+
id: "awakeAction"
|
|
4877
|
+
};
|
|
4878
|
+
const sleepAction = {
|
|
4879
|
+
label: "\u{1F4A4} Sleep",
|
|
4880
|
+
id: "sleepAction"
|
|
4881
|
+
};
|
|
4882
|
+
const quitAction = {
|
|
4883
|
+
label: "\u{1F6D1} Quit",
|
|
4884
|
+
id: "quitAction"
|
|
4885
|
+
};
|
|
4886
|
+
const playAction = {
|
|
4887
|
+
label: "\u25B6\uFE0F Play",
|
|
4888
|
+
id: "playAction"
|
|
4889
|
+
};
|
|
4890
|
+
if (this.state === 1 /* PAUSED */) {
|
|
4891
|
+
actionSheetItems.push(sleepAction);
|
|
4892
|
+
} else if (this.state === 2 /* SLEEPING */) {
|
|
4893
|
+
actionSheetItems.push(awakeAction);
|
|
4894
|
+
}
|
|
4895
|
+
if (this.state !== 3 /* TERMINATED */) {
|
|
4896
|
+
actionSheetItems.push(quitAction);
|
|
4897
|
+
} else if (this.state === 3 /* TERMINATED */) {
|
|
4898
|
+
actionSheetItems.push(playAction);
|
|
4899
|
+
}
|
|
4900
|
+
const action = await this.showActionSheetOverlay(actionSheetItems);
|
|
4901
|
+
if (action === awakeAction.id) {
|
|
4902
|
+
this.tryAwake();
|
|
4903
|
+
} else if (action === sleepAction.id) {
|
|
4904
|
+
this.trySleep();
|
|
4905
|
+
} else if (action === playAction.id) {
|
|
4906
|
+
this.tryPlay();
|
|
4907
|
+
} else if (action === quitAction.id) {
|
|
4908
|
+
this.tryQuit();
|
|
4909
|
+
} else {
|
|
4910
|
+
this.tryResume();
|
|
4911
|
+
}
|
|
4912
|
+
}
|
|
4913
|
+
tryAwake() {
|
|
4914
|
+
if (this.state === 2 /* SLEEPING */) {
|
|
4915
|
+
this.triggerLifecycleEvent("AWAKE" /* AWAKE */);
|
|
4916
|
+
this.state = 1 /* PAUSED */;
|
|
4917
|
+
}
|
|
4918
|
+
}
|
|
4919
|
+
trySleep() {
|
|
4920
|
+
if (this.state === 1 /* PAUSED */) {
|
|
4921
|
+
this.triggerLifecycleEvent("SLEEP" /* SLEEP */);
|
|
4922
|
+
this.state = 2 /* SLEEPING */;
|
|
4923
|
+
}
|
|
4924
|
+
}
|
|
4925
|
+
tryPlay() {
|
|
4926
|
+
if (this.state === 3 /* TERMINATED */) {
|
|
4927
|
+
this.triggerLifecycleEvent("AWAKE" /* AWAKE */);
|
|
4928
|
+
this.state = 1 /* PAUSED */;
|
|
4929
|
+
this.triggerLifecycleEvent("RESUME" /* RESUME */);
|
|
4930
|
+
this.state = 0 /* PLAYING */;
|
|
4931
|
+
}
|
|
4932
|
+
}
|
|
4933
|
+
tryQuit() {
|
|
4934
|
+
if (this.state === 0 /* PLAYING */) {
|
|
4935
|
+
this.triggerLifecycleEvent("PAUSE" /* PAUSE */);
|
|
4936
|
+
this.state = 1 /* PAUSED */;
|
|
4937
|
+
}
|
|
4938
|
+
if (this.state === 1 /* PAUSED */) {
|
|
4939
|
+
this.triggerLifecycleEvent("SLEEP" /* SLEEP */);
|
|
4940
|
+
this.state = 2 /* SLEEPING */;
|
|
4941
|
+
}
|
|
4942
|
+
if (this.state === 2 /* SLEEPING */) {
|
|
4943
|
+
this.triggerLifecycleEvent("QUIT" /* QUIT */);
|
|
4944
|
+
this.state = 3 /* TERMINATED */;
|
|
4945
|
+
}
|
|
4946
|
+
}
|
|
4947
|
+
tryResume() {
|
|
4948
|
+
if (this.state === 1 /* PAUSED */) {
|
|
4949
|
+
this.triggerLifecycleEvent("RESUME" /* RESUME */);
|
|
4950
|
+
}
|
|
4951
|
+
}
|
|
4952
|
+
async showAdOverlay(type) {
|
|
4953
|
+
return new Promise((resolve, reject) => {
|
|
4954
|
+
const overlay = this._overlay;
|
|
4955
|
+
const adOverlay = overlay.adOverlay;
|
|
4956
|
+
overlay.adOverlay.innerHTML = "";
|
|
4957
|
+
const heading = document.createElement("h1");
|
|
4958
|
+
heading.style.cssText = `
|
|
4959
|
+
font-size: 24px;
|
|
4960
|
+
margin-bottom: 20px;
|
|
4961
|
+
text-align: center;
|
|
4962
|
+
`;
|
|
4963
|
+
heading.innerText = type === "interstitial" ? "INTERSTITIAL AD" : "REWARDED VIDEO AD";
|
|
4964
|
+
overlay.adOverlay.appendChild(heading);
|
|
4965
|
+
const content = document.createElement("div");
|
|
4966
|
+
content.style.cssText = `
|
|
4967
|
+
width: 300px;
|
|
4968
|
+
height: 250px;
|
|
4969
|
+
background-color: #1e40af;
|
|
4970
|
+
display: flex;
|
|
4971
|
+
align-items: center;
|
|
4972
|
+
justify-content: center;
|
|
4973
|
+
margin-bottom: 20px;
|
|
4974
|
+
border-radius: 8px;
|
|
4975
|
+
`;
|
|
4976
|
+
content.innerText = "Mock Ad Content";
|
|
4977
|
+
adOverlay.appendChild(content);
|
|
4978
|
+
const timer = document.createElement("p");
|
|
4979
|
+
timer.style.cssText = `
|
|
4980
|
+
margin-bottom: 20px;
|
|
4981
|
+
font-size: 16px;
|
|
4982
|
+
`;
|
|
4983
|
+
timer.innerText = "Normally ads would have a timer...";
|
|
4984
|
+
adOverlay.appendChild(timer);
|
|
4985
|
+
const okButton = document.createElement("button");
|
|
4986
|
+
okButton.style.cssText = `
|
|
4987
|
+
padding: 10px 40px;
|
|
4988
|
+
background-color: #2563eb;
|
|
4989
|
+
color: white;
|
|
4990
|
+
border: none;
|
|
4991
|
+
border-radius: 4px;
|
|
4992
|
+
font-size: 16px;
|
|
4993
|
+
cursor: pointer;
|
|
4994
|
+
`;
|
|
4995
|
+
okButton.innerText = "Close Ad";
|
|
4996
|
+
adOverlay.appendChild(okButton);
|
|
4997
|
+
adOverlay.style.display = "flex";
|
|
4998
|
+
okButton.onclick = () => {
|
|
4999
|
+
this.hideAdOverlay();
|
|
5000
|
+
resolve(true);
|
|
5001
|
+
};
|
|
5002
|
+
});
|
|
5003
|
+
}
|
|
5004
|
+
hideAdOverlay() {
|
|
5005
|
+
const overlay = this._overlay;
|
|
5006
|
+
if (overlay.adOverlay) {
|
|
5007
|
+
overlay.adOverlay.style.display = "none";
|
|
5008
|
+
}
|
|
5009
|
+
}
|
|
5010
|
+
setupActionSheetOverlay() {
|
|
5011
|
+
const actionSheetOverlay = document.createElement("div");
|
|
5012
|
+
actionSheetOverlay.id = "venus-action-sheet-overlay";
|
|
5013
|
+
actionSheetOverlay.style.cssText = `
|
|
5014
|
+
position: fixed;
|
|
5015
|
+
top: 0;
|
|
5016
|
+
left: 0;
|
|
5017
|
+
width: 100%;
|
|
5018
|
+
height: 100%;
|
|
5019
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
5020
|
+
display: flex;
|
|
5021
|
+
align-items: center;
|
|
5022
|
+
justify-content: center;
|
|
5023
|
+
z-index: 10600;
|
|
5024
|
+
font-family: sans-serif;
|
|
5025
|
+
display: none;
|
|
5026
|
+
`;
|
|
5027
|
+
document.body.appendChild(actionSheetOverlay);
|
|
5028
|
+
return actionSheetOverlay;
|
|
5029
|
+
}
|
|
5030
|
+
createOverlayButton(id, text, position, onClick, background, color) {
|
|
5031
|
+
const button = document.createElement("button");
|
|
5032
|
+
button.id = `venus-mock-${id}-button`;
|
|
5033
|
+
button.innerText = text;
|
|
5034
|
+
button.style.cssText = `
|
|
5035
|
+
position: absolute;
|
|
5036
|
+
left: ${position.x}px;
|
|
5037
|
+
top: ${position.y}px;
|
|
5038
|
+
width: ${position.width}px;
|
|
5039
|
+
min-width: ${position.width}px;
|
|
5040
|
+
height: ${position.height}px;
|
|
5041
|
+
background: ${background};
|
|
5042
|
+
color: ${color};
|
|
5043
|
+
border: none;
|
|
5044
|
+
border-radius: 8px;
|
|
5045
|
+
font-family: sans-serif;
|
|
5046
|
+
font-weight: bold;
|
|
5047
|
+
font-size: ${Math.min(position.width, position.height) / 3}px;
|
|
5048
|
+
cursor: pointer;
|
|
5049
|
+
pointer-events: auto;
|
|
5050
|
+
display: flex;
|
|
5051
|
+
align-items: center;
|
|
5052
|
+
justify-content: center;
|
|
5053
|
+
opacity: 0.9;
|
|
5054
|
+
transition: opacity 0.2s;
|
|
5055
|
+
`;
|
|
5056
|
+
button.addEventListener("click", onClick);
|
|
5057
|
+
button.addEventListener("mouseover", () => {
|
|
5058
|
+
button.style.opacity = "1";
|
|
5059
|
+
});
|
|
5060
|
+
button.addEventListener("mouseout", () => {
|
|
5061
|
+
button.style.opacity = "0.9";
|
|
5062
|
+
});
|
|
5063
|
+
return button;
|
|
5064
|
+
}
|
|
5065
|
+
updateOverlayLayout() {
|
|
5066
|
+
const venusApi = this.venusApi;
|
|
5067
|
+
const overlay = this._overlay;
|
|
5068
|
+
venusApi.config.ui.controls = this.updateUiControls();
|
|
5069
|
+
const uiControls = venusApi.config.ui.controls;
|
|
5070
|
+
const menuBtn = overlay.elements.menuButton;
|
|
5071
|
+
const menuPos = uiControls.menuButton;
|
|
5072
|
+
menuBtn.style.left = `${menuPos.x}px`;
|
|
5073
|
+
menuBtn.style.top = `${menuPos.y}px`;
|
|
5074
|
+
menuBtn.style.width = `${menuPos.width}px`;
|
|
5075
|
+
menuBtn.style.minWidth = `${menuPos.width}px`;
|
|
5076
|
+
menuBtn.style.height = `${menuPos.height}px`;
|
|
5077
|
+
}
|
|
5078
|
+
triggerLifecycleEvent(name) {
|
|
5079
|
+
console.log("Trigger Lifecycle Event: ", name);
|
|
5080
|
+
if (name == "PAUSE" /* PAUSE */) {
|
|
5081
|
+
this._mockLifecyclesApi.triggerPauseCallbacks();
|
|
5082
|
+
} else if (name == "RESUME" /* RESUME */) {
|
|
5083
|
+
this._mockLifecyclesApi.triggerResumeCallbacks();
|
|
5084
|
+
} else if (name == "QUIT" /* QUIT */) {
|
|
5085
|
+
this._mockLifecyclesApi.triggerQuitCallbacks();
|
|
5086
|
+
} else if (name == "AWAKE" /* AWAKE */) {
|
|
5087
|
+
this._mockLifecyclesApi.triggerAwakeCallbacks();
|
|
5088
|
+
} else if (name == "SLEEP" /* SLEEP */) {
|
|
5089
|
+
this._mockLifecyclesApi.triggerSleepCallbacks();
|
|
5090
|
+
}
|
|
5091
|
+
}
|
|
5092
|
+
setOverlayElementVisibility(element, visible) {
|
|
5093
|
+
const overlay = this._overlay;
|
|
5094
|
+
const elements = overlay.elements;
|
|
5095
|
+
if (elements[element]) {
|
|
5096
|
+
elements[element].style.display = visible ? "flex" : "none";
|
|
5097
|
+
}
|
|
5098
|
+
}
|
|
5099
|
+
setupAdOverlay() {
|
|
5100
|
+
const adOverlay = document.createElement("div");
|
|
5101
|
+
adOverlay.id = "venus-ad-overlay";
|
|
5102
|
+
adOverlay.style.cssText = `
|
|
5103
|
+
position: fixed;
|
|
5104
|
+
top: 0;
|
|
5105
|
+
left: 0;
|
|
5106
|
+
width: 100%;
|
|
5107
|
+
height: 100%;
|
|
5108
|
+
background-color: rgba(37, 99, 235, 0.9);
|
|
5109
|
+
color: white;
|
|
5110
|
+
display: flex;
|
|
5111
|
+
flex-direction: column;
|
|
5112
|
+
align-items: center;
|
|
5113
|
+
justify-content: center;
|
|
5114
|
+
z-index: 10500;
|
|
5115
|
+
font-family: sans-serif;
|
|
5116
|
+
display: none;
|
|
5117
|
+
`;
|
|
5118
|
+
document.body.appendChild(adOverlay);
|
|
5119
|
+
return adOverlay;
|
|
5120
|
+
}
|
|
5121
|
+
log(msg, ...args) {
|
|
5122
|
+
console.log(`[Venus Mock] ${msg}`, ...args);
|
|
5123
|
+
}
|
|
5124
|
+
showActionSheetOverlay(items, options) {
|
|
5125
|
+
this.log("Showing ActionSheetOverlay...");
|
|
5126
|
+
return new Promise((resolve, reject) => {
|
|
5127
|
+
const overlay = this._overlay;
|
|
5128
|
+
overlay.actionSheetOverlay.innerHTML = "";
|
|
5129
|
+
overlay.actionSheetOverlay.style.display = "flex";
|
|
5130
|
+
const actionSheet = document.createElement("div");
|
|
5131
|
+
actionSheet.className = "venus-action-sheet";
|
|
5132
|
+
actionSheet.style.cssText = `
|
|
5133
|
+
background-color: white;
|
|
5134
|
+
border-radius: 8px;
|
|
5135
|
+
width: 80%;
|
|
5136
|
+
max-width: 400px;
|
|
5137
|
+
max-height: 80%;
|
|
5138
|
+
display: flex;
|
|
5139
|
+
flex-direction: column;
|
|
5140
|
+
overflow: hidden;
|
|
5141
|
+
color: black;
|
|
5142
|
+
`;
|
|
5143
|
+
if (options?.title) {
|
|
5144
|
+
const titleContainer = document.createElement("div");
|
|
5145
|
+
titleContainer.style.cssText = `
|
|
5146
|
+
padding: 16px;
|
|
5147
|
+
border-bottom: 1px solid #eaeaea;
|
|
5148
|
+
font-weight: bold;
|
|
5149
|
+
font-size: 18px;
|
|
5150
|
+
text-align: center;
|
|
5151
|
+
color: black;
|
|
5152
|
+
`;
|
|
5153
|
+
titleContainer.innerText = options.title;
|
|
5154
|
+
actionSheet.appendChild(titleContainer);
|
|
5155
|
+
}
|
|
5156
|
+
if (options?.message) {
|
|
5157
|
+
const messageContainer = document.createElement("div");
|
|
5158
|
+
messageContainer.style.cssText = `
|
|
5159
|
+
padding: 8px 16px;
|
|
5160
|
+
color: #666;
|
|
5161
|
+
font-size: 14px;
|
|
5162
|
+
text-align: center;
|
|
5163
|
+
`;
|
|
5164
|
+
messageContainer.innerText = options.message;
|
|
5165
|
+
actionSheet.appendChild(messageContainer);
|
|
5166
|
+
}
|
|
5167
|
+
const optionsContainer = document.createElement("div");
|
|
5168
|
+
optionsContainer.style.cssText = `
|
|
5169
|
+
overflow-y: auto;
|
|
5170
|
+
max-height: 300px;
|
|
5171
|
+
`;
|
|
5172
|
+
items.forEach((item, index) => {
|
|
5173
|
+
const optionItem = document.createElement("div");
|
|
5174
|
+
optionItem.style.cssText = `
|
|
5175
|
+
padding: 12px 16px;
|
|
5176
|
+
border-bottom: 1px solid #eaeaea;
|
|
5177
|
+
cursor: pointer;
|
|
5178
|
+
display: flex;
|
|
5179
|
+
align-items: center;
|
|
5180
|
+
transition: background-color 0.2s;
|
|
5181
|
+
color: black;
|
|
5182
|
+
`;
|
|
5183
|
+
optionItem.addEventListener("mouseover", () => {
|
|
5184
|
+
optionItem.style.backgroundColor = "#f5f5f5";
|
|
5185
|
+
});
|
|
5186
|
+
optionItem.addEventListener("mouseout", () => {
|
|
5187
|
+
optionItem.style.backgroundColor = "white";
|
|
5188
|
+
});
|
|
5189
|
+
if (item.icon) {
|
|
5190
|
+
const iconSpan = document.createElement("span");
|
|
5191
|
+
iconSpan.style.cssText = `
|
|
5192
|
+
margin-right: 12px;
|
|
5193
|
+
font-size: 16px;
|
|
5194
|
+
`;
|
|
5195
|
+
iconSpan.innerText = item.icon;
|
|
5196
|
+
optionItem.appendChild(iconSpan);
|
|
5197
|
+
}
|
|
5198
|
+
const labelSpan = document.createElement("span");
|
|
5199
|
+
labelSpan.style.cssText = `
|
|
5200
|
+
color: black;
|
|
5201
|
+
`;
|
|
5202
|
+
labelSpan.innerText = item.label;
|
|
5203
|
+
optionItem.appendChild(labelSpan);
|
|
5204
|
+
optionItem.addEventListener("click", () => {
|
|
5205
|
+
this.hideActionSheetOverlay();
|
|
5206
|
+
const optionId = item.id !== void 0 ? item.id : index;
|
|
5207
|
+
resolve(optionId);
|
|
5208
|
+
});
|
|
5209
|
+
optionsContainer.appendChild(optionItem);
|
|
5210
|
+
});
|
|
5211
|
+
actionSheet.appendChild(optionsContainer);
|
|
5212
|
+
if (!options?.disableCancel) {
|
|
5213
|
+
const cancelButton = document.createElement("div");
|
|
5214
|
+
cancelButton.style.cssText = `
|
|
5215
|
+
padding: 14px 16px;
|
|
5216
|
+
text-align: center;
|
|
5217
|
+
font-weight: bold;
|
|
5218
|
+
cursor: pointer;
|
|
5219
|
+
color: #3b82f6;
|
|
5220
|
+
border-top: 1px solid #eaeaea;
|
|
5221
|
+
`;
|
|
5222
|
+
cancelButton.innerText = options?.cancelButtonText || "Cancel";
|
|
5223
|
+
cancelButton.addEventListener("click", () => {
|
|
5224
|
+
this.hideActionSheetOverlay();
|
|
5225
|
+
resolve(null);
|
|
5226
|
+
});
|
|
5227
|
+
actionSheet.appendChild(cancelButton);
|
|
5228
|
+
}
|
|
5229
|
+
if (!options?.disableCancel) {
|
|
5230
|
+
const closeButton = document.createElement("div");
|
|
5231
|
+
closeButton.style.cssText = `
|
|
5232
|
+
position: absolute;
|
|
5233
|
+
top: 8px;
|
|
5234
|
+
right: 8px;
|
|
5235
|
+
width: 24px;
|
|
5236
|
+
height: 24px;
|
|
5237
|
+
border-radius: 12px;
|
|
5238
|
+
background-color: rgba(0,0,0,0.1);
|
|
5239
|
+
color: #666;
|
|
5240
|
+
display: flex;
|
|
5241
|
+
align-items: center;
|
|
5242
|
+
justify-content: center;
|
|
5243
|
+
cursor: pointer;
|
|
5244
|
+
font-size: 14px;
|
|
5245
|
+
`;
|
|
5246
|
+
closeButton.innerText = "\u2715";
|
|
5247
|
+
closeButton.addEventListener("click", () => {
|
|
5248
|
+
this.hideActionSheetOverlay();
|
|
5249
|
+
resolve(null);
|
|
5250
|
+
});
|
|
5251
|
+
actionSheet.appendChild(closeButton);
|
|
5252
|
+
overlay.actionSheetOverlay.appendChild(actionSheet);
|
|
5253
|
+
}
|
|
5254
|
+
});
|
|
5255
|
+
}
|
|
5256
|
+
hideActionSheetOverlay() {
|
|
5257
|
+
const overlay = this._overlay;
|
|
5258
|
+
if (overlay.actionSheetOverlay) {
|
|
5259
|
+
overlay.actionSheetOverlay.style.display = "none";
|
|
5260
|
+
}
|
|
5261
|
+
}
|
|
5262
|
+
};
|
|
5263
|
+
|
|
5264
|
+
// src/Host.ts
|
|
5265
|
+
function createHost(venusApi, isMock) {
|
|
5266
|
+
if (isMock) {
|
|
5267
|
+
console.log("[Venus SDK] Creating Local Host");
|
|
5268
|
+
return new MockHost(venusApi);
|
|
5269
|
+
} else {
|
|
5270
|
+
console.log("[Venus SDK] Creating Remote Host");
|
|
5271
|
+
return new RemoteHost(venusApi);
|
|
5272
|
+
}
|
|
5273
|
+
}
|
|
5274
|
+
|
|
5275
|
+
// src/social/index.ts
|
|
5276
|
+
function initializeSocial(venusApi, host) {
|
|
5277
|
+
venusApi.social = host.social;
|
|
5278
|
+
venusApi.getLaunchParams = () => {
|
|
5279
|
+
return venusApi.launchParams || {};
|
|
5280
|
+
};
|
|
5281
|
+
}
|
|
5282
|
+
|
|
5283
|
+
export { HapticFeedbackStyle, HostCdnApi, HostProfileApi, HostTimeApi, MockAdsApi, MockAiApi, MockAnalyticsApi, MockAvatarApi, MockCdnApi, MockFeaturesApi, MockHapticsApi, MockIapApi, MockLeaderboardApi, MockLifecycleApi, MockLoggingApi, MockNavigationApi, MockNotificationsApi, MockPopupsApi, MockPreloaderApi, MockProfileApi, MockSharedAssetsApi, MockSimulationApi, MockSocialApi, MockStorageApi, MockTimeApi, RemoteHost, RpcAdsApi, RpcAiApi, RpcAnalyticsApi, RpcAvatarApi, RpcClient, RpcFeaturesApi, RpcHapticsApi, RpcIapApi, RpcLeaderboardApi, RpcLifecycleApi, RpcLoggingApi, RpcNavigationApi, RpcNotificationsApi, RpcPopupsApi, RpcPreloaderApi, RpcSharedAssetsApi, RpcSimulationApi, RpcSocialApi, RpcStorageApi, SDK_VERSION, VenusMessageId, VenusRoom, createHost, createMockStorageApi, init_rooms, initializeAds, initializeAi, initializeAnalytics, initializeAvatar3d, initializeCdn, initializeFeaturesApi, initializeHaptics, initializeIap, initializeLeaderboard, initializeLifecycleApi, initializeLocalNotifications, initializeLoggingApi, initializePopups, initializePost, initializePreloader, initializeProfile, initializeRoomsApi, initializeSimulation, initializeSocial, initializeStackNavigation, initializeStorage, initializeTime, isPacificDaylightTime, setupRoomNotifications };
|
|
5284
|
+
//# sourceMappingURL=chunk-6DYG4RFQ.mjs.map
|
|
5285
|
+
//# sourceMappingURL=chunk-6DYG4RFQ.mjs.map
|