@depict-ai/ui 4.8.7 → 4.8.9

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/ES10/index.cjs CHANGED
@@ -114,7 +114,7 @@ $parcel$export(module.exports, "BreadCrumbs", () => $335c02c1241a9ca8$export$5b7
114
114
  $parcel$export(module.exports, "QuickLinks", () => $335c02c1241a9ca8$export$de035477d6fef996);
115
115
  $parcel$export(module.exports, "CategoryPage", () => $c10e33c4681f8c9b$export$e2bf8ce7779e827e);
116
116
  /*! Depict.ai search and product listing SDK */
117
- const $aa1938dec50d6c12$export$83d89fbfd8236492 = "4.8.7";
117
+ const $aa1938dec50d6c12$export$83d89fbfd8236492 = "4.8.9";
118
118
  function $054b1113e4897051$export$54c6d6ff54e72743(whatToWatch) {
119
119
  const [width, setWidth] = $52FdA$solidjs.createSignal(0);
120
120
  const [height, setHeight] = $52FdA$solidjs.createSignal(0);
@@ -10752,11 +10752,13 @@ class $e270e9f953fcbc58$export$e015ed2f2950f2e3 {
10752
10752
  let {
10753
10753
  id_to_query_for_: id_to_query_for_,
10754
10754
  id_type_: id_type_,
10755
+ currentListingForTransformer_: currentListingForTransformer_,
10755
10756
  ...input_req_
10756
10757
  } = _ref2;
10757
10758
  return await $e270e9f953fcbc58$var$_classPrivateMethodGet(this, $e270e9f953fcbc58$var$_cached_request, $e270e9f953fcbc58$var$_cached_request2).call(this, {
10758
10759
  endpoint_: $e270e9f953fcbc58$var$v3_base_url + "listings/" + (id_type_ === $c3739e86187f2054$export$5aae649db1b959fc ? "external_id/" : "") + encodeURIComponent(id_to_query_for_) + "/products",
10759
10760
  input_req_: input_req_,
10761
+ currentListingForTransformer_: currentListingForTransformer_,
10760
10762
  fallback_response_: () => ({
10761
10763
  "n_hits": 0,
10762
10764
  "displays": [],
@@ -10841,7 +10843,7 @@ async function $e270e9f953fcbc58$var$_run_url_creator_for_suggest2(merchant, mar
10841
10843
  response.suggestions = transformedSuggestions;
10842
10844
  return response;
10843
10845
  }
10844
- async function $e270e9f953fcbc58$var$_run_display_transformers_for_rest2(merchant, market, locale, input_data) {
10846
+ async function $e270e9f953fcbc58$var$_run_display_transformers_for_rest2(merchant, market, locale, input_data, currentListingForTransformer) {
10845
10847
  const {
10846
10848
  display_transformers: display_transformers
10847
10849
  } = this;
@@ -10857,7 +10859,8 @@ async function $e270e9f953fcbc58$var$_run_display_transformers_for_rest2(merchan
10857
10859
  merchant: merchant,
10858
10860
  market: market,
10859
10861
  locale: locale,
10860
- displays: [...displays]
10862
+ displays: [...displays],
10863
+ currentListing: currentListingForTransformer
10861
10864
  });
10862
10865
  input_data.displays = transformed_displays;
10863
10866
  }
@@ -10882,7 +10885,8 @@ async function $e270e9f953fcbc58$var$_cached_request2(_ref4) {
10882
10885
  endpoint_: endpoint_,
10883
10886
  input_req_: input_req_,
10884
10887
  fallback_response_: fallback_response_,
10885
- method_ = "POST"
10888
+ method_ = "POST",
10889
+ currentListingForTransformer_: currentListingForTransformer_
10886
10890
  } = _ref4;
10887
10891
  const cache_obj = $e270e9f953fcbc58$var$_classPrivateMethodGet(this, $e270e9f953fcbc58$var$_get_cache_obj_for_endpoint, $e270e9f953fcbc58$var$_get_cache_obj_for_endpoint2).call(this, endpoint_);
10888
10892
  const with_ids = $parcel$interopDefault($52FdA$babelruntimehelpersclassPrivateFieldGet)(this, $e270e9f953fcbc58$var$_add_ids_to_request).call(this, input_req_);
@@ -10912,7 +10916,7 @@ async function $e270e9f953fcbc58$var$_cached_request2(_ref4) {
10912
10916
  let result;
10913
10917
  try {
10914
10918
  const unmodified_result = await api_response.json();
10915
- result = await $e270e9f953fcbc58$var$_classPrivateMethodGet(this, $e270e9f953fcbc58$var$_run_display_transformers_for_rest, $e270e9f953fcbc58$var$_run_display_transformers_for_rest2).call(this, input_req_.merchant, input_req_.market, input_req_.locale, unmodified_result);
10919
+ result = await $e270e9f953fcbc58$var$_classPrivateMethodGet(this, $e270e9f953fcbc58$var$_run_display_transformers_for_rest, $e270e9f953fcbc58$var$_run_display_transformers_for_rest2).call(this, input_req_.merchant, input_req_.market, input_req_.locale, unmodified_result, currentListingForTransformer_);
10916
10920
  } catch (e) {
10917
10921
  $52FdA$depictaiutilishared.dwarn("displayTransformer or json decoding failed", e);
10918
10922
  break return_successfully;
@@ -16045,8 +16049,14 @@ function $c19709057a32b2e7$export$780a853d15174484(_ref) {
16045
16049
  mediaUrl_: mediaUrl_,
16046
16050
  aspectRatioWhenAloneInRow_: aspectRatioWhenAloneInRow_
16047
16051
  } = _ref;
16052
+ let wroteAspectRatioToContainer = false; // Only write this once so we don't get into a aspect ratio changed -> size changed -> image source changed -> aspect ratio slightly changed infinite loop
16048
16053
  const [wrapperSize, setWrapperSize] = $52FdA$solidjs.createSignal();
16049
16054
  const isImage = type_ === "image";
16055
+ const setAspectRatio = aspectRatio => {
16056
+ if (wroteAspectRatioToContainer) return;
16057
+ wroteAspectRatioToContainer = true;
16058
+ setAspectRatioWas_(aspectRatio);
16059
+ };
16050
16060
  return $52FdA$solidjsweb.createComponent((0, $52FdA$solidjsweb.Dynamic), $52FdA$solidjsweb.mergeProps({
16051
16061
  component: link_ ? "a" : "div",
16052
16062
  "class": "d-standard-content-wrapper",
@@ -16081,7 +16091,7 @@ function $c19709057a32b2e7$export$780a853d15174484(_ref) {
16081
16091
  },
16082
16092
  src: mediaUrl_,
16083
16093
  "class": "d-standard-content",
16084
- ref: el => el.addEventListener("load", $52FdA$depictaiutilisharedlatest.catchify(() => setAspectRatioWas_(el.naturalWidth / el.naturalHeight)))
16094
+ ref: el => el.addEventListener("load", $52FdA$depictaiutilisharedlatest.catchify(() => setAspectRatio(el.naturalWidth / el.naturalHeight)))
16085
16095
  });
16086
16096
  }
16087
16097
  }), $52FdA$solidjsweb.createComponent((0, $52FdA$solidjs.Match), {
@@ -16090,7 +16100,7 @@ function $c19709057a32b2e7$export$780a853d15174484(_ref) {
16090
16100
  var _el$ = $52FdA$solidjsweb.getNextElement($c19709057a32b2e7$var$_tmpl$);
16091
16101
  $52FdA$solidjsweb.use(element => {
16092
16102
  const pageVisible = $e7a7d2fe8a8217d8$export$54299a3c81f5425();
16093
- element.addEventListener("loadedmetadata", $52FdA$depictaiutilisharedlatest.catchify(() => setAspectRatioWas_(element.videoWidth / element.videoHeight)));
16103
+ element.addEventListener("loadedmetadata", $52FdA$depictaiutilisharedlatest.catchify(() => setAspectRatio(element.videoWidth / element.videoHeight)));
16094
16104
  $52FdA$solidjs.createEffect(() => {
16095
16105
  if (pageVisible()) element.play().catch(e => $52FdA$depictaiutilishared.dlog("Failed to play", e));else element.pause();
16096
16106
  });
@@ -16158,7 +16168,7 @@ function $0c035bbe7e30b438$export$7a92d995f1bf3592(history_content_blocks_, plp_
16158
16168
  ...prev,
16159
16169
  aspectRatios: {
16160
16170
  ...prev.aspectRatios,
16161
- [componentCacheKey]: Math.round(aspectRatio * 10) / 10
16171
+ [componentCacheKey]: Math.round(aspectRatio * 100) / 100
16162
16172
  }
16163
16173
  }))
16164
16174
  });
@@ -16231,6 +16241,10 @@ function $ede6c70ecdca46fe$export$f7d2f673fc2f091d(_ref) {
16231
16241
  const all_products_loaded_ = $52FdA$solidjs.createSignal(false);
16232
16242
  const [currentlyLoadedDisplays, setCurrentlyLoadedDisplays_] = $52FdA$solidjs.createSignal(0);
16233
16243
  const [can_write_scroll_restoration_, set_can_write_scroll_restoration] = $52FdA$solidjs.createSignal(false);
16244
+ const owner = $52FdA$solidjs.getOwner();
16245
+ const [metaRequestsForQuery, setMetaRequestsForQuery] = $52FdA$solidjs.createSignal(new Map(), {
16246
+ equals: false
16247
+ });
16234
16248
  const products_query_base_ = $e4bc31358c414b18$export$210f130a61ac1e8d(() => {
16235
16249
  const sort_obj = get_sorting() && {
16236
16250
  ...get_sorting()
@@ -16263,7 +16277,20 @@ function $ede6c70ecdca46fe$export$f7d2f673fc2f091d(_ref) {
16263
16277
  limit: limit,
16264
16278
  ...(cursor ? {
16265
16279
  cursor: cursor
16266
- } : {})
16280
+ } : {}),
16281
+ // This gets exposed to the products display transformer and gives it information about the listing the products are in
16282
+ // It's very hard to implement tracking that uses the collection title without this information
16283
+ currentListingForTransformer_: new Promise(resolve => $52FdA$solidjs.createRoot(dispose => {
16284
+ $52FdA$solidjs.createEffect($52FdA$depictaiutilisharedlatest.catchify(() => {
16285
+ const key = base_query.id_type_ + base_query.id_to_query_for_;
16286
+ const metaResponsePromise = metaRequestsForQuery().get(key);
16287
+ if (!metaResponsePromise) return;
16288
+ resolve(metaResponsePromise);
16289
+ dispose();
16290
+ setMetaRequestsForQuery(prev => (prev.delete(key), prev));
16291
+ }));
16292
+ $52FdA$solidjs.runWithOwner(owner, () => $52FdA$solidjs.onCleanup(dispose));
16293
+ }))
16267
16294
  })
16268
16295
  })));
16269
16296
  const meta_query_base = $e4bc31358c414b18$export$210f130a61ac1e8d(() => ({
@@ -16274,7 +16301,17 @@ function $ede6c70ecdca46fe$export$f7d2f673fc2f091d(_ref) {
16274
16301
  id_type_: id_type_()
16275
16302
  }));
16276
16303
  // Make "Get Listing" request to get quicklinks, breadcrumbs, title, etc
16277
- const [plp_meta] = $52FdA$solidjs.createResource(meta_query_base, $52FdA$depictaiutilisharedlatest.catchify(query => depict_api_.get_listing(query)));
16304
+ const [plp_meta] = $52FdA$solidjs.createResource(meta_query_base, $52FdA$depictaiutilisharedlatest.catchify(async query => {
16305
+ const result = await depict_api_.get_listing(query);
16306
+ // In the following two lines, do not expose the finished breadcrumbs and quicklinks in the products display transformer since it's already exposed in the categories display transformer
16307
+ const {
16308
+ breadcrumbs: breadcrumbs,
16309
+ quick_links: quick_links,
16310
+ ...listing
16311
+ } = result;
16312
+ setMetaRequestsForQuery(prev => prev.set(query.id_type_ + query.id_to_query_for_, listing));
16313
+ return result;
16314
+ }));
16278
16315
  const contentBlocksByRow = $0c035bbe7e30b438$export$7a92d995f1bf3592(history_content_blocks_, plp_meta, content_blocks_by_row_, router_);
16279
16316
  const countOfProductsForUI = $e335e2ff536c1a0b$export$a86bc18439445599(plp_products_, all_products_loaded_, currentlyLoadedDisplays);
16280
16317
  const available_sortings_ = $52FdA$solidjs.createMemo(() => {
package/ES10/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Accessor, JSX, Setter, Signal } from "solid-js";
2
2
  import { Display, ModernDisplay, report, Amazing_Slider, useExpandingContainer, ColsAtSize, Elem, Node_Array } from "@depict-ai/utilishared/ES10";
3
3
  import { ContentLink, SearchResponse, SearchFilter as _SearchFilter1 } from "@depict-ai/types/api/SearchResponse";
4
- import { Ancestors, ListingSuggestion, SearchSuggestionsResponseV3 } from "@depict-ai/types/api/SearchSuggestionsResponseV3";
4
+ import { Ancestors, ListingSuggestion, SearchSuggestionsResponseV3, ProductListing as _ProductListing1 } from "@depict-ai/types/api/SearchSuggestionsResponseV3";
5
5
  import { ProductListing, GetListingResponse, ContentBlock as _ContentBlock1 } from "@depict-ai/types/api/GetListingResponse";
6
6
  import { SearchFilter, SearchRequestV3, SortModel } from "@depict-ai/types/api/SearchRequestV3";
7
7
  import { ProductListingResponseV3, SearchFilter as _SearchFilter2 } from "@depict-ai/types/api/ProductListingResponseV3";
@@ -11,7 +11,7 @@ import { GetListingRequest } from "@depict-ai/types/api/GetListingRequest";
11
11
  import { BaseSearchRequestV3 } from "@depict-ai/types/api/BaseSearchRequestV3";
12
12
  import { FeaturedInDisplay } from "@depict-ai/types/api/FeaturedInResponseV3";
13
13
  import { SearchFilter as _SearchFilter3 } from "@depict-ai/types/api/SearchRequestV2";
14
- export const version = "4.8.7";
14
+ export const version = "4.8.9";
15
15
  /**
16
16
  * Returns two accessors (one width and one height) that will update when the size of the provided element changes, to be used with ResponsiveImg
17
17
  */
@@ -46,6 +46,10 @@ type ListingSuggestionForTransformer = (ListingSuggestion & {
46
46
  export type DisplayTransformers<InputDisplay extends ModernDisplay, OutputDisplay extends ModernDisplay | never> = {
47
47
  products?: (options: DisplayTransformerAlwaysThereData & {
48
48
  displays: InputDisplay[];
49
+ /**
50
+ * If the category display transformer was called due to navigating to a listing using a <CategoryPage> component, currentListing will be set and contain a promise that can be used to get information of said listing.
51
+ */
52
+ currentListing?: Promise<ProductListing>;
49
53
  }) => CanBePromiseWrapped<OutputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<OutputDisplay>[] : never>;
50
54
  categories?: <T extends ProductListingWithAncestors | ListingSuggestionForTransformer>(options: DisplayTransformerAlwaysThereData & {
51
55
  data: T[];
@@ -551,10 +555,12 @@ export class DepictAPI<InputDisplay extends Display, OutputDisplay extends Moder
551
555
  get_listing_products({
552
556
  id_to_query_for_,
553
557
  id_type_,
558
+ currentListingForTransformer_,
554
559
  ...input_req_
555
560
  }: ProductListingRequestV3 & {
556
561
  id_to_query_for_: string;
557
562
  id_type_: typeof LISTING_ID | typeof EXTERNAL_ID;
563
+ currentListingForTransformer_: Promise<_ProductListing1>;
558
564
  }): Promise<ProductListingResponseAfterDisplayTransformer & {
559
565
  failed?: true;
560
566
  }>;
package/ES10/index.js CHANGED
@@ -10,7 +10,7 @@ import $8tj43$babelruntimehelpersclassPrivateFieldGet from "@babel/runtime/helpe
10
10
  /*! Depict.ai search and product listing SDK */
11
11
  import { register_es_version } from "../multi_import_deduplicator.mjs";
12
12
  register_es_version("ui", "ES10");
13
- const $8db9a15135765c11$export$83d89fbfd8236492 = "4.8.7";
13
+ const $8db9a15135765c11$export$83d89fbfd8236492 = "4.8.9";
14
14
  function $4be619ec2cd7bba3$export$54c6d6ff54e72743(whatToWatch) {
15
15
  const [width, setWidth] = $8tj43$createSignal(0);
16
16
  const [height, setHeight] = $8tj43$createSignal(0);
@@ -10648,11 +10648,13 @@ class $284849364a6ef73a$export$e015ed2f2950f2e3 {
10648
10648
  let {
10649
10649
  id_to_query_for_: id_to_query_for_,
10650
10650
  id_type_: id_type_,
10651
+ currentListingForTransformer_: currentListingForTransformer_,
10651
10652
  ...input_req_
10652
10653
  } = _ref2;
10653
10654
  return await $284849364a6ef73a$var$_classPrivateMethodGet(this, $284849364a6ef73a$var$_cached_request, $284849364a6ef73a$var$_cached_request2).call(this, {
10654
10655
  endpoint_: $284849364a6ef73a$var$v3_base_url + "listings/" + (id_type_ === $397620a4d7958ed1$export$5aae649db1b959fc ? "external_id/" : "") + encodeURIComponent(id_to_query_for_) + "/products",
10655
10656
  input_req_: input_req_,
10657
+ currentListingForTransformer_: currentListingForTransformer_,
10656
10658
  fallback_response_: () => ({
10657
10659
  "n_hits": 0,
10658
10660
  "displays": [],
@@ -10737,7 +10739,7 @@ async function $284849364a6ef73a$var$_run_url_creator_for_suggest2(merchant, mar
10737
10739
  response.suggestions = transformedSuggestions;
10738
10740
  return response;
10739
10741
  }
10740
- async function $284849364a6ef73a$var$_run_display_transformers_for_rest2(merchant, market, locale, input_data) {
10742
+ async function $284849364a6ef73a$var$_run_display_transformers_for_rest2(merchant, market, locale, input_data, currentListingForTransformer) {
10741
10743
  const {
10742
10744
  display_transformers: display_transformers
10743
10745
  } = this;
@@ -10753,7 +10755,8 @@ async function $284849364a6ef73a$var$_run_display_transformers_for_rest2(merchan
10753
10755
  merchant: merchant,
10754
10756
  market: market,
10755
10757
  locale: locale,
10756
- displays: [...displays]
10758
+ displays: [...displays],
10759
+ currentListing: currentListingForTransformer
10757
10760
  });
10758
10761
  input_data.displays = transformed_displays;
10759
10762
  }
@@ -10778,7 +10781,8 @@ async function $284849364a6ef73a$var$_cached_request2(_ref4) {
10778
10781
  endpoint_: endpoint_,
10779
10782
  input_req_: input_req_,
10780
10783
  fallback_response_: fallback_response_,
10781
- method_ = "POST"
10784
+ method_ = "POST",
10785
+ currentListingForTransformer_: currentListingForTransformer_
10782
10786
  } = _ref4;
10783
10787
  const cache_obj = $284849364a6ef73a$var$_classPrivateMethodGet(this, $284849364a6ef73a$var$_get_cache_obj_for_endpoint, $284849364a6ef73a$var$_get_cache_obj_for_endpoint2).call(this, endpoint_);
10784
10788
  const with_ids = $8tj43$babelruntimehelpersclassPrivateFieldGet(this, $284849364a6ef73a$var$_add_ids_to_request).call(this, input_req_);
@@ -10808,7 +10812,7 @@ async function $284849364a6ef73a$var$_cached_request2(_ref4) {
10808
10812
  let result;
10809
10813
  try {
10810
10814
  const unmodified_result = await api_response.json();
10811
- result = await $284849364a6ef73a$var$_classPrivateMethodGet(this, $284849364a6ef73a$var$_run_display_transformers_for_rest, $284849364a6ef73a$var$_run_display_transformers_for_rest2).call(this, input_req_.merchant, input_req_.market, input_req_.locale, unmodified_result);
10815
+ result = await $284849364a6ef73a$var$_classPrivateMethodGet(this, $284849364a6ef73a$var$_run_display_transformers_for_rest, $284849364a6ef73a$var$_run_display_transformers_for_rest2).call(this, input_req_.merchant, input_req_.market, input_req_.locale, unmodified_result, currentListingForTransformer_);
10812
10816
  } catch (e) {
10813
10817
  $8tj43$dwarn("displayTransformer or json decoding failed", e);
10814
10818
  break return_successfully;
@@ -15941,8 +15945,14 @@ function $3b772ef9a35560fe$export$780a853d15174484(_ref) {
15941
15945
  mediaUrl_: mediaUrl_,
15942
15946
  aspectRatioWhenAloneInRow_: aspectRatioWhenAloneInRow_
15943
15947
  } = _ref;
15948
+ let wroteAspectRatioToContainer = false; // Only write this once so we don't get into a aspect ratio changed -> size changed -> image source changed -> aspect ratio slightly changed infinite loop
15944
15949
  const [wrapperSize, setWrapperSize] = $8tj43$createSignal();
15945
15950
  const isImage = type_ === "image";
15951
+ const setAspectRatio = aspectRatio => {
15952
+ if (wroteAspectRatioToContainer) return;
15953
+ wroteAspectRatioToContainer = true;
15954
+ setAspectRatioWas_(aspectRatio);
15955
+ };
15946
15956
  return $8tj43$createComponent((0, $8tj43$Dynamic), $8tj43$mergeProps({
15947
15957
  component: link_ ? "a" : "div",
15948
15958
  "class": "d-standard-content-wrapper",
@@ -15977,7 +15987,7 @@ function $3b772ef9a35560fe$export$780a853d15174484(_ref) {
15977
15987
  },
15978
15988
  src: mediaUrl_,
15979
15989
  "class": "d-standard-content",
15980
- ref: el => el.addEventListener("load", $8tj43$catchify1(() => setAspectRatioWas_(el.naturalWidth / el.naturalHeight)))
15990
+ ref: el => el.addEventListener("load", $8tj43$catchify1(() => setAspectRatio(el.naturalWidth / el.naturalHeight)))
15981
15991
  });
15982
15992
  }
15983
15993
  }), $8tj43$createComponent((0, $8tj43$Match), {
@@ -15986,7 +15996,7 @@ function $3b772ef9a35560fe$export$780a853d15174484(_ref) {
15986
15996
  var _el$ = $8tj43$getNextElement($3b772ef9a35560fe$var$_tmpl$);
15987
15997
  $8tj43$use(element => {
15988
15998
  const pageVisible = $a35e6f680c5bbc60$export$54299a3c81f5425();
15989
- element.addEventListener("loadedmetadata", $8tj43$catchify1(() => setAspectRatioWas_(element.videoWidth / element.videoHeight)));
15999
+ element.addEventListener("loadedmetadata", $8tj43$catchify1(() => setAspectRatio(element.videoWidth / element.videoHeight)));
15990
16000
  $8tj43$createEffect(() => {
15991
16001
  if (pageVisible()) element.play().catch(e => $8tj43$dlog1("Failed to play", e));else element.pause();
15992
16002
  });
@@ -16054,7 +16064,7 @@ function $12ff24fdc4b26d88$export$7a92d995f1bf3592(history_content_blocks_, plp_
16054
16064
  ...prev,
16055
16065
  aspectRatios: {
16056
16066
  ...prev.aspectRatios,
16057
- [componentCacheKey]: Math.round(aspectRatio * 10) / 10
16067
+ [componentCacheKey]: Math.round(aspectRatio * 100) / 100
16058
16068
  }
16059
16069
  }))
16060
16070
  });
@@ -16127,6 +16137,10 @@ function $4b4b262708b516ee$export$f7d2f673fc2f091d(_ref) {
16127
16137
  const all_products_loaded_ = $8tj43$createSignal(false);
16128
16138
  const [currentlyLoadedDisplays, setCurrentlyLoadedDisplays_] = $8tj43$createSignal(0);
16129
16139
  const [can_write_scroll_restoration_, set_can_write_scroll_restoration] = $8tj43$createSignal(false);
16140
+ const owner = $8tj43$getOwner();
16141
+ const [metaRequestsForQuery, setMetaRequestsForQuery] = $8tj43$createSignal(new Map(), {
16142
+ equals: false
16143
+ });
16130
16144
  const products_query_base_ = $ec225bf1f1627ea8$export$210f130a61ac1e8d(() => {
16131
16145
  const sort_obj = get_sorting() && {
16132
16146
  ...get_sorting()
@@ -16159,7 +16173,20 @@ function $4b4b262708b516ee$export$f7d2f673fc2f091d(_ref) {
16159
16173
  limit: limit,
16160
16174
  ...(cursor ? {
16161
16175
  cursor: cursor
16162
- } : {})
16176
+ } : {}),
16177
+ // This gets exposed to the products display transformer and gives it information about the listing the products are in
16178
+ // It's very hard to implement tracking that uses the collection title without this information
16179
+ currentListingForTransformer_: new Promise(resolve => $8tj43$createRoot(dispose => {
16180
+ $8tj43$createEffect($8tj43$catchify1(() => {
16181
+ const key = base_query.id_type_ + base_query.id_to_query_for_;
16182
+ const metaResponsePromise = metaRequestsForQuery().get(key);
16183
+ if (!metaResponsePromise) return;
16184
+ resolve(metaResponsePromise);
16185
+ dispose();
16186
+ setMetaRequestsForQuery(prev => (prev.delete(key), prev));
16187
+ }));
16188
+ $8tj43$runWithOwner(owner, () => $8tj43$onCleanup(dispose));
16189
+ }))
16163
16190
  })
16164
16191
  })));
16165
16192
  const meta_query_base = $ec225bf1f1627ea8$export$210f130a61ac1e8d(() => ({
@@ -16170,7 +16197,17 @@ function $4b4b262708b516ee$export$f7d2f673fc2f091d(_ref) {
16170
16197
  id_type_: id_type_()
16171
16198
  }));
16172
16199
  // Make "Get Listing" request to get quicklinks, breadcrumbs, title, etc
16173
- const [plp_meta] = $8tj43$createResource(meta_query_base, $8tj43$catchify1(query => depict_api_.get_listing(query)));
16200
+ const [plp_meta] = $8tj43$createResource(meta_query_base, $8tj43$catchify1(async query => {
16201
+ const result = await depict_api_.get_listing(query);
16202
+ // In the following two lines, do not expose the finished breadcrumbs and quicklinks in the products display transformer since it's already exposed in the categories display transformer
16203
+ const {
16204
+ breadcrumbs: breadcrumbs,
16205
+ quick_links: quick_links,
16206
+ ...listing
16207
+ } = result;
16208
+ setMetaRequestsForQuery(prev => prev.set(query.id_type_ + query.id_to_query_for_, listing));
16209
+ return result;
16210
+ }));
16174
16211
  const contentBlocksByRow = $12ff24fdc4b26d88$export$7a92d995f1bf3592(history_content_blocks_, plp_meta, content_blocks_by_row_, router_);
16175
16212
  const countOfProductsForUI = $0728458b46ee9d32$export$a86bc18439445599(plp_products_, all_products_loaded_, currentlyLoadedDisplays);
16176
16213
  const available_sortings_ = $8tj43$createMemo(() => {
package/latest/index.cjs CHANGED
@@ -108,7 +108,7 @@ $parcel$export(module.exports, "BreadCrumbs", () => $1f4925833f07df29$export$5b7
108
108
  $parcel$export(module.exports, "QuickLinks", () => $1f4925833f07df29$export$de035477d6fef996);
109
109
  $parcel$export(module.exports, "CategoryPage", () => $14f289047713d67a$export$e2bf8ce7779e827e);
110
110
  /*! Depict.ai search and product listing SDK */
111
- const $b757f75811f3261f$export$83d89fbfd8236492 = "4.8.7";
111
+ const $b757f75811f3261f$export$83d89fbfd8236492 = "4.8.9";
112
112
  function $128302ab61dab8f1$export$54c6d6ff54e72743(whatToWatch) {
113
113
  const [width, setWidth] = $gVhhF$solidjs.createSignal(0);
114
114
  const [height, setHeight] = $gVhhF$solidjs.createSignal(0);
@@ -10147,7 +10147,7 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
10147
10147
  /**
10148
10148
  * rest = everything except query suggestions
10149
10149
  */
10150
- async #run_display_transformers_for_rest(merchant, market, locale, input_data) {
10150
+ async #run_display_transformers_for_rest(merchant, market, locale, input_data, currentListingForTransformer) {
10151
10151
  const {
10152
10152
  display_transformers: display_transformers
10153
10153
  } = this;
@@ -10163,7 +10163,8 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
10163
10163
  merchant: merchant,
10164
10164
  market: market,
10165
10165
  locale: locale,
10166
- displays: [...displays]
10166
+ displays: [...displays],
10167
+ currentListing: currentListingForTransformer
10167
10168
  });
10168
10169
  input_data.displays = transformed_displays;
10169
10170
  }
@@ -10186,7 +10187,8 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
10186
10187
  endpoint_: endpoint_,
10187
10188
  input_req_: input_req_,
10188
10189
  fallback_response_: fallback_response_,
10189
- method_ = "POST"
10190
+ method_ = "POST",
10191
+ currentListingForTransformer_: currentListingForTransformer_
10190
10192
  }) {
10191
10193
  const cache_obj = this.#get_cache_obj_for_endpoint(endpoint_);
10192
10194
  const with_ids = this.#add_ids_to_request(input_req_);
@@ -10216,7 +10218,7 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
10216
10218
  let result;
10217
10219
  try {
10218
10220
  const unmodified_result = await api_response.json();
10219
- result = await this.#run_display_transformers_for_rest(input_req_.merchant, input_req_.market, input_req_.locale, unmodified_result);
10221
+ result = await this.#run_display_transformers_for_rest(input_req_.merchant, input_req_.market, input_req_.locale, unmodified_result, currentListingForTransformer_);
10220
10222
  } catch (e) {
10221
10223
  $gVhhF$depictaiutilishared.dwarn("displayTransformer or json decoding failed", e);
10222
10224
  break return_successfully;
@@ -10318,11 +10320,13 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
10318
10320
  async get_listing_products({
10319
10321
  id_to_query_for_: id_to_query_for_,
10320
10322
  id_type_: id_type_,
10323
+ currentListingForTransformer_: currentListingForTransformer_,
10321
10324
  ...input_req_
10322
10325
  }) {
10323
10326
  return await this.#cached_request({
10324
10327
  endpoint_: $e1d6c0f3d89d531c$var$v3_base_url + "listings/" + (id_type_ === $779741d0f266ea8c$export$5aae649db1b959fc ? "external_id/" : "") + encodeURIComponent(id_to_query_for_) + "/products",
10325
10328
  input_req_: input_req_,
10329
+ currentListingForTransformer_: currentListingForTransformer_,
10326
10330
  fallback_response_: () => ({
10327
10331
  "n_hits": 0,
10328
10332
  "displays": [],
@@ -14998,8 +15002,14 @@ function $32c662f618f5d80d$export$780a853d15174484({
14998
15002
  mediaUrl_: mediaUrl_,
14999
15003
  aspectRatioWhenAloneInRow_: aspectRatioWhenAloneInRow_
15000
15004
  }) {
15005
+ let wroteAspectRatioToContainer = false; // Only write this once so we don't get into a aspect ratio changed -> size changed -> image source changed -> aspect ratio slightly changed infinite loop
15001
15006
  const [wrapperSize, setWrapperSize] = $gVhhF$solidjs.createSignal();
15002
15007
  const isImage = type_ === "image";
15008
+ const setAspectRatio = aspectRatio => {
15009
+ if (wroteAspectRatioToContainer) return;
15010
+ wroteAspectRatioToContainer = true;
15011
+ setAspectRatioWas_(aspectRatio);
15012
+ };
15003
15013
  return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjsweb.Dynamic), $gVhhF$solidjsweb.mergeProps({
15004
15014
  component: link_ ? "a" : "div",
15005
15015
  "class": "d-standard-content-wrapper",
@@ -15028,7 +15038,7 @@ function $32c662f618f5d80d$export$780a853d15174484({
15028
15038
  sizeHeight: () => wrapperSize()?.[1]?.() || 0,
15029
15039
  src: mediaUrl_,
15030
15040
  "class": "d-standard-content",
15031
- ref: el => el.addEventListener("load", $gVhhF$depictaiutilisharedlatest.catchify(() => setAspectRatioWas_(el.naturalWidth / el.naturalHeight)))
15041
+ ref: el => el.addEventListener("load", $gVhhF$depictaiutilisharedlatest.catchify(() => setAspectRatio(el.naturalWidth / el.naturalHeight)))
15032
15042
  });
15033
15043
  }
15034
15044
  }), $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Match), {
@@ -15037,7 +15047,7 @@ function $32c662f618f5d80d$export$780a853d15174484({
15037
15047
  var _el$ = $gVhhF$solidjsweb.getNextElement($32c662f618f5d80d$var$_tmpl$);
15038
15048
  $gVhhF$solidjsweb.use(element => {
15039
15049
  const pageVisible = $55cbacb79d3e0cea$export$54299a3c81f5425();
15040
- element.addEventListener("loadedmetadata", $gVhhF$depictaiutilisharedlatest.catchify(() => setAspectRatioWas_(element.videoWidth / element.videoHeight)));
15050
+ element.addEventListener("loadedmetadata", $gVhhF$depictaiutilisharedlatest.catchify(() => setAspectRatio(element.videoWidth / element.videoHeight)));
15041
15051
  $gVhhF$solidjs.createEffect(() => {
15042
15052
  if (pageVisible()) element.play().catch(e => $gVhhF$depictaiutilishared.dlog("Failed to play", e));else element.pause();
15043
15053
  });
@@ -15104,7 +15114,7 @@ function $0a80939bf0a1e9cc$export$7a92d995f1bf3592(history_content_blocks_, plp_
15104
15114
  ...prev,
15105
15115
  aspectRatios: {
15106
15116
  ...prev.aspectRatios,
15107
- [componentCacheKey]: Math.round(aspectRatio * 10) / 10
15117
+ [componentCacheKey]: Math.round(aspectRatio * 100) / 100
15108
15118
  }
15109
15119
  }))
15110
15120
  });
@@ -15176,6 +15186,10 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
15176
15186
  const all_products_loaded_ = $gVhhF$solidjs.createSignal(false);
15177
15187
  const [currentlyLoadedDisplays, setCurrentlyLoadedDisplays_] = $gVhhF$solidjs.createSignal(0);
15178
15188
  const [can_write_scroll_restoration_, set_can_write_scroll_restoration] = $gVhhF$solidjs.createSignal(false);
15189
+ const owner = $gVhhF$solidjs.getOwner();
15190
+ const [metaRequestsForQuery, setMetaRequestsForQuery] = $gVhhF$solidjs.createSignal(new Map(), {
15191
+ equals: false
15192
+ });
15179
15193
  const products_query_base_ = $8cd545330f2674dc$export$210f130a61ac1e8d(() => {
15180
15194
  const sort_obj = get_sorting() && {
15181
15195
  ...get_sorting()
@@ -15208,7 +15222,20 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
15208
15222
  limit: limit,
15209
15223
  ...(cursor ? {
15210
15224
  cursor: cursor
15211
- } : {})
15225
+ } : {}),
15226
+ // This gets exposed to the products display transformer and gives it information about the listing the products are in
15227
+ // It's very hard to implement tracking that uses the collection title without this information
15228
+ currentListingForTransformer_: new Promise(resolve => $gVhhF$solidjs.createRoot(dispose => {
15229
+ $gVhhF$solidjs.createEffect($gVhhF$depictaiutilisharedlatest.catchify(() => {
15230
+ const key = base_query.id_type_ + base_query.id_to_query_for_;
15231
+ const metaResponsePromise = metaRequestsForQuery().get(key);
15232
+ if (!metaResponsePromise) return;
15233
+ resolve(metaResponsePromise);
15234
+ dispose();
15235
+ setMetaRequestsForQuery(prev => (prev.delete(key), prev));
15236
+ }));
15237
+ $gVhhF$solidjs.runWithOwner(owner, () => $gVhhF$solidjs.onCleanup(dispose));
15238
+ }))
15212
15239
  })
15213
15240
  })));
15214
15241
  const meta_query_base = $8cd545330f2674dc$export$210f130a61ac1e8d(() => ({
@@ -15219,7 +15246,17 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
15219
15246
  id_type_: id_type_()
15220
15247
  }));
15221
15248
  // Make "Get Listing" request to get quicklinks, breadcrumbs, title, etc
15222
- const [plp_meta] = $gVhhF$solidjs.createResource(meta_query_base, $gVhhF$depictaiutilisharedlatest.catchify(query => depict_api_.get_listing(query)));
15249
+ const [plp_meta] = $gVhhF$solidjs.createResource(meta_query_base, $gVhhF$depictaiutilisharedlatest.catchify(async query => {
15250
+ const result = await depict_api_.get_listing(query);
15251
+ // In the following two lines, do not expose the finished breadcrumbs and quicklinks in the products display transformer since it's already exposed in the categories display transformer
15252
+ const {
15253
+ breadcrumbs: breadcrumbs,
15254
+ quick_links: quick_links,
15255
+ ...listing
15256
+ } = result;
15257
+ setMetaRequestsForQuery(prev => prev.set(query.id_type_ + query.id_to_query_for_, listing));
15258
+ return result;
15259
+ }));
15223
15260
  const contentBlocksByRow = $0a80939bf0a1e9cc$export$7a92d995f1bf3592(history_content_blocks_, plp_meta, content_blocks_by_row_, router_);
15224
15261
  const countOfProductsForUI = $13796d59ea8af231$export$a86bc18439445599(plp_products_, all_products_loaded_, currentlyLoadedDisplays);
15225
15262
  const available_sortings_ = $gVhhF$solidjs.createMemo(() => plp_products_()?.sorts?.map(sort => ({
package/latest/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Accessor, JSX, Setter, Signal } from "solid-js";
2
2
  import { Display, ModernDisplay, report, Amazing_Slider, useExpandingContainer, ColsAtSize, Elem, Node_Array } from "@depict-ai/utilishared/latest";
3
3
  import { ContentLink, SearchResponse, SearchFilter as _SearchFilter1 } from "@depict-ai/types/api/SearchResponse";
4
- import { Ancestors, ListingSuggestion, SearchSuggestionsResponseV3 } from "@depict-ai/types/api/SearchSuggestionsResponseV3";
4
+ import { Ancestors, ListingSuggestion, SearchSuggestionsResponseV3, ProductListing as _ProductListing1 } from "@depict-ai/types/api/SearchSuggestionsResponseV3";
5
5
  import { ProductListing, GetListingResponse, ContentBlock as _ContentBlock1 } from "@depict-ai/types/api/GetListingResponse";
6
6
  import { SearchFilter, SearchRequestV3, SortModel } from "@depict-ai/types/api/SearchRequestV3";
7
7
  import { ProductListingResponseV3, SearchFilter as _SearchFilter2 } from "@depict-ai/types/api/ProductListingResponseV3";
@@ -11,7 +11,7 @@ import { GetListingRequest } from "@depict-ai/types/api/GetListingRequest";
11
11
  import { BaseSearchRequestV3 } from "@depict-ai/types/api/BaseSearchRequestV3";
12
12
  import { FeaturedInDisplay } from "@depict-ai/types/api/FeaturedInResponseV3";
13
13
  import { SearchFilter as _SearchFilter3 } from "@depict-ai/types/api/SearchRequestV2";
14
- export const version = "4.8.7";
14
+ export const version = "4.8.9";
15
15
  /**
16
16
  * Returns two accessors (one width and one height) that will update when the size of the provided element changes, to be used with ResponsiveImg
17
17
  */
@@ -46,6 +46,10 @@ type ListingSuggestionForTransformer = (ListingSuggestion & {
46
46
  export type DisplayTransformers<InputDisplay extends ModernDisplay, OutputDisplay extends ModernDisplay | never> = {
47
47
  products?: (options: DisplayTransformerAlwaysThereData & {
48
48
  displays: InputDisplay[];
49
+ /**
50
+ * If the category display transformer was called due to navigating to a listing using a <CategoryPage> component, currentListing will be set and contain a promise that can be used to get information of said listing.
51
+ */
52
+ currentListing?: Promise<ProductListing>;
49
53
  }) => CanBePromiseWrapped<OutputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<OutputDisplay>[] : never>;
50
54
  categories?: <T extends ProductListingWithAncestors | ListingSuggestionForTransformer>(options: DisplayTransformerAlwaysThereData & {
51
55
  data: T[];
@@ -551,10 +555,12 @@ export class DepictAPI<InputDisplay extends Display, OutputDisplay extends Moder
551
555
  get_listing_products({
552
556
  id_to_query_for_,
553
557
  id_type_,
558
+ currentListingForTransformer_,
554
559
  ...input_req_
555
560
  }: ProductListingRequestV3 & {
556
561
  id_to_query_for_: string;
557
562
  id_type_: typeof LISTING_ID | typeof EXTERNAL_ID;
563
+ currentListingForTransformer_: Promise<_ProductListing1>;
558
564
  }): Promise<ProductListingResponseAfterDisplayTransformer & {
559
565
  failed?: true;
560
566
  }>;