@nosto/search-js 2.1.3 → 2.2.0
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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../index.es-DlUp67LT.cjs");function s({size:e,productId:a,hash:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../index.es-DlUp67LT.cjs");function s({size:e,productId:a,hash:c}){const u=p.i();if(!u)throw new Error("Client script settings are not yet available");return`https://${u.thumbnailHost}/${u.account}/${e}/${a}/${c}/A`}function l({size:e}){function a(i,r){if(r)return s({size:e,productId:i,hash:r})}function c(i,r){if(r)return r.map(t=>({...t,imageUrl:a(i,t.imageHash)??t.imageUrl}))}function u(i,r,t){if(!t)return r;if(r)return t.map(n=>s({size:e,productId:i,hash:n}))}return function(r){const t=r.productId;return t?{...r,imageUrl:a(t,r.imageHash)??r.imageUrl,thumbUrl:a(t,r.thumbHash)??r.thumbUrl,skus:c(t,r.skus),alternateImageUrls:u(t,r.alternateImageUrls,r.alternateImageHashes)}:r}}const g=/cdn\.shopify\.com/,m={1:"170x170",2:"100x100",3:"90x70",4:"50x50",5:"30x30",6:"100x140",7:"200x200",8:"400x400",9:"750x750"};function U(e){return e in m}function f({size:e,fallback:a=c=>c}){if(e==="orig")return a;const c=m[e]||e;function u(n){return n?new URL(n).hostname.match(g):!1}function i(n){return n?u(n)?n.replace(/(\.jpg|\.png|\.jpeg|\.gif|\.webp)/,`_${c}$1`):n:""}function r(n){if(n)return n.map(o=>({...o,imageUrl:i(o.imageUrl)}))}function t(n){if(n)return n.map(o=>i(o))}return function(o){return u(o.imageUrl)?{...o,imageUrl:i(o.imageUrl),thumbUrl:i(o.thumbUrl),skus:r(o.skus),alternateImageUrls:t(o.alternateImageUrls)}:a(o)}}function d(){var e;return(e=window.Nosto)==null?void 0:e.shopifyScript}function b({size:e}){const a=l({size:e});return d()&&U(e)?f({size:e,fallback:a}):a}exports.generateThumbnailUrl=s;exports.nostoThumbnailDecorator=l;exports.shopifyThumbnailDecorator=f;exports.thumbnailDecorator=b;
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
import { i as m } from "../index.es-B8mbAxS4.js";
|
|
2
|
-
function s({ size:
|
|
3
|
-
const
|
|
4
|
-
if (!
|
|
2
|
+
function s({ size: n, productId: a, hash: c }) {
|
|
3
|
+
const i = m();
|
|
4
|
+
if (!i)
|
|
5
5
|
throw new Error("Client script settings are not yet available");
|
|
6
|
-
return `https://${
|
|
6
|
+
return `https://${i.thumbnailHost}/${i.account}/${n}/${a}/${c}/A`;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
function a(
|
|
8
|
+
function l({ size: n }) {
|
|
9
|
+
function a(u, r) {
|
|
10
10
|
if (r)
|
|
11
11
|
return s({
|
|
12
|
-
size:
|
|
13
|
-
productId:
|
|
12
|
+
size: n,
|
|
13
|
+
productId: u,
|
|
14
14
|
hash: r
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function c(u, r) {
|
|
18
18
|
if (r)
|
|
19
19
|
return r.map((t) => ({
|
|
20
20
|
...t,
|
|
21
|
-
imageUrl: a(
|
|
21
|
+
imageUrl: a(u, t.imageHash) ?? t.imageUrl
|
|
22
22
|
}));
|
|
23
23
|
}
|
|
24
|
-
function u
|
|
24
|
+
function i(u, r, t) {
|
|
25
25
|
if (!t)
|
|
26
26
|
return r;
|
|
27
27
|
if (r)
|
|
28
28
|
return t.map(
|
|
29
|
-
(
|
|
30
|
-
size:
|
|
31
|
-
productId:
|
|
32
|
-
hash:
|
|
29
|
+
(e) => s({
|
|
30
|
+
size: n,
|
|
31
|
+
productId: u,
|
|
32
|
+
hash: e
|
|
33
33
|
})
|
|
34
34
|
);
|
|
35
35
|
}
|
|
@@ -39,67 +39,67 @@ function p({ size: e }) {
|
|
|
39
39
|
...r,
|
|
40
40
|
imageUrl: a(t, r.imageHash) ?? r.imageUrl,
|
|
41
41
|
thumbUrl: a(t, r.thumbHash) ?? r.thumbUrl,
|
|
42
|
-
skus:
|
|
43
|
-
alternateImageUrls:
|
|
42
|
+
skus: c(t, r.skus),
|
|
43
|
+
alternateImageUrls: i(t, r.alternateImageUrls, r.alternateImageHashes)
|
|
44
44
|
} : r;
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
-
const
|
|
48
|
-
1: "
|
|
49
|
-
2: "
|
|
50
|
-
3: "
|
|
51
|
-
4: "
|
|
52
|
-
5: "
|
|
53
|
-
6: "
|
|
54
|
-
7: "
|
|
47
|
+
const p = /cdn\.shopify\.com/, f = {
|
|
48
|
+
1: "170x170",
|
|
49
|
+
2: "100x100",
|
|
50
|
+
3: "90x70",
|
|
51
|
+
4: "50x50",
|
|
52
|
+
5: "30x30",
|
|
53
|
+
6: "100x140",
|
|
54
|
+
7: "200x200",
|
|
55
55
|
8: "400x400",
|
|
56
56
|
9: "750x750"
|
|
57
57
|
};
|
|
58
|
-
function g(
|
|
59
|
-
return
|
|
58
|
+
function g(n) {
|
|
59
|
+
return n in f;
|
|
60
60
|
}
|
|
61
|
-
function U({ size:
|
|
62
|
-
if (
|
|
61
|
+
function U({ size: n, fallback: a = (c) => c }) {
|
|
62
|
+
if (n === "orig")
|
|
63
63
|
return a;
|
|
64
|
-
const
|
|
65
|
-
function
|
|
66
|
-
return
|
|
64
|
+
const c = f[n] || n;
|
|
65
|
+
function i(e) {
|
|
66
|
+
return e ? new URL(e).hostname.match(p) : !1;
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
return
|
|
68
|
+
function u(e) {
|
|
69
|
+
return e ? i(e) ? e.replace(/(\.jpg|\.png|\.jpeg|\.gif|\.webp)/, `_${c}$1`) : e : "";
|
|
70
70
|
}
|
|
71
|
-
function r(
|
|
72
|
-
if (
|
|
73
|
-
return
|
|
71
|
+
function r(e) {
|
|
72
|
+
if (e)
|
|
73
|
+
return e.map((o) => ({
|
|
74
74
|
...o,
|
|
75
|
-
imageUrl:
|
|
75
|
+
imageUrl: u(o.imageUrl)
|
|
76
76
|
}));
|
|
77
77
|
}
|
|
78
|
-
function t(
|
|
79
|
-
if (
|
|
80
|
-
return
|
|
78
|
+
function t(e) {
|
|
79
|
+
if (e)
|
|
80
|
+
return e.map((o) => u(o));
|
|
81
81
|
}
|
|
82
82
|
return function(o) {
|
|
83
|
-
return
|
|
83
|
+
return i(o.imageUrl) ? {
|
|
84
84
|
...o,
|
|
85
|
-
imageUrl:
|
|
86
|
-
thumbUrl:
|
|
85
|
+
imageUrl: u(o.imageUrl),
|
|
86
|
+
thumbUrl: u(o.thumbUrl),
|
|
87
87
|
skus: r(o.skus),
|
|
88
88
|
alternateImageUrls: t(o.alternateImageUrls)
|
|
89
89
|
} : a(o);
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
92
|
function d() {
|
|
93
|
-
var
|
|
94
|
-
return (
|
|
93
|
+
var n;
|
|
94
|
+
return (n = window.Nosto) == null ? void 0 : n.shopifyScript;
|
|
95
95
|
}
|
|
96
|
-
function
|
|
97
|
-
const a =
|
|
98
|
-
return d() && g(
|
|
96
|
+
function x({ size: n }) {
|
|
97
|
+
const a = l({ size: n });
|
|
98
|
+
return d() && g(n) ? U({ size: n, fallback: a }) : a;
|
|
99
99
|
}
|
|
100
100
|
export {
|
|
101
101
|
s as generateThumbnailUrl,
|
|
102
|
-
|
|
102
|
+
l as nostoThumbnailDecorator,
|
|
103
103
|
U as shopifyThumbnailDecorator,
|
|
104
|
-
|
|
104
|
+
x as thumbnailDecorator
|
|
105
105
|
};
|