@xpert-ai/chatkit-types 0.17.0 → 0.19.0

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 CHANGED
@@ -754,7 +754,8 @@ const DEFAULT_PET_SIZE = {
754
754
  height: petSpriteAtlas.cellHeight
755
755
  };
756
756
  function petLookFrame(dx, dy, deadZone = 12) {
757
- if (!Number.isFinite(dx) || !Number.isFinite(dy) || Math.hypot(dx, dy) <= deadZone) return null;
757
+ if (!Number.isFinite(dx) || !Number.isFinite(dy) || Math.hypot(dx, dy) <= deadZone)
758
+ return null;
758
759
  const index = (Math.round(Math.atan2(dx, -dy) / (Math.PI / 8)) + 16) % 16;
759
760
  return { row: 9 + Math.floor(index / 8), column: index % 8 };
760
761
  }
@@ -765,6 +766,14 @@ const DEFAULT_PET_BOUNDS_PADDING = {
765
766
  left: 0
766
767
  };
767
768
  const DEFAULT_PET_STORAGE_KEY = "chatkit:pet:position:v1";
769
+ function getPetAssetsBaseUrl(pet) {
770
+ return pet && typeof pet === "object" ? pet.assetsBaseUrl : void 0;
771
+ }
772
+ function getPetAssetUrl(id, assetsBaseUrl) {
773
+ const base = ((assetsBaseUrl == null ? void 0 : assetsBaseUrl.trim()) || "/pets").replace(/\/+$/, "");
774
+ const resourceId = id === "lando" ? "lando-2" : id;
775
+ return `${base}/${encodeURIComponent(resourceId)}/spritesheet.webp`;
776
+ }
768
777
  const DEFAULT_PET_SPRITESHEET_URL = "/pets/boba/spritesheet.webp";
769
778
  const DEFAULT_PET_CHARACTER = {
770
779
  type: "sprite-atlas",
@@ -811,12 +820,16 @@ function normalizeCharacter(character) {
811
820
  return DEFAULT_PET_CHARACTER;
812
821
  }
813
822
  function normalizePetOptions(pet) {
823
+ var _a;
814
824
  if (!pet) {
815
825
  return null;
816
826
  }
817
827
  if (pet === true) {
818
828
  return {
819
- character: DEFAULT_PET_CHARACTER,
829
+ character: {
830
+ ...DEFAULT_PET_CHARACTER,
831
+ src: getPetAssetUrl("boba")
832
+ },
820
833
  position: DEFAULT_POSITION,
821
834
  behavior: "auto",
822
835
  ariaLabel: "Animated pet",
@@ -827,7 +840,10 @@ function normalizePetOptions(pet) {
827
840
  return null;
828
841
  }
829
842
  return {
830
- character: normalizeCharacter(pet.character),
843
+ character: ((_a = pet.character) == null ? void 0 : _a.src) ? normalizeCharacter(pet.character) : {
844
+ ...DEFAULT_PET_CHARACTER,
845
+ src: getPetAssetUrl("boba", pet.assetsBaseUrl)
846
+ },
831
847
  position: {
832
848
  ...DEFAULT_POSITION,
833
849
  ...pet.position
@@ -1248,6 +1264,8 @@ exports.fileChangeRangeKey = fileChangeRangeKey;
1248
1264
  exports.getFileActivityContribution = getFileActivityContribution;
1249
1265
  exports.getLegacyFileActivityContribution = getLegacyFileActivityContribution;
1250
1266
  exports.getMessageSkillUsages = getMessageSkillUsages;
1267
+ exports.getPetAssetUrl = getPetAssetUrl;
1268
+ exports.getPetAssetsBaseUrl = getPetAssetsBaseUrl;
1251
1269
  exports.getPinnedPetPosition = getPinnedPetPosition;
1252
1270
  exports.isApprovalHostReference = isApprovalHostReference;
1253
1271
  exports.isCallEndedContent = isCallEndedContent;