@series-inc/venus-sdk 3.4.2 → 3.4.3-beta.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-ihIIoDSK.d.ts → AdsApi-Dt9Yx0qb.d.ts} +30 -2
- package/dist/SandboxHost-PG4SXT3M.js +1880 -0
- package/dist/SandboxHost-PG4SXT3M.js.map +1 -0
- package/dist/chunk-MQ4UC45P.js +1890 -0
- package/dist/chunk-MQ4UC45P.js.map +1 -0
- package/dist/{chunk-W74ZI2H3.js → chunk-Q7SNANYR.js} +67 -1872
- package/dist/chunk-Q7SNANYR.js.map +1 -0
- package/dist/index.d.ts +31 -4
- package/dist/index.js +2 -1
- package/dist/venus-api/index.d.ts +2 -2
- package/dist/venus-api/index.js +44 -29
- package/dist/venus-api/index.js.map +1 -1
- package/dist/vite/index.css +19 -0
- package/dist/vite/index.css.map +1 -0
- package/dist/vite/index.d.ts +100 -1
- package/dist/vite/index.js +1165 -3
- package/dist/vite/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-W74ZI2H3.js.map +0 -1
|
@@ -112,7 +112,7 @@ var VenusMessageId = /* @__PURE__ */ ((VenusMessageId2) => {
|
|
|
112
112
|
VenusMessageId2["H5_ROOM_START_GAME"] = "H5_ROOM_START_GAME";
|
|
113
113
|
VenusMessageId2["H5_ROOM_PROPOSE_MOVE"] = "h5:room:proposeMove";
|
|
114
114
|
VenusMessageId2["H5_ROOM_END_GAME"] = "H5_ROOM_END_GAME";
|
|
115
|
-
VenusMessageId2["
|
|
115
|
+
VenusMessageId2["H5_ROOM_KICK_PLAYER"] = "H5_ROOM_KICK_PLAYER";
|
|
116
116
|
VenusMessageId2["H5_ROOM_PROMOTE_TO_SPECTATOR"] = "H5_ROOM_PROMOTE_TO_SPECTATOR";
|
|
117
117
|
VenusMessageId2["H5_LOAD_EMBEDDED_ASSET"] = "H5_LOAD_EMBEDDED_ASSET";
|
|
118
118
|
VenusMessageId2["H5_SHOW_LOAD_SCREEN"] = "H5_SHOW_LOAD_SCREEN";
|
|
@@ -2020,109 +2020,6 @@ function initializeProfile(venusApi, host) {
|
|
|
2020
2020
|
};
|
|
2021
2021
|
}
|
|
2022
2022
|
|
|
2023
|
-
// src/utils/idGenerator.ts
|
|
2024
|
-
function generateId() {
|
|
2025
|
-
return `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
2026
|
-
}
|
|
2027
|
-
|
|
2028
|
-
// src/rpc/RpcClient.ts
|
|
2029
|
-
var RpcClient = class {
|
|
2030
|
-
pendingCalls = /* @__PURE__ */ new Map();
|
|
2031
|
-
notificationCallbacks = /* @__PURE__ */ new Map();
|
|
2032
|
-
onResponseSub = null;
|
|
2033
|
-
onNotificationSub = null;
|
|
2034
|
-
transport = null;
|
|
2035
|
-
start(transport) {
|
|
2036
|
-
this.transport = transport;
|
|
2037
|
-
this.onResponseSub = transport.onResponse(async (response) => {
|
|
2038
|
-
return this.handleRpcResponse(response);
|
|
2039
|
-
});
|
|
2040
|
-
this.onNotificationSub = transport.onNotification(async (notification) => {
|
|
2041
|
-
return this.handleRpcNotification(notification);
|
|
2042
|
-
});
|
|
2043
|
-
}
|
|
2044
|
-
stop() {
|
|
2045
|
-
if (this.onResponseSub) {
|
|
2046
|
-
this.onResponseSub.unsubscribe();
|
|
2047
|
-
this.onResponseSub = null;
|
|
2048
|
-
}
|
|
2049
|
-
if (this.onNotificationSub) {
|
|
2050
|
-
this.onNotificationSub.unsubscribe();
|
|
2051
|
-
this.onNotificationSub = null;
|
|
2052
|
-
}
|
|
2053
|
-
this.transport = null;
|
|
2054
|
-
}
|
|
2055
|
-
onNotification(id, callback) {
|
|
2056
|
-
this.notificationCallbacks.set(id, callback);
|
|
2057
|
-
return {
|
|
2058
|
-
unsubscribe: () => {
|
|
2059
|
-
this.notificationCallbacks.delete(id);
|
|
2060
|
-
}
|
|
2061
|
-
};
|
|
2062
|
-
}
|
|
2063
|
-
callT(method, args, timeout = 5e3) {
|
|
2064
|
-
return this.call(method, args, timeout);
|
|
2065
|
-
}
|
|
2066
|
-
async call(method, args, timeout = 5e3) {
|
|
2067
|
-
return new Promise((resolve, reject) => {
|
|
2068
|
-
const id = generateId();
|
|
2069
|
-
this.addPendingCall(id, resolve, reject);
|
|
2070
|
-
const request = {
|
|
2071
|
-
type: "rpc-request",
|
|
2072
|
-
id,
|
|
2073
|
-
method,
|
|
2074
|
-
args
|
|
2075
|
-
};
|
|
2076
|
-
if (this.transport) {
|
|
2077
|
-
this.transport.sendRequest(request);
|
|
2078
|
-
}
|
|
2079
|
-
if (timeout > 0) {
|
|
2080
|
-
setTimeout(() => {
|
|
2081
|
-
if (this.hasPendingCall(id)) {
|
|
2082
|
-
this.removePendingCall(id);
|
|
2083
|
-
reject(new Error(`RPC call ${method} timed out`));
|
|
2084
|
-
}
|
|
2085
|
-
}, timeout);
|
|
2086
|
-
}
|
|
2087
|
-
});
|
|
2088
|
-
}
|
|
2089
|
-
hasPendingCall(id) {
|
|
2090
|
-
return this.pendingCalls.has(id);
|
|
2091
|
-
}
|
|
2092
|
-
addPendingCall(id, resolve, reject) {
|
|
2093
|
-
this.pendingCalls.set(id, {
|
|
2094
|
-
id,
|
|
2095
|
-
resolve,
|
|
2096
|
-
reject
|
|
2097
|
-
});
|
|
2098
|
-
}
|
|
2099
|
-
removePendingCall(id) {
|
|
2100
|
-
this.pendingCalls.delete(id);
|
|
2101
|
-
}
|
|
2102
|
-
getPendingCall(id) {
|
|
2103
|
-
return this.pendingCalls.get(id);
|
|
2104
|
-
}
|
|
2105
|
-
handleRpcResponse(response) {
|
|
2106
|
-
const pending = this.getPendingCall(response.id);
|
|
2107
|
-
if (!pending) {
|
|
2108
|
-
return false;
|
|
2109
|
-
}
|
|
2110
|
-
this.removePendingCall(response.id);
|
|
2111
|
-
if (response.error) {
|
|
2112
|
-
pending.reject(new Error(response.error.message));
|
|
2113
|
-
return true;
|
|
2114
|
-
}
|
|
2115
|
-
pending.resolve(response.result);
|
|
2116
|
-
return true;
|
|
2117
|
-
}
|
|
2118
|
-
handleRpcNotification(notification) {
|
|
2119
|
-
const callback = this.notificationCallbacks.get(notification.id);
|
|
2120
|
-
if (callback) {
|
|
2121
|
-
callback(notification.payload);
|
|
2122
|
-
}
|
|
2123
|
-
}
|
|
2124
|
-
};
|
|
2125
|
-
|
|
2126
2023
|
// src/rooms/VenusRoom.ts
|
|
2127
2024
|
var ROOM_GAME_PHASES = ["waiting", "playing", "ended"];
|
|
2128
2025
|
var VenusRoom = class {
|
|
@@ -2354,6 +2251,16 @@ var RpcRoomsApi = class {
|
|
|
2354
2251
|
}
|
|
2355
2252
|
);
|
|
2356
2253
|
}
|
|
2254
|
+
async kickPlayerAsync(room, targetProfileId, options = {}) {
|
|
2255
|
+
const args = {
|
|
2256
|
+
roomId: room.id,
|
|
2257
|
+
targetProfileId
|
|
2258
|
+
};
|
|
2259
|
+
if (options.reason !== void 0) {
|
|
2260
|
+
args.reason = options.reason;
|
|
2261
|
+
}
|
|
2262
|
+
await this.rpcClient.call("H5_ROOM_KICK_PLAYER" /* H5_ROOM_KICK_PLAYER */, args);
|
|
2263
|
+
}
|
|
2357
2264
|
async startRoomGameAsync(room, options = {}) {
|
|
2358
2265
|
await this.rpcClient.call(
|
|
2359
2266
|
"H5_ROOM_START_GAME" /* H5_ROOM_START_GAME */,
|
|
@@ -2505,6 +2412,7 @@ function initializeRoomsApi(venusApi, host) {
|
|
|
2505
2412
|
["getRoomDataAsync"],
|
|
2506
2413
|
["sendRoomMessageAsync"],
|
|
2507
2414
|
["leaveRoomAsync"],
|
|
2415
|
+
["kickPlayerAsync"],
|
|
2508
2416
|
["startRoomGameAsync"],
|
|
2509
2417
|
["proposeMoveAsync"],
|
|
2510
2418
|
["validateMoveAsync"]
|
|
@@ -2581,6 +2489,19 @@ var MockStorageApi = class {
|
|
|
2581
2489
|
}
|
|
2582
2490
|
return items;
|
|
2583
2491
|
}
|
|
2492
|
+
async getAllData() {
|
|
2493
|
+
const result = {};
|
|
2494
|
+
const orderedKeys = this.keys();
|
|
2495
|
+
for (const key of orderedKeys) {
|
|
2496
|
+
const value = localStorage.getItem(this.buildKey(key));
|
|
2497
|
+
if (value !== null) {
|
|
2498
|
+
result[key] = value;
|
|
2499
|
+
} else {
|
|
2500
|
+
this.removeFromOrder(key);
|
|
2501
|
+
}
|
|
2502
|
+
}
|
|
2503
|
+
return result;
|
|
2504
|
+
}
|
|
2584
2505
|
async getItem(key) {
|
|
2585
2506
|
const fullKey = this.buildKey(key);
|
|
2586
2507
|
await this.simulateSyncDelay();
|
|
@@ -2858,6 +2779,20 @@ var RpcStorageApi = class {
|
|
|
2858
2779
|
}
|
|
2859
2780
|
return this.rpcClient.call(this.methodIds.getAllItems);
|
|
2860
2781
|
}
|
|
2782
|
+
async getAllData() {
|
|
2783
|
+
const result = {};
|
|
2784
|
+
const len = await this.length();
|
|
2785
|
+
for (let i = 0; i < len; i++) {
|
|
2786
|
+
const key = await this.key(i);
|
|
2787
|
+
if (key !== null) {
|
|
2788
|
+
const value = await this.getItem(key);
|
|
2789
|
+
if (value !== null) {
|
|
2790
|
+
result[key] = value;
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
return result;
|
|
2795
|
+
}
|
|
2861
2796
|
setMultipleItems(items) {
|
|
2862
2797
|
if (!this.methodIds.setMultipleItems) {
|
|
2863
2798
|
throw new Error("Method not implemented");
|
|
@@ -2875,364 +2810,6 @@ function initializeStorage(venusApiInstance, host) {
|
|
|
2875
2810
|
venusApiInstance.globalStorage = host.globalStorage;
|
|
2876
2811
|
}
|
|
2877
2812
|
|
|
2878
|
-
// src/simulation/RpcSimulationApi.ts
|
|
2879
|
-
var RpcSimulationApi = class {
|
|
2880
|
-
rpcClient;
|
|
2881
|
-
_simulationConfig = null;
|
|
2882
|
-
subscriptionCallbacks = /* @__PURE__ */ new Map();
|
|
2883
|
-
constructor(rpcClient) {
|
|
2884
|
-
this.rpcClient = rpcClient;
|
|
2885
|
-
this.rpcClient.onNotification(
|
|
2886
|
-
"H5_SIMULATION_UPDATE" /* H5_SIMULATION_UPDATE */,
|
|
2887
|
-
this.handleSimulationUpdate.bind(this)
|
|
2888
|
-
);
|
|
2889
|
-
}
|
|
2890
|
-
isEnabled() {
|
|
2891
|
-
return true;
|
|
2892
|
-
}
|
|
2893
|
-
async validateSlotAssignmentAsync(containerId, slotId, itemId) {
|
|
2894
|
-
return this.rpcClient.call(
|
|
2895
|
-
"H5_SIMULATION_VALIDATE_ASSIGNMENT" /* H5_SIMULATION_VALIDATE_ASSIGNMENT */,
|
|
2896
|
-
{
|
|
2897
|
-
containerId,
|
|
2898
|
-
slotId,
|
|
2899
|
-
itemId
|
|
2900
|
-
}
|
|
2901
|
-
);
|
|
2902
|
-
}
|
|
2903
|
-
async subscribeAsync(options) {
|
|
2904
|
-
this.ensureValidSubscribeOptions(options);
|
|
2905
|
-
const subscriptionId = generateId();
|
|
2906
|
-
this.subscriptionCallbacks.set(subscriptionId, options.onUpdate);
|
|
2907
|
-
try {
|
|
2908
|
-
await this.rpcClient.call("H5_SIMULATION_SUBSCRIBE" /* H5_SIMULATION_SUBSCRIBE */, {
|
|
2909
|
-
subscriptionId,
|
|
2910
|
-
entities: options.entities,
|
|
2911
|
-
tags: options.tags,
|
|
2912
|
-
activeRuns: options.activeRuns,
|
|
2913
|
-
roomId: options.roomId
|
|
2914
|
-
});
|
|
2915
|
-
} catch (error) {
|
|
2916
|
-
this.subscriptionCallbacks.delete(subscriptionId);
|
|
2917
|
-
throw error;
|
|
2918
|
-
}
|
|
2919
|
-
let unsubscribed = false;
|
|
2920
|
-
return () => {
|
|
2921
|
-
if (unsubscribed) {
|
|
2922
|
-
return;
|
|
2923
|
-
}
|
|
2924
|
-
unsubscribed = true;
|
|
2925
|
-
this.subscriptionCallbacks.delete(subscriptionId);
|
|
2926
|
-
void this.rpcClient.call("H5_SIMULATION_UNSUBSCRIBE" /* H5_SIMULATION_UNSUBSCRIBE */, {
|
|
2927
|
-
subscriptionId
|
|
2928
|
-
}).catch((error) => {
|
|
2929
|
-
console.error(
|
|
2930
|
-
"[Venus SDK] Failed to unsubscribe simulation listener",
|
|
2931
|
-
error
|
|
2932
|
-
);
|
|
2933
|
-
});
|
|
2934
|
-
};
|
|
2935
|
-
}
|
|
2936
|
-
executeBatchOperationsAsync(operations, validateOnly) {
|
|
2937
|
-
return this.rpcClient.call(
|
|
2938
|
-
"H5_SIMULATION_BATCH_OPERATIONS" /* H5_SIMULATION_BATCH_OPERATIONS */,
|
|
2939
|
-
{
|
|
2940
|
-
operations,
|
|
2941
|
-
validateOnly
|
|
2942
|
-
}
|
|
2943
|
-
);
|
|
2944
|
-
}
|
|
2945
|
-
async getAvailableItemsAsync(containerId, slotId) {
|
|
2946
|
-
const response = await this.rpcClient.call(
|
|
2947
|
-
"H5_SIMULATION_GET_AVAILABLE_ITEMS" /* H5_SIMULATION_GET_AVAILABLE_ITEMS */,
|
|
2948
|
-
{
|
|
2949
|
-
containerId,
|
|
2950
|
-
slotId
|
|
2951
|
-
}
|
|
2952
|
-
);
|
|
2953
|
-
return response.availableItems || [];
|
|
2954
|
-
}
|
|
2955
|
-
calculatePowerPreviewAsync(containerId, slotId, candidateItemId) {
|
|
2956
|
-
return this.rpcClient.call(
|
|
2957
|
-
"H5_SIMULATION_CALCULATE_POWER_PREVIEW" /* H5_SIMULATION_CALCULATE_POWER_PREVIEW */,
|
|
2958
|
-
{
|
|
2959
|
-
containerId,
|
|
2960
|
-
slotId,
|
|
2961
|
-
candidateItemId
|
|
2962
|
-
}
|
|
2963
|
-
);
|
|
2964
|
-
}
|
|
2965
|
-
assignItemToSlotAsync(containerId, slotId, itemId) {
|
|
2966
|
-
return this.rpcClient.call(
|
|
2967
|
-
"H5_SIMULATION_ASSIGN_ITEM" /* H5_SIMULATION_ASSIGN_ITEM */,
|
|
2968
|
-
{
|
|
2969
|
-
containerId,
|
|
2970
|
-
slotId,
|
|
2971
|
-
itemId
|
|
2972
|
-
}
|
|
2973
|
-
);
|
|
2974
|
-
}
|
|
2975
|
-
removeItemFromSlotAsync(containerId, slotId) {
|
|
2976
|
-
return this.rpcClient.call(
|
|
2977
|
-
"H5_SIMULATION_REMOVE_ITEM" /* H5_SIMULATION_REMOVE_ITEM */,
|
|
2978
|
-
{
|
|
2979
|
-
containerId,
|
|
2980
|
-
slotId
|
|
2981
|
-
}
|
|
2982
|
-
);
|
|
2983
|
-
}
|
|
2984
|
-
async getSlotContainersAsync() {
|
|
2985
|
-
const response = await this.rpcClient.call(
|
|
2986
|
-
"H5_SIMULATION_GET_CONTAINERS" /* H5_SIMULATION_GET_CONTAINERS */,
|
|
2987
|
-
{}
|
|
2988
|
-
);
|
|
2989
|
-
return response.containers || [];
|
|
2990
|
-
}
|
|
2991
|
-
async getSlotAssignmentsAsync(containerId) {
|
|
2992
|
-
const response = await this.rpcClient.call(
|
|
2993
|
-
"H5_SIMULATION_GET_ASSIGNMENTS" /* H5_SIMULATION_GET_ASSIGNMENTS */,
|
|
2994
|
-
{
|
|
2995
|
-
containerId
|
|
2996
|
-
}
|
|
2997
|
-
);
|
|
2998
|
-
return Array.isArray(response) ? response : response.assignments || [];
|
|
2999
|
-
}
|
|
3000
|
-
async getStateAsync(roomId) {
|
|
3001
|
-
const response = await this.rpcClient.call(
|
|
3002
|
-
"H5_SIMULATION_GET_STATE" /* H5_SIMULATION_GET_STATE */,
|
|
3003
|
-
{
|
|
3004
|
-
roomId
|
|
3005
|
-
}
|
|
3006
|
-
);
|
|
3007
|
-
if (response.configuration) {
|
|
3008
|
-
this._simulationConfig = response.configuration;
|
|
3009
|
-
}
|
|
3010
|
-
return response;
|
|
3011
|
-
}
|
|
3012
|
-
async getConfigAsync(roomId) {
|
|
3013
|
-
if (this._simulationConfig) {
|
|
3014
|
-
return this._simulationConfig;
|
|
3015
|
-
}
|
|
3016
|
-
const config = await this.rpcClient.call(
|
|
3017
|
-
"H5_SIMULATION_GET_CONFIG" /* H5_SIMULATION_GET_CONFIG */,
|
|
3018
|
-
{
|
|
3019
|
-
roomId
|
|
3020
|
-
}
|
|
3021
|
-
);
|
|
3022
|
-
if (config) {
|
|
3023
|
-
this._simulationConfig = config;
|
|
3024
|
-
return config;
|
|
3025
|
-
}
|
|
3026
|
-
throw new Error("No simulation configuration available");
|
|
3027
|
-
}
|
|
3028
|
-
executeRecipeAsync(recipeId, inputs, options) {
|
|
3029
|
-
return this.rpcClient.call(
|
|
3030
|
-
"H5_SIMULATION_EXECUTE_RECIPE" /* H5_SIMULATION_EXECUTE_RECIPE */,
|
|
3031
|
-
{
|
|
3032
|
-
recipeId,
|
|
3033
|
-
inputs,
|
|
3034
|
-
roomId: options?.roomId,
|
|
3035
|
-
batchAmount: options?.batchAmount,
|
|
3036
|
-
allowPartialBatch: options?.allowPartialBatch,
|
|
3037
|
-
entity: options?.entity
|
|
3038
|
-
}
|
|
3039
|
-
);
|
|
3040
|
-
}
|
|
3041
|
-
collectRecipeAsync(runId) {
|
|
3042
|
-
return this.rpcClient.call("H5_SIMULATION_COLLECT_RECIPE" /* H5_SIMULATION_COLLECT_RECIPE */, {
|
|
3043
|
-
runId
|
|
3044
|
-
});
|
|
3045
|
-
}
|
|
3046
|
-
getActiveRunsAsync(options) {
|
|
3047
|
-
return this.rpcClient.call(
|
|
3048
|
-
"H5_SIMULATION_GET_ACTIVE_RUNS" /* H5_SIMULATION_GET_ACTIVE_RUNS */,
|
|
3049
|
-
{
|
|
3050
|
-
roomId: options?.roomId
|
|
3051
|
-
}
|
|
3052
|
-
);
|
|
3053
|
-
}
|
|
3054
|
-
executeScopedRecipeAsync(recipeId, entity, inputs, options) {
|
|
3055
|
-
return this.rpcClient.call(
|
|
3056
|
-
"H5_SIMULATION_EXECUTE_SCOPED_RECIPE" /* H5_SIMULATION_EXECUTE_SCOPED_RECIPE */,
|
|
3057
|
-
{
|
|
3058
|
-
recipeId,
|
|
3059
|
-
entity,
|
|
3060
|
-
inputs,
|
|
3061
|
-
roomId: options?.roomId ?? null,
|
|
3062
|
-
options
|
|
3063
|
-
}
|
|
3064
|
-
);
|
|
3065
|
-
}
|
|
3066
|
-
getAvailableRecipesAsync(options) {
|
|
3067
|
-
return this.rpcClient.call(
|
|
3068
|
-
"H5_SIMULATION_GET_AVAILABLE_RECIPES" /* H5_SIMULATION_GET_AVAILABLE_RECIPES */,
|
|
3069
|
-
{
|
|
3070
|
-
roomId: options?.roomId || null,
|
|
3071
|
-
includeActorRecipes: options?.includeActorRecipes || false
|
|
3072
|
-
}
|
|
3073
|
-
);
|
|
3074
|
-
}
|
|
3075
|
-
getRecipeRequirementsAsync(recipe) {
|
|
3076
|
-
return this.rpcClient.call(
|
|
3077
|
-
"H5_SIMULATION_GET_RECIPE_REQUIREMENTS" /* H5_SIMULATION_GET_RECIPE_REQUIREMENTS */,
|
|
3078
|
-
{
|
|
3079
|
-
recipeId: recipe.recipeId,
|
|
3080
|
-
entity: recipe.entity,
|
|
3081
|
-
batchAmount: recipe.batchAmount
|
|
3082
|
-
}
|
|
3083
|
-
);
|
|
3084
|
-
}
|
|
3085
|
-
getBatchRecipeRequirementsAsync(recipes) {
|
|
3086
|
-
return this.rpcClient.call(
|
|
3087
|
-
"H5_SIMULATION_GET_BATCH_RECIPE_REQUIREMENTS" /* H5_SIMULATION_GET_BATCH_RECIPE_REQUIREMENTS */,
|
|
3088
|
-
{
|
|
3089
|
-
recipes
|
|
3090
|
-
}
|
|
3091
|
-
);
|
|
3092
|
-
}
|
|
3093
|
-
triggerRecipeChainAsync(recipeId, options) {
|
|
3094
|
-
return this.rpcClient.call(
|
|
3095
|
-
"H5_SIMULATION_TRIGGER_RECIPE_CHAIN" /* H5_SIMULATION_TRIGGER_RECIPE_CHAIN */,
|
|
3096
|
-
{
|
|
3097
|
-
triggerRecipeId: recipeId,
|
|
3098
|
-
context: options?.context,
|
|
3099
|
-
roomId: options?.roomId
|
|
3100
|
-
}
|
|
3101
|
-
);
|
|
3102
|
-
}
|
|
3103
|
-
getEntityMetadataAsync(entityId) {
|
|
3104
|
-
return this.rpcClient.call(
|
|
3105
|
-
"H5_SIMULATION_GET_ENTITY_METADATA" /* H5_SIMULATION_GET_ENTITY_METADATA */,
|
|
3106
|
-
{
|
|
3107
|
-
entityId
|
|
3108
|
-
}
|
|
3109
|
-
);
|
|
3110
|
-
}
|
|
3111
|
-
async resolveFieldValueAsync(entityId, fieldPath, entity) {
|
|
3112
|
-
const response = await this.rpcClient.call(
|
|
3113
|
-
"H5_SIMULATION_RESOLVE_VALUE" /* H5_SIMULATION_RESOLVE_VALUE */,
|
|
3114
|
-
{
|
|
3115
|
-
entityId,
|
|
3116
|
-
fieldPath,
|
|
3117
|
-
entity
|
|
3118
|
-
}
|
|
3119
|
-
);
|
|
3120
|
-
return response.value;
|
|
3121
|
-
}
|
|
3122
|
-
handleSimulationUpdate(notification) {
|
|
3123
|
-
if (!notification || !notification.subscriptionId) {
|
|
3124
|
-
console.warn("[Venus SDK] Received malformed simulation update");
|
|
3125
|
-
return;
|
|
3126
|
-
}
|
|
3127
|
-
const callback = this.subscriptionCallbacks.get(notification.subscriptionId);
|
|
3128
|
-
if (!callback) {
|
|
3129
|
-
console.warn(
|
|
3130
|
-
"[Venus SDK] Received update for unknown subscription:",
|
|
3131
|
-
notification.subscriptionId
|
|
3132
|
-
);
|
|
3133
|
-
return;
|
|
3134
|
-
}
|
|
3135
|
-
try {
|
|
3136
|
-
callback(notification.updates);
|
|
3137
|
-
} catch (error) {
|
|
3138
|
-
console.error("[Venus SDK] Error in simulation subscription callback", error);
|
|
3139
|
-
}
|
|
3140
|
-
}
|
|
3141
|
-
ensureValidSubscribeOptions(options) {
|
|
3142
|
-
if (typeof options !== "object" || options === null) {
|
|
3143
|
-
throw new Error("Simulation subscribe requires an options object");
|
|
3144
|
-
}
|
|
3145
|
-
const opts = options;
|
|
3146
|
-
if (typeof opts.onUpdate !== "function") {
|
|
3147
|
-
throw new Error("Simulation subscribe requires an onUpdate callback");
|
|
3148
|
-
}
|
|
3149
|
-
const hasFilter = Array.isArray(opts.entities) && opts.entities.length > 0 || Array.isArray(opts.tags) && opts.tags.length > 0 || Boolean(opts.activeRuns);
|
|
3150
|
-
if (!hasFilter) {
|
|
3151
|
-
throw new Error(
|
|
3152
|
-
"Simulation subscribe requires at least one filter (entities, tags, activeRuns)"
|
|
3153
|
-
);
|
|
3154
|
-
}
|
|
3155
|
-
}
|
|
3156
|
-
};
|
|
3157
|
-
|
|
3158
|
-
// src/simulation/index.ts
|
|
3159
|
-
function initializeSimulation(venusApi, host) {
|
|
3160
|
-
venusApi.simulation = {
|
|
3161
|
-
isEnabled: () => true
|
|
3162
|
-
};
|
|
3163
|
-
venusApi.simulation.getConfigAsync = () => {
|
|
3164
|
-
return host.simulation.getConfigAsync();
|
|
3165
|
-
};
|
|
3166
|
-
venusApi.simulation.getStateAsync = (roomId) => {
|
|
3167
|
-
return host.simulation.getStateAsync(roomId);
|
|
3168
|
-
};
|
|
3169
|
-
venusApi.simulation.executeRecipeAsync = (recipeId, inputs, options) => {
|
|
3170
|
-
return host.simulation.executeRecipeAsync(recipeId, inputs, options);
|
|
3171
|
-
};
|
|
3172
|
-
venusApi.simulation.getActiveRunsAsync = () => {
|
|
3173
|
-
return host.simulation.getActiveRunsAsync();
|
|
3174
|
-
};
|
|
3175
|
-
venusApi.simulation.collectRecipeAsync = (runId) => {
|
|
3176
|
-
return host.simulation.collectRecipeAsync(runId);
|
|
3177
|
-
};
|
|
3178
|
-
venusApi.simulation.executeScopedRecipeAsync = (recipeId, entity, inputs, options) => {
|
|
3179
|
-
return host.simulation.executeScopedRecipeAsync(recipeId, entity, inputs, options);
|
|
3180
|
-
};
|
|
3181
|
-
venusApi.simulation.triggerRecipeChainAsync = (recipeId, options) => {
|
|
3182
|
-
return host.simulation.triggerRecipeChainAsync(recipeId, options);
|
|
3183
|
-
};
|
|
3184
|
-
venusApi.simulation.getAvailableRecipesAsync = async (options) => {
|
|
3185
|
-
return host.simulation.getAvailableRecipesAsync(options);
|
|
3186
|
-
};
|
|
3187
|
-
venusApi.simulation.getRecipeRequirementsAsync = (recipe) => {
|
|
3188
|
-
return host.simulation.getRecipeRequirementsAsync(recipe);
|
|
3189
|
-
};
|
|
3190
|
-
venusApi.simulation.getBatchRecipeRequirementsAsync = (recipes) => {
|
|
3191
|
-
return host.simulation.getBatchRecipeRequirementsAsync(recipes);
|
|
3192
|
-
};
|
|
3193
|
-
venusApi.simulation.resolveFieldValueAsync = (entityId, fieldPath, entity) => {
|
|
3194
|
-
return host.simulation.resolveFieldValueAsync(entityId, fieldPath, entity);
|
|
3195
|
-
};
|
|
3196
|
-
venusApi.simulation.getEntityMetadataAsync = (entityId) => {
|
|
3197
|
-
return host.simulation.getEntityMetadataAsync(entityId);
|
|
3198
|
-
};
|
|
3199
|
-
venusApi.simulation.getSlotAssignmentsAsync = (containerId) => {
|
|
3200
|
-
return host.simulation.getSlotAssignmentsAsync(containerId);
|
|
3201
|
-
};
|
|
3202
|
-
venusApi.simulation.getSlotContainersAsync = () => {
|
|
3203
|
-
return host.simulation.getSlotContainersAsync();
|
|
3204
|
-
};
|
|
3205
|
-
venusApi.simulation.assignItemToSlotAsync = (containerId, slotId, itemId) => {
|
|
3206
|
-
return host.simulation.assignItemToSlotAsync(containerId, slotId, itemId);
|
|
3207
|
-
};
|
|
3208
|
-
venusApi.simulation.removeItemFromSlotAsync = (containerId, slotId) => {
|
|
3209
|
-
return host.simulation.removeItemFromSlotAsync(containerId, slotId);
|
|
3210
|
-
};
|
|
3211
|
-
venusApi.simulation.getAvailableItemsAsync = (containerId, slotId) => {
|
|
3212
|
-
return host.simulation.getAvailableItemsAsync(containerId, slotId);
|
|
3213
|
-
};
|
|
3214
|
-
venusApi.simulation.calculatePowerPreviewAsync = (containerId, slotId, candidateItemId) => {
|
|
3215
|
-
return host.simulation.calculatePowerPreviewAsync(
|
|
3216
|
-
containerId,
|
|
3217
|
-
slotId,
|
|
3218
|
-
candidateItemId
|
|
3219
|
-
);
|
|
3220
|
-
};
|
|
3221
|
-
venusApi.simulation.executeBatchOperationsAsync = (operations, validateOnly) => {
|
|
3222
|
-
return host.simulation.executeBatchOperationsAsync(operations, validateOnly);
|
|
3223
|
-
};
|
|
3224
|
-
venusApi.simulation.validateSlotAssignmentAsync = (containerId, slotId, itemId) => {
|
|
3225
|
-
return host.simulation.validateSlotAssignmentAsync(
|
|
3226
|
-
containerId,
|
|
3227
|
-
slotId,
|
|
3228
|
-
itemId
|
|
3229
|
-
);
|
|
3230
|
-
};
|
|
3231
|
-
venusApi.simulation.subscribeAsync = (options) => {
|
|
3232
|
-
return host.simulation.subscribeAsync(options);
|
|
3233
|
-
};
|
|
3234
|
-
}
|
|
3235
|
-
|
|
3236
2813
|
// src/time/utils.ts
|
|
3237
2814
|
function isPacificDaylightTime(date) {
|
|
3238
2815
|
const year = date.getFullYear();
|
|
@@ -3436,9 +3013,6 @@ function initializeTime(venusApi, host) {
|
|
|
3436
3013
|
};
|
|
3437
3014
|
}
|
|
3438
3015
|
|
|
3439
|
-
// src/version.ts
|
|
3440
|
-
var SDK_VERSION = "3.4.2";
|
|
3441
|
-
|
|
3442
3016
|
// src/shared-assets/base64Utils.ts
|
|
3443
3017
|
function base64ToArrayBuffer(base64) {
|
|
3444
3018
|
const binaryString = atob(base64);
|
|
@@ -3645,377 +3219,6 @@ function getLibraryDefinition(libraryKey) {
|
|
|
3645
3219
|
return definition;
|
|
3646
3220
|
}
|
|
3647
3221
|
|
|
3648
|
-
// src/leaderboard/utils.ts
|
|
3649
|
-
var HASH_ALGORITHM_WEB_CRYPTO = "SHA-256";
|
|
3650
|
-
var HASH_ALGORITHM_NODE = "sha256";
|
|
3651
|
-
async function computeScoreHash(score, duration, token, sealingNonce, sealingSecret) {
|
|
3652
|
-
const payload = `score:${score}|duration:${duration}|token:${token}`;
|
|
3653
|
-
const fullPayload = `${payload}|nonce:${sealingNonce}`;
|
|
3654
|
-
const encoder = new TextEncoder();
|
|
3655
|
-
const keyData = encoder.encode(sealingSecret);
|
|
3656
|
-
const messageData = encoder.encode(fullPayload);
|
|
3657
|
-
const cryptoKey = await crypto.subtle.importKey(
|
|
3658
|
-
"raw",
|
|
3659
|
-
keyData,
|
|
3660
|
-
{ name: "HMAC", hash: HASH_ALGORITHM_WEB_CRYPTO },
|
|
3661
|
-
false,
|
|
3662
|
-
["sign"]
|
|
3663
|
-
);
|
|
3664
|
-
const signature = await crypto.subtle.sign("HMAC", cryptoKey, messageData);
|
|
3665
|
-
return Array.from(new Uint8Array(signature)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
3666
|
-
}
|
|
3667
|
-
|
|
3668
|
-
// src/leaderboard/RpcLeaderboardApi.ts
|
|
3669
|
-
var RpcLeaderboardApi = class {
|
|
3670
|
-
rpcClient;
|
|
3671
|
-
/** Cache of score tokens for automatic hash computation */
|
|
3672
|
-
tokenCache = /* @__PURE__ */ new Map();
|
|
3673
|
-
constructor(rpcClient) {
|
|
3674
|
-
this.rpcClient = rpcClient;
|
|
3675
|
-
}
|
|
3676
|
-
/**
|
|
3677
|
-
* Create a score token for submitting a score.
|
|
3678
|
-
* Token is cached for automatic hash computation if score sealing is enabled.
|
|
3679
|
-
*
|
|
3680
|
-
* @param mode - Optional game mode
|
|
3681
|
-
* @returns Score token with sealing data if enabled
|
|
3682
|
-
*/
|
|
3683
|
-
async createScoreToken(mode) {
|
|
3684
|
-
const token = await this.rpcClient.call(
|
|
3685
|
-
"H5_LEADERBOARD_CREATE_SCORE_TOKEN" /* H5_LEADERBOARD_CREATE_SCORE_TOKEN */,
|
|
3686
|
-
mode ? { mode } : {}
|
|
3687
|
-
);
|
|
3688
|
-
this.tokenCache.set(token.token, token);
|
|
3689
|
-
return token;
|
|
3690
|
-
}
|
|
3691
|
-
/**
|
|
3692
|
-
* Submit a score to the leaderboard.
|
|
3693
|
-
* Automatically computes hash if score sealing is enabled and token was created via createScoreToken().
|
|
3694
|
-
*
|
|
3695
|
-
* @param params - Score submission parameters
|
|
3696
|
-
* @returns Submission result with acceptance status and rank
|
|
3697
|
-
* @throws Error if token not found in cache
|
|
3698
|
-
*/
|
|
3699
|
-
async submitScore(params) {
|
|
3700
|
-
let hash;
|
|
3701
|
-
if (params.token) {
|
|
3702
|
-
const cachedToken = this.tokenCache.get(params.token);
|
|
3703
|
-
if (!cachedToken) {
|
|
3704
|
-
throw new Error(
|
|
3705
|
-
"Invalid token: not found in cache. Did you call createScoreToken() first?"
|
|
3706
|
-
);
|
|
3707
|
-
}
|
|
3708
|
-
if (cachedToken.sealingNonce && cachedToken.sealingSecret) {
|
|
3709
|
-
hash = await computeScoreHash(
|
|
3710
|
-
params.score,
|
|
3711
|
-
params.duration,
|
|
3712
|
-
params.token,
|
|
3713
|
-
cachedToken.sealingNonce,
|
|
3714
|
-
cachedToken.sealingSecret
|
|
3715
|
-
);
|
|
3716
|
-
}
|
|
3717
|
-
this.tokenCache.delete(params.token);
|
|
3718
|
-
}
|
|
3719
|
-
return this.rpcClient.call(
|
|
3720
|
-
"H5_LEADERBOARD_SUBMIT_SCORE" /* H5_LEADERBOARD_SUBMIT_SCORE */,
|
|
3721
|
-
{
|
|
3722
|
-
token: params.token,
|
|
3723
|
-
score: params.score,
|
|
3724
|
-
duration: params.duration,
|
|
3725
|
-
mode: params.mode,
|
|
3726
|
-
telemetry: params.telemetry,
|
|
3727
|
-
metadata: params.metadata,
|
|
3728
|
-
hash
|
|
3729
|
-
// undefined if no sealing, computed if sealing enabled
|
|
3730
|
-
}
|
|
3731
|
-
);
|
|
3732
|
-
}
|
|
3733
|
-
getPagedScores(options) {
|
|
3734
|
-
return this.rpcClient.call(
|
|
3735
|
-
"H5_LEADERBOARD_GET_PAGED_SCORES" /* H5_LEADERBOARD_GET_PAGED_SCORES */,
|
|
3736
|
-
options ?? {}
|
|
3737
|
-
);
|
|
3738
|
-
}
|
|
3739
|
-
getMyRank(options) {
|
|
3740
|
-
return this.rpcClient.call(
|
|
3741
|
-
"H5_LEADERBOARD_GET_MY_RANK" /* H5_LEADERBOARD_GET_MY_RANK */,
|
|
3742
|
-
options ?? {}
|
|
3743
|
-
);
|
|
3744
|
-
}
|
|
3745
|
-
getPodiumScores(options) {
|
|
3746
|
-
return this.rpcClient.call(
|
|
3747
|
-
"H5_LEADERBOARD_GET_PODIUM_SCORES" /* H5_LEADERBOARD_GET_PODIUM_SCORES */,
|
|
3748
|
-
options ?? {}
|
|
3749
|
-
);
|
|
3750
|
-
}
|
|
3751
|
-
};
|
|
3752
|
-
|
|
3753
|
-
// src/leaderboard/MockLeaderboardApi.ts
|
|
3754
|
-
var MockLeaderboardApi = class {
|
|
3755
|
-
tokens = /* @__PURE__ */ new Map();
|
|
3756
|
-
/** Cache of score tokens for automatic hash computation */
|
|
3757
|
-
tokenCache = /* @__PURE__ */ new Map();
|
|
3758
|
-
entriesByMode = /* @__PURE__ */ new Map();
|
|
3759
|
-
tokenCounter = 0;
|
|
3760
|
-
enableScoreSealing = false;
|
|
3761
|
-
scoreSealingSecret = "mock-leaderboard-secret-key";
|
|
3762
|
-
constructor(options) {
|
|
3763
|
-
if (options?.enableScoreSealing) {
|
|
3764
|
-
this.enableScoreSealing = true;
|
|
3765
|
-
}
|
|
3766
|
-
if (options?.scoreSealingSecret) {
|
|
3767
|
-
this.scoreSealingSecret = options.scoreSealingSecret;
|
|
3768
|
-
}
|
|
3769
|
-
}
|
|
3770
|
-
/**
|
|
3771
|
-
* Configure mock leaderboard settings
|
|
3772
|
-
*
|
|
3773
|
-
* @param options - Configuration options
|
|
3774
|
-
*/
|
|
3775
|
-
configure(options) {
|
|
3776
|
-
if (typeof options.enableScoreSealing === "boolean") {
|
|
3777
|
-
this.enableScoreSealing = options.enableScoreSealing;
|
|
3778
|
-
}
|
|
3779
|
-
if (options.scoreSealingSecret) {
|
|
3780
|
-
this.scoreSealingSecret = options.scoreSealingSecret;
|
|
3781
|
-
}
|
|
3782
|
-
}
|
|
3783
|
-
generateNonce() {
|
|
3784
|
-
return (Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2)).slice(0, 64);
|
|
3785
|
-
}
|
|
3786
|
-
getModeKey(mode) {
|
|
3787
|
-
const normalizedMode = mode || "default";
|
|
3788
|
-
return `${normalizedMode}`;
|
|
3789
|
-
}
|
|
3790
|
-
getEntriesForMode(mode) {
|
|
3791
|
-
const key = this.getModeKey(mode);
|
|
3792
|
-
if (!this.entriesByMode.has(key)) {
|
|
3793
|
-
this.entriesByMode.set(key, []);
|
|
3794
|
-
}
|
|
3795
|
-
return this.entriesByMode.get(key);
|
|
3796
|
-
}
|
|
3797
|
-
/**
|
|
3798
|
-
* Create a mock score token for testing.
|
|
3799
|
-
* Token is cached for automatic hash computation if score sealing is enabled.
|
|
3800
|
-
*
|
|
3801
|
-
* @param mode - Optional game mode
|
|
3802
|
-
* @returns Score token with sealing data if enabled
|
|
3803
|
-
*/
|
|
3804
|
-
async createScoreToken(mode) {
|
|
3805
|
-
const token = `mock_token_${++this.tokenCounter}`;
|
|
3806
|
-
const startTime = Date.now();
|
|
3807
|
-
const expiresAt = startTime + 36e5;
|
|
3808
|
-
const resolvedMode = mode || "default";
|
|
3809
|
-
const sealingNonce = this.enableScoreSealing ? this.generateNonce() : null;
|
|
3810
|
-
const sealingSecret = this.enableScoreSealing ? this.scoreSealingSecret : null;
|
|
3811
|
-
this.tokens.set(token, {
|
|
3812
|
-
id: token,
|
|
3813
|
-
expiresAt,
|
|
3814
|
-
mode: resolvedMode,
|
|
3815
|
-
sealingNonce,
|
|
3816
|
-
used: false
|
|
3817
|
-
});
|
|
3818
|
-
const result = {
|
|
3819
|
-
token,
|
|
3820
|
-
startTime,
|
|
3821
|
-
expiresAt,
|
|
3822
|
-
sealingNonce,
|
|
3823
|
-
sealingSecret,
|
|
3824
|
-
mode: resolvedMode
|
|
3825
|
-
};
|
|
3826
|
-
this.tokenCache.set(token, result);
|
|
3827
|
-
return result;
|
|
3828
|
-
}
|
|
3829
|
-
/**
|
|
3830
|
-
* Submit a mock score to the leaderboard.
|
|
3831
|
-
* Automatically computes hash if score sealing is enabled and token was created via createScoreToken().
|
|
3832
|
-
*
|
|
3833
|
-
* @param params - Score submission parameters
|
|
3834
|
-
* @returns Submission result with acceptance status and rank
|
|
3835
|
-
* @throws Error if token not found in cache or validation fails
|
|
3836
|
-
*/
|
|
3837
|
-
async submitScore(params) {
|
|
3838
|
-
let hash;
|
|
3839
|
-
if (params.token) {
|
|
3840
|
-
const cachedToken = this.tokenCache.get(params.token);
|
|
3841
|
-
if (!cachedToken) {
|
|
3842
|
-
throw new Error(
|
|
3843
|
-
"Invalid token: not found in cache. Did you call createScoreToken() first?"
|
|
3844
|
-
);
|
|
3845
|
-
}
|
|
3846
|
-
if (cachedToken.sealingNonce && cachedToken.sealingSecret) {
|
|
3847
|
-
hash = await computeScoreHash(
|
|
3848
|
-
params.score,
|
|
3849
|
-
params.duration,
|
|
3850
|
-
params.token,
|
|
3851
|
-
cachedToken.sealingNonce,
|
|
3852
|
-
cachedToken.sealingSecret
|
|
3853
|
-
);
|
|
3854
|
-
}
|
|
3855
|
-
}
|
|
3856
|
-
if (!params.token) {
|
|
3857
|
-
const mode = params.mode || "default";
|
|
3858
|
-
const submittedAt2 = Date.now();
|
|
3859
|
-
const entry2 = {
|
|
3860
|
-
profileId: `mock_profile`,
|
|
3861
|
-
username: "Mock Player",
|
|
3862
|
-
avatarUrl: null,
|
|
3863
|
-
score: params.score,
|
|
3864
|
-
duration: params.duration,
|
|
3865
|
-
submittedAt: submittedAt2,
|
|
3866
|
-
token: "simple-mode",
|
|
3867
|
-
rank: null,
|
|
3868
|
-
zScore: null,
|
|
3869
|
-
isAnomaly: false,
|
|
3870
|
-
trustScore: 50,
|
|
3871
|
-
metadata: params.metadata ?? null,
|
|
3872
|
-
isSeed: false
|
|
3873
|
-
};
|
|
3874
|
-
const modeEntries2 = this.getEntriesForMode(mode);
|
|
3875
|
-
modeEntries2.push(entry2);
|
|
3876
|
-
modeEntries2.sort((a, b) => {
|
|
3877
|
-
if (b.score !== a.score) return b.score - a.score;
|
|
3878
|
-
return a.submittedAt - b.submittedAt;
|
|
3879
|
-
});
|
|
3880
|
-
modeEntries2.forEach((e, index) => {
|
|
3881
|
-
modeEntries2[index] = { ...e, rank: index + 1 };
|
|
3882
|
-
});
|
|
3883
|
-
const inserted2 = modeEntries2.find((e) => e.submittedAt === submittedAt2);
|
|
3884
|
-
return {
|
|
3885
|
-
accepted: true,
|
|
3886
|
-
rank: inserted2?.rank ?? null
|
|
3887
|
-
};
|
|
3888
|
-
}
|
|
3889
|
-
const scoreToken = this.tokens.get(params.token);
|
|
3890
|
-
if (!scoreToken) {
|
|
3891
|
-
throw new Error("Invalid score token");
|
|
3892
|
-
}
|
|
3893
|
-
if (scoreToken.expiresAt < Date.now()) {
|
|
3894
|
-
throw new Error("Invalid or expired score token");
|
|
3895
|
-
}
|
|
3896
|
-
if (scoreToken.used) {
|
|
3897
|
-
throw new Error("Score token already used");
|
|
3898
|
-
}
|
|
3899
|
-
if (params.mode && params.mode !== scoreToken.mode) {
|
|
3900
|
-
throw new Error("Submission mode does not match token mode");
|
|
3901
|
-
}
|
|
3902
|
-
if (scoreToken.sealingNonce && !hash) {
|
|
3903
|
-
throw new Error("Score hash required when score sealing is enabled");
|
|
3904
|
-
}
|
|
3905
|
-
const submittedAt = Date.now();
|
|
3906
|
-
const entry = {
|
|
3907
|
-
profileId: `mock_profile`,
|
|
3908
|
-
username: "Mock Player",
|
|
3909
|
-
avatarUrl: null,
|
|
3910
|
-
score: params.score,
|
|
3911
|
-
duration: params.duration,
|
|
3912
|
-
submittedAt,
|
|
3913
|
-
token: params.token,
|
|
3914
|
-
rank: null,
|
|
3915
|
-
zScore: null,
|
|
3916
|
-
isAnomaly: false,
|
|
3917
|
-
trustScore: 50,
|
|
3918
|
-
metadata: params.metadata ?? null,
|
|
3919
|
-
isSeed: false
|
|
3920
|
-
};
|
|
3921
|
-
const modeEntries = this.getEntriesForMode(scoreToken.mode);
|
|
3922
|
-
modeEntries.push(entry);
|
|
3923
|
-
modeEntries.sort((a, b) => {
|
|
3924
|
-
if (b.score !== a.score) return b.score - a.score;
|
|
3925
|
-
return a.submittedAt - b.submittedAt;
|
|
3926
|
-
});
|
|
3927
|
-
modeEntries.forEach((e, index) => {
|
|
3928
|
-
modeEntries[index] = { ...e, rank: index + 1 };
|
|
3929
|
-
});
|
|
3930
|
-
scoreToken.used = true;
|
|
3931
|
-
scoreToken.sealingNonce = null;
|
|
3932
|
-
this.tokenCache.delete(params.token);
|
|
3933
|
-
const inserted = modeEntries.find((e) => e.token === params.token && e.submittedAt === submittedAt);
|
|
3934
|
-
return {
|
|
3935
|
-
accepted: true,
|
|
3936
|
-
rank: inserted?.rank ?? null
|
|
3937
|
-
};
|
|
3938
|
-
}
|
|
3939
|
-
async getPagedScores(options) {
|
|
3940
|
-
const limit = options?.limit ?? 10;
|
|
3941
|
-
const mode = options?.mode ?? "default";
|
|
3942
|
-
const modeEntries = [...this.getEntriesForMode(mode)];
|
|
3943
|
-
const entries = modeEntries.slice(0, limit).map((entry) => ({
|
|
3944
|
-
...entry
|
|
3945
|
-
}));
|
|
3946
|
-
return {
|
|
3947
|
-
variant: "standard",
|
|
3948
|
-
entries,
|
|
3949
|
-
totalEntries: modeEntries.length,
|
|
3950
|
-
nextCursor: null,
|
|
3951
|
-
playerRank: null,
|
|
3952
|
-
periodInstance: options?.period ?? "alltime"
|
|
3953
|
-
};
|
|
3954
|
-
}
|
|
3955
|
-
async getMyRank(_options) {
|
|
3956
|
-
const mode = _options?.mode ?? "default";
|
|
3957
|
-
const modeEntries = this.getEntriesForMode(mode);
|
|
3958
|
-
const playerEntry = modeEntries[0] ?? null;
|
|
3959
|
-
return {
|
|
3960
|
-
rank: playerEntry?.rank ?? null,
|
|
3961
|
-
score: playerEntry?.score,
|
|
3962
|
-
totalPlayers: modeEntries.length,
|
|
3963
|
-
percentile: playerEntry ? Math.max(0, 1 - ((playerEntry.rank ?? 1) - 1) / Math.max(modeEntries.length, 1)) : void 0,
|
|
3964
|
-
trustScore: 50,
|
|
3965
|
-
periodInstance: _options?.period ?? "alltime"
|
|
3966
|
-
};
|
|
3967
|
-
}
|
|
3968
|
-
async getPodiumScores(options) {
|
|
3969
|
-
const mode = options?.mode ?? "default";
|
|
3970
|
-
const modeEntries = [...this.getEntriesForMode(mode)];
|
|
3971
|
-
const topCount = Math.max(1, Math.min(options?.topCount ?? 3, 10));
|
|
3972
|
-
const aheadCount = Math.max(0, Math.min(options?.contextAhead ?? 4, 10));
|
|
3973
|
-
const behindCount = Math.max(0, Math.min(options?.contextBehind ?? 2, 10));
|
|
3974
|
-
const topEntries = modeEntries.slice(0, topCount);
|
|
3975
|
-
const playerEntry = modeEntries[0] ?? null;
|
|
3976
|
-
const totalEntries = modeEntries.length;
|
|
3977
|
-
let playerRank = playerEntry?.rank ?? null;
|
|
3978
|
-
let beforePlayer = [];
|
|
3979
|
-
let afterPlayer = [];
|
|
3980
|
-
let totalBefore = playerRank ? playerRank - 1 : 0;
|
|
3981
|
-
let totalAfter = playerRank ? Math.max(totalEntries - playerRank, 0) : 0;
|
|
3982
|
-
let omittedBefore = totalBefore;
|
|
3983
|
-
let omittedAfter = totalAfter;
|
|
3984
|
-
if (playerRank && playerRank > 0) {
|
|
3985
|
-
const beforeStart = Math.max(playerRank - aheadCount - 1, 0);
|
|
3986
|
-
beforePlayer = modeEntries.slice(beforeStart, playerRank - 1);
|
|
3987
|
-
const afterEnd = Math.min(playerRank + behindCount, totalEntries);
|
|
3988
|
-
afterPlayer = modeEntries.slice(playerRank, afterEnd);
|
|
3989
|
-
const shownTopAhead = topEntries.filter((entry) => (entry.rank ?? 0) > 0 && (entry.rank ?? 0) < playerRank).length;
|
|
3990
|
-
omittedBefore = Math.max(totalBefore - (beforePlayer.length + shownTopAhead), 0);
|
|
3991
|
-
omittedAfter = Math.max(totalAfter - afterPlayer.length, 0);
|
|
3992
|
-
}
|
|
3993
|
-
return {
|
|
3994
|
-
variant: "highlight",
|
|
3995
|
-
entries: topEntries,
|
|
3996
|
-
totalEntries,
|
|
3997
|
-
nextCursor: null,
|
|
3998
|
-
playerRank: playerRank ?? null,
|
|
3999
|
-
periodInstance: options?.period ?? "alltime",
|
|
4000
|
-
context: {
|
|
4001
|
-
topEntries,
|
|
4002
|
-
beforePlayer,
|
|
4003
|
-
playerEntry: playerEntry ?? null,
|
|
4004
|
-
afterPlayer,
|
|
4005
|
-
totalBefore,
|
|
4006
|
-
totalAfter,
|
|
4007
|
-
omittedBefore,
|
|
4008
|
-
omittedAfter
|
|
4009
|
-
}
|
|
4010
|
-
};
|
|
4011
|
-
}
|
|
4012
|
-
};
|
|
4013
|
-
|
|
4014
|
-
// src/leaderboard/index.ts
|
|
4015
|
-
function initializeLeaderboard(venusApiInstance, host) {
|
|
4016
|
-
venusApiInstance.leaderboard = host.leaderboard;
|
|
4017
|
-
}
|
|
4018
|
-
|
|
4019
3222
|
// src/game-preloader/MockPreloaderApi.ts
|
|
4020
3223
|
var MockPreloaderApi = class {
|
|
4021
3224
|
async showLoadScreen() {
|
|
@@ -4088,1049 +3291,41 @@ var MockSocialApi = class {
|
|
|
4088
3291
|
}
|
|
4089
3292
|
};
|
|
4090
3293
|
|
|
4091
|
-
// src/
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
}
|
|
4096
|
-
async shareLinkAsync(options) {
|
|
4097
|
-
const result = await this.rpcClient.call("H5_SHARE_LINK" /* SHARE_LINK */, {
|
|
4098
|
-
launchParams: options.launchParams,
|
|
4099
|
-
metadata: options.metadata ?? {}
|
|
4100
|
-
});
|
|
4101
|
-
return {
|
|
4102
|
-
shareUrl: result.shareUrl
|
|
4103
|
-
};
|
|
4104
|
-
}
|
|
4105
|
-
async createQRCodeAsync(options) {
|
|
4106
|
-
const result = await this.rpcClient.call(
|
|
4107
|
-
"H5_CREATE_SHARE_QRCODE" /* CREATE_SHARE_QRCODE */,
|
|
4108
|
-
{
|
|
4109
|
-
launchParams: options.launchParams,
|
|
4110
|
-
metadata: options.metadata ?? {},
|
|
4111
|
-
qrOptions: options.qrOptions ?? {}
|
|
4112
|
-
}
|
|
4113
|
-
);
|
|
4114
|
-
return {
|
|
4115
|
-
shareUrl: result.shareUrl,
|
|
4116
|
-
qrCode: result.qrCode
|
|
4117
|
-
};
|
|
4118
|
-
}
|
|
4119
|
-
};
|
|
4120
|
-
|
|
4121
|
-
// src/VenusTransport.ts
|
|
4122
|
-
var VenusTransport = class {
|
|
4123
|
-
messageHandler;
|
|
4124
|
-
onNotificationCallbacks = [];
|
|
4125
|
-
onNotificationCallbacksToRemove = [];
|
|
4126
|
-
onVenusMessageCallbacks = [];
|
|
4127
|
-
onResponseCallbacks = [];
|
|
4128
|
-
onResponseCallbacksToRemove = [];
|
|
4129
|
-
_instanceId = null;
|
|
4130
|
-
isStarted = false;
|
|
4131
|
-
isProcessingMessage = false;
|
|
4132
|
-
constructor() {
|
|
4133
|
-
this.messageHandler = async (event) => {
|
|
4134
|
-
this.isProcessingMessage = true;
|
|
4135
|
-
let message;
|
|
4136
|
-
if (typeof event.data === "string") {
|
|
4137
|
-
message = JSON.parse(event.data);
|
|
4138
|
-
} else {
|
|
4139
|
-
message = event.data;
|
|
4140
|
-
}
|
|
4141
|
-
if (!message) {
|
|
4142
|
-
this.logInfo("No message found. Ignoring message...");
|
|
4143
|
-
return;
|
|
4144
|
-
}
|
|
4145
|
-
this.notifyVenusMessageReceived(message);
|
|
4146
|
-
if (message.type === "PAUSE" /* PAUSE */ || message.type === "RESUME" /* RESUME */ || message.type === "AWAKE" /* AWAKE */ || message.type === "SLEEP" /* SLEEP */ || message.type === "QUIT" /* QUIT */) {
|
|
4147
|
-
const notification = {
|
|
4148
|
-
type: "rpc-notification",
|
|
4149
|
-
id: message.type,
|
|
4150
|
-
payload: message.data
|
|
4151
|
-
};
|
|
4152
|
-
this.handleNotification(notification);
|
|
4153
|
-
this.isProcessingMessage = false;
|
|
4154
|
-
return;
|
|
4155
|
-
}
|
|
4156
|
-
const messageData = message.data;
|
|
4157
|
-
if (!messageData) {
|
|
4158
|
-
this.logWarn("No data found. Ignoring message...");
|
|
4159
|
-
this.isProcessingMessage = false;
|
|
4160
|
-
return;
|
|
4161
|
-
}
|
|
4162
|
-
if (message.type === "H5_SIMULATION_UPDATE" /* H5_SIMULATION_UPDATE */) {
|
|
4163
|
-
const notification = {
|
|
4164
|
-
type: "rpc-notification",
|
|
4165
|
-
id: message.type,
|
|
4166
|
-
payload: message.data
|
|
4167
|
-
};
|
|
4168
|
-
this.handleNotification(notification);
|
|
4169
|
-
this.isProcessingMessage = false;
|
|
4170
|
-
return;
|
|
4171
|
-
}
|
|
4172
|
-
const requestId = messageData.requestId;
|
|
4173
|
-
if (!requestId) {
|
|
4174
|
-
this.logWarn("No requestId. Ignoring message...");
|
|
4175
|
-
this.isProcessingMessage = false;
|
|
4176
|
-
return;
|
|
4177
|
-
}
|
|
4178
|
-
if (message.type !== "H5_RESPONSE" /* H5_RESPONSE */) {
|
|
4179
|
-
this.logWarn(`Ignoring unknown message type: ${message.type}`);
|
|
4180
|
-
this.isProcessingMessage = false;
|
|
4181
|
-
return;
|
|
4182
|
-
}
|
|
4183
|
-
const success = messageData.success;
|
|
4184
|
-
let error = void 0;
|
|
4185
|
-
if (!success) {
|
|
4186
|
-
error = {
|
|
4187
|
-
message: messageData.error || "Unknown error"
|
|
4188
|
-
};
|
|
4189
|
-
}
|
|
4190
|
-
let result = messageData.value;
|
|
4191
|
-
if (result === void 0) {
|
|
4192
|
-
result = messageData.data;
|
|
4193
|
-
}
|
|
4194
|
-
const response = {
|
|
4195
|
-
type: "rpc-response",
|
|
4196
|
-
id: requestId,
|
|
4197
|
-
result,
|
|
4198
|
-
method: message.type,
|
|
4199
|
-
error
|
|
4200
|
-
};
|
|
4201
|
-
await this.handleResponse(response);
|
|
4202
|
-
this.isProcessingMessage = false;
|
|
4203
|
-
};
|
|
4204
|
-
}
|
|
4205
|
-
onNotification(callback) {
|
|
4206
|
-
this.onNotificationCallbacks.push(callback);
|
|
4207
|
-
return {
|
|
4208
|
-
unsubscribe: () => {
|
|
4209
|
-
if (this.isProcessingMessage) {
|
|
4210
|
-
this.onNotificationCallbacks.push(callback);
|
|
4211
|
-
} else {
|
|
4212
|
-
this.removeOnNotificationCallback(callback);
|
|
4213
|
-
}
|
|
4214
|
-
}
|
|
4215
|
-
};
|
|
4216
|
-
}
|
|
4217
|
-
onRequest(callback) {
|
|
4218
|
-
throw new Error("Method not implemented.");
|
|
4219
|
-
}
|
|
4220
|
-
onResponse(callback) {
|
|
4221
|
-
this.onResponseCallbacks.push(callback);
|
|
4222
|
-
return {
|
|
4223
|
-
unsubscribe: () => {
|
|
4224
|
-
if (this.isProcessingMessage) {
|
|
4225
|
-
this.onResponseCallbacksToRemove.push(callback);
|
|
4226
|
-
} else {
|
|
4227
|
-
this.removeOnResponseCallback(callback);
|
|
4228
|
-
}
|
|
4229
|
-
}
|
|
4230
|
-
};
|
|
4231
|
-
}
|
|
4232
|
-
get instanceId() {
|
|
4233
|
-
return this._instanceId;
|
|
4234
|
-
}
|
|
4235
|
-
set instanceId(instanceId) {
|
|
4236
|
-
this._instanceId = instanceId;
|
|
4237
|
-
}
|
|
4238
|
-
sendRequest(request) {
|
|
4239
|
-
const instanceId = this.instanceId || "unknown";
|
|
4240
|
-
const method = request.method;
|
|
4241
|
-
const message = {
|
|
4242
|
-
type: method,
|
|
4243
|
-
direction: "H5_TO_APP",
|
|
4244
|
-
data: {
|
|
4245
|
-
...request.args,
|
|
4246
|
-
requestId: request.id
|
|
4247
|
-
},
|
|
4248
|
-
instanceId,
|
|
4249
|
-
timestamp: Date.now()
|
|
4250
|
-
};
|
|
4251
|
-
this.sendVenusMessage(message);
|
|
4252
|
-
}
|
|
4253
|
-
sendVenusMessage(message) {
|
|
4254
|
-
const messageAsString = JSON.stringify(message, null, 2);
|
|
4255
|
-
const reactNativeWebView = window.ReactNativeWebView;
|
|
4256
|
-
if (reactNativeWebView) {
|
|
4257
|
-
reactNativeWebView.postMessage(messageAsString);
|
|
4258
|
-
} else {
|
|
4259
|
-
window.parent.postMessage(messageAsString, "*");
|
|
4260
|
-
}
|
|
4261
|
-
}
|
|
4262
|
-
sendResponse(response) {
|
|
4263
|
-
throw new Error("Method not implemented.");
|
|
4264
|
-
}
|
|
4265
|
-
start() {
|
|
4266
|
-
if (this.isStarted) {
|
|
4267
|
-
return;
|
|
4268
|
-
}
|
|
4269
|
-
this.isStarted = true;
|
|
4270
|
-
window.addEventListener("message", this.messageHandler, true);
|
|
4271
|
-
this.logInfo(`Started`);
|
|
4272
|
-
}
|
|
4273
|
-
stop() {
|
|
4274
|
-
if (!this.isStarted) {
|
|
4275
|
-
return;
|
|
4276
|
-
}
|
|
4277
|
-
this.isStarted = false;
|
|
4278
|
-
window.removeEventListener("message", this.messageHandler);
|
|
4279
|
-
this.logInfo(`Stopped`);
|
|
4280
|
-
}
|
|
4281
|
-
handleNotification(notification) {
|
|
4282
|
-
for (const callback of this.onNotificationCallbacks) {
|
|
4283
|
-
callback(notification);
|
|
4284
|
-
}
|
|
4285
|
-
for (const callback of this.onNotificationCallbacksToRemove) {
|
|
4286
|
-
this.removeOnNotificationCallback(callback);
|
|
4287
|
-
}
|
|
4288
|
-
this.onNotificationCallbacksToRemove.length = 0;
|
|
4289
|
-
}
|
|
4290
|
-
async handleResponse(response) {
|
|
4291
|
-
for (const callback of this.onResponseCallbacks) {
|
|
4292
|
-
const consumed = await callback(response);
|
|
4293
|
-
if (consumed) {
|
|
4294
|
-
break;
|
|
4295
|
-
}
|
|
4296
|
-
}
|
|
4297
|
-
for (const callback of this.onResponseCallbacksToRemove) {
|
|
4298
|
-
this.removeOnResponseCallback(callback);
|
|
4299
|
-
}
|
|
4300
|
-
this.onResponseCallbacksToRemove.length = 0;
|
|
4301
|
-
}
|
|
4302
|
-
removeOnResponseCallback(callback) {
|
|
4303
|
-
this.onResponseCallbacks.splice(
|
|
4304
|
-
this.onResponseCallbacks.indexOf(callback),
|
|
4305
|
-
1
|
|
4306
|
-
);
|
|
4307
|
-
}
|
|
4308
|
-
removeOnNotificationCallback(callback) {
|
|
4309
|
-
this.onNotificationCallbacks.splice(
|
|
4310
|
-
this.onNotificationCallbacks.indexOf(callback),
|
|
4311
|
-
1
|
|
4312
|
-
);
|
|
4313
|
-
}
|
|
4314
|
-
logInfo(message, ...params) {
|
|
4315
|
-
console.log(`[Venus Transport] ${message}`, ...params);
|
|
4316
|
-
}
|
|
4317
|
-
logWarn(message, ...params) {
|
|
4318
|
-
console.warn(`[Venus Transport] ${message}`, ...params);
|
|
4319
|
-
}
|
|
4320
|
-
onVenusMessage(callback) {
|
|
4321
|
-
this.onVenusMessageCallbacks.push(callback);
|
|
4322
|
-
return {
|
|
4323
|
-
unsubscribe: () => {
|
|
4324
|
-
this.onVenusMessageCallbacks.splice(
|
|
4325
|
-
this.onVenusMessageCallbacks.indexOf(callback),
|
|
4326
|
-
1
|
|
4327
|
-
);
|
|
4328
|
-
}
|
|
4329
|
-
};
|
|
4330
|
-
}
|
|
4331
|
-
notifyVenusMessageReceived(message) {
|
|
4332
|
-
for (const callback of this.onVenusMessageCallbacks) {
|
|
4333
|
-
callback(message);
|
|
4334
|
-
}
|
|
4335
|
-
}
|
|
4336
|
-
};
|
|
4337
|
-
|
|
4338
|
-
// src/RemoteHost.ts
|
|
4339
|
-
var getCdnBaseUrl = () => {
|
|
4340
|
-
return "https://venus-static-01293ak.web.app/";
|
|
4341
|
-
};
|
|
4342
|
-
var RemoteHost = class {
|
|
4343
|
-
ads;
|
|
4344
|
-
analytics;
|
|
4345
|
-
deviceCache;
|
|
4346
|
-
appStorage;
|
|
4347
|
-
globalStorage;
|
|
4348
|
-
avatar3d;
|
|
4349
|
-
navigation;
|
|
4350
|
-
notifications;
|
|
4351
|
-
popups;
|
|
4352
|
-
profile;
|
|
4353
|
-
system;
|
|
4354
|
-
cdn;
|
|
4355
|
-
time;
|
|
4356
|
-
ai;
|
|
4357
|
-
haptics;
|
|
4358
|
-
features;
|
|
4359
|
-
lifecycle;
|
|
4360
|
-
simulation;
|
|
4361
|
-
rooms;
|
|
4362
|
-
logging;
|
|
4363
|
-
iap;
|
|
4364
|
-
leaderboard;
|
|
4365
|
-
preloader;
|
|
4366
|
-
social;
|
|
4367
|
-
context;
|
|
4368
|
-
get isInitialized() {
|
|
4369
|
-
return this._isInitialized;
|
|
4370
|
-
}
|
|
4371
|
-
venusApi;
|
|
4372
|
-
rpcClient;
|
|
4373
|
-
_isInitialized = false;
|
|
4374
|
-
constructor(venusApi) {
|
|
4375
|
-
this.venusApi = venusApi;
|
|
4376
|
-
const rpcClient = new RpcClient();
|
|
4377
|
-
this.rpcClient = rpcClient;
|
|
4378
|
-
this.ads = new RpcAdsApi(rpcClient);
|
|
4379
|
-
this.analytics = new RpcAnalyticsApi(rpcClient);
|
|
4380
|
-
this.deviceCache = new RpcStorageApi(rpcClient, {
|
|
4381
|
-
clear: "H5_DEVICE_CACHE_CLEAR" /* DEVICE_CACHE_CLEAR */,
|
|
4382
|
-
getItem: "H5_DEVICE_CACHE_GET_ITEM" /* DEVICE_CACHE_GET_ITEM */,
|
|
4383
|
-
getKey: "H5_DEVICE_CACHE_KEY" /* DEVICE_CACHE_KEY */,
|
|
4384
|
-
length: "H5_DEVICE_CACHE_LENGTH" /* DEVICE_CACHE_LENGTH */,
|
|
4385
|
-
removeItem: "H5_DEVICE_CACHE_REMOVE_ITEM" /* DEVICE_CACHE_REMOVE_ITEM */,
|
|
4386
|
-
setItem: "H5_DEVICE_CACHE_SET_ITEM" /* DEVICE_CACHE_SET_ITEM */
|
|
4387
|
-
});
|
|
4388
|
-
this.appStorage = new RpcStorageApi(rpcClient, {
|
|
4389
|
-
clear: "H5_APP_STORAGE_CLEAR" /* APP_STORAGE_CLEAR */,
|
|
4390
|
-
getItem: "H5_APP_STORAGE_GET_ITEM" /* APP_STORAGE_GET_ITEM */,
|
|
4391
|
-
getKey: "H5_APP_STORAGE_KEY" /* APP_STORAGE_KEY */,
|
|
4392
|
-
length: "H5_APP_STORAGE_LENGTH" /* APP_STORAGE_LENGTH */,
|
|
4393
|
-
removeItem: "H5_APP_STORAGE_REMOVE_ITEM" /* APP_STORAGE_REMOVE_ITEM */,
|
|
4394
|
-
setItem: "H5_APP_STORAGE_SET_ITEM" /* APP_STORAGE_SET_ITEM */,
|
|
4395
|
-
getAllItems: "H5_APP_STORAGE_GET_ALL_ITEMS" /* APP_STORAGE_GET_ALL_ITEMS */,
|
|
4396
|
-
setMultipleItems: "H5_APP_STORAGE_SET_ITEM" /* APP_STORAGE_SET_ITEM */,
|
|
4397
|
-
removeMultipleItems: "H5_APP_STORAGE_REMOVE_ITEM" /* APP_STORAGE_REMOVE_ITEM */
|
|
4398
|
-
});
|
|
4399
|
-
this.globalStorage = new RpcStorageApi(rpcClient, {
|
|
4400
|
-
clear: "H5_GLOBAL_STORAGE_CLEAR" /* GLOBAL_STORAGE_CLEAR */,
|
|
4401
|
-
getItem: "H5_GLOBAL_STORAGE_GET_ITEM" /* GLOBAL_STORAGE_GET_ITEM */,
|
|
4402
|
-
getKey: "H5_GLOBAL_STORAGE_KEY" /* GLOBAL_STORAGE_KEY */,
|
|
4403
|
-
length: "H5_GLOBAL_STORAGE_LENGTH" /* GLOBAL_STORAGE_LENGTH */,
|
|
4404
|
-
removeItem: "H5_GLOBAL_STORAGE_REMOVE_ITEM" /* GLOBAL_STORAGE_REMOVE_ITEM */,
|
|
4405
|
-
setItem: "H5_GLOBAL_STORAGE_SET_ITEM" /* GLOBAL_STORAGE_SET_ITEM */,
|
|
4406
|
-
getAllItems: "H5_GLOBAL_STORAGE_GET_ALL_ITEMS" /* GLOBAL_STORAGE_GET_ALL_ITEMS */,
|
|
4407
|
-
setMultipleItems: "H5_GLOBAL_STORAGE_SET_MULTIPLE_ITEMS" /* GLOBAL_STORAGE_SET_MULTIPLE_ITEMS */,
|
|
4408
|
-
removeMultipleItems: "H5_GLOBAL_STORAGE_REMOVE_MULTIPLE_ITEMS" /* GLOBAL_STORAGE_REMOVE_MULTIPLE_ITEMS */
|
|
4409
|
-
});
|
|
4410
|
-
this.avatar3d = new RpcAvatarApi(rpcClient, venusApi);
|
|
4411
|
-
this.navigation = new RpcNavigationApi(rpcClient, venusApi);
|
|
4412
|
-
this.notifications = new RpcNotificationsApi(rpcClient);
|
|
4413
|
-
this.popups = new RpcPopupsApi(rpcClient);
|
|
4414
|
-
this.profile = new HostProfileApi(venusApi);
|
|
4415
|
-
const deviceApi = new HostDeviceApi(venusApi);
|
|
4416
|
-
const environmentApi = new HostEnvironmentApi(venusApi);
|
|
4417
|
-
this.system = new HostSystemApi(deviceApi, environmentApi, venusApi);
|
|
4418
|
-
this.cdn = new HostCdnApi(getCdnBaseUrl());
|
|
4419
|
-
this.time = new HostTimeApi(rpcClient, venusApi);
|
|
4420
|
-
this.ai = new RpcAiApi(rpcClient);
|
|
4421
|
-
this.haptics = new RpcHapticsApi(rpcClient);
|
|
4422
|
-
this.features = new RpcFeaturesApi(rpcClient);
|
|
4423
|
-
this.lifecycle = new RpcLifecycleApi(rpcClient);
|
|
4424
|
-
this.simulation = new RpcSimulationApi(rpcClient);
|
|
4425
|
-
this.rooms = new RpcRoomsApi(rpcClient);
|
|
4426
|
-
this.logging = new RpcLoggingApi(this, rpcClient);
|
|
4427
|
-
this.iap = new RpcIapApi(rpcClient);
|
|
4428
|
-
this.leaderboard = new RpcLeaderboardApi(rpcClient);
|
|
4429
|
-
this.preloader = new RpcPreloaderApi(rpcClient);
|
|
4430
|
-
this.social = new RpcSocialApi(rpcClient);
|
|
4431
|
-
venusApi.isMock = () => false;
|
|
4432
|
-
this.venusApi.sharedAssets = new RpcSharedAssetsApi(rpcClient, venusApi);
|
|
4433
|
-
initializeRoomsApi(this.venusApi, this);
|
|
4434
|
-
}
|
|
4435
|
-
async initialize(options) {
|
|
4436
|
-
this.log("Initializing Remote Host...");
|
|
4437
|
-
const transport = new VenusTransport();
|
|
4438
|
-
transport.start();
|
|
4439
|
-
this.rpcClient.start(transport);
|
|
4440
|
-
const roomsApi = this.rooms;
|
|
4441
|
-
roomsApi.setupNotifications(transport);
|
|
4442
|
-
const response = await this.rpcClient.call(
|
|
4443
|
-
"INITIALIZE_SDK" /* INIT_SDK */,
|
|
4444
|
-
{},
|
|
4445
|
-
5e3
|
|
4446
|
-
);
|
|
4447
|
-
transport.instanceId = response.instanceId;
|
|
4448
|
-
this.log(`Remote Host Initialized with id: ${transport.instanceId}`);
|
|
4449
|
-
const profile = response.profile;
|
|
4450
|
-
const sanitizedProfile = {
|
|
4451
|
-
id: profile.id,
|
|
4452
|
-
username: profile.username,
|
|
4453
|
-
avatarUrl: profile.avatarUrl ?? null,
|
|
4454
|
-
isAnonymous: Boolean(profile.isAnonymous)
|
|
4455
|
-
};
|
|
4456
|
-
this.venusApi._profileData = sanitizedProfile;
|
|
4457
|
-
this.venusApi._deviceData = response.device;
|
|
4458
|
-
this.venusApi._environmentData = response.environment;
|
|
4459
|
-
this.venusApi._localeData = response.locale;
|
|
4460
|
-
this.venusApi._languageCodeData = response.languageCode;
|
|
4461
|
-
this._isInitialized = true;
|
|
4462
|
-
this.venusApi.launchParams = response.launchParams;
|
|
4463
|
-
await this.rpcClient.call("READY" /* READY */, {});
|
|
4464
|
-
const safeArea = response.safeArea;
|
|
4465
|
-
if (safeArea) {
|
|
4466
|
-
this.venusApi._safeAreaData = safeArea;
|
|
4467
|
-
}
|
|
4468
|
-
this.context = {
|
|
4469
|
-
safeArea,
|
|
4470
|
-
initializeAsleep: response.initializeAsleep
|
|
4471
|
-
};
|
|
4472
|
-
return this.context;
|
|
3294
|
+
// src/config/sandbox.ts
|
|
3295
|
+
function getSandboxConfig() {
|
|
3296
|
+
if (typeof globalThis === "undefined") {
|
|
3297
|
+
return null;
|
|
4473
3298
|
}
|
|
4474
|
-
|
|
4475
|
-
|
|
3299
|
+
const config = globalThis.__VENUS_SANDBOX__;
|
|
3300
|
+
if (!config?.enabled) {
|
|
3301
|
+
return null;
|
|
4476
3302
|
}
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
// src/MockHost.ts
|
|
4480
|
-
var ROOMS_UNAVAILABLE_MESSAGE = "[Venus SDK] Rooms API is only available when running inside the Venus host environment.";
|
|
4481
|
-
function createUnavailableRoomsApi() {
|
|
4482
|
-
const roomsUnavailableError = () => new Error(ROOMS_UNAVAILABLE_MESSAGE);
|
|
4483
|
-
return {
|
|
4484
|
-
async createRoomAsync() {
|
|
4485
|
-
throw roomsUnavailableError();
|
|
4486
|
-
},
|
|
4487
|
-
async joinOrCreateRoomAsync() {
|
|
4488
|
-
throw roomsUnavailableError();
|
|
4489
|
-
},
|
|
4490
|
-
async joinRoomByCodeAsync() {
|
|
4491
|
-
throw roomsUnavailableError();
|
|
4492
|
-
},
|
|
4493
|
-
async getUserRoomsAsync() {
|
|
4494
|
-
throw roomsUnavailableError();
|
|
4495
|
-
},
|
|
4496
|
-
async subscribeAsync() {
|
|
4497
|
-
throw roomsUnavailableError();
|
|
4498
|
-
},
|
|
4499
|
-
async updateRoomDataAsync() {
|
|
4500
|
-
throw roomsUnavailableError();
|
|
4501
|
-
},
|
|
4502
|
-
async getRoomDataAsync() {
|
|
4503
|
-
throw roomsUnavailableError();
|
|
4504
|
-
},
|
|
4505
|
-
async sendRoomMessageAsync() {
|
|
4506
|
-
throw roomsUnavailableError();
|
|
4507
|
-
},
|
|
4508
|
-
async leaveRoomAsync() {
|
|
4509
|
-
throw roomsUnavailableError();
|
|
4510
|
-
},
|
|
4511
|
-
async startRoomGameAsync() {
|
|
4512
|
-
throw roomsUnavailableError();
|
|
4513
|
-
},
|
|
4514
|
-
async proposeMoveAsync() {
|
|
4515
|
-
throw roomsUnavailableError();
|
|
4516
|
-
},
|
|
4517
|
-
async validateMoveAsync() {
|
|
4518
|
-
throw roomsUnavailableError();
|
|
4519
|
-
}
|
|
4520
|
-
};
|
|
3303
|
+
return config;
|
|
4521
3304
|
}
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
return {
|
|
4526
|
-
isEnabled() {
|
|
4527
|
-
return false;
|
|
4528
|
-
},
|
|
4529
|
-
async getStateAsync() {
|
|
4530
|
-
throw simulationUnavailableError();
|
|
4531
|
-
},
|
|
4532
|
-
async getConfigAsync() {
|
|
4533
|
-
throw simulationUnavailableError();
|
|
4534
|
-
},
|
|
4535
|
-
async executeRecipeAsync() {
|
|
4536
|
-
throw simulationUnavailableError();
|
|
4537
|
-
},
|
|
4538
|
-
async getActiveRunsAsync() {
|
|
4539
|
-
throw simulationUnavailableError();
|
|
4540
|
-
},
|
|
4541
|
-
async collectRecipeAsync() {
|
|
4542
|
-
throw simulationUnavailableError();
|
|
4543
|
-
},
|
|
4544
|
-
async executeScopedRecipeAsync() {
|
|
4545
|
-
throw simulationUnavailableError();
|
|
4546
|
-
},
|
|
4547
|
-
async triggerRecipeChainAsync() {
|
|
4548
|
-
throw simulationUnavailableError();
|
|
4549
|
-
},
|
|
4550
|
-
async getAvailableRecipesAsync() {
|
|
4551
|
-
throw simulationUnavailableError();
|
|
4552
|
-
},
|
|
4553
|
-
async getRecipeRequirementsAsync() {
|
|
4554
|
-
throw simulationUnavailableError();
|
|
4555
|
-
},
|
|
4556
|
-
async getBatchRecipeRequirementsAsync() {
|
|
4557
|
-
throw simulationUnavailableError();
|
|
4558
|
-
},
|
|
4559
|
-
async resolveFieldValueAsync() {
|
|
4560
|
-
throw simulationUnavailableError();
|
|
4561
|
-
},
|
|
4562
|
-
async getEntityMetadataAsync() {
|
|
4563
|
-
throw simulationUnavailableError();
|
|
4564
|
-
},
|
|
4565
|
-
async getSlotContainersAsync() {
|
|
4566
|
-
throw simulationUnavailableError();
|
|
4567
|
-
},
|
|
4568
|
-
async getSlotAssignmentsAsync() {
|
|
4569
|
-
throw simulationUnavailableError();
|
|
4570
|
-
},
|
|
4571
|
-
async assignItemToSlotAsync() {
|
|
4572
|
-
throw simulationUnavailableError();
|
|
4573
|
-
},
|
|
4574
|
-
async removeItemFromSlotAsync() {
|
|
4575
|
-
throw simulationUnavailableError();
|
|
4576
|
-
},
|
|
4577
|
-
async getAvailableItemsAsync() {
|
|
4578
|
-
throw simulationUnavailableError();
|
|
4579
|
-
},
|
|
4580
|
-
async calculatePowerPreviewAsync() {
|
|
4581
|
-
throw simulationUnavailableError();
|
|
4582
|
-
},
|
|
4583
|
-
async validateSlotAssignmentAsync() {
|
|
4584
|
-
throw simulationUnavailableError();
|
|
4585
|
-
},
|
|
4586
|
-
async executeBatchOperationsAsync() {
|
|
4587
|
-
throw simulationUnavailableError();
|
|
4588
|
-
},
|
|
4589
|
-
async subscribeAsync() {
|
|
4590
|
-
throw simulationUnavailableError();
|
|
4591
|
-
}
|
|
4592
|
-
};
|
|
3305
|
+
function isSandboxEnabled() {
|
|
3306
|
+
const config = getSandboxConfig();
|
|
3307
|
+
return config?.enabled === true;
|
|
4593
3308
|
}
|
|
4594
|
-
var
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
appStorage;
|
|
4599
|
-
globalStorage;
|
|
4600
|
-
avatar3d;
|
|
4601
|
-
navigation;
|
|
4602
|
-
notifications;
|
|
4603
|
-
popups;
|
|
4604
|
-
profile;
|
|
4605
|
-
system;
|
|
4606
|
-
cdn;
|
|
4607
|
-
time;
|
|
4608
|
-
ai;
|
|
4609
|
-
haptics;
|
|
4610
|
-
features;
|
|
4611
|
-
lifecycle;
|
|
4612
|
-
simulation;
|
|
4613
|
-
rooms;
|
|
4614
|
-
logging;
|
|
4615
|
-
iap;
|
|
4616
|
-
leaderboard;
|
|
4617
|
-
preloader;
|
|
4618
|
-
social;
|
|
4619
|
-
context;
|
|
4620
|
-
state = 0 /* PLAYING */;
|
|
4621
|
-
get isInitialized() {
|
|
4622
|
-
return this._isInitialized;
|
|
3309
|
+
var VENUS_API_PROXY_PATH = "/__venusapi";
|
|
3310
|
+
function buildFunctionsBaseUrl(config) {
|
|
3311
|
+
if (config.backendUrl) {
|
|
3312
|
+
return config.backendUrl.replace(/\/$/, "");
|
|
4623
3313
|
}
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
_mockLifecyclesApi;
|
|
4628
|
-
_mockAdsApi;
|
|
4629
|
-
constructor(venusApi) {
|
|
4630
|
-
this.venusApi = venusApi;
|
|
4631
|
-
this._overlay = this.createOverlay();
|
|
4632
|
-
this._mockAdsApi = new MockAdsApi(this._overlay);
|
|
4633
|
-
this._mockLifecyclesApi = new MockLifecycleApi();
|
|
4634
|
-
this.ads = this._mockAdsApi;
|
|
4635
|
-
this.analytics = new MockAnalyticsApi();
|
|
4636
|
-
const appUrl = typeof window !== "undefined" ? window.location.href : "";
|
|
4637
|
-
this.deviceCache = createMockStorageApi("deviceCache", appUrl);
|
|
4638
|
-
this.appStorage = createMockStorageApi("appStorage", appUrl);
|
|
4639
|
-
this.globalStorage = createMockStorageApi("globalStorage");
|
|
4640
|
-
this.avatar3d = new MockAvatarApi(venusApi);
|
|
4641
|
-
this.navigation = new MockNavigationApi(venusApi);
|
|
4642
|
-
this.notifications = new MockNotificationsApi(venusApi);
|
|
4643
|
-
this.popups = new MockPopupsApi(this._overlay);
|
|
4644
|
-
this.profile = new MockProfileApi(venusApi);
|
|
4645
|
-
const deviceApi = new MockDeviceApi(venusApi);
|
|
4646
|
-
const environmentApi = new MockEnvironmentApi(venusApi);
|
|
4647
|
-
this.system = new MockSystemApi(deviceApi, environmentApi, venusApi);
|
|
4648
|
-
this.cdn = new MockCdnApi(venusApi);
|
|
4649
|
-
this.time = new MockTimeApi(venusApi);
|
|
4650
|
-
this.ai = new MockAiApi();
|
|
4651
|
-
this.haptics = new MockHapticsApi(venusApi);
|
|
4652
|
-
this.features = new MockFeaturesApi();
|
|
4653
|
-
this.lifecycle = this._mockLifecyclesApi;
|
|
4654
|
-
this.simulation = createUnavailableSimulationApi();
|
|
4655
|
-
this.rooms = createUnavailableRoomsApi();
|
|
4656
|
-
this.logging = new MockLoggingApi();
|
|
4657
|
-
this.iap = new MockIapApi();
|
|
4658
|
-
this.social = new MockSocialApi();
|
|
4659
|
-
this.leaderboard = new MockLeaderboardApi();
|
|
4660
|
-
initializeRoomsApi(this.venusApi, this);
|
|
4661
|
-
this.preloader = new MockPreloaderApi();
|
|
4662
|
-
venusApi.isMock = () => true;
|
|
4663
|
-
this.venusApi.sharedAssets = new MockSharedAssetsApi(this.venusApi);
|
|
4664
|
-
}
|
|
4665
|
-
initialize(options) {
|
|
4666
|
-
this._isInitialized = true;
|
|
4667
|
-
this.venusApi._profileData = this.profile.getCurrentProfile();
|
|
4668
|
-
this.venusApi._deviceData = this.system.getDevice();
|
|
4669
|
-
this.venusApi._environmentData = this.system.getEnvironment();
|
|
4670
|
-
this.venusApi._localeData = this.venusApi._mock?.locale || "en-US";
|
|
4671
|
-
this.venusApi._languageCodeData = this.venusApi._mock?.languageCode || "en";
|
|
4672
|
-
this.context = {
|
|
4673
|
-
initializeAsleep: false,
|
|
4674
|
-
safeArea: this.venusApi._safeAreaData
|
|
4675
|
-
};
|
|
4676
|
-
return Promise.resolve(this.context);
|
|
4677
|
-
}
|
|
4678
|
-
createOverlay() {
|
|
4679
|
-
const overlayContainer = document.createElement("div");
|
|
4680
|
-
overlayContainer.id = "venus-mock-overlay";
|
|
4681
|
-
overlayContainer.style.cssText = `
|
|
4682
|
-
position: fixed;
|
|
4683
|
-
top: 0;
|
|
4684
|
-
left: 0;
|
|
4685
|
-
width: 100%;
|
|
4686
|
-
height: 100%;
|
|
4687
|
-
pointer-events: none;
|
|
4688
|
-
z-index: 10000;
|
|
4689
|
-
`;
|
|
4690
|
-
document.body.appendChild(overlayContainer);
|
|
4691
|
-
const menuButton = this.createOverlayButton(
|
|
4692
|
-
"close",
|
|
4693
|
-
"Menu",
|
|
4694
|
-
{ x: window.innerWidth - 48, y: 16, width: 32, height: 32 },
|
|
4695
|
-
() => {
|
|
4696
|
-
this.handleMenuButtonClicked();
|
|
4697
|
-
},
|
|
4698
|
-
"rgba(59, 130, 246, 0.7)",
|
|
4699
|
-
// Blue background instead of black
|
|
4700
|
-
"#FFFFFF"
|
|
4701
|
-
);
|
|
4702
|
-
overlayContainer.appendChild(menuButton);
|
|
4703
|
-
const adOverlay = this.setupAdOverlay();
|
|
4704
|
-
const actionSheet = this.setupActionSheetOverlay();
|
|
4705
|
-
window.addEventListener("resize", () => {
|
|
4706
|
-
this.updateOverlayLayout();
|
|
4707
|
-
});
|
|
4708
|
-
return {
|
|
4709
|
-
container: overlayContainer,
|
|
4710
|
-
elements: {
|
|
4711
|
-
menuButton
|
|
4712
|
-
},
|
|
4713
|
-
appVisibilityState: "visible",
|
|
4714
|
-
actionSheetOverlay: actionSheet,
|
|
4715
|
-
adOverlay,
|
|
4716
|
-
showAdOverlay: () => {
|
|
4717
|
-
return this.showAdOverlay("REWARDED VIDEO AD");
|
|
4718
|
-
},
|
|
4719
|
-
showActionSheet: (items, options) => {
|
|
4720
|
-
return this.showActionSheetOverlay(items, options);
|
|
4721
|
-
}
|
|
4722
|
-
};
|
|
4723
|
-
}
|
|
4724
|
-
async handleMenuButtonClicked() {
|
|
4725
|
-
if (this.state === 0 /* PLAYING */) {
|
|
4726
|
-
this.triggerLifecycleEvent("PAUSE" /* PAUSE */);
|
|
4727
|
-
this.state = 1 /* PAUSED */;
|
|
4728
|
-
}
|
|
4729
|
-
const actionSheetItems = [];
|
|
4730
|
-
const awakeAction = {
|
|
4731
|
-
label: "\u23F0 Awake",
|
|
4732
|
-
id: "awakeAction"
|
|
4733
|
-
};
|
|
4734
|
-
const sleepAction = {
|
|
4735
|
-
label: "\u{1F4A4} Sleep",
|
|
4736
|
-
id: "sleepAction"
|
|
4737
|
-
};
|
|
4738
|
-
const quitAction = {
|
|
4739
|
-
label: "\u{1F6D1} Quit",
|
|
4740
|
-
id: "quitAction"
|
|
4741
|
-
};
|
|
4742
|
-
const playAction = {
|
|
4743
|
-
label: "\u25B6\uFE0F Play",
|
|
4744
|
-
id: "playAction"
|
|
4745
|
-
};
|
|
4746
|
-
if (this.state === 1 /* PAUSED */) {
|
|
4747
|
-
actionSheetItems.push(sleepAction);
|
|
4748
|
-
} else if (this.state === 2 /* SLEEPING */) {
|
|
4749
|
-
actionSheetItems.push(awakeAction);
|
|
4750
|
-
}
|
|
4751
|
-
if (this.state !== 3 /* TERMINATED */) {
|
|
4752
|
-
actionSheetItems.push(quitAction);
|
|
4753
|
-
} else if (this.state === 3 /* TERMINATED */) {
|
|
4754
|
-
actionSheetItems.push(playAction);
|
|
4755
|
-
}
|
|
4756
|
-
const action = await this.showActionSheetOverlay(actionSheetItems);
|
|
4757
|
-
if (action === awakeAction.id) {
|
|
4758
|
-
this.tryAwake();
|
|
4759
|
-
} else if (action === sleepAction.id) {
|
|
4760
|
-
this.trySleep();
|
|
4761
|
-
} else if (action === playAction.id) {
|
|
4762
|
-
this.tryPlay();
|
|
4763
|
-
} else if (action === quitAction.id) {
|
|
4764
|
-
this.tryQuit();
|
|
4765
|
-
} else {
|
|
4766
|
-
this.tryResume();
|
|
4767
|
-
}
|
|
4768
|
-
}
|
|
4769
|
-
tryAwake() {
|
|
4770
|
-
if (this.state === 2 /* SLEEPING */) {
|
|
4771
|
-
this.triggerLifecycleEvent("AWAKE" /* AWAKE */);
|
|
4772
|
-
this.state = 1 /* PAUSED */;
|
|
4773
|
-
}
|
|
4774
|
-
}
|
|
4775
|
-
trySleep() {
|
|
4776
|
-
if (this.state === 1 /* PAUSED */) {
|
|
4777
|
-
this.triggerLifecycleEvent("SLEEP" /* SLEEP */);
|
|
4778
|
-
this.state = 2 /* SLEEPING */;
|
|
4779
|
-
}
|
|
4780
|
-
}
|
|
4781
|
-
tryPlay() {
|
|
4782
|
-
if (this.state === 3 /* TERMINATED */) {
|
|
4783
|
-
this.triggerLifecycleEvent("AWAKE" /* AWAKE */);
|
|
4784
|
-
this.state = 1 /* PAUSED */;
|
|
4785
|
-
this.triggerLifecycleEvent("RESUME" /* RESUME */);
|
|
4786
|
-
this.state = 0 /* PLAYING */;
|
|
4787
|
-
}
|
|
4788
|
-
}
|
|
4789
|
-
tryQuit() {
|
|
4790
|
-
if (this.state === 0 /* PLAYING */) {
|
|
4791
|
-
this.triggerLifecycleEvent("PAUSE" /* PAUSE */);
|
|
4792
|
-
this.state = 1 /* PAUSED */;
|
|
4793
|
-
}
|
|
4794
|
-
if (this.state === 1 /* PAUSED */) {
|
|
4795
|
-
this.triggerLifecycleEvent("SLEEP" /* SLEEP */);
|
|
4796
|
-
this.state = 2 /* SLEEPING */;
|
|
4797
|
-
}
|
|
4798
|
-
if (this.state === 2 /* SLEEPING */) {
|
|
4799
|
-
this.triggerLifecycleEvent("QUIT" /* QUIT */);
|
|
4800
|
-
this.state = 3 /* TERMINATED */;
|
|
4801
|
-
}
|
|
4802
|
-
}
|
|
4803
|
-
tryResume() {
|
|
4804
|
-
if (this.state === 1 /* PAUSED */) {
|
|
4805
|
-
this.triggerLifecycleEvent("RESUME" /* RESUME */);
|
|
4806
|
-
this.state = 0 /* PLAYING */;
|
|
4807
|
-
}
|
|
4808
|
-
}
|
|
4809
|
-
async showAdOverlay(type) {
|
|
4810
|
-
return new Promise((resolve, reject) => {
|
|
4811
|
-
const overlay = this._overlay;
|
|
4812
|
-
const adOverlay = overlay.adOverlay;
|
|
4813
|
-
overlay.adOverlay.innerHTML = "";
|
|
4814
|
-
const heading = document.createElement("h1");
|
|
4815
|
-
heading.style.cssText = `
|
|
4816
|
-
font-size: 24px;
|
|
4817
|
-
margin-bottom: 20px;
|
|
4818
|
-
text-align: center;
|
|
4819
|
-
`;
|
|
4820
|
-
heading.innerText = type === "interstitial" ? "INTERSTITIAL AD" : "REWARDED VIDEO AD";
|
|
4821
|
-
overlay.adOverlay.appendChild(heading);
|
|
4822
|
-
const content = document.createElement("div");
|
|
4823
|
-
content.style.cssText = `
|
|
4824
|
-
width: 300px;
|
|
4825
|
-
height: 250px;
|
|
4826
|
-
background-color: #1e40af;
|
|
4827
|
-
display: flex;
|
|
4828
|
-
align-items: center;
|
|
4829
|
-
justify-content: center;
|
|
4830
|
-
margin-bottom: 20px;
|
|
4831
|
-
border-radius: 8px;
|
|
4832
|
-
`;
|
|
4833
|
-
content.innerText = "Mock Ad Content";
|
|
4834
|
-
adOverlay.appendChild(content);
|
|
4835
|
-
const timer = document.createElement("p");
|
|
4836
|
-
timer.style.cssText = `
|
|
4837
|
-
margin-bottom: 20px;
|
|
4838
|
-
font-size: 16px;
|
|
4839
|
-
`;
|
|
4840
|
-
timer.innerText = "Normally ads would have a timer...";
|
|
4841
|
-
adOverlay.appendChild(timer);
|
|
4842
|
-
const okButton = document.createElement("button");
|
|
4843
|
-
okButton.style.cssText = `
|
|
4844
|
-
padding: 10px 40px;
|
|
4845
|
-
background-color: #2563eb;
|
|
4846
|
-
color: white;
|
|
4847
|
-
border: none;
|
|
4848
|
-
border-radius: 4px;
|
|
4849
|
-
font-size: 16px;
|
|
4850
|
-
cursor: pointer;
|
|
4851
|
-
`;
|
|
4852
|
-
okButton.innerText = "Close Ad";
|
|
4853
|
-
adOverlay.appendChild(okButton);
|
|
4854
|
-
adOverlay.style.display = "flex";
|
|
4855
|
-
okButton.onclick = () => {
|
|
4856
|
-
this.hideAdOverlay();
|
|
4857
|
-
resolve(true);
|
|
4858
|
-
};
|
|
4859
|
-
});
|
|
4860
|
-
}
|
|
4861
|
-
hideAdOverlay() {
|
|
4862
|
-
const overlay = this._overlay;
|
|
4863
|
-
if (overlay.adOverlay) {
|
|
4864
|
-
overlay.adOverlay.style.display = "none";
|
|
4865
|
-
}
|
|
3314
|
+
if (config.target === "local" && config.functionsEmulatorHost && config.firebaseConfig?.projectId) {
|
|
3315
|
+
const region = config.functionsRegion || "us-central1";
|
|
3316
|
+
return `http://${config.functionsEmulatorHost}/${config.firebaseConfig.projectId}/${region}`;
|
|
4866
3317
|
}
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
actionSheetOverlay.id = "venus-action-sheet-overlay";
|
|
4870
|
-
actionSheetOverlay.style.cssText = `
|
|
4871
|
-
position: fixed;
|
|
4872
|
-
top: 0;
|
|
4873
|
-
left: 0;
|
|
4874
|
-
width: 100%;
|
|
4875
|
-
height: 100%;
|
|
4876
|
-
background-color: rgba(0, 0, 0, 0.5);
|
|
4877
|
-
display: flex;
|
|
4878
|
-
align-items: center;
|
|
4879
|
-
justify-content: center;
|
|
4880
|
-
z-index: 10600;
|
|
4881
|
-
font-family: sans-serif;
|
|
4882
|
-
display: none;
|
|
4883
|
-
`;
|
|
4884
|
-
document.body.appendChild(actionSheetOverlay);
|
|
4885
|
-
return actionSheetOverlay;
|
|
4886
|
-
}
|
|
4887
|
-
createOverlayButton(id, text, position, onClick, background, color) {
|
|
4888
|
-
const button = document.createElement("button");
|
|
4889
|
-
button.id = `venus-mock-${id}-button`;
|
|
4890
|
-
button.innerText = text;
|
|
4891
|
-
button.style.cssText = `
|
|
4892
|
-
position: absolute;
|
|
4893
|
-
left: ${position.x}px;
|
|
4894
|
-
top: ${position.y}px;
|
|
4895
|
-
width: ${position.width}px;
|
|
4896
|
-
min-width: ${position.width}px;
|
|
4897
|
-
height: ${position.height}px;
|
|
4898
|
-
background: ${background};
|
|
4899
|
-
color: ${color};
|
|
4900
|
-
border: none;
|
|
4901
|
-
border-radius: 8px;
|
|
4902
|
-
font-family: sans-serif;
|
|
4903
|
-
font-weight: bold;
|
|
4904
|
-
font-size: ${Math.min(position.width, position.height) / 3}px;
|
|
4905
|
-
cursor: pointer;
|
|
4906
|
-
pointer-events: auto;
|
|
4907
|
-
display: flex;
|
|
4908
|
-
align-items: center;
|
|
4909
|
-
justify-content: center;
|
|
4910
|
-
opacity: 0.9;
|
|
4911
|
-
transition: opacity 0.2s;
|
|
4912
|
-
`;
|
|
4913
|
-
button.addEventListener("click", onClick);
|
|
4914
|
-
button.addEventListener("mouseover", () => {
|
|
4915
|
-
button.style.opacity = "1";
|
|
4916
|
-
});
|
|
4917
|
-
button.addEventListener("mouseout", () => {
|
|
4918
|
-
button.style.opacity = "0.9";
|
|
4919
|
-
});
|
|
4920
|
-
return button;
|
|
4921
|
-
}
|
|
4922
|
-
updateOverlayLayout() {
|
|
4923
|
-
const overlay = this._overlay;
|
|
4924
|
-
const menuBtn = overlay.elements.menuButton;
|
|
4925
|
-
menuBtn.style.left = `${window.innerWidth - 48}px`;
|
|
4926
|
-
menuBtn.style.top = "16px";
|
|
4927
|
-
menuBtn.style.width = "32px";
|
|
4928
|
-
menuBtn.style.minWidth = "32px";
|
|
4929
|
-
menuBtn.style.height = "32px";
|
|
4930
|
-
}
|
|
4931
|
-
triggerLifecycleEvent(name) {
|
|
4932
|
-
console.log("Trigger Lifecycle Event: ", name);
|
|
4933
|
-
if (name == "PAUSE" /* PAUSE */) {
|
|
4934
|
-
this._mockLifecyclesApi.triggerPauseCallbacks();
|
|
4935
|
-
} else if (name == "RESUME" /* RESUME */) {
|
|
4936
|
-
this._mockLifecyclesApi.triggerResumeCallbacks();
|
|
4937
|
-
} else if (name == "QUIT" /* QUIT */) {
|
|
4938
|
-
this._mockLifecyclesApi.triggerQuitCallbacks();
|
|
4939
|
-
} else if (name == "AWAKE" /* AWAKE */) {
|
|
4940
|
-
this._mockLifecyclesApi.triggerAwakeCallbacks();
|
|
4941
|
-
} else if (name == "SLEEP" /* SLEEP */) {
|
|
4942
|
-
this._mockLifecyclesApi.triggerSleepCallbacks();
|
|
4943
|
-
}
|
|
3318
|
+
if (config.target !== "local" && typeof window !== "undefined") {
|
|
3319
|
+
return VENUS_API_PROXY_PATH;
|
|
4944
3320
|
}
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
const elements = overlay.elements;
|
|
4948
|
-
if (elements[element]) {
|
|
4949
|
-
elements[element].style.display = visible ? "flex" : "none";
|
|
4950
|
-
}
|
|
3321
|
+
if (config.firebaseConfig?.projectId && config.functionsRegion) {
|
|
3322
|
+
return `https://${config.functionsRegion}-${config.firebaseConfig.projectId}.cloudfunctions.net`;
|
|
4951
3323
|
}
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
adOverlay.style.cssText = `
|
|
4956
|
-
position: fixed;
|
|
4957
|
-
top: 0;
|
|
4958
|
-
left: 0;
|
|
4959
|
-
width: 100%;
|
|
4960
|
-
height: 100%;
|
|
4961
|
-
background-color: rgba(37, 99, 235, 0.9);
|
|
4962
|
-
color: white;
|
|
4963
|
-
display: flex;
|
|
4964
|
-
flex-direction: column;
|
|
4965
|
-
align-items: center;
|
|
4966
|
-
justify-content: center;
|
|
4967
|
-
z-index: 10500;
|
|
4968
|
-
font-family: sans-serif;
|
|
4969
|
-
display: none;
|
|
4970
|
-
`;
|
|
4971
|
-
document.body.appendChild(adOverlay);
|
|
4972
|
-
return adOverlay;
|
|
4973
|
-
}
|
|
4974
|
-
log(msg, ...args) {
|
|
4975
|
-
console.log(`[Venus Mock] ${msg}`, ...args);
|
|
4976
|
-
}
|
|
4977
|
-
showActionSheetOverlay(items, options) {
|
|
4978
|
-
this.log("Showing ActionSheetOverlay...");
|
|
4979
|
-
return new Promise((resolve, reject) => {
|
|
4980
|
-
const overlay = this._overlay;
|
|
4981
|
-
overlay.actionSheetOverlay.innerHTML = "";
|
|
4982
|
-
overlay.actionSheetOverlay.style.display = "flex";
|
|
4983
|
-
const actionSheet = document.createElement("div");
|
|
4984
|
-
actionSheet.className = "venus-action-sheet";
|
|
4985
|
-
actionSheet.style.cssText = `
|
|
4986
|
-
background-color: white;
|
|
4987
|
-
border-radius: 8px;
|
|
4988
|
-
width: 80%;
|
|
4989
|
-
max-width: 400px;
|
|
4990
|
-
max-height: 80%;
|
|
4991
|
-
display: flex;
|
|
4992
|
-
flex-direction: column;
|
|
4993
|
-
overflow: hidden;
|
|
4994
|
-
color: black;
|
|
4995
|
-
`;
|
|
4996
|
-
if (options?.title) {
|
|
4997
|
-
const titleContainer = document.createElement("div");
|
|
4998
|
-
titleContainer.style.cssText = `
|
|
4999
|
-
padding: 16px;
|
|
5000
|
-
border-bottom: 1px solid #eaeaea;
|
|
5001
|
-
font-weight: bold;
|
|
5002
|
-
font-size: 18px;
|
|
5003
|
-
text-align: center;
|
|
5004
|
-
color: black;
|
|
5005
|
-
`;
|
|
5006
|
-
titleContainer.innerText = options.title;
|
|
5007
|
-
actionSheet.appendChild(titleContainer);
|
|
5008
|
-
}
|
|
5009
|
-
if (options?.message) {
|
|
5010
|
-
const messageContainer = document.createElement("div");
|
|
5011
|
-
messageContainer.style.cssText = `
|
|
5012
|
-
padding: 8px 16px;
|
|
5013
|
-
color: #666;
|
|
5014
|
-
font-size: 14px;
|
|
5015
|
-
text-align: center;
|
|
5016
|
-
`;
|
|
5017
|
-
messageContainer.innerText = options.message;
|
|
5018
|
-
actionSheet.appendChild(messageContainer);
|
|
5019
|
-
}
|
|
5020
|
-
const optionsContainer = document.createElement("div");
|
|
5021
|
-
optionsContainer.style.cssText = `
|
|
5022
|
-
overflow-y: auto;
|
|
5023
|
-
max-height: 300px;
|
|
5024
|
-
`;
|
|
5025
|
-
items.forEach((item, index) => {
|
|
5026
|
-
const optionItem = document.createElement("div");
|
|
5027
|
-
optionItem.style.cssText = `
|
|
5028
|
-
padding: 12px 16px;
|
|
5029
|
-
border-bottom: 1px solid #eaeaea;
|
|
5030
|
-
cursor: pointer;
|
|
5031
|
-
display: flex;
|
|
5032
|
-
align-items: center;
|
|
5033
|
-
transition: background-color 0.2s;
|
|
5034
|
-
color: black;
|
|
5035
|
-
`;
|
|
5036
|
-
optionItem.addEventListener("mouseover", () => {
|
|
5037
|
-
optionItem.style.backgroundColor = "#f5f5f5";
|
|
5038
|
-
});
|
|
5039
|
-
optionItem.addEventListener("mouseout", () => {
|
|
5040
|
-
optionItem.style.backgroundColor = "white";
|
|
5041
|
-
});
|
|
5042
|
-
if (item.icon) {
|
|
5043
|
-
const iconSpan = document.createElement("span");
|
|
5044
|
-
iconSpan.style.cssText = `
|
|
5045
|
-
margin-right: 12px;
|
|
5046
|
-
font-size: 16px;
|
|
5047
|
-
`;
|
|
5048
|
-
iconSpan.innerText = item.icon;
|
|
5049
|
-
optionItem.appendChild(iconSpan);
|
|
5050
|
-
}
|
|
5051
|
-
const labelSpan = document.createElement("span");
|
|
5052
|
-
labelSpan.style.cssText = `
|
|
5053
|
-
color: black;
|
|
5054
|
-
`;
|
|
5055
|
-
labelSpan.innerText = item.label;
|
|
5056
|
-
optionItem.appendChild(labelSpan);
|
|
5057
|
-
optionItem.addEventListener("click", () => {
|
|
5058
|
-
this.hideActionSheetOverlay();
|
|
5059
|
-
const optionId = item.id !== void 0 ? item.id : index;
|
|
5060
|
-
resolve(optionId);
|
|
5061
|
-
});
|
|
5062
|
-
optionsContainer.appendChild(optionItem);
|
|
5063
|
-
});
|
|
5064
|
-
actionSheet.appendChild(optionsContainer);
|
|
5065
|
-
if (!options?.disableCancel) {
|
|
5066
|
-
const cancelButton = document.createElement("div");
|
|
5067
|
-
cancelButton.style.cssText = `
|
|
5068
|
-
padding: 14px 16px;
|
|
5069
|
-
text-align: center;
|
|
5070
|
-
font-weight: bold;
|
|
5071
|
-
cursor: pointer;
|
|
5072
|
-
color: #3b82f6;
|
|
5073
|
-
border-top: 1px solid #eaeaea;
|
|
5074
|
-
`;
|
|
5075
|
-
cancelButton.innerText = options?.cancelButtonText || "Cancel";
|
|
5076
|
-
cancelButton.addEventListener("click", () => {
|
|
5077
|
-
this.hideActionSheetOverlay();
|
|
5078
|
-
resolve(null);
|
|
5079
|
-
});
|
|
5080
|
-
actionSheet.appendChild(cancelButton);
|
|
5081
|
-
}
|
|
5082
|
-
if (!options?.disableCancel) {
|
|
5083
|
-
const closeButton = document.createElement("div");
|
|
5084
|
-
closeButton.style.cssText = `
|
|
5085
|
-
position: absolute;
|
|
5086
|
-
top: 8px;
|
|
5087
|
-
right: 8px;
|
|
5088
|
-
width: 24px;
|
|
5089
|
-
height: 24px;
|
|
5090
|
-
border-radius: 12px;
|
|
5091
|
-
background-color: rgba(0,0,0,0.1);
|
|
5092
|
-
color: #666;
|
|
5093
|
-
display: flex;
|
|
5094
|
-
align-items: center;
|
|
5095
|
-
justify-content: center;
|
|
5096
|
-
cursor: pointer;
|
|
5097
|
-
font-size: 14px;
|
|
5098
|
-
`;
|
|
5099
|
-
closeButton.innerText = "\u2715";
|
|
5100
|
-
closeButton.addEventListener("click", () => {
|
|
5101
|
-
this.hideActionSheetOverlay();
|
|
5102
|
-
resolve(null);
|
|
5103
|
-
});
|
|
5104
|
-
actionSheet.appendChild(closeButton);
|
|
5105
|
-
overlay.actionSheetOverlay.appendChild(actionSheet);
|
|
5106
|
-
}
|
|
5107
|
-
});
|
|
5108
|
-
}
|
|
5109
|
-
hideActionSheetOverlay() {
|
|
5110
|
-
const overlay = this._overlay;
|
|
5111
|
-
if (overlay.actionSheetOverlay) {
|
|
5112
|
-
overlay.actionSheetOverlay.style.display = "none";
|
|
5113
|
-
}
|
|
5114
|
-
}
|
|
5115
|
-
};
|
|
5116
|
-
|
|
5117
|
-
// src/Host.ts
|
|
5118
|
-
function createHost(venusApi, isMock) {
|
|
5119
|
-
if (isMock) {
|
|
5120
|
-
return new MockHost(venusApi);
|
|
5121
|
-
} else {
|
|
5122
|
-
return new RemoteHost(venusApi);
|
|
5123
|
-
}
|
|
5124
|
-
}
|
|
5125
|
-
|
|
5126
|
-
// src/social/index.ts
|
|
5127
|
-
function initializeSocial(venusApi, host) {
|
|
5128
|
-
venusApi.social = host.social;
|
|
5129
|
-
venusApi.getLaunchParams = () => {
|
|
5130
|
-
return venusApi.launchParams || {};
|
|
5131
|
-
};
|
|
3324
|
+
throw new Error(
|
|
3325
|
+
`[Venus SDK] Cannot determine backend URL for target "${config.target}". Either provide backendUrl or configure Firebase project settings.`
|
|
3326
|
+
);
|
|
5132
3327
|
}
|
|
5133
3328
|
|
|
5134
|
-
export { DEFAULT_SHARED_LIB_CDN_BASE, EMBEDDED_LIBRARIES, EMBEDDED_LIBRARY_BY_KEY,
|
|
5135
|
-
//# sourceMappingURL=chunk-
|
|
5136
|
-
//# sourceMappingURL=chunk-
|
|
3329
|
+
export { DEFAULT_SHARED_LIB_CDN_BASE, EMBEDDED_LIBRARIES, EMBEDDED_LIBRARY_BY_KEY, HapticFeedbackStyle, HostCdnApi, HostDeviceApi, HostEnvironmentApi, HostProfileApi, HostSystemApi, HostTimeApi, MODULE_TO_LIBRARY_SPECIFIERS, MockAdsApi, MockAiApi, MockAnalyticsApi, MockAvatarApi, MockCdnApi, MockDeviceApi, MockEnvironmentApi, MockFeaturesApi, MockHapticsApi, MockIapApi, MockLifecycleApi, MockLoggingApi, MockNavigationApi, MockNotificationsApi, MockPopupsApi, MockPreloaderApi, MockProfileApi, MockSharedAssetsApi, MockSocialApi, MockStorageApi, MockSystemApi, MockTimeApi, ROOM_GAME_PHASES, RpcAdsApi, RpcAiApi, RpcAnalyticsApi, RpcAvatarApi, RpcFeaturesApi, RpcHapticsApi, RpcIapApi, RpcLifecycleApi, RpcLoggingApi, RpcNavigationApi, RpcNotificationsApi, RpcPopupsApi, RpcPreloaderApi, RpcRoomsApi, RpcSharedAssetsApi, RpcStorageApi, VenusMessageId, VenusRoom, base64ToArrayBuffer, base64ToUtf8, buildFunctionsBaseUrl, createMockStorageApi, getLibraryDefinition, getSandboxConfig, initializeAds, initializeAi, initializeAnalytics, initializeAvatar3d, initializeCdn, initializeFeaturesApi, initializeHaptics, initializeIap, initializeLifecycleApi, initializeLocalNotifications, initializeLoggingApi, initializePopups, initializePreloader, initializeProfile, initializeRoomsApi, initializeStackNavigation, initializeStorage, initializeSystem, initializeTime, isPacificDaylightTime, isSandboxEnabled, setupRoomNotifications };
|
|
3330
|
+
//# sourceMappingURL=chunk-Q7SNANYR.js.map
|
|
3331
|
+
//# sourceMappingURL=chunk-Q7SNANYR.js.map
|