@depict-ai/ui 1.4.19 → 1.4.20

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.
@@ -1,5 +1,6 @@
1
1
  var $5vyXB$depictaiutilishared = require("@depict-ai/utilishared/latest");
2
2
  var $5vyXB$solidjsweb = require("solid-js/web");
3
+ var $5vyXB$depictaiutilisharedlatest = require("@depict-ai/utilishared/latest/latest");
3
4
  var $5vyXB$solidjs = require("solid-js");
4
5
  require("../../multi_import_deduplicator.cjs").register_es_version("ui", "latest");
5
6
  function $parcel$export(e, n, v, s) {
@@ -10,6 +11,9 @@ function $parcel$export(e, n, v, s) {
10
11
  configurable: true
11
12
  });
12
13
  }
14
+ $parcel$export(module.exports, "ShopifyResponsiveImg", () => $19950faaac026e09$export$6e5611bc7e57e477);
15
+ $parcel$export(module.exports, "makeSizeAccessor", () => $19950faaac026e09$export$e6fffe67d4cdd848);
16
+ $parcel$export(module.exports, "ImageContainer", () => $93304d59a9747aa6$export$94026ee33dbabc26);
13
17
  $parcel$export(module.exports, "SentryErrorBoundary", () => $edafe91daf3091d7$export$b69d0d92862de18b);
14
18
  $parcel$export(module.exports, "ExpandingDetails", () => $a69e505a12a77874$export$6c6d7a51fa9aa15d);
15
19
  $parcel$export(module.exports, "accessor_of_object_to_object_with_accessor_values", () => $0785f4c9947d9b5f$export$f091cbac892643a4);
@@ -55,7 +59,51 @@ $parcel$export(module.exports, "defaultColsAtSize", () => $a3280f0aad997933$expo
55
59
  $parcel$export(module.exports, "defaultCategoryTitlePlugin", () => $a3280f0aad997933$export$7bf543b9d9be2c22);
56
60
  $parcel$export(module.exports, "version", () => $b757f75811f3261f$export$83d89fbfd8236492);
57
61
  /*! Depict.ai search and product listing SDK */
58
- const $b757f75811f3261f$export$83d89fbfd8236492 = "1.4.19";
62
+ const $b757f75811f3261f$export$83d89fbfd8236492 = "1.4.20";
63
+ function $19950faaac026e09$export$e6fffe67d4cdd848(whatToWatch) {
64
+ const [size, setSize] = $5vyXB$solidjs.createSignal(0);
65
+ const resizeObserver = new ResizeObserver($5vyXB$depictaiutilisharedlatest.catchify(records => {
66
+ for (let j = 0; j < records.length; j++) {
67
+ const {
68
+ width: width
69
+ } = records[j].contentRect;
70
+ if (!width) continue;
71
+ // add extra 5% just in case. + safari is (in some cases) acting a bit questionable and needs a third extra to fill the set width
72
+ const new_size = width * 1.05 * ((0, $5vyXB$depictaiutilishared.is_safari) ? 4 / 3 : 1);
73
+ setSize(Math.round(new_size));
74
+ }
75
+ }));
76
+ resizeObserver.observe(whatToWatch);
77
+ $5vyXB$solidjs.onCleanup(() => resizeObserver.disconnect());
78
+ return size;
79
+ }
80
+ function $19950faaac026e09$export$6e5611bc7e57e477({
81
+ src: raw_src,
82
+ size: size,
83
+ resolutions = [64, 128, 256, 300, 400, 512, 768, 1024, 1280, 1536, 2048, 4096],
84
+ ...otherOptions
85
+ }) {
86
+ const src = new URL(raw_src, location.origin);
87
+ const fallbackSrc = $19950faaac026e09$var$generateImageUrl(src, 400);
88
+ const srcset = $19950faaac026e09$var$make_srcset(src, resolutions);
89
+ return $5vyXB$solidjsweb.ssrElement("img", () => ({
90
+ ...otherOptions,
91
+ "src": fallbackSrc,
92
+ "srcset": srcset,
93
+ "sizes": size() + "px"
94
+ }), undefined, true);
95
+ }
96
+ function $19950faaac026e09$var$make_srcset(url, resolutions) {
97
+ return resolutions.map(width => `${$19950faaac026e09$var$generateImageUrl(url, width)} ${width}w`).join(", ");
98
+ }
99
+ function $19950faaac026e09$var$generateImageUrl(url, width) {
100
+ url.searchParams.set("width", width);
101
+ return url.href;
102
+ }
103
+ const $93304d59a9747aa6$var$_tmpl$ = ["<div", ' style="', '"></div>'];
104
+ function $93304d59a9747aa6$export$94026ee33dbabc26(props) {
105
+ return $5vyXB$solidjsweb.ssr($93304d59a9747aa6$var$_tmpl$, $5vyXB$solidjsweb.ssrHydrationKey(), $5vyXB$solidjsweb.ssrStyle(`position:relative;width:100%;padding-bottom:${1 / props.aspectRatio * 100}%`));
106
+ }
59
107
 
60
108
  // Errors caused by SDK consuming code interfacing with the SDK, not the SDK itself or other Depict packages
61
109
  class $7dd1edb2ee2b43ad$export$e1d52e4f0c7557a1 extends Error {}
@@ -1,4 +1,4 @@
1
- import { JSX, Signal, Accessor, Setter } from "solid-js";
1
+ import { Accessor, JSX, Signal, Setter } from "solid-js";
2
2
  import { report, Elem, Display, ColsAtSize, ModernDisplay, Node_Array } from "@depict-ai/utilishared/latest";
3
3
  import { SearchFilter, SearchRequest } from "@depict-ai/types/api/SearchRequest";
4
4
  import { SearchFilter as _SearchFilter1, ContentLink, SearchResponse } from "@depict-ai/types/api/SearchResponse";
@@ -7,7 +7,38 @@ import { CategorySuggestion, SearchSuggestionsResponse } from "@depict-ai/types/
7
7
  import { BaseSearchRequest } from "@depict-ai/types/api/BaseSearchRequest";
8
8
  import { SearchSuggestionsRequest } from "@depict-ai/types/api/SearchSuggestionsRequest";
9
9
  import { ProductListingRequest } from "@depict-ai/types/api/ProductListingRequest";
10
- export const version = "1.4.19";
10
+ export const version = "1.4.20";
11
+ /**
12
+ * Returns an accessor that will update when the size of the provided element changes, to be used with ResponsiveImg
13
+ */
14
+ export function makeSizeAccessor(whatToWatch: HTMLElement): Accessor<number>;
15
+ /**
16
+ * Automatically generate a srcset from the shopify CDN for an image and set the sizes attribute to the provided accessor.
17
+ * This is used for our responsive images:
18
+ * 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.
19
+ * 2. We set a ResizeObserver on one of the currently visible images (see makeSizeAccessor)
20
+ * 3. We set the size attribute of all the visible images to the size of the container we're observing. The point of this is that the sizes attribute is used to determine which image to load, and usually it's set by the user and depends on the relationship between image size and viewport size. By using a ResizeObserver, we can make sure the sizes attribute is always set to the correct value without it having to be configured. This will make so the browser always loads the correct image size for a crisp image but still fast load.
21
+ */
22
+ export function ShopifyResponsiveImg({
23
+ src: raw_src,
24
+ size,
25
+ resolutions,
26
+ ...otherOptions
27
+ }: {
28
+ resolutions?: number[];
29
+ size: Accessor<number>;
30
+ } & Omit<JSX.ImgHTMLAttributes<HTMLImageElement>, "srcset" | "src" | "sizes"> & {
31
+ src: string;
32
+ }): HTMLImageElement;
33
+ /** @jsxImportSource solid-js */
34
+ /**
35
+ * ImageContainer for using the padding hack to set the aspect ratio of an image
36
+ * Put this around an <img> or <ResponsiveImg> to give it a container that always has the same size as the image. This prevents CLS and enables ResponsiveImg to work (the browser to load the correct image size)
37
+ * (Not using the CSS aspect-ratio property yet here due to browser support)
38
+ */
39
+ export function ImageContainer(props: {
40
+ aspectRatio: number;
41
+ }): HTMLDivElement;
11
42
  declare class SDKError extends Error {}
12
43
  export class ProductCardError extends SDKError {
13
44
  constructor(templateError: Error);