@spatius/avatarkit 1.3.4-beta.1 → 1.3.5-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,11 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ## [1.3.4-beta.1] - 2026-08-10
8
+ ## [1.3.4] - 2026-08-11
9
9
 
10
10
  ### Fixed
11
11
  - **The Opus uplink encoder now actually runs off the main thread.** Asset URLs were emitted as absolute paths (`/assets/…`), so any app not served from the domain root — a Vite dev server included — got HTML back for the worker request. The SDK logged `Worker unavailable, falling back to main-thread encode` and encoded every chunk on the main thread, stalling rendering for the whole of playback. URLs are now relative to the referencing chunk.
12
12
  - **Next.js builds no longer fail on the Opus workers.** `withAvatarkit` now copies the pre-built workers (and the sibling chunks they import) into `public/assets/`, and tells webpack to leave those files alone. Previously the bundler re-processed the ESM worker and Terser rejected it with `'import' and 'export' cannot be used outside of module code`, breaking `next build` outright on 1.3.1 and later.
13
+ - Internal telemetry only, no change to public API or runtime behaviour: `http.client.request.duration` no longer records a data point when an asset is served entirely from cache. Those entries carried a hardcoded `statusCode=200` and an empty `server.address`, and their sub-millisecond durations skewed the real network latency distribution. Cache hit rate and cache-hit latency remain available through `download_avatar_assets_latency` and `template_resources_load_measure`, both of which carry `cache_hit` and `cache_type`.
13
14
 
14
15
  ## [1.3.3] - 2026-08-08
15
16
 
@@ -1,8 +1,8 @@
1
1
  import { n as __exportAll } from "./rolldown-runtime-B-1-B7_t.js";
2
- import { t as AvatarSDK } from "./AvatarSDK-kP9209qH.js";
3
- import { Mt as ErrorCode, S as recordHttpClientDuration, St as generateTraceId, c as logEvent, l as logMetric, t as logger, v as hostOf, wt as AvatarError } from "./logger-B-m_sm-g.js";
4
- import { n as APP_CONFIG, r as getFlameCdnBase, t as errorToMessage } from "./error-utils-CSFsFRMn.js";
5
- import { t as PwaCacheManager } from "./pwa-cache-manager-DYYf1j5t.js";
2
+ import { Mt as ErrorCode, S as recordHttpClientDuration, St as generateTraceId, c as logEvent, l as logMetric, t as logger, v as hostOf, wt as AvatarError } from "./logger-BCrlTIt2.js";
3
+ import { n as APP_CONFIG, r as getFlameCdnBase, t as errorToMessage } from "./error-utils-CX5P3vnW.js";
4
+ import { t as AvatarSDK } from "./AvatarSDK-DCYDBMwd.js";
5
+ import { t as PwaCacheManager } from "./pwa-cache-manager-C7su6HpW.js";
6
6
  //#region core/AvatarDownloader.ts
7
7
  var AvatarDownloader_exports = /* @__PURE__ */ __exportAll({ AvatarDownloader: () => AvatarDownloader });
8
8
  /**
@@ -167,7 +167,8 @@ var AvatarDownloader = class {
167
167
  logMetric("template_resources_load_measure", duration, {
168
168
  file_count: 1,
169
169
  cache_hit: true,
170
- cache_type: "pwa"
170
+ cache_type: "pwa",
171
+ result: "success"
171
172
  });
172
173
  return { unifiedModel: cached };
173
174
  }
@@ -193,7 +194,8 @@ var AvatarDownloader = class {
193
194
  logMetric("template_resources_load_measure", Date.now() - startTime, {
194
195
  file_count: 1,
195
196
  cache_hit: false,
196
- cache_type: "none"
197
+ cache_type: "none",
198
+ result: "success"
197
199
  });
198
200
  recordAssetTransaction(templateOutcomes, Date.now() - startTime, TEMPLATE_OPERATION);
199
201
  return { unifiedModel: buffer };
@@ -203,6 +205,16 @@ var AvatarDownloader = class {
203
205
  }
204
206
  }
205
207
  recordAssetTransaction(templateOutcomes, Date.now() - startTime, TEMPLATE_OPERATION);
208
+ const lastStatus = templateOutcomes[0]?.statusCode;
209
+ logMetric("template_resources_load_measure", Date.now() - startTime, {
210
+ file_count: 1,
211
+ cache_hit: false,
212
+ cache_type: "none",
213
+ result: lastStatus !== void 0 && lastStatus >= 200 && lastStatus < 400 ? "decode_failed" : "download_failed"
214
+ }, {
215
+ description: lastError?.message ?? "unknown",
216
+ ...lastStatus !== void 0 ? { last_status_code: lastStatus } : {}
217
+ });
206
218
  throw lastError || /* @__PURE__ */ new Error(`Failed to download unified template after ${maxRetries} attempts`);
207
219
  }
208
220
  /**
@@ -333,6 +345,19 @@ var AvatarDownloader = class {
333
345
  });
334
346
  try {
335
347
  await Promise.all(downloadPromises);
348
+ } catch (error) {
349
+ if (!(error instanceof Error && (error.name === "AbortError" || error.message === "Download cancelled"))) logMetric("download_avatar_assets_latency", Date.now() - totalStartTime, {
350
+ resolution: "default",
351
+ use_compressed_model: useCompressedModel,
352
+ file_count: filesToLoad.length,
353
+ cache_hit: false,
354
+ cache_type: "none",
355
+ result: "download_failed"
356
+ }, {
357
+ avatar_id: characterMeta.characterId ?? "unknown",
358
+ description: error instanceof Error ? error.message : String(error)
359
+ });
360
+ throw error;
336
361
  } finally {
337
362
  recordAssetTransaction(httpOutcomes, Date.now() - totalStartTime);
338
363
  }
@@ -340,6 +365,17 @@ var AvatarDownloader = class {
340
365
  const totalDuration = Date.now() - totalStartTime;
341
366
  if (!characterData.shape || !characterData.pointCloud) {
342
367
  const reason = "Failed to load character data";
368
+ logMetric("download_avatar_assets_latency", totalDuration, {
369
+ resolution: "default",
370
+ use_compressed_model: useCompressedModel,
371
+ file_count: filesToLoad.length,
372
+ cache_hit: false,
373
+ cache_type: "none",
374
+ result: "incomplete_data"
375
+ }, {
376
+ avatar_id: characterMeta.characterId ?? "unknown",
377
+ description: reason
378
+ });
343
379
  logEvent("download_avatar_assets_failed", "error", {
344
380
  avatar_id: characterMeta.characterId ?? "unknown",
345
381
  description: reason
@@ -356,7 +392,8 @@ var AvatarDownloader = class {
356
392
  use_compressed_model: useCompressedModel,
357
393
  file_count: filesToLoad.length,
358
394
  cache_hit: cacheHit,
359
- cache_type: cacheType
395
+ cache_type: cacheType,
396
+ result: "success"
360
397
  }, {
361
398
  avatar_id: characterMeta.characterId ?? "unknown",
362
399
  parallel_duration: parallelDuration,
@@ -532,7 +569,7 @@ var AvatarDownloader = class {
532
569
  const firstError = response.errors[0];
533
570
  throw new AvatarError(`${firstError.code || firstError.status || "SERVER_ERROR"}: ${firstError.detail || firstError.title || firstError.message || "Unknown server error"}`, ErrorCode.failedToFetchAvatarMetadata);
534
571
  }
535
- logMetric("fetch_avatar_metadata_latency", Date.now() - startTime, {}, {
572
+ logMetric("fetch_avatar_metadata_latency", Date.now() - startTime, { result: "success" }, {
536
573
  avatar_id: characterId,
537
574
  trace_id: traceId
538
575
  });
@@ -547,6 +584,11 @@ var AvatarDownloader = class {
547
584
  }
548
585
  logger.error("Failed to fetch character:", error);
549
586
  if (error instanceof AvatarError) {
587
+ logMetric("fetch_avatar_metadata_latency", Date.now() - startTime, { result: error.code }, {
588
+ avatar_id: characterId,
589
+ trace_id: traceId,
590
+ description: error.message
591
+ });
550
592
  logEvent("fetch_avatar_metadata_failed", "error", {
551
593
  avatar_id: characterId ?? "unknown",
552
594
  description: error.message,
@@ -556,6 +598,11 @@ var AvatarDownloader = class {
556
598
  }
557
599
  const errorMessage = error && typeof error === "object" && "message" in error ? String(error.message) : "Failed to fetch character";
558
600
  const dataMessage = error && typeof error === "object" && "data" in error && typeof error.data === "object" && error.data?.message ? String(error.data.message) : null;
601
+ logMetric("fetch_avatar_metadata_latency", Date.now() - startTime, { result: "network_error" }, {
602
+ avatar_id: characterId,
603
+ trace_id: traceId,
604
+ description: dataMessage || errorMessage
605
+ });
559
606
  logEvent("fetch_avatar_metadata_failed", "error", {
560
607
  avatar_id: characterId ?? "unknown",
561
608
  description: dataMessage || errorMessage,