@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.js
CHANGED
|
@@ -75,7 +75,7 @@ var ALL_ACTION_KINDS = [
|
|
|
75
75
|
// src/core/constants.ts
|
|
76
76
|
function resolveSdkVersion() {
|
|
77
77
|
{
|
|
78
|
-
return "0.1.
|
|
78
|
+
return "0.1.26";
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
var SDK_VERSION = resolveSdkVersion();
|
|
@@ -92,7 +92,8 @@ var VIEWPORT_HANDLER_THROTTLE_MS = 80;
|
|
|
92
92
|
var AVATAR_VIEWPORT_PADDING = 12;
|
|
93
93
|
var AVATAR_TARGET_GAP = 16;
|
|
94
94
|
var WEBSITE_MAP_TEXT_LIMIT = 80;
|
|
95
|
-
var CONFIG_CACHE_TTL_MS = 1e3 *
|
|
95
|
+
var CONFIG_CACHE_TTL_MS = 1e3 * 30;
|
|
96
|
+
var CONFIG_REVALIDATION_INTERVAL_MS = 3e4;
|
|
96
97
|
var HEARTBEAT_INTERVAL_MS = 45e3;
|
|
97
98
|
|
|
98
99
|
// src/security/selectors.ts
|
|
@@ -1038,7 +1039,7 @@ var ConfigCache = class {
|
|
|
1038
1039
|
constructor(storage) {
|
|
1039
1040
|
this.storage = storage;
|
|
1040
1041
|
}
|
|
1041
|
-
read(projectId) {
|
|
1042
|
+
read(projectId, ignoreTtl = false) {
|
|
1042
1043
|
const raw = this.storage.read("config");
|
|
1043
1044
|
if (!raw) {
|
|
1044
1045
|
return null;
|
|
@@ -1048,7 +1049,7 @@ var ConfigCache = class {
|
|
|
1048
1049
|
if (parsed.schemaVersion !== CONFIG_SCHEMA_VERSION || parsed.projectId !== projectId) {
|
|
1049
1050
|
return null;
|
|
1050
1051
|
}
|
|
1051
|
-
if (Date.now() - parsed.fetchedAt > CONFIG_CACHE_TTL_MS) {
|
|
1052
|
+
if (!ignoreTtl && Date.now() - parsed.fetchedAt > CONFIG_CACHE_TTL_MS) {
|
|
1052
1053
|
return null;
|
|
1053
1054
|
}
|
|
1054
1055
|
return normalizeProjectConfig(parsed.config);
|
|
@@ -1056,15 +1057,35 @@ var ConfigCache = class {
|
|
|
1056
1057
|
return null;
|
|
1057
1058
|
}
|
|
1058
1059
|
}
|
|
1059
|
-
|
|
1060
|
+
getEnvelope(projectId) {
|
|
1061
|
+
const raw = this.storage.read("config");
|
|
1062
|
+
if (!raw) {
|
|
1063
|
+
return null;
|
|
1064
|
+
}
|
|
1065
|
+
try {
|
|
1066
|
+
const parsed = JSON.parse(raw);
|
|
1067
|
+
if (parsed.schemaVersion !== CONFIG_SCHEMA_VERSION || parsed.projectId !== projectId) {
|
|
1068
|
+
return null;
|
|
1069
|
+
}
|
|
1070
|
+
return parsed;
|
|
1071
|
+
} catch {
|
|
1072
|
+
return null;
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
write(projectId, config, meta) {
|
|
1060
1076
|
const envelope = {
|
|
1061
1077
|
schemaVersion: CONFIG_SCHEMA_VERSION,
|
|
1062
1078
|
projectId,
|
|
1063
1079
|
fetchedAt: Date.now(),
|
|
1080
|
+
etag: meta?.etag,
|
|
1081
|
+
revision: meta?.revision ?? config.version,
|
|
1064
1082
|
config
|
|
1065
1083
|
};
|
|
1066
1084
|
this.storage.write("config", JSON.stringify(envelope));
|
|
1067
1085
|
}
|
|
1086
|
+
clear() {
|
|
1087
|
+
this.storage.remove("config");
|
|
1088
|
+
}
|
|
1068
1089
|
};
|
|
1069
1090
|
|
|
1070
1091
|
// src/config/ConfigManager.ts
|
|
@@ -1073,6 +1094,7 @@ var ConfigManager = class {
|
|
|
1073
1094
|
this.options = options;
|
|
1074
1095
|
this.cloud = cloud;
|
|
1075
1096
|
this.events = events;
|
|
1097
|
+
this.inFlightRefresh = null;
|
|
1076
1098
|
const credentials = validateInitOptions(options);
|
|
1077
1099
|
this.options = { ...options, ...credentials };
|
|
1078
1100
|
this.cache = new ConfigCache(
|
|
@@ -1084,13 +1106,34 @@ var ConfigManager = class {
|
|
|
1084
1106
|
get() {
|
|
1085
1107
|
return this.current;
|
|
1086
1108
|
}
|
|
1087
|
-
async refresh() {
|
|
1109
|
+
async refresh(options) {
|
|
1110
|
+
if (this.inFlightRefresh) {
|
|
1111
|
+
return this.inFlightRefresh;
|
|
1112
|
+
}
|
|
1113
|
+
this.inFlightRefresh = this.executeRefresh(options);
|
|
1114
|
+
try {
|
|
1115
|
+
return await this.inFlightRefresh;
|
|
1116
|
+
} finally {
|
|
1117
|
+
this.inFlightRefresh = null;
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
async executeRefresh(_options) {
|
|
1121
|
+
const prev = this.current;
|
|
1088
1122
|
try {
|
|
1089
1123
|
const remote = await this.cloud.fetchConfig();
|
|
1090
|
-
|
|
1091
|
-
this.
|
|
1124
|
+
const normalized = normalizeProjectConfig(remote);
|
|
1125
|
+
this.current = normalized;
|
|
1126
|
+
this.cache.write(this.options.projectId, normalized);
|
|
1127
|
+
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);
|
|
1128
|
+
if (hasChanged && this.onConfigUpdated) {
|
|
1129
|
+
this.onConfigUpdated(normalized, prev);
|
|
1130
|
+
}
|
|
1092
1131
|
return this.current;
|
|
1093
1132
|
} catch (error) {
|
|
1133
|
+
const lastKnownGood = this.cache.read(this.options.projectId, true);
|
|
1134
|
+
if (lastKnownGood) {
|
|
1135
|
+
this.current = lastKnownGood;
|
|
1136
|
+
}
|
|
1094
1137
|
this.events.emit("asiyst:error", {
|
|
1095
1138
|
code: "config_refresh_failed",
|
|
1096
1139
|
message: error instanceof Error ? error.message : "Failed to refresh configuration"
|
|
@@ -1098,6 +1141,18 @@ var ConfigManager = class {
|
|
|
1098
1141
|
return this.current;
|
|
1099
1142
|
}
|
|
1100
1143
|
}
|
|
1144
|
+
applyLocalUpdate(partial) {
|
|
1145
|
+
const prev = this.current;
|
|
1146
|
+
this.current = {
|
|
1147
|
+
...this.current,
|
|
1148
|
+
...partial
|
|
1149
|
+
};
|
|
1150
|
+
this.cache.write(this.options.projectId, this.current);
|
|
1151
|
+
if (this.onConfigUpdated) {
|
|
1152
|
+
this.onConfigUpdated(this.current, prev);
|
|
1153
|
+
}
|
|
1154
|
+
return this.current;
|
|
1155
|
+
}
|
|
1101
1156
|
localFallback() {
|
|
1102
1157
|
const base = fallbackConfig();
|
|
1103
1158
|
return {
|
|
@@ -1756,13 +1811,34 @@ var AssetLoader = class {
|
|
|
1756
1811
|
constructor() {
|
|
1757
1812
|
this.inFlightController = null;
|
|
1758
1813
|
this.createdObjectUrls = [];
|
|
1814
|
+
this.inFlightLoads = /* @__PURE__ */ new Map();
|
|
1815
|
+
this.cachedAssets = /* @__PURE__ */ new Map();
|
|
1759
1816
|
}
|
|
1760
1817
|
async load(assetUrl, options) {
|
|
1761
|
-
const startTime = Date.now();
|
|
1762
1818
|
const sanitizedUrl = sanitizeText(assetUrl.trim(), 2048);
|
|
1763
1819
|
if (!sanitizedUrl) {
|
|
1764
1820
|
throw new Error("Asset URL is required");
|
|
1765
1821
|
}
|
|
1822
|
+
const cached = this.cachedAssets.get(sanitizedUrl);
|
|
1823
|
+
if (cached) {
|
|
1824
|
+
return cached;
|
|
1825
|
+
}
|
|
1826
|
+
const inFlight = this.inFlightLoads.get(sanitizedUrl);
|
|
1827
|
+
if (inFlight) {
|
|
1828
|
+
return inFlight;
|
|
1829
|
+
}
|
|
1830
|
+
const loadPromise = this.performLoad(sanitizedUrl, options);
|
|
1831
|
+
this.inFlightLoads.set(sanitizedUrl, loadPromise);
|
|
1832
|
+
try {
|
|
1833
|
+
const asset = await loadPromise;
|
|
1834
|
+
this.cachedAssets.set(sanitizedUrl, asset);
|
|
1835
|
+
return asset;
|
|
1836
|
+
} finally {
|
|
1837
|
+
this.inFlightLoads.delete(sanitizedUrl);
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
async performLoad(sanitizedUrl, options) {
|
|
1841
|
+
const startTime = Date.now();
|
|
1766
1842
|
this.inFlightController = new AbortController();
|
|
1767
1843
|
const abortSignal = options?.signal ? anySignal([this.inFlightController.signal, options.signal]) : this.inFlightController.signal;
|
|
1768
1844
|
const timeoutMs = options?.timeoutMs ?? 6e4;
|
|
@@ -1805,6 +1881,9 @@ var AssetLoader = class {
|
|
|
1805
1881
|
throw new Error(`Avatar asset download failed: HTTP ${response.status} from ${sanitizedUrl}`);
|
|
1806
1882
|
}
|
|
1807
1883
|
const contentType = (response.headers.get("content-type") || "").toLowerCase();
|
|
1884
|
+
if (contentType.includes("text/html")) {
|
|
1885
|
+
throw new Error(`Avatar asset request returned HTML instead of 3D asset from ${sanitizedUrl}`);
|
|
1886
|
+
}
|
|
1808
1887
|
if (isJsonExtension || contentType.includes("application/json")) {
|
|
1809
1888
|
const text = await response.text();
|
|
1810
1889
|
let manifest;
|
|
@@ -1838,6 +1917,11 @@ var AssetLoader = class {
|
|
|
1838
1917
|
if (arrayBuffer.byteLength < 12) {
|
|
1839
1918
|
throw new Error("Avatar asset payload is too small to be a valid 3D container");
|
|
1840
1919
|
}
|
|
1920
|
+
const headerBytes = new Uint8Array(arrayBuffer, 0, Math.min(256, arrayBuffer.byteLength));
|
|
1921
|
+
const headerStr = new TextDecoder("utf-8", { fatal: false }).decode(headerBytes).trim();
|
|
1922
|
+
if (/^<!DOCTYPE\s+html/i.test(headerStr) || /^<html/i.test(headerStr)) {
|
|
1923
|
+
throw new Error(`Avatar asset payload contains HTML error page instead of binary 3D container from ${sanitizedUrl}`);
|
|
1924
|
+
}
|
|
1841
1925
|
if (isFbxExtension || this.isFbxBuffer(arrayBuffer) || !isGlbExtension && !this.isGlbBuffer(arrayBuffer)) {
|
|
1842
1926
|
const fbxHeader = this.parseFbxHeader(arrayBuffer);
|
|
1843
1927
|
const resourcePath = sanitizedUrl.includes("/") ? sanitizedUrl.substring(0, sanitizedUrl.lastIndexOf("/") + 1) : "";
|
|
@@ -2083,6 +2167,8 @@ var AssetLoader = class {
|
|
|
2083
2167
|
this.inFlightController.abort();
|
|
2084
2168
|
this.inFlightController = null;
|
|
2085
2169
|
}
|
|
2170
|
+
this.inFlightLoads.clear();
|
|
2171
|
+
this.cachedAssets.clear();
|
|
2086
2172
|
if (typeof URL !== "undefined" && typeof URL.revokeObjectURL === "function") {
|
|
2087
2173
|
for (const objUrl of this.createdObjectUrls) {
|
|
2088
2174
|
try {
|
|
@@ -2112,8 +2198,11 @@ var FbxRenderer = class {
|
|
|
2112
2198
|
this.scene = null;
|
|
2113
2199
|
this.camera = null;
|
|
2114
2200
|
this.modelRoot = null;
|
|
2201
|
+
this.rawObject = null;
|
|
2115
2202
|
this.mixer = null;
|
|
2116
2203
|
this.allAnimations = [];
|
|
2204
|
+
this.animationMetadataList = [];
|
|
2205
|
+
this.assetLoader = new AssetLoader();
|
|
2117
2206
|
this.currentAction = null;
|
|
2118
2207
|
this.animFrameId = null;
|
|
2119
2208
|
this.lastTime = 0;
|
|
@@ -2129,6 +2218,8 @@ var FbxRenderer = class {
|
|
|
2129
2218
|
this.canvas = doc.createElement("canvas");
|
|
2130
2219
|
this.canvas.className = "asiyst-avatar-canvas";
|
|
2131
2220
|
this.canvas.setAttribute("role", "presentation");
|
|
2221
|
+
this.canvas.style.opacity = "0";
|
|
2222
|
+
this.canvas.style.transition = "opacity 0.25s ease";
|
|
2132
2223
|
const glContext = this.canvas.getContext("webgl2") || this.canvas.getContext("webgl");
|
|
2133
2224
|
if (!glContext) {
|
|
2134
2225
|
throw new Error("WebGLRenderingContext is not available or supported in this browser environment");
|
|
@@ -2242,9 +2333,10 @@ var FbxRenderer = class {
|
|
|
2242
2333
|
mesh.receiveShadow = true;
|
|
2243
2334
|
}
|
|
2244
2335
|
});
|
|
2245
|
-
this.
|
|
2336
|
+
this.rawObject = rawObject;
|
|
2337
|
+
this.mixer = new THREE.AnimationMixer(rawObject);
|
|
2338
|
+
this.allAnimations = [...modelAnimations];
|
|
2246
2339
|
if (modelAnimations.length > 0) {
|
|
2247
|
-
this.mixer = new THREE.AnimationMixer(rawObject);
|
|
2248
2340
|
const idleClip = modelAnimations.find((c) => c.name.toLowerCase().includes("idle")) || modelAnimations[0];
|
|
2249
2341
|
if (idleClip) {
|
|
2250
2342
|
this.currentAction = this.mixer.clipAction(idleClip);
|
|
@@ -2256,6 +2348,9 @@ var FbxRenderer = class {
|
|
|
2256
2348
|
try {
|
|
2257
2349
|
this.renderer.render(this.scene, this.camera);
|
|
2258
2350
|
this.initialRenderCompleted = true;
|
|
2351
|
+
if (this.canvas) {
|
|
2352
|
+
this.canvas.style.opacity = "1";
|
|
2353
|
+
}
|
|
2259
2354
|
} catch (renderErr) {
|
|
2260
2355
|
const msg = renderErr instanceof Error ? renderErr.message : String(renderErr);
|
|
2261
2356
|
throw new Error(`Initial FBX WebGL render failed: ${msg}`);
|
|
@@ -2263,6 +2358,9 @@ var FbxRenderer = class {
|
|
|
2263
2358
|
this.startLoop();
|
|
2264
2359
|
this.setFacing(this.facing);
|
|
2265
2360
|
this.setPose(this.currentPose);
|
|
2361
|
+
if (options?.config?.animations && options.config.animations.length > 0) {
|
|
2362
|
+
void this.loadExternalAnimations(options.config.animations);
|
|
2363
|
+
}
|
|
2266
2364
|
if (typeof window !== "undefined") {
|
|
2267
2365
|
this.resizeListener = () => this.handleResize();
|
|
2268
2366
|
window.addEventListener("resize", this.resizeListener);
|
|
@@ -2282,6 +2380,9 @@ var FbxRenderer = class {
|
|
|
2282
2380
|
setPose(pose) {
|
|
2283
2381
|
this.currentPose = pose;
|
|
2284
2382
|
if (!this.modelRoot) return;
|
|
2383
|
+
if (this.playAnimation(pose)) {
|
|
2384
|
+
return;
|
|
2385
|
+
}
|
|
2285
2386
|
if (this.mixer && this.allAnimations.length > 1) {
|
|
2286
2387
|
let targetClip;
|
|
2287
2388
|
if (pose === "speak") {
|
|
@@ -2332,6 +2433,135 @@ var FbxRenderer = class {
|
|
|
2332
2433
|
break;
|
|
2333
2434
|
}
|
|
2334
2435
|
}
|
|
2436
|
+
async loadExternalAnimations(animations) {
|
|
2437
|
+
if (!this.rawObject || !this.mixer) return;
|
|
2438
|
+
for (const anim of animations) {
|
|
2439
|
+
if (!anim.assetUrl) continue;
|
|
2440
|
+
try {
|
|
2441
|
+
const loaded = await this.assetLoader.load(anim.assetUrl);
|
|
2442
|
+
let extractedClips = [];
|
|
2443
|
+
if (loaded.format === "fbx") {
|
|
2444
|
+
const loader = new FBXLoader();
|
|
2445
|
+
if (loaded.resourcePath) {
|
|
2446
|
+
loader.setResourcePath(loaded.resourcePath);
|
|
2447
|
+
}
|
|
2448
|
+
const parsed = loader.parse(loaded.buffer, loaded.resourcePath || "");
|
|
2449
|
+
extractedClips = parsed.animations || [];
|
|
2450
|
+
} else if (loaded.format === "glb") {
|
|
2451
|
+
const loader = new GLTFLoader();
|
|
2452
|
+
const gltf = await new Promise((resolve, reject) => {
|
|
2453
|
+
const glbBuffer = loaded.bin.buffer.slice(
|
|
2454
|
+
loaded.bin.byteOffset,
|
|
2455
|
+
loaded.bin.byteOffset + loaded.bin.byteLength
|
|
2456
|
+
);
|
|
2457
|
+
loader.parse(glbBuffer, loaded.url, resolve, reject);
|
|
2458
|
+
});
|
|
2459
|
+
extractedClips = gltf.animations || [];
|
|
2460
|
+
}
|
|
2461
|
+
for (const rawClip of extractedClips) {
|
|
2462
|
+
const retargeted = this.retargetClip(rawClip, this.rawObject);
|
|
2463
|
+
if (!retargeted) continue;
|
|
2464
|
+
retargeted.name = anim.clipName || anim.name || rawClip.name;
|
|
2465
|
+
this.allAnimations.push(retargeted);
|
|
2466
|
+
this.animationMetadataList.push({
|
|
2467
|
+
id: anim.id,
|
|
2468
|
+
name: anim.name,
|
|
2469
|
+
intent: anim.intent,
|
|
2470
|
+
clipName: anim.clipName,
|
|
2471
|
+
loopMode: anim.loopMode,
|
|
2472
|
+
clip: retargeted
|
|
2473
|
+
});
|
|
2474
|
+
const animIntent = anim.intent?.toLowerCase();
|
|
2475
|
+
const animName = anim.name.toLowerCase();
|
|
2476
|
+
if (animIntent === this.currentPose || this.currentPose === "idle" && (animIntent === "idle" || animName === "idle")) {
|
|
2477
|
+
this.playAnimation(anim.id || anim.name || this.currentPose, anim.loopMode);
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2480
|
+
} catch (err) {
|
|
2481
|
+
if (typeof console !== "undefined" && typeof console.warn === "function") {
|
|
2482
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
2483
|
+
console.warn(`[asiyst] Failed to load external animation "${anim.name}": ${msg}`);
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
}
|
|
2487
|
+
}
|
|
2488
|
+
retargetClip(clip, targetObject) {
|
|
2489
|
+
const targetNodeNames = /* @__PURE__ */ new Set();
|
|
2490
|
+
const boneMap = /* @__PURE__ */ new Map();
|
|
2491
|
+
targetObject.traverse((node) => {
|
|
2492
|
+
if (node.name) {
|
|
2493
|
+
targetNodeNames.add(node.name);
|
|
2494
|
+
const clean = node.name.replace(/^.*[:|/]/, "").toLowerCase();
|
|
2495
|
+
boneMap.set(clean, node.name);
|
|
2496
|
+
boneMap.set(node.name.toLowerCase(), node.name);
|
|
2497
|
+
}
|
|
2498
|
+
});
|
|
2499
|
+
const validTracks = [];
|
|
2500
|
+
for (const track of clip.tracks) {
|
|
2501
|
+
const dotIdx = track.name.lastIndexOf(".");
|
|
2502
|
+
if (dotIdx === -1) continue;
|
|
2503
|
+
const nodePart = track.name.substring(0, dotIdx);
|
|
2504
|
+
const propPart = track.name.substring(dotIdx);
|
|
2505
|
+
if (targetNodeNames.has(nodePart)) {
|
|
2506
|
+
validTracks.push(track);
|
|
2507
|
+
} else {
|
|
2508
|
+
const clean = nodePart.replace(/^.*[:|/]/, "").toLowerCase();
|
|
2509
|
+
const matched = boneMap.get(clean);
|
|
2510
|
+
if (matched) {
|
|
2511
|
+
const clonedTrack = track.clone();
|
|
2512
|
+
clonedTrack.name = `${matched}${propPart}`;
|
|
2513
|
+
validTracks.push(clonedTrack);
|
|
2514
|
+
}
|
|
2515
|
+
}
|
|
2516
|
+
}
|
|
2517
|
+
if (validTracks.length === 0) {
|
|
2518
|
+
return null;
|
|
2519
|
+
}
|
|
2520
|
+
return new THREE.AnimationClip(clip.name, clip.duration, validTracks);
|
|
2521
|
+
}
|
|
2522
|
+
playAnimation(nameOrIntent, loopMode, crossFadeDuration = 0.25) {
|
|
2523
|
+
if (!this.mixer) return false;
|
|
2524
|
+
const query = nameOrIntent.trim().toLowerCase();
|
|
2525
|
+
if (!query) return false;
|
|
2526
|
+
let matched = this.animationMetadataList.find((m) => m.id && m.id.toLowerCase() === query);
|
|
2527
|
+
if (!matched) {
|
|
2528
|
+
matched = this.animationMetadataList.find((m) => m.intent && m.intent.toLowerCase() === query);
|
|
2529
|
+
}
|
|
2530
|
+
if (!matched) {
|
|
2531
|
+
matched = this.animationMetadataList.find((m) => m.name && m.name.toLowerCase() === query);
|
|
2532
|
+
}
|
|
2533
|
+
if (!matched) {
|
|
2534
|
+
matched = this.animationMetadataList.find((m) => m.clipName && m.clipName.toLowerCase() === query);
|
|
2535
|
+
}
|
|
2536
|
+
let clip = matched?.clip;
|
|
2537
|
+
if (!clip) {
|
|
2538
|
+
clip = this.allAnimations.find((c) => c.name.toLowerCase() === query);
|
|
2539
|
+
}
|
|
2540
|
+
if (!clip) {
|
|
2541
|
+
clip = this.allAnimations.find((c) => c.name.toLowerCase().includes(query));
|
|
2542
|
+
}
|
|
2543
|
+
if (!clip) {
|
|
2544
|
+
return false;
|
|
2545
|
+
}
|
|
2546
|
+
const action = this.mixer.clipAction(clip);
|
|
2547
|
+
const effectiveLoop = loopMode || matched?.loopMode || "repeat";
|
|
2548
|
+
if (effectiveLoop === "once") {
|
|
2549
|
+
action.setLoop(THREE.LoopOnce, 1);
|
|
2550
|
+
action.clampWhenFinished = true;
|
|
2551
|
+
} else if (effectiveLoop === "pingpong") {
|
|
2552
|
+
action.setLoop(THREE.LoopPingPong, Infinity);
|
|
2553
|
+
} else {
|
|
2554
|
+
action.setLoop(THREE.LoopRepeat, Infinity);
|
|
2555
|
+
}
|
|
2556
|
+
if (this.currentAction !== action) {
|
|
2557
|
+
action.reset().fadeIn(crossFadeDuration).play();
|
|
2558
|
+
if (this.currentAction) {
|
|
2559
|
+
this.currentAction.fadeOut(crossFadeDuration);
|
|
2560
|
+
}
|
|
2561
|
+
this.currentAction = action;
|
|
2562
|
+
}
|
|
2563
|
+
return true;
|
|
2564
|
+
}
|
|
2335
2565
|
isRendered() {
|
|
2336
2566
|
return this.initialRenderCompleted;
|
|
2337
2567
|
}
|
|
@@ -2418,6 +2648,11 @@ var FbxRenderer = class {
|
|
|
2418
2648
|
this.canvas.remove();
|
|
2419
2649
|
this.canvas = null;
|
|
2420
2650
|
}
|
|
2651
|
+
this.assetLoader.destroy();
|
|
2652
|
+
this.animationMetadataList.length = 0;
|
|
2653
|
+
this.allAnimations = [];
|
|
2654
|
+
this.currentAction = null;
|
|
2655
|
+
this.rawObject = null;
|
|
2421
2656
|
this.camera = null;
|
|
2422
2657
|
this.modelRoot = null;
|
|
2423
2658
|
this.initialRenderCompleted = false;
|
|
@@ -2519,13 +2754,23 @@ var AVATAR_CSS = `
|
|
|
2519
2754
|
pointer-events: none;
|
|
2520
2755
|
}
|
|
2521
2756
|
.asiyst-avatar-loader {
|
|
2522
|
-
width:
|
|
2523
|
-
height:
|
|
2524
|
-
border: 3px solid rgba(
|
|
2525
|
-
border-top-color: #
|
|
2757
|
+
width: 34px;
|
|
2758
|
+
height: 34px;
|
|
2759
|
+
border: 3px solid rgba(37, 99, 235, 0.2);
|
|
2760
|
+
border-top-color: #2563eb;
|
|
2526
2761
|
border-radius: 50%;
|
|
2527
2762
|
animation: asiyst-spin 0.8s linear infinite;
|
|
2528
2763
|
}
|
|
2764
|
+
.asiyst-avatar-loading-silhouette {
|
|
2765
|
+
display: flex;
|
|
2766
|
+
flex-direction: column;
|
|
2767
|
+
align-items: center;
|
|
2768
|
+
justify-content: center;
|
|
2769
|
+
width: 100%;
|
|
2770
|
+
height: 100%;
|
|
2771
|
+
min-height: 240px;
|
|
2772
|
+
pointer-events: none;
|
|
2773
|
+
}
|
|
2529
2774
|
@keyframes asiyst-spin {
|
|
2530
2775
|
to { transform: rotate(360deg); }
|
|
2531
2776
|
}
|
|
@@ -2640,12 +2885,13 @@ var CssAvatarRenderer = class {
|
|
|
2640
2885
|
this.accentColor = "#2563eb";
|
|
2641
2886
|
this.avatarName = "Asiyst";
|
|
2642
2887
|
this.isPanelOpen = false;
|
|
2888
|
+
this.has3dAssetConfigured = false;
|
|
2643
2889
|
// Asset loading & rendering state
|
|
2644
2890
|
this.assetLoader = new AssetLoader();
|
|
2645
2891
|
this.fbxRenderer = null;
|
|
2646
2892
|
this.renderState = "idle";
|
|
2647
2893
|
this.isAssetLoadedFlag = false;
|
|
2648
|
-
this.isFallbackFlag =
|
|
2894
|
+
this.isFallbackFlag = false;
|
|
2649
2895
|
}
|
|
2650
2896
|
mount(container, config) {
|
|
2651
2897
|
const doc = container.ownerDocument;
|
|
@@ -2717,6 +2963,11 @@ var CssAvatarRenderer = class {
|
|
|
2717
2963
|
this.size = config.size;
|
|
2718
2964
|
this.accentColor = config.theme.accent ?? "#2563eb";
|
|
2719
2965
|
this.avatarName = config.avatarName;
|
|
2966
|
+
const has3dAsset = Boolean(config.assetUrl || config.thumbnailUrl);
|
|
2967
|
+
this.has3dAssetConfigured = has3dAsset;
|
|
2968
|
+
if (config.assetUrl || config.thumbnailUrl) {
|
|
2969
|
+
this.activeAssetUrl = config.assetUrl ?? config.thumbnailUrl ?? void 0;
|
|
2970
|
+
}
|
|
2720
2971
|
if (this.nameTextEl) {
|
|
2721
2972
|
renderSafeText(this.nameTextEl, config.avatarName);
|
|
2722
2973
|
}
|
|
@@ -2729,7 +2980,24 @@ var CssAvatarRenderer = class {
|
|
|
2729
2980
|
if (this.root) {
|
|
2730
2981
|
this.root.setAttribute("aria-label", config.avatarName);
|
|
2731
2982
|
}
|
|
2732
|
-
if (
|
|
2983
|
+
if (has3dAsset) {
|
|
2984
|
+
if (this.figure) {
|
|
2985
|
+
this.figure.classList.add("asiyst-3d-active");
|
|
2986
|
+
this.figure.style.width = "";
|
|
2987
|
+
this.figure.style.height = "";
|
|
2988
|
+
this.figure.style.background = "transparent";
|
|
2989
|
+
}
|
|
2990
|
+
if (this.chatActionBtn) {
|
|
2991
|
+
this.chatActionBtn.style.display = this.isAssetLoadedFlag && !this.isPanelOpen ? "inline-flex" : "none";
|
|
2992
|
+
}
|
|
2993
|
+
if (!this.isAssetLoadedFlag && this.viewport) {
|
|
2994
|
+
if (this.renderState === "error") {
|
|
2995
|
+
this.renderFallback(true);
|
|
2996
|
+
} else {
|
|
2997
|
+
this.renderLoader();
|
|
2998
|
+
}
|
|
2999
|
+
}
|
|
3000
|
+
} else {
|
|
2733
3001
|
if (this.figure) {
|
|
2734
3002
|
this.figure.classList.remove("asiyst-3d-active");
|
|
2735
3003
|
this.figure.style.width = `${config.size}px`;
|
|
@@ -2739,16 +3007,9 @@ var CssAvatarRenderer = class {
|
|
|
2739
3007
|
if (this.chatActionBtn) {
|
|
2740
3008
|
this.chatActionBtn.style.display = "none";
|
|
2741
3009
|
}
|
|
2742
|
-
if (this.viewport) {
|
|
3010
|
+
if (this.viewport && !this.isAssetLoadedFlag) {
|
|
2743
3011
|
this.renderFallback();
|
|
2744
3012
|
}
|
|
2745
|
-
} else {
|
|
2746
|
-
if (this.figure) {
|
|
2747
|
-
this.figure.classList.add("asiyst-3d-active");
|
|
2748
|
-
}
|
|
2749
|
-
if (this.chatActionBtn) {
|
|
2750
|
-
this.chatActionBtn.style.display = this.isPanelOpen ? "none" : "inline-flex";
|
|
2751
|
-
}
|
|
2752
3013
|
}
|
|
2753
3014
|
}
|
|
2754
3015
|
setPanelOpen(open) {
|
|
@@ -2767,11 +3028,16 @@ var CssAvatarRenderer = class {
|
|
|
2767
3028
|
return false;
|
|
2768
3029
|
}
|
|
2769
3030
|
this.activeAssetUrl = assetUrl;
|
|
3031
|
+
this.has3dAssetConfigured = true;
|
|
2770
3032
|
this.renderState = "loading";
|
|
2771
3033
|
this.isFallbackFlag = false;
|
|
2772
3034
|
this.lastErrorMessage = void 0;
|
|
2773
3035
|
if (this.figure) {
|
|
2774
3036
|
this.figure.setAttribute("data-state", "loading");
|
|
3037
|
+
this.figure.classList.add("asiyst-3d-active");
|
|
3038
|
+
this.figure.style.width = "";
|
|
3039
|
+
this.figure.style.height = "";
|
|
3040
|
+
this.figure.style.background = "transparent";
|
|
2775
3041
|
}
|
|
2776
3042
|
this.renderLoader();
|
|
2777
3043
|
try {
|
|
@@ -2800,10 +3066,6 @@ var CssAvatarRenderer = class {
|
|
|
2800
3066
|
this.isFallbackFlag = true;
|
|
2801
3067
|
if (this.figure) {
|
|
2802
3068
|
this.figure.setAttribute("data-state", "error");
|
|
2803
|
-
this.figure.classList.remove("asiyst-3d-active");
|
|
2804
|
-
this.figure.style.width = `${this.size}px`;
|
|
2805
|
-
this.figure.style.height = `${this.size}px`;
|
|
2806
|
-
this.figure.style.background = this.accentColor;
|
|
2807
3069
|
}
|
|
2808
3070
|
if (this.chatActionBtn) {
|
|
2809
3071
|
this.chatActionBtn.style.display = "none";
|
|
@@ -2816,10 +3078,13 @@ var CssAvatarRenderer = class {
|
|
|
2816
3078
|
if (!this.viewport) return;
|
|
2817
3079
|
this.viewport.replaceChildren();
|
|
2818
3080
|
const doc = this.viewport.ownerDocument;
|
|
3081
|
+
const container = doc.createElement("div");
|
|
3082
|
+
container.className = "asiyst-avatar-loading-silhouette";
|
|
2819
3083
|
const loader = doc.createElement("div");
|
|
2820
3084
|
loader.className = "asiyst-avatar-loader";
|
|
2821
3085
|
loader.setAttribute("aria-label", `Loading ${this.avatarName}`);
|
|
2822
|
-
|
|
3086
|
+
container.appendChild(loader);
|
|
3087
|
+
this.viewport.appendChild(container);
|
|
2823
3088
|
}
|
|
2824
3089
|
async renderLoadedAsset(asset, config) {
|
|
2825
3090
|
if (!this.viewport) return;
|
|
@@ -2925,12 +3190,15 @@ var CssAvatarRenderer = class {
|
|
|
2925
3190
|
renderSafeText(this.bubble, text);
|
|
2926
3191
|
}
|
|
2927
3192
|
getSize() {
|
|
2928
|
-
if (this.isAssetLoadedFlag
|
|
3193
|
+
if (this.isAssetLoadedFlag || this.has3dAssetConfigured) {
|
|
2929
3194
|
const isMobile = typeof window !== "undefined" && window.innerWidth <= 640;
|
|
2930
3195
|
return { width: isMobile ? 180 : 240, height: isMobile ? 390 : 490 };
|
|
2931
3196
|
}
|
|
2932
3197
|
return { width: this.size, height: this.size + 28 };
|
|
2933
3198
|
}
|
|
3199
|
+
playAnimation(nameOrIntent, loopMode) {
|
|
3200
|
+
return this.fbxRenderer?.playAnimation(nameOrIntent, loopMode) ?? false;
|
|
3201
|
+
}
|
|
2934
3202
|
setHidden(hidden) {
|
|
2935
3203
|
this.hidden = hidden;
|
|
2936
3204
|
if (this.root) {
|
|
@@ -4208,6 +4476,9 @@ var AsiystRuntime = class {
|
|
|
4208
4476
|
}) : void 0;
|
|
4209
4477
|
this.cloud = new CloudClient(transport, options.projectId, options.publicKey, runtimeAuth, this.visitorSessionId, options.avatarId);
|
|
4210
4478
|
this.config = new ConfigManager(options, this.cloud, this.events);
|
|
4479
|
+
this.config.onConfigUpdated = (newConfig, prevConfig) => {
|
|
4480
|
+
void this.applyUpdatedConfig(newConfig, prevConfig);
|
|
4481
|
+
};
|
|
4211
4482
|
this.analytics = new Analytics(options.projectId, this.cloud);
|
|
4212
4483
|
this.host = new HostRoot(doc);
|
|
4213
4484
|
this.resolver = new TargetResolver(
|
|
@@ -4282,6 +4553,7 @@ var AsiystRuntime = class {
|
|
|
4282
4553
|
}
|
|
4283
4554
|
this.avatar.applyConfig(cfg);
|
|
4284
4555
|
this.avatar.show();
|
|
4556
|
+
this.movement.goToAnchor();
|
|
4285
4557
|
this.lifecycle.emit("sdk.verification_started", {
|
|
4286
4558
|
projectId: this.options.projectId,
|
|
4287
4559
|
origin: window.location.origin,
|
|
@@ -4289,10 +4561,15 @@ var AsiystRuntime = class {
|
|
|
4289
4561
|
installationId: this.installationId,
|
|
4290
4562
|
sdkVersion: SDK_VERSION
|
|
4291
4563
|
});
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4564
|
+
void (async () => {
|
|
4565
|
+
try {
|
|
4566
|
+
await this.registerInstallation();
|
|
4567
|
+
await this.sendHeartbeat();
|
|
4568
|
+
const doc = this.host.host.ownerDocument;
|
|
4569
|
+
this.startHeartbeatScheduler(doc);
|
|
4570
|
+
} catch {
|
|
4571
|
+
}
|
|
4572
|
+
})();
|
|
4296
4573
|
this.events.emit("asiyst:ready", { projectId: this.options.projectId, configVersion: cfg.version });
|
|
4297
4574
|
void this.cloud.sendTelemetryEvent("avatar_runtime_initialized", {
|
|
4298
4575
|
avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
|
|
@@ -4301,72 +4578,145 @@ var AsiystRuntime = class {
|
|
|
4301
4578
|
});
|
|
4302
4579
|
const assetTarget = cfg.assetUrl ?? cfg.thumbnailUrl;
|
|
4303
4580
|
if (assetTarget) {
|
|
4304
|
-
this.
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4581
|
+
await this.loadAvatarAsset(cfg, assetTarget);
|
|
4582
|
+
}
|
|
4583
|
+
this.startConfigRevalidationScheduler();
|
|
4584
|
+
}
|
|
4585
|
+
async loadAvatarAsset(cfg, assetTarget) {
|
|
4586
|
+
this.events.emit("asiyst:avatar:loading", {
|
|
4587
|
+
avatarId: this.options.avatarId ?? cfg.avatarId,
|
|
4588
|
+
assetUrl: assetTarget
|
|
4589
|
+
});
|
|
4590
|
+
void this.cloud.sendTelemetryEvent("avatar_asset_loading_started", {
|
|
4591
|
+
avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
|
|
4592
|
+
assetUrl: assetTarget
|
|
4593
|
+
});
|
|
4594
|
+
try {
|
|
4595
|
+
const loaded = await this.renderer.loadAsset(cfg);
|
|
4596
|
+
if (loaded) {
|
|
4597
|
+
this.movement.goToAnchor();
|
|
4598
|
+
const format = this.renderer.getLoadedFormat();
|
|
4599
|
+
const assetUrl = this.renderer.getAssetUrl();
|
|
4600
|
+
const isRendered = this.renderer.isRendered();
|
|
4601
|
+
this.events.emit("asiyst:avatar:loaded", {
|
|
4602
|
+
avatarId: this.options.avatarId ?? cfg.avatarId,
|
|
4603
|
+
assetUrl,
|
|
4604
|
+
format
|
|
4605
|
+
});
|
|
4606
|
+
void this.cloud.sendTelemetryEvent("avatar_asset_loaded", {
|
|
4607
|
+
avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
|
|
4608
|
+
avatarName: cfg.avatarName,
|
|
4609
|
+
assetUrl,
|
|
4610
|
+
format,
|
|
4611
|
+
publishedVersion: cfg.publishedVersion
|
|
4612
|
+
});
|
|
4613
|
+
if (isRendered) {
|
|
4614
|
+
this.events.emit("asiyst:avatar:rendered", {
|
|
4320
4615
|
avatarId: this.options.avatarId ?? cfg.avatarId,
|
|
4321
|
-
assetUrl,
|
|
4322
4616
|
format
|
|
4323
4617
|
});
|
|
4324
|
-
void this.cloud.sendTelemetryEvent("
|
|
4618
|
+
void this.cloud.sendTelemetryEvent("avatar_rendered", {
|
|
4325
4619
|
avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
|
|
4326
4620
|
avatarName: cfg.avatarName,
|
|
4327
|
-
assetUrl,
|
|
4328
4621
|
format,
|
|
4329
4622
|
publishedVersion: cfg.publishedVersion
|
|
4330
4623
|
});
|
|
4331
|
-
if (isRendered) {
|
|
4332
|
-
this.events.emit("asiyst:avatar:rendered", {
|
|
4333
|
-
avatarId: this.options.avatarId ?? cfg.avatarId,
|
|
4334
|
-
format
|
|
4335
|
-
});
|
|
4336
|
-
void this.cloud.sendTelemetryEvent("avatar_rendered", {
|
|
4337
|
-
avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
|
|
4338
|
-
avatarName: cfg.avatarName,
|
|
4339
|
-
format,
|
|
4340
|
-
publishedVersion: cfg.publishedVersion
|
|
4341
|
-
});
|
|
4342
|
-
}
|
|
4343
|
-
} else {
|
|
4344
|
-
const err = this.renderer.getLastError() ?? "Avatar asset loading failed";
|
|
4345
|
-
this.events.emit("asiyst:avatar:error", {
|
|
4346
|
-
avatarId: this.options.avatarId ?? cfg.avatarId,
|
|
4347
|
-
error: err,
|
|
4348
|
-
stage: "renderer_init"
|
|
4349
|
-
});
|
|
4350
|
-
void this.cloud.sendTelemetryEvent("avatar_render_failed", {
|
|
4351
|
-
avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
|
|
4352
|
-
error: err,
|
|
4353
|
-
stage: "renderer_init"
|
|
4354
|
-
});
|
|
4355
4624
|
}
|
|
4356
|
-
|
|
4357
|
-
|
|
4625
|
+
return true;
|
|
4626
|
+
} else {
|
|
4627
|
+
const err = this.renderer.getLastError() ?? "Avatar asset loading failed";
|
|
4358
4628
|
this.events.emit("asiyst:avatar:error", {
|
|
4359
4629
|
avatarId: this.options.avatarId ?? cfg.avatarId,
|
|
4360
4630
|
error: err,
|
|
4361
|
-
stage: "
|
|
4631
|
+
stage: "renderer_init"
|
|
4362
4632
|
});
|
|
4363
4633
|
void this.cloud.sendTelemetryEvent("avatar_render_failed", {
|
|
4364
4634
|
avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
|
|
4365
4635
|
error: err,
|
|
4366
|
-
stage: "
|
|
4636
|
+
stage: "renderer_init"
|
|
4367
4637
|
});
|
|
4638
|
+
return false;
|
|
4639
|
+
}
|
|
4640
|
+
} catch (error) {
|
|
4641
|
+
const err = error instanceof Error ? error.message : "Avatar asset rendering failed";
|
|
4642
|
+
this.events.emit("asiyst:avatar:error", {
|
|
4643
|
+
avatarId: this.options.avatarId ?? cfg.avatarId,
|
|
4644
|
+
error: err,
|
|
4645
|
+
stage: "asset_fetch"
|
|
4646
|
+
});
|
|
4647
|
+
void this.cloud.sendTelemetryEvent("avatar_render_failed", {
|
|
4648
|
+
avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
|
|
4649
|
+
error: err,
|
|
4650
|
+
stage: "asset_fetch"
|
|
4651
|
+
});
|
|
4652
|
+
return false;
|
|
4653
|
+
}
|
|
4654
|
+
}
|
|
4655
|
+
startConfigRevalidationScheduler() {
|
|
4656
|
+
if (this.configRevalidationTimer) {
|
|
4657
|
+
clearInterval(this.configRevalidationTimer);
|
|
4658
|
+
}
|
|
4659
|
+
this.configRevalidationTimer = setInterval(() => {
|
|
4660
|
+
if (!this.destroyed) {
|
|
4661
|
+
void this.config.refresh();
|
|
4662
|
+
}
|
|
4663
|
+
}, CONFIG_REVALIDATION_INTERVAL_MS);
|
|
4664
|
+
}
|
|
4665
|
+
async applyUpdatedConfig(newConfig, prevConfig) {
|
|
4666
|
+
if (this.destroyed) return;
|
|
4667
|
+
const domainCheck = validateWebsiteDomain(newConfig, window.location.href);
|
|
4668
|
+
if (!domainCheck.allowed) {
|
|
4669
|
+
this.connectionStatus = "disconnected";
|
|
4670
|
+
this.verificationStatus = "not_detected";
|
|
4671
|
+
this.events.emit("asiyst:error", {
|
|
4672
|
+
code: "domain_not_authorized",
|
|
4673
|
+
message: "This website is not authorized for the updated Asiyst configuration."
|
|
4674
|
+
});
|
|
4675
|
+
return;
|
|
4676
|
+
}
|
|
4677
|
+
const assetUrlChanged = newConfig.assetUrl !== prevConfig?.assetUrl || newConfig.thumbnailUrl !== prevConfig?.thumbnailUrl;
|
|
4678
|
+
if (assetUrlChanged && (newConfig.assetUrl || newConfig.thumbnailUrl)) {
|
|
4679
|
+
const target = newConfig.assetUrl ?? newConfig.thumbnailUrl ?? "";
|
|
4680
|
+
await this.loadAvatarAsset(newConfig, target);
|
|
4681
|
+
} else {
|
|
4682
|
+
const animationsChanged = JSON.stringify(newConfig.animations) !== JSON.stringify(prevConfig?.animations);
|
|
4683
|
+
if (animationsChanged && newConfig.animations && newConfig.animations.length > 0) {
|
|
4684
|
+
const fbxRenderer = this.renderer.getFbxRenderer();
|
|
4685
|
+
if (fbxRenderer) {
|
|
4686
|
+
void fbxRenderer.loadExternalAnimations(newConfig.animations);
|
|
4687
|
+
}
|
|
4368
4688
|
}
|
|
4369
4689
|
}
|
|
4690
|
+
this.avatar.applyConfig(newConfig);
|
|
4691
|
+
if (newConfig.position !== prevConfig?.position || newConfig.size !== prevConfig?.size) {
|
|
4692
|
+
this.movement.goToAnchor();
|
|
4693
|
+
}
|
|
4694
|
+
this.events.emit("asiyst:config:updated", {
|
|
4695
|
+
config: newConfig,
|
|
4696
|
+
previousVersion: prevConfig?.version
|
|
4697
|
+
});
|
|
4698
|
+
}
|
|
4699
|
+
async reloadConfig() {
|
|
4700
|
+
const updated = await this.config.refresh({ force: true });
|
|
4701
|
+
await this.applyUpdatedConfig(updated, this.config.get());
|
|
4702
|
+
return updated;
|
|
4703
|
+
}
|
|
4704
|
+
async updateConfig(partial) {
|
|
4705
|
+
const prev = this.config.get();
|
|
4706
|
+
const updated = this.config.applyLocalUpdate(partial);
|
|
4707
|
+
await this.applyUpdatedConfig(updated, prev);
|
|
4708
|
+
}
|
|
4709
|
+
playAnimation(nameOrIntent, options) {
|
|
4710
|
+
const played = this.renderer.playAnimation?.(nameOrIntent, options?.loopMode) ?? false;
|
|
4711
|
+
if (played) {
|
|
4712
|
+
this.events.emit("asiyst:animation:played", { name: nameOrIntent, intent: options?.loopMode });
|
|
4713
|
+
} else {
|
|
4714
|
+
this.events.emit("asiyst:animation:error", {
|
|
4715
|
+
name: nameOrIntent,
|
|
4716
|
+
error: `Animation "${nameOrIntent}" not found or incompatible with current skeleton`
|
|
4717
|
+
});
|
|
4718
|
+
}
|
|
4719
|
+
return played;
|
|
4370
4720
|
}
|
|
4371
4721
|
getConnectionStatus() {
|
|
4372
4722
|
return this.connectionStatus;
|
|
@@ -4427,6 +4777,10 @@ var AsiystRuntime = class {
|
|
|
4427
4777
|
clearInterval(this.heartbeatTimer);
|
|
4428
4778
|
this.heartbeatTimer = void 0;
|
|
4429
4779
|
}
|
|
4780
|
+
if (this.configRevalidationTimer) {
|
|
4781
|
+
clearInterval(this.configRevalidationTimer);
|
|
4782
|
+
this.configRevalidationTimer = void 0;
|
|
4783
|
+
}
|
|
4430
4784
|
const doc = this.host.host.ownerDocument;
|
|
4431
4785
|
if (doc && this.visibilityListener) {
|
|
4432
4786
|
doc.removeEventListener("visibilitychange", this.visibilityListener);
|
|
@@ -4696,6 +5050,12 @@ var Asiyst = {
|
|
|
4696
5050
|
getConfig() {
|
|
4697
5051
|
return requireRuntime().getConfig();
|
|
4698
5052
|
},
|
|
5053
|
+
async reloadConfig() {
|
|
5054
|
+
return requireRuntime().reloadConfig();
|
|
5055
|
+
},
|
|
5056
|
+
async updateConfig(partial) {
|
|
5057
|
+
await requireRuntime().updateConfig(partial);
|
|
5058
|
+
},
|
|
4699
5059
|
getConnectionStatus() {
|
|
4700
5060
|
return requireRuntime().getConnectionStatus();
|
|
4701
5061
|
},
|
|
@@ -4730,6 +5090,9 @@ var Asiyst = {
|
|
|
4730
5090
|
celebrate() {
|
|
4731
5091
|
withIsolation(() => requireRuntime().avatarApi().celebrate());
|
|
4732
5092
|
},
|
|
5093
|
+
playAnimation(nameOrIntent, options) {
|
|
5094
|
+
return requireRuntime().playAnimation(nameOrIntent, options);
|
|
5095
|
+
},
|
|
4733
5096
|
setPosition(x, y) {
|
|
4734
5097
|
withIsolation(() => requireRuntime().avatarApi().setPosition(x, y));
|
|
4735
5098
|
}
|