@gem-sdk/pages 1.36.20 → 2.0.0-dev.832
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 -36
- package/dist/cjs/components/Footer.js +1 -125
- package/dist/cjs/components/FooterForPostPurchase.js +1 -0
- package/dist/cjs/components/GoogleAnalytic.js +5 -67
- package/dist/cjs/components/Header.js +1 -96
- package/dist/cjs/components/TikTokPixel.js +3 -19
- package/dist/cjs/components/builder/PopupManager.js +1 -62
- package/dist/cjs/components/builder/Toolbar.js +1 -883
- package/dist/cjs/components/builder/Toolbox.js +1 -384
- package/dist/cjs/components/builder/toolbar/Onboarding.js +1 -110
- package/dist/cjs/components/image-to-layout/AddSectionImageToLayout.js +1 -263
- package/dist/cjs/components/image-to-layout/DropElement.js +1 -164
- package/dist/cjs/components/image-to-layout/ImageToLayout.js +1 -41
- package/dist/cjs/index.js +1 -75
- package/dist/cjs/layouts/main.js +1 -30
- package/dist/cjs/libs/api/get-builder-props.js +1 -41
- package/dist/cjs/libs/api/get-collection-props.js +1 -68
- package/dist/cjs/libs/api/get-home-page-props-v2.js +1 -145
- package/dist/cjs/libs/api/get-home-page-props.js +1 -151
- package/dist/cjs/libs/api/get-post-purchase-props-preview.js +1 -0
- 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 -150
- package/dist/cjs/libs/api/get-static-page-props-v2.js +1 -152
- package/dist/cjs/libs/api/get-static-page-props.js +1 -148
- package/dist/cjs/libs/custom-fonts.js +6 -60
- package/dist/cjs/libs/fetcher.js +1 -67
- 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 -81
- package/dist/cjs/libs/helpers/common.js +1 -27
- package/dist/cjs/libs/helpers/gen-css.js +1 -117
- package/dist/cjs/libs/helpers/gen-fonts.js +1 -68
- package/dist/cjs/libs/helpers/generate-manifres.js +1 -5
- package/dist/cjs/libs/helpers/get-fallback.js +1 -35
- package/dist/cjs/libs/helpers/normalize.js +1 -90
- package/dist/cjs/libs/helpers/parse-json.js +1 -16
- package/dist/cjs/libs/helpers/user-agent.js +1 -7
- package/dist/cjs/libs/hooks/use-tracking-view.js +1 -45
- package/dist/cjs/libs/hooks/usePagePreview.js +1 -0
- package/dist/cjs/libs/parse-html.js +1 -42
- 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 -103
- 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 +1 -91
- package/dist/cjs/pages/static.js +1 -75
- package/dist/esm/components/ErrorBoundary.js +1 -38
- package/dist/esm/components/ErrorFallback.js +1 -24
- package/dist/esm/components/FacebookPixel.js +3 -34
- package/dist/esm/components/Footer.js +1 -121
- package/dist/esm/components/FooterForPostPurchase.js +1 -0
- package/dist/esm/components/GoogleAnalytic.js +5 -65
- package/dist/esm/components/Header.js +1 -92
- package/dist/esm/components/TikTokPixel.js +3 -17
- package/dist/esm/components/builder/PopupManager.js +1 -58
- package/dist/esm/components/builder/Toolbar.js +1 -879
- package/dist/esm/components/builder/Toolbox.js +1 -380
- package/dist/esm/components/builder/toolbar/Onboarding.js +1 -106
- package/dist/esm/components/image-to-layout/AddSectionImageToLayout.js +1 -259
- package/dist/esm/components/image-to-layout/DropElement.js +1 -162
- package/dist/esm/components/image-to-layout/ImageToLayout.js +1 -37
- package/dist/esm/index.js +1 -33
- package/dist/esm/layouts/main.js +1 -26
- package/dist/esm/libs/api/get-builder-props.js +1 -39
- package/dist/esm/libs/api/get-collection-props.js +1 -66
- package/dist/esm/libs/api/get-home-page-props-v2.js +1 -143
- package/dist/esm/libs/api/get-home-page-props.js +1 -149
- package/dist/esm/libs/api/get-post-purchase-props-preview.js +1 -0
- 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 -148
- package/dist/esm/libs/api/get-static-page-props-v2.js +1 -150
- package/dist/esm/libs/api/get-static-page-props.js +1 -146
- package/dist/esm/libs/custom-fonts.js +6 -55
- package/dist/esm/libs/fetcher.js +1 -64
- 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 -75
- package/dist/esm/libs/helpers/common.js +1 -24
- package/dist/esm/libs/helpers/gen-css.js +1 -115
- package/dist/esm/libs/helpers/gen-fonts.js +1 -65
- package/dist/esm/libs/helpers/generate-manifres.js +1 -3
- package/dist/esm/libs/helpers/get-fallback.js +1 -33
- package/dist/esm/libs/helpers/normalize.js +1 -85
- package/dist/esm/libs/helpers/parse-json.js +1 -13
- package/dist/esm/libs/helpers/user-agent.js +1 -5
- package/dist/esm/libs/hooks/use-tracking-view.js +1 -43
- package/dist/esm/libs/hooks/usePagePreview.js +1 -0
- package/dist/esm/libs/parse-html.js +1 -40
- 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 -101
- 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 +1 -89
- package/dist/esm/pages/static.js +1 -71
- package/dist/types/index.d.ts +28 -6
- package/package.json +5 -5
|
@@ -1,115 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import merge from 'deepmerge';
|
|
3
|
-
|
|
4
|
-
const baseDevices = {
|
|
5
|
-
tablet: '1023px',
|
|
6
|
-
mobile: '767px'
|
|
7
|
-
};
|
|
8
|
-
const flattenObject = (obj, prefix)=>{
|
|
9
|
-
return Object.keys(obj).reduce((acc, k)=>{
|
|
10
|
-
const pre = prefix ? `${prefix}-` : '';
|
|
11
|
-
if (typeof obj[k] === 'object' && obj[k] !== null && Object.keys(obj[k]).length > 0) Object.assign(acc, flattenObject(obj[k], pre + k));
|
|
12
|
-
else acc[pre + k] = obj[k];
|
|
13
|
-
return acc;
|
|
14
|
-
}, {});
|
|
15
|
-
};
|
|
16
|
-
const devicesOrder = [
|
|
17
|
-
'desktop',
|
|
18
|
-
'tablet',
|
|
19
|
-
'mobile'
|
|
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
|
-
};
|
|
66
|
-
return deviceData;
|
|
67
|
-
};
|
|
68
|
-
const genCSSVariable = (deviceData)=>{
|
|
69
|
-
return Object.entries(mapObject(flattenObject(deviceData))).map(([key, value])=>{
|
|
70
|
-
if (value === undefined) return undefined;
|
|
71
|
-
if ([
|
|
72
|
-
'font-heading',
|
|
73
|
-
'font-body'
|
|
74
|
-
].includes(key)) {
|
|
75
|
-
return `--g-${key}: '${value}'`;
|
|
76
|
-
}
|
|
77
|
-
return `--g-${key}:${value}`;
|
|
78
|
-
}).filter((v)=>v !== undefined).join(';');
|
|
79
|
-
};
|
|
80
|
-
const genCSS = (input, mobileOnly)=>{
|
|
81
|
-
if (!input) return '';
|
|
82
|
-
let data = {};
|
|
83
|
-
try {
|
|
84
|
-
if (typeof input === 'string') {
|
|
85
|
-
data = JSON.parse(input);
|
|
86
|
-
} else {
|
|
87
|
-
data = input;
|
|
88
|
-
}
|
|
89
|
-
if (mobileOnly) {
|
|
90
|
-
const desktop = getValueByDevice(data, 'desktop');
|
|
91
|
-
const mobile = getValueByDevice(data, 'mobile');
|
|
92
|
-
const deviceData = merge(desktop, mobile);
|
|
93
|
-
deviceData.color = data.color;
|
|
94
|
-
deviceData.radius = data.radius;
|
|
95
|
-
const cssData = genCSSVariable(deviceData);
|
|
96
|
-
return `:root{${cssData}}`;
|
|
97
|
-
}
|
|
98
|
-
return devicesOrder.map((device)=>{
|
|
99
|
-
const deviceData = getValueByDevice(data, device);
|
|
100
|
-
if (device === 'desktop') {
|
|
101
|
-
deviceData.color = data.color;
|
|
102
|
-
deviceData.radius = data.radius;
|
|
103
|
-
}
|
|
104
|
-
const cssData = genCSSVariable(deviceData);
|
|
105
|
-
if (device === 'desktop') {
|
|
106
|
-
return `:root{${cssData}}`;
|
|
107
|
-
}
|
|
108
|
-
return `@media (max-width: ${baseDevices[device]}) {:root{${cssData}}}`;
|
|
109
|
-
}).join('\n');
|
|
110
|
-
} catch {
|
|
111
|
-
return '';
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
export { genCSS };
|
|
1
|
+
import{getShortName as e}from"@gem-sdk/core";import t from"deepmerge";let baseDevices={tablet:"1023px",mobile:"767px"},flattenObject=(e,t)=>Object.keys(e).reduce((r,o)=>{let i=t?`${t}-`:"";return"object"==typeof e[o]&&null!==e[o]&&Object.keys(e[o]).length>0?Object.assign(r,flattenObject(e[o],i+o)):r[i+o]=e[o],r},{}),devicesOrder=["desktop","tablet","mobile"],mapObject=t=>Object.entries(t??{}).reduce((t,[r,o])=>({...t,[e(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]))};return r},genCSSVariable=e=>Object.entries(mapObject(flattenObject(e))).map(([e,t])=>{if(void 0!==t)return["font-heading","font-body"].includes(e)?`--g-${e}: '${t}'`:`--g-${e}:${t}`}).filter(e=>void 0!==e).join(";"),genCSS=(e,r)=>{if(!e)return"";let o={};try{if(o="string"==typeof e?JSON.parse(e):e,r){let e=getValueByDevice(o,"desktop"),r=getValueByDevice(o,"mobile"),i=t(e,r);i.color=o.color,i.radius=o.radius;let n=genCSSVariable(i);return`:root{${n}}`}return devicesOrder.map(e=>{let t=getValueByDevice(o,e);"desktop"===e&&(t.color=o.color,t.radius=o.radius);let r=genCSSVariable(t);return"desktop"===e?`:root{${r}}`:`@media (max-width: ${baseDevices[e]}) {:root{${r}}}`}).join("\n")}catch{return""}};export{genCSS};
|
|
@@ -1,65 +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
|
-
for(const attr in groupSetting){
|
|
16
|
-
if (Object.prototype.hasOwnProperty.call(groupSetting, attr)) {
|
|
17
|
-
const value = groupSetting[attr];
|
|
18
|
-
if (value) {
|
|
19
|
-
const customFontFamily = value.custom?.fontFamily;
|
|
20
|
-
let customFontVariants = value.custom?.fontVariants;
|
|
21
|
-
if (!customFontVariants?.length) {
|
|
22
|
-
customFontVariants = [
|
|
23
|
-
value.custom?.fontWeight
|
|
24
|
-
];
|
|
25
|
-
}
|
|
26
|
-
if (customFontFamily && customFontVariants?.length) {
|
|
27
|
-
const variants = customFontVariants.map((item)=>{
|
|
28
|
-
switch(item){
|
|
29
|
-
case 'regular':
|
|
30
|
-
return '400';
|
|
31
|
-
}
|
|
32
|
-
return item;
|
|
33
|
-
});
|
|
34
|
-
const customFontWeight = value.custom?.fontWeight && variants.includes(value.custom?.fontWeight) ? value.custom?.fontWeight : variants[0];
|
|
35
|
-
if (customFontWeight) {
|
|
36
|
-
const isExist = fonts.find((item)=>item.family == customFontFamily && item.variants.includes(customFontWeight));
|
|
37
|
-
if (!isExist) {
|
|
38
|
-
const isFontFamily = fonts.find((item)=>item.family == customFontFamily);
|
|
39
|
-
if (isFontFamily) {
|
|
40
|
-
isFontFamily.variants.push(customFontWeight);
|
|
41
|
-
} else {
|
|
42
|
-
const fontVariants = [
|
|
43
|
-
customFontWeight
|
|
44
|
-
];
|
|
45
|
-
if (customFontWeight !== '700') {
|
|
46
|
-
if (variants.includes('700')) {
|
|
47
|
-
fontVariants.push('700'); // Auto add 700 for bold in editor inline
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
fonts.push({
|
|
51
|
-
family: customFontFamily,
|
|
52
|
-
variants: fontVariants,
|
|
53
|
-
subsets: [],
|
|
54
|
-
type: 'google'
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export { getFontFromGroupSetting, getFontsFromDataBuilder };
|
|
1
|
+
let getFontsFromDataBuilder=t=>{let e=[];for(let o in t)if(Object.prototype.hasOwnProperty.call(t,o)){let i=t[o],n=i.styles,l=i.settings;getFontFromGroupSetting(e,n),getFontFromGroupSetting(e,l)}return e},getFontFromGroupSetting=(t,e)=>{for(let o in e)if(Object.prototype.hasOwnProperty.call(e,o)){let i=e[o];if(i){let e=i.custom?.fontFamily,o=i.custom?.fontVariants;if(o?.length||(o=[i.custom?.fontWeight]),e&&o?.length){let n=o.map(t=>"regular"===t?"400":t),l=i.custom?.fontWeight&&n.includes(i.custom?.fontWeight)?i.custom?.fontWeight:n[0];if(l){let o=t.find(t=>t.family==e&&t.variants.includes(l));if(!o){let o=t.find(t=>t.family==e);if(o)o.variants.push(l);else{let o=[l];"700"!==l&&n.includes("700")&&o.push("700"),t.push({family:e,variants:o,subsets:[],type:"google"})}}}}}}};export{getFontFromGroupSetting,getFontsFromDataBuilder};
|
|
@@ -1,33 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const isStorefront = true;
|
|
4
|
-
const getFallbackV2 = async (fetcher, data)=>{
|
|
5
|
-
const isSample = !process.env.NEXT_PUBLIC_STOREFRONT_TOKEN;
|
|
6
|
-
const queries = data.map((v)=>prefetchQueries(v.data, {
|
|
7
|
-
isSample,
|
|
8
|
-
isStorefront
|
|
9
|
-
})).flat();
|
|
10
|
-
const datas = await Promise.allSettled(queries.map(({ query, variables, func })=>{
|
|
11
|
-
if (func) {
|
|
12
|
-
return func(fetcher, variables);
|
|
13
|
-
}
|
|
14
|
-
if (query) return fetcher([
|
|
15
|
-
query,
|
|
16
|
-
variables
|
|
17
|
-
]);
|
|
18
|
-
return {};
|
|
19
|
-
}));
|
|
20
|
-
const fallback = queries.reduce((acc, { key }, index)=>{
|
|
21
|
-
const res = datas[index];
|
|
22
|
-
if (res?.status === 'fulfilled') {
|
|
23
|
-
return {
|
|
24
|
-
...acc,
|
|
25
|
-
[key]: res.value
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
return acc;
|
|
29
|
-
}, {});
|
|
30
|
-
return fallback;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export { getFallbackV2 };
|
|
1
|
+
import{prefetchQueries as e}from"@gem-sdk/core";let isStorefront=!0,getFallbackV2=async(t,a)=>{let l=!process.env.NEXT_PUBLIC_STOREFRONT_TOKEN,r=a.map(t=>e(t.data,{isSample:l,isStorefront:!0})).flat(),o=await Promise.allSettled(r.map(({query:e,variables:a,func:l})=>l?l(t,a):e?t([e,a]):{})),s=r.reduce((e,{key:t},a)=>{let l=o[a];return l?.status==="fulfilled"?{...e,[t]:l.value}:e},{});return s};export{getFallbackV2};
|
|
@@ -1,85 +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)) ?? [];
|
|
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?.sectionPosition);
|
|
77
|
-
};
|
|
78
|
-
const parseBuilderTemplate = (data)=>{
|
|
79
|
-
return normalizePageSectionResponse([
|
|
80
|
-
...data?.pageSections ?? [],
|
|
81
|
-
...data?.themePageCustomSections ?? []
|
|
82
|
-
], data?.sectionPosition);
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export { normalizeBuilderData, normalizePageSectionResponseV2, parseBuilderTemplate, parseBuilderTemplateV2 };
|
|
1
|
+
let normalizeBuilderData=e=>{let t={};function i(e,t={}){if(e){let{childrens:n,dateModified:r,editorConfigs:o,...a}=e;if("section"===a.type)t[a.uid]=a;else{let e=n?.map(e=>e?.uid)??[];t[a.uid]={...a,childrens:e},n&&n.map(e=>i(e,t))}}}return i(e,t),{...t}},orderSection=(e,t)=>{let i=t?.filter(t=>e?.some(e=>e?.id===t)),n=i?.map(t=>e?.find(e=>e?.id===t))??[],r=e?.filter(e=>(!e?.id||!i?.includes(e.id))&&!e?.deletedAt)??[];return n.concat(r)};function normalizePageSectionResponse(e,t){let i=orderSection(e,t),n=i.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:n})}function normalizePageSectionResponseV2(e,t){let i=orderSection(e,t),n=i.map(e=>{if(!e?.component)return!1;try{let t=JSON.parse(e.component);return t}catch{return!1}}).filter(Boolean);return n.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?.sectionPosition),parseBuilderTemplate=e=>normalizePageSectionResponse([...e?.pageSections??[],...e?.themePageCustomSections??[]],e?.sectionPosition);export{normalizeBuilderData,normalizePageSectionResponseV2,parseBuilderTemplate,parseBuilderTemplateV2};
|
|
@@ -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,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};
|
|
@@ -1,43 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useCallback, useEffect } from 'react';
|
|
3
|
-
import { isBot } from '../helpers/user-agent.js';
|
|
4
|
-
|
|
5
|
-
const useTrackingView = (token, handle, isFallback)=>{
|
|
6
|
-
const shopToken = token || process.env.NEXT_PUBLIC_SHOP_TOKEN;
|
|
7
|
-
const apiURL = process.env.NEXT_PUBLIC_API_URL;
|
|
8
|
-
const sendTracking = useCallback((handle)=>{
|
|
9
|
-
if (!apiURL || !shopToken) return;
|
|
10
|
-
const bot = isBot(navigator.userAgent);
|
|
11
|
-
const variables = {
|
|
12
|
-
pageHandle: handle,
|
|
13
|
-
userAgent: bot ? 'BOT' : 'BROWSER'
|
|
14
|
-
};
|
|
15
|
-
const headers = {
|
|
16
|
-
'Content-Type': 'application/json',
|
|
17
|
-
'X-GemX-Shop-Token': shopToken
|
|
18
|
-
};
|
|
19
|
-
fetch(apiURL, {
|
|
20
|
-
method: 'POST',
|
|
21
|
-
headers,
|
|
22
|
-
body: JSON.stringify({
|
|
23
|
-
query: PageViewUpDocument,
|
|
24
|
-
variables
|
|
25
|
-
})
|
|
26
|
-
}).finally(()=>{
|
|
27
|
-
//
|
|
28
|
-
});
|
|
29
|
-
}, [
|
|
30
|
-
apiURL,
|
|
31
|
-
shopToken
|
|
32
|
-
]);
|
|
33
|
-
useEffect(()=>{
|
|
34
|
-
if (!handle || isFallback) return;
|
|
35
|
-
sendTracking(handle);
|
|
36
|
-
}, [
|
|
37
|
-
handle,
|
|
38
|
-
sendTracking,
|
|
39
|
-
isFallback
|
|
40
|
-
]);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export { useTrackingView };
|
|
1
|
+
import{PageViewUpDocument as e}from"@gem-sdk/core";import{useCallback as o,useEffect as r}from"react";let useTrackingView=(t,n,i)=>{let p=t||process.env.NEXT_PUBLIC_SHOP_TOKEN,s=process.env.NEXT_PUBLIC_API_URL,a=o(o=>{if(!s||!p)return;let r={pageHandle:o},t={"Content-Type":"application/json","X-GemX-Shop-Token":p};fetch(s,{method:"POST",headers:t,body:JSON.stringify({query:e,variables:r})}).finally(()=>{})},[s,p]);r(()=>{n&&!i&&a(n)},[n,a,i])};export{useTrackingView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{generateManifest as e}from"../helpers/generate-manifres.js";import{parseJson as o}from"../helpers/parse-json.js";let usePagePreview=(r,a,n)=>{let s=r?.isMobile??!1,i="fulfilled"===n.status?n.value:void 0,t="fulfilled"===a.status?a.value:void 0,l=t?.storeProperty?.favicon??"/favicon/favicon-32x32.png",c=i?.localization.language.isoCode??null,p=i?.localization.country.isoCode??null,m=i?.shop.moneyFormat??null,f=i?.localization.country.currency.isoCode??null,u=o(t?.storeProperty?.swatchesConfig),d=c&&p?`${c}-${p}`:null,h={defaultTitle:i?.shop.name,title:r?.name,openGraph:{site_name:i?.shop.name,locale:i?.localization.country.isoCode,title:r?.name??i?.shop.name},nofollow:!0,noindex:!0,canonical:`/preview/${r?.id}`,additionalMetaTags:[{name:"theme-color",content:"#000000"}],additionalLinkTags:[{rel:"icon",sizes:"32x32",href:`${l}-/crop/1:1/center/-/smart_resize/32x32/`},{rel:"icon",sizes:"16x16",href:`${l}-/crop/1:1/center/-/smart_resize/16x16/`},{rel:"apple-touch-icon",sizes:"180x180",href:`${l}-/crop/1:1/center/-/smart_resize/180x180/`},{rel:"manifest",href:e({theme_color:"#000000",background_color:"#ffffff",display:"standalone",scope:"/",start_url:"/",name:i?.shop.name,short_name:i?.shop.name,description:i?.shop.description,icons:[{src:`${l}-/crop/1:1/center/-/smart_resize/192x192/`,sizes:"192x192",type:"image/png",purpose:"any maskable"},{src:`${l}-/crop/1:1/center/-/smart_resize/512x512/`,sizes:"512x512",type:"image/png"}]})}]};return{seo:h,pageConfig:{mobileOnly:s,locale:d,languageIsoCode:c,countryIsoCode:p,moneyFormat:m,currency:f,swatches:u}}};export{usePagePreview};
|
|
@@ -1,40 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import parse, { Element, Text } from 'html-react-parser';
|
|
3
|
-
import Script from 'next/script';
|
|
4
|
-
|
|
5
|
-
const parseHtml = (html, isHead)=>{
|
|
6
|
-
if (!html) return undefined;
|
|
7
|
-
try {
|
|
8
|
-
return parse(html, {
|
|
9
|
-
replace: (node)=>{
|
|
10
|
-
if (node.type === 'script' && node instanceof Element) {
|
|
11
|
-
const child = node.children?.[0];
|
|
12
|
-
if (child instanceof Text) {
|
|
13
|
-
if (isHead) return /*#__PURE__*/ jsx("script", {
|
|
14
|
-
...node.attribs,
|
|
15
|
-
dangerouslySetInnerHTML: {
|
|
16
|
-
__html: child.data
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
else return /*#__PURE__*/ jsx(Script, {
|
|
20
|
-
...node.attribs,
|
|
21
|
-
dangerouslySetInnerHTML: {
|
|
22
|
-
__html: child.data
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
} else {
|
|
26
|
-
if (!isHead) {
|
|
27
|
-
return /*#__PURE__*/ jsx(Script, {
|
|
28
|
-
...node.attribs
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
} catch {
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export { parseHtml };
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";import r,{Element as e,Text as a}from"html-react-parser";import i from"next/script";let parseHtml=(n,s)=>{if(n)try{return r(n,{replace:r=>{if("script"===r.type&&r instanceof e){let e=r.children?.[0];if(e instanceof a)return s?t("script",{...r.attribs,dangerouslySetInnerHTML:{__html:e.data}}):t(i,{...r.attribs,dangerouslySetInnerHTML:{__html:e.data}});if(!s)return t(i,{...r.attribs})}}})}catch{return}};export{parseHtml};
|