@spatius/avatarkit 1.3.5-beta.1 → 1.3.5
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/CHANGELOG.md +7 -0
- package/dist/assets/{OpusDecoderWorker.worker-DkKhJmGs.js → OpusDecoderWorker.worker-BTHlnzwA.js} +8890 -3
- package/dist/assets/{OpusEncoderWorker.worker-Bu8QRO55.js → OpusEncoderWorker.worker-DB_Lvnzc.js} +8890 -3
- package/dist/core/sdk-ref.d.ts +1 -0
- package/dist/index.js +46228 -649
- package/dist/internal-telemetry.js +1 -2
- package/dist/{logger-BCrlTIt2.js → otel-trace-CdspSqI0.js} +5121 -120
- package/dist/{assets/rolldown-runtime-B-1-B7_t.js → rolldown-runtime-FDOR9p9I.js} +1 -10
- package/package.json +1 -1
- package/dist/AvatarDownloader-BLERPef7.js +0 -616
- package/dist/AvatarSDK-DCYDBMwd.js +0 -2048
- package/dist/OpusCodec-BYwstcZb.js +0 -41760
- package/dist/OpusDecoderProxy-DW_SVYwd.js +0 -142
- package/dist/OpusEncoderProxy-CQrj6ZjY.js +0 -170
- package/dist/StreamingAudioPlayer-BORop_1T.js +0 -561
- package/dist/assets/AvatarDownloader-DImd24mo.js +0 -844
- package/dist/assets/AvatarSDK-vQTYP0IB.js +0 -6732
- package/dist/assets/avatar_core_wasm-wdep7Ict.js +0 -2536
- package/dist/assets/logger-CnIdJBOF.js +0 -15542
- package/dist/error-utils-CX5P3vnW.js +0 -85
- package/dist/otel-trace-D2py5nQo.js +0 -5007
- package/dist/pwa-cache-manager-C7su6HpW.js +0 -151
- package/dist/rolldown-runtime-B-1-B7_t.js +0 -33
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { n as __exportAll } from "./rolldown-runtime-B-1-B7_t.js";
|
|
2
|
-
import { t as logger } from "./logger-BCrlTIt2.js";
|
|
3
|
-
//#region utils/pwa-cache-manager.ts
|
|
4
|
-
/**
|
|
5
|
-
* PWA Cache Manager
|
|
6
|
-
* Manages Service Worker Cache for character resources and template resources
|
|
7
|
-
* @internal
|
|
8
|
-
*/
|
|
9
|
-
var pwa_cache_manager_exports = /* @__PURE__ */ __exportAll({ PwaCacheManager: () => PwaCacheManager });
|
|
10
|
-
/**
|
|
11
|
-
* PWA Cache Manager
|
|
12
|
-
* Manages character resources cache (per character) and template resources cache (versioned)
|
|
13
|
-
*/
|
|
14
|
-
var PwaCacheManager = class PwaCacheManager {
|
|
15
|
-
static TEMPLATE_RESOURCE_VERSION = "1.0.0";
|
|
16
|
-
static TEMPLATE_CACHE_NAME = `spatius-sdk-template-cache-${PwaCacheManager.TEMPLATE_RESOURCE_VERSION}`;
|
|
17
|
-
static TEMPLATE_VERSION_STORAGE_KEY = "spatius-sdk-template-cache-version";
|
|
18
|
-
static CHARACTER_CACHE_PREFIX = "spatius-sdk-character-";
|
|
19
|
-
static CHARACTER_CACHE_SUFFIX = "-cache";
|
|
20
|
-
static MAX_CHARACTER_CACHE_ENTRIES = 1e3;
|
|
21
|
-
/**
|
|
22
|
-
* Check if Cache API is supported
|
|
23
|
-
* @internal
|
|
24
|
-
*/
|
|
25
|
-
static isSupported() {
|
|
26
|
-
return typeof caches !== "undefined";
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Get character cache name
|
|
30
|
-
* @internal
|
|
31
|
-
*/
|
|
32
|
-
static getCharacterCacheName(characterId) {
|
|
33
|
-
return `${PwaCacheManager.CHARACTER_CACHE_PREFIX}${characterId}${PwaCacheManager.CHARACTER_CACHE_SUFFIX}`;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Get character resource from cache
|
|
37
|
-
* @internal
|
|
38
|
-
*/
|
|
39
|
-
static async getCharacterResource(characterId, url) {
|
|
40
|
-
if (!PwaCacheManager.isSupported()) return null;
|
|
41
|
-
try {
|
|
42
|
-
const cacheName = PwaCacheManager.getCharacterCacheName(characterId);
|
|
43
|
-
const response = await (await caches.open(cacheName)).match(url);
|
|
44
|
-
if (response) {
|
|
45
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
46
|
-
logger.log(`[PwaCacheManager] Character resource cache hit: ${url}`);
|
|
47
|
-
return arrayBuffer;
|
|
48
|
-
}
|
|
49
|
-
return null;
|
|
50
|
-
} catch (error) {
|
|
51
|
-
logger.warn(`[PwaCacheManager] Failed to get character resource from cache:`, error);
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Put character resource into cache
|
|
57
|
-
* @internal
|
|
58
|
-
*/
|
|
59
|
-
static async putCharacterResource(characterId, url, data) {
|
|
60
|
-
if (!PwaCacheManager.isSupported()) return;
|
|
61
|
-
try {
|
|
62
|
-
const cacheName = PwaCacheManager.getCharacterCacheName(characterId);
|
|
63
|
-
const cache = await caches.open(cacheName);
|
|
64
|
-
const keys = await cache.keys();
|
|
65
|
-
if (keys.length >= PwaCacheManager.MAX_CHARACTER_CACHE_ENTRIES) {
|
|
66
|
-
const oldestKey = keys[0];
|
|
67
|
-
await cache.delete(oldestKey);
|
|
68
|
-
logger.log(`[PwaCacheManager] Character cache full, deleted oldest entry: ${oldestKey.url}`);
|
|
69
|
-
}
|
|
70
|
-
await cache.put(url, new Response(data));
|
|
71
|
-
logger.log(`[PwaCacheManager] Character resource cached: ${url}`);
|
|
72
|
-
} catch (error) {
|
|
73
|
-
logger.warn(`[PwaCacheManager] Failed to put character resource to cache:`, error);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Get template resource from cache
|
|
78
|
-
* @internal
|
|
79
|
-
*/
|
|
80
|
-
static async getTemplateResource(url) {
|
|
81
|
-
if (!PwaCacheManager.isSupported()) return null;
|
|
82
|
-
try {
|
|
83
|
-
const response = await (await caches.open(PwaCacheManager.TEMPLATE_CACHE_NAME)).match(url);
|
|
84
|
-
if (response) {
|
|
85
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
86
|
-
logger.log(`[PwaCacheManager] Template resource cache hit: ${url}`);
|
|
87
|
-
return arrayBuffer;
|
|
88
|
-
}
|
|
89
|
-
return null;
|
|
90
|
-
} catch (error) {
|
|
91
|
-
logger.warn(`[PwaCacheManager] Failed to get template resource from cache:`, error);
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Put template resource into cache
|
|
97
|
-
* Template resources have no quantity limit, permanently retained until version update
|
|
98
|
-
* @internal
|
|
99
|
-
*/
|
|
100
|
-
static async putTemplateResource(url, data) {
|
|
101
|
-
if (!PwaCacheManager.isSupported()) return;
|
|
102
|
-
try {
|
|
103
|
-
await (await caches.open(PwaCacheManager.TEMPLATE_CACHE_NAME)).put(url, new Response(data));
|
|
104
|
-
logger.log(`[PwaCacheManager] Template resource cached: ${url}`);
|
|
105
|
-
} catch (error) {
|
|
106
|
-
logger.warn(`[PwaCacheManager] Failed to put template resource to cache:`, error);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Clear character cache
|
|
111
|
-
* @internal
|
|
112
|
-
*/
|
|
113
|
-
static async clearCharacterCache(characterId) {
|
|
114
|
-
if (!PwaCacheManager.isSupported()) return;
|
|
115
|
-
try {
|
|
116
|
-
const cacheName = PwaCacheManager.getCharacterCacheName(characterId);
|
|
117
|
-
await caches.delete(cacheName);
|
|
118
|
-
logger.log(`[PwaCacheManager] Character cache cleared: ${characterId}`);
|
|
119
|
-
} catch (error) {
|
|
120
|
-
logger.warn(`[PwaCacheManager] Failed to clear character cache:`, error);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Check template cache version, clear cache if version changed
|
|
125
|
-
* Uses independent template resource version (not dependent on SDK version), allowing different SDK versions to share the same template resource cache
|
|
126
|
-
* @returns true if version changed and cache was cleared, false otherwise
|
|
127
|
-
* @internal
|
|
128
|
-
*/
|
|
129
|
-
static async checkTemplateCacheVersion() {
|
|
130
|
-
if (!PwaCacheManager.isSupported()) return false;
|
|
131
|
-
try {
|
|
132
|
-
const currentTemplateVersion = PwaCacheManager.TEMPLATE_RESOURCE_VERSION;
|
|
133
|
-
const storedVersion = localStorage.getItem(PwaCacheManager.TEMPLATE_VERSION_STORAGE_KEY);
|
|
134
|
-
if (storedVersion !== currentTemplateVersion) {
|
|
135
|
-
if (storedVersion) {
|
|
136
|
-
const oldCacheName = `spatius-sdk-template-cache-${storedVersion}`;
|
|
137
|
-
await caches.delete(oldCacheName).catch(() => {});
|
|
138
|
-
}
|
|
139
|
-
localStorage.setItem(PwaCacheManager.TEMPLATE_VERSION_STORAGE_KEY, currentTemplateVersion);
|
|
140
|
-
logger.log(`[PwaCacheManager] Template cache version changed: ${storedVersion} -> ${currentTemplateVersion}, old cache cleared`);
|
|
141
|
-
return true;
|
|
142
|
-
}
|
|
143
|
-
return false;
|
|
144
|
-
} catch (error) {
|
|
145
|
-
logger.warn(`[PwaCacheManager] Failed to check template cache version:`, error);
|
|
146
|
-
return false;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
//#endregion
|
|
151
|
-
export { pwa_cache_manager_exports as n, PwaCacheManager as t };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
9
|
-
var __exportAll = (all, no_symbols) => {
|
|
10
|
-
let target = {};
|
|
11
|
-
for (var name in all) __defProp(target, name, {
|
|
12
|
-
get: all[name],
|
|
13
|
-
enumerable: true
|
|
14
|
-
});
|
|
15
|
-
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
16
|
-
return target;
|
|
17
|
-
};
|
|
18
|
-
var __copyProps = (to, from, except, desc) => {
|
|
19
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
20
|
-
key = keys[i];
|
|
21
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
22
|
-
get: ((k) => from[k]).bind(null, key),
|
|
23
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
return to;
|
|
27
|
-
};
|
|
28
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
29
|
-
value: mod,
|
|
30
|
-
enumerable: true
|
|
31
|
-
}) : target, mod));
|
|
32
|
-
//#endregion
|
|
33
|
-
export { __exportAll as n, __toESM as r, __commonJSMin as t };
|