@asiyst/sdk 0.1.23 → 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 +846 -182
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +57 -10
- package/dist/index.d.ts +57 -10
- package/dist/index.js +846 -182
- 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
|
|
@@ -395,18 +396,22 @@ function normalizeProjectConfig(raw) {
|
|
|
395
396
|
return base;
|
|
396
397
|
}
|
|
397
398
|
const rawAvatarRecord = isRecord(raw.avatar) ? raw.avatar : void 0;
|
|
399
|
+
const rawConfigRecord = isRecord(raw.config) ? raw.config : void 0;
|
|
400
|
+
const rawManifestRecord = isRecord(raw.manifest) ? raw.manifest : void 0;
|
|
398
401
|
const avatarId = asString(
|
|
399
|
-
raw.avatarId ?? rawAvatarRecord?.avatarId ?? rawAvatarRecord?.id,
|
|
402
|
+
raw.avatarId ?? rawAvatarRecord?.avatarId ?? rawAvatarRecord?.id ?? rawConfigRecord?.avatarId,
|
|
400
403
|
"",
|
|
401
404
|
128
|
|
402
405
|
) || void 0;
|
|
403
|
-
const assetUrl = typeof raw.assetUrl === "string" ? raw.assetUrl : typeof rawAvatarRecord?.assetUrl === "string" ? rawAvatarRecord.assetUrl : void 0;
|
|
404
|
-
const thumbnailUrl = typeof raw.thumbnailUrl === "string" ? raw.thumbnailUrl : typeof rawAvatarRecord?.thumbnailUrl === "string" ? rawAvatarRecord.thumbnailUrl : rawAvatarRecord?.thumbnailUrl === null ? null : void 0;
|
|
405
|
-
const publishedVersion = typeof raw.publishedVersion === "string" ? raw.publishedVersion : typeof rawAvatarRecord?.version === "string" ? rawAvatarRecord.version : void 0;
|
|
406
|
-
const animations = parseAnimations(
|
|
407
|
-
|
|
406
|
+
const assetUrl = typeof raw.assetUrl === "string" && raw.assetUrl ? raw.assetUrl : typeof rawAvatarRecord?.assetUrl === "string" && rawAvatarRecord.assetUrl ? rawAvatarRecord.assetUrl : typeof rawAvatarRecord?.modelUrl === "string" && rawAvatarRecord.modelUrl ? rawAvatarRecord.modelUrl : typeof rawConfigRecord?.assetUrl === "string" && rawConfigRecord.assetUrl ? rawConfigRecord.assetUrl : typeof rawManifestRecord?.assetUrl === "string" && rawManifestRecord.assetUrl ? rawManifestRecord.assetUrl : typeof rawManifestRecord?.modelUrl === "string" && rawManifestRecord.modelUrl ? rawManifestRecord.modelUrl : void 0;
|
|
407
|
+
const thumbnailUrl = typeof raw.thumbnailUrl === "string" ? raw.thumbnailUrl : typeof rawAvatarRecord?.thumbnailUrl === "string" ? rawAvatarRecord.thumbnailUrl : typeof rawConfigRecord?.thumbnailUrl === "string" ? rawConfigRecord.thumbnailUrl : typeof rawManifestRecord?.thumbnailUrl === "string" ? rawManifestRecord.thumbnailUrl : rawAvatarRecord?.thumbnailUrl === null ? null : void 0;
|
|
408
|
+
const publishedVersion = typeof raw.publishedVersion === "string" ? raw.publishedVersion : typeof rawAvatarRecord?.version === "string" ? rawAvatarRecord.version : typeof rawManifestRecord?.version === "string" ? rawManifestRecord.version : void 0;
|
|
409
|
+
const animations = parseAnimations(
|
|
410
|
+
raw.animations ?? rawAvatarRecord?.animations ?? rawConfigRecord?.animations
|
|
411
|
+
);
|
|
412
|
+
const branding = parseBranding(raw.branding ?? rawAvatarRecord?.branding);
|
|
408
413
|
const avatarName = asString(
|
|
409
|
-
raw.avatarName ?? rawAvatarRecord?.name,
|
|
414
|
+
raw.avatarName ?? rawAvatarRecord?.name ?? rawConfigRecord?.avatarName ?? rawManifestRecord?.name,
|
|
410
415
|
base.avatarName,
|
|
411
416
|
40
|
|
412
417
|
);
|
|
@@ -670,39 +675,58 @@ var CloudClient = class {
|
|
|
670
675
|
const avatarAndKeyParams = `?projectId=${encodeURIComponent(this.projectId)}&publicKey=${encodeURIComponent(this.publicKey)}${this.avatarId ? `&avatarId=${encodeURIComponent(this.avatarId)}` : ""}`;
|
|
671
676
|
const baseUrl = this.getApiBaseUrl();
|
|
672
677
|
const resolveAssetUrls = (raw) => {
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
+
let canonicalBase = "https://asiyst.com";
|
|
679
|
+
try {
|
|
680
|
+
if (baseUrl) {
|
|
681
|
+
const u = new URL(baseUrl);
|
|
682
|
+
canonicalBase = u.origin;
|
|
678
683
|
}
|
|
679
|
-
|
|
680
|
-
|
|
684
|
+
} catch {
|
|
685
|
+
canonicalBase = "https://asiyst.com";
|
|
686
|
+
}
|
|
687
|
+
const toAbsolute = (url) => {
|
|
688
|
+
if (typeof url === "string" && url.startsWith("/")) {
|
|
689
|
+
return new URL(url, canonicalBase).href;
|
|
681
690
|
}
|
|
691
|
+
return url;
|
|
692
|
+
};
|
|
693
|
+
if (raw.avatar && typeof raw.avatar === "object" && !Array.isArray(raw.avatar)) {
|
|
694
|
+
const av = { ...raw.avatar };
|
|
695
|
+
av.assetUrl = toAbsolute(av.assetUrl);
|
|
696
|
+
av.thumbnailUrl = toAbsolute(av.thumbnailUrl);
|
|
697
|
+
av.modelUrl = toAbsolute(av.modelUrl);
|
|
698
|
+
av.manifestUrl = toAbsolute(av.manifestUrl);
|
|
682
699
|
if (Array.isArray(av.animations)) {
|
|
683
700
|
av.animations = av.animations.map((item) => {
|
|
684
701
|
if (item && typeof item === "object") {
|
|
685
702
|
const animObj = item;
|
|
686
|
-
|
|
687
|
-
return { ...animObj, assetUrl: new URL(animObj.assetUrl, canonicalBase).href };
|
|
688
|
-
}
|
|
703
|
+
return { ...animObj, assetUrl: toAbsolute(animObj.assetUrl) };
|
|
689
704
|
}
|
|
690
705
|
return item;
|
|
691
706
|
});
|
|
692
707
|
}
|
|
693
708
|
raw.avatar = av;
|
|
694
709
|
}
|
|
695
|
-
if (typeof raw.
|
|
696
|
-
|
|
710
|
+
if (raw.config && typeof raw.config === "object" && !Array.isArray(raw.config)) {
|
|
711
|
+
const cfg = { ...raw.config };
|
|
712
|
+
cfg.assetUrl = toAbsolute(cfg.assetUrl);
|
|
713
|
+
cfg.thumbnailUrl = toAbsolute(cfg.thumbnailUrl);
|
|
714
|
+
cfg.manifestUrl = toAbsolute(cfg.manifestUrl);
|
|
715
|
+
raw.config = cfg;
|
|
697
716
|
}
|
|
698
|
-
if (typeof raw.
|
|
699
|
-
|
|
717
|
+
if (raw.manifest && typeof raw.manifest === "object" && !Array.isArray(raw.manifest)) {
|
|
718
|
+
const mf = { ...raw.manifest };
|
|
719
|
+
mf.assetUrl = toAbsolute(mf.assetUrl);
|
|
720
|
+
mf.thumbnailUrl = toAbsolute(mf.thumbnailUrl);
|
|
721
|
+
mf.modelUrl = toAbsolute(mf.modelUrl);
|
|
722
|
+
raw.manifest = mf;
|
|
700
723
|
}
|
|
724
|
+
raw.assetUrl = toAbsolute(raw.assetUrl);
|
|
725
|
+
raw.thumbnailUrl = toAbsolute(raw.thumbnailUrl);
|
|
726
|
+
raw.manifestUrl = toAbsolute(raw.manifestUrl);
|
|
701
727
|
if (raw.branding && typeof raw.branding === "object" && !Array.isArray(raw.branding)) {
|
|
702
728
|
const br = { ...raw.branding };
|
|
703
|
-
|
|
704
|
-
br.siteLogoUrl = new URL(br.siteLogoUrl, canonicalBase).href;
|
|
705
|
-
}
|
|
729
|
+
br.siteLogoUrl = toAbsolute(br.siteLogoUrl);
|
|
706
730
|
raw.branding = br;
|
|
707
731
|
}
|
|
708
732
|
return raw;
|
|
@@ -715,8 +739,11 @@ var CloudClient = class {
|
|
|
715
739
|
idempotent: true
|
|
716
740
|
});
|
|
717
741
|
if (response.ok && response.data) {
|
|
718
|
-
const
|
|
719
|
-
|
|
742
|
+
const fullData = response.data && typeof response.data === "object" && !Array.isArray(response.data) ? {
|
|
743
|
+
...response.data,
|
|
744
|
+
...response.data.config && typeof response.data.config === "object" ? response.data.config : {}
|
|
745
|
+
} : {};
|
|
746
|
+
return normalizeProjectConfig(resolveAssetUrls(fullData));
|
|
720
747
|
}
|
|
721
748
|
if (response.status === 404) {
|
|
722
749
|
lastError = new ConfigurationError(`Project ${this.projectId} or avatar configuration not found`);
|
|
@@ -1034,7 +1061,7 @@ var ConfigCache = class {
|
|
|
1034
1061
|
constructor(storage) {
|
|
1035
1062
|
this.storage = storage;
|
|
1036
1063
|
}
|
|
1037
|
-
read(projectId) {
|
|
1064
|
+
read(projectId, ignoreTtl = false) {
|
|
1038
1065
|
const raw = this.storage.read("config");
|
|
1039
1066
|
if (!raw) {
|
|
1040
1067
|
return null;
|
|
@@ -1044,7 +1071,7 @@ var ConfigCache = class {
|
|
|
1044
1071
|
if (parsed.schemaVersion !== CONFIG_SCHEMA_VERSION || parsed.projectId !== projectId) {
|
|
1045
1072
|
return null;
|
|
1046
1073
|
}
|
|
1047
|
-
if (Date.now() - parsed.fetchedAt > CONFIG_CACHE_TTL_MS) {
|
|
1074
|
+
if (!ignoreTtl && Date.now() - parsed.fetchedAt > CONFIG_CACHE_TTL_MS) {
|
|
1048
1075
|
return null;
|
|
1049
1076
|
}
|
|
1050
1077
|
return normalizeProjectConfig(parsed.config);
|
|
@@ -1052,15 +1079,35 @@ var ConfigCache = class {
|
|
|
1052
1079
|
return null;
|
|
1053
1080
|
}
|
|
1054
1081
|
}
|
|
1055
|
-
|
|
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) {
|
|
1056
1098
|
const envelope = {
|
|
1057
1099
|
schemaVersion: CONFIG_SCHEMA_VERSION,
|
|
1058
1100
|
projectId,
|
|
1059
1101
|
fetchedAt: Date.now(),
|
|
1102
|
+
etag: meta?.etag,
|
|
1103
|
+
revision: meta?.revision ?? config.version,
|
|
1060
1104
|
config
|
|
1061
1105
|
};
|
|
1062
1106
|
this.storage.write("config", JSON.stringify(envelope));
|
|
1063
1107
|
}
|
|
1108
|
+
clear() {
|
|
1109
|
+
this.storage.remove("config");
|
|
1110
|
+
}
|
|
1064
1111
|
};
|
|
1065
1112
|
|
|
1066
1113
|
// src/config/ConfigManager.ts
|
|
@@ -1069,6 +1116,7 @@ var ConfigManager = class {
|
|
|
1069
1116
|
this.options = options;
|
|
1070
1117
|
this.cloud = cloud;
|
|
1071
1118
|
this.events = events;
|
|
1119
|
+
this.inFlightRefresh = null;
|
|
1072
1120
|
const credentials = validateInitOptions(options);
|
|
1073
1121
|
this.options = { ...options, ...credentials };
|
|
1074
1122
|
this.cache = new ConfigCache(
|
|
@@ -1080,13 +1128,34 @@ var ConfigManager = class {
|
|
|
1080
1128
|
get() {
|
|
1081
1129
|
return this.current;
|
|
1082
1130
|
}
|
|
1083
|
-
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;
|
|
1084
1144
|
try {
|
|
1085
1145
|
const remote = await this.cloud.fetchConfig();
|
|
1086
|
-
|
|
1087
|
-
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
|
+
}
|
|
1088
1153
|
return this.current;
|
|
1089
1154
|
} catch (error) {
|
|
1155
|
+
const lastKnownGood = this.cache.read(this.options.projectId, true);
|
|
1156
|
+
if (lastKnownGood) {
|
|
1157
|
+
this.current = lastKnownGood;
|
|
1158
|
+
}
|
|
1090
1159
|
this.events.emit("asiyst:error", {
|
|
1091
1160
|
code: "config_refresh_failed",
|
|
1092
1161
|
message: error instanceof Error ? error.message : "Failed to refresh configuration"
|
|
@@ -1094,6 +1163,18 @@ var ConfigManager = class {
|
|
|
1094
1163
|
return this.current;
|
|
1095
1164
|
}
|
|
1096
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
|
+
}
|
|
1097
1178
|
localFallback() {
|
|
1098
1179
|
const base = fallbackConfig();
|
|
1099
1180
|
return {
|
|
@@ -1752,16 +1833,37 @@ var AssetLoader = class {
|
|
|
1752
1833
|
constructor() {
|
|
1753
1834
|
this.inFlightController = null;
|
|
1754
1835
|
this.createdObjectUrls = [];
|
|
1836
|
+
this.inFlightLoads = /* @__PURE__ */ new Map();
|
|
1837
|
+
this.cachedAssets = /* @__PURE__ */ new Map();
|
|
1755
1838
|
}
|
|
1756
1839
|
async load(assetUrl, options) {
|
|
1757
|
-
const startTime = Date.now();
|
|
1758
1840
|
const sanitizedUrl = sanitizeText(assetUrl.trim(), 2048);
|
|
1759
1841
|
if (!sanitizedUrl) {
|
|
1760
1842
|
throw new Error("Asset URL is required");
|
|
1761
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();
|
|
1762
1864
|
this.inFlightController = new AbortController();
|
|
1763
1865
|
const abortSignal = options?.signal ? anySignal([this.inFlightController.signal, options.signal]) : this.inFlightController.signal;
|
|
1764
|
-
const timeoutMs = options?.timeoutMs ??
|
|
1866
|
+
const timeoutMs = options?.timeoutMs ?? 6e4;
|
|
1765
1867
|
const timeoutId = setTimeout(() => {
|
|
1766
1868
|
this.inFlightController?.abort();
|
|
1767
1869
|
}, timeoutMs);
|
|
@@ -1801,6 +1903,9 @@ var AssetLoader = class {
|
|
|
1801
1903
|
throw new Error(`Avatar asset download failed: HTTP ${response.status} from ${sanitizedUrl}`);
|
|
1802
1904
|
}
|
|
1803
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
|
+
}
|
|
1804
1909
|
if (isJsonExtension || contentType.includes("application/json")) {
|
|
1805
1910
|
const text = await response.text();
|
|
1806
1911
|
let manifest;
|
|
@@ -1834,6 +1939,11 @@ var AssetLoader = class {
|
|
|
1834
1939
|
if (arrayBuffer.byteLength < 12) {
|
|
1835
1940
|
throw new Error("Avatar asset payload is too small to be a valid 3D container");
|
|
1836
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
|
+
}
|
|
1837
1947
|
if (isFbxExtension || this.isFbxBuffer(arrayBuffer) || !isGlbExtension && !this.isGlbBuffer(arrayBuffer)) {
|
|
1838
1948
|
const fbxHeader = this.parseFbxHeader(arrayBuffer);
|
|
1839
1949
|
const resourcePath = sanitizedUrl.includes("/") ? sanitizedUrl.substring(0, sanitizedUrl.lastIndexOf("/") + 1) : "";
|
|
@@ -2079,6 +2189,8 @@ var AssetLoader = class {
|
|
|
2079
2189
|
this.inFlightController.abort();
|
|
2080
2190
|
this.inFlightController = null;
|
|
2081
2191
|
}
|
|
2192
|
+
this.inFlightLoads.clear();
|
|
2193
|
+
this.cachedAssets.clear();
|
|
2082
2194
|
if (typeof URL !== "undefined" && typeof URL.revokeObjectURL === "function") {
|
|
2083
2195
|
for (const objUrl of this.createdObjectUrls) {
|
|
2084
2196
|
try {
|
|
@@ -2108,7 +2220,12 @@ var FbxRenderer = class {
|
|
|
2108
2220
|
this.scene = null;
|
|
2109
2221
|
this.camera = null;
|
|
2110
2222
|
this.modelRoot = null;
|
|
2223
|
+
this.rawObject = null;
|
|
2111
2224
|
this.mixer = null;
|
|
2225
|
+
this.allAnimations = [];
|
|
2226
|
+
this.animationMetadataList = [];
|
|
2227
|
+
this.assetLoader = new AssetLoader();
|
|
2228
|
+
this.currentAction = null;
|
|
2112
2229
|
this.animFrameId = null;
|
|
2113
2230
|
this.lastTime = 0;
|
|
2114
2231
|
this.facing = "right";
|
|
@@ -2123,39 +2240,59 @@ var FbxRenderer = class {
|
|
|
2123
2240
|
this.canvas = doc.createElement("canvas");
|
|
2124
2241
|
this.canvas.className = "asiyst-avatar-canvas";
|
|
2125
2242
|
this.canvas.setAttribute("role", "presentation");
|
|
2243
|
+
this.canvas.style.opacity = "0";
|
|
2244
|
+
this.canvas.style.transition = "opacity 0.25s ease";
|
|
2126
2245
|
const glContext = this.canvas.getContext("webgl2") || this.canvas.getContext("webgl");
|
|
2127
2246
|
if (!glContext) {
|
|
2128
2247
|
throw new Error("WebGLRenderingContext is not available or supported in this browser environment");
|
|
2129
2248
|
}
|
|
2249
|
+
const isMobile = typeof window !== "undefined" && window.innerWidth <= 640;
|
|
2250
|
+
const width = options?.width || (isMobile ? 180 : 240);
|
|
2251
|
+
const height = options?.height || (isMobile ? 360 : 460);
|
|
2130
2252
|
const dpr = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
2131
|
-
|
|
2132
|
-
this.canvas.
|
|
2133
|
-
this.canvas.
|
|
2253
|
+
this.canvas.width = Math.round(width * dpr);
|
|
2254
|
+
this.canvas.height = Math.round(height * dpr);
|
|
2255
|
+
this.canvas.style.width = `${width}px`;
|
|
2256
|
+
this.canvas.style.height = `${height}px`;
|
|
2134
2257
|
try {
|
|
2135
2258
|
this.renderer = new THREE__namespace.WebGLRenderer({
|
|
2136
2259
|
canvas: this.canvas,
|
|
2137
2260
|
alpha: true,
|
|
2138
2261
|
antialias: true,
|
|
2139
|
-
powerPreference: "
|
|
2262
|
+
powerPreference: "high-performance"
|
|
2140
2263
|
});
|
|
2141
2264
|
this.renderer.setPixelRatio(Math.min(dpr, 2));
|
|
2142
|
-
this.renderer.setSize(
|
|
2265
|
+
this.renderer.setSize(width, height, false);
|
|
2143
2266
|
this.renderer.outputColorSpace = THREE__namespace.SRGBColorSpace;
|
|
2267
|
+
this.renderer.shadowMap.enabled = true;
|
|
2268
|
+
this.renderer.shadowMap.type = THREE__namespace.PCFSoftShadowMap;
|
|
2144
2269
|
} catch (err) {
|
|
2145
2270
|
const msg = err instanceof Error ? err.message : String(err);
|
|
2146
2271
|
throw new Error(`Failed to initialize WebGLRenderer: ${msg}`);
|
|
2147
2272
|
}
|
|
2148
2273
|
this.scene = new THREE__namespace.Scene();
|
|
2149
|
-
this.camera = new THREE__namespace.PerspectiveCamera(
|
|
2150
|
-
this.camera.position.set(0, 0, 3.4);
|
|
2274
|
+
this.camera = new THREE__namespace.PerspectiveCamera(45, width / height, 0.1, 100);
|
|
2151
2275
|
const ambientLight = new THREE__namespace.AmbientLight(16777215, 1.2);
|
|
2152
2276
|
this.scene.add(ambientLight);
|
|
2153
|
-
const keyLight = new THREE__namespace.DirectionalLight(
|
|
2154
|
-
keyLight.position.set(
|
|
2277
|
+
const keyLight = new THREE__namespace.DirectionalLight(16774634, 2);
|
|
2278
|
+
keyLight.position.set(3, 4, 3);
|
|
2279
|
+
keyLight.castShadow = true;
|
|
2280
|
+
keyLight.shadow.mapSize.width = 512;
|
|
2281
|
+
keyLight.shadow.mapSize.height = 512;
|
|
2155
2282
|
this.scene.add(keyLight);
|
|
2156
|
-
const fillLight = new THREE__namespace.DirectionalLight(
|
|
2157
|
-
fillLight.position.set(-
|
|
2283
|
+
const fillLight = new THREE__namespace.DirectionalLight(15459032, 1.2);
|
|
2284
|
+
fillLight.position.set(-3, 2, 2);
|
|
2158
2285
|
this.scene.add(fillLight);
|
|
2286
|
+
const rimLight = new THREE__namespace.DirectionalLight(16771286, 1.5);
|
|
2287
|
+
rimLight.position.set(0, 4, -3);
|
|
2288
|
+
this.scene.add(rimLight);
|
|
2289
|
+
const shadowGeo = new THREE__namespace.PlaneGeometry(3, 3);
|
|
2290
|
+
const shadowMat = new THREE__namespace.ShadowMaterial({ opacity: 0.15 });
|
|
2291
|
+
const shadowPlane = new THREE__namespace.Mesh(shadowGeo, shadowMat);
|
|
2292
|
+
shadowPlane.rotation.x = -Math.PI / 2;
|
|
2293
|
+
shadowPlane.position.y = 0;
|
|
2294
|
+
shadowPlane.receiveShadow = true;
|
|
2295
|
+
this.scene.add(shadowPlane);
|
|
2159
2296
|
let rawObject;
|
|
2160
2297
|
let modelAnimations = [];
|
|
2161
2298
|
if (asset.format === "fbx") {
|
|
@@ -2192,32 +2329,40 @@ var FbxRenderer = class {
|
|
|
2192
2329
|
}
|
|
2193
2330
|
}
|
|
2194
2331
|
const { meshCount, vertexCount: totalVertices } = this.validateGeometry(rawObject);
|
|
2195
|
-
const
|
|
2196
|
-
if (
|
|
2332
|
+
const rawBox = new THREE__namespace.Box3().setFromObject(rawObject);
|
|
2333
|
+
if (rawBox.isEmpty()) {
|
|
2197
2334
|
throw new Error("FBX asset geometry bounding box is empty");
|
|
2198
2335
|
}
|
|
2199
|
-
const
|
|
2200
|
-
|
|
2201
|
-
const
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
rawObject.position.z -= center.z;
|
|
2336
|
+
const rawSize = rawBox.getSize(new THREE__namespace.Vector3());
|
|
2337
|
+
const rawCenter = rawBox.getCenter(new THREE__namespace.Vector3());
|
|
2338
|
+
const rawHeight = rawSize.y > 0 ? rawSize.y : 1.8;
|
|
2339
|
+
rawObject.position.set(-rawCenter.x, -rawBox.min.y, -rawCenter.z);
|
|
2340
|
+
const targetVisualHeight = 1.8;
|
|
2341
|
+
const targetScale = targetVisualHeight / rawHeight;
|
|
2206
2342
|
this.modelRoot = new THREE__namespace.Group();
|
|
2207
2343
|
this.modelRoot.add(rawObject);
|
|
2344
|
+
this.modelRoot.scale.setScalar(targetScale);
|
|
2208
2345
|
this.scene.add(this.modelRoot);
|
|
2209
|
-
const
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2346
|
+
const visualCenterY = targetVisualHeight * 0.52;
|
|
2347
|
+
const fovRadians = this.camera.fov * Math.PI / 180;
|
|
2348
|
+
const fitDist = Math.max(2.4, targetVisualHeight / 2 / Math.tan(fovRadians / 2) * 1.25);
|
|
2349
|
+
this.camera.position.set(0, visualCenterY + 0.1, fitDist);
|
|
2350
|
+
this.camera.lookAt(0, visualCenterY, 0);
|
|
2351
|
+
rawObject.traverse((child) => {
|
|
2352
|
+
const mesh = child;
|
|
2353
|
+
if (mesh.isMesh) {
|
|
2354
|
+
mesh.castShadow = true;
|
|
2355
|
+
mesh.receiveShadow = true;
|
|
2356
|
+
}
|
|
2357
|
+
});
|
|
2358
|
+
this.rawObject = rawObject;
|
|
2359
|
+
this.mixer = new THREE__namespace.AnimationMixer(rawObject);
|
|
2360
|
+
this.allAnimations = [...modelAnimations];
|
|
2215
2361
|
if (modelAnimations.length > 0) {
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
action.play();
|
|
2362
|
+
const idleClip = modelAnimations.find((c) => c.name.toLowerCase().includes("idle")) || modelAnimations[0];
|
|
2363
|
+
if (idleClip) {
|
|
2364
|
+
this.currentAction = this.mixer.clipAction(idleClip);
|
|
2365
|
+
this.currentAction.play();
|
|
2221
2366
|
}
|
|
2222
2367
|
}
|
|
2223
2368
|
container.replaceChildren();
|
|
@@ -2225,6 +2370,9 @@ var FbxRenderer = class {
|
|
|
2225
2370
|
try {
|
|
2226
2371
|
this.renderer.render(this.scene, this.camera);
|
|
2227
2372
|
this.initialRenderCompleted = true;
|
|
2373
|
+
if (this.canvas) {
|
|
2374
|
+
this.canvas.style.opacity = "1";
|
|
2375
|
+
}
|
|
2228
2376
|
} catch (renderErr) {
|
|
2229
2377
|
const msg = renderErr instanceof Error ? renderErr.message : String(renderErr);
|
|
2230
2378
|
throw new Error(`Initial FBX WebGL render failed: ${msg}`);
|
|
@@ -2232,6 +2380,13 @@ var FbxRenderer = class {
|
|
|
2232
2380
|
this.startLoop();
|
|
2233
2381
|
this.setFacing(this.facing);
|
|
2234
2382
|
this.setPose(this.currentPose);
|
|
2383
|
+
if (options?.config?.animations && options.config.animations.length > 0) {
|
|
2384
|
+
void this.loadExternalAnimations(options.config.animations);
|
|
2385
|
+
}
|
|
2386
|
+
if (typeof window !== "undefined") {
|
|
2387
|
+
this.resizeListener = () => this.handleResize();
|
|
2388
|
+
window.addEventListener("resize", this.resizeListener);
|
|
2389
|
+
}
|
|
2235
2390
|
return {
|
|
2236
2391
|
meshCount,
|
|
2237
2392
|
vertexCount: totalVertices,
|
|
@@ -2247,6 +2402,34 @@ var FbxRenderer = class {
|
|
|
2247
2402
|
setPose(pose) {
|
|
2248
2403
|
this.currentPose = pose;
|
|
2249
2404
|
if (!this.modelRoot) return;
|
|
2405
|
+
if (this.playAnimation(pose)) {
|
|
2406
|
+
return;
|
|
2407
|
+
}
|
|
2408
|
+
if (this.mixer && this.allAnimations.length > 1) {
|
|
2409
|
+
let targetClip;
|
|
2410
|
+
if (pose === "speak") {
|
|
2411
|
+
targetClip = this.allAnimations.find(
|
|
2412
|
+
(c) => c.name.toLowerCase().includes("talk") || c.name.toLowerCase().includes("speak")
|
|
2413
|
+
);
|
|
2414
|
+
} else if (pose === "think") {
|
|
2415
|
+
targetClip = this.allAnimations.find(
|
|
2416
|
+
(c) => c.name.toLowerCase().includes("think")
|
|
2417
|
+
);
|
|
2418
|
+
} else {
|
|
2419
|
+
targetClip = this.allAnimations.find((c) => c.name.toLowerCase().includes("idle")) || this.allAnimations[0];
|
|
2420
|
+
}
|
|
2421
|
+
if (targetClip) {
|
|
2422
|
+
const newAction = this.mixer.clipAction(targetClip);
|
|
2423
|
+
if (newAction !== this.currentAction) {
|
|
2424
|
+
newAction.reset().fadeIn(0.25).play();
|
|
2425
|
+
if (this.currentAction) {
|
|
2426
|
+
this.currentAction.fadeOut(0.25);
|
|
2427
|
+
}
|
|
2428
|
+
this.currentAction = newAction;
|
|
2429
|
+
return;
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2250
2433
|
switch (pose) {
|
|
2251
2434
|
case "point":
|
|
2252
2435
|
this.modelRoot.rotation.z = -0.15;
|
|
@@ -2256,6 +2439,10 @@ var FbxRenderer = class {
|
|
|
2256
2439
|
this.modelRoot.rotation.z = 0.12;
|
|
2257
2440
|
this.modelRoot.rotation.x = -0.1;
|
|
2258
2441
|
break;
|
|
2442
|
+
case "speak":
|
|
2443
|
+
this.modelRoot.rotation.y = this.facing === "left" ? -0.22 : 0.22;
|
|
2444
|
+
this.modelRoot.rotation.x = 0.04;
|
|
2445
|
+
break;
|
|
2259
2446
|
case "celebrate":
|
|
2260
2447
|
this.modelRoot.rotation.z = 0;
|
|
2261
2448
|
this.modelRoot.rotation.x = -0.15;
|
|
@@ -2264,9 +2451,139 @@ var FbxRenderer = class {
|
|
|
2264
2451
|
default:
|
|
2265
2452
|
this.modelRoot.rotation.z = 0;
|
|
2266
2453
|
this.modelRoot.rotation.x = 0;
|
|
2454
|
+
this.modelRoot.rotation.y = this.facing === "left" ? -0.35 : 0.35;
|
|
2267
2455
|
break;
|
|
2268
2456
|
}
|
|
2269
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
|
+
}
|
|
2270
2587
|
isRendered() {
|
|
2271
2588
|
return this.initialRenderCompleted;
|
|
2272
2589
|
}
|
|
@@ -2308,6 +2625,10 @@ var FbxRenderer = class {
|
|
|
2308
2625
|
this.animFrameId = requestAnimationFrame(tick);
|
|
2309
2626
|
}
|
|
2310
2627
|
destroy() {
|
|
2628
|
+
if (typeof window !== "undefined" && this.resizeListener) {
|
|
2629
|
+
window.removeEventListener("resize", this.resizeListener);
|
|
2630
|
+
this.resizeListener = void 0;
|
|
2631
|
+
}
|
|
2311
2632
|
if (this.animFrameId !== null && typeof cancelAnimationFrame !== "undefined") {
|
|
2312
2633
|
cancelAnimationFrame(this.animFrameId);
|
|
2313
2634
|
this.animFrameId = null;
|
|
@@ -2349,10 +2670,39 @@ var FbxRenderer = class {
|
|
|
2349
2670
|
this.canvas.remove();
|
|
2350
2671
|
this.canvas = null;
|
|
2351
2672
|
}
|
|
2673
|
+
this.assetLoader.destroy();
|
|
2674
|
+
this.animationMetadataList.length = 0;
|
|
2675
|
+
this.allAnimations = [];
|
|
2676
|
+
this.currentAction = null;
|
|
2677
|
+
this.rawObject = null;
|
|
2352
2678
|
this.camera = null;
|
|
2353
2679
|
this.modelRoot = null;
|
|
2354
2680
|
this.initialRenderCompleted = false;
|
|
2355
2681
|
}
|
|
2682
|
+
handleResize() {
|
|
2683
|
+
if (!this.canvas || !this.renderer || !this.camera) return;
|
|
2684
|
+
const isMobile = typeof window !== "undefined" && window.innerWidth <= 640;
|
|
2685
|
+
const width = isMobile ? 180 : 240;
|
|
2686
|
+
const height = isMobile ? 360 : 460;
|
|
2687
|
+
const dpr = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
2688
|
+
this.canvas.width = Math.round(width * dpr);
|
|
2689
|
+
this.canvas.height = Math.round(height * dpr);
|
|
2690
|
+
this.canvas.style.width = `${width}px`;
|
|
2691
|
+
this.canvas.style.height = `${height}px`;
|
|
2692
|
+
this.camera.aspect = width / height;
|
|
2693
|
+
this.camera.updateProjectionMatrix();
|
|
2694
|
+
this.renderer.setPixelRatio(Math.min(dpr, 2));
|
|
2695
|
+
this.renderer.setSize(width, height, false);
|
|
2696
|
+
}
|
|
2697
|
+
getCamera() {
|
|
2698
|
+
return this.camera;
|
|
2699
|
+
}
|
|
2700
|
+
getModelRoot() {
|
|
2701
|
+
return this.modelRoot;
|
|
2702
|
+
}
|
|
2703
|
+
getMixer() {
|
|
2704
|
+
return this.mixer;
|
|
2705
|
+
}
|
|
2356
2706
|
};
|
|
2357
2707
|
|
|
2358
2708
|
// src/avatar/CssAvatarRenderer.ts
|
|
@@ -2363,7 +2713,7 @@ var AVATAR_CSS = `
|
|
|
2363
2713
|
display: flex;
|
|
2364
2714
|
flex-direction: column;
|
|
2365
2715
|
align-items: center;
|
|
2366
|
-
gap:
|
|
2716
|
+
gap: 4px;
|
|
2367
2717
|
pointer-events: auto;
|
|
2368
2718
|
user-select: none;
|
|
2369
2719
|
}
|
|
@@ -2384,28 +2734,38 @@ var AVATAR_CSS = `
|
|
|
2384
2734
|
padding: 0;
|
|
2385
2735
|
outline: none;
|
|
2386
2736
|
background: #2563eb;
|
|
2737
|
+
transition: width 0.3s ease, height 0.3s ease, background 0.3s ease;
|
|
2738
|
+
}
|
|
2739
|
+
.asiyst-figure.asiyst-3d-active {
|
|
2740
|
+
width: 240px !important;
|
|
2741
|
+
height: 460px !important;
|
|
2742
|
+
background: transparent !important;
|
|
2743
|
+
border-radius: 0 !important;
|
|
2744
|
+
box-shadow: none !important;
|
|
2745
|
+
overflow: visible !important;
|
|
2746
|
+
}
|
|
2747
|
+
@media (max-width: 640px) {
|
|
2748
|
+
.asiyst-figure.asiyst-3d-active {
|
|
2749
|
+
width: 180px !important;
|
|
2750
|
+
height: 360px !important;
|
|
2751
|
+
}
|
|
2387
2752
|
}
|
|
2388
|
-
.asiyst-figure[data-pose="point"] { transform: rotate(-12deg); }
|
|
2389
|
-
.asiyst-figure[data-pose="think"] { opacity: 0.85; }
|
|
2390
|
-
.asiyst-figure[data-pose="celebrate"] { transform: scale(1.08); }
|
|
2391
2753
|
.asiyst-avatar-viewport {
|
|
2392
|
-
position:
|
|
2393
|
-
inset: 0;
|
|
2754
|
+
position: relative;
|
|
2394
2755
|
width: 100%;
|
|
2395
2756
|
height: 100%;
|
|
2396
2757
|
display: grid;
|
|
2397
2758
|
place-items: center;
|
|
2398
2759
|
border-radius: inherit;
|
|
2399
|
-
overflow:
|
|
2400
|
-
pointer-events:
|
|
2760
|
+
overflow: visible;
|
|
2761
|
+
pointer-events: auto;
|
|
2401
2762
|
}
|
|
2402
2763
|
.asiyst-avatar-canvas {
|
|
2403
2764
|
width: 100%;
|
|
2404
2765
|
height: 100%;
|
|
2405
2766
|
object-fit: contain;
|
|
2406
|
-
border-radius: inherit;
|
|
2407
2767
|
display: block;
|
|
2408
|
-
pointer-events:
|
|
2768
|
+
pointer-events: auto;
|
|
2409
2769
|
}
|
|
2410
2770
|
.asiyst-avatar-graphic {
|
|
2411
2771
|
width: 100%;
|
|
@@ -2416,13 +2776,23 @@ var AVATAR_CSS = `
|
|
|
2416
2776
|
pointer-events: none;
|
|
2417
2777
|
}
|
|
2418
2778
|
.asiyst-avatar-loader {
|
|
2419
|
-
width:
|
|
2420
|
-
height:
|
|
2421
|
-
border: 3px solid rgba(
|
|
2422
|
-
border-top-color: #
|
|
2779
|
+
width: 34px;
|
|
2780
|
+
height: 34px;
|
|
2781
|
+
border: 3px solid rgba(37, 99, 235, 0.2);
|
|
2782
|
+
border-top-color: #2563eb;
|
|
2423
2783
|
border-radius: 50%;
|
|
2424
2784
|
animation: asiyst-spin 0.8s linear infinite;
|
|
2425
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
|
+
}
|
|
2426
2796
|
@keyframes asiyst-spin {
|
|
2427
2797
|
to { transform: rotate(360deg); }
|
|
2428
2798
|
}
|
|
@@ -2459,11 +2829,73 @@ var AVATAR_CSS = `
|
|
|
2459
2829
|
padding: 8px 10px;
|
|
2460
2830
|
font: 13px/1.4 system-ui, sans-serif;
|
|
2461
2831
|
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
|
|
2832
|
+
margin-bottom: 4px;
|
|
2833
|
+
}
|
|
2834
|
+
.asiyst-name-tag {
|
|
2835
|
+
display: inline-flex;
|
|
2836
|
+
align-items: center;
|
|
2837
|
+
gap: 6px;
|
|
2838
|
+
background: rgba(255, 255, 255, 0.95);
|
|
2839
|
+
backdrop-filter: blur(8px);
|
|
2840
|
+
border: 1px solid rgba(226, 232, 240, 0.9);
|
|
2841
|
+
border-radius: 9999px;
|
|
2842
|
+
padding: 4px 12px;
|
|
2843
|
+
font-size: 11px;
|
|
2844
|
+
font-weight: 700;
|
|
2845
|
+
color: #1e293b;
|
|
2846
|
+
box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
|
|
2847
|
+
user-select: none;
|
|
2848
|
+
margin-bottom: 2px;
|
|
2849
|
+
pointer-events: none;
|
|
2850
|
+
transition: opacity 0.2s ease;
|
|
2851
|
+
}
|
|
2852
|
+
.asiyst-name-sparkle { color: #f59e0b; font-size: 12px; font-weight: 900; }
|
|
2853
|
+
.asiyst-name-dot {
|
|
2854
|
+
width: 6px;
|
|
2855
|
+
height: 6px;
|
|
2856
|
+
border-radius: 50%;
|
|
2857
|
+
background: #10b981;
|
|
2858
|
+
display: inline-block;
|
|
2859
|
+
animation: asiyst-pulse 2s infinite;
|
|
2860
|
+
}
|
|
2861
|
+
.asiyst-name-status {
|
|
2862
|
+
font-size: 10px;
|
|
2863
|
+
color: #64748b;
|
|
2864
|
+
font-weight: 500;
|
|
2865
|
+
text-transform: uppercase;
|
|
2866
|
+
}
|
|
2867
|
+
@keyframes asiyst-pulse {
|
|
2868
|
+
0%, 100% { opacity: 1; transform: scale(1); }
|
|
2869
|
+
50% { opacity: 0.4; transform: scale(1.3); }
|
|
2870
|
+
}
|
|
2871
|
+
.asiyst-open-chat-btn {
|
|
2872
|
+
display: inline-flex;
|
|
2873
|
+
align-items: center;
|
|
2874
|
+
gap: 6px;
|
|
2875
|
+
background: #0f172a;
|
|
2876
|
+
color: #fbbf24;
|
|
2877
|
+
border: 1px solid rgba(245, 158, 11, 0.6);
|
|
2878
|
+
border-radius: 9999px;
|
|
2879
|
+
padding: 6px 14px;
|
|
2880
|
+
font-size: 12px;
|
|
2881
|
+
font-weight: 700;
|
|
2882
|
+
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
|
|
2883
|
+
cursor: pointer;
|
|
2884
|
+
margin-top: 4px;
|
|
2885
|
+
pointer-events: auto;
|
|
2886
|
+
transition: transform 0.15s ease, background-color 0.15s ease;
|
|
2887
|
+
}
|
|
2888
|
+
.asiyst-open-chat-btn:hover {
|
|
2889
|
+
transform: scale(1.05);
|
|
2890
|
+
background: #1e293b;
|
|
2891
|
+
}
|
|
2892
|
+
.asiyst-open-chat-btn svg {
|
|
2893
|
+
stroke: #fbbf24;
|
|
2462
2894
|
}
|
|
2463
|
-
.asiyst-name { font: 600 12px/1 system-ui, sans-serif; color: #0f172a; }
|
|
2464
2895
|
@media (prefers-reduced-motion: reduce) {
|
|
2465
2896
|
.asiyst-avatar.asiyst-animate { transition: none; }
|
|
2466
2897
|
.asiyst-avatar-loader { animation: none; }
|
|
2898
|
+
.asiyst-name-dot { animation: none; }
|
|
2467
2899
|
}
|
|
2468
2900
|
`;
|
|
2469
2901
|
var CssAvatarRenderer = class {
|
|
@@ -2474,12 +2906,14 @@ var CssAvatarRenderer = class {
|
|
|
2474
2906
|
this.pose = "idle";
|
|
2475
2907
|
this.accentColor = "#2563eb";
|
|
2476
2908
|
this.avatarName = "Asiyst";
|
|
2909
|
+
this.isPanelOpen = false;
|
|
2910
|
+
this.has3dAssetConfigured = false;
|
|
2477
2911
|
// Asset loading & rendering state
|
|
2478
2912
|
this.assetLoader = new AssetLoader();
|
|
2479
2913
|
this.fbxRenderer = null;
|
|
2480
2914
|
this.renderState = "idle";
|
|
2481
2915
|
this.isAssetLoadedFlag = false;
|
|
2482
|
-
this.isFallbackFlag =
|
|
2916
|
+
this.isFallbackFlag = false;
|
|
2483
2917
|
}
|
|
2484
2918
|
mount(container, config) {
|
|
2485
2919
|
const doc = container.ownerDocument;
|
|
@@ -2489,6 +2923,20 @@ var CssAvatarRenderer = class {
|
|
|
2489
2923
|
this.root = doc.createElement("div");
|
|
2490
2924
|
this.root.className = "asiyst-avatar asiyst-animate";
|
|
2491
2925
|
this.root.setAttribute("role", "img");
|
|
2926
|
+
this.nameTagEl = doc.createElement("div");
|
|
2927
|
+
this.nameTagEl.className = "asiyst-name-tag";
|
|
2928
|
+
const sparkle = doc.createElement("span");
|
|
2929
|
+
sparkle.className = "asiyst-name-sparkle";
|
|
2930
|
+
sparkle.textContent = "\u2726";
|
|
2931
|
+
this.nameTextEl = doc.createElement("span");
|
|
2932
|
+
this.nameTextEl.className = "asiyst-name-text";
|
|
2933
|
+
this.nameTextEl.textContent = config.avatarName;
|
|
2934
|
+
const dot = doc.createElement("span");
|
|
2935
|
+
dot.className = "asiyst-name-dot";
|
|
2936
|
+
this.statusTextEl = doc.createElement("span");
|
|
2937
|
+
this.statusTextEl.className = "asiyst-name-status";
|
|
2938
|
+
this.statusTextEl.textContent = "(IDLE)";
|
|
2939
|
+
this.nameTagEl.append(sparkle, this.nameTextEl, dot, this.statusTextEl);
|
|
2492
2940
|
this.figure = doc.createElement("button");
|
|
2493
2941
|
this.figure.type = "button";
|
|
2494
2942
|
this.figure.className = "asiyst-figure";
|
|
@@ -2497,12 +2945,26 @@ var CssAvatarRenderer = class {
|
|
|
2497
2945
|
this.viewport = doc.createElement("div");
|
|
2498
2946
|
this.viewport.className = "asiyst-avatar-viewport";
|
|
2499
2947
|
this.figure.appendChild(this.viewport);
|
|
2500
|
-
this.nameEl = doc.createElement("div");
|
|
2501
|
-
this.nameEl.className = "asiyst-name";
|
|
2502
2948
|
this.bubble = doc.createElement("div");
|
|
2503
2949
|
this.bubble.className = "asiyst-bubble";
|
|
2504
2950
|
this.bubble.hidden = true;
|
|
2505
|
-
this.
|
|
2951
|
+
this.chatActionBtn = doc.createElement("button");
|
|
2952
|
+
this.chatActionBtn.type = "button";
|
|
2953
|
+
this.chatActionBtn.className = "asiyst-open-chat-btn";
|
|
2954
|
+
this.chatActionBtn.innerHTML = `
|
|
2955
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
|
2956
|
+
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
|
|
2957
|
+
</svg>
|
|
2958
|
+
<span>Chat with ${config.avatarName}</span>
|
|
2959
|
+
`;
|
|
2960
|
+
this.chatActionBtn.addEventListener("click", (e) => {
|
|
2961
|
+
e.stopPropagation();
|
|
2962
|
+
this.onOpenChat?.();
|
|
2963
|
+
});
|
|
2964
|
+
this.figure.addEventListener("click", () => {
|
|
2965
|
+
this.onOpenChat?.();
|
|
2966
|
+
});
|
|
2967
|
+
this.root.append(this.bubble, this.nameTagEl, this.figure, this.chatActionBtn);
|
|
2506
2968
|
container.appendChild(this.root);
|
|
2507
2969
|
this.applyConfig(config);
|
|
2508
2970
|
}
|
|
@@ -2516,24 +2978,66 @@ var CssAvatarRenderer = class {
|
|
|
2516
2978
|
this.root = void 0;
|
|
2517
2979
|
this.figure = void 0;
|
|
2518
2980
|
this.viewport = void 0;
|
|
2981
|
+
this.nameTagEl = void 0;
|
|
2982
|
+
this.chatActionBtn = void 0;
|
|
2519
2983
|
}
|
|
2520
2984
|
applyConfig(config) {
|
|
2521
2985
|
this.size = config.size;
|
|
2522
2986
|
this.accentColor = config.theme.accent ?? "#2563eb";
|
|
2523
2987
|
this.avatarName = config.avatarName;
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
this.
|
|
2528
|
-
}
|
|
2529
|
-
if (this.
|
|
2530
|
-
renderSafeText(this.
|
|
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
|
+
}
|
|
2993
|
+
if (this.nameTextEl) {
|
|
2994
|
+
renderSafeText(this.nameTextEl, config.avatarName);
|
|
2995
|
+
}
|
|
2996
|
+
if (this.chatActionBtn) {
|
|
2997
|
+
const span = this.chatActionBtn.querySelector("span");
|
|
2998
|
+
if (span) {
|
|
2999
|
+
renderSafeText(span, `Chat with ${config.avatarName}`);
|
|
3000
|
+
}
|
|
2531
3001
|
}
|
|
2532
3002
|
if (this.root) {
|
|
2533
3003
|
this.root.setAttribute("aria-label", config.avatarName);
|
|
2534
3004
|
}
|
|
2535
|
-
if (
|
|
2536
|
-
this.
|
|
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 {
|
|
3023
|
+
if (this.figure) {
|
|
3024
|
+
this.figure.classList.remove("asiyst-3d-active");
|
|
3025
|
+
this.figure.style.width = `${config.size}px`;
|
|
3026
|
+
this.figure.style.height = `${config.size}px`;
|
|
3027
|
+
this.figure.style.background = this.accentColor;
|
|
3028
|
+
}
|
|
3029
|
+
if (this.chatActionBtn) {
|
|
3030
|
+
this.chatActionBtn.style.display = "none";
|
|
3031
|
+
}
|
|
3032
|
+
if (this.viewport && !this.isAssetLoadedFlag) {
|
|
3033
|
+
this.renderFallback();
|
|
3034
|
+
}
|
|
3035
|
+
}
|
|
3036
|
+
}
|
|
3037
|
+
setPanelOpen(open) {
|
|
3038
|
+
this.isPanelOpen = open;
|
|
3039
|
+
if (this.chatActionBtn && this.isAssetLoadedFlag) {
|
|
3040
|
+
this.chatActionBtn.style.display = open ? "none" : "inline-flex";
|
|
2537
3041
|
}
|
|
2538
3042
|
}
|
|
2539
3043
|
async loadAsset(config) {
|
|
@@ -2546,15 +3050,20 @@ var CssAvatarRenderer = class {
|
|
|
2546
3050
|
return false;
|
|
2547
3051
|
}
|
|
2548
3052
|
this.activeAssetUrl = assetUrl;
|
|
3053
|
+
this.has3dAssetConfigured = true;
|
|
2549
3054
|
this.renderState = "loading";
|
|
2550
3055
|
this.isFallbackFlag = false;
|
|
2551
3056
|
this.lastErrorMessage = void 0;
|
|
2552
3057
|
if (this.figure) {
|
|
2553
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";
|
|
2554
3063
|
}
|
|
2555
3064
|
this.renderLoader();
|
|
2556
3065
|
try {
|
|
2557
|
-
const asset = await this.assetLoader.load(assetUrl);
|
|
3066
|
+
const asset = await this.assetLoader.load(assetUrl, { timeoutMs: 6e4 });
|
|
2558
3067
|
await this.renderLoadedAsset(asset, config);
|
|
2559
3068
|
this.renderState = "ready";
|
|
2560
3069
|
this.isAssetLoadedFlag = true;
|
|
@@ -2562,6 +3071,13 @@ var CssAvatarRenderer = class {
|
|
|
2562
3071
|
this.loadedFormat = asset.format;
|
|
2563
3072
|
if (this.figure) {
|
|
2564
3073
|
this.figure.setAttribute("data-state", "ready");
|
|
3074
|
+
this.figure.classList.add("asiyst-3d-active");
|
|
3075
|
+
this.figure.style.width = "";
|
|
3076
|
+
this.figure.style.height = "";
|
|
3077
|
+
this.figure.style.background = "transparent";
|
|
3078
|
+
}
|
|
3079
|
+
if (this.chatActionBtn) {
|
|
3080
|
+
this.chatActionBtn.style.display = this.isPanelOpen ? "none" : "inline-flex";
|
|
2565
3081
|
}
|
|
2566
3082
|
return true;
|
|
2567
3083
|
} catch (err) {
|
|
@@ -2573,6 +3089,9 @@ var CssAvatarRenderer = class {
|
|
|
2573
3089
|
if (this.figure) {
|
|
2574
3090
|
this.figure.setAttribute("data-state", "error");
|
|
2575
3091
|
}
|
|
3092
|
+
if (this.chatActionBtn) {
|
|
3093
|
+
this.chatActionBtn.style.display = "none";
|
|
3094
|
+
}
|
|
2576
3095
|
this.renderFallback(true);
|
|
2577
3096
|
return false;
|
|
2578
3097
|
}
|
|
@@ -2581,10 +3100,13 @@ var CssAvatarRenderer = class {
|
|
|
2581
3100
|
if (!this.viewport) return;
|
|
2582
3101
|
this.viewport.replaceChildren();
|
|
2583
3102
|
const doc = this.viewport.ownerDocument;
|
|
3103
|
+
const container = doc.createElement("div");
|
|
3104
|
+
container.className = "asiyst-avatar-loading-silhouette";
|
|
2584
3105
|
const loader = doc.createElement("div");
|
|
2585
3106
|
loader.className = "asiyst-avatar-loader";
|
|
2586
3107
|
loader.setAttribute("aria-label", `Loading ${this.avatarName}`);
|
|
2587
|
-
|
|
3108
|
+
container.appendChild(loader);
|
|
3109
|
+
this.viewport.appendChild(container);
|
|
2588
3110
|
}
|
|
2589
3111
|
async renderLoadedAsset(asset, config) {
|
|
2590
3112
|
if (!this.viewport) return;
|
|
@@ -2593,10 +3115,15 @@ var CssAvatarRenderer = class {
|
|
|
2593
3115
|
this.fbxRenderer = null;
|
|
2594
3116
|
}
|
|
2595
3117
|
if (asset.format === "fbx" || asset.format === "glb") {
|
|
3118
|
+
const isMobile = typeof window !== "undefined" && window.innerWidth <= 640;
|
|
3119
|
+
const width = isMobile ? 180 : 240;
|
|
3120
|
+
const height = isMobile ? 360 : 460;
|
|
2596
3121
|
this.fbxRenderer = new FbxRenderer();
|
|
2597
3122
|
this.renderMetrics = await this.fbxRenderer.mount(this.viewport, asset, {
|
|
2598
3123
|
accentColor: this.accentColor,
|
|
2599
|
-
config
|
|
3124
|
+
config,
|
|
3125
|
+
width,
|
|
3126
|
+
height
|
|
2600
3127
|
});
|
|
2601
3128
|
this.fbxRenderer.setFacing(this.facing);
|
|
2602
3129
|
this.fbxRenderer.setPose(this.pose);
|
|
@@ -2612,7 +3139,7 @@ var CssAvatarRenderer = class {
|
|
|
2612
3139
|
const thumb = typeof asset.manifest.thumbnailUrl === "string" ? asset.manifest.thumbnailUrl : void 0;
|
|
2613
3140
|
const modelUrl = typeof asset.manifest.assetUrl === "string" ? asset.manifest.assetUrl : typeof asset.manifest.modelUrl === "string" ? asset.manifest.modelUrl : void 0;
|
|
2614
3141
|
if (modelUrl) {
|
|
2615
|
-
const subAsset = await this.assetLoader.load(modelUrl);
|
|
3142
|
+
const subAsset = await this.assetLoader.load(modelUrl, { timeoutMs: 6e4 });
|
|
2616
3143
|
await this.renderLoadedAsset(subAsset, config);
|
|
2617
3144
|
} else if (thumb) {
|
|
2618
3145
|
this.viewport.replaceChildren();
|
|
@@ -2644,7 +3171,6 @@ var CssAvatarRenderer = class {
|
|
|
2644
3171
|
if (isError) {
|
|
2645
3172
|
const badge = doc.createElement("span");
|
|
2646
3173
|
badge.className = "asiyst-avatar-fallback-badge";
|
|
2647
|
-
badge.setAttribute("title", "Avatar asset failed to load");
|
|
2648
3174
|
badge.textContent = "!";
|
|
2649
3175
|
fallback.appendChild(badge);
|
|
2650
3176
|
}
|
|
@@ -2652,66 +3178,75 @@ var CssAvatarRenderer = class {
|
|
|
2652
3178
|
}
|
|
2653
3179
|
setPosition(x, y, animate) {
|
|
2654
3180
|
if (!this.root) return;
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
3181
|
+
if (animate) {
|
|
3182
|
+
this.root.classList.add("asiyst-animate");
|
|
3183
|
+
} else {
|
|
3184
|
+
this.root.classList.remove("asiyst-animate");
|
|
3185
|
+
}
|
|
3186
|
+
this.root.style.left = `${Math.round(x)}px`;
|
|
3187
|
+
this.root.style.top = `${Math.round(y)}px`;
|
|
2658
3188
|
}
|
|
2659
3189
|
setFacing(direction) {
|
|
2660
3190
|
this.facing = direction;
|
|
2661
3191
|
this.fbxRenderer?.setFacing(direction);
|
|
2662
|
-
this.syncTransform();
|
|
2663
3192
|
}
|
|
2664
3193
|
setPose(pose) {
|
|
2665
3194
|
this.pose = pose;
|
|
3195
|
+
if (this.figure) {
|
|
3196
|
+
this.figure.setAttribute("data-pose", pose);
|
|
3197
|
+
}
|
|
3198
|
+
if (this.statusTextEl) {
|
|
3199
|
+
const displayStatus = pose === "speak" ? "(SPEAKING)" : pose === "think" ? "(THINKING)" : pose === "celebrate" ? "(CELEBRATING)" : "(IDLE)";
|
|
3200
|
+
this.statusTextEl.textContent = displayStatus;
|
|
3201
|
+
}
|
|
2666
3202
|
this.fbxRenderer?.setPose(pose);
|
|
2667
|
-
this.figure?.setAttribute("data-pose", pose);
|
|
2668
|
-
this.syncTransform();
|
|
2669
|
-
}
|
|
2670
|
-
syncTransform() {
|
|
2671
|
-
if (!this.figure) return;
|
|
2672
|
-
const face = this.facing === "left" ? "scaleX(-1)" : "";
|
|
2673
|
-
const pose = this.pose === "point" ? "rotate(-12deg)" : this.pose === "celebrate" ? "scale(1.08)" : "";
|
|
2674
|
-
this.figure.style.transform = `${face} ${pose}`.trim();
|
|
2675
3203
|
}
|
|
2676
3204
|
setSpeech(text) {
|
|
2677
3205
|
if (!this.bubble) return;
|
|
2678
3206
|
if (!text) {
|
|
2679
3207
|
this.bubble.hidden = true;
|
|
2680
|
-
this.bubble.
|
|
3208
|
+
this.bubble.replaceChildren();
|
|
2681
3209
|
return;
|
|
2682
3210
|
}
|
|
2683
3211
|
this.bubble.hidden = false;
|
|
2684
3212
|
renderSafeText(this.bubble, text);
|
|
2685
3213
|
}
|
|
2686
3214
|
getSize() {
|
|
3215
|
+
if (this.isAssetLoadedFlag || this.has3dAssetConfigured) {
|
|
3216
|
+
const isMobile = typeof window !== "undefined" && window.innerWidth <= 640;
|
|
3217
|
+
return { width: isMobile ? 180 : 240, height: isMobile ? 390 : 490 };
|
|
3218
|
+
}
|
|
2687
3219
|
return { width: this.size, height: this.size + 28 };
|
|
2688
3220
|
}
|
|
3221
|
+
playAnimation(nameOrIntent, loopMode) {
|
|
3222
|
+
return this.fbxRenderer?.playAnimation(nameOrIntent, loopMode) ?? false;
|
|
3223
|
+
}
|
|
2689
3224
|
setHidden(hidden) {
|
|
2690
3225
|
this.hidden = hidden;
|
|
2691
3226
|
if (this.root) {
|
|
2692
|
-
this.root.
|
|
3227
|
+
this.root.style.display = hidden ? "none" : "";
|
|
2693
3228
|
}
|
|
2694
3229
|
}
|
|
2695
3230
|
isHidden() {
|
|
2696
3231
|
return this.hidden;
|
|
2697
3232
|
}
|
|
2698
|
-
|
|
2699
|
-
return this.
|
|
2700
|
-
}
|
|
2701
|
-
getViewport() {
|
|
2702
|
-
return this.viewport;
|
|
3233
|
+
getRenderState() {
|
|
3234
|
+
return this.renderState;
|
|
2703
3235
|
}
|
|
2704
3236
|
isAssetLoaded() {
|
|
2705
3237
|
return this.isAssetLoadedFlag;
|
|
2706
3238
|
}
|
|
2707
|
-
|
|
2708
|
-
return this.
|
|
3239
|
+
getViewport() {
|
|
3240
|
+
return this.viewport;
|
|
3241
|
+
}
|
|
3242
|
+
isFallback() {
|
|
3243
|
+
return this.isFallbackFlag;
|
|
2709
3244
|
}
|
|
2710
3245
|
isFallbackActive() {
|
|
2711
3246
|
return this.isFallbackFlag;
|
|
2712
3247
|
}
|
|
2713
|
-
|
|
2714
|
-
return this.
|
|
3248
|
+
isRendered() {
|
|
3249
|
+
return this.isAssetLoadedFlag && (this.fbxRenderer ? this.fbxRenderer.isRendered() : true);
|
|
2715
3250
|
}
|
|
2716
3251
|
getLoadedFormat() {
|
|
2717
3252
|
return this.loadedFormat;
|
|
@@ -2725,6 +3260,18 @@ var CssAvatarRenderer = class {
|
|
|
2725
3260
|
getMetrics() {
|
|
2726
3261
|
return this.renderMetrics;
|
|
2727
3262
|
}
|
|
3263
|
+
getFigure() {
|
|
3264
|
+
return this.figure;
|
|
3265
|
+
}
|
|
3266
|
+
getFbxRenderer() {
|
|
3267
|
+
return this.fbxRenderer;
|
|
3268
|
+
}
|
|
3269
|
+
getChatActionBtn() {
|
|
3270
|
+
return this.chatActionBtn;
|
|
3271
|
+
}
|
|
3272
|
+
getNameTag() {
|
|
3273
|
+
return this.nameTagEl;
|
|
3274
|
+
}
|
|
2728
3275
|
};
|
|
2729
3276
|
|
|
2730
3277
|
// src/accessibility/a11y.ts
|
|
@@ -2908,6 +3455,8 @@ var MovementEngine = class {
|
|
|
2908
3455
|
this.onViewport = throttle(() => {
|
|
2909
3456
|
if (this.followTarget) {
|
|
2910
3457
|
this.placeBeside(this.followTarget, false);
|
|
3458
|
+
} else {
|
|
3459
|
+
this.goToAnchor();
|
|
2911
3460
|
}
|
|
2912
3461
|
}, VIEWPORT_HANDLER_THROTTLE_MS);
|
|
2913
3462
|
}
|
|
@@ -3525,27 +4074,39 @@ var ConversationPanel = class {
|
|
|
3525
4074
|
this.style.textContent = `
|
|
3526
4075
|
.asiyst-panel {
|
|
3527
4076
|
position: fixed;
|
|
3528
|
-
right:
|
|
3529
|
-
bottom:
|
|
3530
|
-
width: min(
|
|
3531
|
-
max-height: min(
|
|
3532
|
-
background: #
|
|
4077
|
+
right: 256px;
|
|
4078
|
+
bottom: 20px;
|
|
4079
|
+
width: min(380px, calc(100vw - 280px));
|
|
4080
|
+
max-height: min(560px, 75vh);
|
|
4081
|
+
background: #ffffff;
|
|
3533
4082
|
color: #0f172a;
|
|
3534
|
-
border-radius:
|
|
3535
|
-
box-shadow: 0
|
|
4083
|
+
border-radius: 18px;
|
|
4084
|
+
box-shadow: 0 20px 48px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(15, 23, 42, 0.08);
|
|
3536
4085
|
display: flex;
|
|
3537
4086
|
flex-direction: column;
|
|
3538
|
-
font: 14px/1.45 system-ui, sans-serif;
|
|
4087
|
+
font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
3539
4088
|
overflow: hidden;
|
|
4089
|
+
z-index: 100000;
|
|
4090
|
+
transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
|
|
4091
|
+
}
|
|
4092
|
+
@media (max-width: 640px) {
|
|
4093
|
+
.asiyst-panel {
|
|
4094
|
+
right: 12px;
|
|
4095
|
+
bottom: 12px;
|
|
4096
|
+
left: 12px;
|
|
4097
|
+
width: auto;
|
|
4098
|
+
max-height: 70vh;
|
|
4099
|
+
}
|
|
3540
4100
|
}
|
|
3541
4101
|
.asiyst-panel[hidden] { display: none; }
|
|
3542
4102
|
.asiyst-panel header {
|
|
3543
4103
|
display: flex;
|
|
3544
4104
|
justify-content: space-between;
|
|
3545
4105
|
align-items: center;
|
|
3546
|
-
padding:
|
|
4106
|
+
padding: 14px 16px;
|
|
3547
4107
|
background: #0f172a;
|
|
3548
4108
|
color: #f8fafc;
|
|
4109
|
+
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
|
3549
4110
|
}
|
|
3550
4111
|
.asiyst-log { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
|
|
3551
4112
|
.asiyst-msg { padding: 8px 10px; border-radius: 10px; max-width: 90%; }
|
|
@@ -3937,6 +4498,9 @@ var AsiystRuntime = class {
|
|
|
3937
4498
|
}) : void 0;
|
|
3938
4499
|
this.cloud = new CloudClient(transport, options.projectId, options.publicKey, runtimeAuth, this.visitorSessionId, options.avatarId);
|
|
3939
4500
|
this.config = new ConfigManager(options, this.cloud, this.events);
|
|
4501
|
+
this.config.onConfigUpdated = (newConfig, prevConfig) => {
|
|
4502
|
+
void this.applyUpdatedConfig(newConfig, prevConfig);
|
|
4503
|
+
};
|
|
3940
4504
|
this.analytics = new Analytics(options.projectId, this.cloud);
|
|
3941
4505
|
this.host = new HostRoot(doc);
|
|
3942
4506
|
this.resolver = new TargetResolver(
|
|
@@ -3945,6 +4509,7 @@ var AsiystRuntime = class {
|
|
|
3945
4509
|
() => this.map.list()
|
|
3946
4510
|
);
|
|
3947
4511
|
this.renderer = new CssAvatarRenderer();
|
|
4512
|
+
this.renderer.onOpenChat = () => this.open();
|
|
3948
4513
|
this.renderer.mount(this.host.chrome, this.config.get());
|
|
3949
4514
|
this.highlights = new HighlightLayer(this.host.overlay, win);
|
|
3950
4515
|
this.movement = new MovementEngine(win, doc, this.renderer, this.resolver, this.events, () => this.config.get());
|
|
@@ -3967,6 +4532,7 @@ var AsiystRuntime = class {
|
|
|
3967
4532
|
(open) => {
|
|
3968
4533
|
const convId = this.panel.getConversationId();
|
|
3969
4534
|
this.cloud.setConversationId(convId);
|
|
4535
|
+
this.renderer.setPanelOpen(open);
|
|
3970
4536
|
if (open) {
|
|
3971
4537
|
this.analytics.track("assistant_opened");
|
|
3972
4538
|
this.events.emit("asiyst:conversation:started", { conversationId: convId });
|
|
@@ -4009,6 +4575,7 @@ var AsiystRuntime = class {
|
|
|
4009
4575
|
}
|
|
4010
4576
|
this.avatar.applyConfig(cfg);
|
|
4011
4577
|
this.avatar.show();
|
|
4578
|
+
this.movement.goToAnchor();
|
|
4012
4579
|
this.lifecycle.emit("sdk.verification_started", {
|
|
4013
4580
|
projectId: this.options.projectId,
|
|
4014
4581
|
origin: window.location.origin,
|
|
@@ -4016,10 +4583,15 @@ var AsiystRuntime = class {
|
|
|
4016
4583
|
installationId: this.installationId,
|
|
4017
4584
|
sdkVersion: SDK_VERSION
|
|
4018
4585
|
});
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
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
|
+
})();
|
|
4023
4595
|
this.events.emit("asiyst:ready", { projectId: this.options.projectId, configVersion: cfg.version });
|
|
4024
4596
|
void this.cloud.sendTelemetryEvent("avatar_runtime_initialized", {
|
|
4025
4597
|
avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
|
|
@@ -4028,71 +4600,145 @@ var AsiystRuntime = class {
|
|
|
4028
4600
|
});
|
|
4029
4601
|
const assetTarget = cfg.assetUrl ?? cfg.thumbnailUrl;
|
|
4030
4602
|
if (assetTarget) {
|
|
4031
|
-
this.
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
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", {
|
|
4046
4637
|
avatarId: this.options.avatarId ?? cfg.avatarId,
|
|
4047
|
-
assetUrl,
|
|
4048
4638
|
format
|
|
4049
4639
|
});
|
|
4050
|
-
void this.cloud.sendTelemetryEvent("
|
|
4640
|
+
void this.cloud.sendTelemetryEvent("avatar_rendered", {
|
|
4051
4641
|
avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
|
|
4052
4642
|
avatarName: cfg.avatarName,
|
|
4053
|
-
assetUrl,
|
|
4054
4643
|
format,
|
|
4055
4644
|
publishedVersion: cfg.publishedVersion
|
|
4056
4645
|
});
|
|
4057
|
-
if (isRendered) {
|
|
4058
|
-
this.events.emit("asiyst:avatar:rendered", {
|
|
4059
|
-
avatarId: this.options.avatarId ?? cfg.avatarId,
|
|
4060
|
-
format
|
|
4061
|
-
});
|
|
4062
|
-
void this.cloud.sendTelemetryEvent("avatar_rendered", {
|
|
4063
|
-
avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
|
|
4064
|
-
avatarName: cfg.avatarName,
|
|
4065
|
-
format,
|
|
4066
|
-
publishedVersion: cfg.publishedVersion
|
|
4067
|
-
});
|
|
4068
|
-
}
|
|
4069
|
-
} else {
|
|
4070
|
-
const err = this.renderer.getLastError() ?? "Avatar asset loading failed";
|
|
4071
|
-
this.events.emit("asiyst:avatar:error", {
|
|
4072
|
-
avatarId: this.options.avatarId ?? cfg.avatarId,
|
|
4073
|
-
error: err,
|
|
4074
|
-
stage: "renderer_init"
|
|
4075
|
-
});
|
|
4076
|
-
void this.cloud.sendTelemetryEvent("avatar_render_failed", {
|
|
4077
|
-
avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
|
|
4078
|
-
error: err,
|
|
4079
|
-
stage: "renderer_init"
|
|
4080
|
-
});
|
|
4081
4646
|
}
|
|
4082
|
-
|
|
4083
|
-
|
|
4647
|
+
return true;
|
|
4648
|
+
} else {
|
|
4649
|
+
const err = this.renderer.getLastError() ?? "Avatar asset loading failed";
|
|
4084
4650
|
this.events.emit("asiyst:avatar:error", {
|
|
4085
4651
|
avatarId: this.options.avatarId ?? cfg.avatarId,
|
|
4086
4652
|
error: err,
|
|
4087
|
-
stage: "
|
|
4653
|
+
stage: "renderer_init"
|
|
4088
4654
|
});
|
|
4089
4655
|
void this.cloud.sendTelemetryEvent("avatar_render_failed", {
|
|
4090
4656
|
avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
|
|
4091
4657
|
error: err,
|
|
4092
|
-
stage: "
|
|
4658
|
+
stage: "renderer_init"
|
|
4093
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
|
+
}
|
|
4094
4710
|
}
|
|
4095
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;
|
|
4096
4742
|
}
|
|
4097
4743
|
getConnectionStatus() {
|
|
4098
4744
|
return this.connectionStatus;
|
|
@@ -4106,9 +4752,14 @@ var AsiystRuntime = class {
|
|
|
4106
4752
|
open() {
|
|
4107
4753
|
this.panel.open();
|
|
4108
4754
|
this.avatar.show();
|
|
4755
|
+
this.renderer.setPanelOpen(true);
|
|
4109
4756
|
}
|
|
4110
4757
|
close() {
|
|
4111
4758
|
this.panel.close();
|
|
4759
|
+
this.renderer.setPanelOpen(false);
|
|
4760
|
+
}
|
|
4761
|
+
getRenderer() {
|
|
4762
|
+
return this.renderer;
|
|
4112
4763
|
}
|
|
4113
4764
|
avatarApi() {
|
|
4114
4765
|
return this.avatar;
|
|
@@ -4148,6 +4799,10 @@ var AsiystRuntime = class {
|
|
|
4148
4799
|
clearInterval(this.heartbeatTimer);
|
|
4149
4800
|
this.heartbeatTimer = void 0;
|
|
4150
4801
|
}
|
|
4802
|
+
if (this.configRevalidationTimer) {
|
|
4803
|
+
clearInterval(this.configRevalidationTimer);
|
|
4804
|
+
this.configRevalidationTimer = void 0;
|
|
4805
|
+
}
|
|
4151
4806
|
const doc = this.host.host.ownerDocument;
|
|
4152
4807
|
if (doc && this.visibilityListener) {
|
|
4153
4808
|
doc.removeEventListener("visibilitychange", this.visibilityListener);
|
|
@@ -4417,6 +5072,12 @@ var Asiyst = {
|
|
|
4417
5072
|
getConfig() {
|
|
4418
5073
|
return requireRuntime().getConfig();
|
|
4419
5074
|
},
|
|
5075
|
+
async reloadConfig() {
|
|
5076
|
+
return requireRuntime().reloadConfig();
|
|
5077
|
+
},
|
|
5078
|
+
async updateConfig(partial) {
|
|
5079
|
+
await requireRuntime().updateConfig(partial);
|
|
5080
|
+
},
|
|
4420
5081
|
getConnectionStatus() {
|
|
4421
5082
|
return requireRuntime().getConnectionStatus();
|
|
4422
5083
|
},
|
|
@@ -4451,6 +5112,9 @@ var Asiyst = {
|
|
|
4451
5112
|
celebrate() {
|
|
4452
5113
|
withIsolation(() => requireRuntime().avatarApi().celebrate());
|
|
4453
5114
|
},
|
|
5115
|
+
playAnimation(nameOrIntent, options) {
|
|
5116
|
+
return requireRuntime().playAnimation(nameOrIntent, options);
|
|
5117
|
+
},
|
|
4454
5118
|
setPosition(x, y) {
|
|
4455
5119
|
withIsolation(() => requireRuntime().avatarApi().setPosition(x, y));
|
|
4456
5120
|
}
|