@gem-sdk/components 2.5.10 → 2.5.11

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.
@@ -33,8 +33,11 @@ const getSrcSetLink = (link)=>{
33
33
  return link; // Since image src didn't change in size so this line of code is pointless
34
34
  // return `${link} 768w,${link} 1024w,${link} 1440w`;
35
35
  };
36
+ const isShopifyCDNImage = (assetUrl)=>{
37
+ return assetUrl && assetUrl?.startsWith('https://cdn.shopify.com/');
38
+ };
36
39
  const getImageSrc = (image, currentDevice)=>{
37
- let src = image?.backupFilePath;
40
+ let src = image?.backupFilePath ?? image?.src;
38
41
  if (image?.backupFileKey) {
39
42
  const newBackupFileKey = getNewBackupFileKey(image.backupFileKey, image?.src ?? '');
40
43
  if (image.storage === 'THEME' || !image.storage) {
@@ -43,7 +46,7 @@ const getImageSrc = (image, currentDevice)=>{
43
46
  src = `{{ "${replaceBackupFileKeyFileContent(newBackupFileKey)}" | file_url }}`;
44
47
  }
45
48
  }
46
- if (currentDevice && (image?.backupFileKey || src?.includes('cdn.shopify'))) {
49
+ if (currentDevice && isShopifyCDNImage(src)) {
47
50
  switch(currentDevice){
48
51
  case 'tablet':
49
52
  src = src?.replace(regexReplaceEndDot, `_1024x.`);
@@ -53,7 +56,7 @@ const getImageSrc = (image, currentDevice)=>{
53
56
  break;
54
57
  }
55
58
  }
56
- return src ?? image?.src;
59
+ return src;
57
60
  };
58
61
  const regexReplaceEndDot = /\.(?=[^.]*$)/;
59
62
  const replaceBackupFileKeyFileContent = (backupFileKey)=>{
@@ -31,8 +31,11 @@ const getSrcSetLink = (link)=>{
31
31
  return link; // Since image src didn't change in size so this line of code is pointless
32
32
  // return `${link} 768w,${link} 1024w,${link} 1440w`;
33
33
  };
34
+ const isShopifyCDNImage = (assetUrl)=>{
35
+ return assetUrl && assetUrl?.startsWith('https://cdn.shopify.com/');
36
+ };
34
37
  const getImageSrc = (image, currentDevice)=>{
35
- let src = image?.backupFilePath;
38
+ let src = image?.backupFilePath ?? image?.src;
36
39
  if (image?.backupFileKey) {
37
40
  const newBackupFileKey = getNewBackupFileKey(image.backupFileKey, image?.src ?? '');
38
41
  if (image.storage === 'THEME' || !image.storage) {
@@ -41,7 +44,7 @@ const getImageSrc = (image, currentDevice)=>{
41
44
  src = `{{ "${replaceBackupFileKeyFileContent(newBackupFileKey)}" | file_url }}`;
42
45
  }
43
46
  }
44
- if (currentDevice && (image?.backupFileKey || src?.includes('cdn.shopify'))) {
47
+ if (currentDevice && isShopifyCDNImage(src)) {
45
48
  switch(currentDevice){
46
49
  case 'tablet':
47
50
  src = src?.replace(regexReplaceEndDot, `_1024x.`);
@@ -51,7 +54,7 @@ const getImageSrc = (image, currentDevice)=>{
51
54
  break;
52
55
  }
53
56
  }
54
- return src ?? image?.src;
57
+ return src;
55
58
  };
56
59
  const regexReplaceEndDot = /\.(?=[^.]*$)/;
57
60
  const replaceBackupFileKeyFileContent = (backupFileKey)=>{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/components",
3
- "version": "2.5.10",
3
+ "version": "2.5.11",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",
@@ -21,7 +21,7 @@
21
21
  "format": "prettier --write \"./src/**/*.{ts,tsx}\""
22
22
  },
23
23
  "devDependencies": {
24
- "@gem-sdk/core": "2.5.10",
24
+ "@gem-sdk/core": "2.5.11",
25
25
  "@gem-sdk/styles": "2.4.8",
26
26
  "@types/react-transition-group": "^4.4.5"
27
27
  },