@gem-sdk/core 1.31.10 → 1.31.14

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.
@@ -49,11 +49,27 @@ const getBgImageByDevice = (background, device, options)=>{
49
49
  const isBgVideo = background?.[device]?.type === 'video';
50
50
  if (isBgVideo) return;
51
51
  const backupFileKey = background?.[device]?.image?.backupFileKey;
52
- const imageByDevice = options?.liquid && backupFileKey && `{{ "${backupFileKey}" | asset_url }}` || background?.[device]?.image?.src;
52
+ const storage = background?.[device]?.image?.storage;
53
+ let imageByDevice = background?.[device]?.image?.src;
54
+ let newBackupFilekey = backupFileKey;
55
+ const shopifyHandleName = imageByDevice?.match(// eslint-disable-next-line
56
+ /\/files\/([^\/]+\.(jpg|jpeg|gif|png|webp))$/)?.[1];
57
+ if (shopifyHandleName && shopifyHandleName != backupFileKey) {
58
+ newBackupFilekey = shopifyHandleName;
59
+ }
60
+ if (storage === 'FILE_CONTENT') {
61
+ if (options?.liquid && newBackupFilekey) {
62
+ imageByDevice = `{{ "${newBackupFilekey.replace('.jpeg', '.jpg')}" | file_url }}`;
63
+ }
64
+ }
65
+ if (storage === 'THEME' || !storage) {
66
+ if (options?.liquid && newBackupFilekey) {
67
+ imageByDevice = `{{ "${newBackupFilekey}" | asset_url }}`;
68
+ }
69
+ }
53
70
  if (typeof imageByDevice === 'string') {
54
71
  return `url(${imageByDevice})`;
55
72
  }
56
- return;
57
73
  };
58
74
  const getStyleBgPosition = (background)=>{
59
75
  const bgPosition = {
@@ -47,11 +47,27 @@ const getBgImageByDevice = (background, device, options)=>{
47
47
  const isBgVideo = background?.[device]?.type === 'video';
48
48
  if (isBgVideo) return;
49
49
  const backupFileKey = background?.[device]?.image?.backupFileKey;
50
- const imageByDevice = options?.liquid && backupFileKey && `{{ "${backupFileKey}" | asset_url }}` || background?.[device]?.image?.src;
50
+ const storage = background?.[device]?.image?.storage;
51
+ let imageByDevice = background?.[device]?.image?.src;
52
+ let newBackupFilekey = backupFileKey;
53
+ const shopifyHandleName = imageByDevice?.match(// eslint-disable-next-line
54
+ /\/files\/([^\/]+\.(jpg|jpeg|gif|png|webp))$/)?.[1];
55
+ if (shopifyHandleName && shopifyHandleName != backupFileKey) {
56
+ newBackupFilekey = shopifyHandleName;
57
+ }
58
+ if (storage === 'FILE_CONTENT') {
59
+ if (options?.liquid && newBackupFilekey) {
60
+ imageByDevice = `{{ "${newBackupFilekey.replace('.jpeg', '.jpg')}" | file_url }}`;
61
+ }
62
+ }
63
+ if (storage === 'THEME' || !storage) {
64
+ if (options?.liquid && newBackupFilekey) {
65
+ imageByDevice = `{{ "${newBackupFilekey}" | asset_url }}`;
66
+ }
67
+ }
51
68
  if (typeof imageByDevice === 'string') {
52
69
  return `url(${imageByDevice})`;
53
70
  }
54
- return;
55
71
  };
56
72
  const getStyleBgPosition = (background)=>{
57
73
  const bgPosition = {
@@ -669,6 +669,8 @@ type Background = {
669
669
  width?: number;
670
670
  height?: number;
671
671
  backupFileKey?: string;
672
+ storage?: 'THEME' | 'FILE_CONTENT';
673
+ backupFilePath?: string;
672
674
  };
673
675
  size?: BgSize;
674
676
  position?: BgPosition;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/core",
3
- "version": "1.31.10",
3
+ "version": "1.31.14",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",