@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:u}){const i=p.i();if(!i)throw new Error("Client script settings are not yet available");return`https://${i.thumbnailHost}/${i.account}/${e}/${a}/${u}/A`}function l({size:e}){function a(c,r){if(r)return s({size:e,productId:c,hash:r})}function u(c,r){if(r)return r.map(t=>({...t,imageUrl:a(c,t.imageHash)??t.imageUrl}))}function i(c,r,t){if(!t)return r;if(r)return t.map(n=>s({size:e,productId:c,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:u(t,r.skus),alternateImageUrls:i(t,r.alternateImageUrls,r.alternateImageHashes)}:r}}const g=/cdn\.shopify\.com/,m={1:"170x170_crop_center",2:"100x100_crop_center",3:"90x70_crop_center",4:"50x50_crop_center",5:"30x30_crop_center",6:"100x140_crop_center",7:"200x200_crop_center",8:"400x400",9:"750x750"};function U(e){return e in m}function f({size:e,fallback:a=u=>u}){if(e==="orig")return a;const u=m[e]||e;function i(n){return n?new URL(n).hostname.match(g):!1}function c(n){return n?i(n)?n.replace(/(\.jpg|\.png|\.jpeg|\.gif|\.webp)/,`_${u}$1`):n:""}function r(n){if(n)return n.map(o=>({...o,imageUrl:c(o.imageUrl)}))}function t(n){if(n)return n.map(o=>c(o))}return function(o){return i(o.imageUrl)?{...o,imageUrl:c(o.imageUrl),thumbUrl:c(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
+ "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: e, productId: a, hash: i }) {
3
- const u = m();
4
- if (!u)
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://${u.thumbnailHost}/${u.account}/${e}/${a}/${i}/A`;
6
+ return `https://${i.thumbnailHost}/${i.account}/${n}/${a}/${c}/A`;
7
7
  }
8
- function p({ size: e }) {
9
- function a(c, r) {
8
+ function l({ size: n }) {
9
+ function a(u, r) {
10
10
  if (r)
11
11
  return s({
12
- size: e,
13
- productId: c,
12
+ size: n,
13
+ productId: u,
14
14
  hash: r
15
15
  });
16
16
  }
17
- function i(c, r) {
17
+ function c(u, r) {
18
18
  if (r)
19
19
  return r.map((t) => ({
20
20
  ...t,
21
- imageUrl: a(c, t.imageHash) ?? t.imageUrl
21
+ imageUrl: a(u, t.imageHash) ?? t.imageUrl
22
22
  }));
23
23
  }
24
- function u(c, r, t) {
24
+ function i(u, r, t) {
25
25
  if (!t)
26
26
  return r;
27
27
  if (r)
28
28
  return t.map(
29
- (n) => s({
30
- size: e,
31
- productId: c,
32
- hash: n
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: i(t, r.skus),
43
- alternateImageUrls: u(t, r.alternateImageUrls, r.alternateImageHashes)
42
+ skus: c(t, r.skus),
43
+ alternateImageUrls: i(t, r.alternateImageUrls, r.alternateImageHashes)
44
44
  } : r;
45
45
  };
46
46
  }
47
- const l = /cdn\.shopify\.com/, f = {
48
- 1: "170x170_crop_center",
49
- 2: "100x100_crop_center",
50
- 3: "90x70_crop_center",
51
- 4: "50x50_crop_center",
52
- 5: "30x30_crop_center",
53
- 6: "100x140_crop_center",
54
- 7: "200x200_crop_center",
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(e) {
59
- return e in f;
58
+ function g(n) {
59
+ return n in f;
60
60
  }
61
- function U({ size: e, fallback: a = (i) => i }) {
62
- if (e === "orig")
61
+ function U({ size: n, fallback: a = (c) => c }) {
62
+ if (n === "orig")
63
63
  return a;
64
- const i = f[e] || e;
65
- function u(n) {
66
- return n ? new URL(n).hostname.match(l) : !1;
64
+ const c = f[n] || n;
65
+ function i(e) {
66
+ return e ? new URL(e).hostname.match(p) : !1;
67
67
  }
68
- function c(n) {
69
- return n ? u(n) ? n.replace(/(\.jpg|\.png|\.jpeg|\.gif|\.webp)/, `_${i}$1`) : n : "";
68
+ function u(e) {
69
+ return e ? i(e) ? e.replace(/(\.jpg|\.png|\.jpeg|\.gif|\.webp)/, `_${c}$1`) : e : "";
70
70
  }
71
- function r(n) {
72
- if (n)
73
- return n.map((o) => ({
71
+ function r(e) {
72
+ if (e)
73
+ return e.map((o) => ({
74
74
  ...o,
75
- imageUrl: c(o.imageUrl)
75
+ imageUrl: u(o.imageUrl)
76
76
  }));
77
77
  }
78
- function t(n) {
79
- if (n)
80
- return n.map((o) => c(o));
78
+ function t(e) {
79
+ if (e)
80
+ return e.map((o) => u(o));
81
81
  }
82
82
  return function(o) {
83
- return u(o.imageUrl) ? {
83
+ return i(o.imageUrl) ? {
84
84
  ...o,
85
- imageUrl: c(o.imageUrl),
86
- thumbUrl: c(o.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 e;
94
- return (e = window.Nosto) == null ? void 0 : e.shopifyScript;
93
+ var n;
94
+ return (n = window.Nosto) == null ? void 0 : n.shopifyScript;
95
95
  }
96
- function b({ size: e }) {
97
- const a = p({ size: e });
98
- return d() && g(e) ? U({ size: e, fallback: a }) : a;
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
- p as nostoThumbnailDecorator,
102
+ l as nostoThumbnailDecorator,
103
103
  U as shopifyThumbnailDecorator,
104
- b as thumbnailDecorator
104
+ x as thumbnailDecorator
105
105
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nosto/search-js",
3
- "version": "2.1.3",
3
+ "version": "2.2.0",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "files": [