@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.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
|
|
@@ -373,18 +374,22 @@ function normalizeProjectConfig(raw) {
|
|
|
373
374
|
return base;
|
|
374
375
|
}
|
|
375
376
|
const rawAvatarRecord = isRecord(raw.avatar) ? raw.avatar : void 0;
|
|
377
|
+
const rawConfigRecord = isRecord(raw.config) ? raw.config : void 0;
|
|
378
|
+
const rawManifestRecord = isRecord(raw.manifest) ? raw.manifest : void 0;
|
|
376
379
|
const avatarId = asString(
|
|
377
|
-
raw.avatarId ?? rawAvatarRecord?.avatarId ?? rawAvatarRecord?.id,
|
|
380
|
+
raw.avatarId ?? rawAvatarRecord?.avatarId ?? rawAvatarRecord?.id ?? rawConfigRecord?.avatarId,
|
|
378
381
|
"",
|
|
379
382
|
128
|
|
380
383
|
) || void 0;
|
|
381
|
-
const assetUrl = typeof raw.assetUrl === "string" ? raw.assetUrl : typeof rawAvatarRecord?.assetUrl === "string" ? rawAvatarRecord.assetUrl : void 0;
|
|
382
|
-
const thumbnailUrl = typeof raw.thumbnailUrl === "string" ? raw.thumbnailUrl : typeof rawAvatarRecord?.thumbnailUrl === "string" ? rawAvatarRecord.thumbnailUrl : rawAvatarRecord?.thumbnailUrl === null ? null : void 0;
|
|
383
|
-
const publishedVersion = typeof raw.publishedVersion === "string" ? raw.publishedVersion : typeof rawAvatarRecord?.version === "string" ? rawAvatarRecord.version : void 0;
|
|
384
|
-
const animations = parseAnimations(
|
|
385
|
-
|
|
384
|
+
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;
|
|
385
|
+
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;
|
|
386
|
+
const publishedVersion = typeof raw.publishedVersion === "string" ? raw.publishedVersion : typeof rawAvatarRecord?.version === "string" ? rawAvatarRecord.version : typeof rawManifestRecord?.version === "string" ? rawManifestRecord.version : void 0;
|
|
387
|
+
const animations = parseAnimations(
|
|
388
|
+
raw.animations ?? rawAvatarRecord?.animations ?? rawConfigRecord?.animations
|
|
389
|
+
);
|
|
390
|
+
const branding = parseBranding(raw.branding ?? rawAvatarRecord?.branding);
|
|
386
391
|
const avatarName = asString(
|
|
387
|
-
raw.avatarName ?? rawAvatarRecord?.name,
|
|
392
|
+
raw.avatarName ?? rawAvatarRecord?.name ?? rawConfigRecord?.avatarName ?? rawManifestRecord?.name,
|
|
388
393
|
base.avatarName,
|
|
389
394
|
40
|
|
390
395
|
);
|
|
@@ -648,39 +653,58 @@ var CloudClient = class {
|
|
|
648
653
|
const avatarAndKeyParams = `?projectId=${encodeURIComponent(this.projectId)}&publicKey=${encodeURIComponent(this.publicKey)}${this.avatarId ? `&avatarId=${encodeURIComponent(this.avatarId)}` : ""}`;
|
|
649
654
|
const baseUrl = this.getApiBaseUrl();
|
|
650
655
|
const resolveAssetUrls = (raw) => {
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
+
let canonicalBase = "https://asiyst.com";
|
|
657
|
+
try {
|
|
658
|
+
if (baseUrl) {
|
|
659
|
+
const u = new URL(baseUrl);
|
|
660
|
+
canonicalBase = u.origin;
|
|
656
661
|
}
|
|
657
|
-
|
|
658
|
-
|
|
662
|
+
} catch {
|
|
663
|
+
canonicalBase = "https://asiyst.com";
|
|
664
|
+
}
|
|
665
|
+
const toAbsolute = (url) => {
|
|
666
|
+
if (typeof url === "string" && url.startsWith("/")) {
|
|
667
|
+
return new URL(url, canonicalBase).href;
|
|
659
668
|
}
|
|
669
|
+
return url;
|
|
670
|
+
};
|
|
671
|
+
if (raw.avatar && typeof raw.avatar === "object" && !Array.isArray(raw.avatar)) {
|
|
672
|
+
const av = { ...raw.avatar };
|
|
673
|
+
av.assetUrl = toAbsolute(av.assetUrl);
|
|
674
|
+
av.thumbnailUrl = toAbsolute(av.thumbnailUrl);
|
|
675
|
+
av.modelUrl = toAbsolute(av.modelUrl);
|
|
676
|
+
av.manifestUrl = toAbsolute(av.manifestUrl);
|
|
660
677
|
if (Array.isArray(av.animations)) {
|
|
661
678
|
av.animations = av.animations.map((item) => {
|
|
662
679
|
if (item && typeof item === "object") {
|
|
663
680
|
const animObj = item;
|
|
664
|
-
|
|
665
|
-
return { ...animObj, assetUrl: new URL(animObj.assetUrl, canonicalBase).href };
|
|
666
|
-
}
|
|
681
|
+
return { ...animObj, assetUrl: toAbsolute(animObj.assetUrl) };
|
|
667
682
|
}
|
|
668
683
|
return item;
|
|
669
684
|
});
|
|
670
685
|
}
|
|
671
686
|
raw.avatar = av;
|
|
672
687
|
}
|
|
673
|
-
if (typeof raw.
|
|
674
|
-
|
|
688
|
+
if (raw.config && typeof raw.config === "object" && !Array.isArray(raw.config)) {
|
|
689
|
+
const cfg = { ...raw.config };
|
|
690
|
+
cfg.assetUrl = toAbsolute(cfg.assetUrl);
|
|
691
|
+
cfg.thumbnailUrl = toAbsolute(cfg.thumbnailUrl);
|
|
692
|
+
cfg.manifestUrl = toAbsolute(cfg.manifestUrl);
|
|
693
|
+
raw.config = cfg;
|
|
675
694
|
}
|
|
676
|
-
if (typeof raw.
|
|
677
|
-
|
|
695
|
+
if (raw.manifest && typeof raw.manifest === "object" && !Array.isArray(raw.manifest)) {
|
|
696
|
+
const mf = { ...raw.manifest };
|
|
697
|
+
mf.assetUrl = toAbsolute(mf.assetUrl);
|
|
698
|
+
mf.thumbnailUrl = toAbsolute(mf.thumbnailUrl);
|
|
699
|
+
mf.modelUrl = toAbsolute(mf.modelUrl);
|
|
700
|
+
raw.manifest = mf;
|
|
678
701
|
}
|
|
702
|
+
raw.assetUrl = toAbsolute(raw.assetUrl);
|
|
703
|
+
raw.thumbnailUrl = toAbsolute(raw.thumbnailUrl);
|
|
704
|
+
raw.manifestUrl = toAbsolute(raw.manifestUrl);
|
|
679
705
|
if (raw.branding && typeof raw.branding === "object" && !Array.isArray(raw.branding)) {
|
|
680
706
|
const br = { ...raw.branding };
|
|
681
|
-
|
|
682
|
-
br.siteLogoUrl = new URL(br.siteLogoUrl, canonicalBase).href;
|
|
683
|
-
}
|
|
707
|
+
br.siteLogoUrl = toAbsolute(br.siteLogoUrl);
|
|
684
708
|
raw.branding = br;
|
|
685
709
|
}
|
|
686
710
|
return raw;
|
|
@@ -693,8 +717,11 @@ var CloudClient = class {
|
|
|
693
717
|
idempotent: true
|
|
694
718
|
});
|
|
695
719
|
if (response.ok && response.data) {
|
|
696
|
-
const
|
|
697
|
-
|
|
720
|
+
const fullData = response.data && typeof response.data === "object" && !Array.isArray(response.data) ? {
|
|
721
|
+
...response.data,
|
|
722
|
+
...response.data.config && typeof response.data.config === "object" ? response.data.config : {}
|
|
723
|
+
} : {};
|
|
724
|
+
return normalizeProjectConfig(resolveAssetUrls(fullData));
|
|
698
725
|
}
|
|
699
726
|
if (response.status === 404) {
|
|
700
727
|
lastError = new ConfigurationError(`Project ${this.projectId} or avatar configuration not found`);
|
|
@@ -1012,7 +1039,7 @@ var ConfigCache = class {
|
|
|
1012
1039
|
constructor(storage) {
|
|
1013
1040
|
this.storage = storage;
|
|
1014
1041
|
}
|
|
1015
|
-
read(projectId) {
|
|
1042
|
+
read(projectId, ignoreTtl = false) {
|
|
1016
1043
|
const raw = this.storage.read("config");
|
|
1017
1044
|
if (!raw) {
|
|
1018
1045
|
return null;
|
|
@@ -1022,7 +1049,7 @@ var ConfigCache = class {
|
|
|
1022
1049
|
if (parsed.schemaVersion !== CONFIG_SCHEMA_VERSION || parsed.projectId !== projectId) {
|
|
1023
1050
|
return null;
|
|
1024
1051
|
}
|
|
1025
|
-
if (Date.now() - parsed.fetchedAt > CONFIG_CACHE_TTL_MS) {
|
|
1052
|
+
if (!ignoreTtl && Date.now() - parsed.fetchedAt > CONFIG_CACHE_TTL_MS) {
|
|
1026
1053
|
return null;
|
|
1027
1054
|
}
|
|
1028
1055
|
return normalizeProjectConfig(parsed.config);
|
|
@@ -1030,15 +1057,35 @@ var ConfigCache = class {
|
|
|
1030
1057
|
return null;
|
|
1031
1058
|
}
|
|
1032
1059
|
}
|
|
1033
|
-
|
|
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) {
|
|
1034
1076
|
const envelope = {
|
|
1035
1077
|
schemaVersion: CONFIG_SCHEMA_VERSION,
|
|
1036
1078
|
projectId,
|
|
1037
1079
|
fetchedAt: Date.now(),
|
|
1080
|
+
etag: meta?.etag,
|
|
1081
|
+
revision: meta?.revision ?? config.version,
|
|
1038
1082
|
config
|
|
1039
1083
|
};
|
|
1040
1084
|
this.storage.write("config", JSON.stringify(envelope));
|
|
1041
1085
|
}
|
|
1086
|
+
clear() {
|
|
1087
|
+
this.storage.remove("config");
|
|
1088
|
+
}
|
|
1042
1089
|
};
|
|
1043
1090
|
|
|
1044
1091
|
// src/config/ConfigManager.ts
|
|
@@ -1047,6 +1094,7 @@ var ConfigManager = class {
|
|
|
1047
1094
|
this.options = options;
|
|
1048
1095
|
this.cloud = cloud;
|
|
1049
1096
|
this.events = events;
|
|
1097
|
+
this.inFlightRefresh = null;
|
|
1050
1098
|
const credentials = validateInitOptions(options);
|
|
1051
1099
|
this.options = { ...options, ...credentials };
|
|
1052
1100
|
this.cache = new ConfigCache(
|
|
@@ -1058,13 +1106,34 @@ var ConfigManager = class {
|
|
|
1058
1106
|
get() {
|
|
1059
1107
|
return this.current;
|
|
1060
1108
|
}
|
|
1061
|
-
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;
|
|
1062
1122
|
try {
|
|
1063
1123
|
const remote = await this.cloud.fetchConfig();
|
|
1064
|
-
|
|
1065
|
-
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
|
+
}
|
|
1066
1131
|
return this.current;
|
|
1067
1132
|
} catch (error) {
|
|
1133
|
+
const lastKnownGood = this.cache.read(this.options.projectId, true);
|
|
1134
|
+
if (lastKnownGood) {
|
|
1135
|
+
this.current = lastKnownGood;
|
|
1136
|
+
}
|
|
1068
1137
|
this.events.emit("asiyst:error", {
|
|
1069
1138
|
code: "config_refresh_failed",
|
|
1070
1139
|
message: error instanceof Error ? error.message : "Failed to refresh configuration"
|
|
@@ -1072,6 +1141,18 @@ var ConfigManager = class {
|
|
|
1072
1141
|
return this.current;
|
|
1073
1142
|
}
|
|
1074
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
|
+
}
|
|
1075
1156
|
localFallback() {
|
|
1076
1157
|
const base = fallbackConfig();
|
|
1077
1158
|
return {
|
|
@@ -1730,16 +1811,37 @@ var AssetLoader = class {
|
|
|
1730
1811
|
constructor() {
|
|
1731
1812
|
this.inFlightController = null;
|
|
1732
1813
|
this.createdObjectUrls = [];
|
|
1814
|
+
this.inFlightLoads = /* @__PURE__ */ new Map();
|
|
1815
|
+
this.cachedAssets = /* @__PURE__ */ new Map();
|
|
1733
1816
|
}
|
|
1734
1817
|
async load(assetUrl, options) {
|
|
1735
|
-
const startTime = Date.now();
|
|
1736
1818
|
const sanitizedUrl = sanitizeText(assetUrl.trim(), 2048);
|
|
1737
1819
|
if (!sanitizedUrl) {
|
|
1738
1820
|
throw new Error("Asset URL is required");
|
|
1739
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();
|
|
1740
1842
|
this.inFlightController = new AbortController();
|
|
1741
1843
|
const abortSignal = options?.signal ? anySignal([this.inFlightController.signal, options.signal]) : this.inFlightController.signal;
|
|
1742
|
-
const timeoutMs = options?.timeoutMs ??
|
|
1844
|
+
const timeoutMs = options?.timeoutMs ?? 6e4;
|
|
1743
1845
|
const timeoutId = setTimeout(() => {
|
|
1744
1846
|
this.inFlightController?.abort();
|
|
1745
1847
|
}, timeoutMs);
|
|
@@ -1779,6 +1881,9 @@ var AssetLoader = class {
|
|
|
1779
1881
|
throw new Error(`Avatar asset download failed: HTTP ${response.status} from ${sanitizedUrl}`);
|
|
1780
1882
|
}
|
|
1781
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
|
+
}
|
|
1782
1887
|
if (isJsonExtension || contentType.includes("application/json")) {
|
|
1783
1888
|
const text = await response.text();
|
|
1784
1889
|
let manifest;
|
|
@@ -1812,6 +1917,11 @@ var AssetLoader = class {
|
|
|
1812
1917
|
if (arrayBuffer.byteLength < 12) {
|
|
1813
1918
|
throw new Error("Avatar asset payload is too small to be a valid 3D container");
|
|
1814
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
|
+
}
|
|
1815
1925
|
if (isFbxExtension || this.isFbxBuffer(arrayBuffer) || !isGlbExtension && !this.isGlbBuffer(arrayBuffer)) {
|
|
1816
1926
|
const fbxHeader = this.parseFbxHeader(arrayBuffer);
|
|
1817
1927
|
const resourcePath = sanitizedUrl.includes("/") ? sanitizedUrl.substring(0, sanitizedUrl.lastIndexOf("/") + 1) : "";
|
|
@@ -2057,6 +2167,8 @@ var AssetLoader = class {
|
|
|
2057
2167
|
this.inFlightController.abort();
|
|
2058
2168
|
this.inFlightController = null;
|
|
2059
2169
|
}
|
|
2170
|
+
this.inFlightLoads.clear();
|
|
2171
|
+
this.cachedAssets.clear();
|
|
2060
2172
|
if (typeof URL !== "undefined" && typeof URL.revokeObjectURL === "function") {
|
|
2061
2173
|
for (const objUrl of this.createdObjectUrls) {
|
|
2062
2174
|
try {
|
|
@@ -2086,7 +2198,12 @@ var FbxRenderer = class {
|
|
|
2086
2198
|
this.scene = null;
|
|
2087
2199
|
this.camera = null;
|
|
2088
2200
|
this.modelRoot = null;
|
|
2201
|
+
this.rawObject = null;
|
|
2089
2202
|
this.mixer = null;
|
|
2203
|
+
this.allAnimations = [];
|
|
2204
|
+
this.animationMetadataList = [];
|
|
2205
|
+
this.assetLoader = new AssetLoader();
|
|
2206
|
+
this.currentAction = null;
|
|
2090
2207
|
this.animFrameId = null;
|
|
2091
2208
|
this.lastTime = 0;
|
|
2092
2209
|
this.facing = "right";
|
|
@@ -2101,39 +2218,59 @@ var FbxRenderer = class {
|
|
|
2101
2218
|
this.canvas = doc.createElement("canvas");
|
|
2102
2219
|
this.canvas.className = "asiyst-avatar-canvas";
|
|
2103
2220
|
this.canvas.setAttribute("role", "presentation");
|
|
2221
|
+
this.canvas.style.opacity = "0";
|
|
2222
|
+
this.canvas.style.transition = "opacity 0.25s ease";
|
|
2104
2223
|
const glContext = this.canvas.getContext("webgl2") || this.canvas.getContext("webgl");
|
|
2105
2224
|
if (!glContext) {
|
|
2106
2225
|
throw new Error("WebGLRenderingContext is not available or supported in this browser environment");
|
|
2107
2226
|
}
|
|
2227
|
+
const isMobile = typeof window !== "undefined" && window.innerWidth <= 640;
|
|
2228
|
+
const width = options?.width || (isMobile ? 180 : 240);
|
|
2229
|
+
const height = options?.height || (isMobile ? 360 : 460);
|
|
2108
2230
|
const dpr = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
2109
|
-
|
|
2110
|
-
this.canvas.
|
|
2111
|
-
this.canvas.
|
|
2231
|
+
this.canvas.width = Math.round(width * dpr);
|
|
2232
|
+
this.canvas.height = Math.round(height * dpr);
|
|
2233
|
+
this.canvas.style.width = `${width}px`;
|
|
2234
|
+
this.canvas.style.height = `${height}px`;
|
|
2112
2235
|
try {
|
|
2113
2236
|
this.renderer = new THREE.WebGLRenderer({
|
|
2114
2237
|
canvas: this.canvas,
|
|
2115
2238
|
alpha: true,
|
|
2116
2239
|
antialias: true,
|
|
2117
|
-
powerPreference: "
|
|
2240
|
+
powerPreference: "high-performance"
|
|
2118
2241
|
});
|
|
2119
2242
|
this.renderer.setPixelRatio(Math.min(dpr, 2));
|
|
2120
|
-
this.renderer.setSize(
|
|
2243
|
+
this.renderer.setSize(width, height, false);
|
|
2121
2244
|
this.renderer.outputColorSpace = THREE.SRGBColorSpace;
|
|
2245
|
+
this.renderer.shadowMap.enabled = true;
|
|
2246
|
+
this.renderer.shadowMap.type = THREE.PCFSoftShadowMap;
|
|
2122
2247
|
} catch (err) {
|
|
2123
2248
|
const msg = err instanceof Error ? err.message : String(err);
|
|
2124
2249
|
throw new Error(`Failed to initialize WebGLRenderer: ${msg}`);
|
|
2125
2250
|
}
|
|
2126
2251
|
this.scene = new THREE.Scene();
|
|
2127
|
-
this.camera = new THREE.PerspectiveCamera(
|
|
2128
|
-
this.camera.position.set(0, 0, 3.4);
|
|
2252
|
+
this.camera = new THREE.PerspectiveCamera(45, width / height, 0.1, 100);
|
|
2129
2253
|
const ambientLight = new THREE.AmbientLight(16777215, 1.2);
|
|
2130
2254
|
this.scene.add(ambientLight);
|
|
2131
|
-
const keyLight = new THREE.DirectionalLight(
|
|
2132
|
-
keyLight.position.set(
|
|
2255
|
+
const keyLight = new THREE.DirectionalLight(16774634, 2);
|
|
2256
|
+
keyLight.position.set(3, 4, 3);
|
|
2257
|
+
keyLight.castShadow = true;
|
|
2258
|
+
keyLight.shadow.mapSize.width = 512;
|
|
2259
|
+
keyLight.shadow.mapSize.height = 512;
|
|
2133
2260
|
this.scene.add(keyLight);
|
|
2134
|
-
const fillLight = new THREE.DirectionalLight(
|
|
2135
|
-
fillLight.position.set(-
|
|
2261
|
+
const fillLight = new THREE.DirectionalLight(15459032, 1.2);
|
|
2262
|
+
fillLight.position.set(-3, 2, 2);
|
|
2136
2263
|
this.scene.add(fillLight);
|
|
2264
|
+
const rimLight = new THREE.DirectionalLight(16771286, 1.5);
|
|
2265
|
+
rimLight.position.set(0, 4, -3);
|
|
2266
|
+
this.scene.add(rimLight);
|
|
2267
|
+
const shadowGeo = new THREE.PlaneGeometry(3, 3);
|
|
2268
|
+
const shadowMat = new THREE.ShadowMaterial({ opacity: 0.15 });
|
|
2269
|
+
const shadowPlane = new THREE.Mesh(shadowGeo, shadowMat);
|
|
2270
|
+
shadowPlane.rotation.x = -Math.PI / 2;
|
|
2271
|
+
shadowPlane.position.y = 0;
|
|
2272
|
+
shadowPlane.receiveShadow = true;
|
|
2273
|
+
this.scene.add(shadowPlane);
|
|
2137
2274
|
let rawObject;
|
|
2138
2275
|
let modelAnimations = [];
|
|
2139
2276
|
if (asset.format === "fbx") {
|
|
@@ -2170,32 +2307,40 @@ var FbxRenderer = class {
|
|
|
2170
2307
|
}
|
|
2171
2308
|
}
|
|
2172
2309
|
const { meshCount, vertexCount: totalVertices } = this.validateGeometry(rawObject);
|
|
2173
|
-
const
|
|
2174
|
-
if (
|
|
2310
|
+
const rawBox = new THREE.Box3().setFromObject(rawObject);
|
|
2311
|
+
if (rawBox.isEmpty()) {
|
|
2175
2312
|
throw new Error("FBX asset geometry bounding box is empty");
|
|
2176
2313
|
}
|
|
2177
|
-
const
|
|
2178
|
-
|
|
2179
|
-
const
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
rawObject.position.z -= center.z;
|
|
2314
|
+
const rawSize = rawBox.getSize(new THREE.Vector3());
|
|
2315
|
+
const rawCenter = rawBox.getCenter(new THREE.Vector3());
|
|
2316
|
+
const rawHeight = rawSize.y > 0 ? rawSize.y : 1.8;
|
|
2317
|
+
rawObject.position.set(-rawCenter.x, -rawBox.min.y, -rawCenter.z);
|
|
2318
|
+
const targetVisualHeight = 1.8;
|
|
2319
|
+
const targetScale = targetVisualHeight / rawHeight;
|
|
2184
2320
|
this.modelRoot = new THREE.Group();
|
|
2185
2321
|
this.modelRoot.add(rawObject);
|
|
2322
|
+
this.modelRoot.scale.setScalar(targetScale);
|
|
2186
2323
|
this.scene.add(this.modelRoot);
|
|
2187
|
-
const
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2324
|
+
const visualCenterY = targetVisualHeight * 0.52;
|
|
2325
|
+
const fovRadians = this.camera.fov * Math.PI / 180;
|
|
2326
|
+
const fitDist = Math.max(2.4, targetVisualHeight / 2 / Math.tan(fovRadians / 2) * 1.25);
|
|
2327
|
+
this.camera.position.set(0, visualCenterY + 0.1, fitDist);
|
|
2328
|
+
this.camera.lookAt(0, visualCenterY, 0);
|
|
2329
|
+
rawObject.traverse((child) => {
|
|
2330
|
+
const mesh = child;
|
|
2331
|
+
if (mesh.isMesh) {
|
|
2332
|
+
mesh.castShadow = true;
|
|
2333
|
+
mesh.receiveShadow = true;
|
|
2334
|
+
}
|
|
2335
|
+
});
|
|
2336
|
+
this.rawObject = rawObject;
|
|
2337
|
+
this.mixer = new THREE.AnimationMixer(rawObject);
|
|
2338
|
+
this.allAnimations = [...modelAnimations];
|
|
2193
2339
|
if (modelAnimations.length > 0) {
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
action.play();
|
|
2340
|
+
const idleClip = modelAnimations.find((c) => c.name.toLowerCase().includes("idle")) || modelAnimations[0];
|
|
2341
|
+
if (idleClip) {
|
|
2342
|
+
this.currentAction = this.mixer.clipAction(idleClip);
|
|
2343
|
+
this.currentAction.play();
|
|
2199
2344
|
}
|
|
2200
2345
|
}
|
|
2201
2346
|
container.replaceChildren();
|
|
@@ -2203,6 +2348,9 @@ var FbxRenderer = class {
|
|
|
2203
2348
|
try {
|
|
2204
2349
|
this.renderer.render(this.scene, this.camera);
|
|
2205
2350
|
this.initialRenderCompleted = true;
|
|
2351
|
+
if (this.canvas) {
|
|
2352
|
+
this.canvas.style.opacity = "1";
|
|
2353
|
+
}
|
|
2206
2354
|
} catch (renderErr) {
|
|
2207
2355
|
const msg = renderErr instanceof Error ? renderErr.message : String(renderErr);
|
|
2208
2356
|
throw new Error(`Initial FBX WebGL render failed: ${msg}`);
|
|
@@ -2210,6 +2358,13 @@ var FbxRenderer = class {
|
|
|
2210
2358
|
this.startLoop();
|
|
2211
2359
|
this.setFacing(this.facing);
|
|
2212
2360
|
this.setPose(this.currentPose);
|
|
2361
|
+
if (options?.config?.animations && options.config.animations.length > 0) {
|
|
2362
|
+
void this.loadExternalAnimations(options.config.animations);
|
|
2363
|
+
}
|
|
2364
|
+
if (typeof window !== "undefined") {
|
|
2365
|
+
this.resizeListener = () => this.handleResize();
|
|
2366
|
+
window.addEventListener("resize", this.resizeListener);
|
|
2367
|
+
}
|
|
2213
2368
|
return {
|
|
2214
2369
|
meshCount,
|
|
2215
2370
|
vertexCount: totalVertices,
|
|
@@ -2225,6 +2380,34 @@ var FbxRenderer = class {
|
|
|
2225
2380
|
setPose(pose) {
|
|
2226
2381
|
this.currentPose = pose;
|
|
2227
2382
|
if (!this.modelRoot) return;
|
|
2383
|
+
if (this.playAnimation(pose)) {
|
|
2384
|
+
return;
|
|
2385
|
+
}
|
|
2386
|
+
if (this.mixer && this.allAnimations.length > 1) {
|
|
2387
|
+
let targetClip;
|
|
2388
|
+
if (pose === "speak") {
|
|
2389
|
+
targetClip = this.allAnimations.find(
|
|
2390
|
+
(c) => c.name.toLowerCase().includes("talk") || c.name.toLowerCase().includes("speak")
|
|
2391
|
+
);
|
|
2392
|
+
} else if (pose === "think") {
|
|
2393
|
+
targetClip = this.allAnimations.find(
|
|
2394
|
+
(c) => c.name.toLowerCase().includes("think")
|
|
2395
|
+
);
|
|
2396
|
+
} else {
|
|
2397
|
+
targetClip = this.allAnimations.find((c) => c.name.toLowerCase().includes("idle")) || this.allAnimations[0];
|
|
2398
|
+
}
|
|
2399
|
+
if (targetClip) {
|
|
2400
|
+
const newAction = this.mixer.clipAction(targetClip);
|
|
2401
|
+
if (newAction !== this.currentAction) {
|
|
2402
|
+
newAction.reset().fadeIn(0.25).play();
|
|
2403
|
+
if (this.currentAction) {
|
|
2404
|
+
this.currentAction.fadeOut(0.25);
|
|
2405
|
+
}
|
|
2406
|
+
this.currentAction = newAction;
|
|
2407
|
+
return;
|
|
2408
|
+
}
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2228
2411
|
switch (pose) {
|
|
2229
2412
|
case "point":
|
|
2230
2413
|
this.modelRoot.rotation.z = -0.15;
|
|
@@ -2234,6 +2417,10 @@ var FbxRenderer = class {
|
|
|
2234
2417
|
this.modelRoot.rotation.z = 0.12;
|
|
2235
2418
|
this.modelRoot.rotation.x = -0.1;
|
|
2236
2419
|
break;
|
|
2420
|
+
case "speak":
|
|
2421
|
+
this.modelRoot.rotation.y = this.facing === "left" ? -0.22 : 0.22;
|
|
2422
|
+
this.modelRoot.rotation.x = 0.04;
|
|
2423
|
+
break;
|
|
2237
2424
|
case "celebrate":
|
|
2238
2425
|
this.modelRoot.rotation.z = 0;
|
|
2239
2426
|
this.modelRoot.rotation.x = -0.15;
|
|
@@ -2242,9 +2429,139 @@ var FbxRenderer = class {
|
|
|
2242
2429
|
default:
|
|
2243
2430
|
this.modelRoot.rotation.z = 0;
|
|
2244
2431
|
this.modelRoot.rotation.x = 0;
|
|
2432
|
+
this.modelRoot.rotation.y = this.facing === "left" ? -0.35 : 0.35;
|
|
2245
2433
|
break;
|
|
2246
2434
|
}
|
|
2247
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
|
+
}
|
|
2248
2565
|
isRendered() {
|
|
2249
2566
|
return this.initialRenderCompleted;
|
|
2250
2567
|
}
|
|
@@ -2286,6 +2603,10 @@ var FbxRenderer = class {
|
|
|
2286
2603
|
this.animFrameId = requestAnimationFrame(tick);
|
|
2287
2604
|
}
|
|
2288
2605
|
destroy() {
|
|
2606
|
+
if (typeof window !== "undefined" && this.resizeListener) {
|
|
2607
|
+
window.removeEventListener("resize", this.resizeListener);
|
|
2608
|
+
this.resizeListener = void 0;
|
|
2609
|
+
}
|
|
2289
2610
|
if (this.animFrameId !== null && typeof cancelAnimationFrame !== "undefined") {
|
|
2290
2611
|
cancelAnimationFrame(this.animFrameId);
|
|
2291
2612
|
this.animFrameId = null;
|
|
@@ -2327,10 +2648,39 @@ var FbxRenderer = class {
|
|
|
2327
2648
|
this.canvas.remove();
|
|
2328
2649
|
this.canvas = null;
|
|
2329
2650
|
}
|
|
2651
|
+
this.assetLoader.destroy();
|
|
2652
|
+
this.animationMetadataList.length = 0;
|
|
2653
|
+
this.allAnimations = [];
|
|
2654
|
+
this.currentAction = null;
|
|
2655
|
+
this.rawObject = null;
|
|
2330
2656
|
this.camera = null;
|
|
2331
2657
|
this.modelRoot = null;
|
|
2332
2658
|
this.initialRenderCompleted = false;
|
|
2333
2659
|
}
|
|
2660
|
+
handleResize() {
|
|
2661
|
+
if (!this.canvas || !this.renderer || !this.camera) return;
|
|
2662
|
+
const isMobile = typeof window !== "undefined" && window.innerWidth <= 640;
|
|
2663
|
+
const width = isMobile ? 180 : 240;
|
|
2664
|
+
const height = isMobile ? 360 : 460;
|
|
2665
|
+
const dpr = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
2666
|
+
this.canvas.width = Math.round(width * dpr);
|
|
2667
|
+
this.canvas.height = Math.round(height * dpr);
|
|
2668
|
+
this.canvas.style.width = `${width}px`;
|
|
2669
|
+
this.canvas.style.height = `${height}px`;
|
|
2670
|
+
this.camera.aspect = width / height;
|
|
2671
|
+
this.camera.updateProjectionMatrix();
|
|
2672
|
+
this.renderer.setPixelRatio(Math.min(dpr, 2));
|
|
2673
|
+
this.renderer.setSize(width, height, false);
|
|
2674
|
+
}
|
|
2675
|
+
getCamera() {
|
|
2676
|
+
return this.camera;
|
|
2677
|
+
}
|
|
2678
|
+
getModelRoot() {
|
|
2679
|
+
return this.modelRoot;
|
|
2680
|
+
}
|
|
2681
|
+
getMixer() {
|
|
2682
|
+
return this.mixer;
|
|
2683
|
+
}
|
|
2334
2684
|
};
|
|
2335
2685
|
|
|
2336
2686
|
// src/avatar/CssAvatarRenderer.ts
|
|
@@ -2341,7 +2691,7 @@ var AVATAR_CSS = `
|
|
|
2341
2691
|
display: flex;
|
|
2342
2692
|
flex-direction: column;
|
|
2343
2693
|
align-items: center;
|
|
2344
|
-
gap:
|
|
2694
|
+
gap: 4px;
|
|
2345
2695
|
pointer-events: auto;
|
|
2346
2696
|
user-select: none;
|
|
2347
2697
|
}
|
|
@@ -2362,28 +2712,38 @@ var AVATAR_CSS = `
|
|
|
2362
2712
|
padding: 0;
|
|
2363
2713
|
outline: none;
|
|
2364
2714
|
background: #2563eb;
|
|
2715
|
+
transition: width 0.3s ease, height 0.3s ease, background 0.3s ease;
|
|
2716
|
+
}
|
|
2717
|
+
.asiyst-figure.asiyst-3d-active {
|
|
2718
|
+
width: 240px !important;
|
|
2719
|
+
height: 460px !important;
|
|
2720
|
+
background: transparent !important;
|
|
2721
|
+
border-radius: 0 !important;
|
|
2722
|
+
box-shadow: none !important;
|
|
2723
|
+
overflow: visible !important;
|
|
2724
|
+
}
|
|
2725
|
+
@media (max-width: 640px) {
|
|
2726
|
+
.asiyst-figure.asiyst-3d-active {
|
|
2727
|
+
width: 180px !important;
|
|
2728
|
+
height: 360px !important;
|
|
2729
|
+
}
|
|
2365
2730
|
}
|
|
2366
|
-
.asiyst-figure[data-pose="point"] { transform: rotate(-12deg); }
|
|
2367
|
-
.asiyst-figure[data-pose="think"] { opacity: 0.85; }
|
|
2368
|
-
.asiyst-figure[data-pose="celebrate"] { transform: scale(1.08); }
|
|
2369
2731
|
.asiyst-avatar-viewport {
|
|
2370
|
-
position:
|
|
2371
|
-
inset: 0;
|
|
2732
|
+
position: relative;
|
|
2372
2733
|
width: 100%;
|
|
2373
2734
|
height: 100%;
|
|
2374
2735
|
display: grid;
|
|
2375
2736
|
place-items: center;
|
|
2376
2737
|
border-radius: inherit;
|
|
2377
|
-
overflow:
|
|
2378
|
-
pointer-events:
|
|
2738
|
+
overflow: visible;
|
|
2739
|
+
pointer-events: auto;
|
|
2379
2740
|
}
|
|
2380
2741
|
.asiyst-avatar-canvas {
|
|
2381
2742
|
width: 100%;
|
|
2382
2743
|
height: 100%;
|
|
2383
2744
|
object-fit: contain;
|
|
2384
|
-
border-radius: inherit;
|
|
2385
2745
|
display: block;
|
|
2386
|
-
pointer-events:
|
|
2746
|
+
pointer-events: auto;
|
|
2387
2747
|
}
|
|
2388
2748
|
.asiyst-avatar-graphic {
|
|
2389
2749
|
width: 100%;
|
|
@@ -2394,13 +2754,23 @@ var AVATAR_CSS = `
|
|
|
2394
2754
|
pointer-events: none;
|
|
2395
2755
|
}
|
|
2396
2756
|
.asiyst-avatar-loader {
|
|
2397
|
-
width:
|
|
2398
|
-
height:
|
|
2399
|
-
border: 3px solid rgba(
|
|
2400
|
-
border-top-color: #
|
|
2757
|
+
width: 34px;
|
|
2758
|
+
height: 34px;
|
|
2759
|
+
border: 3px solid rgba(37, 99, 235, 0.2);
|
|
2760
|
+
border-top-color: #2563eb;
|
|
2401
2761
|
border-radius: 50%;
|
|
2402
2762
|
animation: asiyst-spin 0.8s linear infinite;
|
|
2403
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
|
+
}
|
|
2404
2774
|
@keyframes asiyst-spin {
|
|
2405
2775
|
to { transform: rotate(360deg); }
|
|
2406
2776
|
}
|
|
@@ -2437,11 +2807,73 @@ var AVATAR_CSS = `
|
|
|
2437
2807
|
padding: 8px 10px;
|
|
2438
2808
|
font: 13px/1.4 system-ui, sans-serif;
|
|
2439
2809
|
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
|
|
2810
|
+
margin-bottom: 4px;
|
|
2811
|
+
}
|
|
2812
|
+
.asiyst-name-tag {
|
|
2813
|
+
display: inline-flex;
|
|
2814
|
+
align-items: center;
|
|
2815
|
+
gap: 6px;
|
|
2816
|
+
background: rgba(255, 255, 255, 0.95);
|
|
2817
|
+
backdrop-filter: blur(8px);
|
|
2818
|
+
border: 1px solid rgba(226, 232, 240, 0.9);
|
|
2819
|
+
border-radius: 9999px;
|
|
2820
|
+
padding: 4px 12px;
|
|
2821
|
+
font-size: 11px;
|
|
2822
|
+
font-weight: 700;
|
|
2823
|
+
color: #1e293b;
|
|
2824
|
+
box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
|
|
2825
|
+
user-select: none;
|
|
2826
|
+
margin-bottom: 2px;
|
|
2827
|
+
pointer-events: none;
|
|
2828
|
+
transition: opacity 0.2s ease;
|
|
2829
|
+
}
|
|
2830
|
+
.asiyst-name-sparkle { color: #f59e0b; font-size: 12px; font-weight: 900; }
|
|
2831
|
+
.asiyst-name-dot {
|
|
2832
|
+
width: 6px;
|
|
2833
|
+
height: 6px;
|
|
2834
|
+
border-radius: 50%;
|
|
2835
|
+
background: #10b981;
|
|
2836
|
+
display: inline-block;
|
|
2837
|
+
animation: asiyst-pulse 2s infinite;
|
|
2838
|
+
}
|
|
2839
|
+
.asiyst-name-status {
|
|
2840
|
+
font-size: 10px;
|
|
2841
|
+
color: #64748b;
|
|
2842
|
+
font-weight: 500;
|
|
2843
|
+
text-transform: uppercase;
|
|
2844
|
+
}
|
|
2845
|
+
@keyframes asiyst-pulse {
|
|
2846
|
+
0%, 100% { opacity: 1; transform: scale(1); }
|
|
2847
|
+
50% { opacity: 0.4; transform: scale(1.3); }
|
|
2848
|
+
}
|
|
2849
|
+
.asiyst-open-chat-btn {
|
|
2850
|
+
display: inline-flex;
|
|
2851
|
+
align-items: center;
|
|
2852
|
+
gap: 6px;
|
|
2853
|
+
background: #0f172a;
|
|
2854
|
+
color: #fbbf24;
|
|
2855
|
+
border: 1px solid rgba(245, 158, 11, 0.6);
|
|
2856
|
+
border-radius: 9999px;
|
|
2857
|
+
padding: 6px 14px;
|
|
2858
|
+
font-size: 12px;
|
|
2859
|
+
font-weight: 700;
|
|
2860
|
+
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
|
|
2861
|
+
cursor: pointer;
|
|
2862
|
+
margin-top: 4px;
|
|
2863
|
+
pointer-events: auto;
|
|
2864
|
+
transition: transform 0.15s ease, background-color 0.15s ease;
|
|
2865
|
+
}
|
|
2866
|
+
.asiyst-open-chat-btn:hover {
|
|
2867
|
+
transform: scale(1.05);
|
|
2868
|
+
background: #1e293b;
|
|
2869
|
+
}
|
|
2870
|
+
.asiyst-open-chat-btn svg {
|
|
2871
|
+
stroke: #fbbf24;
|
|
2440
2872
|
}
|
|
2441
|
-
.asiyst-name { font: 600 12px/1 system-ui, sans-serif; color: #0f172a; }
|
|
2442
2873
|
@media (prefers-reduced-motion: reduce) {
|
|
2443
2874
|
.asiyst-avatar.asiyst-animate { transition: none; }
|
|
2444
2875
|
.asiyst-avatar-loader { animation: none; }
|
|
2876
|
+
.asiyst-name-dot { animation: none; }
|
|
2445
2877
|
}
|
|
2446
2878
|
`;
|
|
2447
2879
|
var CssAvatarRenderer = class {
|
|
@@ -2452,12 +2884,14 @@ var CssAvatarRenderer = class {
|
|
|
2452
2884
|
this.pose = "idle";
|
|
2453
2885
|
this.accentColor = "#2563eb";
|
|
2454
2886
|
this.avatarName = "Asiyst";
|
|
2887
|
+
this.isPanelOpen = false;
|
|
2888
|
+
this.has3dAssetConfigured = false;
|
|
2455
2889
|
// Asset loading & rendering state
|
|
2456
2890
|
this.assetLoader = new AssetLoader();
|
|
2457
2891
|
this.fbxRenderer = null;
|
|
2458
2892
|
this.renderState = "idle";
|
|
2459
2893
|
this.isAssetLoadedFlag = false;
|
|
2460
|
-
this.isFallbackFlag =
|
|
2894
|
+
this.isFallbackFlag = false;
|
|
2461
2895
|
}
|
|
2462
2896
|
mount(container, config) {
|
|
2463
2897
|
const doc = container.ownerDocument;
|
|
@@ -2467,6 +2901,20 @@ var CssAvatarRenderer = class {
|
|
|
2467
2901
|
this.root = doc.createElement("div");
|
|
2468
2902
|
this.root.className = "asiyst-avatar asiyst-animate";
|
|
2469
2903
|
this.root.setAttribute("role", "img");
|
|
2904
|
+
this.nameTagEl = doc.createElement("div");
|
|
2905
|
+
this.nameTagEl.className = "asiyst-name-tag";
|
|
2906
|
+
const sparkle = doc.createElement("span");
|
|
2907
|
+
sparkle.className = "asiyst-name-sparkle";
|
|
2908
|
+
sparkle.textContent = "\u2726";
|
|
2909
|
+
this.nameTextEl = doc.createElement("span");
|
|
2910
|
+
this.nameTextEl.className = "asiyst-name-text";
|
|
2911
|
+
this.nameTextEl.textContent = config.avatarName;
|
|
2912
|
+
const dot = doc.createElement("span");
|
|
2913
|
+
dot.className = "asiyst-name-dot";
|
|
2914
|
+
this.statusTextEl = doc.createElement("span");
|
|
2915
|
+
this.statusTextEl.className = "asiyst-name-status";
|
|
2916
|
+
this.statusTextEl.textContent = "(IDLE)";
|
|
2917
|
+
this.nameTagEl.append(sparkle, this.nameTextEl, dot, this.statusTextEl);
|
|
2470
2918
|
this.figure = doc.createElement("button");
|
|
2471
2919
|
this.figure.type = "button";
|
|
2472
2920
|
this.figure.className = "asiyst-figure";
|
|
@@ -2475,12 +2923,26 @@ var CssAvatarRenderer = class {
|
|
|
2475
2923
|
this.viewport = doc.createElement("div");
|
|
2476
2924
|
this.viewport.className = "asiyst-avatar-viewport";
|
|
2477
2925
|
this.figure.appendChild(this.viewport);
|
|
2478
|
-
this.nameEl = doc.createElement("div");
|
|
2479
|
-
this.nameEl.className = "asiyst-name";
|
|
2480
2926
|
this.bubble = doc.createElement("div");
|
|
2481
2927
|
this.bubble.className = "asiyst-bubble";
|
|
2482
2928
|
this.bubble.hidden = true;
|
|
2483
|
-
this.
|
|
2929
|
+
this.chatActionBtn = doc.createElement("button");
|
|
2930
|
+
this.chatActionBtn.type = "button";
|
|
2931
|
+
this.chatActionBtn.className = "asiyst-open-chat-btn";
|
|
2932
|
+
this.chatActionBtn.innerHTML = `
|
|
2933
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
|
2934
|
+
<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>
|
|
2935
|
+
</svg>
|
|
2936
|
+
<span>Chat with ${config.avatarName}</span>
|
|
2937
|
+
`;
|
|
2938
|
+
this.chatActionBtn.addEventListener("click", (e) => {
|
|
2939
|
+
e.stopPropagation();
|
|
2940
|
+
this.onOpenChat?.();
|
|
2941
|
+
});
|
|
2942
|
+
this.figure.addEventListener("click", () => {
|
|
2943
|
+
this.onOpenChat?.();
|
|
2944
|
+
});
|
|
2945
|
+
this.root.append(this.bubble, this.nameTagEl, this.figure, this.chatActionBtn);
|
|
2484
2946
|
container.appendChild(this.root);
|
|
2485
2947
|
this.applyConfig(config);
|
|
2486
2948
|
}
|
|
@@ -2494,24 +2956,66 @@ var CssAvatarRenderer = class {
|
|
|
2494
2956
|
this.root = void 0;
|
|
2495
2957
|
this.figure = void 0;
|
|
2496
2958
|
this.viewport = void 0;
|
|
2959
|
+
this.nameTagEl = void 0;
|
|
2960
|
+
this.chatActionBtn = void 0;
|
|
2497
2961
|
}
|
|
2498
2962
|
applyConfig(config) {
|
|
2499
2963
|
this.size = config.size;
|
|
2500
2964
|
this.accentColor = config.theme.accent ?? "#2563eb";
|
|
2501
2965
|
this.avatarName = config.avatarName;
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
this.
|
|
2506
|
-
}
|
|
2507
|
-
if (this.
|
|
2508
|
-
renderSafeText(this.
|
|
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
|
+
}
|
|
2971
|
+
if (this.nameTextEl) {
|
|
2972
|
+
renderSafeText(this.nameTextEl, config.avatarName);
|
|
2973
|
+
}
|
|
2974
|
+
if (this.chatActionBtn) {
|
|
2975
|
+
const span = this.chatActionBtn.querySelector("span");
|
|
2976
|
+
if (span) {
|
|
2977
|
+
renderSafeText(span, `Chat with ${config.avatarName}`);
|
|
2978
|
+
}
|
|
2509
2979
|
}
|
|
2510
2980
|
if (this.root) {
|
|
2511
2981
|
this.root.setAttribute("aria-label", config.avatarName);
|
|
2512
2982
|
}
|
|
2513
|
-
if (
|
|
2514
|
-
this.
|
|
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 {
|
|
3001
|
+
if (this.figure) {
|
|
3002
|
+
this.figure.classList.remove("asiyst-3d-active");
|
|
3003
|
+
this.figure.style.width = `${config.size}px`;
|
|
3004
|
+
this.figure.style.height = `${config.size}px`;
|
|
3005
|
+
this.figure.style.background = this.accentColor;
|
|
3006
|
+
}
|
|
3007
|
+
if (this.chatActionBtn) {
|
|
3008
|
+
this.chatActionBtn.style.display = "none";
|
|
3009
|
+
}
|
|
3010
|
+
if (this.viewport && !this.isAssetLoadedFlag) {
|
|
3011
|
+
this.renderFallback();
|
|
3012
|
+
}
|
|
3013
|
+
}
|
|
3014
|
+
}
|
|
3015
|
+
setPanelOpen(open) {
|
|
3016
|
+
this.isPanelOpen = open;
|
|
3017
|
+
if (this.chatActionBtn && this.isAssetLoadedFlag) {
|
|
3018
|
+
this.chatActionBtn.style.display = open ? "none" : "inline-flex";
|
|
2515
3019
|
}
|
|
2516
3020
|
}
|
|
2517
3021
|
async loadAsset(config) {
|
|
@@ -2524,15 +3028,20 @@ var CssAvatarRenderer = class {
|
|
|
2524
3028
|
return false;
|
|
2525
3029
|
}
|
|
2526
3030
|
this.activeAssetUrl = assetUrl;
|
|
3031
|
+
this.has3dAssetConfigured = true;
|
|
2527
3032
|
this.renderState = "loading";
|
|
2528
3033
|
this.isFallbackFlag = false;
|
|
2529
3034
|
this.lastErrorMessage = void 0;
|
|
2530
3035
|
if (this.figure) {
|
|
2531
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";
|
|
2532
3041
|
}
|
|
2533
3042
|
this.renderLoader();
|
|
2534
3043
|
try {
|
|
2535
|
-
const asset = await this.assetLoader.load(assetUrl);
|
|
3044
|
+
const asset = await this.assetLoader.load(assetUrl, { timeoutMs: 6e4 });
|
|
2536
3045
|
await this.renderLoadedAsset(asset, config);
|
|
2537
3046
|
this.renderState = "ready";
|
|
2538
3047
|
this.isAssetLoadedFlag = true;
|
|
@@ -2540,6 +3049,13 @@ var CssAvatarRenderer = class {
|
|
|
2540
3049
|
this.loadedFormat = asset.format;
|
|
2541
3050
|
if (this.figure) {
|
|
2542
3051
|
this.figure.setAttribute("data-state", "ready");
|
|
3052
|
+
this.figure.classList.add("asiyst-3d-active");
|
|
3053
|
+
this.figure.style.width = "";
|
|
3054
|
+
this.figure.style.height = "";
|
|
3055
|
+
this.figure.style.background = "transparent";
|
|
3056
|
+
}
|
|
3057
|
+
if (this.chatActionBtn) {
|
|
3058
|
+
this.chatActionBtn.style.display = this.isPanelOpen ? "none" : "inline-flex";
|
|
2543
3059
|
}
|
|
2544
3060
|
return true;
|
|
2545
3061
|
} catch (err) {
|
|
@@ -2551,6 +3067,9 @@ var CssAvatarRenderer = class {
|
|
|
2551
3067
|
if (this.figure) {
|
|
2552
3068
|
this.figure.setAttribute("data-state", "error");
|
|
2553
3069
|
}
|
|
3070
|
+
if (this.chatActionBtn) {
|
|
3071
|
+
this.chatActionBtn.style.display = "none";
|
|
3072
|
+
}
|
|
2554
3073
|
this.renderFallback(true);
|
|
2555
3074
|
return false;
|
|
2556
3075
|
}
|
|
@@ -2559,10 +3078,13 @@ var CssAvatarRenderer = class {
|
|
|
2559
3078
|
if (!this.viewport) return;
|
|
2560
3079
|
this.viewport.replaceChildren();
|
|
2561
3080
|
const doc = this.viewport.ownerDocument;
|
|
3081
|
+
const container = doc.createElement("div");
|
|
3082
|
+
container.className = "asiyst-avatar-loading-silhouette";
|
|
2562
3083
|
const loader = doc.createElement("div");
|
|
2563
3084
|
loader.className = "asiyst-avatar-loader";
|
|
2564
3085
|
loader.setAttribute("aria-label", `Loading ${this.avatarName}`);
|
|
2565
|
-
|
|
3086
|
+
container.appendChild(loader);
|
|
3087
|
+
this.viewport.appendChild(container);
|
|
2566
3088
|
}
|
|
2567
3089
|
async renderLoadedAsset(asset, config) {
|
|
2568
3090
|
if (!this.viewport) return;
|
|
@@ -2571,10 +3093,15 @@ var CssAvatarRenderer = class {
|
|
|
2571
3093
|
this.fbxRenderer = null;
|
|
2572
3094
|
}
|
|
2573
3095
|
if (asset.format === "fbx" || asset.format === "glb") {
|
|
3096
|
+
const isMobile = typeof window !== "undefined" && window.innerWidth <= 640;
|
|
3097
|
+
const width = isMobile ? 180 : 240;
|
|
3098
|
+
const height = isMobile ? 360 : 460;
|
|
2574
3099
|
this.fbxRenderer = new FbxRenderer();
|
|
2575
3100
|
this.renderMetrics = await this.fbxRenderer.mount(this.viewport, asset, {
|
|
2576
3101
|
accentColor: this.accentColor,
|
|
2577
|
-
config
|
|
3102
|
+
config,
|
|
3103
|
+
width,
|
|
3104
|
+
height
|
|
2578
3105
|
});
|
|
2579
3106
|
this.fbxRenderer.setFacing(this.facing);
|
|
2580
3107
|
this.fbxRenderer.setPose(this.pose);
|
|
@@ -2590,7 +3117,7 @@ var CssAvatarRenderer = class {
|
|
|
2590
3117
|
const thumb = typeof asset.manifest.thumbnailUrl === "string" ? asset.manifest.thumbnailUrl : void 0;
|
|
2591
3118
|
const modelUrl = typeof asset.manifest.assetUrl === "string" ? asset.manifest.assetUrl : typeof asset.manifest.modelUrl === "string" ? asset.manifest.modelUrl : void 0;
|
|
2592
3119
|
if (modelUrl) {
|
|
2593
|
-
const subAsset = await this.assetLoader.load(modelUrl);
|
|
3120
|
+
const subAsset = await this.assetLoader.load(modelUrl, { timeoutMs: 6e4 });
|
|
2594
3121
|
await this.renderLoadedAsset(subAsset, config);
|
|
2595
3122
|
} else if (thumb) {
|
|
2596
3123
|
this.viewport.replaceChildren();
|
|
@@ -2622,7 +3149,6 @@ var CssAvatarRenderer = class {
|
|
|
2622
3149
|
if (isError) {
|
|
2623
3150
|
const badge = doc.createElement("span");
|
|
2624
3151
|
badge.className = "asiyst-avatar-fallback-badge";
|
|
2625
|
-
badge.setAttribute("title", "Avatar asset failed to load");
|
|
2626
3152
|
badge.textContent = "!";
|
|
2627
3153
|
fallback.appendChild(badge);
|
|
2628
3154
|
}
|
|
@@ -2630,66 +3156,75 @@ var CssAvatarRenderer = class {
|
|
|
2630
3156
|
}
|
|
2631
3157
|
setPosition(x, y, animate) {
|
|
2632
3158
|
if (!this.root) return;
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
3159
|
+
if (animate) {
|
|
3160
|
+
this.root.classList.add("asiyst-animate");
|
|
3161
|
+
} else {
|
|
3162
|
+
this.root.classList.remove("asiyst-animate");
|
|
3163
|
+
}
|
|
3164
|
+
this.root.style.left = `${Math.round(x)}px`;
|
|
3165
|
+
this.root.style.top = `${Math.round(y)}px`;
|
|
2636
3166
|
}
|
|
2637
3167
|
setFacing(direction) {
|
|
2638
3168
|
this.facing = direction;
|
|
2639
3169
|
this.fbxRenderer?.setFacing(direction);
|
|
2640
|
-
this.syncTransform();
|
|
2641
3170
|
}
|
|
2642
3171
|
setPose(pose) {
|
|
2643
3172
|
this.pose = pose;
|
|
3173
|
+
if (this.figure) {
|
|
3174
|
+
this.figure.setAttribute("data-pose", pose);
|
|
3175
|
+
}
|
|
3176
|
+
if (this.statusTextEl) {
|
|
3177
|
+
const displayStatus = pose === "speak" ? "(SPEAKING)" : pose === "think" ? "(THINKING)" : pose === "celebrate" ? "(CELEBRATING)" : "(IDLE)";
|
|
3178
|
+
this.statusTextEl.textContent = displayStatus;
|
|
3179
|
+
}
|
|
2644
3180
|
this.fbxRenderer?.setPose(pose);
|
|
2645
|
-
this.figure?.setAttribute("data-pose", pose);
|
|
2646
|
-
this.syncTransform();
|
|
2647
|
-
}
|
|
2648
|
-
syncTransform() {
|
|
2649
|
-
if (!this.figure) return;
|
|
2650
|
-
const face = this.facing === "left" ? "scaleX(-1)" : "";
|
|
2651
|
-
const pose = this.pose === "point" ? "rotate(-12deg)" : this.pose === "celebrate" ? "scale(1.08)" : "";
|
|
2652
|
-
this.figure.style.transform = `${face} ${pose}`.trim();
|
|
2653
3181
|
}
|
|
2654
3182
|
setSpeech(text) {
|
|
2655
3183
|
if (!this.bubble) return;
|
|
2656
3184
|
if (!text) {
|
|
2657
3185
|
this.bubble.hidden = true;
|
|
2658
|
-
this.bubble.
|
|
3186
|
+
this.bubble.replaceChildren();
|
|
2659
3187
|
return;
|
|
2660
3188
|
}
|
|
2661
3189
|
this.bubble.hidden = false;
|
|
2662
3190
|
renderSafeText(this.bubble, text);
|
|
2663
3191
|
}
|
|
2664
3192
|
getSize() {
|
|
3193
|
+
if (this.isAssetLoadedFlag || this.has3dAssetConfigured) {
|
|
3194
|
+
const isMobile = typeof window !== "undefined" && window.innerWidth <= 640;
|
|
3195
|
+
return { width: isMobile ? 180 : 240, height: isMobile ? 390 : 490 };
|
|
3196
|
+
}
|
|
2665
3197
|
return { width: this.size, height: this.size + 28 };
|
|
2666
3198
|
}
|
|
3199
|
+
playAnimation(nameOrIntent, loopMode) {
|
|
3200
|
+
return this.fbxRenderer?.playAnimation(nameOrIntent, loopMode) ?? false;
|
|
3201
|
+
}
|
|
2667
3202
|
setHidden(hidden) {
|
|
2668
3203
|
this.hidden = hidden;
|
|
2669
3204
|
if (this.root) {
|
|
2670
|
-
this.root.
|
|
3205
|
+
this.root.style.display = hidden ? "none" : "";
|
|
2671
3206
|
}
|
|
2672
3207
|
}
|
|
2673
3208
|
isHidden() {
|
|
2674
3209
|
return this.hidden;
|
|
2675
3210
|
}
|
|
2676
|
-
|
|
2677
|
-
return this.
|
|
2678
|
-
}
|
|
2679
|
-
getViewport() {
|
|
2680
|
-
return this.viewport;
|
|
3211
|
+
getRenderState() {
|
|
3212
|
+
return this.renderState;
|
|
2681
3213
|
}
|
|
2682
3214
|
isAssetLoaded() {
|
|
2683
3215
|
return this.isAssetLoadedFlag;
|
|
2684
3216
|
}
|
|
2685
|
-
|
|
2686
|
-
return this.
|
|
3217
|
+
getViewport() {
|
|
3218
|
+
return this.viewport;
|
|
3219
|
+
}
|
|
3220
|
+
isFallback() {
|
|
3221
|
+
return this.isFallbackFlag;
|
|
2687
3222
|
}
|
|
2688
3223
|
isFallbackActive() {
|
|
2689
3224
|
return this.isFallbackFlag;
|
|
2690
3225
|
}
|
|
2691
|
-
|
|
2692
|
-
return this.
|
|
3226
|
+
isRendered() {
|
|
3227
|
+
return this.isAssetLoadedFlag && (this.fbxRenderer ? this.fbxRenderer.isRendered() : true);
|
|
2693
3228
|
}
|
|
2694
3229
|
getLoadedFormat() {
|
|
2695
3230
|
return this.loadedFormat;
|
|
@@ -2703,6 +3238,18 @@ var CssAvatarRenderer = class {
|
|
|
2703
3238
|
getMetrics() {
|
|
2704
3239
|
return this.renderMetrics;
|
|
2705
3240
|
}
|
|
3241
|
+
getFigure() {
|
|
3242
|
+
return this.figure;
|
|
3243
|
+
}
|
|
3244
|
+
getFbxRenderer() {
|
|
3245
|
+
return this.fbxRenderer;
|
|
3246
|
+
}
|
|
3247
|
+
getChatActionBtn() {
|
|
3248
|
+
return this.chatActionBtn;
|
|
3249
|
+
}
|
|
3250
|
+
getNameTag() {
|
|
3251
|
+
return this.nameTagEl;
|
|
3252
|
+
}
|
|
2706
3253
|
};
|
|
2707
3254
|
|
|
2708
3255
|
// src/accessibility/a11y.ts
|
|
@@ -2886,6 +3433,8 @@ var MovementEngine = class {
|
|
|
2886
3433
|
this.onViewport = throttle(() => {
|
|
2887
3434
|
if (this.followTarget) {
|
|
2888
3435
|
this.placeBeside(this.followTarget, false);
|
|
3436
|
+
} else {
|
|
3437
|
+
this.goToAnchor();
|
|
2889
3438
|
}
|
|
2890
3439
|
}, VIEWPORT_HANDLER_THROTTLE_MS);
|
|
2891
3440
|
}
|
|
@@ -3503,27 +4052,39 @@ var ConversationPanel = class {
|
|
|
3503
4052
|
this.style.textContent = `
|
|
3504
4053
|
.asiyst-panel {
|
|
3505
4054
|
position: fixed;
|
|
3506
|
-
right:
|
|
3507
|
-
bottom:
|
|
3508
|
-
width: min(
|
|
3509
|
-
max-height: min(
|
|
3510
|
-
background: #
|
|
4055
|
+
right: 256px;
|
|
4056
|
+
bottom: 20px;
|
|
4057
|
+
width: min(380px, calc(100vw - 280px));
|
|
4058
|
+
max-height: min(560px, 75vh);
|
|
4059
|
+
background: #ffffff;
|
|
3511
4060
|
color: #0f172a;
|
|
3512
|
-
border-radius:
|
|
3513
|
-
box-shadow: 0
|
|
4061
|
+
border-radius: 18px;
|
|
4062
|
+
box-shadow: 0 20px 48px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(15, 23, 42, 0.08);
|
|
3514
4063
|
display: flex;
|
|
3515
4064
|
flex-direction: column;
|
|
3516
|
-
font: 14px/1.45 system-ui, sans-serif;
|
|
4065
|
+
font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
3517
4066
|
overflow: hidden;
|
|
4067
|
+
z-index: 100000;
|
|
4068
|
+
transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
|
|
4069
|
+
}
|
|
4070
|
+
@media (max-width: 640px) {
|
|
4071
|
+
.asiyst-panel {
|
|
4072
|
+
right: 12px;
|
|
4073
|
+
bottom: 12px;
|
|
4074
|
+
left: 12px;
|
|
4075
|
+
width: auto;
|
|
4076
|
+
max-height: 70vh;
|
|
4077
|
+
}
|
|
3518
4078
|
}
|
|
3519
4079
|
.asiyst-panel[hidden] { display: none; }
|
|
3520
4080
|
.asiyst-panel header {
|
|
3521
4081
|
display: flex;
|
|
3522
4082
|
justify-content: space-between;
|
|
3523
4083
|
align-items: center;
|
|
3524
|
-
padding:
|
|
4084
|
+
padding: 14px 16px;
|
|
3525
4085
|
background: #0f172a;
|
|
3526
4086
|
color: #f8fafc;
|
|
4087
|
+
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
|
3527
4088
|
}
|
|
3528
4089
|
.asiyst-log { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
|
|
3529
4090
|
.asiyst-msg { padding: 8px 10px; border-radius: 10px; max-width: 90%; }
|
|
@@ -3915,6 +4476,9 @@ var AsiystRuntime = class {
|
|
|
3915
4476
|
}) : void 0;
|
|
3916
4477
|
this.cloud = new CloudClient(transport, options.projectId, options.publicKey, runtimeAuth, this.visitorSessionId, options.avatarId);
|
|
3917
4478
|
this.config = new ConfigManager(options, this.cloud, this.events);
|
|
4479
|
+
this.config.onConfigUpdated = (newConfig, prevConfig) => {
|
|
4480
|
+
void this.applyUpdatedConfig(newConfig, prevConfig);
|
|
4481
|
+
};
|
|
3918
4482
|
this.analytics = new Analytics(options.projectId, this.cloud);
|
|
3919
4483
|
this.host = new HostRoot(doc);
|
|
3920
4484
|
this.resolver = new TargetResolver(
|
|
@@ -3923,6 +4487,7 @@ var AsiystRuntime = class {
|
|
|
3923
4487
|
() => this.map.list()
|
|
3924
4488
|
);
|
|
3925
4489
|
this.renderer = new CssAvatarRenderer();
|
|
4490
|
+
this.renderer.onOpenChat = () => this.open();
|
|
3926
4491
|
this.renderer.mount(this.host.chrome, this.config.get());
|
|
3927
4492
|
this.highlights = new HighlightLayer(this.host.overlay, win);
|
|
3928
4493
|
this.movement = new MovementEngine(win, doc, this.renderer, this.resolver, this.events, () => this.config.get());
|
|
@@ -3945,6 +4510,7 @@ var AsiystRuntime = class {
|
|
|
3945
4510
|
(open) => {
|
|
3946
4511
|
const convId = this.panel.getConversationId();
|
|
3947
4512
|
this.cloud.setConversationId(convId);
|
|
4513
|
+
this.renderer.setPanelOpen(open);
|
|
3948
4514
|
if (open) {
|
|
3949
4515
|
this.analytics.track("assistant_opened");
|
|
3950
4516
|
this.events.emit("asiyst:conversation:started", { conversationId: convId });
|
|
@@ -3987,6 +4553,7 @@ var AsiystRuntime = class {
|
|
|
3987
4553
|
}
|
|
3988
4554
|
this.avatar.applyConfig(cfg);
|
|
3989
4555
|
this.avatar.show();
|
|
4556
|
+
this.movement.goToAnchor();
|
|
3990
4557
|
this.lifecycle.emit("sdk.verification_started", {
|
|
3991
4558
|
projectId: this.options.projectId,
|
|
3992
4559
|
origin: window.location.origin,
|
|
@@ -3994,10 +4561,15 @@ var AsiystRuntime = class {
|
|
|
3994
4561
|
installationId: this.installationId,
|
|
3995
4562
|
sdkVersion: SDK_VERSION
|
|
3996
4563
|
});
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
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
|
+
})();
|
|
4001
4573
|
this.events.emit("asiyst:ready", { projectId: this.options.projectId, configVersion: cfg.version });
|
|
4002
4574
|
void this.cloud.sendTelemetryEvent("avatar_runtime_initialized", {
|
|
4003
4575
|
avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
|
|
@@ -4006,71 +4578,145 @@ var AsiystRuntime = class {
|
|
|
4006
4578
|
});
|
|
4007
4579
|
const assetTarget = cfg.assetUrl ?? cfg.thumbnailUrl;
|
|
4008
4580
|
if (assetTarget) {
|
|
4009
|
-
this.
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
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", {
|
|
4024
4615
|
avatarId: this.options.avatarId ?? cfg.avatarId,
|
|
4025
|
-
assetUrl,
|
|
4026
4616
|
format
|
|
4027
4617
|
});
|
|
4028
|
-
void this.cloud.sendTelemetryEvent("
|
|
4618
|
+
void this.cloud.sendTelemetryEvent("avatar_rendered", {
|
|
4029
4619
|
avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
|
|
4030
4620
|
avatarName: cfg.avatarName,
|
|
4031
|
-
assetUrl,
|
|
4032
4621
|
format,
|
|
4033
4622
|
publishedVersion: cfg.publishedVersion
|
|
4034
4623
|
});
|
|
4035
|
-
if (isRendered) {
|
|
4036
|
-
this.events.emit("asiyst:avatar:rendered", {
|
|
4037
|
-
avatarId: this.options.avatarId ?? cfg.avatarId,
|
|
4038
|
-
format
|
|
4039
|
-
});
|
|
4040
|
-
void this.cloud.sendTelemetryEvent("avatar_rendered", {
|
|
4041
|
-
avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
|
|
4042
|
-
avatarName: cfg.avatarName,
|
|
4043
|
-
format,
|
|
4044
|
-
publishedVersion: cfg.publishedVersion
|
|
4045
|
-
});
|
|
4046
|
-
}
|
|
4047
|
-
} else {
|
|
4048
|
-
const err = this.renderer.getLastError() ?? "Avatar asset loading failed";
|
|
4049
|
-
this.events.emit("asiyst:avatar:error", {
|
|
4050
|
-
avatarId: this.options.avatarId ?? cfg.avatarId,
|
|
4051
|
-
error: err,
|
|
4052
|
-
stage: "renderer_init"
|
|
4053
|
-
});
|
|
4054
|
-
void this.cloud.sendTelemetryEvent("avatar_render_failed", {
|
|
4055
|
-
avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
|
|
4056
|
-
error: err,
|
|
4057
|
-
stage: "renderer_init"
|
|
4058
|
-
});
|
|
4059
4624
|
}
|
|
4060
|
-
|
|
4061
|
-
|
|
4625
|
+
return true;
|
|
4626
|
+
} else {
|
|
4627
|
+
const err = this.renderer.getLastError() ?? "Avatar asset loading failed";
|
|
4062
4628
|
this.events.emit("asiyst:avatar:error", {
|
|
4063
4629
|
avatarId: this.options.avatarId ?? cfg.avatarId,
|
|
4064
4630
|
error: err,
|
|
4065
|
-
stage: "
|
|
4631
|
+
stage: "renderer_init"
|
|
4066
4632
|
});
|
|
4067
4633
|
void this.cloud.sendTelemetryEvent("avatar_render_failed", {
|
|
4068
4634
|
avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
|
|
4069
4635
|
error: err,
|
|
4070
|
-
stage: "
|
|
4636
|
+
stage: "renderer_init"
|
|
4071
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
|
+
}
|
|
4072
4688
|
}
|
|
4073
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;
|
|
4074
4720
|
}
|
|
4075
4721
|
getConnectionStatus() {
|
|
4076
4722
|
return this.connectionStatus;
|
|
@@ -4084,9 +4730,14 @@ var AsiystRuntime = class {
|
|
|
4084
4730
|
open() {
|
|
4085
4731
|
this.panel.open();
|
|
4086
4732
|
this.avatar.show();
|
|
4733
|
+
this.renderer.setPanelOpen(true);
|
|
4087
4734
|
}
|
|
4088
4735
|
close() {
|
|
4089
4736
|
this.panel.close();
|
|
4737
|
+
this.renderer.setPanelOpen(false);
|
|
4738
|
+
}
|
|
4739
|
+
getRenderer() {
|
|
4740
|
+
return this.renderer;
|
|
4090
4741
|
}
|
|
4091
4742
|
avatarApi() {
|
|
4092
4743
|
return this.avatar;
|
|
@@ -4126,6 +4777,10 @@ var AsiystRuntime = class {
|
|
|
4126
4777
|
clearInterval(this.heartbeatTimer);
|
|
4127
4778
|
this.heartbeatTimer = void 0;
|
|
4128
4779
|
}
|
|
4780
|
+
if (this.configRevalidationTimer) {
|
|
4781
|
+
clearInterval(this.configRevalidationTimer);
|
|
4782
|
+
this.configRevalidationTimer = void 0;
|
|
4783
|
+
}
|
|
4129
4784
|
const doc = this.host.host.ownerDocument;
|
|
4130
4785
|
if (doc && this.visibilityListener) {
|
|
4131
4786
|
doc.removeEventListener("visibilitychange", this.visibilityListener);
|
|
@@ -4395,6 +5050,12 @@ var Asiyst = {
|
|
|
4395
5050
|
getConfig() {
|
|
4396
5051
|
return requireRuntime().getConfig();
|
|
4397
5052
|
},
|
|
5053
|
+
async reloadConfig() {
|
|
5054
|
+
return requireRuntime().reloadConfig();
|
|
5055
|
+
},
|
|
5056
|
+
async updateConfig(partial) {
|
|
5057
|
+
await requireRuntime().updateConfig(partial);
|
|
5058
|
+
},
|
|
4398
5059
|
getConnectionStatus() {
|
|
4399
5060
|
return requireRuntime().getConnectionStatus();
|
|
4400
5061
|
},
|
|
@@ -4429,6 +5090,9 @@ var Asiyst = {
|
|
|
4429
5090
|
celebrate() {
|
|
4430
5091
|
withIsolation(() => requireRuntime().avatarApi().celebrate());
|
|
4431
5092
|
},
|
|
5093
|
+
playAnimation(nameOrIntent, options) {
|
|
5094
|
+
return requireRuntime().playAnimation(nameOrIntent, options);
|
|
5095
|
+
},
|
|
4432
5096
|
setPosition(x, y) {
|
|
4433
5097
|
withIsolation(() => requireRuntime().avatarApi().setPosition(x, y));
|
|
4434
5098
|
}
|