@series-inc/venus-sdk 3.2.0 → 3.2.1-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-DFutZ7_q.d.mts → AdsApi-OXtzPhiB.d.mts} +1 -67
- package/dist/{AdsApi-DFutZ7_q.d.ts → AdsApi-OXtzPhiB.d.ts} +1 -67
- package/dist/{chunk-UXY5CKKG.mjs → chunk-3ZNKYBXC.mjs} +3 -3
- package/dist/chunk-3ZNKYBXC.mjs.map +1 -0
- package/dist/{chunk-AGXMORDL.mjs → chunk-46LCYRXS.mjs} +221 -213
- package/dist/chunk-46LCYRXS.mjs.map +1 -0
- package/dist/index.cjs +220 -212
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +26 -14
- package/dist/index.d.ts +26 -14
- package/dist/index.mjs +2 -2
- package/dist/venus-api/index.cjs +203 -219
- 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 +1 -1
- package/dist/vite/index.cjs +20 -0
- package/dist/vite/index.cjs.map +1 -1
- package/dist/vite/index.mjs +20 -1
- package/dist/vite/index.mjs.map +1 -1
- package/dist/webview/index.cjs +1 -1
- package/dist/webview/index.cjs.map +1 -1
- package/dist/webview/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-AGXMORDL.mjs.map +0 -1
- package/dist/chunk-UXY5CKKG.mjs.map +0 -1
package/dist/venus-api/index.cjs
CHANGED
|
@@ -101,21 +101,23 @@ var init_core = __esm({
|
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
// src/storage/MockStorageApi.ts
|
|
104
|
+
var STORAGE_PREFIXES = {
|
|
105
|
+
globalStorage: "venus:global",
|
|
106
|
+
deviceCache: "venus:deviceCache",
|
|
107
|
+
appStorage: "venus:appStorage"
|
|
108
|
+
};
|
|
104
109
|
function createMockStorageApi(storageType, appUrl) {
|
|
105
110
|
const appIdentifier = appUrl ? generateAppIdentifier(appUrl) : null;
|
|
106
|
-
let prefix;
|
|
111
|
+
let prefix = STORAGE_PREFIXES[storageType];
|
|
107
112
|
let syncDelay = 0;
|
|
108
113
|
switch (storageType) {
|
|
109
114
|
case "deviceCache":
|
|
110
|
-
prefix = "venus:app";
|
|
111
115
|
syncDelay = 0;
|
|
112
116
|
break;
|
|
113
117
|
case "appStorage":
|
|
114
|
-
prefix = "venus:app";
|
|
115
118
|
syncDelay = 100;
|
|
116
119
|
break;
|
|
117
120
|
case "globalStorage":
|
|
118
|
-
prefix = "venus:global";
|
|
119
121
|
syncDelay = 100;
|
|
120
122
|
break;
|
|
121
123
|
default:
|
|
@@ -128,29 +130,38 @@ var MockStorageApi = class {
|
|
|
128
130
|
constructor(prefix, syncDelay) {
|
|
129
131
|
__publicField(this, "prefix");
|
|
130
132
|
__publicField(this, "syncDelay");
|
|
133
|
+
__publicField(this, "orderStorageKey");
|
|
131
134
|
this.prefix = prefix;
|
|
132
135
|
this.syncDelay = syncDelay;
|
|
136
|
+
this.orderStorageKey = `${prefix}__order__`;
|
|
133
137
|
}
|
|
134
138
|
async clear() {
|
|
139
|
+
const keysToRemove = [];
|
|
135
140
|
const fullLength = localStorage.length;
|
|
136
141
|
for (let i = 0; i < fullLength; i++) {
|
|
137
142
|
const fullKey = localStorage.key(i);
|
|
138
|
-
if (fullKey
|
|
139
|
-
|
|
143
|
+
if (!fullKey || fullKey === this.orderStorageKey) {
|
|
144
|
+
continue;
|
|
140
145
|
}
|
|
146
|
+
if (fullKey.startsWith(this.prefix)) {
|
|
147
|
+
keysToRemove.push(fullKey);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
for (const key of keysToRemove) {
|
|
151
|
+
localStorage.removeItem(key);
|
|
141
152
|
}
|
|
153
|
+
this.clearOrder();
|
|
142
154
|
await this.simulateSyncDelay();
|
|
143
155
|
}
|
|
144
156
|
async getAllItems() {
|
|
145
157
|
const items = new Array();
|
|
146
|
-
const
|
|
147
|
-
for (
|
|
148
|
-
const
|
|
149
|
-
if (
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
158
|
+
const orderedKeys = this.keys();
|
|
159
|
+
for (const key of orderedKeys) {
|
|
160
|
+
const value = localStorage.getItem(this.buildKey(key));
|
|
161
|
+
if (value !== null) {
|
|
162
|
+
items.push(value);
|
|
163
|
+
} else {
|
|
164
|
+
this.removeFromOrder(key);
|
|
154
165
|
}
|
|
155
166
|
}
|
|
156
167
|
return items;
|
|
@@ -175,11 +186,13 @@ var MockStorageApi = class {
|
|
|
175
186
|
const fullKey = this.buildKey(key);
|
|
176
187
|
await this.simulateSyncDelay();
|
|
177
188
|
localStorage.removeItem(fullKey);
|
|
189
|
+
this.removeFromOrder(key);
|
|
178
190
|
}
|
|
179
191
|
async setItem(key, item) {
|
|
180
192
|
const fullKey = this.buildKey(key);
|
|
181
193
|
await this.simulateSyncDelay();
|
|
182
194
|
localStorage.setItem(fullKey, item);
|
|
195
|
+
this.upsertOrder(key);
|
|
183
196
|
}
|
|
184
197
|
async setMultipleItems(entries) {
|
|
185
198
|
for (const entry of entries) {
|
|
@@ -187,6 +200,7 @@ var MockStorageApi = class {
|
|
|
187
200
|
localStorage.setItem(fullKey, entry.value);
|
|
188
201
|
}
|
|
189
202
|
await this.simulateSyncDelay();
|
|
203
|
+
this.bulkUpsertOrder(entries.map((entry) => entry.key));
|
|
190
204
|
}
|
|
191
205
|
async removeMultipleItems(keys) {
|
|
192
206
|
for (const key of keys) {
|
|
@@ -194,6 +208,7 @@ var MockStorageApi = class {
|
|
|
194
208
|
localStorage.removeItem(fullKey);
|
|
195
209
|
}
|
|
196
210
|
await this.simulateSyncDelay();
|
|
211
|
+
this.bulkRemoveFromOrder(keys);
|
|
197
212
|
}
|
|
198
213
|
buildKey(key) {
|
|
199
214
|
const prefix = this.prefix;
|
|
@@ -204,17 +219,8 @@ var MockStorageApi = class {
|
|
|
204
219
|
return fullKey.substring(prefix.length);
|
|
205
220
|
}
|
|
206
221
|
keys() {
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
for (let i = 0; i < length; i++) {
|
|
210
|
-
const fullKey = localStorage.key(i);
|
|
211
|
-
if (fullKey && fullKey.startsWith(this.prefix)) {
|
|
212
|
-
length++;
|
|
213
|
-
const key = this.extractKey(fullKey);
|
|
214
|
-
keys.push(key);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
return keys;
|
|
222
|
+
const order = this.readOrder();
|
|
223
|
+
return [...order];
|
|
218
224
|
}
|
|
219
225
|
async simulateSyncDelay() {
|
|
220
226
|
const syncDelay = this.syncDelay;
|
|
@@ -222,6 +228,127 @@ var MockStorageApi = class {
|
|
|
222
228
|
await new Promise((resolve) => setTimeout(resolve, syncDelay));
|
|
223
229
|
}
|
|
224
230
|
}
|
|
231
|
+
readOrder() {
|
|
232
|
+
const raw = localStorage.getItem(this.orderStorageKey);
|
|
233
|
+
if (!raw) {
|
|
234
|
+
return this.rebuildOrderFromStorage();
|
|
235
|
+
}
|
|
236
|
+
try {
|
|
237
|
+
const parsed = JSON.parse(raw);
|
|
238
|
+
if (Array.isArray(parsed)) {
|
|
239
|
+
return this.normalizeOrder(parsed);
|
|
240
|
+
}
|
|
241
|
+
} catch {
|
|
242
|
+
}
|
|
243
|
+
return this.rebuildOrderFromStorage();
|
|
244
|
+
}
|
|
245
|
+
normalizeOrder(order) {
|
|
246
|
+
const seen = /* @__PURE__ */ new Set();
|
|
247
|
+
const normalized = [];
|
|
248
|
+
let changed = false;
|
|
249
|
+
for (const entry of order) {
|
|
250
|
+
if (typeof entry !== "string") {
|
|
251
|
+
changed = true;
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
if (seen.has(entry)) {
|
|
255
|
+
changed = true;
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
const fullKey = this.buildKey(entry);
|
|
259
|
+
if (localStorage.getItem(fullKey) === null) {
|
|
260
|
+
changed = true;
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
seen.add(entry);
|
|
264
|
+
normalized.push(entry);
|
|
265
|
+
}
|
|
266
|
+
if (changed) {
|
|
267
|
+
this.writeOrder(normalized);
|
|
268
|
+
}
|
|
269
|
+
return normalized;
|
|
270
|
+
}
|
|
271
|
+
rebuildOrderFromStorage() {
|
|
272
|
+
const keys = [];
|
|
273
|
+
const total = localStorage.length;
|
|
274
|
+
for (let i = 0; i < total; i++) {
|
|
275
|
+
const fullKey = localStorage.key(i);
|
|
276
|
+
if (!fullKey) continue;
|
|
277
|
+
if (fullKey === this.orderStorageKey) continue;
|
|
278
|
+
if (fullKey.startsWith(this.prefix)) {
|
|
279
|
+
keys.push(this.extractKey(fullKey));
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
this.writeOrder(keys);
|
|
283
|
+
return keys;
|
|
284
|
+
}
|
|
285
|
+
upsertOrder(key) {
|
|
286
|
+
const order = this.readOrder();
|
|
287
|
+
const index = order.indexOf(key);
|
|
288
|
+
if (index !== -1) {
|
|
289
|
+
order.splice(index, 1);
|
|
290
|
+
}
|
|
291
|
+
order.push(key);
|
|
292
|
+
this.writeOrder(order);
|
|
293
|
+
}
|
|
294
|
+
bulkUpsertOrder(keys) {
|
|
295
|
+
const dedupedKeys = this.dedupeKeys(keys);
|
|
296
|
+
if (dedupedKeys.length === 0) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
const order = this.readOrder();
|
|
300
|
+
const keysSet = new Set(dedupedKeys);
|
|
301
|
+
const filtered = order.filter((entry) => !keysSet.has(entry));
|
|
302
|
+
for (const key of dedupedKeys) {
|
|
303
|
+
filtered.push(key);
|
|
304
|
+
}
|
|
305
|
+
this.writeOrder(filtered);
|
|
306
|
+
}
|
|
307
|
+
removeFromOrder(key) {
|
|
308
|
+
const order = this.readOrder();
|
|
309
|
+
const index = order.indexOf(key);
|
|
310
|
+
if (index !== -1) {
|
|
311
|
+
order.splice(index, 1);
|
|
312
|
+
this.writeOrder(order);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
bulkRemoveFromOrder(keys) {
|
|
316
|
+
const dedupedKeys = this.dedupeKeys(keys);
|
|
317
|
+
if (dedupedKeys.length === 0) {
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
const order = this.readOrder();
|
|
321
|
+
const keysSet = new Set(dedupedKeys);
|
|
322
|
+
const filtered = order.filter((entry) => !keysSet.has(entry));
|
|
323
|
+
if (filtered.length !== order.length) {
|
|
324
|
+
this.writeOrder(filtered);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
writeOrder(order) {
|
|
328
|
+
if (order.length === 0) {
|
|
329
|
+
localStorage.removeItem(this.orderStorageKey);
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
localStorage.setItem(this.orderStorageKey, JSON.stringify(order));
|
|
333
|
+
}
|
|
334
|
+
clearOrder() {
|
|
335
|
+
localStorage.removeItem(this.orderStorageKey);
|
|
336
|
+
}
|
|
337
|
+
dedupeKeys(keys) {
|
|
338
|
+
const result = [];
|
|
339
|
+
const seen = /* @__PURE__ */ new Set();
|
|
340
|
+
for (const key of keys) {
|
|
341
|
+
if (typeof key !== "string") {
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
if (seen.has(key)) {
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
seen.add(key);
|
|
348
|
+
result.push(key);
|
|
349
|
+
}
|
|
350
|
+
return result;
|
|
351
|
+
}
|
|
225
352
|
};
|
|
226
353
|
function generateAppIdentifier(appUrl) {
|
|
227
354
|
if (!appUrl) appUrl = "";
|
|
@@ -415,40 +542,6 @@ var RpcPopupsApi = class {
|
|
|
415
542
|
__publicField(this, "rpcClient");
|
|
416
543
|
this.rpcClient = rpcClient;
|
|
417
544
|
}
|
|
418
|
-
async showActionSheet(items, options) {
|
|
419
|
-
const result = await this.rpcClient.call(
|
|
420
|
-
"H5_ACTION_SHEET_SHOW" /* ACTION_SHEET_SHOW */,
|
|
421
|
-
{
|
|
422
|
-
title: options?.title || "",
|
|
423
|
-
message: options?.message || "",
|
|
424
|
-
options: items,
|
|
425
|
-
cancelButtonText: options?.cancelButtonText || "Cancel"
|
|
426
|
-
}
|
|
427
|
-
);
|
|
428
|
-
return result;
|
|
429
|
-
}
|
|
430
|
-
async showAlert(title, message, options) {
|
|
431
|
-
const buttonText = options?.buttonText || "OK";
|
|
432
|
-
await this.rpcClient.call("H5_ALERT_DIALOG" /* ALERT_DIALOG */, {
|
|
433
|
-
title,
|
|
434
|
-
message,
|
|
435
|
-
buttonText
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
async showConfirm(title, message, options) {
|
|
439
|
-
const confirmText = options?.confirmText || "OK";
|
|
440
|
-
const cancelText = options?.cancelText || "Cancel";
|
|
441
|
-
const result = await this.rpcClient.call(
|
|
442
|
-
"H5_CONFIRM_DIALOG" /* CONFIRM_DIALOG */,
|
|
443
|
-
{
|
|
444
|
-
title,
|
|
445
|
-
message,
|
|
446
|
-
confirmText,
|
|
447
|
-
cancelText
|
|
448
|
-
}
|
|
449
|
-
);
|
|
450
|
-
return result;
|
|
451
|
-
}
|
|
452
545
|
async showToast(message, options) {
|
|
453
546
|
const duration = options?.duration ?? 3e3;
|
|
454
547
|
const variant = options?.variant ?? "info";
|
|
@@ -472,21 +565,6 @@ var MockPopupsApi = class {
|
|
|
472
565
|
__publicField(this, "overlay");
|
|
473
566
|
this.overlay = override;
|
|
474
567
|
}
|
|
475
|
-
showActionSheet(items, options) {
|
|
476
|
-
console.log(
|
|
477
|
-
`[Venus Mock] Show Action sheet, items: ${JSON.stringify(items, null, 2)}, options: ${JSON.stringify(options, null, 2)}`
|
|
478
|
-
);
|
|
479
|
-
return this.overlay.showActionSheet(items, options);
|
|
480
|
-
}
|
|
481
|
-
async showAlert(title, message, options) {
|
|
482
|
-
window.alert(`${title}
|
|
483
|
-
${message}`);
|
|
484
|
-
}
|
|
485
|
-
async showConfirm(title, message, options) {
|
|
486
|
-
const result = window.confirm(`${title || "Confirm"}
|
|
487
|
-
${message}`);
|
|
488
|
-
return result;
|
|
489
|
-
}
|
|
490
568
|
async showToast(message, options) {
|
|
491
569
|
const variant = options?.variant ?? "info";
|
|
492
570
|
const duration = options?.duration ?? 3e3;
|
|
@@ -513,41 +591,6 @@ ${message}`);
|
|
|
513
591
|
|
|
514
592
|
// src/popups/index.ts
|
|
515
593
|
function initializePopups(venusApi, host) {
|
|
516
|
-
venusApi.showToast = async (input) => {
|
|
517
|
-
if (typeof input === "string") {
|
|
518
|
-
return await host.popups.showToast(input);
|
|
519
|
-
} else {
|
|
520
|
-
return await host.popups.showToast(input.message, {
|
|
521
|
-
duration: input.duration,
|
|
522
|
-
action: input.action,
|
|
523
|
-
variant: "success"
|
|
524
|
-
});
|
|
525
|
-
}
|
|
526
|
-
};
|
|
527
|
-
venusApi.showAlert = async (input) => {
|
|
528
|
-
await host.popups.showAlert(input.title, input.message, {
|
|
529
|
-
buttonText: input.buttonText
|
|
530
|
-
});
|
|
531
|
-
};
|
|
532
|
-
venusApi.showConfirm = async (input) => {
|
|
533
|
-
const confirmed = await host.popups.showConfirm(
|
|
534
|
-
input.title,
|
|
535
|
-
input.message,
|
|
536
|
-
{
|
|
537
|
-
confirmText: input.confirmText,
|
|
538
|
-
cancelText: input.cancelText
|
|
539
|
-
}
|
|
540
|
-
);
|
|
541
|
-
return confirmed;
|
|
542
|
-
};
|
|
543
|
-
venusApi.showActionSheet = async (input) => {
|
|
544
|
-
return await host.popups.showActionSheet(input.options, {
|
|
545
|
-
title: input.title,
|
|
546
|
-
message: input.message,
|
|
547
|
-
cancelButtonText: input.cancelButtonText,
|
|
548
|
-
disableCancel: input.disableCancel
|
|
549
|
-
});
|
|
550
|
-
};
|
|
551
594
|
venusApi.popups = host.popups;
|
|
552
595
|
}
|
|
553
596
|
|
|
@@ -4261,7 +4304,7 @@ var MockCdnApi = class {
|
|
|
4261
4304
|
const cleanSubPath = subPath.startsWith("/") ? subPath.slice(1) : subPath;
|
|
4262
4305
|
const isLocalhost = typeof window !== "undefined" && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1");
|
|
4263
4306
|
if (isLocalhost && !this.forceRemoteCdn) {
|
|
4264
|
-
return
|
|
4307
|
+
return `cdn/${cleanSubPath}`;
|
|
4265
4308
|
}
|
|
4266
4309
|
const pathParts = cleanSubPath.split("/");
|
|
4267
4310
|
const encodedParts = pathParts.map((part, index) => {
|
|
@@ -5069,6 +5112,54 @@ function initializeLoggingApi(venusApi, host) {
|
|
|
5069
5112
|
};
|
|
5070
5113
|
}
|
|
5071
5114
|
|
|
5115
|
+
// src/shared-assets/base64Utils.ts
|
|
5116
|
+
function base64ToArrayBuffer(base64) {
|
|
5117
|
+
const binaryString = atob(base64);
|
|
5118
|
+
const len = binaryString.length;
|
|
5119
|
+
const bytes = new Uint8Array(len);
|
|
5120
|
+
for (let i = 0; i < len; i++) {
|
|
5121
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
5122
|
+
}
|
|
5123
|
+
return bytes.buffer;
|
|
5124
|
+
}
|
|
5125
|
+
|
|
5126
|
+
// src/shared-assets/RpcSharedAssetsApi.ts
|
|
5127
|
+
var RpcSharedAssetsApi = class {
|
|
5128
|
+
constructor(rpcClient, venusApi) {
|
|
5129
|
+
__publicField(this, "venusApi");
|
|
5130
|
+
__publicField(this, "rpcClient");
|
|
5131
|
+
this.rpcClient = rpcClient;
|
|
5132
|
+
this.venusApi = venusApi;
|
|
5133
|
+
}
|
|
5134
|
+
async loadAssetsBundle(game, bundleKey, fileType = "stow") {
|
|
5135
|
+
try {
|
|
5136
|
+
const response = await this.rpcClient.callT("H5_LOAD_EMBEDDED_ASSET" /* H5_LOAD_EMBEDDED_ASSET */, {
|
|
5137
|
+
assetKey: bundleKey
|
|
5138
|
+
});
|
|
5139
|
+
return base64ToArrayBuffer(response.base64Data);
|
|
5140
|
+
} catch (err) {
|
|
5141
|
+
try {
|
|
5142
|
+
const blob = await this.venusApi.cdn.fetchBlob(`${game}/${bundleKey}.${fileType}`);
|
|
5143
|
+
return await blob.arrayBuffer();
|
|
5144
|
+
} catch (e) {
|
|
5145
|
+
throw new Error(`Failed to load ${bundleKey}`);
|
|
5146
|
+
}
|
|
5147
|
+
}
|
|
5148
|
+
}
|
|
5149
|
+
};
|
|
5150
|
+
|
|
5151
|
+
// src/shared-assets/MockSharedAssetsApi.ts
|
|
5152
|
+
var MockSharedAssetsApi = class {
|
|
5153
|
+
constructor(venusApi) {
|
|
5154
|
+
__publicField(this, "venusApi");
|
|
5155
|
+
this.venusApi = venusApi;
|
|
5156
|
+
}
|
|
5157
|
+
async loadAssetsBundle(game, bundleKey, fileType = "stow") {
|
|
5158
|
+
const blob = await this.venusApi.cdn.fetchBlob(`${game}/${bundleKey}.${fileType}`);
|
|
5159
|
+
return await blob.arrayBuffer();
|
|
5160
|
+
}
|
|
5161
|
+
};
|
|
5162
|
+
|
|
5072
5163
|
// src/shared-assets/embeddedLibrariesManifest.ts
|
|
5073
5164
|
var EMBEDDED_LIBRARIES = [
|
|
5074
5165
|
{
|
|
@@ -5183,7 +5274,7 @@ var EMBEDDED_LIBRARIES = [
|
|
|
5183
5274
|
// Not ready yet - WASM loading needs additional work
|
|
5184
5275
|
}
|
|
5185
5276
|
];
|
|
5186
|
-
|
|
5277
|
+
EMBEDDED_LIBRARIES.reduce(
|
|
5187
5278
|
(acc, lib) => {
|
|
5188
5279
|
acc[lib.libraryKey] = lib;
|
|
5189
5280
|
return acc;
|
|
@@ -5198,113 +5289,6 @@ EMBEDDED_LIBRARIES.filter(
|
|
|
5198
5289
|
libraryKey: lib.libraryKey
|
|
5199
5290
|
}))
|
|
5200
5291
|
);
|
|
5201
|
-
function getLibraryDefinition(libraryKey) {
|
|
5202
|
-
const definition = EMBEDDED_LIBRARY_BY_KEY[libraryKey];
|
|
5203
|
-
if (!definition) {
|
|
5204
|
-
const availableKeys = Object.keys(EMBEDDED_LIBRARY_BY_KEY).join(", ");
|
|
5205
|
-
throw new Error(
|
|
5206
|
-
`Unsupported embedded library: ${libraryKey}. Available libraries: ${availableKeys}`
|
|
5207
|
-
);
|
|
5208
|
-
}
|
|
5209
|
-
return definition;
|
|
5210
|
-
}
|
|
5211
|
-
|
|
5212
|
-
// src/shared-assets/base64Utils.ts
|
|
5213
|
-
function base64ToArrayBuffer(base64) {
|
|
5214
|
-
const binaryString = atob(base64);
|
|
5215
|
-
const len = binaryString.length;
|
|
5216
|
-
const bytes = new Uint8Array(len);
|
|
5217
|
-
for (let i = 0; i < len; i++) {
|
|
5218
|
-
bytes[i] = binaryString.charCodeAt(i);
|
|
5219
|
-
}
|
|
5220
|
-
return bytes.buffer;
|
|
5221
|
-
}
|
|
5222
|
-
function base64ToUtf8(base64) {
|
|
5223
|
-
if (typeof TextDecoder !== "undefined") {
|
|
5224
|
-
const decoder = new TextDecoder("utf-8");
|
|
5225
|
-
const buffer = base64ToArrayBuffer(base64);
|
|
5226
|
-
return decoder.decode(new Uint8Array(buffer));
|
|
5227
|
-
}
|
|
5228
|
-
if (typeof globalThis !== "undefined" && typeof globalThis.Buffer !== "undefined") {
|
|
5229
|
-
const BufferCtor = globalThis.Buffer;
|
|
5230
|
-
return BufferCtor.from(base64, "base64").toString("utf-8");
|
|
5231
|
-
}
|
|
5232
|
-
const binaryString = atob(base64);
|
|
5233
|
-
let result = "";
|
|
5234
|
-
for (let i = 0; i < binaryString.length; i++) {
|
|
5235
|
-
result += String.fromCharCode(binaryString.charCodeAt(i));
|
|
5236
|
-
}
|
|
5237
|
-
return decodeURIComponent(escape(result));
|
|
5238
|
-
}
|
|
5239
|
-
|
|
5240
|
-
// src/shared-assets/RpcSharedAssetsApi.ts
|
|
5241
|
-
var RpcSharedAssetsApi = class {
|
|
5242
|
-
constructor(rpcClient, venusApi) {
|
|
5243
|
-
__publicField(this, "venusApi");
|
|
5244
|
-
__publicField(this, "rpcClient");
|
|
5245
|
-
this.rpcClient = rpcClient;
|
|
5246
|
-
this.venusApi = venusApi;
|
|
5247
|
-
}
|
|
5248
|
-
async loadAssetsBundle(game, bundleKey, fileType = "stow") {
|
|
5249
|
-
try {
|
|
5250
|
-
const response = await this.rpcClient.callT("H5_LOAD_EMBEDDED_ASSET" /* H5_LOAD_EMBEDDED_ASSET */, {
|
|
5251
|
-
assetKey: bundleKey
|
|
5252
|
-
});
|
|
5253
|
-
return base64ToArrayBuffer(response.base64Data);
|
|
5254
|
-
} catch (err) {
|
|
5255
|
-
try {
|
|
5256
|
-
const blob = await this.venusApi.cdn.fetchBlob(`${game}/${bundleKey}.${fileType}`);
|
|
5257
|
-
return await blob.arrayBuffer();
|
|
5258
|
-
} catch (e) {
|
|
5259
|
-
throw new Error(`Failed to load ${bundleKey}`);
|
|
5260
|
-
}
|
|
5261
|
-
}
|
|
5262
|
-
}
|
|
5263
|
-
async loadLibraryCode(libraryKey) {
|
|
5264
|
-
const definition = getLibraryDefinition(libraryKey);
|
|
5265
|
-
try {
|
|
5266
|
-
const response = await this.rpcClient.callT("H5_LOAD_EMBEDDED_ASSET" /* H5_LOAD_EMBEDDED_ASSET */, {
|
|
5267
|
-
assetKey: definition.assetKey
|
|
5268
|
-
});
|
|
5269
|
-
return base64ToUtf8(response.base64Data);
|
|
5270
|
-
} catch (err) {
|
|
5271
|
-
console.error(
|
|
5272
|
-
`[Venus Libraries] Failed to load ${libraryKey} from host via RPC:`,
|
|
5273
|
-
err
|
|
5274
|
-
);
|
|
5275
|
-
console.warn(
|
|
5276
|
-
`[Venus Libraries] Falling back to CDN for ${libraryKey}. This may indicate an asset packaging issue.`
|
|
5277
|
-
);
|
|
5278
|
-
try {
|
|
5279
|
-
const cdnUrl = this.venusApi.cdn.resolveSharedLibUrl(definition.cdnPath);
|
|
5280
|
-
const response = await this.venusApi.cdn.fetchFromCdn(cdnUrl);
|
|
5281
|
-
return await response.text();
|
|
5282
|
-
} catch (cdnError) {
|
|
5283
|
-
throw new Error(
|
|
5284
|
-
`Failed to load embedded library ${libraryKey}: RPC failed, CDN fallback failed: ${cdnError.message}`
|
|
5285
|
-
);
|
|
5286
|
-
}
|
|
5287
|
-
}
|
|
5288
|
-
}
|
|
5289
|
-
};
|
|
5290
|
-
|
|
5291
|
-
// src/shared-assets/MockSharedAssetsApi.ts
|
|
5292
|
-
var MockSharedAssetsApi = class {
|
|
5293
|
-
constructor(venusApi) {
|
|
5294
|
-
__publicField(this, "venusApi");
|
|
5295
|
-
this.venusApi = venusApi;
|
|
5296
|
-
}
|
|
5297
|
-
async loadAssetsBundle(game, bundleKey, fileType = "stow") {
|
|
5298
|
-
const blob = await this.venusApi.cdn.fetchBlob(`${game}/${bundleKey}.${fileType}`);
|
|
5299
|
-
return await blob.arrayBuffer();
|
|
5300
|
-
}
|
|
5301
|
-
async loadLibraryCode(libraryKey) {
|
|
5302
|
-
const definition = getLibraryDefinition(libraryKey);
|
|
5303
|
-
const url = this.venusApi.cdn.resolveSharedLibUrl(definition.cdnPath);
|
|
5304
|
-
const response = await this.venusApi.cdn.fetchFromCdn(url);
|
|
5305
|
-
return await response.text();
|
|
5306
|
-
}
|
|
5307
|
-
};
|
|
5308
5292
|
|
|
5309
5293
|
// src/game-preloader/MockPreloaderApi.ts
|
|
5310
5294
|
var MockPreloaderApi = class {
|
|
@@ -6870,7 +6854,7 @@ function createHost(venusApi, isMock) {
|
|
|
6870
6854
|
}
|
|
6871
6855
|
|
|
6872
6856
|
// src/version.ts
|
|
6873
|
-
var SDK_VERSION = "3.2.
|
|
6857
|
+
var SDK_VERSION = "3.2.1-beta.1";
|
|
6874
6858
|
|
|
6875
6859
|
// src/social/index.ts
|
|
6876
6860
|
function initializeSocial(venusApi, host) {
|