@depict-ai/ui 4.1.3 → 4.1.5
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 +189 -82
- package/ES10/index.d.ts +8 -2
- package/ES10/index.js +189 -83
- package/latest/index.cjs +189 -82
- package/latest/index.d.ts +8 -2
- package/latest/index.js +189 -83
- package/package.json +1 -1
- package/server/ES10/index.cjs +157 -53
- package/server/ES10/index.d.ts +8 -2
- package/server/ES10/index.js +157 -54
- package/server/latest/index.cjs +157 -53
- package/server/latest/index.d.ts +8 -2
- package/server/latest/index.js +157 -54
package/server/latest/index.cjs
CHANGED
|
@@ -12,6 +12,7 @@ function $parcel$export(e, n, v, s) {
|
|
|
12
12
|
configurable: true
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
+
$parcel$export(module.exports, "promiseSafeStructuredClone", () => $ac946c6b782bb900$export$83bb9af5671e1dbe);
|
|
15
16
|
$parcel$export(module.exports, "preserve_items_in_history_dot_state", () => $d84fe647b84b5dc5$export$5162a71f252e6122);
|
|
16
17
|
$parcel$export(module.exports, "prefixes_to_preserve_in_history_dot_state", () => $d84fe647b84b5dc5$export$3064e1e8c6513da3);
|
|
17
18
|
$parcel$export(module.exports, "allowNativeNavigation", () => $747421cd28dec5b5$export$29d28dadc2d6b631);
|
|
@@ -92,7 +93,76 @@ $parcel$export(module.exports, "defaultCategoryTitlePlugin", () => $a3280f0aad99
|
|
|
92
93
|
$parcel$export(module.exports, "version", () => $b757f75811f3261f$export$83d89fbfd8236492);
|
|
93
94
|
$parcel$export(module.exports, "SearchField", () => $c0a0659cf97e8eb2$export$316f6f283ae64765);
|
|
94
95
|
/*! Depict.ai search and product listing SDK */
|
|
95
|
-
const $b757f75811f3261f$export$83d89fbfd8236492 = "4.1.
|
|
96
|
+
const $b757f75811f3261f$export$83d89fbfd8236492 = "4.1.5";
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* This is a function that will safely clone an object that may contain promises.
|
|
100
|
+
* It will use structuredClone to clone the object and then re-apply (copy) any promises that were in the original object to the cloned object.
|
|
101
|
+
* @param obj Anything to clone
|
|
102
|
+
*/
|
|
103
|
+
function $ac946c6b782bb900$export$83bb9af5671e1dbe(obj) {
|
|
104
|
+
if (obj instanceof Promise) return obj;
|
|
105
|
+
// Extract all promises, keep a map of them, and then re-apply them to both the original object and the target object after cloning
|
|
106
|
+
const seen = new Set();
|
|
107
|
+
const keyStack = [[]];
|
|
108
|
+
const valueStack = [obj];
|
|
109
|
+
const promiseLocationStack = [];
|
|
110
|
+
while (valueStack.length) {
|
|
111
|
+
const value = valueStack.pop();
|
|
112
|
+
const keyPath = keyStack.pop();
|
|
113
|
+
// Promises can only be in objects and we don't need to check for objects we've already seen (like in circular references)
|
|
114
|
+
if (typeof value !== "object" || value === null || seen.has(value)) continue;
|
|
115
|
+
seen.add(value);
|
|
116
|
+
if (Array.isArray(value)) {
|
|
117
|
+
for (let i = 0; i < value.length; i++) {
|
|
118
|
+
const ourValue = value[i];
|
|
119
|
+
const valuesKeyPath = [...keyPath, i];
|
|
120
|
+
if (ourValue instanceof Promise) {
|
|
121
|
+
promiseLocationStack.push([valuesKeyPath, ourValue]);
|
|
122
|
+
delete value[i]; // This will leave a hole in the array, but it's fine since we'll put it back soon
|
|
123
|
+
// This way both the indexes will be correct when putting the value back and our for loop doesn't get messed up
|
|
124
|
+
} else {
|
|
125
|
+
keyStack.push(valuesKeyPath);
|
|
126
|
+
valueStack.push(ourValue);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
for (const innerKey in value) {
|
|
132
|
+
const ourValue = value[innerKey];
|
|
133
|
+
const valuesKeyPath = [...keyPath, innerKey];
|
|
134
|
+
if (ourValue instanceof Promise) {
|
|
135
|
+
promiseLocationStack.push([valuesKeyPath, ourValue]);
|
|
136
|
+
delete value[innerKey];
|
|
137
|
+
} else {
|
|
138
|
+
keyStack.push(valuesKeyPath);
|
|
139
|
+
valueStack.push(ourValue);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
let structuredClonedObject;
|
|
144
|
+
let error;
|
|
145
|
+
try {
|
|
146
|
+
structuredClonedObject = structuredClone(obj);
|
|
147
|
+
} catch (e) {
|
|
148
|
+
// We still need to put back the promises in the original object, even if we threw an error
|
|
149
|
+
error = e;
|
|
150
|
+
}
|
|
151
|
+
// Put back the promises in both the original object and the cloned object
|
|
152
|
+
while (promiseLocationStack.length) {
|
|
153
|
+
const [keyPath, promise] = promiseLocationStack.pop();
|
|
154
|
+
let targetInClone = structuredClonedObject;
|
|
155
|
+
let targetInOriginal = obj;
|
|
156
|
+
for (let i = 0; i < keyPath.length - 1; i++) {
|
|
157
|
+
if (!error) targetInClone = targetInClone[keyPath[i]];
|
|
158
|
+
targetInOriginal = targetInOriginal[keyPath[i]];
|
|
159
|
+
}
|
|
160
|
+
if (!error) targetInClone[keyPath[keyPath.length - 1]] = promise;
|
|
161
|
+
targetInOriginal[keyPath[keyPath.length - 1]] = promise;
|
|
162
|
+
}
|
|
163
|
+
if (error) throw error;
|
|
164
|
+
return structuredClonedObject;
|
|
165
|
+
}
|
|
96
166
|
const $d84fe647b84b5dc5$export$3064e1e8c6513da3 = new Set();
|
|
97
167
|
let $d84fe647b84b5dc5$var$has_ran = false;
|
|
98
168
|
function $d84fe647b84b5dc5$export$5162a71f252e6122() {
|
|
@@ -234,12 +304,42 @@ function $b54e6192d0caa293$export$d9f36cf74e24d595(media_query) {
|
|
|
234
304
|
}) => signal[1](matches)).remove);
|
|
235
305
|
return signal[0];
|
|
236
306
|
}
|
|
307
|
+
var $9fe9883b1d8ecccc$var$_tmpl$ = ["<span", ' class="', '" style="', '"></span>'];
|
|
308
|
+
function $9fe9883b1d8ecccc$export$acb3eaade4b23afd(props) {
|
|
309
|
+
// Work around https://github.com/solidjs/solid/issues/1980
|
|
310
|
+
return $5vyXB$solidjsweb.ssr($9fe9883b1d8ecccc$var$_tmpl$, $5vyXB$solidjsweb.ssrHydrationKey(), `${$5vyXB$solidjsweb.escape(props.class, true) || ""} depict-placeholder`, $5vyXB$solidjsweb.ssrStyle(props.style));
|
|
311
|
+
}
|
|
312
|
+
function $061ff5b4c3d36171$export$89c6019e4baa40b1(props) {
|
|
313
|
+
const style = $5vyXB$solidjs.createMemo(() => {
|
|
314
|
+
const {
|
|
315
|
+
style: style,
|
|
316
|
+
height: height,
|
|
317
|
+
width: width
|
|
318
|
+
} = props;
|
|
319
|
+
return {
|
|
320
|
+
...(style || {}),
|
|
321
|
+
height: height ?? "1em",
|
|
322
|
+
...(width && {
|
|
323
|
+
width: width
|
|
324
|
+
})
|
|
325
|
+
};
|
|
326
|
+
});
|
|
327
|
+
return $5vyXB$solidjsweb.createComponent((0, $9fe9883b1d8ecccc$export$acb3eaade4b23afd), {
|
|
328
|
+
get style() {
|
|
329
|
+
return style();
|
|
330
|
+
},
|
|
331
|
+
get ["class"]() {
|
|
332
|
+
return props.class;
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
}
|
|
237
336
|
var $6ae613870d3380fc$var$_tmpl$ = ["<span", ' class="title line-clamp">', "</span>"],
|
|
238
337
|
$6ae613870d3380fc$var$_tmpl$2 = ["<span", ' class="brand">', "</span>"],
|
|
239
338
|
$6ae613870d3380fc$var$_tmpl$3 = ["<div", ' class="tagline line-clamp">', "</div>"],
|
|
240
339
|
$6ae613870d3380fc$var$_tmpl$4 = ["<span", ' class="orig price"><!--$-->', "<!--/--><!--$-->", "<!--/--><!--$-->", "<!--/--></span>"],
|
|
241
|
-
$6ae613870d3380fc$var$_tmpl$5 = ["<
|
|
242
|
-
$6ae613870d3380fc$var$_tmpl$6 = ["<div", ' class="
|
|
340
|
+
$6ae613870d3380fc$var$_tmpl$5 = ["<span", ' class="', '"><!--$-->', "<!--/--><!--$-->", "<!--/--><!--$-->", "<!--/--></span>"],
|
|
341
|
+
$6ae613870d3380fc$var$_tmpl$6 = ["<a", ' class="', '"', '><div class="img-part"><!--$-->', "<!--/--><!--$-->", '<!--/--></div><div class="right-part"><!--$-->', '<!--/--><div class="price-container"><!--$-->', "<!--/--><!--$-->", "<!--/--></div></div></a>"],
|
|
342
|
+
$6ae613870d3380fc$var$_tmpl$7 = ["<div", ' class="title-brand-tagline">', "</div>"];
|
|
243
343
|
const $6ae613870d3380fc$export$b05c0ae390cf3e06 = ({
|
|
244
344
|
display_: display_,
|
|
245
345
|
router_: router_,
|
|
@@ -253,13 +353,16 @@ const $6ae613870d3380fc$export$b05c0ae390cf3e06 = ({
|
|
|
253
353
|
const [get_selected_index_, set_selected_index_] = selected_index_ || [];
|
|
254
354
|
const variant = display_.variant_displays[display_.variant_index];
|
|
255
355
|
const href = $5vyXB$solidjs.createMemo(() => variant.page_url); // <- could be made reactive getter in displayTransformers, read it in memo here since it might create computations (for example in the preview-brower), and there's no owner in the onClick handler
|
|
256
|
-
|
|
356
|
+
// Prices can be promises, for example in our shopify app. Always assume they are (will work the same when they aren't)
|
|
357
|
+
const [salePrice] = $5vyXB$solidjs.createResource(() => variant.sale_price);
|
|
358
|
+
const [originalPrice] = $5vyXB$solidjs.createResource(() => variant.original_price);
|
|
359
|
+
const isOnSale = $5vyXB$solidjs.createMemo(() => salePrice() !== originalPrice());
|
|
257
360
|
const supports_hover = $b54e6192d0caa293$export$d9f36cf74e24d595("(hover: hover) and (pointer: fine)");
|
|
258
361
|
const [isSelected, selectedDueToKeyboardNavigation] = selected_index_ ? $f144ea315d9e4caa$export$fb40a80c530e5f2b(get_selected_index_, keyboardNavigationGroupIndex_, index_) : [];
|
|
259
362
|
const secondary_image_url = variant.image_urls?.[1] || variant.secondary_image_url || variant.alternative_display_image_url;
|
|
260
363
|
const brandInTagline = selected_index_ && variant.brand;
|
|
261
364
|
const TitleBrandTagline = () => [!selected_index_ && $5vyXB$solidjsweb.ssr($6ae613870d3380fc$var$_tmpl$2, $5vyXB$solidjsweb.ssrHydrationKey(), $5vyXB$solidjsweb.escape(variant.brand)), $5vyXB$solidjsweb.ssr($6ae613870d3380fc$var$_tmpl$, $5vyXB$solidjsweb.ssrHydrationKey(), $5vyXB$solidjsweb.escape(variant.title)), (variant.sub_heading_1 || variant.sub_heading_2 || brandInTagline) && $5vyXB$solidjsweb.ssr($6ae613870d3380fc$var$_tmpl$3, $5vyXB$solidjsweb.ssrHydrationKey(), $5vyXB$solidjsweb.escape([brandInTagline, variant.sub_heading_1, variant.sub_heading_2].filter(v => v).join(" | ")))];
|
|
262
|
-
return $5vyXB$solidjsweb.ssr($6ae613870d3380fc$var$_tmpl$
|
|
365
|
+
return $5vyXB$solidjsweb.ssr($6ae613870d3380fc$var$_tmpl$6, $5vyXB$solidjsweb.ssrHydrationKey(), `instant-card ${isSelected?.() ? "selected" : ""}`, $5vyXB$solidjsweb.ssrAttribute("href", $5vyXB$solidjsweb.escape(href(), true), false) + $5vyXB$solidjsweb.ssrAttribute("data-search-result-id", $5vyXB$solidjsweb.escape(display_.search_result_id, true), false), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent(InstantCardImageComponent_, {
|
|
263
366
|
get src_() {
|
|
264
367
|
return variant.image_urls?.[0] || variant.image_url || variant.display_image_url;
|
|
265
368
|
}
|
|
@@ -272,32 +375,43 @@ const $6ae613870d3380fc$export$b05c0ae390cf3e06 = ({
|
|
|
272
375
|
src_: secondary_image_url
|
|
273
376
|
});
|
|
274
377
|
}
|
|
275
|
-
})), selected_index_ ? $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent(TitleBrandTagline, {})) : $5vyXB$solidjsweb.ssr($6ae613870d3380fc$var$_tmpl$
|
|
276
|
-
when
|
|
378
|
+
})), selected_index_ ? $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent(TitleBrandTagline, {})) : $5vyXB$solidjsweb.ssr($6ae613870d3380fc$var$_tmpl$7, $5vyXB$solidjsweb.ssrHydrationKey(), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent(TitleBrandTagline, {}))), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Show), {
|
|
379
|
+
get when() {
|
|
380
|
+
return isOnSale();
|
|
381
|
+
},
|
|
277
382
|
get children() {
|
|
278
383
|
return $5vyXB$solidjsweb.ssr($6ae613870d3380fc$var$_tmpl$4, $5vyXB$solidjsweb.ssrHydrationKey(), $5vyXB$solidjsweb.escape(i18n_.price_formatting_().pre_), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $d659702496cb72ea$export$a71e92cfbb498adc), {
|
|
279
384
|
get price_() {
|
|
280
|
-
return
|
|
385
|
+
return originalPrice();
|
|
281
386
|
},
|
|
282
387
|
get price_formatting_() {
|
|
283
388
|
return i18n_.price_formatting_();
|
|
284
389
|
}
|
|
285
390
|
})), $5vyXB$solidjsweb.escape(i18n_.price_formatting_().post_));
|
|
286
391
|
}
|
|
287
|
-
})),
|
|
288
|
-
get
|
|
289
|
-
return
|
|
392
|
+
})), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Show), {
|
|
393
|
+
get when() {
|
|
394
|
+
return !salePrice.loading && salePrice.latest;
|
|
290
395
|
},
|
|
291
|
-
get
|
|
292
|
-
return
|
|
396
|
+
get fallback() {
|
|
397
|
+
return $5vyXB$solidjsweb.createComponent((0, $061ff5b4c3d36171$export$89c6019e4baa40b1), {
|
|
398
|
+
width: "5ch",
|
|
399
|
+
height: "1em",
|
|
400
|
+
"class": "price"
|
|
401
|
+
});
|
|
402
|
+
},
|
|
403
|
+
get children() {
|
|
404
|
+
return $5vyXB$solidjsweb.ssr($6ae613870d3380fc$var$_tmpl$5, $5vyXB$solidjsweb.ssrHydrationKey(), `${"price"} ${isOnSale() ? "sales-price" : ""}`, $5vyXB$solidjsweb.escape(i18n_.price_formatting_().pre_), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $d659702496cb72ea$export$a71e92cfbb498adc), {
|
|
405
|
+
get price_() {
|
|
406
|
+
return salePrice();
|
|
407
|
+
},
|
|
408
|
+
get price_formatting_() {
|
|
409
|
+
return i18n_.price_formatting_();
|
|
410
|
+
}
|
|
411
|
+
})), $5vyXB$solidjsweb.escape(i18n_.price_formatting_().post_));
|
|
293
412
|
}
|
|
294
|
-
}))
|
|
413
|
+
})));
|
|
295
414
|
};
|
|
296
|
-
var $9fe9883b1d8ecccc$var$_tmpl$ = ["<span", ' class="', '" style="', '"></span>'];
|
|
297
|
-
function $9fe9883b1d8ecccc$export$acb3eaade4b23afd(props) {
|
|
298
|
-
// Work around https://github.com/solidjs/solid/issues/1980
|
|
299
|
-
return $5vyXB$solidjsweb.ssr($9fe9883b1d8ecccc$var$_tmpl$, $5vyXB$solidjsweb.ssrHydrationKey(), `${$5vyXB$solidjsweb.escape(props.class, true) || ""} depict-placeholder`, $5vyXB$solidjsweb.ssrStyle(props.style));
|
|
300
|
-
}
|
|
301
415
|
function $3bc4a89b971a3af5$export$3f37af283f8fb843(props) {
|
|
302
416
|
const style = $5vyXB$solidjs.createMemo(() => {
|
|
303
417
|
const {
|
|
@@ -329,30 +443,6 @@ function $3bc4a89b971a3af5$export$3f37af283f8fb843(props) {
|
|
|
329
443
|
}
|
|
330
444
|
});
|
|
331
445
|
}
|
|
332
|
-
function $061ff5b4c3d36171$export$89c6019e4baa40b1(props) {
|
|
333
|
-
const style = $5vyXB$solidjs.createMemo(() => {
|
|
334
|
-
const {
|
|
335
|
-
style: style,
|
|
336
|
-
height: height,
|
|
337
|
-
width: width
|
|
338
|
-
} = props;
|
|
339
|
-
return {
|
|
340
|
-
...(style || {}),
|
|
341
|
-
height: height ?? "1em",
|
|
342
|
-
...(width && {
|
|
343
|
-
width: width
|
|
344
|
-
})
|
|
345
|
-
};
|
|
346
|
-
});
|
|
347
|
-
return $5vyXB$solidjsweb.createComponent((0, $9fe9883b1d8ecccc$export$acb3eaade4b23afd), {
|
|
348
|
-
get style() {
|
|
349
|
-
return style();
|
|
350
|
-
},
|
|
351
|
-
get ["class"]() {
|
|
352
|
-
return props.class;
|
|
353
|
-
}
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
446
|
var $6f604560873e4f69$var$_tmpl$ = ["<div", ' class="instant-card"><div class="img-part">', '</div><div class="right-part"><div class="title-brand-tagline"><span class="title">', '</span></div><div class="price-container">', "</div></div></div>"];
|
|
357
447
|
const $6f604560873e4f69$export$8a2234b5b1a5ebd4 = "--image-aspect-ratio";
|
|
358
448
|
function $6f604560873e4f69$export$ee1733d9a8495996() {
|
|
@@ -450,7 +540,12 @@ function $a73063cc642f3e5f$export$43f0fb951fcb0c54({
|
|
|
450
540
|
// We had a case on singular where they popped an image url and due to use caching after some time there was no image
|
|
451
541
|
// Attempt cloning the displays if possible (99.9% of the cases probably) and if not, just use the original display
|
|
452
542
|
try {
|
|
453
|
-
|
|
543
|
+
// Use promiseSafeStructuredClone so that:
|
|
544
|
+
// 1. When fetching for example prices from an API, one can start that API request
|
|
545
|
+
// 2. Add the promise to the display
|
|
546
|
+
// 3. Already render the product card with placeholders for prices while the price loads
|
|
547
|
+
// 4. When the price loads, re-render the display with the new price
|
|
548
|
+
display = $ac946c6b782bb900$export$83bb9af5671e1dbe(display);
|
|
454
549
|
} catch (e) {
|
|
455
550
|
if (!$a73063cc642f3e5f$var$printedCloneError) {
|
|
456
551
|
$a73063cc642f3e5f$var$printedCloneError = true;
|
|
@@ -508,7 +603,7 @@ function $a73063cc642f3e5f$export$43f0fb951fcb0c54({
|
|
|
508
603
|
// Modified futher to bias towards saying objects are equal non-primitive objects differ
|
|
509
604
|
function $a73063cc642f3e5f$var$deep_equal(obj1, obj2) {
|
|
510
605
|
const stack = [[obj1, obj2]];
|
|
511
|
-
while (stack.length
|
|
606
|
+
while (stack.length) {
|
|
512
607
|
const [currentObj1, currentObj2] = stack.pop();
|
|
513
608
|
if (currentObj1 === currentObj2) continue;
|
|
514
609
|
if (Array.isArray(currentObj1) && Array.isArray(currentObj2)) {
|
|
@@ -1985,10 +2080,10 @@ function $19950faaac026e09$export$6e5611bc7e57e477(props) {
|
|
|
1985
2080
|
const src_options = $5vyXB$solidjs.createMemo(() => {
|
|
1986
2081
|
const {
|
|
1987
2082
|
src: src,
|
|
1988
|
-
|
|
2083
|
+
customUrls: customUrls
|
|
1989
2084
|
} = props;
|
|
1990
|
-
const fallback_src = (
|
|
1991
|
-
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],
|
|
2085
|
+
const fallback_src = (customUrls || $19950faaac026e09$export$1d6267828870adda)(src, 400);
|
|
2086
|
+
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], customUrls);
|
|
1992
2087
|
// The order here *might* matter - I've seen mobile safari always start with loading the 400px version when it was reversed
|
|
1993
2088
|
return {
|
|
1994
2089
|
srcset: srcset,
|
|
@@ -1997,7 +2092,9 @@ function $19950faaac026e09$export$6e5611bc7e57e477(props) {
|
|
|
1997
2092
|
});
|
|
1998
2093
|
// Work around https://github.com/solidjs/solid/issues/1828
|
|
1999
2094
|
const img = new Image(); // Need to use new Image or browser might not start loading image before it's in the DOM
|
|
2000
|
-
const [, otherAttributes] = $5vyXB$solidjs.splitProps(props, ["resolutions", "size", "src", "srcSet", "loading"
|
|
2095
|
+
const [, otherAttributes] = $5vyXB$solidjs.splitProps(props, ["resolutions", "size", "src", "srcSet", "loading", "customUrls" // Can't have properties ending on underscore because the property name mangling will get confused by this <-
|
|
2096
|
+
]);
|
|
2097
|
+
|
|
2001
2098
|
const [hasSetSize, setHasSetSize] = $5vyXB$solidjs.createSignal(false);
|
|
2002
2099
|
const [hasDecoded, setHasDecoded] = $5vyXB$solidjs.createSignal(false);
|
|
2003
2100
|
const productCardIndexAccessor = $129b9b9c010039d0$export$e3faf4d95300054f();
|
|
@@ -2126,9 +2223,9 @@ function $19950faaac026e09$export$6e5611bc7e57e477(props) {
|
|
|
2126
2223
|
});
|
|
2127
2224
|
}
|
|
2128
2225
|
function $19950faaac026e09$var$make_srcset(url, resolutions, customGenerateImageUrl_) {
|
|
2129
|
-
return resolutions.map(width => `${(customGenerateImageUrl_ || $19950faaac026e09$
|
|
2226
|
+
return resolutions.map(width => `${(customGenerateImageUrl_ || $19950faaac026e09$export$1d6267828870adda)(url, width)} ${width}w`).join(", ");
|
|
2130
2227
|
}
|
|
2131
|
-
function $19950faaac026e09$
|
|
2228
|
+
function $19950faaac026e09$export$1d6267828870adda(url, width) {
|
|
2132
2229
|
// 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)
|
|
2133
2230
|
// 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)
|
|
2134
2231
|
// That way we can just to string concatenation which is insanely fast
|
|
@@ -2193,8 +2290,15 @@ function $e8327f98c8ee28d7$export$9d4a4b669b1929ab(props) {
|
|
|
2193
2290
|
get imgProps() {
|
|
2194
2291
|
return {
|
|
2195
2292
|
...props.imgProps,
|
|
2196
|
-
|
|
2197
|
-
) =>
|
|
2293
|
+
customUrls: (url, width // Apparently don't have to encode url for CF's service
|
|
2294
|
+
) => {
|
|
2295
|
+
if (url.startsWith("https://cdn.shopify.com"))
|
|
2296
|
+
// The shopify image resizing CDN blocks Cloudflare's image resizer. It's possible that we can't detect shopify image URLs sometimes because they go to the merchant's domain,
|
|
2297
|
+
// but it seems like the URLs returned by the Depict API always goes to the cdn.shopify.com version of an image, so this simple workaround works.
|
|
2298
|
+
return $19950faaac026e09$export$1d6267828870adda(url, width);
|
|
2299
|
+
// Use cloudflare image resizer instead of img.depict.ai because it's a lot faster (and also auto-chooses other formats if webp is not supported)
|
|
2300
|
+
return `https://app.depict.ai/cdn-cgi/image/width=${width},format=auto/${url}`;
|
|
2301
|
+
}
|
|
2198
2302
|
};
|
|
2199
2303
|
}
|
|
2200
2304
|
}));
|
package/server/latest/index.d.ts
CHANGED
|
@@ -10,7 +10,13 @@ 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 _SearchFilter3 } from "@depict-ai/types/api/SearchRequestV2";
|
|
13
|
-
export const version = "4.1.
|
|
13
|
+
export const version = "4.1.5";
|
|
14
|
+
/**
|
|
15
|
+
* This is a function that will safely clone an object that may contain promises.
|
|
16
|
+
* It will use structuredClone to clone the object and then re-apply (copy) any promises that were in the original object to the cloned object.
|
|
17
|
+
* @param obj Anything to clone
|
|
18
|
+
*/
|
|
19
|
+
export function promiseSafeStructuredClone<T>(obj: T): T;
|
|
14
20
|
export const prefixes_to_preserve_in_history_dot_state: Set<string>;
|
|
15
21
|
/**
|
|
16
22
|
* Prevent, usually SPAs, from deleting our stuff from history.state when they call history.pushState with a new object they have constructed. This will only run once no matter how often it's called.
|
|
@@ -436,7 +442,7 @@ export function ShopifyResponsiveImg(props: {
|
|
|
436
442
|
size: Accessor<number>;
|
|
437
443
|
src: string;
|
|
438
444
|
loading?: "eager" | "lazy" | "force-lazy";
|
|
439
|
-
|
|
445
|
+
customUrls?: (url: string, width: number) => string;
|
|
440
446
|
} & Omit<JSX.ImgHTMLAttributes<HTMLImageElement>, "srcset" | "src" | "sizes" | "loading">): JSX.Element;
|
|
441
447
|
type ImagePlaceholderBaseOptions = {
|
|
442
448
|
style?: JSX.CSSProperties;
|