@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.cjs +112 -57
- package/ES10/index.d.ts +17 -4
- package/ES10/index.js +116 -63
- package/latest/index.cjs +110 -56
- package/latest/index.d.ts +17 -4
- package/latest/index.js +114 -62
- package/package.json +1 -1
- package/server/ES10/index.cjs +112 -57
- package/server/ES10/index.d.ts +17 -4
- package/server/ES10/index.js +116 -63
- package/server/latest/index.cjs +110 -56
- package/server/latest/index.d.ts +17 -4
- package/server/latest/index.js +114 -62
package/ES10/index.cjs
CHANGED
|
@@ -35,6 +35,8 @@ $parcel$export(module.exports, "decode_sorting", () => $a68b73fd7ba0853f$export$
|
|
|
35
35
|
$parcel$export(module.exports, "shopifyContainedImageContextSymbol", () => $28535bb7671c63d1$export$d7b7ab832c20e2f4);
|
|
36
36
|
$parcel$export(module.exports, "ListingProvider", () => $d067f3a30f047b41$export$e68cff63f76bd15b);
|
|
37
37
|
$parcel$export(module.exports, "useListing", () => $d067f3a30f047b41$export$8d0c4fdbb05a2f2e);
|
|
38
|
+
$parcel$export(module.exports, "ProductCardIndexProvider", () => $b54645378dfc7280$export$11354f017ddc9790);
|
|
39
|
+
$parcel$export(module.exports, "useProductCardIndex", () => $b54645378dfc7280$export$e3faf4d95300054f);
|
|
38
40
|
$parcel$export(module.exports, "ShopifyContainedImage", () => $28535bb7671c63d1$export$e4b984597b71e989);
|
|
39
41
|
$parcel$export(module.exports, "SlidableItems", () => $ad8ec7729fffeb9c$export$6649caad96ef8870);
|
|
40
42
|
$parcel$export(module.exports, "make_accurate_width_accessor", () => $c387d7f1d9fb66c0$export$ebdc3711f7e02ccd);
|
|
@@ -92,7 +94,7 @@ $parcel$export(module.exports, "defaultCategoryTitlePlugin", () => $33eed84f447a
|
|
|
92
94
|
$parcel$export(module.exports, "version", () => $aa1938dec50d6c12$export$83d89fbfd8236492);
|
|
93
95
|
$parcel$export(module.exports, "SearchField", () => $98aef9965764903d$export$316f6f283ae64765);
|
|
94
96
|
/*! Depict.ai search and product listing SDK */
|
|
95
|
-
const $aa1938dec50d6c12$export$83d89fbfd8236492 = "4.0.
|
|
97
|
+
const $aa1938dec50d6c12$export$83d89fbfd8236492 = "4.0.9";
|
|
96
98
|
function $a28000bc10de28ad$export$e417c49320921907(dependency, fetcher) {
|
|
97
99
|
const [promiseOfCurrentFetcherRun, setPromiseOfCurrentFetcherRun] = $52FdA$solidjs.createSignal();
|
|
98
100
|
const deparallelizedFetcher = $52FdA$depictaiutilishared.deparallelize_no_drop(async dependencyValue => {
|
|
@@ -451,6 +453,20 @@ function $e82d0d417fa613e8$var$unwrapping_helper(elements) {
|
|
|
451
453
|
} else if (typeof elements == "function") result.push(...$e82d0d417fa613e8$var$unwrapping_helper(elements()));else if (elements != undefined && typeof elements != "boolean") result.push(elements);
|
|
452
454
|
return result;
|
|
453
455
|
}
|
|
456
|
+
const $b54645378dfc7280$var$ProductCardIndexContext = /*@__PURE__*/$52FdA$solidjs.createContext();
|
|
457
|
+
function $b54645378dfc7280$export$11354f017ddc9790(props) {
|
|
458
|
+
return $52FdA$solidjsweb.createComponent($b54645378dfc7280$var$ProductCardIndexContext.Provider, {
|
|
459
|
+
get value() {
|
|
460
|
+
return props.index_;
|
|
461
|
+
},
|
|
462
|
+
get children() {
|
|
463
|
+
return props.children;
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
function $b54645378dfc7280$export$e3faf4d95300054f() {
|
|
468
|
+
return $52FdA$solidjs.useContext($b54645378dfc7280$var$ProductCardIndexContext);
|
|
469
|
+
}
|
|
454
470
|
let $76012c4468a53d1f$var$printedCloneError = false;
|
|
455
471
|
function $76012c4468a53d1f$export$7f8bd308237ab5a5(get_displays_) {
|
|
456
472
|
const displays_by_key_ = $52FdA$solidjs.createMemo(() => {
|
|
@@ -508,9 +524,22 @@ function $76012c4468a53d1f$export$43f0fb951fcb0c54(_ref) {
|
|
|
508
524
|
$52FdA$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);
|
|
509
525
|
}
|
|
510
526
|
}
|
|
511
|
-
|
|
512
|
-
|
|
527
|
+
let renderingResult;
|
|
528
|
+
// Wrap the product card in a ProductCardIndexProvider so that the index is available to the product card
|
|
529
|
+
// This is wo we can do intelligent image loading in ShopifyContainedImage without shopify devs having to pass in the index
|
|
530
|
+
// 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
|
|
531
|
+
$b54645378dfc7280$export$11354f017ddc9790({
|
|
532
|
+
index_: index,
|
|
533
|
+
get children() {
|
|
534
|
+
// 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
|
|
535
|
+
renderingResult = product_card_template_(display, {
|
|
536
|
+
set_on_index_change: fn => $52FdA$solidjs.runWithOwner(owner, () => $52FdA$solidjs.createEffect(() => fn(index())))
|
|
537
|
+
});
|
|
538
|
+
return undefined; // just to satisfy the typing
|
|
539
|
+
}
|
|
513
540
|
});
|
|
541
|
+
// 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)
|
|
542
|
+
return renderingResult;
|
|
514
543
|
});
|
|
515
544
|
const node_accessor = $e82d0d417fa613e8$export$2f0cbfbb4354bb52(product_card_resource);
|
|
516
545
|
$52FdA$solidjs.createEffect(() => {
|
|
@@ -535,7 +564,8 @@ function $76012c4468a53d1f$export$43f0fb951fcb0c54(_ref) {
|
|
|
535
564
|
});
|
|
536
565
|
return [
|
|
537
566
|
// Show content block before product card, so it's *at* that index
|
|
538
|
-
possible_content_block,
|
|
567
|
+
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,
|
|
568
|
+
]; // Regarding the as unknown shenanigans: https://github.com/solidjs/solid/releases/tag/v1.7.0
|
|
539
569
|
}
|
|
540
570
|
});
|
|
541
571
|
}
|
|
@@ -2507,6 +2537,34 @@ function $ce467edb5343cfcd$export$94026ee33dbabc26(props) {
|
|
|
2507
2537
|
return _el$;
|
|
2508
2538
|
})();
|
|
2509
2539
|
}
|
|
2540
|
+
let $e4e98e5080f4386e$var$browserIsBugged = false;
|
|
2541
|
+
function $e4e98e5080f4386e$export$2972b890694ced75(callback, _ref) {
|
|
2542
|
+
let {
|
|
2543
|
+
timeout: timeout
|
|
2544
|
+
} = _ref;
|
|
2545
|
+
if ($e4e98e5080f4386e$var$browserIsBugged) timeout /= 4;
|
|
2546
|
+
const cancel = () => {
|
|
2547
|
+
cancelIdleCallback(idleHandle);
|
|
2548
|
+
clearTimeout(racingTimeout);
|
|
2549
|
+
};
|
|
2550
|
+
const idleHandle = requestIdleCallback(deadline => {
|
|
2551
|
+
cancel();
|
|
2552
|
+
return callback(deadline);
|
|
2553
|
+
}, {
|
|
2554
|
+
timeout: timeout
|
|
2555
|
+
});
|
|
2556
|
+
const racingTimeout = setTimeout(() => {
|
|
2557
|
+
$e4e98e5080f4386e$var$browserIsBugged = true;
|
|
2558
|
+
cancel();
|
|
2559
|
+
callback({
|
|
2560
|
+
didTimeout: false,
|
|
2561
|
+
timeRemaining() {
|
|
2562
|
+
return 500;
|
|
2563
|
+
}
|
|
2564
|
+
});
|
|
2565
|
+
}, timeout + 1000);
|
|
2566
|
+
return cancel;
|
|
2567
|
+
}
|
|
2510
2568
|
function $858fdcf73148519f$export$e6fffe67d4cdd848(whatToWatch) {
|
|
2511
2569
|
const [size, setSize] = $52FdA$solidjs.createSignal(0);
|
|
2512
2570
|
const resizeObserver = new ResizeObserver($52FdA$depictaiutilishared.catchify(records => {
|
|
@@ -2534,23 +2592,11 @@ function $858fdcf73148519f$export$e6fffe67d4cdd848(whatToWatch) {
|
|
|
2534
2592
|
}
|
|
2535
2593
|
const $858fdcf73148519f$var$onIdleFunctionsSymbol = /*@__PURE__*/Symbol("onIdleFunctions");
|
|
2536
2594
|
const $858fdcf73148519f$export$f8945274f08a3105 = /*@__PURE__*/Symbol("listingContextAspectRatios");
|
|
2595
|
+
const $858fdcf73148519f$export$6066eb417ed2e9f7 = /*@__PURE__*/Symbol("listingContextAspectRatios");
|
|
2537
2596
|
function $858fdcf73148519f$export$6e5611bc7e57e477(props) {
|
|
2538
|
-
// Enable reactive props
|
|
2539
|
-
const otherOptions = $52FdA$solidjs.createMemo(() => {
|
|
2540
|
-
const cloned_props = {
|
|
2541
|
-
...props
|
|
2542
|
-
};
|
|
2543
|
-
delete cloned_props.resolutions;
|
|
2544
|
-
// @ts-ignore
|
|
2545
|
-
delete cloned_props.size;
|
|
2546
|
-
// @ts-ignore
|
|
2547
|
-
delete cloned_props.src;
|
|
2548
|
-
return cloned_props;
|
|
2549
|
-
});
|
|
2550
2597
|
const src_options = $52FdA$solidjs.createMemo(() => {
|
|
2551
|
-
const
|
|
2552
|
-
const
|
|
2553
|
-
const srcset = $858fdcf73148519f$var$make_srcset(src, props.resolutions || [64, 128, 256, 300, 400, 512, 640, 768, 1024, 1280, 1536, 2048, 2560, 3072, 3584, 4096]);
|
|
2598
|
+
const fallback_src = $858fdcf73148519f$var$generateImageUrl(props.src, 400);
|
|
2599
|
+
const srcset = $858fdcf73148519f$var$make_srcset(props.src, props.resolutions || [64, 128, 256, 300, 400, 512, 640, 768, 1024, 1280, 1536, 2048, 2560, 3072, 3584, 4096]);
|
|
2554
2600
|
// The order here *might* matter - I've seen mobile safari always start with loading the 400px version when it was reversed
|
|
2555
2601
|
return {
|
|
2556
2602
|
srcset: srcset,
|
|
@@ -2559,19 +2605,35 @@ function $858fdcf73148519f$export$6e5611bc7e57e477(props) {
|
|
|
2559
2605
|
});
|
|
2560
2606
|
// Work around https://github.com/solidjs/solid/issues/1828
|
|
2561
2607
|
const img = new Image(); // Need to use new Image or browser might not start loading image before it's in the DOM
|
|
2608
|
+
const [, otherAttributes] = $52FdA$solidjs.splitProps(props, ["resolutions", "size", "src", "srcSet", "loading"]);
|
|
2562
2609
|
const [hasSetSize, setHasSetSize] = $52FdA$solidjs.createSignal(false);
|
|
2563
2610
|
const [hasDecoded, setHasDecoded] = $52FdA$solidjs.createSignal(false);
|
|
2611
|
+
const productCardIndexAccessor = $b54645378dfc7280$export$e3faf4d95300054f();
|
|
2564
2612
|
const sizePX = $52FdA$solidjs.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
|
|
2565
2613
|
const listingContext = $d067f3a30f047b41$export$8d0c4fdbb05a2f2e();
|
|
2614
|
+
const isPrioritisedImage = $52FdA$solidjs.createMemo(() => (productCardIndexAccessor === null || productCardIndexAccessor === void 0 ? void 0 : productCardIndexAccessor()) < 8);
|
|
2615
|
+
const shouldActuallyEnableLazyLoading = $52FdA$solidjs.createMemo(() => {
|
|
2616
|
+
const {
|
|
2617
|
+
loading: loading
|
|
2618
|
+
} = props;
|
|
2619
|
+
if (loading === "force-lazy") return true;
|
|
2620
|
+
return loading === "lazy" && !isPrioritisedImage();
|
|
2621
|
+
});
|
|
2622
|
+
const modifiedOtherAttributes = $52FdA$solidjs.mergeProps(otherAttributes, {
|
|
2623
|
+
get loading() {
|
|
2624
|
+
return shouldActuallyEnableLazyLoading() ? "lazy" : undefined;
|
|
2625
|
+
}
|
|
2626
|
+
});
|
|
2566
2627
|
// 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
|
|
2567
2628
|
// Happened on singular, they have some weird observer (+we also have one but ours is at least 3x more efficient)
|
|
2568
2629
|
const executeWhenIdleBatched = fn => {
|
|
2569
2630
|
if (typeof requestIdleCallback !== "function") return setTimeout(fn); // Old browsers don't get optimisation
|
|
2631
|
+
if ($52FdA$solidjs.untrack(isPrioritisedImage)) return fn(); // If we're one of the first 8 images, execute the callbacks immediately
|
|
2570
2632
|
const existingStack = listingContext === null || listingContext === void 0 ? void 0 : listingContext[$858fdcf73148519f$var$onIdleFunctionsSymbol];
|
|
2571
2633
|
if (existingStack) return existingStack.add(fn);
|
|
2572
2634
|
const newStack = new Set([fn]);
|
|
2573
2635
|
if (listingContext) listingContext[$858fdcf73148519f$var$onIdleFunctionsSymbol] = newStack;
|
|
2574
|
-
const processStackWhenIdle = () =>
|
|
2636
|
+
const processStackWhenIdle = () => $e4e98e5080f4386e$export$2972b890694ced75($52FdA$depictaiutilishared.catchify(deadline => {
|
|
2575
2637
|
const start = performance.now();
|
|
2576
2638
|
const thirdDeadlineTime = deadline.timeRemaining() / 3; // observers coming after this take up 2-3x the time so don't use all of it
|
|
2577
2639
|
for (const fn of newStack) {
|
|
@@ -2586,7 +2648,7 @@ function $858fdcf73148519f$export$6e5611bc7e57e477(props) {
|
|
|
2586
2648
|
}
|
|
2587
2649
|
// Stack is empty
|
|
2588
2650
|
if (listingContext) delete listingContext[$858fdcf73148519f$var$onIdleFunctionsSymbol];
|
|
2589
|
-
}, {
|
|
2651
|
+
}), {
|
|
2590
2652
|
timeout: 15000
|
|
2591
2653
|
} // 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
|
|
2592
2654
|
);
|
|
@@ -2600,7 +2662,8 @@ function $858fdcf73148519f$export$6e5611bc7e57e477(props) {
|
|
|
2600
2662
|
img.classList.add("s-responsive-image");
|
|
2601
2663
|
if (listingContext) {
|
|
2602
2664
|
let prevValue;
|
|
2603
|
-
const aspectRatios = listingContext[$858fdcf73148519f$export$f8945274f08a3105] || (listingContext[$858fdcf73148519f$export$f8945274f08a3105] = new (
|
|
2665
|
+
const aspectRatios = listingContext[$858fdcf73148519f$export$f8945274f08a3105] || (listingContext[$858fdcf73148519f$export$f8945274f08a3105] = new Set());
|
|
2666
|
+
const [, setMostPrevalentAspectRatio] = listingContext[$858fdcf73148519f$export$6066eb417ed2e9f7] || (listingContext[$858fdcf73148519f$export$6066eb417ed2e9f7] = $52FdA$solidjs.createSignal());
|
|
2604
2667
|
img.addEventListener("load", $52FdA$depictaiutilishared.catchify(() => {
|
|
2605
2668
|
// Save our aspect ratio whenever it changes, so that we can base the containers on the most dominant aspect ratio, used in SearchModalV2
|
|
2606
2669
|
const aspectRatio_ = img.naturalWidth / img.naturalHeight;
|
|
@@ -2610,13 +2673,22 @@ function $858fdcf73148519f$export$6e5611bc7e57e477(props) {
|
|
|
2610
2673
|
} : undefined;
|
|
2611
2674
|
if (newValue) aspectRatios.add(newValue);
|
|
2612
2675
|
prevValue = newValue;
|
|
2676
|
+
// Do all calculations resulting of an update directly, for performance
|
|
2677
|
+
const asArray = [...aspectRatios].map(_ref2 => {
|
|
2678
|
+
let {
|
|
2679
|
+
aspectRatio_: aspectRatio_
|
|
2680
|
+
} = _ref2;
|
|
2681
|
+
return aspectRatio_;
|
|
2682
|
+
});
|
|
2683
|
+
const mostPrevalentAspectRatio = $52FdA$depictaiutilishared.findMostFrequentItem(asArray);
|
|
2684
|
+
setMostPrevalentAspectRatio(mostPrevalentAspectRatio);
|
|
2613
2685
|
}));
|
|
2614
2686
|
$52FdA$solidjs.onCleanup(() => prevValue && aspectRatios.delete(prevValue));
|
|
2615
2687
|
}
|
|
2616
2688
|
$52FdA$solidjs.onCleanup(() => gotCleanedUp = true);
|
|
2617
|
-
$52FdA$solidjsweb.spread(img, $52FdA$solidjs.mergeProps(
|
|
2689
|
+
$52FdA$solidjsweb.spread(img, $52FdA$solidjs.mergeProps(modifiedOtherAttributes), false, true);
|
|
2618
2690
|
$52FdA$solidjs.createEffect(() => {
|
|
2619
|
-
if (!props.size()) return; // wait until we have a size
|
|
2691
|
+
if (!props.size()) return; // wait until we have a size, run every time the size changes
|
|
2620
2692
|
if (timeoutSet) return;
|
|
2621
2693
|
const handler = $52FdA$depictaiutilishared.catchify(() => {
|
|
2622
2694
|
if (gotCleanedUp) return;
|
|
@@ -2641,7 +2713,7 @@ function $858fdcf73148519f$export$6e5611bc7e57e477(props) {
|
|
|
2641
2713
|
// We can do this because there has to be a container around us giving us a size
|
|
2642
2714
|
// No need to listen if we're already in the DOM
|
|
2643
2715
|
if (hasDecodedFastPath) return;
|
|
2644
|
-
if (
|
|
2716
|
+
if (shouldActuallyEnableLazyLoading()) {
|
|
2645
2717
|
// For lazy loading there's no decoding to wait for as it only occurs when the image is visible
|
|
2646
2718
|
// Make sure src is set before we put the image into the DOM though so no broken image symbol is shown
|
|
2647
2719
|
setHasDecoded(true);
|
|
@@ -2668,9 +2740,10 @@ function $858fdcf73148519f$var$make_srcset(url, resolutions) {
|
|
|
2668
2740
|
return resolutions.map(width => "".concat($858fdcf73148519f$var$generateImageUrl(url, width), " ").concat(width, "w")).join(", ");
|
|
2669
2741
|
}
|
|
2670
2742
|
function $858fdcf73148519f$var$generateImageUrl(url, width) {
|
|
2671
|
-
//
|
|
2672
|
-
url
|
|
2673
|
-
|
|
2743
|
+
// 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)
|
|
2744
|
+
// 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)
|
|
2745
|
+
// That way we can just to string concatenation which is insanely fast
|
|
2746
|
+
return url + "&width=" + encodeURIComponent(width);
|
|
2674
2747
|
}
|
|
2675
2748
|
const $28535bb7671c63d1$var$backupSizeSignal = /*@__PURE__*/$52FdA$solidjs.createSignal();
|
|
2676
2749
|
const $28535bb7671c63d1$export$d7b7ab832c20e2f4 = /*@__PURE__*/Symbol("ShopifyContainedImage");
|
|
@@ -2680,41 +2753,23 @@ function $28535bb7671c63d1$export$e4b984597b71e989(props) {
|
|
|
2680
2753
|
// create a signal that's the same for all items in this listing
|
|
2681
2754
|
context[$28535bb7671c63d1$export$d7b7ab832c20e2f4] = $52FdA$solidjs.createSignal();
|
|
2682
2755
|
const [currentImageSize, setCurrentImageSize] = (context === null || context === void 0 ? void 0 : context[$28535bb7671c63d1$export$d7b7ab832c20e2f4]) || $28535bb7671c63d1$var$backupSizeSignal; // use global fallback signal (might lead to blurry images) if no context is available
|
|
2683
|
-
const
|
|
2684
|
-
const
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
const aspectRatioToUse = $52FdA$solidjs.createMemo(() => {
|
|
2688
|
-
const aspectRatiosSet = aspectRatios(); // This signal "changes" to the same set every time the set changes, so we can use it as a dependency here
|
|
2689
|
-
useMostPrevalentAspectRatio: {
|
|
2690
|
-
if (!aspectRatiosSet || !props.autoAdjustAspectRatio) break useMostPrevalentAspectRatio;
|
|
2691
|
-
// Get the aspect ratio that most of the loaded images inside the ListingProvider we are, load
|
|
2692
|
-
const asArray = [...aspectRatiosSet].map(_ref => {
|
|
2693
|
-
let {
|
|
2694
|
-
aspectRatio_: aspectRatio_
|
|
2695
|
-
} = _ref;
|
|
2696
|
-
return aspectRatio_;
|
|
2697
|
-
});
|
|
2698
|
-
const mostPrevalentAspectRatio = $52FdA$depictaiutilishared.findMostFrequentItem(asArray);
|
|
2699
|
-
if (mostPrevalentAspectRatio) return "var(".concat((0, $c0cf6af094336798$export$8a2234b5b1a5ebd4), ", ").concat(mostPrevalentAspectRatio, ")");
|
|
2700
|
-
}
|
|
2701
|
-
return props.aspectRatio;
|
|
2702
|
-
});
|
|
2703
|
-
const container = $52FdA$solidjsweb.createComponent((0, $ce467edb5343cfcd$export$94026ee33dbabc26), {
|
|
2704
|
-
get aspectRatio() {
|
|
2705
|
-
return aspectRatioToUse();
|
|
2706
|
-
},
|
|
2707
|
-
get ["class"]() {
|
|
2756
|
+
const [mostPrevalentAspectRatio] = context ? context[(0, $858fdcf73148519f$export$6066eb417ed2e9f7)] || (context[(0, $858fdcf73148519f$export$6066eb417ed2e9f7)] = $52FdA$solidjs.createSignal()) : [];
|
|
2757
|
+
const container = $ce467edb5343cfcd$export$94026ee33dbabc26({
|
|
2758
|
+
// Write getters manually instead of using JSX, so we can do more complex logic in the aspectRatio getter without increasing bundle size
|
|
2759
|
+
get class() {
|
|
2708
2760
|
return props.class;
|
|
2761
|
+
},
|
|
2762
|
+
get aspectRatio() {
|
|
2763
|
+
if (props.autoAdjustAspectRatio) {
|
|
2764
|
+
const targetRatio = mostPrevalentAspectRatio === null || mostPrevalentAspectRatio === void 0 ? void 0 : mostPrevalentAspectRatio();
|
|
2765
|
+
if (targetRatio != undefined) return "var(".concat((0, $c0cf6af094336798$export$8a2234b5b1a5ebd4), ", ").concat(targetRatio, ")");
|
|
2766
|
+
}
|
|
2767
|
+
return props.aspectRatio;
|
|
2709
2768
|
}
|
|
2710
2769
|
});
|
|
2711
2770
|
const owner = $52FdA$solidjs.getOwner();
|
|
2712
2771
|
let createdSizeAccessor = false;
|
|
2713
2772
|
let wasCleanedUp = false;
|
|
2714
|
-
for (const event of ["add", "delete"]) {
|
|
2715
|
-
aspectRatiosSet === null || aspectRatiosSet === void 0 || aspectRatiosSet.addEventListener(event, () => setAspectRatios(aspectRatiosSet));
|
|
2716
|
-
$52FdA$solidjs.onCleanup(() => aspectRatiosSet === null || aspectRatiosSet === void 0 ? void 0 : aspectRatiosSet.removeEventListener(event, () => setAspectRatios(aspectRatiosSet)));
|
|
2717
|
-
}
|
|
2718
2773
|
$52FdA$solidjs.createEffect(() => {
|
|
2719
2774
|
if (currentImageSize() || wasCleanedUp) return; // We get into the effect when onCleanup is called if we don't have wasCleanedUp
|
|
2720
2775
|
// ensure we always have a size accessor
|
package/ES10/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { ProductListingRequestV3 } from "@depict-ai/types/api/ProductListingRequ
|
|
|
10
10
|
import { GetListingRequest } from "@depict-ai/types/api/GetListingRequest";
|
|
11
11
|
import { BaseSearchRequestV3 } from "@depict-ai/types/api/BaseSearchRequestV3";
|
|
12
12
|
import { SearchFilter as _SearchFilter2 } from "@depict-ai/types/api/SearchRequestV2";
|
|
13
|
-
export const version = "4.0.
|
|
13
|
+
export const version = "4.0.9";
|
|
14
14
|
export type ModalAlignmentSignals = {
|
|
15
15
|
body_: Signal<JSX.CSSProperties>;
|
|
16
16
|
field_: Signal<JSX.CSSProperties>;
|
|
@@ -388,6 +388,17 @@ export function ImageContainer(props: {
|
|
|
388
388
|
class?: string;
|
|
389
389
|
children?: JSX.Element;
|
|
390
390
|
}): HTMLDivElement;
|
|
391
|
+
/**
|
|
392
|
+
* Provider to wrap every product card that gets rendered in (in PLPResults rendering internals), enables using useProductCardIndex anywhere inside the product card to get the index of the product card.
|
|
393
|
+
*/
|
|
394
|
+
export function ProductCardIndexProvider(props: {
|
|
395
|
+
children: JSX.Element;
|
|
396
|
+
index_: Accessor<number>;
|
|
397
|
+
}): JSX.Element;
|
|
398
|
+
/**
|
|
399
|
+
* Use this to get an accessor containing the index of your product card.
|
|
400
|
+
*/
|
|
401
|
+
export function useProductCardIndex(): Accessor<number> | undefined;
|
|
391
402
|
/**
|
|
392
403
|
* Returns an accessor that will update when the size of the provided element changes, to be used with ResponsiveImg
|
|
393
404
|
*/
|
|
@@ -395,6 +406,7 @@ export function makeSizeAccessor(whatToWatch: HTMLElement): Accessor<number>;
|
|
|
395
406
|
/**
|
|
396
407
|
* Automatically generate a srcset from the shopify CDN for an image and set the sizes attribute to the provided accessor.
|
|
397
408
|
* Will also delay loading and decoding of image until the browser is idle (with 5s timeout) to improve filtering/loading more performance.
|
|
409
|
+
* If ran within Depict product card rendering, within one of the first 8 product cards, those images will be loaded immediately and loading="lazy" will be ignored for them (unless you set it to "force-lazy").
|
|
398
410
|
* This is used for our responsive images:
|
|
399
411
|
* 1. The image must have a container with a fixed size (or aspect ratio) that is independent of the image. When aspectRatio is configured on the depict-cards element as data attribute, we will wrap the image in a ImageContainer for this. If it's false, the user has to provide this container themselves.
|
|
400
412
|
* 2. We set a ResizeObserver on one of the currently visible images (see makeSizeAccessor)
|
|
@@ -404,8 +416,9 @@ export function makeSizeAccessor(whatToWatch: HTMLElement): Accessor<number>;
|
|
|
404
416
|
export function ShopifyResponsiveImg(props: {
|
|
405
417
|
resolutions?: number[];
|
|
406
418
|
size: Accessor<number>;
|
|
407
|
-
} & Omit<JSX.ImgHTMLAttributes<HTMLImageElement>, "srcset" | "src" | "sizes"> & {
|
|
419
|
+
} & Omit<JSX.ImgHTMLAttributes<HTMLImageElement>, "srcset" | "src" | "sizes" | "loading"> & {
|
|
408
420
|
src: string;
|
|
421
|
+
loading?: "eager" | "lazy" | "force-lazy";
|
|
409
422
|
}): JSX.Element;
|
|
410
423
|
type ImagePlaceholderBaseOptions = {
|
|
411
424
|
style?: JSX.CSSProperties;
|
|
@@ -1194,7 +1207,7 @@ export function CategoryPage<OriginalDisplay extends Display, OutputDisplay exte
|
|
|
1194
1207
|
on_listing_query_change?: (new_listing_query?: ListingQuery | undefined, old_listing_query?: ListingQuery | undefined) => void;
|
|
1195
1208
|
content_blocks_by_row?: ContentBlocksByRow;
|
|
1196
1209
|
layout?: PossibleLayout;
|
|
1197
|
-
}): import("@depict-ai/utilishared").Node_Array;
|
|
1210
|
+
}): import("@depict-ai/utilishared/latest").Node_Array;
|
|
1198
1211
|
export function BreadCrumbs<T extends Display>({
|
|
1199
1212
|
depict_category
|
|
1200
1213
|
}: {
|
|
@@ -1326,7 +1339,7 @@ type OpenModalParams<OriginalDisplay extends Display, OutputDisplay extends Mode
|
|
|
1326
1339
|
* Open the modal with support for alignment.
|
|
1327
1340
|
* @returns {void}
|
|
1328
1341
|
*/
|
|
1329
|
-
export const open_modal_with_alignment: <OriginalDisplay extends Display, OutputDisplay extends
|
|
1342
|
+
export const open_modal_with_alignment: <OriginalDisplay extends Display, OutputDisplay extends ModernDisplay>(openModalParams: OpenModalParams<OriginalDisplay, OutputDisplay>) => void;
|
|
1330
1343
|
export function open_search_with_shift_slash(open_search: VoidFunction): () => void;
|
|
1331
1344
|
export interface PageReplacer {
|
|
1332
1345
|
readonly render_: () => Node_Array;
|