@gem-sdk/pages 2.0.0-staging.709 → 2.0.0-staging.764
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/dist/cjs/components/ErrorBoundary.js +1 -40
- package/dist/cjs/components/ErrorFallback.js +1 -26
- package/dist/cjs/components/FacebookPixel.js +3 -33
- package/dist/cjs/components/FooterForPostPurchase.js +1 -34
- package/dist/cjs/components/GoogleAnalytic.js +5 -65
- package/dist/cjs/components/TikTokPixel.js +3 -19
- package/dist/cjs/components/builder/Body.js +1 -36
- package/dist/cjs/components/builder/Footer.js +1 -154
- package/dist/cjs/components/builder/Header.js +1 -186
- package/dist/cjs/components/builder/PopupManager.js +1 -63
- package/dist/cjs/components/builder/SwitchView.js +1 -184
- package/dist/cjs/components/builder/Toolbar.js +1 -706
- package/dist/cjs/components/builder/Toolbox.js +1 -508
- package/dist/cjs/components/builder/const.js +1 -56
- package/dist/cjs/components/builder/toolbar/const.js +1 -7
- package/dist/cjs/components/builder/toolbar/utils/findDOMClosest.js +1 -41
- package/dist/cjs/components/builder/toolbar/utils/findOverflowParent.js +1 -20
- package/dist/cjs/components/builder/toolbar/utils/getChildrenByAttrSelector.js +1 -18
- package/dist/cjs/components/builder/toolbar/utils/getDOMElementParents.js +1 -32
- package/dist/cjs/components/builder/toolbar/utils/isOverParent.js +1 -16
- package/dist/cjs/components/builder/toolbar/utils/isOverToolbarPosition.js +1 -12
- package/dist/cjs/components/builder/toolbar/utils/isSection.js +1 -8
- package/dist/cjs/components/builder/toolbar/utils/notVisible.js +1 -8
- package/dist/cjs/components/builder/toolbar/utils/waitForElementToExist.js +1 -27
- package/dist/cjs/components/composable/getListFontWeightTypos.js +1 -14
- package/dist/cjs/components/image-to-layout/AddSectionImageToLayout.js +1 -151
- package/dist/cjs/components/image-to-layout/DropElement.js +1 -191
- package/dist/cjs/components/image-to-layout/ImageToLayout.js +1 -41
- package/dist/cjs/constants/index.js +1 -15
- package/dist/cjs/index.js +1 -80
- package/dist/cjs/layouts/main.js +1 -30
- package/dist/cjs/libs/api/get-builder-props.js +1 -46
- package/dist/cjs/libs/api/get-collection-props.js +1 -68
- package/dist/cjs/libs/api/get-home-page-props-v2.js +1 -157
- package/dist/cjs/libs/api/get-home-page-props.js +1 -163
- package/dist/cjs/libs/api/get-post-purchase-props-preview.js +1 -301
- package/dist/cjs/libs/api/get-preview-props.js +1 -18
- package/dist/cjs/libs/api/get-product-props.js +1 -73
- package/dist/cjs/libs/api/get-static-page-props-preview.js +1 -160
- package/dist/cjs/libs/api/get-static-page-props-v2.js +1 -173
- package/dist/cjs/libs/api/get-static-page-props.js +1 -161
- package/dist/cjs/libs/custom-fonts.js +6 -60
- package/dist/cjs/libs/fetcher.js +1 -100
- package/dist/cjs/libs/get-layout.js +1 -13
- package/dist/cjs/libs/get-storefront-api.js +1 -12
- package/dist/cjs/libs/getStaticPaths.js +1 -10
- package/dist/cjs/libs/google-fonts.js +1 -138
- package/dist/cjs/libs/helpers/check-option-font.js +1 -65
- package/dist/cjs/libs/helpers/common.js +1 -27
- package/dist/cjs/libs/helpers/gen-css.js +1 -135
- package/dist/cjs/libs/helpers/gen-fonts.js +1 -96
- package/dist/cjs/libs/helpers/generate-manifres.js +1 -5
- package/dist/cjs/libs/helpers/get-fallback.js +1 -34
- package/dist/cjs/libs/helpers/get-metafield.js +1 -7
- package/dist/cjs/libs/helpers/normalize.js +1 -112
- package/dist/cjs/libs/helpers/parse-json.js +1 -16
- package/dist/cjs/libs/helpers/sentry.js +1 -17
- package/dist/cjs/libs/helpers/user-agent.js +1 -7
- package/dist/cjs/libs/hooks/use-tracking-view.js +1 -42
- package/dist/cjs/libs/hooks/usePagePreview.js +1 -92
- package/dist/cjs/libs/parse-html.js +1 -34
- package/dist/cjs/libs/shopify-cdn-with-google-fonts.js +1 -1845
- package/dist/cjs/pages/404.js +1 -43
- package/dist/cjs/pages/500.js +1 -74
- package/dist/cjs/pages/CollectionGlobalProvider.js +1 -59
- package/dist/cjs/pages/builder.js +1 -119
- package/dist/cjs/pages/collection-detail.js +1 -64
- package/dist/cjs/pages/preview.js +1 -26
- package/dist/cjs/pages/product-detail.js +1 -69
- package/dist/cjs/pages/static-v2.js +3 -142
- package/dist/cjs/pages/static.js +1 -75
- package/dist/cjs/store/libs-store.js +1 -14
- package/dist/esm/components/ErrorBoundary.js +1 -38
- package/dist/esm/components/ErrorFallback.js +1 -24
- package/dist/esm/components/FacebookPixel.js +3 -31
- package/dist/esm/components/FooterForPostPurchase.js +1 -30
- package/dist/esm/components/GoogleAnalytic.js +5 -63
- package/dist/esm/components/TikTokPixel.js +3 -17
- package/dist/esm/components/builder/Body.js +1 -32
- package/dist/esm/components/builder/Footer.js +1 -150
- package/dist/esm/components/builder/Header.js +1 -182
- package/dist/esm/components/builder/PopupManager.js +1 -59
- package/dist/esm/components/builder/SwitchView.js +1 -180
- package/dist/esm/components/builder/Toolbar.js +1 -702
- package/dist/esm/components/builder/Toolbox.js +1 -504
- package/dist/esm/components/builder/const.js +1 -54
- package/dist/esm/components/builder/toolbar/const.js +1 -4
- package/dist/esm/components/builder/toolbar/utils/findDOMClosest.js +1 -39
- package/dist/esm/components/builder/toolbar/utils/findOverflowParent.js +1 -18
- package/dist/esm/components/builder/toolbar/utils/getChildrenByAttrSelector.js +1 -16
- package/dist/esm/components/builder/toolbar/utils/getDOMElementParents.js +1 -30
- package/dist/esm/components/builder/toolbar/utils/isOverParent.js +1 -14
- package/dist/esm/components/builder/toolbar/utils/isOverToolbarPosition.js +1 -10
- package/dist/esm/components/builder/toolbar/utils/isSection.js +1 -6
- package/dist/esm/components/builder/toolbar/utils/notVisible.js +1 -6
- package/dist/esm/components/builder/toolbar/utils/waitForElementToExist.js +1 -25
- package/dist/esm/components/composable/getListFontWeightTypos.js +1 -12
- package/dist/esm/components/image-to-layout/AddSectionImageToLayout.js +1 -147
- package/dist/esm/components/image-to-layout/DropElement.js +1 -189
- package/dist/esm/components/image-to-layout/ImageToLayout.js +1 -37
- package/dist/esm/constants/index.js +1 -15
- package/dist/esm/index.js +1 -35
- package/dist/esm/layouts/main.js +1 -26
- package/dist/esm/libs/api/get-builder-props.js +1 -44
- package/dist/esm/libs/api/get-collection-props.js +1 -66
- package/dist/esm/libs/api/get-home-page-props-v2.js +1 -155
- package/dist/esm/libs/api/get-home-page-props.js +1 -161
- package/dist/esm/libs/api/get-post-purchase-props-preview.js +1 -293
- package/dist/esm/libs/api/get-preview-props.js +1 -16
- package/dist/esm/libs/api/get-product-props.js +1 -71
- package/dist/esm/libs/api/get-static-page-props-preview.js +1 -158
- package/dist/esm/libs/api/get-static-page-props-v2.js +1 -171
- package/dist/esm/libs/api/get-static-page-props.js +1 -159
- package/dist/esm/libs/custom-fonts.js +6 -55
- package/dist/esm/libs/fetcher.js +1 -96
- package/dist/esm/libs/get-layout.js +1 -11
- package/dist/esm/libs/get-storefront-api.js +1 -10
- package/dist/esm/libs/getStaticPaths.js +1 -8
- package/dist/esm/libs/google-fonts.js +1 -132
- package/dist/esm/libs/helpers/check-option-font.js +1 -63
- package/dist/esm/libs/helpers/common.js +1 -24
- package/dist/esm/libs/helpers/gen-css.js +1 -133
- package/dist/esm/libs/helpers/gen-fonts.js +1 -93
- package/dist/esm/libs/helpers/generate-manifres.js +1 -3
- package/dist/esm/libs/helpers/get-fallback.js +1 -32
- package/dist/esm/libs/helpers/get-metafield.js +1 -5
- package/dist/esm/libs/helpers/normalize.js +1 -104
- package/dist/esm/libs/helpers/parse-json.js +1 -13
- package/dist/esm/libs/helpers/sentry.js +1 -15
- package/dist/esm/libs/helpers/user-agent.js +1 -5
- package/dist/esm/libs/hooks/use-tracking-view.js +1 -40
- package/dist/esm/libs/hooks/usePagePreview.js +1 -90
- package/dist/esm/libs/parse-html.js +1 -32
- package/dist/esm/libs/shopify-cdn-with-google-fonts.js +1 -1843
- package/dist/esm/pages/404.js +1 -41
- package/dist/esm/pages/500.js +1 -72
- package/dist/esm/pages/CollectionGlobalProvider.js +1 -55
- package/dist/esm/pages/builder.js +1 -117
- package/dist/esm/pages/collection-detail.js +1 -60
- package/dist/esm/pages/preview.js +1 -24
- package/dist/esm/pages/product-detail.js +1 -65
- package/dist/esm/pages/static-v2.js +3 -140
- package/dist/esm/pages/static.js +1 -71
- package/dist/esm/store/libs-store.js +1 -12
- package/package.json +5 -5
|
@@ -1,132 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { getFontsFromDataBuilder } from './helpers/gen-fonts.js';
|
|
3
|
-
|
|
4
|
-
const CHROME_UA = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36';
|
|
5
|
-
const IE_UA = 'Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko';
|
|
6
|
-
async function getFontForUA(url, UA) {
|
|
7
|
-
return fetch(url, {
|
|
8
|
-
headers: {
|
|
9
|
-
'User-Agent': UA
|
|
10
|
-
}
|
|
11
|
-
}).then((res)=>{
|
|
12
|
-
if (res.status === 200) {
|
|
13
|
-
return res.text();
|
|
14
|
-
}
|
|
15
|
-
return '';
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
const composeFonts = (fonts)=>{
|
|
19
|
-
const uniqFonts = fonts.filter((font, index, arr)=>{
|
|
20
|
-
return index === arr.findIndex((t)=>t.family === font.family);
|
|
21
|
-
});
|
|
22
|
-
return uniqFonts.map((font)=>{
|
|
23
|
-
const variants = fonts.filter((t)=>t.family === font.family).reduce((acc, t)=>{
|
|
24
|
-
return [
|
|
25
|
-
...acc,
|
|
26
|
-
...t.variants
|
|
27
|
-
];
|
|
28
|
-
}, []).filter((t, index, arr)=>{
|
|
29
|
-
return index === arr.findIndex((v)=>v === t);
|
|
30
|
-
});
|
|
31
|
-
return {
|
|
32
|
-
...font,
|
|
33
|
-
variants
|
|
34
|
-
};
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
const handleGenerateFontParams = (variants, fontType = 'google')=>{
|
|
38
|
-
const regularWeights = [];
|
|
39
|
-
if (!variants.length) {
|
|
40
|
-
return fontType === 'bunny' ? '400' : 'wght@400';
|
|
41
|
-
}
|
|
42
|
-
// Get regular weights and remove italic variants
|
|
43
|
-
variants.forEach((variant)=>{
|
|
44
|
-
if (typeof variant !== 'string' || variant?.includes('italic')) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
const weight = variant === 'regular' ? '400' : variant;
|
|
48
|
-
regularWeights.push(weight);
|
|
49
|
-
});
|
|
50
|
-
// Sort weights numerically (ex: [900, 700, 400] -> [400, 700, 900])
|
|
51
|
-
const sortedRegularWeights = regularWeights.sort((a, b)=>Number(a) - Number(b));
|
|
52
|
-
// Build the variant string with only regular weights
|
|
53
|
-
const axisPrefix = 'wght@';
|
|
54
|
-
const listVariantsGoogleFonts = sortedRegularWeights.map((weight)=>weight);
|
|
55
|
-
return fontType === 'google' ? `${axisPrefix}${listVariantsGoogleFonts.join(';')}` : sortedRegularWeights.join(',');
|
|
56
|
-
};
|
|
57
|
-
const createFontUrl = (fonts, option, fontType = 'google')=>{
|
|
58
|
-
const mainFonts = fonts.filter((font)=>{
|
|
59
|
-
return !([
|
|
60
|
-
'bunny',
|
|
61
|
-
'google'
|
|
62
|
-
].includes(font.type) && checkNotInOptionFont(font.family, fontType || 'google')) && (font.type === 'google' || font.type === 'bunny' || !font.type);
|
|
63
|
-
});
|
|
64
|
-
if (!mainFonts.length) return;
|
|
65
|
-
const params = new URLSearchParams();
|
|
66
|
-
const display = option?.display || 'swap';
|
|
67
|
-
const uniqFonts = mainFonts.filter((font, index, arr)=>{
|
|
68
|
-
return index === arr.findIndex((t)=>t.family === font.family);
|
|
69
|
-
});
|
|
70
|
-
const family = composeFonts(uniqFonts).map((font)=>{
|
|
71
|
-
return `${font.family.replace(/ /g, '+')}:${handleGenerateFontParams(font.variants, fontType)}`;
|
|
72
|
-
}).join(fontType === 'google' ? '&family=' : '|');
|
|
73
|
-
params.append('family', family);
|
|
74
|
-
params.append('display', display);
|
|
75
|
-
if (option?.subset) {
|
|
76
|
-
params.append('subset', option.subset);
|
|
77
|
-
}
|
|
78
|
-
if (option?.effect) {
|
|
79
|
-
params.append('effect', option.effect);
|
|
80
|
-
}
|
|
81
|
-
const bunnyFontUrl = `https://fonts.bunny.net/css?family=${family}`;
|
|
82
|
-
const googleFontUrl = `https://fonts.googleapis.com/css2?${decodeURIComponent(params.toString())}`;
|
|
83
|
-
return fontType === 'bunny' ? bunnyFontUrl : googleFontUrl;
|
|
84
|
-
};
|
|
85
|
-
// eslint-disable-next-line max-params
|
|
86
|
-
async function getFonts(fonts, option, isImportFontByUrl = true, fontType) {
|
|
87
|
-
/**
|
|
88
|
-
* The order of IE -> Chrome is important, other wise chrome starts loading woff1.
|
|
89
|
-
* CSS cascading 🤷♂️.
|
|
90
|
-
*/ const url = createFontUrl(fonts, option, fontType);
|
|
91
|
-
if (!url) return '';
|
|
92
|
-
try {
|
|
93
|
-
if (isImportFontByUrl) return `@import url('${url}');`;
|
|
94
|
-
const [ie, chrome] = await Promise.all([
|
|
95
|
-
getFontForUA(url, IE_UA),
|
|
96
|
-
getFontForUA(url, CHROME_UA)
|
|
97
|
-
]);
|
|
98
|
-
const maxSize = 50; // 50KB
|
|
99
|
-
const value = ie + chrome;
|
|
100
|
-
if (maxSize) {
|
|
101
|
-
const textEncoder = new TextEncoder();
|
|
102
|
-
const size = value ? textEncoder.encode(value).length : 0;
|
|
103
|
-
if (Math.ceil(size / 1024) >= maxSize) {
|
|
104
|
-
return `@import url('${url}');`;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return value;
|
|
108
|
-
} catch (_e) {
|
|
109
|
-
return '';
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
const getFontFromGlobalStyle = (data, sourceFont)=>{
|
|
113
|
-
if (!data) return '';
|
|
114
|
-
try {
|
|
115
|
-
const globalStyle = JSON.parse(data);
|
|
116
|
-
const fontData = globalStyle?.font ?? {};
|
|
117
|
-
const fonts = Object.entries(fontData).map(([, value])=>{
|
|
118
|
-
return value;
|
|
119
|
-
});
|
|
120
|
-
return getFonts(fonts, undefined, undefined, sourceFont);
|
|
121
|
-
} catch {
|
|
122
|
-
return '';
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
async function getFontStyleFromPageTemplate(pageTemplate, sourceFont) {
|
|
126
|
-
const fontStyle = pageTemplate.map((sectionData)=>{
|
|
127
|
-
return getFonts(getFontsFromDataBuilder(sectionData.data), undefined, undefined, sourceFont);
|
|
128
|
-
});
|
|
129
|
-
return await Promise.all(fontStyle);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export { composeFonts, createFontUrl, getFontFromGlobalStyle, getFontStyleFromPageTemplate, getFonts };
|
|
1
|
+
import{checkNotInOptionFont as e}from"./helpers/check-option-font.js";import{getFontsFromDataBuilder as t}from"./helpers/gen-fonts.js";let CHROME_UA="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36",IE_UA="Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko";async function getFontForUA(e,t){return fetch(e,{headers:{"User-Agent":t}}).then(e=>200===e.status?e.text():"")}let composeFonts=e=>{let t=e.filter((e,t,n)=>t===n.findIndex(t=>t.family===e.family));return t.map(t=>{let n=e.filter(e=>e.family===t.family).reduce((e,t)=>[...e,...t.variants],[]).filter((e,t,n)=>t===n.findIndex(t=>t===e));return{...t,variants:n}})},handleGenerateFontParams=(e,t="google")=>{let n=[];if(!e.length)return"bunny"===t?"400":"wght@400";e.forEach(e=>{if("string"!=typeof e||e?.includes("italic"))return;let t="regular"===e?"400":e;n.push(t)});let o=n.sort((e,t)=>Number(e)-Number(t)),r=o.map(e=>e);return"google"===t?`wght@${r.join(";")}`:o.join(",")},createFontUrl=(t,n,o="google")=>{let r=t.filter(t=>!(["bunny","google"].includes(t.type)&&e(t.family,o||"google"))&&("google"===t.type||"bunny"===t.type||!t.type));if(!r.length)return;let l=new URLSearchParams,a=n?.display||"swap",i=r.filter((e,t,n)=>t===n.findIndex(t=>t.family===e.family)),s=composeFonts(i).map(e=>`${e.family.replace(/ /g,"+")}:${handleGenerateFontParams(e.variants,o)}`).join("google"===o?"&family=":"|");l.append("family",s),l.append("display",a),n?.subset&&l.append("subset",n.subset),n?.effect&&l.append("effect",n.effect);let f=`https://fonts.bunny.net/css?family=${s}`,c=`https://fonts.googleapis.com/css2?${decodeURIComponent(l.toString())}`;return"bunny"===o?f:c};async function getFonts(e,t,n=!0,o){let r=createFontUrl(e,t,o);if(!r)return"";try{if(n)return`@import url('${r}');`;let[e,t]=await Promise.all([getFontForUA(r,"Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko"),getFontForUA(r,"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36")]),o=e+t;{let e=new TextEncoder,t=o?e.encode(o).length:0;if(Math.ceil(t/1024)>=50)return`@import url('${r}');`}return o}catch(e){return""}}let getFontFromGlobalStyle=(e,t)=>{if(!e)return"";try{let n=JSON.parse(e),o=n?.font??{},r=Object.entries(o).map(([,e])=>e);return getFonts(r,void 0,void 0,t)}catch{return""}};async function getFontStyleFromPageTemplate(e,n){let o=e.map(e=>getFonts(t(e.data),void 0,void 0,n));return await Promise.all(o)}export{composeFonts,createFontUrl,getFontFromGlobalStyle,getFontStyleFromPageTemplate,getFonts};
|
|
@@ -1,63 +1 @@
|
|
|
1
|
-
|
|
2
|
-
'Anton SC',
|
|
3
|
-
'Arsenal SC',
|
|
4
|
-
'Baskervville SC',
|
|
5
|
-
'Beiruti',
|
|
6
|
-
'Bodoni Moda SC',
|
|
7
|
-
'Bona Nova SC',
|
|
8
|
-
'Bungee Tint',
|
|
9
|
-
'Edu AU VIC WA NT Hand',
|
|
10
|
-
'Fustat',
|
|
11
|
-
'Ga Maamli',
|
|
12
|
-
'Kalnia Glaze',
|
|
13
|
-
'Maname',
|
|
14
|
-
'Matemasie',
|
|
15
|
-
'Material Icons',
|
|
16
|
-
'Material Icons Outlined',
|
|
17
|
-
'Material Icons Round',
|
|
18
|
-
'Material Icons Sharp',
|
|
19
|
-
'Material Icons Two Tone',
|
|
20
|
-
'Material Symbols Outlined',
|
|
21
|
-
'Material Symbols Rounded',
|
|
22
|
-
'Material Symbols Sharp',
|
|
23
|
-
'Moderustic',
|
|
24
|
-
'New Amsterdam',
|
|
25
|
-
'Playwrite AR',
|
|
26
|
-
'Playwrite AT',
|
|
27
|
-
'Playwrite BE VLG',
|
|
28
|
-
'Playwrite BE WAL',
|
|
29
|
-
'Playwrite CL',
|
|
30
|
-
'Playwrite CU',
|
|
31
|
-
'Playwrite CZ',
|
|
32
|
-
'Playwrite DK Loopet',
|
|
33
|
-
'Playwrite DK Uloopet',
|
|
34
|
-
'Playwrite HR',
|
|
35
|
-
'Playwrite HR Lijeva',
|
|
36
|
-
'Playwrite HU',
|
|
37
|
-
'Playwrite PE',
|
|
38
|
-
'SUSE',
|
|
39
|
-
'Sankofa Display',
|
|
40
|
-
'Wittgenstein',
|
|
41
|
-
'Zain'
|
|
42
|
-
];
|
|
43
|
-
const listFontsNotInGoogle = [
|
|
44
|
-
'Arima Madurai',
|
|
45
|
-
'Coda Caption',
|
|
46
|
-
'Fredoka One',
|
|
47
|
-
'Gentium Book Basic',
|
|
48
|
-
'Kantumruy',
|
|
49
|
-
'Merienda One',
|
|
50
|
-
'Source Sans Pro',
|
|
51
|
-
'Source Serif Pro',
|
|
52
|
-
'Briem Hand',
|
|
53
|
-
'Pushster'
|
|
54
|
-
];
|
|
55
|
-
const objectFont = {
|
|
56
|
-
bunny: listFontsNotInBunny,
|
|
57
|
-
google: listFontsNotInGoogle
|
|
58
|
-
};
|
|
59
|
-
const checkNotInOptionFont = (currentfont, type)=>{
|
|
60
|
-
return objectFont?.[type]?.includes(currentfont);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export { checkNotInOptionFont };
|
|
1
|
+
let listFontsNotInBunny=["Anton SC","Arsenal SC","Baskervville SC","Beiruti","Bodoni Moda SC","Bona Nova SC","Bungee Tint","Edu AU VIC WA NT Hand","Fustat","Ga Maamli","Kalnia Glaze","Maname","Matemasie","Material Icons","Material Icons Outlined","Material Icons Round","Material Icons Sharp","Material Icons Two Tone","Material Symbols Outlined","Material Symbols Rounded","Material Symbols Sharp","Moderustic","New Amsterdam","Playwrite AR","Playwrite AT","Playwrite BE VLG","Playwrite BE WAL","Playwrite CL","Playwrite CU","Playwrite CZ","Playwrite DK Loopet","Playwrite DK Uloopet","Playwrite HR","Playwrite HR Lijeva","Playwrite HU","Playwrite PE","SUSE","Sankofa Display","Wittgenstein","Zain"],listFontsNotInGoogle=["Arima Madurai","Coda Caption","Fredoka One","Gentium Book Basic","Kantumruy","Merienda One","Source Sans Pro","Source Serif Pro","Briem Hand","Pushster"],objectFont={bunny:listFontsNotInBunny,google:listFontsNotInGoogle},checkNotInOptionFont=(a,e)=>objectFont?.[e]?.includes(a);export{checkNotInOptionFont};
|
|
@@ -1,24 +1 @@
|
|
|
1
|
-
async function wait(
|
|
2
|
-
return new Promise((resolve)=>setTimeout(resolve, ms));
|
|
3
|
-
}
|
|
4
|
-
const retryWithDelay = async (fn, config)=>{
|
|
5
|
-
const retries = config?.retries ?? 3;
|
|
6
|
-
const delay = config?.delay ?? 1000;
|
|
7
|
-
try {
|
|
8
|
-
return await fn();
|
|
9
|
-
} catch (err) {
|
|
10
|
-
if (retries <= 0 || config?.retryIf && !config.retryIf(err)) {
|
|
11
|
-
return Promise.reject(err);
|
|
12
|
-
}
|
|
13
|
-
//delay the next call
|
|
14
|
-
await wait(delay);
|
|
15
|
-
//recursively call the same func
|
|
16
|
-
return retryWithDelay(fn, {
|
|
17
|
-
...config,
|
|
18
|
-
retries: retries - 1,
|
|
19
|
-
delay
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export { retryWithDelay, wait };
|
|
1
|
+
async function wait(e){return new Promise(t=>setTimeout(t,e))}let retryWithDelay=async(e,t)=>{let r=t?.retries??3,i=t?.delay??1e3;try{return await e()}catch(a){if(r<=0||t?.retryIf&&!t.retryIf(a))return Promise.reject(a);return await wait(i),retryWithDelay(e,{...t,retries:r-1,delay:i})}};export{retryWithDelay,wait};
|
|
@@ -1,133 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import merge from 'deepmerge';
|
|
3
|
-
|
|
4
|
-
const baseDevices = {
|
|
5
|
-
tablet: '1024px',
|
|
6
|
-
mobile: '767px'
|
|
7
|
-
};
|
|
8
|
-
const devicesOrder = [
|
|
9
|
-
'desktop',
|
|
10
|
-
'tablet',
|
|
11
|
-
'mobile'
|
|
12
|
-
];
|
|
13
|
-
const flattenObject = (obj, prefix)=>{
|
|
14
|
-
return Object.keys(obj).reduce((acc, k)=>{
|
|
15
|
-
const pre = prefix ? `${prefix}-` : '';
|
|
16
|
-
if (typeof obj[k] === 'object' && obj[k] !== null && Object.keys(obj[k]).length > 0) Object.assign(acc, flattenObject(obj[k], pre + k));
|
|
17
|
-
else acc[pre + k] = obj[k];
|
|
18
|
-
return acc;
|
|
19
|
-
}, {});
|
|
20
|
-
};
|
|
21
|
-
const mapObject = (obj)=>{
|
|
22
|
-
return Object.entries(obj ?? {}).reduce((acc, [k, v])=>{
|
|
23
|
-
return {
|
|
24
|
-
...acc,
|
|
25
|
-
[getShortName(k)]: typeof v === 'object' ? mapObject(v) : v
|
|
26
|
-
};
|
|
27
|
-
}, {});
|
|
28
|
-
};
|
|
29
|
-
const getValueByDevice = (data, device)=>{
|
|
30
|
-
const deviceData = {
|
|
31
|
-
typography: Object.fromEntries(Object.entries(data?.typography ?? {}).map(([key, value])=>{
|
|
32
|
-
const typo = {
|
|
33
|
-
...value?.[device]
|
|
34
|
-
};
|
|
35
|
-
if (!typo) return [
|
|
36
|
-
key,
|
|
37
|
-
undefined
|
|
38
|
-
];
|
|
39
|
-
if (typo.fontFamily) {
|
|
40
|
-
typo.fontFamily = `var(--g-font-${typo.fontFamily}, ${typo.fontFamily})`;
|
|
41
|
-
}
|
|
42
|
-
return [
|
|
43
|
-
key,
|
|
44
|
-
typo
|
|
45
|
-
];
|
|
46
|
-
})),
|
|
47
|
-
spacing: Object.fromEntries(Object.entries(data?.spacing ?? {}).map(([key, value])=>{
|
|
48
|
-
return [
|
|
49
|
-
key,
|
|
50
|
-
value?.[device]
|
|
51
|
-
];
|
|
52
|
-
})),
|
|
53
|
-
container: Object.fromEntries(Object.entries(data?.container ?? {}).map(([key, value])=>{
|
|
54
|
-
return [
|
|
55
|
-
key,
|
|
56
|
-
value?.[device]
|
|
57
|
-
];
|
|
58
|
-
})),
|
|
59
|
-
font: Object.fromEntries(Object.entries(data?.font ?? {}).map(([key, value])=>{
|
|
60
|
-
return [
|
|
61
|
-
key,
|
|
62
|
-
value?.family
|
|
63
|
-
];
|
|
64
|
-
})),
|
|
65
|
-
theme: {
|
|
66
|
-
font: Object.fromEntries(Object.entries(data?.theme?.font ?? {}).map(([key, value])=>{
|
|
67
|
-
return [
|
|
68
|
-
key,
|
|
69
|
-
value?.family
|
|
70
|
-
];
|
|
71
|
-
}))
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
return deviceData;
|
|
75
|
-
};
|
|
76
|
-
const quoteFontName = (font)=>{
|
|
77
|
-
if ([
|
|
78
|
-
'sans-serif'
|
|
79
|
-
].includes(font)) {
|
|
80
|
-
return font;
|
|
81
|
-
}
|
|
82
|
-
return `'${font}'`;
|
|
83
|
-
};
|
|
84
|
-
const genCSSVariable = (deviceData)=>{
|
|
85
|
-
return Object.entries(mapObject(flattenObject(deviceData))).map(([key, value])=>{
|
|
86
|
-
if (value === undefined) return undefined;
|
|
87
|
-
if ([
|
|
88
|
-
'font-heading',
|
|
89
|
-
'font-body',
|
|
90
|
-
'theme-font-heading',
|
|
91
|
-
'theme-font-body'
|
|
92
|
-
].includes(key)) {
|
|
93
|
-
return `--g-${key}: ${quoteFontName(value)}`;
|
|
94
|
-
}
|
|
95
|
-
return `--g-${key}:${value}`;
|
|
96
|
-
}).filter((v)=>v !== undefined).join(';');
|
|
97
|
-
};
|
|
98
|
-
const genCSS = (input, mobileOnly)=>{
|
|
99
|
-
if (!input) return '';
|
|
100
|
-
let data = {};
|
|
101
|
-
try {
|
|
102
|
-
if (typeof input === 'string') {
|
|
103
|
-
data = JSON.parse(input);
|
|
104
|
-
} else {
|
|
105
|
-
data = input;
|
|
106
|
-
}
|
|
107
|
-
if (mobileOnly) {
|
|
108
|
-
const desktop = getValueByDevice(data, 'desktop');
|
|
109
|
-
const mobile = getValueByDevice(data, 'mobile');
|
|
110
|
-
const deviceData = merge(desktop, mobile);
|
|
111
|
-
deviceData.color = data.color;
|
|
112
|
-
deviceData.radius = data.radius;
|
|
113
|
-
const cssData = genCSSVariable(deviceData);
|
|
114
|
-
return `:root{${cssData}}`;
|
|
115
|
-
}
|
|
116
|
-
return devicesOrder.map((device)=>{
|
|
117
|
-
const deviceData = getValueByDevice(data, device);
|
|
118
|
-
if (device === 'desktop') {
|
|
119
|
-
deviceData.color = data.color;
|
|
120
|
-
deviceData.radius = data.radius;
|
|
121
|
-
}
|
|
122
|
-
const cssData = genCSSVariable(deviceData);
|
|
123
|
-
if (device === 'desktop') {
|
|
124
|
-
return `:root{${cssData}}`;
|
|
125
|
-
}
|
|
126
|
-
return `@media (max-width: ${baseDevices[device]}) {:root{${cssData}}}`;
|
|
127
|
-
}).join('\n');
|
|
128
|
-
} catch {
|
|
129
|
-
return '';
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
export { genCSS };
|
|
1
|
+
import{DEVICES as e,getShortName as t}from"@gem-sdk/core";import r from"deepmerge";let baseDevices={tablet:"1024px",mobile:"767px"},flattenObject=(e,t)=>Object.keys(e).reduce((r,o)=>{let n=t?`${t}-`:"";return"object"==typeof e[o]&&null!==e[o]&&Object.keys(e[o]).length>0?Object.assign(r,flattenObject(e[o],n+o)):r[n+o]=e[o],r},{}),mapObject=e=>Object.entries(e??{}).reduce((e,[r,o])=>({...e,[t(r)]:"object"==typeof o?mapObject(o):o}),{}),getValueByDevice=(e,t)=>{let r={typography:Object.fromEntries(Object.entries(e?.typography??{}).map(([e,r])=>{let o={...r?.[t]};return o?(o.fontFamily&&(o.fontFamily=`var(--g-font-${o.fontFamily}, ${o.fontFamily})`),[e,o]):[e,void 0]})),spacing:Object.fromEntries(Object.entries(e?.spacing??{}).map(([e,r])=>[e,r?.[t]])),container:Object.fromEntries(Object.entries(e?.container??{}).map(([e,r])=>[e,r?.[t]])),font:Object.fromEntries(Object.entries(e?.font??{}).map(([e,t])=>[e,t?.family])),theme:{font:Object.fromEntries(Object.entries(e?.theme?.font??{}).map(([e,t])=>[e,t?.family]))}};return r},quoteFontName=e=>["sans-serif"].includes(e)?e:`'${e}'`,genCSSVariable=e=>Object.entries(mapObject(flattenObject(e))).map(([e,t])=>{if(void 0!==t)return["font-heading","font-body","theme-font-heading","theme-font-body"].includes(e)?`--g-${e}: ${quoteFontName(t)}`:`--g-${e}:${t}`}).filter(e=>void 0!==e).join(";"),genCSS=(t,o)=>{if(!t)return"";let n={};try{if(n="string"==typeof t?JSON.parse(t):t,o){let e=getValueByDevice(n,"desktop"),t=getValueByDevice(n,"mobile"),o=r(e,t);o.color=n.color,o.radius=n.radius;let i=genCSSVariable(o);return`:root{${i}}`}return e.map(e=>{let t=getValueByDevice(n,e);"desktop"===e&&(t.color=n.color,t.radius=n.radius);let r=genCSSVariable(t);return"desktop"===e?`:root{${r}}`:`@media (max-width: ${baseDevices[e]}) {:root{${r}}}`}).join("\n")}catch{return""}};export{genCSS};
|
|
@@ -1,93 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const fonts = [];
|
|
3
|
-
for(const uid in dataBuilder){
|
|
4
|
-
if (Object.prototype.hasOwnProperty.call(dataBuilder, uid)) {
|
|
5
|
-
const data = dataBuilder[uid];
|
|
6
|
-
const styles = data.styles;
|
|
7
|
-
const settings = data.settings;
|
|
8
|
-
getFontFromGroupSetting(fonts, styles);
|
|
9
|
-
getFontFromGroupSetting(fonts, settings);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return fonts;
|
|
13
|
-
};
|
|
14
|
-
const getFontFromGroupSetting = (fonts, groupSetting)=>{
|
|
15
|
-
const states = [
|
|
16
|
-
'normal',
|
|
17
|
-
'hover',
|
|
18
|
-
'focus',
|
|
19
|
-
'active',
|
|
20
|
-
'disabled',
|
|
21
|
-
'price',
|
|
22
|
-
'compareAtPrice'
|
|
23
|
-
];
|
|
24
|
-
for(const attr in groupSetting){
|
|
25
|
-
if (Object.prototype.hasOwnProperty.call(groupSetting, attr)) {
|
|
26
|
-
const value = groupSetting[attr];
|
|
27
|
-
if (!value) continue;
|
|
28
|
-
getFontValue(fonts, value);
|
|
29
|
-
for (const state of states){
|
|
30
|
-
if (!value[state]) continue;
|
|
31
|
-
getFontValue(fonts, value[state]);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
const uniqueArray = (arr)=>{
|
|
37
|
-
return Array.from(new Set(arr));
|
|
38
|
-
};
|
|
39
|
-
const getFontValue = (fonts, value)=>{
|
|
40
|
-
let customFontFamily = value.custom?.fontFamily;
|
|
41
|
-
if (typeof customFontFamily === 'string') {
|
|
42
|
-
customFontFamily = {
|
|
43
|
-
value: value.custom?.fontFamily || '',
|
|
44
|
-
type: 'google'
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
const fontFamily = customFontFamily?.value;
|
|
48
|
-
let customFontVariants = value.custom?.fontVariants;
|
|
49
|
-
if (!customFontVariants?.length) {
|
|
50
|
-
customFontVariants = [
|
|
51
|
-
value.custom?.fontWeight
|
|
52
|
-
];
|
|
53
|
-
}
|
|
54
|
-
if (customFontFamily && customFontVariants?.length) {
|
|
55
|
-
const variants = customFontVariants.map((item)=>{
|
|
56
|
-
switch(item){
|
|
57
|
-
case 'regular':
|
|
58
|
-
return '400';
|
|
59
|
-
}
|
|
60
|
-
return item;
|
|
61
|
-
});
|
|
62
|
-
const customFontWeight = value.custom?.fontWeight && variants.includes(value.custom?.fontWeight) ? value.custom?.fontWeight : variants[0];
|
|
63
|
-
if (customFontWeight) {
|
|
64
|
-
const fontVariants = uniqueArray([
|
|
65
|
-
customFontWeight,
|
|
66
|
-
...value?.attrs?.isAlwaysLoadBold ? [
|
|
67
|
-
'700'
|
|
68
|
-
] : []
|
|
69
|
-
]);
|
|
70
|
-
const isExist = fonts.find((item)=>item.family == fontFamily && item.variants.includes(customFontWeight));
|
|
71
|
-
if (!isExist) {
|
|
72
|
-
const isFontFamily = fonts.find((item)=>item.family == fontFamily);
|
|
73
|
-
if (isFontFamily) {
|
|
74
|
-
isFontFamily.variants.push(customFontWeight);
|
|
75
|
-
} else {
|
|
76
|
-
if (customFontWeight !== '700') {
|
|
77
|
-
if (variants.includes('700')) {
|
|
78
|
-
fontVariants.push('700'); // Auto add 700 for bold in editor inline
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
fonts.push({
|
|
82
|
-
family: fontFamily || '',
|
|
83
|
-
variants: fontVariants,
|
|
84
|
-
subsets: [],
|
|
85
|
-
type: customFontFamily.type
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export { getFontFromGroupSetting, getFontsFromDataBuilder };
|
|
1
|
+
let getFontsFromDataBuilder=t=>{let e=[];for(let o in t)if(Object.prototype.hasOwnProperty.call(t,o)){let n=t[o],r=n.styles,i=n.settings;getFontFromGroupSetting(e,r),getFontFromGroupSetting(e,i)}return e},getFontFromGroupSetting=(t,e)=>{let o=["normal","hover","focus","active","disabled","price","compareAtPrice"];for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)){let r=e[n];if(!r)continue;for(let e of(getFontValue(t,r),o))r[e]&&getFontValue(t,r[e])}},uniqueArray=t=>Array.from(new Set(t)),getFontValue=(t,e)=>{let o=e.custom?.fontFamily;"string"==typeof o&&(o={value:e.custom?.fontFamily||"",type:"google"});let n=o?.value,r=e.custom?.fontVariants;if(r?.length||(r=[e.custom?.fontWeight]),o&&r?.length){let i=r.map(t=>"regular"===t?"400":t),l=e.custom?.fontWeight&&i.includes(e.custom?.fontWeight)?e.custom?.fontWeight:i[0];if(l){let r=uniqueArray([l,...e?.attrs?.isAlwaysLoadBold?["700"]:[]]),a=t.find(t=>t.family==n&&t.variants.includes(l));if(!a){let e=t.find(t=>t.family==n);e?e.variants.push(l):("700"!==l&&i.includes("700")&&r.push("700"),t.push({family:n||"",variants:r,subsets:[],type:o.type}))}}}};export{getFontFromGroupSetting,getFontsFromDataBuilder};
|
|
@@ -1,32 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const getFallbackV2 = async (fetcher, data, isStorefront = true)=>{
|
|
4
|
-
const isSample = isStorefront ? !process.env.NEXT_PUBLIC_STOREFRONT_TOKEN : false;
|
|
5
|
-
const queries = data.map((v)=>prefetchQueries(v.data, {
|
|
6
|
-
isSample,
|
|
7
|
-
isStorefront
|
|
8
|
-
})).flat();
|
|
9
|
-
const datas = await Promise.allSettled(queries.map(({ query, variables, func })=>{
|
|
10
|
-
if (func) {
|
|
11
|
-
return func(fetcher, variables);
|
|
12
|
-
}
|
|
13
|
-
if (query) return fetcher([
|
|
14
|
-
query,
|
|
15
|
-
variables
|
|
16
|
-
]);
|
|
17
|
-
return {};
|
|
18
|
-
}));
|
|
19
|
-
const fallback = queries.reduce((acc, { key }, index)=>{
|
|
20
|
-
const res = datas[index];
|
|
21
|
-
if (res?.status === 'fulfilled') {
|
|
22
|
-
return {
|
|
23
|
-
...acc,
|
|
24
|
-
[key]: res.value
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
return acc;
|
|
28
|
-
}, {});
|
|
29
|
-
return fallback;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export { getFallbackV2 };
|
|
1
|
+
import{prefetchQueries as e}from"@gem-sdk/core";let getFallbackV2=async(t,a,l=!0)=>{let r=!!l&&!process.env.NEXT_PUBLIC_STOREFRONT_TOKEN,s=a.map(t=>e(t.data,{isSample:r,isStorefront:l})).flat(),c=await Promise.allSettled(s.map(({query:e,variables:a,func:l})=>l?l(t,a):e?t([e,a]):{})),m=s.reduce((e,{key:t},a)=>{let l=c[a];return l?.status==="fulfilled"?{...e,[t]:l.value}:e},{});return m};export{getFallbackV2};
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
return metafields?.find((item)=>item?.key === key)?.value;
|
|
3
|
-
};
|
|
4
|
-
|
|
5
|
-
export { getPublishedThemePageMetafieldByKey };
|
|
1
|
+
let getPublishedThemePageMetafieldByKey=(e,l)=>l?.find(l=>l?.key===e)?.value;export{getPublishedThemePageMetafieldByKey};
|
|
@@ -1,104 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const result = {};
|
|
3
|
-
function compose(cData, currData = {}) {
|
|
4
|
-
if (cData) {
|
|
5
|
-
const { childrens, dateModified, editorConfigs, ...rest } = cData;
|
|
6
|
-
if (rest.type === 'section') {
|
|
7
|
-
currData[rest.uid] = rest;
|
|
8
|
-
} else {
|
|
9
|
-
const items = childrens?.map((child)=>child?.uid) ?? [];
|
|
10
|
-
currData[rest.uid] = {
|
|
11
|
-
...rest,
|
|
12
|
-
childrens: items
|
|
13
|
-
};
|
|
14
|
-
if (childrens) {
|
|
15
|
-
childrens.map((child)=>compose(child, currData));
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
compose(data, result);
|
|
21
|
-
return {
|
|
22
|
-
...result
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
const orderSection = (sections, orders)=>{
|
|
26
|
-
// Filter out sections that are not in the order list
|
|
27
|
-
const ids = orders?.filter((id)=>sections?.some((v)=>v?.id === id));
|
|
28
|
-
// Return the ordered sections
|
|
29
|
-
const orderedSections = ids?.map((id)=>sections?.find((v)=>v?.id === id)) ?? [];
|
|
30
|
-
// Return the sections that are not in the order list
|
|
31
|
-
const sectionsNotInOrder = sections?.filter((v)=>(!v?.id || !ids?.includes(v.id)) && !v?.deletedAt) ?? [];
|
|
32
|
-
// Return the ordered sections + the sections that are not in the order list
|
|
33
|
-
return orderedSections.concat(sectionsNotInOrder);
|
|
34
|
-
};
|
|
35
|
-
function normalizePageSectionResponse(sections, orders) {
|
|
36
|
-
const sortedSections = orderSection(sections, orders);
|
|
37
|
-
const childrens = sortedSections.map((item)=>{
|
|
38
|
-
if (!item?.component) return false;
|
|
39
|
-
try {
|
|
40
|
-
const data = JSON.parse(item.component);
|
|
41
|
-
return data;
|
|
42
|
-
} catch {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
}).filter(Boolean);
|
|
46
|
-
return normalizeBuilderData({
|
|
47
|
-
uid: 'ROOT',
|
|
48
|
-
tag: 'Root',
|
|
49
|
-
childrens
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
function normalizePageSectionResponseV2(sections, orders) {
|
|
53
|
-
const sortedSections = orderSection(sections, orders);
|
|
54
|
-
const childrens = sortedSections.map((item)=>{
|
|
55
|
-
if (!item?.component) return false;
|
|
56
|
-
try {
|
|
57
|
-
const data = JSON.parse(item.component);
|
|
58
|
-
return data;
|
|
59
|
-
} catch {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
}).filter(Boolean);
|
|
63
|
-
return childrens.map((v)=>{
|
|
64
|
-
return {
|
|
65
|
-
uid: v.uid,
|
|
66
|
-
lazy: Boolean(v.settings?.lazy),
|
|
67
|
-
priority: Boolean(v.settings?.priority),
|
|
68
|
-
data: normalizeBuilderData(v)
|
|
69
|
-
};
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
const parseBuilderTemplateV2 = (data)=>{
|
|
73
|
-
return normalizePageSectionResponseV2([
|
|
74
|
-
...data?.pageSections ?? [],
|
|
75
|
-
...data?.themePageCustomSections ?? [],
|
|
76
|
-
...data?.themeSections ?? []
|
|
77
|
-
], data?.sectionPosition);
|
|
78
|
-
};
|
|
79
|
-
const parseBuilderTemplate = (data)=>{
|
|
80
|
-
return normalizePageSectionResponse([
|
|
81
|
-
...data?.pageSections ?? [],
|
|
82
|
-
...data?.themePageCustomSections ?? []
|
|
83
|
-
], data?.sectionPosition);
|
|
84
|
-
};
|
|
85
|
-
const extractPageBackground = (data)=>{
|
|
86
|
-
try {
|
|
87
|
-
const pageBackgroundStr = data?.metafields?.find((item)=>item?.key === 'page_background')?.value;
|
|
88
|
-
return JSON.parse(pageBackgroundStr ?? '{}');
|
|
89
|
-
} catch {
|
|
90
|
-
return {};
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
const parseBuilderLibraryTemplate = (data)=>{
|
|
94
|
-
return normalizePageSectionResponseV2([
|
|
95
|
-
...data?.sections ?? []
|
|
96
|
-
], data?.sectionPosition);
|
|
97
|
-
};
|
|
98
|
-
const parseShopLibraryPageTemplate = (data)=>{
|
|
99
|
-
return normalizePageSectionResponseV2([
|
|
100
|
-
...data?.shopLibrarySections ?? []
|
|
101
|
-
], data?.sectionPosition);
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
export { extractPageBackground, normalizeBuilderData, normalizePageSectionResponseV2, parseBuilderLibraryTemplate, parseBuilderTemplate, parseBuilderTemplateV2, parseShopLibraryPageTemplate };
|
|
1
|
+
let normalizeBuilderData=e=>{let t={};function r(e,t={}){if(e){let{childrens:i,dateModified:a,editorConfigs:n,...o}=e;if("section"===o.type)t[o.uid]=o;else{let e=i?.map(e=>e?.uid)??[];t[o.uid]={...o,childrens:e},i&&i.map(e=>r(e,t))}}}return r(e,t),{...t}},orderSection=(e,t)=>{let r=t?.filter(t=>e?.some(e=>e?.id===t)),i=r?.map(t=>e?.find(e=>e?.id===t))??[],a=e?.filter(e=>(!e?.id||!r?.includes(e.id))&&!e?.deletedAt)??[];return i.concat(a)};function normalizePageSectionResponse(e,t){let r=orderSection(e,t),i=r.map(e=>{if(!e?.component)return!1;try{let t=JSON.parse(e.component);return t}catch{return!1}}).filter(Boolean);return normalizeBuilderData({uid:"ROOT",tag:"Root",childrens:i})}function normalizePageSectionResponseV2(e,t){let r=orderSection(e,t),i=r.map(e=>{if(!e?.component)return!1;try{let t=JSON.parse(e.component);return t}catch{return!1}}).filter(Boolean);return i.map(e=>({uid:e.uid,lazy:!!e.settings?.lazy,priority:!!e.settings?.priority,data:normalizeBuilderData(e)}))}let parseBuilderTemplateV2=e=>normalizePageSectionResponseV2([...e?.pageSections??[],...e?.themePageCustomSections??[],...e?.themeSections??[]],e?.sectionPosition),parseBuilderTemplate=e=>normalizePageSectionResponse([...e?.pageSections??[],...e?.themePageCustomSections??[]],e?.sectionPosition),extractPageBackground=e=>{try{let t=e?.metafields?.find(e=>e?.key==="page_background")?.value;return JSON.parse(t??"{}")}catch{return{}}},parseBuilderLibraryTemplate=e=>normalizePageSectionResponseV2([...e?.sections??[]],e?.sectionPosition),parseShopLibraryPageTemplate=e=>normalizePageSectionResponseV2([...e?.shopLibrarySections??[]],e?.sectionPosition);export{extractPageBackground,normalizeBuilderData,normalizePageSectionResponseV2,parseBuilderLibraryTemplate,parseBuilderTemplate,parseBuilderTemplateV2,parseShopLibraryPageTemplate};
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
|
|
2
|
-
if (!json) return null;
|
|
3
|
-
try {
|
|
4
|
-
return JSON.parse(json);
|
|
5
|
-
} catch (_e) {
|
|
6
|
-
return null;
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
const serializableJson = (props)=>{
|
|
10
|
-
return JSON.parse(JSON.stringify(props));
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export { parseJson, serializableJson };
|
|
1
|
+
let parseJson=r=>{if(!r)return null;try{return JSON.parse(r)}catch(r){return null}},serializableJson=r=>JSON.parse(JSON.stringify(r));export{parseJson,serializableJson};
|
|
@@ -1,15 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const sentryCaptureException = (funcName, message, data, options)=>{
|
|
4
|
-
withScope((scope)=>{
|
|
5
|
-
scope.setLevel(options?.level ?? 'log');
|
|
6
|
-
if (options?.tag) {
|
|
7
|
-
scope.setTag(options?.tag.key, options?.tag.value);
|
|
8
|
-
}
|
|
9
|
-
scope.setExtra('function', funcName);
|
|
10
|
-
scope.setExtra('data', JSON.stringify(data));
|
|
11
|
-
captureMessage(`${funcName}: ${message}`);
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export { sentryCaptureException };
|
|
1
|
+
import{withScope as t,captureMessage as e}from"@sentry/nextjs";let sentryCaptureException=(a,r,n,s)=>{t(t=>{t.setLevel(s?.level??"log"),s?.tag&&t.setTag(s?.tag.key,s?.tag.value),t.setExtra("function",a),t.setExtra("data",JSON.stringify(n)),e(`${a}: ${r}`)})};export{sentryCaptureException};
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
function isBot(
|
|
2
|
-
return /Googlebot|Mediapartners-Google|AdsBot-Google|googleweblight|Storebot-Google|Google-PageRenderer|Chrome-Lighthouse|Bingbot|BingPreview|Slurp|DuckDuckBot|baiduspider|yandex|sogou|LinkedInBot|bitlybot|tumblr|vkShare|quora link preview|facebookexternalhit|facebookcatalog|Twitterbot|applebot|redditbot|Slackbot|Discordbot|WhatsApp|SkypeUriPreview|ia_archiver/i.test(input);
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export { isBot };
|
|
1
|
+
function isBot(o){return/Googlebot|Mediapartners-Google|AdsBot-Google|googleweblight|Storebot-Google|Google-PageRenderer|Chrome-Lighthouse|Bingbot|BingPreview|Slurp|DuckDuckBot|baiduspider|yandex|sogou|LinkedInBot|bitlybot|tumblr|vkShare|quora link preview|facebookexternalhit|facebookcatalog|Twitterbot|applebot|redditbot|Slackbot|Discordbot|WhatsApp|SkypeUriPreview|ia_archiver/i.test(o)}export{isBot};
|