@depict-ai/ui 4.8.0 → 4.8.2

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.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { add_to_version_info as $8tj43$add_to_version_info, queueMacroTask as $8tj43$queueMacroTask, catchify as $8tj43$catchify, findMostFrequentItem as $8tj43$findMostFrequentItem, dwarn as $8tj43$dwarn, observer as $8tj43$observer, layout_media_query_header as $8tj43$layout_media_query_header, javascript_media_query as $8tj43$javascript_media_query, make_random_classname as $8tj43$make_random_classname, n_col_styling_with_dist as $8tj43$n_col_styling_with_dist, report as $8tj43$report, slider_fading_factory as $8tj43$slider_fading_factory, Amazing_Slider as $8tj43$Amazing_Slider, slider_snap_css as $8tj43$slider_snap_css, dlog as $8tj43$dlog1, camelCasifyObject as $8tj43$camelCasifyObject, useExpandingContainer as $8tj43$useExpandingContainer, fetch_retry as $8tj43$fetch_retry, base_url as $8tj43$base_url, slider_fractional_factory as $8tj43$slider_fractional_factory, layout_get_visible_recs_without_partial_rows as $8tj43$layout_get_visible_recs_without_partial_rows, layout_get_total_rec_amount_for_row as $8tj43$layout_get_total_rec_amount_for_row, standard_price_format as $8tj43$standard_price_format, instant_exec_on_suspect_history_change as $8tj43$instant_exec_on_suspect_history_change, deparallelize_no_drop as $8tj43$deparallelize_no_drop, ContainedImage as $8tj43$ContainedImage, buildThresholdList as $8tj43$buildThresholdList, make_asyncIterable_exiter as $8tj43$make_asyncIterable_exiter, href_change_ipns as $8tj43$href_change_ipns, base64_encode_unicode as $8tj43$base64_encode_unicode, base64_decode_unicode as $8tj43$base64_decode_unicode, use_href_accessor as $8tj43$use_href_accessor, get_session_id as $8tj43$get_session_id, add_version_query_params as $8tj43$add_version_query_params, hex_to_rgb as $8tj43$hex_to_rgb, relative_luminance_from_rgb as $8tj43$relative_luminance_from_rgb, snakeCasifyObject as $8tj43$snakeCasifyObject, make_url_with_query_params as $8tj43$make_url_with_query_params, sort_obj as $8tj43$sort_obj, insert_surfaces as $8tj43$insert_surfaces, is_debug as $8tj43$is_debug } from "@depict-ai/utilishared/ES10";
2
2
  import { createComponent as $8tj43$createComponent, mergeProps as $8tj43$mergeProps, insert as $8tj43$insert, template as $8tj43$template, getNextElement as $8tj43$getNextElement, effect as $8tj43$effect, style as $8tj43$style, className as $8tj43$className, spread as $8tj43$spread, runHydrationEvents as $8tj43$runHydrationEvents, getNextMarker as $8tj43$getNextMarker, classList as $8tj43$classList, isServer as $8tj43$isServer, setAttribute as $8tj43$setAttribute, addEventListener as $8tj43$addEventListener, memo as $8tj43$memo, delegateEvents as $8tj43$delegateEvents, use as $8tj43$use, setProperty as $8tj43$setProperty, Dynamic as $8tj43$Dynamic } from "solid-js/web";
3
- import { createSignal as $8tj43$createSignal, getOwner as $8tj43$getOwner, createEffect as $8tj43$createEffect, runWithOwner as $8tj43$runWithOwner, onCleanup as $8tj43$onCleanup, createContext as $8tj43$createContext, useContext as $8tj43$useContext, createMemo as $8tj43$createMemo, splitProps as $8tj43$splitProps, mergeProps as $8tj43$mergeProps1, untrack as $8tj43$untrack, createRenderEffect as $8tj43$createRenderEffect, Show as $8tj43$Show, batch as $8tj43$batch, createComputed as $8tj43$createComputed, mapArray as $8tj43$mapArray, createResource as $8tj43$createResource, Suspense as $8tj43$Suspense, createUniqueId as $8tj43$createUniqueId, ErrorBoundary as $8tj43$ErrorBoundary, createRoot as $8tj43$createRoot, For as $8tj43$For, Index as $8tj43$Index, on as $8tj43$on, createSelector as $8tj43$createSelector, children as $8tj43$children, createReaction as $8tj43$createReaction } from "solid-js";
3
+ import { createSignal as $8tj43$createSignal, getOwner as $8tj43$getOwner, createEffect as $8tj43$createEffect, runWithOwner as $8tj43$runWithOwner, onCleanup as $8tj43$onCleanup, createContext as $8tj43$createContext, useContext as $8tj43$useContext, createMemo as $8tj43$createMemo, splitProps as $8tj43$splitProps, mergeProps as $8tj43$mergeProps1, untrack as $8tj43$untrack, createRenderEffect as $8tj43$createRenderEffect, Show as $8tj43$Show, batch as $8tj43$batch, createComputed as $8tj43$createComputed, mapArray as $8tj43$mapArray, createResource as $8tj43$createResource, Suspense as $8tj43$Suspense, createUniqueId as $8tj43$createUniqueId, ErrorBoundary as $8tj43$ErrorBoundary, createRoot as $8tj43$createRoot, For as $8tj43$For, Index as $8tj43$Index, on as $8tj43$on, createSelector as $8tj43$createSelector, children as $8tj43$children, createReaction as $8tj43$createReaction, Switch as $8tj43$Switch, Match as $8tj43$Match } from "solid-js";
4
4
  import { createStore as $8tj43$createStore, reconcile as $8tj43$reconcile } from "solid-js/store";
5
5
  import { dlog as $8tj43$dlog, catchify as $8tj43$catchify1, ListenableSet as $8tj43$ListenableSet, use_href_accessor as $8tj43$use_href_accessor1, queueMacroTask as $8tj43$queueMacroTask1, report as $8tj43$report1 } from "@depict-ai/utilishared/ES10";
6
6
  import $8tj43$babelruntimehelpersdefineProperty from "@babel/runtime/helpers/defineProperty";
@@ -10,7 +10,14 @@ 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.0";
13
+ const $8db9a15135765c11$export$83d89fbfd8236492 = "4.8.2";
14
+
15
+ // Value first so shopify merchants can set (extra) display transformers in the shopify app
16
+ // Calling these functions normally doesn't do anything, but our shopify app respects them
17
+ // Them being here is value first too because this can be easily imported in the product card editor
18
+ let $80c7883e020be192$var$extraDisplayTransformers;
19
+ const $80c7883e020be192$export$b2d94be4f02525b2 = () => $80c7883e020be192$var$extraDisplayTransformers;
20
+ const $80c7883e020be192$export$f98b8d5ea7207a1 = displayTransformers => $80c7883e020be192$var$extraDisplayTransformers = displayTransformers;
14
21
  const $5441862cd2f5e111$var$ListingContext = /*@__PURE__*/$8tj43$createContext();
15
22
  function $5441862cd2f5e111$export$e68cff63f76bd15b(props) {
16
23
  const our_object = {};
@@ -91,8 +98,12 @@ const $56047603f9d212b6$export$6066eb417ed2e9f7 = /*@__PURE__*/Symbol("listingCo
91
98
  function $56047603f9d212b6$export$6e5611bc7e57e477(props) {
92
99
  const img = new Image(); // Need to use new Image or browser might not start loading image before it's in the DOM
93
100
  const [ourRatioKeyed, setOurRatioKeyed] = $8tj43$createSignal();
101
+ const [rAFSinceReturned, setRAFSinceReturned] = $8tj43$createSignal(false);
94
102
  const sizeToUse = $8tj43$createMemo(() => {
95
103
  var _props$sizeHeight;
104
+ // We first put the images into the DOM after they have been decoded. We can only get the correct object-fit value after the image is in the DOM.
105
+ // To avoid using an observer for knowing when the image is in the DOM (one of the most CPU intensive things when we did lighthouse optimisation) we just re-check an animationframe after we told <Show> to show the image, which seems to work reliably
106
+ rAFSinceReturned();
96
107
  // props.size could be a getter that expects a cleanup so get it in this memo instead of where we set img.sizes (also we need to multiply, and it's good with some diffing here so people calling the comp don't have to)
97
108
  const incomingSize = props.size();
98
109
  const ratio = ourRatioKeyed();
@@ -251,6 +262,7 @@ function $56047603f9d212b6$export$6e5611bc7e57e477(props) {
251
262
  hasDecodedFastPath = true;
252
263
  });
253
264
  });
265
+ $8tj43$createEffect(() => hasDecoded() && requestAnimationFrame($8tj43$catchify(() => setRAFSinceReturned(prev => !prev))));
254
266
  return $8tj43$createComponent((0, $8tj43$Show), {
255
267
  get when() {
256
268
  return hasDecoded();
@@ -476,13 +488,6 @@ function $98688279b9059f50$export$140423fa4bfb6d63(props) {
476
488
  customUrls: $98688279b9059f50$var$customUrls
477
489
  }));
478
490
  }
479
-
480
- // Value first so shopify merchants can set (extra) display transformers in the shopify app
481
- // Calling these functions normally doesn't do anything, but our shopify app respects them
482
- // Them being here is value first too because this can be easily imported in the product card editor
483
- let $80c7883e020be192$var$extraDisplayTransformers;
484
- const $80c7883e020be192$export$b2d94be4f02525b2 = () => $80c7883e020be192$var$extraDisplayTransformers;
485
- const $80c7883e020be192$export$f98b8d5ea7207a1 = displayTransformers => $80c7883e020be192$var$extraDisplayTransformers = displayTransformers;
486
491
  function $00a5b94f0c11efbb$export$d9f36cf74e24d595(media_query) {
487
492
  const signal = $8tj43$createSignal(false);
488
493
  $8tj43$onCleanup($8tj43$javascript_media_query(media_query, _ref => {
@@ -10326,7 +10331,8 @@ function $bc811d9630f9579b$export$9862539c89138352(_ref) {
10326
10331
  let {
10327
10332
  get_default_values_: get_default_values_,
10328
10333
  router_: router_,
10329
- prefix_: prefix_
10334
+ prefix_: prefix_,
10335
+ preserveKeys_: preserveKeys_
10330
10336
  } = _ref;
10331
10337
  const get_prefixed_default_values_ = () => {
10332
10338
  const default_values = get_default_values_();
@@ -10336,9 +10342,11 @@ function $bc811d9630f9579b$export$9862539c89138352(_ref) {
10336
10342
  }));
10337
10343
  };
10338
10344
  const prefixed_state = $972f6bce0f9d61be$export$e183a13865960371(get_prefixed_default_values_(), router_);
10345
+ const prefixedPreserveKeys = preserveKeys_ === null || preserveKeys_ === void 0 ? void 0 : preserveKeys_.map(key => prefix_ + key);
10339
10346
  const reset_state = () => {
10340
10347
  const new_defaults = get_prefixed_default_values_();
10341
10348
  for (const key in prefixed_state) {
10349
+ if (prefixedPreserveKeys !== null && prefixedPreserveKeys !== void 0 && prefixedPreserveKeys.includes(key)) continue;
10342
10350
  const new_value = new_defaults[key];
10343
10351
  prefixed_state[key][1](new_value);
10344
10352
  }
@@ -11068,8 +11076,13 @@ class $f5f54892fd0c7d9f$export$f34314aa9505732e {
11068
11076
  local_filter_cache: [],
11069
11077
  expanded_hierarchical_filters: [],
11070
11078
  scroll_restoration_data: [],
11071
- history_content_blocks: []
11079
+ history_content_blocks: {
11080
+ blocks: [],
11081
+ aspectRatios: {}
11082
+ }
11072
11083
  }),
11084
+ // Don't reset content block stuff when leaving category page as we need it for scroll restoration, same with scroll restoration data (actually a bit unsure if this is needed, I think it depends on if someone cleans up our elements before the location changes or after, and maybe some of the test flakyness we have seen is due to this not existing before?)
11085
+ preserveKeys_: ["history_content_blocks", "scroll_restoration_data"],
11073
11086
  router_: $8tj43$babelruntimehelpersclassPrivateFieldGet(this, $f5f54892fd0c7d9f$var$_router),
11074
11087
  prefix_: "category" + unique_instance_key_for_state + "_"
11075
11088
  });
@@ -15857,102 +15870,140 @@ function $1145661fd3ca5519$export$7af06a63c5a976c9(el, listing_id, i18n_) {
15857
15870
  $8tj43$onCleanup(disconnect);
15858
15871
  }
15859
15872
  $8tj43$delegateEvents(["click"]);
15860
- var $3b772ef9a35560fe$var$_tmpl$ = /*#__PURE__*/$8tj43$template(`<a class=d-standard-content-wrapper><video loop class=d-standard-content>`);
15873
+ var $3b772ef9a35560fe$var$_tmpl$ = /*#__PURE__*/$8tj43$template(`<video loop class=d-standard-content>`);
15861
15874
  function $3b772ef9a35560fe$export$780a853d15174484(_ref) {
15862
15875
  let {
15863
- contentBlock_: {
15864
- content: {
15865
- link: link,
15866
- type: type,
15867
- url: mediaUrl
15868
- }
15869
- },
15870
- router_: router_
15876
+ link_: link_,
15877
+ type_: type_,
15878
+ router_: router_,
15879
+ setAspectRatioWas_: setAspectRatioWas_,
15880
+ mediaUrl_: mediaUrl_,
15881
+ aspectRatioWhenAloneInRow_: aspectRatioWhenAloneInRow_
15871
15882
  } = _ref;
15872
- if (type === "image") {
15873
- const [wrapperSize, setWrapperSize] = $8tj43$createSignal();
15874
- return $8tj43$createComponent((0, $8tj43$Dynamic), $8tj43$mergeProps({
15875
- component: link ? "a" : "div",
15876
- "class": "d-standard-content-wrapper",
15877
- ref: el => setWrapperSize(() => $4be619ec2cd7bba3$export$54c6d6ff54e72743(el)),
15878
- get onClick() {
15879
- return $8tj43$catchify1(ev => link && router_.navigate_.go_to_({
15880
- new_url_: link,
15881
- is_replace_: false,
15882
- event_: ev
15883
- }));
15884
- }
15885
- }, link && {
15886
- href: link
15887
- }, {
15888
- get children() {
15889
- return $8tj43$createComponent((0, $98688279b9059f50$export$140423fa4bfb6d63), {
15890
- size: () => {
15891
- var _wrapperSize, _wrapperSize$;
15892
- return ((_wrapperSize = wrapperSize()) === null || _wrapperSize === void 0 ? void 0 : (_wrapperSize$ = _wrapperSize[0]) === null || _wrapperSize$ === void 0 ? void 0 : _wrapperSize$.call(_wrapperSize)) || 0;
15893
- },
15894
- sizeHeight: () => {
15895
- var _wrapperSize2, _wrapperSize2$;
15896
- return ((_wrapperSize2 = wrapperSize()) === null || _wrapperSize2 === void 0 ? void 0 : (_wrapperSize2$ = _wrapperSize2[1]) === null || _wrapperSize2$ === void 0 ? void 0 : _wrapperSize2$.call(_wrapperSize2)) || 0;
15897
- },
15898
- src: mediaUrl,
15899
- "class": "d-standard-content"
15900
- });
15901
- }
15902
- }));
15903
- }
15904
- if (type === "video") {
15905
- const pageVisible = $a35e6f680c5bbc60$export$54299a3c81f5425();
15906
- return (() => {
15907
- var _el$ = $8tj43$getNextElement($3b772ef9a35560fe$var$_tmpl$),
15908
- _el$2 = _el$.firstChild;
15909
- $8tj43$addEventListener(_el$, "click", $8tj43$catchify1(ev => router_.navigate_.go_to_({
15910
- new_url_: link,
15883
+ const [wrapperSize, setWrapperSize] = $8tj43$createSignal();
15884
+ const isImage = type_ === "image";
15885
+ return $8tj43$createComponent((0, $8tj43$Dynamic), $8tj43$mergeProps({
15886
+ component: link_ ? "a" : "div",
15887
+ "class": "d-standard-content-wrapper",
15888
+ get style() {
15889
+ return $8tj43$memo(() => !!aspectRatioWhenAloneInRow_())() ? "--media-aspect-ratio: ".concat(aspectRatioWhenAloneInRow_()) : "";
15890
+ },
15891
+ ref: el => isImage && setWrapperSize(() => $4be619ec2cd7bba3$export$54c6d6ff54e72743(el)),
15892
+ get onClick() {
15893
+ return $8tj43$catchify1(ev => link_ && router_.navigate_.go_to_({
15894
+ new_url_: link_,
15911
15895
  is_replace_: false,
15912
15896
  event_: ev
15913
- })), true);
15914
- $8tj43$setAttribute(_el$, "href", link);
15915
- $8tj43$use(element => $8tj43$createEffect(() => {
15916
- if (pageVisible()) element.play().catch(e => $8tj43$dlog1("Failed to play", e));else element.pause();
15917
- }), _el$2);
15918
- $8tj43$setAttribute(_el$2, "src", mediaUrl);
15919
- $8tj43$setProperty(_el$2, "controls", false);
15920
- $8tj43$setProperty(_el$2, "muted", true);
15921
- $8tj43$setProperty(_el$2, "autoplay", true);
15922
- $8tj43$setProperty(_el$2, "playsinline", true);
15923
- $8tj43$runHydrationEvents();
15924
- return _el$;
15925
- })();
15926
- }
15897
+ }));
15898
+ }
15899
+ }, link_ && {
15900
+ href: link_
15901
+ }, {
15902
+ get children() {
15903
+ return $8tj43$createComponent((0, $8tj43$Switch), {
15904
+ get children() {
15905
+ return [$8tj43$createComponent((0, $8tj43$Match), {
15906
+ when: isImage,
15907
+ get children() {
15908
+ return $8tj43$createComponent((0, $98688279b9059f50$export$140423fa4bfb6d63), {
15909
+ size: () => {
15910
+ var _wrapperSize, _wrapperSize$;
15911
+ return ((_wrapperSize = wrapperSize()) === null || _wrapperSize === void 0 ? void 0 : (_wrapperSize$ = _wrapperSize[0]) === null || _wrapperSize$ === void 0 ? void 0 : _wrapperSize$.call(_wrapperSize)) || 0;
15912
+ },
15913
+ sizeHeight: () => {
15914
+ var _wrapperSize2, _wrapperSize2$;
15915
+ return ((_wrapperSize2 = wrapperSize()) === null || _wrapperSize2 === void 0 ? void 0 : (_wrapperSize2$ = _wrapperSize2[1]) === null || _wrapperSize2$ === void 0 ? void 0 : _wrapperSize2$.call(_wrapperSize2)) || 0;
15916
+ },
15917
+ src: mediaUrl_,
15918
+ "class": "d-standard-content",
15919
+ ref: el => el.addEventListener("load", $8tj43$catchify1(() => setAspectRatioWas_(el.naturalWidth / el.naturalHeight)))
15920
+ });
15921
+ }
15922
+ }), $8tj43$createComponent((0, $8tj43$Match), {
15923
+ when: type_ === "video",
15924
+ get children() {
15925
+ var _el$ = $8tj43$getNextElement($3b772ef9a35560fe$var$_tmpl$);
15926
+ $8tj43$use(element => {
15927
+ const pageVisible = $a35e6f680c5bbc60$export$54299a3c81f5425();
15928
+ element.addEventListener("loadedmetadata", $8tj43$catchify1(() => setAspectRatioWas_(element.videoWidth / element.videoHeight)));
15929
+ $8tj43$createEffect(() => {
15930
+ if (pageVisible()) element.play().catch(e => $8tj43$dlog1("Failed to play", e));else element.pause();
15931
+ });
15932
+ }, _el$);
15933
+ $8tj43$setAttribute(_el$, "src", mediaUrl_);
15934
+ $8tj43$setProperty(_el$, "controls", false);
15935
+ $8tj43$setProperty(_el$, "muted", true);
15936
+ $8tj43$setProperty(_el$, "autoplay", true);
15937
+ $8tj43$setProperty(_el$, "playsinline", true);
15938
+ return _el$;
15939
+ }
15940
+ })];
15941
+ }
15942
+ });
15943
+ }
15944
+ }));
15927
15945
  }
15928
- $8tj43$delegateEvents(["click"]);
15929
15946
  function $12ff24fdc4b26d88$export$7a92d995f1bf3592(history_content_blocks_, plp_meta, content_blocks_by_row_, router_) {
15930
15947
  let hasSeenContentBlock = false;
15931
15948
  const [historyContentBlocks, setHistoryContentBlocks] = history_content_blocks_;
15949
+ const contentComponents = new Map();
15932
15950
  $8tj43$createEffect(() => {
15933
15951
  var _plp_meta;
15934
15952
  const serverContentBlock = (_plp_meta = plp_meta()) === null || _plp_meta === void 0 ? void 0 : _plp_meta.content_blocks;
15935
- if (serverContentBlock && JSON.stringify(serverContentBlock) !== JSON.stringify(historyContentBlocks())) setHistoryContentBlocks(serverContentBlock);
15953
+ const currentHistory = $8tj43$untrack(historyContentBlocks);
15954
+ // Only write to the history if the content blocks have changed when a new backend results arrives (we have them in history so scroll restoration works when going back, even when running shopify without single page navigations where our script dies inbetween pages).
15955
+ if (serverContentBlock && JSON.stringify(serverContentBlock) !== JSON.stringify(currentHistory.blocks)) setHistoryContentBlocks({
15956
+ ...currentHistory,
15957
+ blocks: serverContentBlock
15958
+ });
15936
15959
  });
15937
15960
  const contentBlocksByRow = $8tj43$createMemo(() => {
15938
15961
  const developerProvided = content_blocks_by_row_();
15939
- const fromHistory = historyContentBlocks();
15962
+ const {
15963
+ blocks: blocksFromHistory
15964
+ } = historyContentBlocks();
15940
15965
  if (developerProvided) return developerProvided;
15941
15966
  // If we didn't get any content blocks (backend always return empty array) and we haven't seen any content blocks yet, return undefined
15942
15967
  // This is so the result rendering (PLPResults) will still use flexbox provided rendering on existing customers, so adding this isn't a breaking change
15943
15968
  // We don't want to switch rendering method every time one switches between a collection that hasn't vs has content blocks though, so once we've seen one content block we'll switch to css-grid-based rendering
15944
- if (!(fromHistory !== null && fromHistory !== void 0 && fromHistory.length) && !hasSeenContentBlock) return undefined;
15969
+ if (!(blocksFromHistory !== null && blocksFromHistory !== void 0 && blocksFromHistory.length) && !hasSeenContentBlock) return;
15945
15970
  const content = [];
15946
15971
  hasSeenContentBlock = true;
15947
- fromHistory.forEach(row => {
15972
+ blocksFromHistory.forEach(row => {
15973
+ const {
15974
+ content: {
15975
+ link: link,
15976
+ type: type,
15977
+ url: url
15978
+ }
15979
+ } = row;
15980
+ // Key the "content"-component by the link, type and url, so we can reuse the component (and later downstream the block elements) if it's the same
15981
+ // This makes the block not flicker when going backwards/forwards if the content is the same on both pages
15982
+ // Also it lets us rewrite the blocks state in the history based on the block aspect ratio without infinite looping
15983
+ const componentCacheKey = JSON.stringify([link, type, url]);
15984
+ let component = contentComponents.get(componentCacheKey);
15985
+ if (!component) {
15986
+ component = () => $8tj43$createComponent((0, $3b772ef9a35560fe$export$780a853d15174484), {
15987
+ link_: link,
15988
+ type_: type,
15989
+ mediaUrl_: url,
15990
+ router_: router_,
15991
+ aspectRatioWhenAloneInRow_: () => historyContentBlocks().aspectRatios[componentCacheKey],
15992
+ setAspectRatioWas_: aspectRatio => setHistoryContentBlocks(prev => ({
15993
+ ...prev,
15994
+ aspectRatios: {
15995
+ ...prev.aspectRatios,
15996
+ [componentCacheKey]: Math.round(aspectRatio * 100) / 100
15997
+ }
15998
+ }))
15999
+ });
16000
+ contentComponents.set(componentCacheKey, component);
16001
+ }
15948
16002
  const contentBlock = {
15949
16003
  span_columns: row.span_columns,
15950
16004
  span_rows: row.span_rows,
15951
16005
  position: row.position,
15952
- content: () => $8tj43$createComponent((0, $3b772ef9a35560fe$export$780a853d15174484), {
15953
- contentBlock_: row,
15954
- router_: router_
15955
- })
16006
+ content: component
15956
16007
  };
15957
16008
  content[row.row] = contentBlock;
15958
16009
  });
@@ -16508,4 +16559,4 @@ function $8821a19349c36651$export$e2bf8ce7779e827e(props) {
16508
16559
  }, "Entire CategoryPage failed");
16509
16560
  }
16510
16561
  $8tj43$add_to_version_info("ui", (0, $8db9a15135765c11$export$83d89fbfd8236492));
16511
- export { $98688279b9059f50$export$140423fa4bfb6d63 as ModernResponsiveImage, $80c7883e020be192$export$f98b8d5ea7207a1 as setExtraDisplayTransformers, $80c7883e020be192$export$b2d94be4f02525b2 as getExtraDisplayTransformers, $ff7feae4dddd6073$export$92aa5d691d588f3f as remap_blocks_to_index, $715f7f2e53146662$export$d4d96868197be50e as useMobileHover, $a35e6f680c5bbc60$export$54299a3c81f5425 as useVisibilityState, $002f09d00aac50b2$export$eaa625fb39439e37 as useSlidableInformation, $618bd53ea0a41cd4$export$80bb7300ce6a8be3 as useProductCardIsVisible, $618bd53ea0a41cd4$export$f223d69ed12f5fb7 as CurrentlyIntersectingContext, $8e8b179489080711$export$5bad61ecde080b1f as useExpandingContainerReactive, $bb34cd283e904784$export$2c9f9bf2092486aa as LooksSliderOrGrid, $22dd375b476673e2$export$44809a8a3e867e30 as LookCard, $ac571292d606f30b$export$7e1297a3a19f10d8 as PseudoRouter, $6d75ec14f537c37f$export$83bb9af5671e1dbe as promiseSafeStructuredClone, $68e6625c8d51f847$export$5162a71f252e6122 as preserve_items_in_history_dot_state, $68e6625c8d51f847$export$3064e1e8c6513da3 as prefixes_to_preserve_in_history_dot_state, $9b35d1384e31813a$export$29d28dadc2d6b631 as allowNativeNavigation, $b026fa9c9c904a98$export$1ea76ea778b880dd as modalVersionSymbol, $a604a8ffa4e4c03f$export$e417c49320921907 as createDeparallelizedNoDropResource, $01c33966d9ddb108$export$f50b88e2a00918b5 as throw_globally, $40411f2ec772c376$export$9265e66f26f8e383 as ClassicSearchModal, $06fcd2a345efd24d$export$b0c55aa2e87c4be7 as SearchModalV2, $98688279b9059f50$export$9d4a4b669b1929ab as ModernResponsiveContainedImage, $6a439680ae7e9ba3$export$3e41faf802a29e71 as Tab, $6a439680ae7e9ba3$export$b2539bed5023c21c as Tabs, $6b0fd8fd20df8ccf$export$d4973c31938cbfd1 as ShopTheLookButton, $972f6bce0f9d61be$export$e183a13865960371 as history_dot_state_to_state, $2855bffe06ef7a03$export$916e6850778505f6 as strip_encoded_filter_and_sort, $2855bffe06ef7a03$export$58aa3f171519b6d7 as encode_filters, $2855bffe06ef7a03$export$f934fa24c3a86811 as decode_filters, $2855bffe06ef7a03$export$62acb285a7579555 as encode_sorting, $2855bffe06ef7a03$export$766e9676e74997d3 as decode_sorting, $4df489344a0f97c7$export$d7b7ab832c20e2f4 as shopifyContainedImageContextSymbol, $5441862cd2f5e111$export$e68cff63f76bd15b as ListingProvider, $5441862cd2f5e111$export$8d0c4fdbb05a2f2e as useListing, $1e69163caedaab4e$export$11354f017ddc9790 as ProductCardIndexProvider, $1e69163caedaab4e$export$e3faf4d95300054f as useProductCardIndex, $4df489344a0f97c7$export$e4b984597b71e989 as ShopifyContainedImage, $002f09d00aac50b2$export$6649caad96ef8870 as SlidableItems, $fc830a7ee59416ef$export$ebdc3711f7e02ccd as make_accurate_width_accessor, $d5d7e58c5c9d8db0$export$9574e176201e5e8d as RecommendationSlider, $b432b11321ad4c97$export$9756467d34d91cdb as RecommendationGrid, $56047603f9d212b6$export$6e5611bc7e57e477 as ShopifyResponsiveImg, $801e8845d3fa3653$export$94026ee33dbabc26 as ImageContainer, $74777e8fe65b3dcb$export$b69d0d92862de18b as SentryErrorBoundary, $74777e8fe65b3dcb$export$240ecf5363d76c0f as ExtraSentryContextProvider, $ad371564683947ab$export$6c6d7a51fa9aa15d as ExpandingDetails, $e18ab2868df26f40$export$f091cbac892643a4 as accessor_of_object_to_object_with_accessor_values, $4711a82d08d2021b$export$fecbb157621501bd as SelectedFilters, $f6b0500577e1b210$export$3f1a388cc0d8fed7 as FilterBody, $44aa24b1bb793549$export$b288c38ae3fddb56 as create_modified_filters, $63f1f8dbcd07d3b0$export$d21e32dfedac04be as SolidLayout, $63f1f8dbcd07d3b0$export$445d8d3f5f706a40 as SolidLayoutWithProvidedElement, $d5f1e6a0f9117286$export$79b1565500412d9b as general_modal_abstraction, $9783d437ad61594c$export$3b621d86b1566b2 as CrossIcon, $ca6ab5f08bd28bca$export$8be2714ec7f169ee as GenericSliderArrowButton, $50aebf5b445518eb$export$58e808b1db15d3bc as fetchDepictRecommendations, $fa332ea03168857c$export$b91cec6bdc6b32a1 as CategoryTitle, $702d7656a373973e$export$824dde41348efed1 as embedded_num_products, $160ea2b55d8772d2$export$c1a6b039e689a58e as get_listings, $f5f54892fd0c7d9f$export$f34314aa9505732e as DepictCategory, $eb064bc3350276c1$export$ac6237957a15b3f0 as DepictSearch, $eb064bc3350276c1$export$bde3eb976dfded9 as get_search_query_updating_blocked_signal, $eb064bc3350276c1$export$f2dc7e4e4aa11abb as SearchPage, $f3b7124b76123e44$export$aa14a9f43128f61f as ProductCardError, $169c13c0531d91d2$export$d86a33413558014e as open_modal_with_alignment, $5eaa00b951637e96$export$ee1733d9a8495996 as DefaultInstantCardPlaceholder, $1308a7816c3d4f2d$export$b3ad617e9036868 as align_field, $1308a7816c3d4f2d$export$3f238c96c45e6cc6 as ALIGN_TOP, $1308a7816c3d4f2d$export$902f8b4a7dae5d78 as ALIGN_WIDTH_ON_MODAL, $1308a7816c3d4f2d$export$7895aadd1956b1c7 as ALIGN_LEFT, $1308a7816c3d4f2d$export$6060bc6bee850eb6 as SET_CENTERED_LEFT, $a9c7ba6087881ac2$export$6daf8749b65a1b77 as convert_sdk_cols_at_size_to_layout, $cc64aabf2c7a1f1a$export$1233ca167bf71f9a as styles_to_valid_css_string, $e56d241d0f33d459$export$fe334901e8bebd57 as disable_scrolling, $573c007c697a1831$export$d0596b5cae35ad4 as open_search_with_shift_slash, $284849364a6ef73a$export$e015ed2f2950f2e3 as DepictAPI, $00a5b94f0c11efbb$export$d9f36cf74e24d595 as media_query_to_accessor, $e60a76195ac6d408$export$689e204eadb33baf as setup_fast_leave, $a61a2051e15c8d7a$export$5196e4c01fa56fcb as show_toast, $60ec7a29849d81db$export$a71e92cfbb498adc as SolidFormatPrice, $37e8c97bb6876197$export$828dcdd425fd3231 as connect_search_field_height_to_aligner_height, $bc2337c9a05ecd18$export$acb3eaade4b23afd as BasePlaceholder, $ceafb6fb91c6f394$export$89c6019e4baa40b1 as TextPlaceholder, $3ab4aa97880fb88d$export$3f37af283f8fb843 as ImagePlaceholder, $f9fd3017c20b774a$export$3ccaa27d81dd8556 as PageReplacer, $d399250dfa491636$export$864d304a0bc46829 as defaultGridSpacing, $d399250dfa491636$export$c3834fa86c616831 as defaultColsAtSize, $d399250dfa491636$export$7bf543b9d9be2c22 as defaultCategoryTitlePlugin, $8db9a15135765c11$export$83d89fbfd8236492 as version, $a3026fb727bc7550$export$316f6f283ae64765 as SearchField, $62a8813a51fbd22f$export$5b7c3ce0ebe51f86 as BreadCrumbs, $62a8813a51fbd22f$export$de035477d6fef996 as QuickLinks, $8821a19349c36651$export$e2bf8ce7779e827e as CategoryPage, $4be619ec2cd7bba3$export$54c6d6ff54e72743 as makeSizeAccessors };
16562
+ export { $80c7883e020be192$export$f98b8d5ea7207a1 as setExtraDisplayTransformers, $80c7883e020be192$export$b2d94be4f02525b2 as getExtraDisplayTransformers, $98688279b9059f50$export$140423fa4bfb6d63 as ModernResponsiveImage, $ff7feae4dddd6073$export$92aa5d691d588f3f as remap_blocks_to_index, $715f7f2e53146662$export$d4d96868197be50e as useMobileHover, $a35e6f680c5bbc60$export$54299a3c81f5425 as useVisibilityState, $002f09d00aac50b2$export$eaa625fb39439e37 as useSlidableInformation, $618bd53ea0a41cd4$export$80bb7300ce6a8be3 as useProductCardIsVisible, $618bd53ea0a41cd4$export$f223d69ed12f5fb7 as CurrentlyIntersectingContext, $8e8b179489080711$export$5bad61ecde080b1f as useExpandingContainerReactive, $bb34cd283e904784$export$2c9f9bf2092486aa as LooksSliderOrGrid, $22dd375b476673e2$export$44809a8a3e867e30 as LookCard, $ac571292d606f30b$export$7e1297a3a19f10d8 as PseudoRouter, $6d75ec14f537c37f$export$83bb9af5671e1dbe as promiseSafeStructuredClone, $68e6625c8d51f847$export$5162a71f252e6122 as preserve_items_in_history_dot_state, $68e6625c8d51f847$export$3064e1e8c6513da3 as prefixes_to_preserve_in_history_dot_state, $9b35d1384e31813a$export$29d28dadc2d6b631 as allowNativeNavigation, $b026fa9c9c904a98$export$1ea76ea778b880dd as modalVersionSymbol, $a604a8ffa4e4c03f$export$e417c49320921907 as createDeparallelizedNoDropResource, $01c33966d9ddb108$export$f50b88e2a00918b5 as throw_globally, $40411f2ec772c376$export$9265e66f26f8e383 as ClassicSearchModal, $06fcd2a345efd24d$export$b0c55aa2e87c4be7 as SearchModalV2, $98688279b9059f50$export$9d4a4b669b1929ab as ModernResponsiveContainedImage, $6a439680ae7e9ba3$export$3e41faf802a29e71 as Tab, $6a439680ae7e9ba3$export$b2539bed5023c21c as Tabs, $6b0fd8fd20df8ccf$export$d4973c31938cbfd1 as ShopTheLookButton, $972f6bce0f9d61be$export$e183a13865960371 as history_dot_state_to_state, $2855bffe06ef7a03$export$916e6850778505f6 as strip_encoded_filter_and_sort, $2855bffe06ef7a03$export$58aa3f171519b6d7 as encode_filters, $2855bffe06ef7a03$export$f934fa24c3a86811 as decode_filters, $2855bffe06ef7a03$export$62acb285a7579555 as encode_sorting, $2855bffe06ef7a03$export$766e9676e74997d3 as decode_sorting, $4df489344a0f97c7$export$d7b7ab832c20e2f4 as shopifyContainedImageContextSymbol, $5441862cd2f5e111$export$e68cff63f76bd15b as ListingProvider, $5441862cd2f5e111$export$8d0c4fdbb05a2f2e as useListing, $1e69163caedaab4e$export$11354f017ddc9790 as ProductCardIndexProvider, $1e69163caedaab4e$export$e3faf4d95300054f as useProductCardIndex, $4df489344a0f97c7$export$e4b984597b71e989 as ShopifyContainedImage, $002f09d00aac50b2$export$6649caad96ef8870 as SlidableItems, $fc830a7ee59416ef$export$ebdc3711f7e02ccd as make_accurate_width_accessor, $d5d7e58c5c9d8db0$export$9574e176201e5e8d as RecommendationSlider, $b432b11321ad4c97$export$9756467d34d91cdb as RecommendationGrid, $56047603f9d212b6$export$6e5611bc7e57e477 as ShopifyResponsiveImg, $801e8845d3fa3653$export$94026ee33dbabc26 as ImageContainer, $74777e8fe65b3dcb$export$b69d0d92862de18b as SentryErrorBoundary, $74777e8fe65b3dcb$export$240ecf5363d76c0f as ExtraSentryContextProvider, $ad371564683947ab$export$6c6d7a51fa9aa15d as ExpandingDetails, $e18ab2868df26f40$export$f091cbac892643a4 as accessor_of_object_to_object_with_accessor_values, $4711a82d08d2021b$export$fecbb157621501bd as SelectedFilters, $f6b0500577e1b210$export$3f1a388cc0d8fed7 as FilterBody, $44aa24b1bb793549$export$b288c38ae3fddb56 as create_modified_filters, $63f1f8dbcd07d3b0$export$d21e32dfedac04be as SolidLayout, $63f1f8dbcd07d3b0$export$445d8d3f5f706a40 as SolidLayoutWithProvidedElement, $d5f1e6a0f9117286$export$79b1565500412d9b as general_modal_abstraction, $9783d437ad61594c$export$3b621d86b1566b2 as CrossIcon, $ca6ab5f08bd28bca$export$8be2714ec7f169ee as GenericSliderArrowButton, $50aebf5b445518eb$export$58e808b1db15d3bc as fetchDepictRecommendations, $fa332ea03168857c$export$b91cec6bdc6b32a1 as CategoryTitle, $702d7656a373973e$export$824dde41348efed1 as embedded_num_products, $160ea2b55d8772d2$export$c1a6b039e689a58e as get_listings, $f5f54892fd0c7d9f$export$f34314aa9505732e as DepictCategory, $eb064bc3350276c1$export$ac6237957a15b3f0 as DepictSearch, $eb064bc3350276c1$export$bde3eb976dfded9 as get_search_query_updating_blocked_signal, $eb064bc3350276c1$export$f2dc7e4e4aa11abb as SearchPage, $f3b7124b76123e44$export$aa14a9f43128f61f as ProductCardError, $169c13c0531d91d2$export$d86a33413558014e as open_modal_with_alignment, $5eaa00b951637e96$export$ee1733d9a8495996 as DefaultInstantCardPlaceholder, $1308a7816c3d4f2d$export$b3ad617e9036868 as align_field, $1308a7816c3d4f2d$export$3f238c96c45e6cc6 as ALIGN_TOP, $1308a7816c3d4f2d$export$902f8b4a7dae5d78 as ALIGN_WIDTH_ON_MODAL, $1308a7816c3d4f2d$export$7895aadd1956b1c7 as ALIGN_LEFT, $1308a7816c3d4f2d$export$6060bc6bee850eb6 as SET_CENTERED_LEFT, $a9c7ba6087881ac2$export$6daf8749b65a1b77 as convert_sdk_cols_at_size_to_layout, $cc64aabf2c7a1f1a$export$1233ca167bf71f9a as styles_to_valid_css_string, $e56d241d0f33d459$export$fe334901e8bebd57 as disable_scrolling, $573c007c697a1831$export$d0596b5cae35ad4 as open_search_with_shift_slash, $284849364a6ef73a$export$e015ed2f2950f2e3 as DepictAPI, $00a5b94f0c11efbb$export$d9f36cf74e24d595 as media_query_to_accessor, $e60a76195ac6d408$export$689e204eadb33baf as setup_fast_leave, $a61a2051e15c8d7a$export$5196e4c01fa56fcb as show_toast, $60ec7a29849d81db$export$a71e92cfbb498adc as SolidFormatPrice, $37e8c97bb6876197$export$828dcdd425fd3231 as connect_search_field_height_to_aligner_height, $bc2337c9a05ecd18$export$acb3eaade4b23afd as BasePlaceholder, $ceafb6fb91c6f394$export$89c6019e4baa40b1 as TextPlaceholder, $3ab4aa97880fb88d$export$3f37af283f8fb843 as ImagePlaceholder, $f9fd3017c20b774a$export$3ccaa27d81dd8556 as PageReplacer, $d399250dfa491636$export$864d304a0bc46829 as defaultGridSpacing, $d399250dfa491636$export$c3834fa86c616831 as defaultColsAtSize, $d399250dfa491636$export$7bf543b9d9be2c22 as defaultCategoryTitlePlugin, $8db9a15135765c11$export$83d89fbfd8236492 as version, $a3026fb727bc7550$export$316f6f283ae64765 as SearchField, $62a8813a51fbd22f$export$5b7c3ce0ebe51f86 as BreadCrumbs, $62a8813a51fbd22f$export$de035477d6fef996 as QuickLinks, $8821a19349c36651$export$e2bf8ce7779e827e as CategoryPage };
package/latest/index.cjs CHANGED
@@ -12,9 +12,9 @@ function $parcel$export(e, n, v, s) {
12
12
  configurable: true
13
13
  });
14
14
  }
15
- $parcel$export(module.exports, "ModernResponsiveImage", () => $d212a67662c5cf38$export$140423fa4bfb6d63);
16
15
  $parcel$export(module.exports, "setExtraDisplayTransformers", () => $606c221d98ba4d92$export$f98b8d5ea7207a1);
17
16
  $parcel$export(module.exports, "getExtraDisplayTransformers", () => $606c221d98ba4d92$export$b2d94be4f02525b2);
17
+ $parcel$export(module.exports, "ModernResponsiveImage", () => $d212a67662c5cf38$export$140423fa4bfb6d63);
18
18
  $parcel$export(module.exports, "remap_blocks_to_index", () => $d92f338ba8f9da9b$export$92aa5d691d588f3f);
19
19
  $parcel$export(module.exports, "useMobileHover", () => $8bf678c45948a297$export$d4d96868197be50e);
20
20
  $parcel$export(module.exports, "useVisibilityState", () => $55cbacb79d3e0cea$export$54299a3c81f5425);
@@ -106,9 +106,15 @@ $parcel$export(module.exports, "SearchField", () => $c0a0659cf97e8eb2$export$316
106
106
  $parcel$export(module.exports, "BreadCrumbs", () => $1f4925833f07df29$export$5b7c3ce0ebe51f86);
107
107
  $parcel$export(module.exports, "QuickLinks", () => $1f4925833f07df29$export$de035477d6fef996);
108
108
  $parcel$export(module.exports, "CategoryPage", () => $14f289047713d67a$export$e2bf8ce7779e827e);
109
- $parcel$export(module.exports, "makeSizeAccessors", () => $128302ab61dab8f1$export$54c6d6ff54e72743);
110
109
  /*! Depict.ai search and product listing SDK */
111
- const $b757f75811f3261f$export$83d89fbfd8236492 = "4.8.0";
110
+ const $b757f75811f3261f$export$83d89fbfd8236492 = "4.8.2";
111
+
112
+ // Value first so shopify merchants can set (extra) display transformers in the shopify app
113
+ // Calling these functions normally doesn't do anything, but our shopify app respects them
114
+ // Them being here is value first too because this can be easily imported in the product card editor
115
+ let $606c221d98ba4d92$var$extraDisplayTransformers;
116
+ const $606c221d98ba4d92$export$b2d94be4f02525b2 = () => $606c221d98ba4d92$var$extraDisplayTransformers;
117
+ const $606c221d98ba4d92$export$f98b8d5ea7207a1 = displayTransformers => $606c221d98ba4d92$var$extraDisplayTransformers = displayTransformers;
112
118
  const $84798aaa863a4909$var$ListingContext = /*@__PURE__*/$gVhhF$solidjs.createContext();
113
119
  function $84798aaa863a4909$export$e68cff63f76bd15b(props) {
114
120
  const our_object = {};
@@ -188,7 +194,11 @@ const $19950faaac026e09$export$6066eb417ed2e9f7 = /*@__PURE__*/Symbol("listingCo
188
194
  function $19950faaac026e09$export$6e5611bc7e57e477(props) {
189
195
  const img = new Image(); // Need to use new Image or browser might not start loading image before it's in the DOM
190
196
  const [ourRatioKeyed, setOurRatioKeyed] = $gVhhF$solidjs.createSignal();
197
+ const [rAFSinceReturned, setRAFSinceReturned] = $gVhhF$solidjs.createSignal(false);
191
198
  const sizeToUse = $gVhhF$solidjs.createMemo(() => {
199
+ // We first put the images into the DOM after they have been decoded. We can only get the correct object-fit value after the image is in the DOM.
200
+ // To avoid using an observer for knowing when the image is in the DOM (one of the most CPU intensive things when we did lighthouse optimisation) we just re-check an animationframe after we told <Show> to show the image, which seems to work reliably
201
+ rAFSinceReturned();
192
202
  // props.size could be a getter that expects a cleanup so get it in this memo instead of where we set img.sizes (also we need to multiply, and it's good with some diffing here so people calling the comp don't have to)
193
203
  const incomingSize = props.size();
194
204
  const ratio = ourRatioKeyed();
@@ -344,6 +354,7 @@ function $19950faaac026e09$export$6e5611bc7e57e477(props) {
344
354
  hasDecodedFastPath = true;
345
355
  });
346
356
  });
357
+ $gVhhF$solidjs.createEffect(() => hasDecoded() && requestAnimationFrame($gVhhF$depictaiutilishared.catchify(() => setRAFSinceReturned(prev => !prev))));
347
358
  return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
348
359
  get when() {
349
360
  return hasDecoded();
@@ -560,13 +571,6 @@ function $d212a67662c5cf38$export$140423fa4bfb6d63(props) {
560
571
  customUrls: $d212a67662c5cf38$var$customUrls
561
572
  }));
562
573
  }
563
-
564
- // Value first so shopify merchants can set (extra) display transformers in the shopify app
565
- // Calling these functions normally doesn't do anything, but our shopify app respects them
566
- // Them being here is value first too because this can be easily imported in the product card editor
567
- let $606c221d98ba4d92$var$extraDisplayTransformers;
568
- const $606c221d98ba4d92$export$b2d94be4f02525b2 = () => $606c221d98ba4d92$var$extraDisplayTransformers;
569
- const $606c221d98ba4d92$export$f98b8d5ea7207a1 = displayTransformers => $606c221d98ba4d92$var$extraDisplayTransformers = displayTransformers;
570
574
  function $b54e6192d0caa293$export$d9f36cf74e24d595(media_query) {
571
575
  const signal = $gVhhF$solidjs.createSignal(false);
572
576
  $gVhhF$solidjs.onCleanup($gVhhF$depictaiutilishared.javascript_media_query(media_query, ({
@@ -9907,16 +9911,19 @@ async function $6382a1b83da39674$var$download_categories(merchant, market, local
9907
9911
  function $26a56f6b44703084$export$9862539c89138352({
9908
9912
  get_default_values_: get_default_values_,
9909
9913
  router_: router_,
9910
- prefix_: prefix_
9914
+ prefix_: prefix_,
9915
+ preserveKeys_: preserveKeys_
9911
9916
  }) {
9912
9917
  const get_prefixed_default_values_ = () => {
9913
9918
  const default_values = get_default_values_();
9914
9919
  return Object.fromEntries(Object.entries(default_values).map(([key, value]) => [prefix_ + key, value]));
9915
9920
  };
9916
9921
  const prefixed_state = $6e22b5314fb52f4c$export$e183a13865960371(get_prefixed_default_values_(), router_);
9922
+ const prefixedPreserveKeys = preserveKeys_?.map(key => prefix_ + key);
9917
9923
  const reset_state = () => {
9918
9924
  const new_defaults = get_prefixed_default_values_();
9919
9925
  for (const key in prefixed_state) {
9926
+ if (prefixedPreserveKeys?.includes(key)) continue;
9920
9927
  const new_value = new_defaults[key];
9921
9928
  prefixed_state[key][1](new_value);
9922
9929
  }
@@ -10525,8 +10532,13 @@ class $48567ac5b39bac56$export$f34314aa9505732e {
10525
10532
  local_filter_cache: [],
10526
10533
  expanded_hierarchical_filters: [],
10527
10534
  scroll_restoration_data: [],
10528
- history_content_blocks: []
10535
+ history_content_blocks: {
10536
+ blocks: [],
10537
+ aspectRatios: {}
10538
+ }
10529
10539
  }),
10540
+ // Don't reset content block stuff when leaving category page as we need it for scroll restoration, same with scroll restoration data (actually a bit unsure if this is needed, I think it depends on if someone cleans up our elements before the location changes or after, and maybe some of the test flakyness we have seen is due to this not existing before?)
10541
+ preserveKeys_: ["history_content_blocks", "scroll_restoration_data"],
10530
10542
  router_: this.#router,
10531
10543
  prefix_: "category" + unique_instance_key_for_state + "_"
10532
10544
  });
@@ -14919,94 +14931,132 @@ function $bb9760b7a8acdc18$export$7af06a63c5a976c9(el, listing_id, i18n_) {
14919
14931
  $gVhhF$solidjs.onCleanup(disconnect);
14920
14932
  }
14921
14933
  $gVhhF$solidjsweb.delegateEvents(["click"]);
14922
- var $32c662f618f5d80d$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<a class=d-standard-content-wrapper><video loop class=d-standard-content>`);
14934
+ var $32c662f618f5d80d$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<video loop class=d-standard-content>`);
14923
14935
  function $32c662f618f5d80d$export$780a853d15174484({
14924
- contentBlock_: {
14925
- content: {
14926
- link: link,
14927
- type: type,
14928
- url: mediaUrl
14929
- }
14930
- },
14931
- router_: router_
14936
+ link_: link_,
14937
+ type_: type_,
14938
+ router_: router_,
14939
+ setAspectRatioWas_: setAspectRatioWas_,
14940
+ mediaUrl_: mediaUrl_,
14941
+ aspectRatioWhenAloneInRow_: aspectRatioWhenAloneInRow_
14932
14942
  }) {
14933
- if (type === "image") {
14934
- const [wrapperSize, setWrapperSize] = $gVhhF$solidjs.createSignal();
14935
- return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjsweb.Dynamic), $gVhhF$solidjsweb.mergeProps({
14936
- component: link ? "a" : "div",
14937
- "class": "d-standard-content-wrapper",
14938
- ref: el => setWrapperSize(() => $128302ab61dab8f1$export$54c6d6ff54e72743(el)),
14939
- get onClick() {
14940
- return $gVhhF$depictaiutilisharedlatest.catchify(ev => link && router_.navigate_.go_to_({
14941
- new_url_: link,
14942
- is_replace_: false,
14943
- event_: ev
14944
- }));
14945
- }
14946
- }, link && {
14947
- href: link
14948
- }, {
14949
- get children() {
14950
- return $gVhhF$solidjsweb.createComponent((0, $d212a67662c5cf38$export$140423fa4bfb6d63), {
14951
- size: () => wrapperSize()?.[0]?.() || 0,
14952
- sizeHeight: () => wrapperSize()?.[1]?.() || 0,
14953
- src: mediaUrl,
14954
- "class": "d-standard-content"
14955
- });
14956
- }
14957
- }));
14958
- }
14959
- if (type === "video") {
14960
- const pageVisible = $55cbacb79d3e0cea$export$54299a3c81f5425();
14961
- return (() => {
14962
- var _el$ = $gVhhF$solidjsweb.getNextElement($32c662f618f5d80d$var$_tmpl$),
14963
- _el$2 = _el$.firstChild;
14964
- $gVhhF$solidjsweb.addEventListener(_el$, "click", $gVhhF$depictaiutilisharedlatest.catchify(ev => router_.navigate_.go_to_({
14965
- new_url_: link,
14943
+ const [wrapperSize, setWrapperSize] = $gVhhF$solidjs.createSignal();
14944
+ const isImage = type_ === "image";
14945
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjsweb.Dynamic), $gVhhF$solidjsweb.mergeProps({
14946
+ component: link_ ? "a" : "div",
14947
+ "class": "d-standard-content-wrapper",
14948
+ get style() {
14949
+ return $gVhhF$solidjsweb.memo(() => !!aspectRatioWhenAloneInRow_())() ? `--media-aspect-ratio: ${aspectRatioWhenAloneInRow_()}` : "";
14950
+ },
14951
+ ref: el => isImage && setWrapperSize(() => $128302ab61dab8f1$export$54c6d6ff54e72743(el)),
14952
+ get onClick() {
14953
+ return $gVhhF$depictaiutilisharedlatest.catchify(ev => link_ && router_.navigate_.go_to_({
14954
+ new_url_: link_,
14966
14955
  is_replace_: false,
14967
14956
  event_: ev
14968
- })), true);
14969
- $gVhhF$solidjsweb.setAttribute(_el$, "href", link);
14970
- $gVhhF$solidjsweb.use(element => $gVhhF$solidjs.createEffect(() => {
14971
- if (pageVisible()) element.play().catch(e => $gVhhF$depictaiutilishared.dlog("Failed to play", e));else element.pause();
14972
- }), _el$2);
14973
- $gVhhF$solidjsweb.setAttribute(_el$2, "src", mediaUrl);
14974
- $gVhhF$solidjsweb.setProperty(_el$2, "controls", false);
14975
- $gVhhF$solidjsweb.setProperty(_el$2, "muted", true);
14976
- $gVhhF$solidjsweb.setProperty(_el$2, "autoplay", true);
14977
- $gVhhF$solidjsweb.setProperty(_el$2, "playsinline", true);
14978
- $gVhhF$solidjsweb.runHydrationEvents();
14979
- return _el$;
14980
- })();
14981
- }
14957
+ }));
14958
+ }
14959
+ }, link_ && {
14960
+ href: link_
14961
+ }, {
14962
+ get children() {
14963
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Switch), {
14964
+ get children() {
14965
+ return [$gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Match), {
14966
+ when: isImage,
14967
+ get children() {
14968
+ return $gVhhF$solidjsweb.createComponent((0, $d212a67662c5cf38$export$140423fa4bfb6d63), {
14969
+ size: () => wrapperSize()?.[0]?.() || 0,
14970
+ sizeHeight: () => wrapperSize()?.[1]?.() || 0,
14971
+ src: mediaUrl_,
14972
+ "class": "d-standard-content",
14973
+ ref: el => el.addEventListener("load", $gVhhF$depictaiutilisharedlatest.catchify(() => setAspectRatioWas_(el.naturalWidth / el.naturalHeight)))
14974
+ });
14975
+ }
14976
+ }), $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Match), {
14977
+ when: type_ === "video",
14978
+ get children() {
14979
+ var _el$ = $gVhhF$solidjsweb.getNextElement($32c662f618f5d80d$var$_tmpl$);
14980
+ $gVhhF$solidjsweb.use(element => {
14981
+ const pageVisible = $55cbacb79d3e0cea$export$54299a3c81f5425();
14982
+ element.addEventListener("loadedmetadata", $gVhhF$depictaiutilisharedlatest.catchify(() => setAspectRatioWas_(element.videoWidth / element.videoHeight)));
14983
+ $gVhhF$solidjs.createEffect(() => {
14984
+ if (pageVisible()) element.play().catch(e => $gVhhF$depictaiutilishared.dlog("Failed to play", e));else element.pause();
14985
+ });
14986
+ }, _el$);
14987
+ $gVhhF$solidjsweb.setAttribute(_el$, "src", mediaUrl_);
14988
+ $gVhhF$solidjsweb.setProperty(_el$, "controls", false);
14989
+ $gVhhF$solidjsweb.setProperty(_el$, "muted", true);
14990
+ $gVhhF$solidjsweb.setProperty(_el$, "autoplay", true);
14991
+ $gVhhF$solidjsweb.setProperty(_el$, "playsinline", true);
14992
+ return _el$;
14993
+ }
14994
+ })];
14995
+ }
14996
+ });
14997
+ }
14998
+ }));
14982
14999
  }
14983
- $gVhhF$solidjsweb.delegateEvents(["click"]);
14984
15000
  function $0a80939bf0a1e9cc$export$7a92d995f1bf3592(history_content_blocks_, plp_meta, content_blocks_by_row_, router_) {
14985
15001
  let hasSeenContentBlock = false;
14986
15002
  const [historyContentBlocks, setHistoryContentBlocks] = history_content_blocks_;
15003
+ const contentComponents = new Map();
14987
15004
  $gVhhF$solidjs.createEffect(() => {
14988
15005
  const serverContentBlock = plp_meta()?.content_blocks;
14989
- if (serverContentBlock && JSON.stringify(serverContentBlock) !== JSON.stringify(historyContentBlocks())) setHistoryContentBlocks(serverContentBlock);
15006
+ const currentHistory = $gVhhF$solidjs.untrack(historyContentBlocks);
15007
+ // Only write to the history if the content blocks have changed when a new backend results arrives (we have them in history so scroll restoration works when going back, even when running shopify without single page navigations where our script dies inbetween pages).
15008
+ if (serverContentBlock && JSON.stringify(serverContentBlock) !== JSON.stringify(currentHistory.blocks)) setHistoryContentBlocks({
15009
+ ...currentHistory,
15010
+ blocks: serverContentBlock
15011
+ });
14990
15012
  });
14991
15013
  const contentBlocksByRow = $gVhhF$solidjs.createMemo(() => {
14992
15014
  const developerProvided = content_blocks_by_row_();
14993
- const fromHistory = historyContentBlocks();
15015
+ const {
15016
+ blocks: blocksFromHistory
15017
+ } = historyContentBlocks();
14994
15018
  if (developerProvided) return developerProvided;
14995
15019
  // If we didn't get any content blocks (backend always return empty array) and we haven't seen any content blocks yet, return undefined
14996
15020
  // This is so the result rendering (PLPResults) will still use flexbox provided rendering on existing customers, so adding this isn't a breaking change
14997
15021
  // We don't want to switch rendering method every time one switches between a collection that hasn't vs has content blocks though, so once we've seen one content block we'll switch to css-grid-based rendering
14998
- if (!fromHistory?.length && !hasSeenContentBlock) return undefined;
15022
+ if (!blocksFromHistory?.length && !hasSeenContentBlock) return;
14999
15023
  const content = [];
15000
15024
  hasSeenContentBlock = true;
15001
- fromHistory.forEach(row => {
15025
+ blocksFromHistory.forEach(row => {
15026
+ const {
15027
+ content: {
15028
+ link: link,
15029
+ type: type,
15030
+ url: url
15031
+ }
15032
+ } = row;
15033
+ // Key the "content"-component by the link, type and url, so we can reuse the component (and later downstream the block elements) if it's the same
15034
+ // This makes the block not flicker when going backwards/forwards if the content is the same on both pages
15035
+ // Also it lets us rewrite the blocks state in the history based on the block aspect ratio without infinite looping
15036
+ const componentCacheKey = JSON.stringify([link, type, url]);
15037
+ let component = contentComponents.get(componentCacheKey);
15038
+ if (!component) {
15039
+ component = () => $gVhhF$solidjsweb.createComponent((0, $32c662f618f5d80d$export$780a853d15174484), {
15040
+ link_: link,
15041
+ type_: type,
15042
+ mediaUrl_: url,
15043
+ router_: router_,
15044
+ aspectRatioWhenAloneInRow_: () => historyContentBlocks().aspectRatios[componentCacheKey],
15045
+ setAspectRatioWas_: aspectRatio => setHistoryContentBlocks(prev => ({
15046
+ ...prev,
15047
+ aspectRatios: {
15048
+ ...prev.aspectRatios,
15049
+ [componentCacheKey]: Math.round(aspectRatio * 100) / 100
15050
+ }
15051
+ }))
15052
+ });
15053
+ contentComponents.set(componentCacheKey, component);
15054
+ }
15002
15055
  const contentBlock = {
15003
15056
  span_columns: row.span_columns,
15004
15057
  span_rows: row.span_rows,
15005
15058
  position: row.position,
15006
- content: () => $gVhhF$solidjsweb.createComponent((0, $32c662f618f5d80d$export$780a853d15174484), {
15007
- contentBlock_: row,
15008
- router_: router_
15009
- })
15059
+ content: component
15010
15060
  };
15011
15061
  content[row.row] = contentBlock;
15012
15062
  });