@asiyst/sdk 0.1.25 → 0.1.27
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/index.cjs +445 -82
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +445 -82
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -97,7 +97,7 @@ var ALL_ACTION_KINDS = [
|
|
|
97
97
|
// src/core/constants.ts
|
|
98
98
|
function resolveSdkVersion() {
|
|
99
99
|
{
|
|
100
|
-
return "0.1.
|
|
100
|
+
return "0.1.26";
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
var SDK_VERSION = resolveSdkVersion();
|
|
@@ -114,7 +114,8 @@ var VIEWPORT_HANDLER_THROTTLE_MS = 80;
|
|
|
114
114
|
var AVATAR_VIEWPORT_PADDING = 12;
|
|
115
115
|
var AVATAR_TARGET_GAP = 16;
|
|
116
116
|
var WEBSITE_MAP_TEXT_LIMIT = 80;
|
|
117
|
-
var CONFIG_CACHE_TTL_MS = 1e3 *
|
|
117
|
+
var CONFIG_CACHE_TTL_MS = 1e3 * 30;
|
|
118
|
+
var CONFIG_REVALIDATION_INTERVAL_MS = 3e4;
|
|
118
119
|
var HEARTBEAT_INTERVAL_MS = 45e3;
|
|
119
120
|
|
|
120
121
|
// src/security/selectors.ts
|
|
@@ -1060,7 +1061,7 @@ var ConfigCache = class {
|
|
|
1060
1061
|
constructor(storage) {
|
|
1061
1062
|
this.storage = storage;
|
|
1062
1063
|
}
|
|
1063
|
-
read(projectId) {
|
|
1064
|
+
read(projectId, ignoreTtl = false) {
|
|
1064
1065
|
const raw = this.storage.read("config");
|
|
1065
1066
|
if (!raw) {
|
|
1066
1067
|
return null;
|
|
@@ -1070,7 +1071,7 @@ var ConfigCache = class {
|
|
|
1070
1071
|
if (parsed.schemaVersion !== CONFIG_SCHEMA_VERSION || parsed.projectId !== projectId) {
|
|
1071
1072
|
return null;
|
|
1072
1073
|
}
|
|
1073
|
-
if (Date.now() - parsed.fetchedAt > CONFIG_CACHE_TTL_MS) {
|
|
1074
|
+
if (!ignoreTtl && Date.now() - parsed.fetchedAt > CONFIG_CACHE_TTL_MS) {
|
|
1074
1075
|
return null;
|
|
1075
1076
|
}
|
|
1076
1077
|
return normalizeProjectConfig(parsed.config);
|
|
@@ -1078,15 +1079,35 @@ var ConfigCache = class {
|
|
|
1078
1079
|
return null;
|
|
1079
1080
|
}
|
|
1080
1081
|
}
|
|
1081
|
-
|
|
1082
|
+
getEnvelope(projectId) {
|
|
1083
|
+
const raw = this.storage.read("config");
|
|
1084
|
+
if (!raw) {
|
|
1085
|
+
return null;
|
|
1086
|
+
}
|
|
1087
|
+
try {
|
|
1088
|
+
const parsed = JSON.parse(raw);
|
|
1089
|
+
if (parsed.schemaVersion !== CONFIG_SCHEMA_VERSION || parsed.projectId !== projectId) {
|
|
1090
|
+
return null;
|
|
1091
|
+
}
|
|
1092
|
+
return parsed;
|
|
1093
|
+
} catch {
|
|
1094
|
+
return null;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
write(projectId, config, meta) {
|
|
1082
1098
|
const envelope = {
|
|
1083
1099
|
schemaVersion: CONFIG_SCHEMA_VERSION,
|
|
1084
1100
|
projectId,
|
|
1085
1101
|
fetchedAt: Date.now(),
|
|
1102
|
+
etag: meta?.etag,
|
|
1103
|
+
revision: meta?.revision ?? config.version,
|
|
1086
1104
|
config
|
|
1087
1105
|
};
|
|
1088
1106
|
this.storage.write("config", JSON.stringify(envelope));
|
|
1089
1107
|
}
|
|
1108
|
+
clear() {
|
|
1109
|
+
this.storage.remove("config");
|
|
1110
|
+
}
|
|
1090
1111
|
};
|
|
1091
1112
|
|
|
1092
1113
|
// src/config/ConfigManager.ts
|
|
@@ -1095,6 +1116,7 @@ var ConfigManager = class {
|
|
|
1095
1116
|
this.options = options;
|
|
1096
1117
|
this.cloud = cloud;
|
|
1097
1118
|
this.events = events;
|
|
1119
|
+
this.inFlightRefresh = null;
|
|
1098
1120
|
const credentials = validateInitOptions(options);
|
|
1099
1121
|
this.options = { ...options, ...credentials };
|
|
1100
1122
|
this.cache = new ConfigCache(
|
|
@@ -1106,13 +1128,34 @@ var ConfigManager = class {
|
|
|
1106
1128
|
get() {
|
|
1107
1129
|
return this.current;
|
|
1108
1130
|
}
|
|
1109
|
-
async refresh() {
|
|
1131
|
+
async refresh(options) {
|
|
1132
|
+
if (this.inFlightRefresh) {
|
|
1133
|
+
return this.inFlightRefresh;
|
|
1134
|
+
}
|
|
1135
|
+
this.inFlightRefresh = this.executeRefresh(options);
|
|
1136
|
+
try {
|
|
1137
|
+
return await this.inFlightRefresh;
|
|
1138
|
+
} finally {
|
|
1139
|
+
this.inFlightRefresh = null;
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
async executeRefresh(_options) {
|
|
1143
|
+
const prev = this.current;
|
|
1110
1144
|
try {
|
|
1111
1145
|
const remote = await this.cloud.fetchConfig();
|
|
1112
|
-
|
|
1113
|
-
this.
|
|
1146
|
+
const normalized = normalizeProjectConfig(remote);
|
|
1147
|
+
this.current = normalized;
|
|
1148
|
+
this.cache.write(this.options.projectId, normalized);
|
|
1149
|
+
const hasChanged = prev.version !== normalized.version || prev.avatarName !== normalized.avatarName || prev.position !== normalized.position || prev.size !== normalized.size || prev.assetUrl !== normalized.assetUrl || prev.thumbnailUrl !== normalized.thumbnailUrl || JSON.stringify(prev.theme) !== JSON.stringify(normalized.theme) || JSON.stringify(prev.animations) !== JSON.stringify(normalized.animations);
|
|
1150
|
+
if (hasChanged && this.onConfigUpdated) {
|
|
1151
|
+
this.onConfigUpdated(normalized, prev);
|
|
1152
|
+
}
|
|
1114
1153
|
return this.current;
|
|
1115
1154
|
} catch (error) {
|
|
1155
|
+
const lastKnownGood = this.cache.read(this.options.projectId, true);
|
|
1156
|
+
if (lastKnownGood) {
|
|
1157
|
+
this.current = lastKnownGood;
|
|
1158
|
+
}
|
|
1116
1159
|
this.events.emit("asiyst:error", {
|
|
1117
1160
|
code: "config_refresh_failed",
|
|
1118
1161
|
message: error instanceof Error ? error.message : "Failed to refresh configuration"
|
|
@@ -1120,6 +1163,18 @@ var ConfigManager = class {
|
|
|
1120
1163
|
return this.current;
|
|
1121
1164
|
}
|
|
1122
1165
|
}
|
|
1166
|
+
applyLocalUpdate(partial) {
|
|
1167
|
+
const prev = this.current;
|
|
1168
|
+
this.current = {
|
|
1169
|
+
...this.current,
|
|
1170
|
+
...partial
|
|
1171
|
+
};
|
|
1172
|
+
this.cache.write(this.options.projectId, this.current);
|
|
1173
|
+
if (this.onConfigUpdated) {
|
|
1174
|
+
this.onConfigUpdated(this.current, prev);
|
|
1175
|
+
}
|
|
1176
|
+
return this.current;
|
|
1177
|
+
}
|
|
1123
1178
|
localFallback() {
|
|
1124
1179
|
const base = fallbackConfig();
|
|
1125
1180
|
return {
|
|
@@ -1778,13 +1833,34 @@ var AssetLoader = class {
|
|
|
1778
1833
|
constructor() {
|
|
1779
1834
|
this.inFlightController = null;
|
|
1780
1835
|
this.createdObjectUrls = [];
|
|
1836
|
+
this.inFlightLoads = /* @__PURE__ */ new Map();
|
|
1837
|
+
this.cachedAssets = /* @__PURE__ */ new Map();
|
|
1781
1838
|
}
|
|
1782
1839
|
async load(assetUrl, options) {
|
|
1783
|
-
const startTime = Date.now();
|
|
1784
1840
|
const sanitizedUrl = sanitizeText(assetUrl.trim(), 2048);
|
|
1785
1841
|
if (!sanitizedUrl) {
|
|
1786
1842
|
throw new Error("Asset URL is required");
|
|
1787
1843
|
}
|
|
1844
|
+
const cached = this.cachedAssets.get(sanitizedUrl);
|
|
1845
|
+
if (cached) {
|
|
1846
|
+
return cached;
|
|
1847
|
+
}
|
|
1848
|
+
const inFlight = this.inFlightLoads.get(sanitizedUrl);
|
|
1849
|
+
if (inFlight) {
|
|
1850
|
+
return inFlight;
|
|
1851
|
+
}
|
|
1852
|
+
const loadPromise = this.performLoad(sanitizedUrl, options);
|
|
1853
|
+
this.inFlightLoads.set(sanitizedUrl, loadPromise);
|
|
1854
|
+
try {
|
|
1855
|
+
const asset = await loadPromise;
|
|
1856
|
+
this.cachedAssets.set(sanitizedUrl, asset);
|
|
1857
|
+
return asset;
|
|
1858
|
+
} finally {
|
|
1859
|
+
this.inFlightLoads.delete(sanitizedUrl);
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
async performLoad(sanitizedUrl, options) {
|
|
1863
|
+
const startTime = Date.now();
|
|
1788
1864
|
this.inFlightController = new AbortController();
|
|
1789
1865
|
const abortSignal = options?.signal ? anySignal([this.inFlightController.signal, options.signal]) : this.inFlightController.signal;
|
|
1790
1866
|
const timeoutMs = options?.timeoutMs ?? 6e4;
|
|
@@ -1827,6 +1903,9 @@ var AssetLoader = class {
|
|
|
1827
1903
|
throw new Error(`Avatar asset download failed: HTTP ${response.status} from ${sanitizedUrl}`);
|
|
1828
1904
|
}
|
|
1829
1905
|
const contentType = (response.headers.get("content-type") || "").toLowerCase();
|
|
1906
|
+
if (contentType.includes("text/html")) {
|
|
1907
|
+
throw new Error(`Avatar asset request returned HTML instead of 3D asset from ${sanitizedUrl}`);
|
|
1908
|
+
}
|
|
1830
1909
|
if (isJsonExtension || contentType.includes("application/json")) {
|
|
1831
1910
|
const text = await response.text();
|
|
1832
1911
|
let manifest;
|
|
@@ -1860,6 +1939,11 @@ var AssetLoader = class {
|
|
|
1860
1939
|
if (arrayBuffer.byteLength < 12) {
|
|
1861
1940
|
throw new Error("Avatar asset payload is too small to be a valid 3D container");
|
|
1862
1941
|
}
|
|
1942
|
+
const headerBytes = new Uint8Array(arrayBuffer, 0, Math.min(256, arrayBuffer.byteLength));
|
|
1943
|
+
const headerStr = new TextDecoder("utf-8", { fatal: false }).decode(headerBytes).trim();
|
|
1944
|
+
if (/^<!DOCTYPE\s+html/i.test(headerStr) || /^<html/i.test(headerStr)) {
|
|
1945
|
+
throw new Error(`Avatar asset payload contains HTML error page instead of binary 3D container from ${sanitizedUrl}`);
|
|
1946
|
+
}
|
|
1863
1947
|
if (isFbxExtension || this.isFbxBuffer(arrayBuffer) || !isGlbExtension && !this.isGlbBuffer(arrayBuffer)) {
|
|
1864
1948
|
const fbxHeader = this.parseFbxHeader(arrayBuffer);
|
|
1865
1949
|
const resourcePath = sanitizedUrl.includes("/") ? sanitizedUrl.substring(0, sanitizedUrl.lastIndexOf("/") + 1) : "";
|
|
@@ -2105,6 +2189,8 @@ var AssetLoader = class {
|
|
|
2105
2189
|
this.inFlightController.abort();
|
|
2106
2190
|
this.inFlightController = null;
|
|
2107
2191
|
}
|
|
2192
|
+
this.inFlightLoads.clear();
|
|
2193
|
+
this.cachedAssets.clear();
|
|
2108
2194
|
if (typeof URL !== "undefined" && typeof URL.revokeObjectURL === "function") {
|
|
2109
2195
|
for (const objUrl of this.createdObjectUrls) {
|
|
2110
2196
|
try {
|
|
@@ -2134,8 +2220,11 @@ var FbxRenderer = class {
|
|
|
2134
2220
|
this.scene = null;
|
|
2135
2221
|
this.camera = null;
|
|
2136
2222
|
this.modelRoot = null;
|
|
2223
|
+
this.rawObject = null;
|
|
2137
2224
|
this.mixer = null;
|
|
2138
2225
|
this.allAnimations = [];
|
|
2226
|
+
this.animationMetadataList = [];
|
|
2227
|
+
this.assetLoader = new AssetLoader();
|
|
2139
2228
|
this.currentAction = null;
|
|
2140
2229
|
this.animFrameId = null;
|
|
2141
2230
|
this.lastTime = 0;
|
|
@@ -2151,6 +2240,8 @@ var FbxRenderer = class {
|
|
|
2151
2240
|
this.canvas = doc.createElement("canvas");
|
|
2152
2241
|
this.canvas.className = "asiyst-avatar-canvas";
|
|
2153
2242
|
this.canvas.setAttribute("role", "presentation");
|
|
2243
|
+
this.canvas.style.opacity = "0";
|
|
2244
|
+
this.canvas.style.transition = "opacity 0.25s ease";
|
|
2154
2245
|
const glContext = this.canvas.getContext("webgl2") || this.canvas.getContext("webgl");
|
|
2155
2246
|
if (!glContext) {
|
|
2156
2247
|
throw new Error("WebGLRenderingContext is not available or supported in this browser environment");
|
|
@@ -2264,9 +2355,10 @@ var FbxRenderer = class {
|
|
|
2264
2355
|
mesh.receiveShadow = true;
|
|
2265
2356
|
}
|
|
2266
2357
|
});
|
|
2267
|
-
this.
|
|
2358
|
+
this.rawObject = rawObject;
|
|
2359
|
+
this.mixer = new THREE__namespace.AnimationMixer(rawObject);
|
|
2360
|
+
this.allAnimations = [...modelAnimations];
|
|
2268
2361
|
if (modelAnimations.length > 0) {
|
|
2269
|
-
this.mixer = new THREE__namespace.AnimationMixer(rawObject);
|
|
2270
2362
|
const idleClip = modelAnimations.find((c) => c.name.toLowerCase().includes("idle")) || modelAnimations[0];
|
|
2271
2363
|
if (idleClip) {
|
|
2272
2364
|
this.currentAction = this.mixer.clipAction(idleClip);
|
|
@@ -2278,6 +2370,9 @@ var FbxRenderer = class {
|
|
|
2278
2370
|
try {
|
|
2279
2371
|
this.renderer.render(this.scene, this.camera);
|
|
2280
2372
|
this.initialRenderCompleted = true;
|
|
2373
|
+
if (this.canvas) {
|
|
2374
|
+
this.canvas.style.opacity = "1";
|
|
2375
|
+
}
|
|
2281
2376
|
} catch (renderErr) {
|
|
2282
2377
|
const msg = renderErr instanceof Error ? renderErr.message : String(renderErr);
|
|
2283
2378
|
throw new Error(`Initial FBX WebGL render failed: ${msg}`);
|
|
@@ -2285,6 +2380,9 @@ var FbxRenderer = class {
|
|
|
2285
2380
|
this.startLoop();
|
|
2286
2381
|
this.setFacing(this.facing);
|
|
2287
2382
|
this.setPose(this.currentPose);
|
|
2383
|
+
if (options?.config?.animations && options.config.animations.length > 0) {
|
|
2384
|
+
void this.loadExternalAnimations(options.config.animations);
|
|
2385
|
+
}
|
|
2288
2386
|
if (typeof window !== "undefined") {
|
|
2289
2387
|
this.resizeListener = () => this.handleResize();
|
|
2290
2388
|
window.addEventListener("resize", this.resizeListener);
|
|
@@ -2304,6 +2402,9 @@ var FbxRenderer = class {
|
|
|
2304
2402
|
setPose(pose) {
|
|
2305
2403
|
this.currentPose = pose;
|
|
2306
2404
|
if (!this.modelRoot) return;
|
|
2405
|
+
if (this.playAnimation(pose)) {
|
|
2406
|
+
return;
|
|
2407
|
+
}
|
|
2307
2408
|
if (this.mixer && this.allAnimations.length > 1) {
|
|
2308
2409
|
let targetClip;
|
|
2309
2410
|
if (pose === "speak") {
|
|
@@ -2354,6 +2455,135 @@ var FbxRenderer = class {
|
|
|
2354
2455
|
break;
|
|
2355
2456
|
}
|
|
2356
2457
|
}
|
|
2458
|
+
async loadExternalAnimations(animations) {
|
|
2459
|
+
if (!this.rawObject || !this.mixer) return;
|
|
2460
|
+
for (const anim of animations) {
|
|
2461
|
+
if (!anim.assetUrl) continue;
|
|
2462
|
+
try {
|
|
2463
|
+
const loaded = await this.assetLoader.load(anim.assetUrl);
|
|
2464
|
+
let extractedClips = [];
|
|
2465
|
+
if (loaded.format === "fbx") {
|
|
2466
|
+
const loader = new FBXLoader_js.FBXLoader();
|
|
2467
|
+
if (loaded.resourcePath) {
|
|
2468
|
+
loader.setResourcePath(loaded.resourcePath);
|
|
2469
|
+
}
|
|
2470
|
+
const parsed = loader.parse(loaded.buffer, loaded.resourcePath || "");
|
|
2471
|
+
extractedClips = parsed.animations || [];
|
|
2472
|
+
} else if (loaded.format === "glb") {
|
|
2473
|
+
const loader = new GLTFLoader_js.GLTFLoader();
|
|
2474
|
+
const gltf = await new Promise((resolve, reject) => {
|
|
2475
|
+
const glbBuffer = loaded.bin.buffer.slice(
|
|
2476
|
+
loaded.bin.byteOffset,
|
|
2477
|
+
loaded.bin.byteOffset + loaded.bin.byteLength
|
|
2478
|
+
);
|
|
2479
|
+
loader.parse(glbBuffer, loaded.url, resolve, reject);
|
|
2480
|
+
});
|
|
2481
|
+
extractedClips = gltf.animations || [];
|
|
2482
|
+
}
|
|
2483
|
+
for (const rawClip of extractedClips) {
|
|
2484
|
+
const retargeted = this.retargetClip(rawClip, this.rawObject);
|
|
2485
|
+
if (!retargeted) continue;
|
|
2486
|
+
retargeted.name = anim.clipName || anim.name || rawClip.name;
|
|
2487
|
+
this.allAnimations.push(retargeted);
|
|
2488
|
+
this.animationMetadataList.push({
|
|
2489
|
+
id: anim.id,
|
|
2490
|
+
name: anim.name,
|
|
2491
|
+
intent: anim.intent,
|
|
2492
|
+
clipName: anim.clipName,
|
|
2493
|
+
loopMode: anim.loopMode,
|
|
2494
|
+
clip: retargeted
|
|
2495
|
+
});
|
|
2496
|
+
const animIntent = anim.intent?.toLowerCase();
|
|
2497
|
+
const animName = anim.name.toLowerCase();
|
|
2498
|
+
if (animIntent === this.currentPose || this.currentPose === "idle" && (animIntent === "idle" || animName === "idle")) {
|
|
2499
|
+
this.playAnimation(anim.id || anim.name || this.currentPose, anim.loopMode);
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2502
|
+
} catch (err) {
|
|
2503
|
+
if (typeof console !== "undefined" && typeof console.warn === "function") {
|
|
2504
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
2505
|
+
console.warn(`[asiyst] Failed to load external animation "${anim.name}": ${msg}`);
|
|
2506
|
+
}
|
|
2507
|
+
}
|
|
2508
|
+
}
|
|
2509
|
+
}
|
|
2510
|
+
retargetClip(clip, targetObject) {
|
|
2511
|
+
const targetNodeNames = /* @__PURE__ */ new Set();
|
|
2512
|
+
const boneMap = /* @__PURE__ */ new Map();
|
|
2513
|
+
targetObject.traverse((node) => {
|
|
2514
|
+
if (node.name) {
|
|
2515
|
+
targetNodeNames.add(node.name);
|
|
2516
|
+
const clean = node.name.replace(/^.*[:|/]/, "").toLowerCase();
|
|
2517
|
+
boneMap.set(clean, node.name);
|
|
2518
|
+
boneMap.set(node.name.toLowerCase(), node.name);
|
|
2519
|
+
}
|
|
2520
|
+
});
|
|
2521
|
+
const validTracks = [];
|
|
2522
|
+
for (const track of clip.tracks) {
|
|
2523
|
+
const dotIdx = track.name.lastIndexOf(".");
|
|
2524
|
+
if (dotIdx === -1) continue;
|
|
2525
|
+
const nodePart = track.name.substring(0, dotIdx);
|
|
2526
|
+
const propPart = track.name.substring(dotIdx);
|
|
2527
|
+
if (targetNodeNames.has(nodePart)) {
|
|
2528
|
+
validTracks.push(track);
|
|
2529
|
+
} else {
|
|
2530
|
+
const clean = nodePart.replace(/^.*[:|/]/, "").toLowerCase();
|
|
2531
|
+
const matched = boneMap.get(clean);
|
|
2532
|
+
if (matched) {
|
|
2533
|
+
const clonedTrack = track.clone();
|
|
2534
|
+
clonedTrack.name = `${matched}${propPart}`;
|
|
2535
|
+
validTracks.push(clonedTrack);
|
|
2536
|
+
}
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
if (validTracks.length === 0) {
|
|
2540
|
+
return null;
|
|
2541
|
+
}
|
|
2542
|
+
return new THREE__namespace.AnimationClip(clip.name, clip.duration, validTracks);
|
|
2543
|
+
}
|
|
2544
|
+
playAnimation(nameOrIntent, loopMode, crossFadeDuration = 0.25) {
|
|
2545
|
+
if (!this.mixer) return false;
|
|
2546
|
+
const query = nameOrIntent.trim().toLowerCase();
|
|
2547
|
+
if (!query) return false;
|
|
2548
|
+
let matched = this.animationMetadataList.find((m) => m.id && m.id.toLowerCase() === query);
|
|
2549
|
+
if (!matched) {
|
|
2550
|
+
matched = this.animationMetadataList.find((m) => m.intent && m.intent.toLowerCase() === query);
|
|
2551
|
+
}
|
|
2552
|
+
if (!matched) {
|
|
2553
|
+
matched = this.animationMetadataList.find((m) => m.name && m.name.toLowerCase() === query);
|
|
2554
|
+
}
|
|
2555
|
+
if (!matched) {
|
|
2556
|
+
matched = this.animationMetadataList.find((m) => m.clipName && m.clipName.toLowerCase() === query);
|
|
2557
|
+
}
|
|
2558
|
+
let clip = matched?.clip;
|
|
2559
|
+
if (!clip) {
|
|
2560
|
+
clip = this.allAnimations.find((c) => c.name.toLowerCase() === query);
|
|
2561
|
+
}
|
|
2562
|
+
if (!clip) {
|
|
2563
|
+
clip = this.allAnimations.find((c) => c.name.toLowerCase().includes(query));
|
|
2564
|
+
}
|
|
2565
|
+
if (!clip) {
|
|
2566
|
+
return false;
|
|
2567
|
+
}
|
|
2568
|
+
const action = this.mixer.clipAction(clip);
|
|
2569
|
+
const effectiveLoop = loopMode || matched?.loopMode || "repeat";
|
|
2570
|
+
if (effectiveLoop === "once") {
|
|
2571
|
+
action.setLoop(THREE__namespace.LoopOnce, 1);
|
|
2572
|
+
action.clampWhenFinished = true;
|
|
2573
|
+
} else if (effectiveLoop === "pingpong") {
|
|
2574
|
+
action.setLoop(THREE__namespace.LoopPingPong, Infinity);
|
|
2575
|
+
} else {
|
|
2576
|
+
action.setLoop(THREE__namespace.LoopRepeat, Infinity);
|
|
2577
|
+
}
|
|
2578
|
+
if (this.currentAction !== action) {
|
|
2579
|
+
action.reset().fadeIn(crossFadeDuration).play();
|
|
2580
|
+
if (this.currentAction) {
|
|
2581
|
+
this.currentAction.fadeOut(crossFadeDuration);
|
|
2582
|
+
}
|
|
2583
|
+
this.currentAction = action;
|
|
2584
|
+
}
|
|
2585
|
+
return true;
|
|
2586
|
+
}
|
|
2357
2587
|
isRendered() {
|
|
2358
2588
|
return this.initialRenderCompleted;
|
|
2359
2589
|
}
|
|
@@ -2440,6 +2670,11 @@ var FbxRenderer = class {
|
|
|
2440
2670
|
this.canvas.remove();
|
|
2441
2671
|
this.canvas = null;
|
|
2442
2672
|
}
|
|
2673
|
+
this.assetLoader.destroy();
|
|
2674
|
+
this.animationMetadataList.length = 0;
|
|
2675
|
+
this.allAnimations = [];
|
|
2676
|
+
this.currentAction = null;
|
|
2677
|
+
this.rawObject = null;
|
|
2443
2678
|
this.camera = null;
|
|
2444
2679
|
this.modelRoot = null;
|
|
2445
2680
|
this.initialRenderCompleted = false;
|
|
@@ -2541,13 +2776,23 @@ var AVATAR_CSS = `
|
|
|
2541
2776
|
pointer-events: none;
|
|
2542
2777
|
}
|
|
2543
2778
|
.asiyst-avatar-loader {
|
|
2544
|
-
width:
|
|
2545
|
-
height:
|
|
2546
|
-
border: 3px solid rgba(
|
|
2547
|
-
border-top-color: #
|
|
2779
|
+
width: 34px;
|
|
2780
|
+
height: 34px;
|
|
2781
|
+
border: 3px solid rgba(37, 99, 235, 0.2);
|
|
2782
|
+
border-top-color: #2563eb;
|
|
2548
2783
|
border-radius: 50%;
|
|
2549
2784
|
animation: asiyst-spin 0.8s linear infinite;
|
|
2550
2785
|
}
|
|
2786
|
+
.asiyst-avatar-loading-silhouette {
|
|
2787
|
+
display: flex;
|
|
2788
|
+
flex-direction: column;
|
|
2789
|
+
align-items: center;
|
|
2790
|
+
justify-content: center;
|
|
2791
|
+
width: 100%;
|
|
2792
|
+
height: 100%;
|
|
2793
|
+
min-height: 240px;
|
|
2794
|
+
pointer-events: none;
|
|
2795
|
+
}
|
|
2551
2796
|
@keyframes asiyst-spin {
|
|
2552
2797
|
to { transform: rotate(360deg); }
|
|
2553
2798
|
}
|
|
@@ -2662,12 +2907,13 @@ var CssAvatarRenderer = class {
|
|
|
2662
2907
|
this.accentColor = "#2563eb";
|
|
2663
2908
|
this.avatarName = "Asiyst";
|
|
2664
2909
|
this.isPanelOpen = false;
|
|
2910
|
+
this.has3dAssetConfigured = false;
|
|
2665
2911
|
// Asset loading & rendering state
|
|
2666
2912
|
this.assetLoader = new AssetLoader();
|
|
2667
2913
|
this.fbxRenderer = null;
|
|
2668
2914
|
this.renderState = "idle";
|
|
2669
2915
|
this.isAssetLoadedFlag = false;
|
|
2670
|
-
this.isFallbackFlag =
|
|
2916
|
+
this.isFallbackFlag = false;
|
|
2671
2917
|
}
|
|
2672
2918
|
mount(container, config) {
|
|
2673
2919
|
const doc = container.ownerDocument;
|
|
@@ -2739,6 +2985,11 @@ var CssAvatarRenderer = class {
|
|
|
2739
2985
|
this.size = config.size;
|
|
2740
2986
|
this.accentColor = config.theme.accent ?? "#2563eb";
|
|
2741
2987
|
this.avatarName = config.avatarName;
|
|
2988
|
+
const has3dAsset = Boolean(config.assetUrl || config.thumbnailUrl);
|
|
2989
|
+
this.has3dAssetConfigured = has3dAsset;
|
|
2990
|
+
if (config.assetUrl || config.thumbnailUrl) {
|
|
2991
|
+
this.activeAssetUrl = config.assetUrl ?? config.thumbnailUrl ?? void 0;
|
|
2992
|
+
}
|
|
2742
2993
|
if (this.nameTextEl) {
|
|
2743
2994
|
renderSafeText(this.nameTextEl, config.avatarName);
|
|
2744
2995
|
}
|
|
@@ -2751,7 +3002,24 @@ var CssAvatarRenderer = class {
|
|
|
2751
3002
|
if (this.root) {
|
|
2752
3003
|
this.root.setAttribute("aria-label", config.avatarName);
|
|
2753
3004
|
}
|
|
2754
|
-
if (
|
|
3005
|
+
if (has3dAsset) {
|
|
3006
|
+
if (this.figure) {
|
|
3007
|
+
this.figure.classList.add("asiyst-3d-active");
|
|
3008
|
+
this.figure.style.width = "";
|
|
3009
|
+
this.figure.style.height = "";
|
|
3010
|
+
this.figure.style.background = "transparent";
|
|
3011
|
+
}
|
|
3012
|
+
if (this.chatActionBtn) {
|
|
3013
|
+
this.chatActionBtn.style.display = this.isAssetLoadedFlag && !this.isPanelOpen ? "inline-flex" : "none";
|
|
3014
|
+
}
|
|
3015
|
+
if (!this.isAssetLoadedFlag && this.viewport) {
|
|
3016
|
+
if (this.renderState === "error") {
|
|
3017
|
+
this.renderFallback(true);
|
|
3018
|
+
} else {
|
|
3019
|
+
this.renderLoader();
|
|
3020
|
+
}
|
|
3021
|
+
}
|
|
3022
|
+
} else {
|
|
2755
3023
|
if (this.figure) {
|
|
2756
3024
|
this.figure.classList.remove("asiyst-3d-active");
|
|
2757
3025
|
this.figure.style.width = `${config.size}px`;
|
|
@@ -2761,16 +3029,9 @@ var CssAvatarRenderer = class {
|
|
|
2761
3029
|
if (this.chatActionBtn) {
|
|
2762
3030
|
this.chatActionBtn.style.display = "none";
|
|
2763
3031
|
}
|
|
2764
|
-
if (this.viewport) {
|
|
3032
|
+
if (this.viewport && !this.isAssetLoadedFlag) {
|
|
2765
3033
|
this.renderFallback();
|
|
2766
3034
|
}
|
|
2767
|
-
} else {
|
|
2768
|
-
if (this.figure) {
|
|
2769
|
-
this.figure.classList.add("asiyst-3d-active");
|
|
2770
|
-
}
|
|
2771
|
-
if (this.chatActionBtn) {
|
|
2772
|
-
this.chatActionBtn.style.display = this.isPanelOpen ? "none" : "inline-flex";
|
|
2773
|
-
}
|
|
2774
3035
|
}
|
|
2775
3036
|
}
|
|
2776
3037
|
setPanelOpen(open) {
|
|
@@ -2789,11 +3050,16 @@ var CssAvatarRenderer = class {
|
|
|
2789
3050
|
return false;
|
|
2790
3051
|
}
|
|
2791
3052
|
this.activeAssetUrl = assetUrl;
|
|
3053
|
+
this.has3dAssetConfigured = true;
|
|
2792
3054
|
this.renderState = "loading";
|
|
2793
3055
|
this.isFallbackFlag = false;
|
|
2794
3056
|
this.lastErrorMessage = void 0;
|
|
2795
3057
|
if (this.figure) {
|
|
2796
3058
|
this.figure.setAttribute("data-state", "loading");
|
|
3059
|
+
this.figure.classList.add("asiyst-3d-active");
|
|
3060
|
+
this.figure.style.width = "";
|
|
3061
|
+
this.figure.style.height = "";
|
|
3062
|
+
this.figure.style.background = "transparent";
|
|
2797
3063
|
}
|
|
2798
3064
|
this.renderLoader();
|
|
2799
3065
|
try {
|
|
@@ -2822,10 +3088,6 @@ var CssAvatarRenderer = class {
|
|
|
2822
3088
|
this.isFallbackFlag = true;
|
|
2823
3089
|
if (this.figure) {
|
|
2824
3090
|
this.figure.setAttribute("data-state", "error");
|
|
2825
|
-
this.figure.classList.remove("asiyst-3d-active");
|
|
2826
|
-
this.figure.style.width = `${this.size}px`;
|
|
2827
|
-
this.figure.style.height = `${this.size}px`;
|
|
2828
|
-
this.figure.style.background = this.accentColor;
|
|
2829
3091
|
}
|
|
2830
3092
|
if (this.chatActionBtn) {
|
|
2831
3093
|
this.chatActionBtn.style.display = "none";
|
|
@@ -2838,10 +3100,13 @@ var CssAvatarRenderer = class {
|
|
|
2838
3100
|
if (!this.viewport) return;
|
|
2839
3101
|
this.viewport.replaceChildren();
|
|
2840
3102
|
const doc = this.viewport.ownerDocument;
|
|
3103
|
+
const container = doc.createElement("div");
|
|
3104
|
+
container.className = "asiyst-avatar-loading-silhouette";
|
|
2841
3105
|
const loader = doc.createElement("div");
|
|
2842
3106
|
loader.className = "asiyst-avatar-loader";
|
|
2843
3107
|
loader.setAttribute("aria-label", `Loading ${this.avatarName}`);
|
|
2844
|
-
|
|
3108
|
+
container.appendChild(loader);
|
|
3109
|
+
this.viewport.appendChild(container);
|
|
2845
3110
|
}
|
|
2846
3111
|
async renderLoadedAsset(asset, config) {
|
|
2847
3112
|
if (!this.viewport) return;
|
|
@@ -2947,12 +3212,15 @@ var CssAvatarRenderer = class {
|
|
|
2947
3212
|
renderSafeText(this.bubble, text);
|
|
2948
3213
|
}
|
|
2949
3214
|
getSize() {
|
|
2950
|
-
if (this.isAssetLoadedFlag
|
|
3215
|
+
if (this.isAssetLoadedFlag || this.has3dAssetConfigured) {
|
|
2951
3216
|
const isMobile = typeof window !== "undefined" && window.innerWidth <= 640;
|
|
2952
3217
|
return { width: isMobile ? 180 : 240, height: isMobile ? 390 : 490 };
|
|
2953
3218
|
}
|
|
2954
3219
|
return { width: this.size, height: this.size + 28 };
|
|
2955
3220
|
}
|
|
3221
|
+
playAnimation(nameOrIntent, loopMode) {
|
|
3222
|
+
return this.fbxRenderer?.playAnimation(nameOrIntent, loopMode) ?? false;
|
|
3223
|
+
}
|
|
2956
3224
|
setHidden(hidden) {
|
|
2957
3225
|
this.hidden = hidden;
|
|
2958
3226
|
if (this.root) {
|
|
@@ -4230,6 +4498,9 @@ var AsiystRuntime = class {
|
|
|
4230
4498
|
}) : void 0;
|
|
4231
4499
|
this.cloud = new CloudClient(transport, options.projectId, options.publicKey, runtimeAuth, this.visitorSessionId, options.avatarId);
|
|
4232
4500
|
this.config = new ConfigManager(options, this.cloud, this.events);
|
|
4501
|
+
this.config.onConfigUpdated = (newConfig, prevConfig) => {
|
|
4502
|
+
void this.applyUpdatedConfig(newConfig, prevConfig);
|
|
4503
|
+
};
|
|
4233
4504
|
this.analytics = new Analytics(options.projectId, this.cloud);
|
|
4234
4505
|
this.host = new HostRoot(doc);
|
|
4235
4506
|
this.resolver = new TargetResolver(
|
|
@@ -4304,6 +4575,7 @@ var AsiystRuntime = class {
|
|
|
4304
4575
|
}
|
|
4305
4576
|
this.avatar.applyConfig(cfg);
|
|
4306
4577
|
this.avatar.show();
|
|
4578
|
+
this.movement.goToAnchor();
|
|
4307
4579
|
this.lifecycle.emit("sdk.verification_started", {
|
|
4308
4580
|
projectId: this.options.projectId,
|
|
4309
4581
|
origin: window.location.origin,
|
|
@@ -4311,10 +4583,15 @@ var AsiystRuntime = class {
|
|
|
4311
4583
|
installationId: this.installationId,
|
|
4312
4584
|
sdkVersion: SDK_VERSION
|
|
4313
4585
|
});
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4586
|
+
void (async () => {
|
|
4587
|
+
try {
|
|
4588
|
+
await this.registerInstallation();
|
|
4589
|
+
await this.sendHeartbeat();
|
|
4590
|
+
const doc = this.host.host.ownerDocument;
|
|
4591
|
+
this.startHeartbeatScheduler(doc);
|
|
4592
|
+
} catch {
|
|
4593
|
+
}
|
|
4594
|
+
})();
|
|
4318
4595
|
this.events.emit("asiyst:ready", { projectId: this.options.projectId, configVersion: cfg.version });
|
|
4319
4596
|
void this.cloud.sendTelemetryEvent("avatar_runtime_initialized", {
|
|
4320
4597
|
avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
|
|
@@ -4323,72 +4600,145 @@ var AsiystRuntime = class {
|
|
|
4323
4600
|
});
|
|
4324
4601
|
const assetTarget = cfg.assetUrl ?? cfg.thumbnailUrl;
|
|
4325
4602
|
if (assetTarget) {
|
|
4326
|
-
this.
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4603
|
+
await this.loadAvatarAsset(cfg, assetTarget);
|
|
4604
|
+
}
|
|
4605
|
+
this.startConfigRevalidationScheduler();
|
|
4606
|
+
}
|
|
4607
|
+
async loadAvatarAsset(cfg, assetTarget) {
|
|
4608
|
+
this.events.emit("asiyst:avatar:loading", {
|
|
4609
|
+
avatarId: this.options.avatarId ?? cfg.avatarId,
|
|
4610
|
+
assetUrl: assetTarget
|
|
4611
|
+
});
|
|
4612
|
+
void this.cloud.sendTelemetryEvent("avatar_asset_loading_started", {
|
|
4613
|
+
avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
|
|
4614
|
+
assetUrl: assetTarget
|
|
4615
|
+
});
|
|
4616
|
+
try {
|
|
4617
|
+
const loaded = await this.renderer.loadAsset(cfg);
|
|
4618
|
+
if (loaded) {
|
|
4619
|
+
this.movement.goToAnchor();
|
|
4620
|
+
const format = this.renderer.getLoadedFormat();
|
|
4621
|
+
const assetUrl = this.renderer.getAssetUrl();
|
|
4622
|
+
const isRendered = this.renderer.isRendered();
|
|
4623
|
+
this.events.emit("asiyst:avatar:loaded", {
|
|
4624
|
+
avatarId: this.options.avatarId ?? cfg.avatarId,
|
|
4625
|
+
assetUrl,
|
|
4626
|
+
format
|
|
4627
|
+
});
|
|
4628
|
+
void this.cloud.sendTelemetryEvent("avatar_asset_loaded", {
|
|
4629
|
+
avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
|
|
4630
|
+
avatarName: cfg.avatarName,
|
|
4631
|
+
assetUrl,
|
|
4632
|
+
format,
|
|
4633
|
+
publishedVersion: cfg.publishedVersion
|
|
4634
|
+
});
|
|
4635
|
+
if (isRendered) {
|
|
4636
|
+
this.events.emit("asiyst:avatar:rendered", {
|
|
4342
4637
|
avatarId: this.options.avatarId ?? cfg.avatarId,
|
|
4343
|
-
assetUrl,
|
|
4344
4638
|
format
|
|
4345
4639
|
});
|
|
4346
|
-
void this.cloud.sendTelemetryEvent("
|
|
4640
|
+
void this.cloud.sendTelemetryEvent("avatar_rendered", {
|
|
4347
4641
|
avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
|
|
4348
4642
|
avatarName: cfg.avatarName,
|
|
4349
|
-
assetUrl,
|
|
4350
4643
|
format,
|
|
4351
4644
|
publishedVersion: cfg.publishedVersion
|
|
4352
4645
|
});
|
|
4353
|
-
if (isRendered) {
|
|
4354
|
-
this.events.emit("asiyst:avatar:rendered", {
|
|
4355
|
-
avatarId: this.options.avatarId ?? cfg.avatarId,
|
|
4356
|
-
format
|
|
4357
|
-
});
|
|
4358
|
-
void this.cloud.sendTelemetryEvent("avatar_rendered", {
|
|
4359
|
-
avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
|
|
4360
|
-
avatarName: cfg.avatarName,
|
|
4361
|
-
format,
|
|
4362
|
-
publishedVersion: cfg.publishedVersion
|
|
4363
|
-
});
|
|
4364
|
-
}
|
|
4365
|
-
} else {
|
|
4366
|
-
const err = this.renderer.getLastError() ?? "Avatar asset loading failed";
|
|
4367
|
-
this.events.emit("asiyst:avatar:error", {
|
|
4368
|
-
avatarId: this.options.avatarId ?? cfg.avatarId,
|
|
4369
|
-
error: err,
|
|
4370
|
-
stage: "renderer_init"
|
|
4371
|
-
});
|
|
4372
|
-
void this.cloud.sendTelemetryEvent("avatar_render_failed", {
|
|
4373
|
-
avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
|
|
4374
|
-
error: err,
|
|
4375
|
-
stage: "renderer_init"
|
|
4376
|
-
});
|
|
4377
4646
|
}
|
|
4378
|
-
|
|
4379
|
-
|
|
4647
|
+
return true;
|
|
4648
|
+
} else {
|
|
4649
|
+
const err = this.renderer.getLastError() ?? "Avatar asset loading failed";
|
|
4380
4650
|
this.events.emit("asiyst:avatar:error", {
|
|
4381
4651
|
avatarId: this.options.avatarId ?? cfg.avatarId,
|
|
4382
4652
|
error: err,
|
|
4383
|
-
stage: "
|
|
4653
|
+
stage: "renderer_init"
|
|
4384
4654
|
});
|
|
4385
4655
|
void this.cloud.sendTelemetryEvent("avatar_render_failed", {
|
|
4386
4656
|
avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
|
|
4387
4657
|
error: err,
|
|
4388
|
-
stage: "
|
|
4658
|
+
stage: "renderer_init"
|
|
4389
4659
|
});
|
|
4660
|
+
return false;
|
|
4661
|
+
}
|
|
4662
|
+
} catch (error) {
|
|
4663
|
+
const err = error instanceof Error ? error.message : "Avatar asset rendering failed";
|
|
4664
|
+
this.events.emit("asiyst:avatar:error", {
|
|
4665
|
+
avatarId: this.options.avatarId ?? cfg.avatarId,
|
|
4666
|
+
error: err,
|
|
4667
|
+
stage: "asset_fetch"
|
|
4668
|
+
});
|
|
4669
|
+
void this.cloud.sendTelemetryEvent("avatar_render_failed", {
|
|
4670
|
+
avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
|
|
4671
|
+
error: err,
|
|
4672
|
+
stage: "asset_fetch"
|
|
4673
|
+
});
|
|
4674
|
+
return false;
|
|
4675
|
+
}
|
|
4676
|
+
}
|
|
4677
|
+
startConfigRevalidationScheduler() {
|
|
4678
|
+
if (this.configRevalidationTimer) {
|
|
4679
|
+
clearInterval(this.configRevalidationTimer);
|
|
4680
|
+
}
|
|
4681
|
+
this.configRevalidationTimer = setInterval(() => {
|
|
4682
|
+
if (!this.destroyed) {
|
|
4683
|
+
void this.config.refresh();
|
|
4684
|
+
}
|
|
4685
|
+
}, CONFIG_REVALIDATION_INTERVAL_MS);
|
|
4686
|
+
}
|
|
4687
|
+
async applyUpdatedConfig(newConfig, prevConfig) {
|
|
4688
|
+
if (this.destroyed) return;
|
|
4689
|
+
const domainCheck = validateWebsiteDomain(newConfig, window.location.href);
|
|
4690
|
+
if (!domainCheck.allowed) {
|
|
4691
|
+
this.connectionStatus = "disconnected";
|
|
4692
|
+
this.verificationStatus = "not_detected";
|
|
4693
|
+
this.events.emit("asiyst:error", {
|
|
4694
|
+
code: "domain_not_authorized",
|
|
4695
|
+
message: "This website is not authorized for the updated Asiyst configuration."
|
|
4696
|
+
});
|
|
4697
|
+
return;
|
|
4698
|
+
}
|
|
4699
|
+
const assetUrlChanged = newConfig.assetUrl !== prevConfig?.assetUrl || newConfig.thumbnailUrl !== prevConfig?.thumbnailUrl;
|
|
4700
|
+
if (assetUrlChanged && (newConfig.assetUrl || newConfig.thumbnailUrl)) {
|
|
4701
|
+
const target = newConfig.assetUrl ?? newConfig.thumbnailUrl ?? "";
|
|
4702
|
+
await this.loadAvatarAsset(newConfig, target);
|
|
4703
|
+
} else {
|
|
4704
|
+
const animationsChanged = JSON.stringify(newConfig.animations) !== JSON.stringify(prevConfig?.animations);
|
|
4705
|
+
if (animationsChanged && newConfig.animations && newConfig.animations.length > 0) {
|
|
4706
|
+
const fbxRenderer = this.renderer.getFbxRenderer();
|
|
4707
|
+
if (fbxRenderer) {
|
|
4708
|
+
void fbxRenderer.loadExternalAnimations(newConfig.animations);
|
|
4709
|
+
}
|
|
4390
4710
|
}
|
|
4391
4711
|
}
|
|
4712
|
+
this.avatar.applyConfig(newConfig);
|
|
4713
|
+
if (newConfig.position !== prevConfig?.position || newConfig.size !== prevConfig?.size) {
|
|
4714
|
+
this.movement.goToAnchor();
|
|
4715
|
+
}
|
|
4716
|
+
this.events.emit("asiyst:config:updated", {
|
|
4717
|
+
config: newConfig,
|
|
4718
|
+
previousVersion: prevConfig?.version
|
|
4719
|
+
});
|
|
4720
|
+
}
|
|
4721
|
+
async reloadConfig() {
|
|
4722
|
+
const updated = await this.config.refresh({ force: true });
|
|
4723
|
+
await this.applyUpdatedConfig(updated, this.config.get());
|
|
4724
|
+
return updated;
|
|
4725
|
+
}
|
|
4726
|
+
async updateConfig(partial) {
|
|
4727
|
+
const prev = this.config.get();
|
|
4728
|
+
const updated = this.config.applyLocalUpdate(partial);
|
|
4729
|
+
await this.applyUpdatedConfig(updated, prev);
|
|
4730
|
+
}
|
|
4731
|
+
playAnimation(nameOrIntent, options) {
|
|
4732
|
+
const played = this.renderer.playAnimation?.(nameOrIntent, options?.loopMode) ?? false;
|
|
4733
|
+
if (played) {
|
|
4734
|
+
this.events.emit("asiyst:animation:played", { name: nameOrIntent, intent: options?.loopMode });
|
|
4735
|
+
} else {
|
|
4736
|
+
this.events.emit("asiyst:animation:error", {
|
|
4737
|
+
name: nameOrIntent,
|
|
4738
|
+
error: `Animation "${nameOrIntent}" not found or incompatible with current skeleton`
|
|
4739
|
+
});
|
|
4740
|
+
}
|
|
4741
|
+
return played;
|
|
4392
4742
|
}
|
|
4393
4743
|
getConnectionStatus() {
|
|
4394
4744
|
return this.connectionStatus;
|
|
@@ -4449,6 +4799,10 @@ var AsiystRuntime = class {
|
|
|
4449
4799
|
clearInterval(this.heartbeatTimer);
|
|
4450
4800
|
this.heartbeatTimer = void 0;
|
|
4451
4801
|
}
|
|
4802
|
+
if (this.configRevalidationTimer) {
|
|
4803
|
+
clearInterval(this.configRevalidationTimer);
|
|
4804
|
+
this.configRevalidationTimer = void 0;
|
|
4805
|
+
}
|
|
4452
4806
|
const doc = this.host.host.ownerDocument;
|
|
4453
4807
|
if (doc && this.visibilityListener) {
|
|
4454
4808
|
doc.removeEventListener("visibilitychange", this.visibilityListener);
|
|
@@ -4718,6 +5072,12 @@ var Asiyst = {
|
|
|
4718
5072
|
getConfig() {
|
|
4719
5073
|
return requireRuntime().getConfig();
|
|
4720
5074
|
},
|
|
5075
|
+
async reloadConfig() {
|
|
5076
|
+
return requireRuntime().reloadConfig();
|
|
5077
|
+
},
|
|
5078
|
+
async updateConfig(partial) {
|
|
5079
|
+
await requireRuntime().updateConfig(partial);
|
|
5080
|
+
},
|
|
4721
5081
|
getConnectionStatus() {
|
|
4722
5082
|
return requireRuntime().getConnectionStatus();
|
|
4723
5083
|
},
|
|
@@ -4752,6 +5112,9 @@ var Asiyst = {
|
|
|
4752
5112
|
celebrate() {
|
|
4753
5113
|
withIsolation(() => requireRuntime().avatarApi().celebrate());
|
|
4754
5114
|
},
|
|
5115
|
+
playAnimation(nameOrIntent, options) {
|
|
5116
|
+
return requireRuntime().playAnimation(nameOrIntent, options);
|
|
5117
|
+
},
|
|
4755
5118
|
setPosition(x, y) {
|
|
4756
5119
|
withIsolation(() => requireRuntime().avatarApi().setPosition(x, y));
|
|
4757
5120
|
}
|