@thefittingroom/shop-ui 4.3.4 → 4.3.6

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.js CHANGED
@@ -20531,15 +20531,6 @@ class FittingRoomAPI {
20531
20531
  throw error;
20532
20532
  }
20533
20533
  }
20534
- const copyOfCache = /* @__PURE__ */ new Map();
20535
- for (const sku of skus) {
20536
- const asset = this.cachedColorwaySizeAssets.get(sku);
20537
- if (asset) {
20538
- copyOfCache.set(sku, asset);
20539
- } else {
20540
- console.error(`no colorway asset found for SKU: ${sku}`);
20541
- }
20542
- }
20543
20534
  return this.cachedColorwaySizeAssets;
20544
20535
  }
20545
20536
  async GetStyleGarmentCategory(styleId) {
@@ -20607,6 +20598,10 @@ class FittingRoomAPI {
20607
20598
  const firestoreUser = data;
20608
20599
  const colorwaySizeAssetEntry = firestoreUser.vto?.[this.BrandID]?.[colorwaySizeAssetSKU];
20609
20600
  if (!colorwaySizeAssetEntry) {
20601
+ if (!skipFullSnapshot) {
20602
+ console.debug("no vto entry for full snapshot");
20603
+ throw NoFramesFoundError;
20604
+ }
20610
20605
  console.debug("no vto entry for SKU, continue watching:", colorwaySizeAssetSKU);
20611
20606
  return false;
20612
20607
  }
@@ -20634,7 +20629,7 @@ class FittingRoomAPI {
20634
20629
  const timeoutPromise = new Promise((_, reject) => {
20635
20630
  setTimeout(() => {
20636
20631
  reject(TimeoutError);
20637
- }, 3e5);
20632
+ }, 1e3 * 60 * 7);
20638
20633
  });
20639
20634
  let firestoreUser;
20640
20635
  try {
@@ -20656,6 +20651,8 @@ class FittingRoomAPI {
20656
20651
  console.error(`Frames not found on final user object for SKU: ${colorwaySizeAssetSKU}`, firestoreUser);
20657
20652
  throw NoFramesFoundError;
20658
20653
  }
20654
+ const timingMS = firestoreUser.vto?.[this.BrandID]?.[colorwaySizeAssetSKU]?.timing_ms;
20655
+ console.debug("vto timing", "colorway_size_asset", colorwaySizeAssetSKU, "timing_ms", timingMS);
20659
20656
  return frames;
20660
20657
  }
20661
20658
  async GetCachedOrRequestUserColorwaySizeAssetFrames(firestoreUserController, colorwaySizeAssetSKU, skipCache) {
@@ -20666,6 +20663,7 @@ class FittingRoomAPI {
20666
20663
  console.debug("returning cached frames", colorwaySizeAssetSKU);
20667
20664
  return await cached;
20668
20665
  }
20666
+ console.debug("no local cache for colorwaySizeAssetSKU", colorwaySizeAssetSKU);
20669
20667
  }
20670
20668
  const colorwaySizeAsset = this.cachedColorwaySizeAssets.get(colorwaySizeAssetSKU);
20671
20669
  if (!colorwaySizeAsset) {
@@ -20675,25 +20673,27 @@ class FittingRoomAPI {
20675
20673
  const colorwaySizeAssetID = colorwaySizeAsset.id;
20676
20674
  let framesPromise;
20677
20675
  try {
20678
- let skipFullSnapshot = false;
20679
- if (skipCache) {
20680
- console.debug("skipping cache, requesting fresh frames");
20681
- await this.requestColorwaySizeAssetFramesByID(colorwaySizeAssetID);
20682
- skipFullSnapshot = true;
20676
+ if (!skipCache) {
20677
+ framesPromise = this.watchForTryOnFrames(firestoreUserController, colorwaySizeAssetSKU, false);
20678
+ this.vtoFramesPromiseCache.set(colorwaySizeAssetSKU, framesPromise);
20679
+ return await framesPromise;
20683
20680
  }
20684
- framesPromise = this.watchForTryOnFrames(firestoreUserController, colorwaySizeAssetSKU, skipFullSnapshot);
20685
- await framesPromise;
20681
+ console.debug("no remote cache, requesting fresh frames", colorwaySizeAssetSKU);
20682
+ await this.requestColorwaySizeAssetFramesByID(colorwaySizeAssetID);
20683
+ framesPromise = this.watchForTryOnFrames(firestoreUserController, colorwaySizeAssetSKU, true);
20684
+ this.vtoFramesPromiseCache.set(colorwaySizeAssetSKU, framesPromise);
20685
+ return await framesPromise;
20686
20686
  } catch (error) {
20687
20687
  if (error != NoFramesFoundError) {
20688
20688
  throw error;
20689
20689
  }
20690
- console.debug(`No frames found for SKU: ${colorwaySizeAssetSKU}, attempting to request fresh frames`);
20690
+ console.debug(`catch: no frames found for SKU: ${colorwaySizeAssetSKU}, attempting to request fresh frames`);
20691
20691
  await this.requestColorwaySizeAssetFramesByID(colorwaySizeAssetID);
20692
- console.debug("waiting for new vto after refresh request");
20692
+ console.debug("catch: waiting for new vto after refresh request");
20693
20693
  framesPromise = this.watchForTryOnFrames(firestoreUserController, colorwaySizeAssetSKU, true);
20694
+ this.vtoFramesPromiseCache.set(colorwaySizeAssetSKU, framesPromise);
20695
+ return await framesPromise;
20694
20696
  }
20695
- this.vtoFramesPromiseCache.set(colorwaySizeAssetSKU, framesPromise);
20696
- return await framesPromise;
20697
20697
  }
20698
20698
  }
20699
20699
  const AvatarStatusNotCreated = "NOT_CREATED";
@@ -22047,6 +22047,7 @@ class FittingRoomController {
22047
22047
  this.cacheColorwaySizeAssetsPromise = this.API.FetchColorwaySizeAssetsFromStyleId(style.id);
22048
22048
  console.debug("is_published", this.style.is_published);
22049
22049
  if (!this.style.is_published) {
22050
+ console.warn("hiding unpublished style");
22050
22051
  this.SizeRecommendationController.Hide();
22051
22052
  }
22052
22053
  this.styleMeasurementLocations = this.styleToGarmentMeasurementLocations(this.style);
@@ -22169,6 +22170,7 @@ class FittingRoomController {
22169
22170
  }
22170
22171
  // callback for SizeRecommendationController
22171
22172
  async onTryOnCallback(selectedSizeID, availableSizeIDs, fromSizeRecSelect) {
22173
+ const startTime = performance.now();
22172
22174
  try {
22173
22175
  if (!this.selectedColorwaySizeAsset) {
22174
22176
  throw new Error("selectedColorwaySizeAsset is not set");
@@ -22177,7 +22179,8 @@ class FittingRoomController {
22177
22179
  await this.cacheColorwaySizeAssetsPromise;
22178
22180
  }
22179
22181
  this.SizeRecommendationController.SetVTOLoading(true);
22180
- console.log("tryOnCallback", selectedSizeID, availableSizeIDs);
22182
+ console.debug("tryOnCallback", selectedSizeID, availableSizeIDs, "sizeRecSelect");
22183
+ console.debug("forceFreshVTO", this.hasInitializedTryOn, this.noCacheOnRetry, fromSizeRecSelect);
22181
22184
  this.forceFreshVTO = !fromSizeRecSelect && this.hasInitializedTryOn && this.noCacheOnRetry;
22182
22185
  const allCachedAssets = this.API.GetCachedColorwaySizeAssets();
22183
22186
  const selectedAsset = allCachedAssets.find(
@@ -22201,6 +22204,8 @@ class FittingRoomController {
22201
22204
  this.vtoComponent.onNewFramesReady(batchResult);
22202
22205
  this.SizeRecommendationController.SetVTOLoading(false);
22203
22206
  this.hasInitializedTryOn = true;
22207
+ const endTime = performance.now();
22208
+ console.debug("tryOnCallback", "timing", endTime - startTime);
22204
22209
  } catch (e) {
22205
22210
  this.tfrModal.onError(L$1.SomethingWentWrong);
22206
22211
  console.log("calling HideVTOLoading after VTO error");
@@ -20535,15 +20535,6 @@ This typically indicates that your device does not have a healthy Internet conne
20535
20535
  throw error;
20536
20536
  }
20537
20537
  }
20538
- const copyOfCache = /* @__PURE__ */ new Map();
20539
- for (const sku of skus) {
20540
- const asset = this.cachedColorwaySizeAssets.get(sku);
20541
- if (asset) {
20542
- copyOfCache.set(sku, asset);
20543
- } else {
20544
- console.error(`no colorway asset found for SKU: ${sku}`);
20545
- }
20546
- }
20547
20538
  return this.cachedColorwaySizeAssets;
20548
20539
  }
20549
20540
  async GetStyleGarmentCategory(styleId) {
@@ -20611,6 +20602,10 @@ This typically indicates that your device does not have a healthy Internet conne
20611
20602
  const firestoreUser = data;
20612
20603
  const colorwaySizeAssetEntry = firestoreUser.vto?.[this.BrandID]?.[colorwaySizeAssetSKU];
20613
20604
  if (!colorwaySizeAssetEntry) {
20605
+ if (!skipFullSnapshot) {
20606
+ console.debug("no vto entry for full snapshot");
20607
+ throw NoFramesFoundError;
20608
+ }
20614
20609
  console.debug("no vto entry for SKU, continue watching:", colorwaySizeAssetSKU);
20615
20610
  return false;
20616
20611
  }
@@ -20638,7 +20633,7 @@ This typically indicates that your device does not have a healthy Internet conne
20638
20633
  const timeoutPromise = new Promise((_, reject) => {
20639
20634
  setTimeout(() => {
20640
20635
  reject(TimeoutError);
20641
- }, 3e5);
20636
+ }, 1e3 * 60 * 7);
20642
20637
  });
20643
20638
  let firestoreUser;
20644
20639
  try {
@@ -20660,6 +20655,8 @@ This typically indicates that your device does not have a healthy Internet conne
20660
20655
  console.error(`Frames not found on final user object for SKU: ${colorwaySizeAssetSKU}`, firestoreUser);
20661
20656
  throw NoFramesFoundError;
20662
20657
  }
20658
+ const timingMS = firestoreUser.vto?.[this.BrandID]?.[colorwaySizeAssetSKU]?.timing_ms;
20659
+ console.debug("vto timing", "colorway_size_asset", colorwaySizeAssetSKU, "timing_ms", timingMS);
20663
20660
  return frames;
20664
20661
  }
20665
20662
  async GetCachedOrRequestUserColorwaySizeAssetFrames(firestoreUserController, colorwaySizeAssetSKU, skipCache) {
@@ -20670,6 +20667,7 @@ This typically indicates that your device does not have a healthy Internet conne
20670
20667
  console.debug("returning cached frames", colorwaySizeAssetSKU);
20671
20668
  return await cached;
20672
20669
  }
20670
+ console.debug("no local cache for colorwaySizeAssetSKU", colorwaySizeAssetSKU);
20673
20671
  }
20674
20672
  const colorwaySizeAsset = this.cachedColorwaySizeAssets.get(colorwaySizeAssetSKU);
20675
20673
  if (!colorwaySizeAsset) {
@@ -20679,25 +20677,27 @@ This typically indicates that your device does not have a healthy Internet conne
20679
20677
  const colorwaySizeAssetID = colorwaySizeAsset.id;
20680
20678
  let framesPromise;
20681
20679
  try {
20682
- let skipFullSnapshot = false;
20683
- if (skipCache) {
20684
- console.debug("skipping cache, requesting fresh frames");
20685
- await this.requestColorwaySizeAssetFramesByID(colorwaySizeAssetID);
20686
- skipFullSnapshot = true;
20680
+ if (!skipCache) {
20681
+ framesPromise = this.watchForTryOnFrames(firestoreUserController, colorwaySizeAssetSKU, false);
20682
+ this.vtoFramesPromiseCache.set(colorwaySizeAssetSKU, framesPromise);
20683
+ return await framesPromise;
20687
20684
  }
20688
- framesPromise = this.watchForTryOnFrames(firestoreUserController, colorwaySizeAssetSKU, skipFullSnapshot);
20689
- await framesPromise;
20685
+ console.debug("no remote cache, requesting fresh frames", colorwaySizeAssetSKU);
20686
+ await this.requestColorwaySizeAssetFramesByID(colorwaySizeAssetID);
20687
+ framesPromise = this.watchForTryOnFrames(firestoreUserController, colorwaySizeAssetSKU, true);
20688
+ this.vtoFramesPromiseCache.set(colorwaySizeAssetSKU, framesPromise);
20689
+ return await framesPromise;
20690
20690
  } catch (error) {
20691
20691
  if (error != NoFramesFoundError) {
20692
20692
  throw error;
20693
20693
  }
20694
- console.debug(`No frames found for SKU: ${colorwaySizeAssetSKU}, attempting to request fresh frames`);
20694
+ console.debug(`catch: no frames found for SKU: ${colorwaySizeAssetSKU}, attempting to request fresh frames`);
20695
20695
  await this.requestColorwaySizeAssetFramesByID(colorwaySizeAssetID);
20696
- console.debug("waiting for new vto after refresh request");
20696
+ console.debug("catch: waiting for new vto after refresh request");
20697
20697
  framesPromise = this.watchForTryOnFrames(firestoreUserController, colorwaySizeAssetSKU, true);
20698
+ this.vtoFramesPromiseCache.set(colorwaySizeAssetSKU, framesPromise);
20699
+ return await framesPromise;
20698
20700
  }
20699
- this.vtoFramesPromiseCache.set(colorwaySizeAssetSKU, framesPromise);
20700
- return await framesPromise;
20701
20701
  }
20702
20702
  }
20703
20703
  const AvatarStatusNotCreated = "NOT_CREATED";
@@ -22051,6 +22051,7 @@ This typically indicates that your device does not have a healthy Internet conne
22051
22051
  this.cacheColorwaySizeAssetsPromise = this.API.FetchColorwaySizeAssetsFromStyleId(style.id);
22052
22052
  console.debug("is_published", this.style.is_published);
22053
22053
  if (!this.style.is_published) {
22054
+ console.warn("hiding unpublished style");
22054
22055
  this.SizeRecommendationController.Hide();
22055
22056
  }
22056
22057
  this.styleMeasurementLocations = this.styleToGarmentMeasurementLocations(this.style);
@@ -22173,6 +22174,7 @@ This typically indicates that your device does not have a healthy Internet conne
22173
22174
  }
22174
22175
  // callback for SizeRecommendationController
22175
22176
  async onTryOnCallback(selectedSizeID, availableSizeIDs, fromSizeRecSelect) {
22177
+ const startTime = performance.now();
22176
22178
  try {
22177
22179
  if (!this.selectedColorwaySizeAsset) {
22178
22180
  throw new Error("selectedColorwaySizeAsset is not set");
@@ -22181,7 +22183,8 @@ This typically indicates that your device does not have a healthy Internet conne
22181
22183
  await this.cacheColorwaySizeAssetsPromise;
22182
22184
  }
22183
22185
  this.SizeRecommendationController.SetVTOLoading(true);
22184
- console.log("tryOnCallback", selectedSizeID, availableSizeIDs);
22186
+ console.debug("tryOnCallback", selectedSizeID, availableSizeIDs, "sizeRecSelect");
22187
+ console.debug("forceFreshVTO", this.hasInitializedTryOn, this.noCacheOnRetry, fromSizeRecSelect);
22185
22188
  this.forceFreshVTO = !fromSizeRecSelect && this.hasInitializedTryOn && this.noCacheOnRetry;
22186
22189
  const allCachedAssets = this.API.GetCachedColorwaySizeAssets();
22187
22190
  const selectedAsset = allCachedAssets.find(
@@ -22205,6 +22208,8 @@ This typically indicates that your device does not have a healthy Internet conne
22205
22208
  this.vtoComponent.onNewFramesReady(batchResult);
22206
22209
  this.SizeRecommendationController.SetVTOLoading(false);
22207
22210
  this.hasInitializedTryOn = true;
22211
+ const endTime = performance.now();
22212
+ console.debug("tryOnCallback", "timing", endTime - startTime);
22208
22213
  } catch (e) {
22209
22214
  this.tfrModal.onError(L$1.SomethingWentWrong);
22210
22215
  console.log("calling HideVTOLoading after VTO error");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thefittingroom/shop-ui",
3
- "version": "4.3.4",
3
+ "version": "4.3.6",
4
4
  "description": "the fitting room UI library",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",