@depict-ai/ui 4.0.7 → 4.0.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.js CHANGED
@@ -1,7 +1,7 @@
1
- import { add_to_version_info as $8tj43$add_to_version_info, deparallelize_no_drop as $8tj43$deparallelize_no_drop, catchify as $8tj43$catchify, make_random_classname as $8tj43$make_random_classname, ContainedImage as $8tj43$ContainedImage, standard_price_format as $8tj43$standard_price_format, javascript_media_query as $8tj43$javascript_media_query, dlog as $8tj43$dlog, camelCasifyObject as $8tj43$camelCasifyObject, buildThresholdList as $8tj43$buildThresholdList, make_asyncIterable_exiter as $8tj43$make_asyncIterable_exiter, href_change_ipns as $8tj43$href_change_ipns, observer as $8tj43$observer, report as $8tj43$report, base64_encode_unicode as $8tj43$base64_encode_unicode, base64_decode_unicode as $8tj43$base64_decode_unicode, ListenableSet as $8tj43$ListenableSet, findMostFrequentItem as $8tj43$findMostFrequentItem, queueMacroTask as $8tj43$queueMacroTask, dwarn as $8tj43$dwarn, slider_fading_factory as $8tj43$slider_fading_factory, Amazing_Slider as $8tj43$Amazing_Slider, slider_snap_css as $8tj43$slider_snap_css, n_col_styling_with_dist as $8tj43$n_col_styling_with_dist, 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, layout_media_query_header as $8tj43$layout_media_query_header, 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, base_url as $8tj43$base_url, instant_exec_on_suspect_history_change as $8tj43$instant_exec_on_suspect_history_change, slider_fractional_factory as $8tj43$slider_fractional_factory, useExpandingContainer as $8tj43$useExpandingContainer, hex_to_rgb as $8tj43$hex_to_rgb, relative_luminance_from_rgb as $8tj43$relative_luminance_from_rgb, snakeCasifyObject as $8tj43$snakeCasifyObject, fetch_retry as $8tj43$fetch_retry, make_url_with_query_params as $8tj43$make_url_with_query_params, sort_obj as $8tj43$sort_obj, is_debug as $8tj43$is_debug, insert_surfaces as $8tj43$insert_surfaces } from "@depict-ai/utilishared/ES10";
2
- import { createSignal as $8tj43$createSignal, createResource as $8tj43$createResource, createEffect as $8tj43$createEffect, untrack as $8tj43$untrack, createMemo as $8tj43$createMemo, onCleanup as $8tj43$onCleanup, Show as $8tj43$Show, createComputed as $8tj43$createComputed, For as $8tj43$For, getOwner as $8tj43$getOwner, runWithOwner as $8tj43$runWithOwner, on as $8tj43$on, Index as $8tj43$Index, batch as $8tj43$batch, ErrorBoundary as $8tj43$ErrorBoundary, createContext as $8tj43$createContext, useContext as $8tj43$useContext, mergeProps as $8tj43$mergeProps1, createUniqueId as $8tj43$createUniqueId, createRenderEffect as $8tj43$createRenderEffect, createSelector as $8tj43$createSelector, children as $8tj43$children, splitProps as $8tj43$splitProps, createRoot as $8tj43$createRoot, Suspense as $8tj43$Suspense, createReaction as $8tj43$createReaction, mapArray as $8tj43$mapArray } from "solid-js";
1
+ import { add_to_version_info as $8tj43$add_to_version_info, deparallelize_no_drop as $8tj43$deparallelize_no_drop, catchify as $8tj43$catchify, make_random_classname as $8tj43$make_random_classname, ContainedImage as $8tj43$ContainedImage, standard_price_format as $8tj43$standard_price_format, javascript_media_query as $8tj43$javascript_media_query, dlog as $8tj43$dlog, camelCasifyObject as $8tj43$camelCasifyObject, buildThresholdList as $8tj43$buildThresholdList, make_asyncIterable_exiter as $8tj43$make_asyncIterable_exiter, href_change_ipns as $8tj43$href_change_ipns, observer as $8tj43$observer, report as $8tj43$report, base64_encode_unicode as $8tj43$base64_encode_unicode, base64_decode_unicode as $8tj43$base64_decode_unicode, queueMacroTask as $8tj43$queueMacroTask, findMostFrequentItem as $8tj43$findMostFrequentItem, dwarn as $8tj43$dwarn, slider_fading_factory as $8tj43$slider_fading_factory, Amazing_Slider as $8tj43$Amazing_Slider, slider_snap_css as $8tj43$slider_snap_css, n_col_styling_with_dist as $8tj43$n_col_styling_with_dist, 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, layout_media_query_header as $8tj43$layout_media_query_header, 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, base_url as $8tj43$base_url, instant_exec_on_suspect_history_change as $8tj43$instant_exec_on_suspect_history_change, slider_fractional_factory as $8tj43$slider_fractional_factory, useExpandingContainer as $8tj43$useExpandingContainer, hex_to_rgb as $8tj43$hex_to_rgb, relative_luminance_from_rgb as $8tj43$relative_luminance_from_rgb, snakeCasifyObject as $8tj43$snakeCasifyObject, fetch_retry as $8tj43$fetch_retry, make_url_with_query_params as $8tj43$make_url_with_query_params, sort_obj as $8tj43$sort_obj, is_debug as $8tj43$is_debug, ListenableSet as $8tj43$ListenableSet1, insert_surfaces as $8tj43$insert_surfaces } from "@depict-ai/utilishared/ES10";
2
+ import { createSignal as $8tj43$createSignal, createResource as $8tj43$createResource, createEffect as $8tj43$createEffect, untrack as $8tj43$untrack, createMemo as $8tj43$createMemo, onCleanup as $8tj43$onCleanup, Show as $8tj43$Show, createComputed as $8tj43$createComputed, For as $8tj43$For, getOwner as $8tj43$getOwner, runWithOwner as $8tj43$runWithOwner, createContext as $8tj43$createContext, useContext as $8tj43$useContext, on as $8tj43$on, Index as $8tj43$Index, batch as $8tj43$batch, ErrorBoundary as $8tj43$ErrorBoundary, splitProps as $8tj43$splitProps, mergeProps as $8tj43$mergeProps1, createUniqueId as $8tj43$createUniqueId, createRenderEffect as $8tj43$createRenderEffect, createSelector as $8tj43$createSelector, children as $8tj43$children, createRoot as $8tj43$createRoot, Suspense as $8tj43$Suspense, createReaction as $8tj43$createReaction, mapArray as $8tj43$mapArray } from "solid-js";
3
3
  import { template as $8tj43$template, getNextElement as $8tj43$getNextElement, addEventListener as $8tj43$addEventListener, insert as $8tj43$insert, memo as $8tj43$memo, runHydrationEvents as $8tj43$runHydrationEvents, createComponent as $8tj43$createComponent, getNextMarker as $8tj43$getNextMarker, use as $8tj43$use, effect as $8tj43$effect, classList as $8tj43$classList, setAttribute as $8tj43$setAttribute, delegateEvents as $8tj43$delegateEvents, style as $8tj43$style, className as $8tj43$className, spread as $8tj43$spread, mergeProps as $8tj43$mergeProps, setProperty as $8tj43$setProperty, isServer as $8tj43$isServer, Dynamic as $8tj43$Dynamic } from "solid-js/web";
4
- import { ListenableSet as $8tj43$ListenableSet1, catchify as $8tj43$catchify1, use_href_accessor as $8tj43$use_href_accessor1, report as $8tj43$report1 } from "@depict-ai/utilishared/ES10";
4
+ import { ListenableSet as $8tj43$ListenableSet, catchify as $8tj43$catchify1, use_href_accessor as $8tj43$use_href_accessor1, report as $8tj43$report1 } from "@depict-ai/utilishared/ES10";
5
5
  import $8tj43$babelruntimehelpersdefineProperty from "@babel/runtime/helpers/defineProperty";
6
6
  import $8tj43$babelruntimehelpersclassPrivateFieldSet from "@babel/runtime/helpers/classPrivateFieldSet";
7
7
  import $8tj43$babelruntimehelpersclassPrivateFieldGet from "@babel/runtime/helpers/classPrivateFieldGet";
@@ -10,7 +10,7 @@ import { createStore as $8tj43$createStore, reconcile as $8tj43$reconcile } from
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.0.7";
13
+ const $8db9a15135765c11$export$83d89fbfd8236492 = "4.0.9";
14
14
  function $a604a8ffa4e4c03f$export$e417c49320921907(dependency, fetcher) {
15
15
  const [promiseOfCurrentFetcherRun, setPromiseOfCurrentFetcherRun] = $8tj43$createSignal();
16
16
  const deparallelizedFetcher = $8tj43$deparallelize_no_drop(async dependencyValue => {
@@ -369,6 +369,20 @@ function $cb64b315b25cfc59$var$unwrapping_helper(elements) {
369
369
  } else if (typeof elements == "function") result.push(...$cb64b315b25cfc59$var$unwrapping_helper(elements()));else if (elements != undefined && typeof elements != "boolean") result.push(elements);
370
370
  return result;
371
371
  }
372
+ const $1e69163caedaab4e$var$ProductCardIndexContext = /*@__PURE__*/$8tj43$createContext();
373
+ function $1e69163caedaab4e$export$11354f017ddc9790(props) {
374
+ return $8tj43$createComponent($1e69163caedaab4e$var$ProductCardIndexContext.Provider, {
375
+ get value() {
376
+ return props.index_;
377
+ },
378
+ get children() {
379
+ return props.children;
380
+ }
381
+ });
382
+ }
383
+ function $1e69163caedaab4e$export$e3faf4d95300054f() {
384
+ return $8tj43$useContext($1e69163caedaab4e$var$ProductCardIndexContext);
385
+ }
372
386
  let $2d7bad8684bc7f44$var$printedCloneError = false;
373
387
  function $2d7bad8684bc7f44$export$7f8bd308237ab5a5(get_displays_) {
374
388
  const displays_by_key_ = $8tj43$createMemo(() => {
@@ -426,9 +440,22 @@ function $2d7bad8684bc7f44$export$43f0fb951fcb0c54(_ref) {
426
440
  $8tj43$dlog("Can't clone display", display, " (uncloneable objects in it), make sure you don't mutate it in the template since we cache.", e);
427
441
  }
428
442
  }
429
- return product_card_template_(display, {
430
- set_on_index_change: fn => $8tj43$runWithOwner(owner, () => $8tj43$createEffect(() => fn(index())))
443
+ let renderingResult;
444
+ // Wrap the product card in a ProductCardIndexProvider so that the index is available to the product card
445
+ // This is wo we can do intelligent image loading in ShopifyContainedImage without shopify devs having to pass in the index
446
+ // We don't care about the return value of ProductCardIndexProvider because our rendering result might be a promise which solid doesn't support until it has gone through createResource
447
+ $1e69163caedaab4e$export$11354f017ddc9790({
448
+ index_: index,
449
+ get children() {
450
+ // This is the key - the functions called inside of the children getter of the provider are the one that have the context defined in their solid-internal Owner
451
+ renderingResult = product_card_template_(display, {
452
+ set_on_index_change: fn => $8tj43$runWithOwner(owner, () => $8tj43$createEffect(() => fn(index())))
453
+ });
454
+ return undefined; // just to satisfy the typing
455
+ }
431
456
  });
457
+ // renderingResult is guaranteed to be defined here (if rendering returned something) because the children getter of ProductCardIndexProvider is called synchronously (createRenderEffect is used solid-internally)
458
+ return renderingResult;
432
459
  });
433
460
  const node_accessor = $cb64b315b25cfc59$export$2f0cbfbb4354bb52(product_card_resource);
434
461
  $8tj43$createEffect(() => {
@@ -453,7 +480,8 @@ function $2d7bad8684bc7f44$export$43f0fb951fcb0c54(_ref) {
453
480
  });
454
481
  return [
455
482
  // Show content block before product card, so it's *at* that index
456
- possible_content_block, product_card_resource]; // https://github.com/solidjs/solid/releases/tag/v1.7.0
483
+ possible_content_block, node_accessor // Don't return product_card_resource as calling it could be creating the nodes which would mean we'd be double-creating the nodes,
484
+ ]; // Regarding the as unknown shenanigans: https://github.com/solidjs/solid/releases/tag/v1.7.0
457
485
  }
458
486
  });
459
487
  }
@@ -2425,6 +2453,34 @@ function $801e8845d3fa3653$export$94026ee33dbabc26(props) {
2425
2453
  return _el$;
2426
2454
  })();
2427
2455
  }
2456
+ let $6db93f70c2db1486$var$browserIsBugged = false;
2457
+ function $6db93f70c2db1486$export$2972b890694ced75(callback, _ref) {
2458
+ let {
2459
+ timeout: timeout
2460
+ } = _ref;
2461
+ if ($6db93f70c2db1486$var$browserIsBugged) timeout /= 4;
2462
+ const cancel = () => {
2463
+ cancelIdleCallback(idleHandle);
2464
+ clearTimeout(racingTimeout);
2465
+ };
2466
+ const idleHandle = requestIdleCallback(deadline => {
2467
+ cancel();
2468
+ return callback(deadline);
2469
+ }, {
2470
+ timeout: timeout
2471
+ });
2472
+ const racingTimeout = setTimeout(() => {
2473
+ $6db93f70c2db1486$var$browserIsBugged = true;
2474
+ cancel();
2475
+ callback({
2476
+ didTimeout: false,
2477
+ timeRemaining() {
2478
+ return 500;
2479
+ }
2480
+ });
2481
+ }, timeout + 1000);
2482
+ return cancel;
2483
+ }
2428
2484
  function $56047603f9d212b6$export$e6fffe67d4cdd848(whatToWatch) {
2429
2485
  const [size, setSize] = $8tj43$createSignal(0);
2430
2486
  const resizeObserver = new ResizeObserver($8tj43$catchify(records => {
@@ -2452,23 +2508,11 @@ function $56047603f9d212b6$export$e6fffe67d4cdd848(whatToWatch) {
2452
2508
  }
2453
2509
  const $56047603f9d212b6$var$onIdleFunctionsSymbol = /*@__PURE__*/Symbol("onIdleFunctions");
2454
2510
  const $56047603f9d212b6$export$f8945274f08a3105 = /*@__PURE__*/Symbol("listingContextAspectRatios");
2511
+ const $56047603f9d212b6$export$6066eb417ed2e9f7 = /*@__PURE__*/Symbol("listingContextAspectRatios");
2455
2512
  function $56047603f9d212b6$export$6e5611bc7e57e477(props) {
2456
- // Enable reactive props
2457
- const otherOptions = $8tj43$createMemo(() => {
2458
- const cloned_props = {
2459
- ...props
2460
- };
2461
- delete cloned_props.resolutions;
2462
- // @ts-ignore
2463
- delete cloned_props.size;
2464
- // @ts-ignore
2465
- delete cloned_props.src;
2466
- return cloned_props;
2467
- });
2468
2513
  const src_options = $8tj43$createMemo(() => {
2469
- const src = new URL(props.src, location.origin);
2470
- const fallback_src = $56047603f9d212b6$var$generateImageUrl(src, 400);
2471
- const srcset = $56047603f9d212b6$var$make_srcset(src, props.resolutions || [64, 128, 256, 300, 400, 512, 640, 768, 1024, 1280, 1536, 2048, 2560, 3072, 3584, 4096]);
2514
+ const fallback_src = $56047603f9d212b6$var$generateImageUrl(props.src, 400);
2515
+ const srcset = $56047603f9d212b6$var$make_srcset(props.src, props.resolutions || [64, 128, 256, 300, 400, 512, 640, 768, 1024, 1280, 1536, 2048, 2560, 3072, 3584, 4096]);
2472
2516
  // The order here *might* matter - I've seen mobile safari always start with loading the 400px version when it was reversed
2473
2517
  return {
2474
2518
  srcset: srcset,
@@ -2477,19 +2521,35 @@ function $56047603f9d212b6$export$6e5611bc7e57e477(props) {
2477
2521
  });
2478
2522
  // Work around https://github.com/solidjs/solid/issues/1828
2479
2523
  const img = new Image(); // Need to use new Image or browser might not start loading image before it's in the DOM
2524
+ const [, otherAttributes] = $8tj43$splitProps(props, ["resolutions", "size", "src", "srcSet", "loading"]);
2480
2525
  const [hasSetSize, setHasSetSize] = $8tj43$createSignal(false);
2481
2526
  const [hasDecoded, setHasDecoded] = $8tj43$createSignal(false);
2527
+ const productCardIndexAccessor = $1e69163caedaab4e$export$e3faf4d95300054f();
2482
2528
  const sizePX = $8tj43$createMemo(() => "".concat(props.size(), "px")); // props.size could be a getter that expects a cleanup so get it in this memo instead of where we set img.sizes
2483
2529
  const listingContext = $5441862cd2f5e111$export$8d0c4fdbb05a2f2e();
2530
+ const isPrioritisedImage = $8tj43$createMemo(() => (productCardIndexAccessor === null || productCardIndexAccessor === void 0 ? void 0 : productCardIndexAccessor()) < 8);
2531
+ const shouldActuallyEnableLazyLoading = $8tj43$createMemo(() => {
2532
+ const {
2533
+ loading: loading
2534
+ } = props;
2535
+ if (loading === "force-lazy") return true;
2536
+ return loading === "lazy" && !isPrioritisedImage();
2537
+ });
2538
+ const modifiedOtherAttributes = $8tj43$mergeProps1(otherAttributes, {
2539
+ get loading() {
2540
+ return shouldActuallyEnableLazyLoading() ? "lazy" : undefined;
2541
+ }
2542
+ });
2484
2543
  // Batch idle callbacks so that MutationObserver can batch the resulting mutations better, so we don't lose tons of CPU time to MutationObservers doing lots of things for each image
2485
2544
  // Happened on singular, they have some weird observer (+we also have one but ours is at least 3x more efficient)
2486
2545
  const executeWhenIdleBatched = fn => {
2487
2546
  if (typeof requestIdleCallback !== "function") return setTimeout(fn); // Old browsers don't get optimisation
2547
+ if ($8tj43$untrack(isPrioritisedImage)) return fn(); // If we're one of the first 8 images, execute the callbacks immediately
2488
2548
  const existingStack = listingContext === null || listingContext === void 0 ? void 0 : listingContext[$56047603f9d212b6$var$onIdleFunctionsSymbol];
2489
2549
  if (existingStack) return existingStack.add(fn);
2490
2550
  const newStack = new Set([fn]);
2491
2551
  if (listingContext) listingContext[$56047603f9d212b6$var$onIdleFunctionsSymbol] = newStack;
2492
- const processStackWhenIdle = () => requestIdleCallback(deadline => {
2552
+ const processStackWhenIdle = () => $6db93f70c2db1486$export$2972b890694ced75($8tj43$catchify(deadline => {
2493
2553
  const start = performance.now();
2494
2554
  const thirdDeadlineTime = deadline.timeRemaining() / 3; // observers coming after this take up 2-3x the time so don't use all of it
2495
2555
  for (const fn of newStack) {
@@ -2504,7 +2564,7 @@ function $56047603f9d212b6$export$6e5611bc7e57e477(props) {
2504
2564
  }
2505
2565
  // Stack is empty
2506
2566
  if (listingContext) delete listingContext[$56047603f9d212b6$var$onIdleFunctionsSymbol];
2507
- }, {
2567
+ }), {
2508
2568
  timeout: 15000
2509
2569
  } // long timeout, better to not have images than to freeze the browser. But also we don't want to confuse user why no iamges are loading
2510
2570
  );
@@ -2518,7 +2578,8 @@ function $56047603f9d212b6$export$6e5611bc7e57e477(props) {
2518
2578
  img.classList.add("s-responsive-image");
2519
2579
  if (listingContext) {
2520
2580
  let prevValue;
2521
- const aspectRatios = listingContext[$56047603f9d212b6$export$f8945274f08a3105] || (listingContext[$56047603f9d212b6$export$f8945274f08a3105] = new (0, $8tj43$ListenableSet)());
2581
+ const aspectRatios = listingContext[$56047603f9d212b6$export$f8945274f08a3105] || (listingContext[$56047603f9d212b6$export$f8945274f08a3105] = new Set());
2582
+ const [, setMostPrevalentAspectRatio] = listingContext[$56047603f9d212b6$export$6066eb417ed2e9f7] || (listingContext[$56047603f9d212b6$export$6066eb417ed2e9f7] = $8tj43$createSignal());
2522
2583
  img.addEventListener("load", $8tj43$catchify(() => {
2523
2584
  // Save our aspect ratio whenever it changes, so that we can base the containers on the most dominant aspect ratio, used in SearchModalV2
2524
2585
  const aspectRatio_ = img.naturalWidth / img.naturalHeight;
@@ -2528,13 +2589,22 @@ function $56047603f9d212b6$export$6e5611bc7e57e477(props) {
2528
2589
  } : undefined;
2529
2590
  if (newValue) aspectRatios.add(newValue);
2530
2591
  prevValue = newValue;
2592
+ // Do all calculations resulting of an update directly, for performance
2593
+ const asArray = [...aspectRatios].map(_ref2 => {
2594
+ let {
2595
+ aspectRatio_: aspectRatio_
2596
+ } = _ref2;
2597
+ return aspectRatio_;
2598
+ });
2599
+ const mostPrevalentAspectRatio = $8tj43$findMostFrequentItem(asArray);
2600
+ setMostPrevalentAspectRatio(mostPrevalentAspectRatio);
2531
2601
  }));
2532
2602
  $8tj43$onCleanup(() => prevValue && aspectRatios.delete(prevValue));
2533
2603
  }
2534
2604
  $8tj43$onCleanup(() => gotCleanedUp = true);
2535
- $8tj43$spread(img, $8tj43$mergeProps1(otherOptions), false, true);
2605
+ $8tj43$spread(img, $8tj43$mergeProps1(modifiedOtherAttributes), false, true);
2536
2606
  $8tj43$createEffect(() => {
2537
- if (!props.size()) return; // wait until we have a size
2607
+ if (!props.size()) return; // wait until we have a size, run every time the size changes
2538
2608
  if (timeoutSet) return;
2539
2609
  const handler = $8tj43$catchify(() => {
2540
2610
  if (gotCleanedUp) return;
@@ -2559,7 +2629,7 @@ function $56047603f9d212b6$export$6e5611bc7e57e477(props) {
2559
2629
  // We can do this because there has to be a container around us giving us a size
2560
2630
  // No need to listen if we're already in the DOM
2561
2631
  if (hasDecodedFastPath) return;
2562
- if (props.loading === "lazy") {
2632
+ if (shouldActuallyEnableLazyLoading()) {
2563
2633
  // For lazy loading there's no decoding to wait for as it only occurs when the image is visible
2564
2634
  // Make sure src is set before we put the image into the DOM though so no broken image symbol is shown
2565
2635
  setHasDecoded(true);
@@ -2586,9 +2656,10 @@ function $56047603f9d212b6$var$make_srcset(url, resolutions) {
2586
2656
  return resolutions.map(width => "".concat($56047603f9d212b6$var$generateImageUrl(url, width), " ").concat(width, "w")).join(", ");
2587
2657
  }
2588
2658
  function $56047603f9d212b6$var$generateImageUrl(url, width) {
2589
- // This function is quite slow, we maybe could do string concat with encodeURIComponent instead if shopify handles double width params well?
2590
- url.searchParams.set("width", width);
2591
- return url.href;
2659
+ // Even just creating one `URL` object per image src and then setting the search parameter is quite slow (0.25ms to set the width param)
2660
+ // We're making the assumptions that the url has already at least one query parameter and that the image resizing service will choose the last one out of a duplicate width parameter (shopify's does)
2661
+ // That way we can just to string concatenation which is insanely fast
2662
+ return url + "&width=" + encodeURIComponent(width);
2592
2663
  }
2593
2664
  const $4df489344a0f97c7$var$backupSizeSignal = /*@__PURE__*/$8tj43$createSignal();
2594
2665
  const $4df489344a0f97c7$export$d7b7ab832c20e2f4 = /*@__PURE__*/Symbol("ShopifyContainedImage");
@@ -2598,41 +2669,23 @@ function $4df489344a0f97c7$export$e4b984597b71e989(props) {
2598
2669
  // create a signal that's the same for all items in this listing
2599
2670
  context[$4df489344a0f97c7$export$d7b7ab832c20e2f4] = $8tj43$createSignal();
2600
2671
  const [currentImageSize, setCurrentImageSize] = (context === null || context === void 0 ? void 0 : context[$4df489344a0f97c7$export$d7b7ab832c20e2f4]) || $4df489344a0f97c7$var$backupSizeSignal; // use global fallback signal (might lead to blurry images) if no context is available
2601
- const aspectRatiosSet = context ? context[(0, $56047603f9d212b6$export$f8945274f08a3105)] || (context[(0, $56047603f9d212b6$export$f8945274f08a3105)] = new (0, $8tj43$ListenableSet)()) : undefined;
2602
- const [aspectRatios, setAspectRatios] = $8tj43$createSignal(aspectRatiosSet, {
2603
- equals: false
2604
- });
2605
- const aspectRatioToUse = $8tj43$createMemo(() => {
2606
- const aspectRatiosSet = aspectRatios(); // This signal "changes" to the same set every time the set changes, so we can use it as a dependency here
2607
- useMostPrevalentAspectRatio: {
2608
- if (!aspectRatiosSet || !props.autoAdjustAspectRatio) break useMostPrevalentAspectRatio;
2609
- // Get the aspect ratio that most of the loaded images inside the ListingProvider we are, load
2610
- const asArray = [...aspectRatiosSet].map(_ref => {
2611
- let {
2612
- aspectRatio_: aspectRatio_
2613
- } = _ref;
2614
- return aspectRatio_;
2615
- });
2616
- const mostPrevalentAspectRatio = $8tj43$findMostFrequentItem(asArray);
2617
- if (mostPrevalentAspectRatio) return "var(".concat((0, $5eaa00b951637e96$export$8a2234b5b1a5ebd4), ", ").concat(mostPrevalentAspectRatio, ")");
2618
- }
2619
- return props.aspectRatio;
2620
- });
2621
- const container = $8tj43$createComponent((0, $801e8845d3fa3653$export$94026ee33dbabc26), {
2622
- get aspectRatio() {
2623
- return aspectRatioToUse();
2624
- },
2625
- get ["class"]() {
2672
+ const [mostPrevalentAspectRatio] = context ? context[(0, $56047603f9d212b6$export$6066eb417ed2e9f7)] || (context[(0, $56047603f9d212b6$export$6066eb417ed2e9f7)] = $8tj43$createSignal()) : [];
2673
+ const container = $801e8845d3fa3653$export$94026ee33dbabc26({
2674
+ // Write getters manually instead of using JSX, so we can do more complex logic in the aspectRatio getter without increasing bundle size
2675
+ get class() {
2626
2676
  return props.class;
2677
+ },
2678
+ get aspectRatio() {
2679
+ if (props.autoAdjustAspectRatio) {
2680
+ const targetRatio = mostPrevalentAspectRatio === null || mostPrevalentAspectRatio === void 0 ? void 0 : mostPrevalentAspectRatio();
2681
+ if (targetRatio != undefined) return "var(".concat((0, $5eaa00b951637e96$export$8a2234b5b1a5ebd4), ", ").concat(targetRatio, ")");
2682
+ }
2683
+ return props.aspectRatio;
2627
2684
  }
2628
2685
  });
2629
2686
  const owner = $8tj43$getOwner();
2630
2687
  let createdSizeAccessor = false;
2631
2688
  let wasCleanedUp = false;
2632
- for (const event of ["add", "delete"]) {
2633
- aspectRatiosSet === null || aspectRatiosSet === void 0 || aspectRatiosSet.addEventListener(event, () => setAspectRatios(aspectRatiosSet));
2634
- $8tj43$onCleanup(() => aspectRatiosSet === null || aspectRatiosSet === void 0 ? void 0 : aspectRatiosSet.removeEventListener(event, () => setAspectRatios(aspectRatiosSet)));
2635
- }
2636
2689
  $8tj43$createEffect(() => {
2637
2690
  if (currentImageSize() || wasCleanedUp) return; // We get into the effect when onCleanup is called if we don't have wasCleanedUp
2638
2691
  // ensure we always have a size accessor
@@ -3908,7 +3961,7 @@ const $6a439680ae7e9ba3$var$TabsContext = /*@__PURE__*/$8tj43$createContext();
3908
3961
  const $6a439680ae7e9ba3$var$useTabs = () => $8tj43$useContext($6a439680ae7e9ba3$var$TabsContext);
3909
3962
  function $6a439680ae7e9ba3$export$b2539bed5023c21c(props) {
3910
3963
  return $8tj43$createComponent($6a439680ae7e9ba3$var$TabsContext.Provider, {
3911
- value: new (0, $8tj43$ListenableSet1)(),
3964
+ value: new (0, $8tj43$ListenableSet)(),
3912
3965
  get children() {
3913
3966
  return $8tj43$createComponent($6a439680ae7e9ba3$var$ActualTabs, $8tj43$mergeProps(props, {
3914
3967
  get children() {
@@ -13373,7 +13426,7 @@ function $d53ebed6f63304e4$export$6d0c9c22f6652669(_ref) {
13373
13426
  number_: num_results,
13374
13427
  i18n_: i18n_
13375
13428
  });
13376
- const queries_without_content_results_ = new (0, $8tj43$ListenableSet)();
13429
+ const queries_without_content_results_ = new (0, $8tj43$ListenableSet1)();
13377
13430
  const [check_query, set_check_query] = $8tj43$createSignal(false);
13378
13431
  const placeholders_enabled = $8tj43$createMemo(() => {
13379
13432
  // don't show placeholders when the user toggles filters
@@ -15100,4 +15153,4 @@ function $a3026fb727bc7550$var$align_field_modal(alignmentSignals, input, modalV
15100
15153
  });
15101
15154
  }
15102
15155
  $8tj43$add_to_version_info("ui", (0, $8db9a15135765c11$export$83d89fbfd8236492));
15103
- export { $a604a8ffa4e4c03f$export$e417c49320921907 as createDeparallelizedNoDropResource, $01c33966d9ddb108$export$f50b88e2a00918b5 as throw_globally, $40411f2ec772c376$export$9265e66f26f8e383 as ClassicSearchModal, $06fcd2a345efd24d$export$b0c55aa2e87c4be7 as SearchModalV2, $7fbaab3d3dafb4f5$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, $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, $56047603f9d212b6$export$e6fffe67d4cdd848 as makeSizeAccessor, $801e8845d3fa3653$export$94026ee33dbabc26 as ImageContainer, $74777e8fe65b3dcb$export$b69d0d92862de18b as SentryErrorBoundary, $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, $d5f1e6a0f9117286$export$79b1565500412d9b as general_modal_abstraction, $9783d437ad61594c$export$3b621d86b1566b2 as CrossIcon, $ca6ab5f08bd28bca$export$8be2714ec7f169ee as GenericSliderArrowButton, $50aebf5b445518eb$export$58e808b1db15d3bc as fetchDepictRecommendations, $f5f54892fd0c7d9f$export$de035477d6fef996 as QuickLinks, $f5f54892fd0c7d9f$export$5b7c3ce0ebe51f86 as BreadCrumbs, $fa332ea03168857c$export$b91cec6bdc6b32a1 as CategoryTitle, $702d7656a373973e$export$824dde41348efed1 as embedded_num_products, $160ea2b55d8772d2$export$c1a6b039e689a58e as get_listings, $f5f54892fd0c7d9f$export$f34314aa9505732e as DepictCategory, $f5f54892fd0c7d9f$export$e2bf8ce7779e827e as CategoryPage, $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 };
15156
+ export { $a604a8ffa4e4c03f$export$e417c49320921907 as createDeparallelizedNoDropResource, $01c33966d9ddb108$export$f50b88e2a00918b5 as throw_globally, $40411f2ec772c376$export$9265e66f26f8e383 as ClassicSearchModal, $06fcd2a345efd24d$export$b0c55aa2e87c4be7 as SearchModalV2, $7fbaab3d3dafb4f5$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, $56047603f9d212b6$export$e6fffe67d4cdd848 as makeSizeAccessor, $801e8845d3fa3653$export$94026ee33dbabc26 as ImageContainer, $74777e8fe65b3dcb$export$b69d0d92862de18b as SentryErrorBoundary, $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, $d5f1e6a0f9117286$export$79b1565500412d9b as general_modal_abstraction, $9783d437ad61594c$export$3b621d86b1566b2 as CrossIcon, $ca6ab5f08bd28bca$export$8be2714ec7f169ee as GenericSliderArrowButton, $50aebf5b445518eb$export$58e808b1db15d3bc as fetchDepictRecommendations, $f5f54892fd0c7d9f$export$de035477d6fef996 as QuickLinks, $f5f54892fd0c7d9f$export$5b7c3ce0ebe51f86 as BreadCrumbs, $fa332ea03168857c$export$b91cec6bdc6b32a1 as CategoryTitle, $702d7656a373973e$export$824dde41348efed1 as embedded_num_products, $160ea2b55d8772d2$export$c1a6b039e689a58e as get_listings, $f5f54892fd0c7d9f$export$f34314aa9505732e as DepictCategory, $f5f54892fd0c7d9f$export$e2bf8ce7779e827e as CategoryPage, $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 };
package/latest/index.cjs CHANGED
@@ -29,6 +29,8 @@ $parcel$export(module.exports, "decode_sorting", () => $1ab22f2cd39b3061$export$
29
29
  $parcel$export(module.exports, "shopifyContainedImageContextSymbol", () => $a33065cfed827fc0$export$d7b7ab832c20e2f4);
30
30
  $parcel$export(module.exports, "ListingProvider", () => $84798aaa863a4909$export$e68cff63f76bd15b);
31
31
  $parcel$export(module.exports, "useListing", () => $84798aaa863a4909$export$8d0c4fdbb05a2f2e);
32
+ $parcel$export(module.exports, "ProductCardIndexProvider", () => $129b9b9c010039d0$export$11354f017ddc9790);
33
+ $parcel$export(module.exports, "useProductCardIndex", () => $129b9b9c010039d0$export$e3faf4d95300054f);
32
34
  $parcel$export(module.exports, "ShopifyContainedImage", () => $a33065cfed827fc0$export$e4b984597b71e989);
33
35
  $parcel$export(module.exports, "SlidableItems", () => $a0e53f99354809d9$export$6649caad96ef8870);
34
36
  $parcel$export(module.exports, "make_accurate_width_accessor", () => $f13855d1b951b24a$export$ebdc3711f7e02ccd);
@@ -86,7 +88,7 @@ $parcel$export(module.exports, "defaultCategoryTitlePlugin", () => $a3280f0aad99
86
88
  $parcel$export(module.exports, "version", () => $b757f75811f3261f$export$83d89fbfd8236492);
87
89
  $parcel$export(module.exports, "SearchField", () => $c0a0659cf97e8eb2$export$316f6f283ae64765);
88
90
  /*! Depict.ai search and product listing SDK */
89
- const $b757f75811f3261f$export$83d89fbfd8236492 = "4.0.7";
91
+ const $b757f75811f3261f$export$83d89fbfd8236492 = "4.0.9";
90
92
  function $53df95e470b2f8d2$export$e417c49320921907(dependency, fetcher) {
91
93
  const [promiseOfCurrentFetcherRun, setPromiseOfCurrentFetcherRun] = $gVhhF$solidjs.createSignal();
92
94
  const deparallelizedFetcher = $gVhhF$depictaiutilishared.deparallelize_no_drop(async dependencyValue => {
@@ -429,6 +431,20 @@ function $5f7d55c710fd1bc2$var$unwrapping_helper(elements) {
429
431
  } else if (typeof elements == "function") result.push(...$5f7d55c710fd1bc2$var$unwrapping_helper(elements()));else if (elements != undefined && typeof elements != "boolean") result.push(elements);
430
432
  return result;
431
433
  }
434
+ const $129b9b9c010039d0$var$ProductCardIndexContext = /*@__PURE__*/$gVhhF$solidjs.createContext();
435
+ function $129b9b9c010039d0$export$11354f017ddc9790(props) {
436
+ return $gVhhF$solidjsweb.createComponent($129b9b9c010039d0$var$ProductCardIndexContext.Provider, {
437
+ get value() {
438
+ return props.index_;
439
+ },
440
+ get children() {
441
+ return props.children;
442
+ }
443
+ });
444
+ }
445
+ function $129b9b9c010039d0$export$e3faf4d95300054f() {
446
+ return $gVhhF$solidjs.useContext($129b9b9c010039d0$var$ProductCardIndexContext);
447
+ }
432
448
  let $a73063cc642f3e5f$var$printedCloneError = false;
433
449
  function $a73063cc642f3e5f$export$7f8bd308237ab5a5(get_displays_) {
434
450
  const displays_by_key_ = $gVhhF$solidjs.createMemo(() => {
@@ -482,9 +498,22 @@ function $a73063cc642f3e5f$export$43f0fb951fcb0c54({
482
498
  $gVhhF$depictaiutilishared.dlog("Can't clone display", display, " (uncloneable objects in it), make sure you don't mutate it in the template since we cache.", e);
483
499
  }
484
500
  }
485
- return product_card_template_(display, {
486
- set_on_index_change: fn => $gVhhF$solidjs.runWithOwner(owner, () => $gVhhF$solidjs.createEffect(() => fn(index())))
501
+ let renderingResult;
502
+ // Wrap the product card in a ProductCardIndexProvider so that the index is available to the product card
503
+ // This is wo we can do intelligent image loading in ShopifyContainedImage without shopify devs having to pass in the index
504
+ // We don't care about the return value of ProductCardIndexProvider because our rendering result might be a promise which solid doesn't support until it has gone through createResource
505
+ $129b9b9c010039d0$export$11354f017ddc9790({
506
+ index_: index,
507
+ get children() {
508
+ // This is the key - the functions called inside of the children getter of the provider are the one that have the context defined in their solid-internal Owner
509
+ renderingResult = product_card_template_(display, {
510
+ set_on_index_change: fn => $gVhhF$solidjs.runWithOwner(owner, () => $gVhhF$solidjs.createEffect(() => fn(index())))
511
+ });
512
+ return undefined; // just to satisfy the typing
513
+ }
487
514
  });
515
+ // renderingResult is guaranteed to be defined here (if rendering returned something) because the children getter of ProductCardIndexProvider is called synchronously (createRenderEffect is used solid-internally)
516
+ return renderingResult;
488
517
  });
489
518
  const node_accessor = $5f7d55c710fd1bc2$export$2f0cbfbb4354bb52(product_card_resource);
490
519
  $gVhhF$solidjs.createEffect(() => {
@@ -509,7 +538,8 @@ function $a73063cc642f3e5f$export$43f0fb951fcb0c54({
509
538
  });
510
539
  return [
511
540
  // Show content block before product card, so it's *at* that index
512
- possible_content_block, product_card_resource]; // https://github.com/solidjs/solid/releases/tag/v1.7.0
541
+ possible_content_block, node_accessor // Don't return product_card_resource as calling it could be creating the nodes which would mean we'd be double-creating the nodes,
542
+ ]; // Regarding the as unknown shenanigans: https://github.com/solidjs/solid/releases/tag/v1.7.0
513
543
  }
514
544
  });
515
545
  }
@@ -2400,6 +2430,33 @@ function $93304d59a9747aa6$export$94026ee33dbabc26(props) {
2400
2430
  return _el$;
2401
2431
  })();
2402
2432
  }
2433
+ let $3ea8e0af95b5b7d2$var$browserIsBugged = false;
2434
+ function $3ea8e0af95b5b7d2$export$2972b890694ced75(callback, {
2435
+ timeout: timeout
2436
+ }) {
2437
+ if ($3ea8e0af95b5b7d2$var$browserIsBugged) timeout /= 4;
2438
+ const cancel = () => {
2439
+ cancelIdleCallback(idleHandle);
2440
+ clearTimeout(racingTimeout);
2441
+ };
2442
+ const idleHandle = requestIdleCallback(deadline => {
2443
+ cancel();
2444
+ return callback(deadline);
2445
+ }, {
2446
+ timeout: timeout
2447
+ });
2448
+ const racingTimeout = setTimeout(() => {
2449
+ $3ea8e0af95b5b7d2$var$browserIsBugged = true;
2450
+ cancel();
2451
+ callback({
2452
+ didTimeout: false,
2453
+ timeRemaining() {
2454
+ return 500;
2455
+ }
2456
+ });
2457
+ }, timeout + 1000);
2458
+ return cancel;
2459
+ }
2403
2460
  function $19950faaac026e09$export$e6fffe67d4cdd848(whatToWatch) {
2404
2461
  const [size, setSize] = $gVhhF$solidjs.createSignal(0);
2405
2462
  const resizeObserver = new ResizeObserver($gVhhF$depictaiutilishared.catchify(records => {
@@ -2424,23 +2481,11 @@ function $19950faaac026e09$export$e6fffe67d4cdd848(whatToWatch) {
2424
2481
  }
2425
2482
  const $19950faaac026e09$var$onIdleFunctionsSymbol = /*@__PURE__*/Symbol("onIdleFunctions");
2426
2483
  const $19950faaac026e09$export$f8945274f08a3105 = /*@__PURE__*/Symbol("listingContextAspectRatios");
2484
+ const $19950faaac026e09$export$6066eb417ed2e9f7 = /*@__PURE__*/Symbol("listingContextAspectRatios");
2427
2485
  function $19950faaac026e09$export$6e5611bc7e57e477(props) {
2428
- // Enable reactive props
2429
- const otherOptions = $gVhhF$solidjs.createMemo(() => {
2430
- const cloned_props = {
2431
- ...props
2432
- };
2433
- delete cloned_props.resolutions;
2434
- // @ts-ignore
2435
- delete cloned_props.size;
2436
- // @ts-ignore
2437
- delete cloned_props.src;
2438
- return cloned_props;
2439
- });
2440
2486
  const src_options = $gVhhF$solidjs.createMemo(() => {
2441
- const src = new URL(props.src, location.origin);
2442
- const fallback_src = $19950faaac026e09$var$generateImageUrl(src, 400);
2443
- const srcset = $19950faaac026e09$var$make_srcset(src, props.resolutions || [64, 128, 256, 300, 400, 512, 640, 768, 1024, 1280, 1536, 2048, 2560, 3072, 3584, 4096]);
2487
+ const fallback_src = $19950faaac026e09$var$generateImageUrl(props.src, 400);
2488
+ const srcset = $19950faaac026e09$var$make_srcset(props.src, props.resolutions || [64, 128, 256, 300, 400, 512, 640, 768, 1024, 1280, 1536, 2048, 2560, 3072, 3584, 4096]);
2444
2489
  // The order here *might* matter - I've seen mobile safari always start with loading the 400px version when it was reversed
2445
2490
  return {
2446
2491
  srcset: srcset,
@@ -2449,19 +2494,35 @@ function $19950faaac026e09$export$6e5611bc7e57e477(props) {
2449
2494
  });
2450
2495
  // Work around https://github.com/solidjs/solid/issues/1828
2451
2496
  const img = new Image(); // Need to use new Image or browser might not start loading image before it's in the DOM
2497
+ const [, otherAttributes] = $gVhhF$solidjs.splitProps(props, ["resolutions", "size", "src", "srcSet", "loading"]);
2452
2498
  const [hasSetSize, setHasSetSize] = $gVhhF$solidjs.createSignal(false);
2453
2499
  const [hasDecoded, setHasDecoded] = $gVhhF$solidjs.createSignal(false);
2500
+ const productCardIndexAccessor = $129b9b9c010039d0$export$e3faf4d95300054f();
2454
2501
  const sizePX = $gVhhF$solidjs.createMemo(() => `${props.size()}px`); // props.size could be a getter that expects a cleanup so get it in this memo instead of where we set img.sizes
2455
2502
  const listingContext = $84798aaa863a4909$export$8d0c4fdbb05a2f2e();
2503
+ const isPrioritisedImage = $gVhhF$solidjs.createMemo(() => productCardIndexAccessor?.() < 8);
2504
+ const shouldActuallyEnableLazyLoading = $gVhhF$solidjs.createMemo(() => {
2505
+ const {
2506
+ loading: loading
2507
+ } = props;
2508
+ if (loading === "force-lazy") return true;
2509
+ return loading === "lazy" && !isPrioritisedImage();
2510
+ });
2511
+ const modifiedOtherAttributes = $gVhhF$solidjs.mergeProps(otherAttributes, {
2512
+ get loading() {
2513
+ return shouldActuallyEnableLazyLoading() ? "lazy" : undefined;
2514
+ }
2515
+ });
2456
2516
  // Batch idle callbacks so that MutationObserver can batch the resulting mutations better, so we don't lose tons of CPU time to MutationObservers doing lots of things for each image
2457
2517
  // Happened on singular, they have some weird observer (+we also have one but ours is at least 3x more efficient)
2458
2518
  const executeWhenIdleBatched = fn => {
2459
2519
  if (typeof requestIdleCallback !== "function") return setTimeout(fn); // Old browsers don't get optimisation
2520
+ if ($gVhhF$solidjs.untrack(isPrioritisedImage)) return fn(); // If we're one of the first 8 images, execute the callbacks immediately
2460
2521
  const existingStack = listingContext?.[$19950faaac026e09$var$onIdleFunctionsSymbol];
2461
2522
  if (existingStack) return existingStack.add(fn);
2462
2523
  const newStack = new Set([fn]);
2463
2524
  if (listingContext) listingContext[$19950faaac026e09$var$onIdleFunctionsSymbol] = newStack;
2464
- const processStackWhenIdle = () => requestIdleCallback(deadline => {
2525
+ const processStackWhenIdle = () => $3ea8e0af95b5b7d2$export$2972b890694ced75($gVhhF$depictaiutilishared.catchify(deadline => {
2465
2526
  const start = performance.now();
2466
2527
  const thirdDeadlineTime = deadline.timeRemaining() / 3; // observers coming after this take up 2-3x the time so don't use all of it
2467
2528
  for (const fn of newStack) {
@@ -2476,7 +2537,7 @@ function $19950faaac026e09$export$6e5611bc7e57e477(props) {
2476
2537
  }
2477
2538
  // Stack is empty
2478
2539
  if (listingContext) delete listingContext[$19950faaac026e09$var$onIdleFunctionsSymbol];
2479
- }, {
2540
+ }), {
2480
2541
  timeout: 15000
2481
2542
  } // long timeout, better to not have images than to freeze the browser. But also we don't want to confuse user why no iamges are loading
2482
2543
  );
@@ -2490,7 +2551,8 @@ function $19950faaac026e09$export$6e5611bc7e57e477(props) {
2490
2551
  img.classList.add("s-responsive-image");
2491
2552
  if (listingContext) {
2492
2553
  let prevValue;
2493
- const aspectRatios = listingContext[$19950faaac026e09$export$f8945274f08a3105] ||= new (0, $gVhhF$depictaiutilishared.ListenableSet)();
2554
+ const aspectRatios = listingContext[$19950faaac026e09$export$f8945274f08a3105] ||= new Set();
2555
+ const [, setMostPrevalentAspectRatio] = listingContext[$19950faaac026e09$export$6066eb417ed2e9f7] ||= $gVhhF$solidjs.createSignal();
2494
2556
  img.addEventListener("load", $gVhhF$depictaiutilishared.catchify(() => {
2495
2557
  // Save our aspect ratio whenever it changes, so that we can base the containers on the most dominant aspect ratio, used in SearchModalV2
2496
2558
  const aspectRatio_ = img.naturalWidth / img.naturalHeight;
@@ -2500,13 +2562,19 @@ function $19950faaac026e09$export$6e5611bc7e57e477(props) {
2500
2562
  } : undefined;
2501
2563
  if (newValue) aspectRatios.add(newValue);
2502
2564
  prevValue = newValue;
2565
+ // Do all calculations resulting of an update directly, for performance
2566
+ const asArray = [...aspectRatios].map(({
2567
+ aspectRatio_: aspectRatio_
2568
+ }) => aspectRatio_);
2569
+ const mostPrevalentAspectRatio = $gVhhF$depictaiutilishared.findMostFrequentItem(asArray);
2570
+ setMostPrevalentAspectRatio(mostPrevalentAspectRatio);
2503
2571
  }));
2504
2572
  $gVhhF$solidjs.onCleanup(() => prevValue && aspectRatios.delete(prevValue));
2505
2573
  }
2506
2574
  $gVhhF$solidjs.onCleanup(() => gotCleanedUp = true);
2507
- $gVhhF$solidjsweb.spread(img, $gVhhF$solidjs.mergeProps(otherOptions), false, true);
2575
+ $gVhhF$solidjsweb.spread(img, $gVhhF$solidjs.mergeProps(modifiedOtherAttributes), false, true);
2508
2576
  $gVhhF$solidjs.createEffect(() => {
2509
- if (!props.size()) return; // wait until we have a size
2577
+ if (!props.size()) return; // wait until we have a size, run every time the size changes
2510
2578
  if (timeoutSet) return;
2511
2579
  const handler = $gVhhF$depictaiutilishared.catchify(() => {
2512
2580
  if (gotCleanedUp) return;
@@ -2531,7 +2599,7 @@ function $19950faaac026e09$export$6e5611bc7e57e477(props) {
2531
2599
  // We can do this because there has to be a container around us giving us a size
2532
2600
  // No need to listen if we're already in the DOM
2533
2601
  if (hasDecodedFastPath) return;
2534
- if (props.loading === "lazy") {
2602
+ if (shouldActuallyEnableLazyLoading()) {
2535
2603
  // For lazy loading there's no decoding to wait for as it only occurs when the image is visible
2536
2604
  // Make sure src is set before we put the image into the DOM though so no broken image symbol is shown
2537
2605
  setHasDecoded(true);
@@ -2558,9 +2626,10 @@ function $19950faaac026e09$var$make_srcset(url, resolutions) {
2558
2626
  return resolutions.map(width => `${$19950faaac026e09$var$generateImageUrl(url, width)} ${width}w`).join(", ");
2559
2627
  }
2560
2628
  function $19950faaac026e09$var$generateImageUrl(url, width) {
2561
- // This function is quite slow, we maybe could do string concat with encodeURIComponent instead if shopify handles double width params well?
2562
- url.searchParams.set("width", width);
2563
- return url.href;
2629
+ // Even just creating one `URL` object per image src and then setting the search parameter is quite slow (0.25ms to set the width param)
2630
+ // We're making the assumptions that the url has already at least one query parameter and that the image resizing service will choose the last one out of a duplicate width parameter (shopify's does)
2631
+ // That way we can just to string concatenation which is insanely fast
2632
+ return url + "&width=" + encodeURIComponent(width);
2564
2633
  }
2565
2634
  const $a33065cfed827fc0$var$backupSizeSignal = /*@__PURE__*/$gVhhF$solidjs.createSignal();
2566
2635
  const $a33065cfed827fc0$export$d7b7ab832c20e2f4 = /*@__PURE__*/Symbol("ShopifyContainedImage");
@@ -2570,40 +2639,25 @@ function $a33065cfed827fc0$export$e4b984597b71e989(props) {
2570
2639
  // create a signal that's the same for all items in this listing
2571
2640
  context[$a33065cfed827fc0$export$d7b7ab832c20e2f4] = $gVhhF$solidjs.createSignal();
2572
2641
  const [currentImageSize, setCurrentImageSize] = context?.[$a33065cfed827fc0$export$d7b7ab832c20e2f4] || $a33065cfed827fc0$var$backupSizeSignal; // use global fallback signal (might lead to blurry images) if no context is available
2573
- const aspectRatiosSet = context ?
2574
- // If the context exists we have to create the set here as getting it here would be too late when it's created by ShopifyResponsiveImg below
2575
- context[(0, $19950faaac026e09$export$f8945274f08a3105)] ||= new (0, $gVhhF$depictaiutilishared.ListenableSet)() : undefined;
2576
- const [aspectRatios, setAspectRatios] = $gVhhF$solidjs.createSignal(aspectRatiosSet, {
2577
- equals: false
2578
- });
2579
- const aspectRatioToUse = $gVhhF$solidjs.createMemo(() => {
2580
- const aspectRatiosSet = aspectRatios(); // This signal "changes" to the same set every time the set changes, so we can use it as a dependency here
2581
- useMostPrevalentAspectRatio: {
2582
- if (!aspectRatiosSet || !props.autoAdjustAspectRatio) break useMostPrevalentAspectRatio;
2583
- // Get the aspect ratio that most of the loaded images inside the ListingProvider we are, load
2584
- const asArray = [...aspectRatiosSet].map(({
2585
- aspectRatio_: aspectRatio_
2586
- }) => aspectRatio_);
2587
- const mostPrevalentAspectRatio = $gVhhF$depictaiutilishared.findMostFrequentItem(asArray);
2588
- if (mostPrevalentAspectRatio) return `var(${(0, $6f604560873e4f69$export$8a2234b5b1a5ebd4)}, ${mostPrevalentAspectRatio})`;
2589
- }
2590
- return props.aspectRatio;
2591
- });
2592
- const container = $gVhhF$solidjsweb.createComponent((0, $93304d59a9747aa6$export$94026ee33dbabc26), {
2593
- get aspectRatio() {
2594
- return aspectRatioToUse();
2595
- },
2596
- get ["class"]() {
2642
+ const [mostPrevalentAspectRatio] = context ?
2643
+ // If the context exists we have to create the signal here as getting it here would be too late when it's created by ShopifyResponsiveImg below
2644
+ context[(0, $19950faaac026e09$export$6066eb417ed2e9f7)] ||= $gVhhF$solidjs.createSignal() : [];
2645
+ const container = $93304d59a9747aa6$export$94026ee33dbabc26({
2646
+ // Write getters manually instead of using JSX, so we can do more complex logic in the aspectRatio getter without increasing bundle size
2647
+ get class() {
2597
2648
  return props.class;
2649
+ },
2650
+ get aspectRatio() {
2651
+ if (props.autoAdjustAspectRatio) {
2652
+ const targetRatio = mostPrevalentAspectRatio?.();
2653
+ if (targetRatio != undefined) return `var(${(0, $6f604560873e4f69$export$8a2234b5b1a5ebd4)}, ${targetRatio})`;
2654
+ }
2655
+ return props.aspectRatio;
2598
2656
  }
2599
2657
  });
2600
2658
  const owner = $gVhhF$solidjs.getOwner();
2601
2659
  let createdSizeAccessor = false;
2602
2660
  let wasCleanedUp = false;
2603
- for (const event of ["add", "delete"]) {
2604
- aspectRatiosSet?.addEventListener(event, () => setAspectRatios(aspectRatiosSet));
2605
- $gVhhF$solidjs.onCleanup(() => aspectRatiosSet?.removeEventListener(event, () => setAspectRatios(aspectRatiosSet)));
2606
- }
2607
2661
  $gVhhF$solidjs.createEffect(() => {
2608
2662
  if (currentImageSize() || wasCleanedUp) return; // We get into the effect when onCleanup is called if we don't have wasCleanedUp
2609
2663
  // ensure we always have a size accessor