@gem-sdk/pages 2.0.0-staging.120 → 2.0.2
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 +0 -1
- package/dist/cjs/components/ErrorFallback.js +0 -1
- package/dist/cjs/components/FacebookPixel.js +9 -7
- package/dist/cjs/components/FooterForPostPurchase.js +0 -1
- package/dist/cjs/components/GoogleAnalytic.js +10 -9
- package/dist/cjs/components/TikTokPixel.js +0 -1
- package/dist/cjs/components/builder/Body.js +0 -1
- package/dist/cjs/components/builder/Footer.js +0 -1
- package/dist/cjs/components/builder/Header.js +4 -3
- package/dist/cjs/components/builder/InteractionSelectOnPageHeader.js +192 -0
- package/dist/cjs/components/builder/PopupManager.js +0 -1
- package/dist/cjs/components/builder/SwitchView.js +0 -1
- package/dist/cjs/components/builder/Toolbar.js +0 -1
- package/dist/cjs/components/builder/Toolbox.js +0 -1
- package/dist/cjs/components/image-to-layout/AddSectionImageToLayout.js +0 -1
- package/dist/cjs/components/image-to-layout/DropElement.js +0 -1
- package/dist/cjs/components/image-to-layout/ImageToLayout.js +0 -1
- package/dist/cjs/index.js +14 -12
- package/dist/cjs/layouts/main.js +0 -1
- package/dist/cjs/libs/api/get-post-purchase-props-preview.js +0 -1
- package/dist/cjs/libs/api/get-static-page-props-preview.js +9 -5
- package/dist/cjs/libs/api/get-static-page-props-v2.js +1 -2
- package/dist/cjs/libs/helpers/normalize.js +0 -9
- package/dist/cjs/libs/helpers/sentry.js +17 -0
- package/dist/cjs/libs/hooks/use-tracking-view.js +0 -1
- package/dist/cjs/pages/static-v2.js +2 -9
- package/dist/esm/components/ErrorBoundary.js +0 -1
- package/dist/esm/components/ErrorFallback.js +0 -1
- package/dist/esm/components/FacebookPixel.js +9 -7
- package/dist/esm/components/FooterForPostPurchase.js +0 -1
- package/dist/esm/components/GoogleAnalytic.js +10 -9
- package/dist/esm/components/TikTokPixel.js +0 -1
- package/dist/esm/components/builder/Body.js +0 -1
- package/dist/esm/components/builder/Footer.js +0 -1
- package/dist/esm/components/builder/Header.js +4 -3
- package/dist/esm/components/builder/InteractionSelectOnPageHeader.js +188 -0
- package/dist/esm/components/builder/PopupManager.js +0 -1
- package/dist/esm/components/builder/SwitchView.js +0 -1
- package/dist/esm/components/builder/Toolbar.js +0 -1
- package/dist/esm/components/builder/Toolbox.js +0 -1
- package/dist/esm/components/image-to-layout/AddSectionImageToLayout.js +0 -1
- package/dist/esm/components/image-to-layout/DropElement.js +0 -1
- package/dist/esm/components/image-to-layout/ImageToLayout.js +0 -1
- package/dist/esm/index.js +7 -6
- package/dist/esm/layouts/main.js +0 -1
- package/dist/esm/libs/api/get-post-purchase-props-preview.js +0 -1
- package/dist/esm/libs/api/get-static-page-props-preview.js +10 -6
- package/dist/esm/libs/api/get-static-page-props-v2.js +2 -3
- package/dist/esm/libs/helpers/normalize.js +1 -9
- package/dist/esm/libs/helpers/sentry.js +15 -0
- package/dist/esm/libs/hooks/use-tracking-view.js +0 -1
- package/dist/esm/pages/static-v2.js +2 -9
- package/dist/types/index.d.ts +32 -34
- package/package.json +5 -5
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
'use client';
|
|
2
1
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
2
|
import { gtag } from '@gem-sdk/core';
|
|
4
|
-
import {
|
|
3
|
+
import { useRouter } from 'next/router';
|
|
5
4
|
import Script from 'next/script';
|
|
6
5
|
import { useEffect } from 'react';
|
|
7
6
|
|
|
8
7
|
const GoogleAnalytic = ({ trackingId })=>{
|
|
9
|
-
const
|
|
10
|
-
const pathName = usePathname();
|
|
8
|
+
const router = useRouter();
|
|
11
9
|
useEffect(()=>{
|
|
12
|
-
const url = pathName + searchParams.toString();
|
|
13
10
|
const handleRouteChange = (url)=>{
|
|
14
11
|
gtag.pageview(url, trackingId);
|
|
15
12
|
};
|
|
16
|
-
handleRouteChange
|
|
13
|
+
router.events.on('routeChangeComplete', handleRouteChange);
|
|
14
|
+
router.events.on('hashChangeComplete', handleRouteChange);
|
|
15
|
+
return ()=>{
|
|
16
|
+
router.events.off('routeChangeComplete', handleRouteChange);
|
|
17
|
+
router.events.off('hashChangeComplete', handleRouteChange);
|
|
18
|
+
};
|
|
17
19
|
}, [
|
|
18
20
|
trackingId,
|
|
19
|
-
|
|
20
|
-
searchParams
|
|
21
|
+
router.events
|
|
21
22
|
]);
|
|
22
23
|
const handleOnReady = ()=>{
|
|
23
|
-
gtag.pageview(
|
|
24
|
+
gtag.pageview(router.pathname, trackingId);
|
|
24
25
|
};
|
|
25
26
|
if (!trackingId) return null;
|
|
26
27
|
if (trackingId.startsWith('UA-')) return /*#__PURE__*/ jsxs(Fragment, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
'use client';
|
|
2
1
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
2
|
import { useShopStore, usePageStore, cls, makeStyleResponsive } from '@gem-sdk/core';
|
|
4
3
|
import Devices from './SwitchView.js';
|
|
4
|
+
import InteractionSelectOnPageHeader from './InteractionSelectOnPageHeader.js';
|
|
5
5
|
|
|
6
6
|
const defaultMargin = {
|
|
7
7
|
desktop: '16px',
|
|
@@ -18,7 +18,7 @@ const sizeCheck = {
|
|
|
18
18
|
const Header = (props)=>{
|
|
19
19
|
const { pageType, isOriginTemplate, openPageSetting } = props;
|
|
20
20
|
const layoutSetting = useShopStore((s)=>s.layoutSettings);
|
|
21
|
-
usePageStore((s)=>s.sidebarMode);
|
|
21
|
+
const sidebarMode = usePageStore((s)=>s.sidebarMode);
|
|
22
22
|
const activeHeader = layoutSetting?.showHeader || isOriginTemplate;
|
|
23
23
|
const headerColor = activeHeader ? HEADER_ON_COLOR : HEADER_OFF_COLOR;
|
|
24
24
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
@@ -176,7 +176,8 @@ const Header = (props)=>{
|
|
|
176
176
|
})
|
|
177
177
|
]
|
|
178
178
|
})
|
|
179
|
-
})
|
|
179
|
+
}),
|
|
180
|
+
sidebarMode === 'interaction' && /*#__PURE__*/ jsx(InteractionSelectOnPageHeader, {})
|
|
180
181
|
]
|
|
181
182
|
});
|
|
182
183
|
};
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { usePageStore, useInteraction } from '@gem-sdk/core';
|
|
3
|
+
import { useState, useRef, useCallback, useEffect, useMemo } from 'react';
|
|
4
|
+
|
|
5
|
+
const InteractionSelectOnPageHeader = ()=>{
|
|
6
|
+
const selectType = usePageStore((s)=>s.interactionData?.selectType);
|
|
7
|
+
const settingType = usePageStore((s)=>s.interactionData?.settingType);
|
|
8
|
+
const setInteractionSelectType = usePageStore((s)=>s.setInteractionSelectType);
|
|
9
|
+
const { closeSelectOnPage, changeSelectMode } = useInteraction();
|
|
10
|
+
const [hoverOption, setHoverOption] = useState(null);
|
|
11
|
+
const [openDropdown, setOpenDropdown] = useState(false);
|
|
12
|
+
const popupRef = useRef(null);
|
|
13
|
+
const isSelectOnPage = usePageStore((s)=>s.interactionData?.isSelectOnPage);
|
|
14
|
+
const handleSetInteraction = (type)=>{
|
|
15
|
+
setOpenDropdown(false);
|
|
16
|
+
setInteractionSelectType(type);
|
|
17
|
+
changeSelectMode(type);
|
|
18
|
+
if (type == 'PAGE') closeSelectOnPage();
|
|
19
|
+
};
|
|
20
|
+
const handleClickOutside = useCallback((event)=>{
|
|
21
|
+
if (!openDropdown) return;
|
|
22
|
+
if (popupRef.current && !popupRef.current.contains(event.target)) {
|
|
23
|
+
setOpenDropdown(false);
|
|
24
|
+
}
|
|
25
|
+
}, [
|
|
26
|
+
openDropdown
|
|
27
|
+
]);
|
|
28
|
+
useEffect(()=>{
|
|
29
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
30
|
+
return ()=>{
|
|
31
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
32
|
+
};
|
|
33
|
+
}, [
|
|
34
|
+
handleClickOutside
|
|
35
|
+
]);
|
|
36
|
+
const isShowOverlay = useMemo(()=>{
|
|
37
|
+
return hoverOption !== 'ELEMENT' && (selectType === 'PAGE' || selectType === 'ELEMENT' && hoverOption === 'PAGE') && settingType === 'TRIGGER';
|
|
38
|
+
}, [
|
|
39
|
+
hoverOption,
|
|
40
|
+
selectType
|
|
41
|
+
]);
|
|
42
|
+
const title = useMemo(()=>{
|
|
43
|
+
const type = selectType === 'ELEMENT' ? 'an element' : 'entire page';
|
|
44
|
+
if (settingType === 'TRIGGER') return `Start with triggering ${type}`;
|
|
45
|
+
return `Set ${selectType === 'ELEMENT' ? 'an element' : 'entire page'} as target`;
|
|
46
|
+
}, [
|
|
47
|
+
selectType,
|
|
48
|
+
settingType
|
|
49
|
+
]);
|
|
50
|
+
const renderIconCheckSvg = ()=>{
|
|
51
|
+
return /*#__PURE__*/ jsx("div", {
|
|
52
|
+
className: "gp-w-[21px]",
|
|
53
|
+
children: /*#__PURE__*/ jsx("svg", {
|
|
54
|
+
width: "21",
|
|
55
|
+
height: "20",
|
|
56
|
+
viewBox: "0 0 21 20",
|
|
57
|
+
fill: "none",
|
|
58
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
59
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
60
|
+
fillRule: "evenodd",
|
|
61
|
+
clipRule: "evenodd",
|
|
62
|
+
d: "M16.3415 5.1766C16.5528 5.41207 16.5528 5.79383 16.3415 6.0293L8.45016 14.8234C8.34869 14.9365 8.21107 15 8.06757 15C7.92408 15 7.78645 14.9365 7.68499 14.8234L4.65846 11.4505C4.44717 11.215 4.44718 10.8333 4.65848 10.5978C4.86978 10.3623 5.21236 10.3623 5.42365 10.5978L8.06759 13.5443L15.5764 5.1766C15.7877 4.94113 16.1302 4.94113 16.3415 5.1766Z",
|
|
63
|
+
fill: "#00C853"
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
if (!isSelectOnPage) return null;
|
|
69
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
70
|
+
children: [
|
|
71
|
+
/*#__PURE__*/ jsx("header", {
|
|
72
|
+
className: "gp-flex gp-text-[12px] gp-justify-center gp-items-center gp-h-10 gp-fixed gp-top-0 gp-left-0 gp-w-full gp-z-[1000] gp-bg-[#151515] gp-text-white interaction-select-mode-header",
|
|
73
|
+
children: /*#__PURE__*/ jsxs("section", {
|
|
74
|
+
className: "gp-flex gp-bg-[#151515]/[0.15] gp-items-center gp-h-full gp-rounded-b-lg gp-pt-1 gp-gap-2",
|
|
75
|
+
children: [
|
|
76
|
+
/*#__PURE__*/ jsxs("div", {
|
|
77
|
+
className: "gp-relative",
|
|
78
|
+
children: [
|
|
79
|
+
/*#__PURE__*/ jsxs("button", {
|
|
80
|
+
className: `gp-h-full hover:gp-bg-[#7190FF] gp-w-[280px] gp-gap-2 gp-py-2 gp-px-4 gp-items-center gp-justify-center gp-leading-5 gp-font-medium gp-flex gp-rounded-b-[8px] gp-bg-[#3C67FF] gp-text-[#F9F9F9]`,
|
|
81
|
+
onClick: ()=>setOpenDropdown((prev)=>!prev),
|
|
82
|
+
children: [
|
|
83
|
+
/*#__PURE__*/ jsx("p", {
|
|
84
|
+
className: "gp-grow",
|
|
85
|
+
children: title
|
|
86
|
+
}),
|
|
87
|
+
settingType === 'TRIGGER' && /*#__PURE__*/ jsx("div", {
|
|
88
|
+
className: "gp-w-[21px]",
|
|
89
|
+
children: /*#__PURE__*/ jsx("svg", {
|
|
90
|
+
width: "16",
|
|
91
|
+
height: "16",
|
|
92
|
+
viewBox: "0 0 16 16",
|
|
93
|
+
fill: "currentColor",
|
|
94
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
95
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
96
|
+
fillRule: "evenodd",
|
|
97
|
+
clipRule: "evenodd",
|
|
98
|
+
d: "M4.13017 6.11716C4.30374 5.96095 4.58515 5.96095 4.75871 6.11716L8 9.03431L11.2413 6.11716C11.4149 5.96095 11.6963 5.96095 11.8698 6.11716C12.0434 6.27337 12.0434 6.52663 11.8698 6.68284L8.31427 9.88284C8.1407 10.0391 7.8593 10.0391 7.68573 9.88284L4.13017 6.68284C3.95661 6.52663 3.95661 6.27337 4.13017 6.11716Z",
|
|
99
|
+
fill: "currentColor"
|
|
100
|
+
})
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
]
|
|
104
|
+
}),
|
|
105
|
+
openDropdown && settingType === 'TRIGGER' && /*#__PURE__*/ jsxs("div", {
|
|
106
|
+
ref: popupRef,
|
|
107
|
+
className: "gp-p-2 gp-flex gp-flex-col gp-absolute gp-top-[calc(100%_+_4px)] gp-w-[280px] gp-bg-[#151515] gp-rounded-xl gp-text-white",
|
|
108
|
+
children: [
|
|
109
|
+
/*#__PURE__*/ jsxs("div", {
|
|
110
|
+
className: "gp-p-2 gp-flex gp-gap-2 gp-cursor-pointer hover:gp-bg-[#3b3b3b] gp-rounded-lg",
|
|
111
|
+
"aria-hidden": true,
|
|
112
|
+
onClick: ()=>handleSetInteraction('ELEMENT'),
|
|
113
|
+
onMouseOver: ()=>setHoverOption('ELEMENT'),
|
|
114
|
+
onFocus: ()=>setHoverOption('ELEMENT'),
|
|
115
|
+
onMouseLeave: ()=>setHoverOption(null),
|
|
116
|
+
children: [
|
|
117
|
+
selectType === 'ELEMENT' ? renderIconCheckSvg() : /*#__PURE__*/ jsx("div", {
|
|
118
|
+
className: "gp-w-[21px]",
|
|
119
|
+
children: /*#__PURE__*/ jsx("svg", {
|
|
120
|
+
width: "18",
|
|
121
|
+
height: "18",
|
|
122
|
+
viewBox: "0 0 18 18",
|
|
123
|
+
fill: "none",
|
|
124
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
125
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
126
|
+
fillRule: "evenodd",
|
|
127
|
+
clipRule: "evenodd",
|
|
128
|
+
d: "M8.99983 0.351562C9.34501 0.351562 9.62483 0.631385 9.62483 0.976562V2.15278C12.923 2.45 15.5496 5.07654 15.8468 8.37476H17.0233C17.3684 8.37476 17.6483 8.65458 17.6483 8.99976C17.6483 9.34493 17.3684 9.62476 17.0233 9.62476H15.8468C15.5496 12.923 12.923 15.5495 9.62483 15.8467V17.0232C9.62483 17.3683 9.34501 17.6482 8.99983 17.6482C8.65465 17.6482 8.37483 17.3683 8.37483 17.0232V15.8467C5.07662 15.5495 2.45007 12.923 2.15286 9.62476H0.976562C0.631385 9.62476 0.351562 9.34493 0.351562 8.99976C0.351562 8.65458 0.631385 8.37476 0.976562 8.37476H2.15286C2.45007 5.07654 5.07662 2.45 8.37483 2.15278V0.976562C8.37483 0.631385 8.65465 0.351562 8.99983 0.351562ZM3.40916 9.62476H5.97656C6.32174 9.62476 6.60156 9.34493 6.60156 8.99976C6.60156 8.65458 6.32174 8.37476 5.97656 8.37476H3.40916C3.69738 5.7675 5.76757 3.6973 8.37483 3.40909V5.97656C8.37483 6.32174 8.65465 6.60156 8.99983 6.60156C9.34501 6.60156 9.62483 6.32174 9.62483 5.97656V3.40909C12.2321 3.6973 14.3023 5.7675 14.5905 8.37476H12.0233C11.6781 8.37476 11.3983 8.65458 11.3983 8.99976C11.3983 9.34493 11.6781 9.62476 12.0233 9.62476H14.5905C14.3023 12.232 12.2321 14.3022 9.62483 14.5904V12.0232C9.62483 11.678 9.34501 11.3982 8.99983 11.3982C8.65465 11.3982 8.37483 11.678 8.37483 12.0232V14.5904C5.76757 14.3022 3.69738 12.232 3.40916 9.62476Z",
|
|
129
|
+
fill: "#AAAAAA"
|
|
130
|
+
})
|
|
131
|
+
})
|
|
132
|
+
}),
|
|
133
|
+
/*#__PURE__*/ jsx("p", {
|
|
134
|
+
className: "gp-h-[21px]",
|
|
135
|
+
children: "An element"
|
|
136
|
+
})
|
|
137
|
+
]
|
|
138
|
+
}),
|
|
139
|
+
/*#__PURE__*/ jsxs("div", {
|
|
140
|
+
className: "gp-p-2 gp-flex gp-gap-2 gp-cursor-pointer hover:gp-bg-[#3b3b3b] gp-rounded-lg",
|
|
141
|
+
onClick: ()=>handleSetInteraction('PAGE'),
|
|
142
|
+
onMouseOver: ()=>setHoverOption('PAGE'),
|
|
143
|
+
onFocus: ()=>setHoverOption('PAGE'),
|
|
144
|
+
onMouseLeave: ()=>setHoverOption(null),
|
|
145
|
+
"aria-hidden": true,
|
|
146
|
+
children: [
|
|
147
|
+
selectType === 'PAGE' ? renderIconCheckSvg() : /*#__PURE__*/ jsx("svg", {
|
|
148
|
+
width: "21",
|
|
149
|
+
height: "20",
|
|
150
|
+
viewBox: "0 0 21 20",
|
|
151
|
+
fill: "none",
|
|
152
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
153
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
154
|
+
fillRule: "evenodd",
|
|
155
|
+
clipRule: "evenodd",
|
|
156
|
+
d: "M7.25 4.5C6.55964 4.5 6 5.05964 6 5.75V14.25C6 14.9404 6.55964 15.5 7.25 15.5H13.75C14.4404 15.5 15 14.9404 15 14.25V9.5H11.75C10.7835 9.5 10 8.7165 10 7.75V4.5H7.25ZM11.5 5.56066L13.9393 8H11.75C11.6119 8 11.5 7.88807 11.5 7.75V5.56066ZM4.5 5.75C4.5 4.23122 5.73122 3 7.25 3H10.75C10.9489 3 11.1397 3.07902 11.2803 3.21967L16.2803 8.21967C16.421 8.36032 16.5 8.55109 16.5 8.75V14.25C16.5 15.7688 15.2688 17 13.75 17H7.25C5.73122 17 4.5 15.7688 4.5 14.25V5.75Z",
|
|
157
|
+
fill: "#AAAAAA"
|
|
158
|
+
})
|
|
159
|
+
}),
|
|
160
|
+
/*#__PURE__*/ jsx("p", {
|
|
161
|
+
className: "gp-h-[21px]",
|
|
162
|
+
children: "Entire page"
|
|
163
|
+
})
|
|
164
|
+
]
|
|
165
|
+
})
|
|
166
|
+
]
|
|
167
|
+
})
|
|
168
|
+
]
|
|
169
|
+
}),
|
|
170
|
+
/*#__PURE__*/ jsx("button", {
|
|
171
|
+
className: "",
|
|
172
|
+
onClick: closeSelectOnPage,
|
|
173
|
+
children: "Cancel"
|
|
174
|
+
})
|
|
175
|
+
]
|
|
176
|
+
})
|
|
177
|
+
}),
|
|
178
|
+
isShowOverlay && /*#__PURE__*/ jsx("div", {
|
|
179
|
+
className: `gp-w-full gp-fixed gp-top-0 gp-left-0 gp-mt-[40px] gp-z-[999] gp-bg-[#3c67ff]/[0.25] gp-pointer-events-none`,
|
|
180
|
+
style: {
|
|
181
|
+
height: 'calc(100% - 40px)'
|
|
182
|
+
}
|
|
183
|
+
})
|
|
184
|
+
]
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
export { InteractionSelectOnPageHeader as default };
|
package/dist/esm/index.js
CHANGED
|
@@ -16,6 +16,12 @@ export { isBot } from './libs/helpers/user-agent.js';
|
|
|
16
16
|
export { normalizePageSectionResponseV2, parseBuilderTemplateV2 } from './libs/helpers/normalize.js';
|
|
17
17
|
export { getFallbackV2 } from './libs/helpers/get-fallback.js';
|
|
18
18
|
export { retryWithDelay } from './libs/helpers/common.js';
|
|
19
|
+
export { default as CollectionDetailPage } from './pages/collection-detail.js';
|
|
20
|
+
export { PreviewPage } from './pages/preview.js';
|
|
21
|
+
export { default as ProductDetailPage } from './pages/product-detail.js';
|
|
22
|
+
export { default as StaticPage } from './pages/static.js';
|
|
23
|
+
export { BuilderPage } from './pages/builder.js';
|
|
24
|
+
export { StaticPageV2 } from './pages/static-v2.js';
|
|
19
25
|
export { getStaticPaths } from './libs/getStaticPaths.js';
|
|
20
26
|
export { getFontFromGroupSetting, getFontsFromDataBuilder } from './libs/helpers/gen-fonts.js';
|
|
21
27
|
export { getFontFromGlobalStyle, getFonts } from './libs/google-fonts.js';
|
|
@@ -27,9 +33,4 @@ export { Page500 } from './pages/500.js';
|
|
|
27
33
|
export { GoogleAnalytic } from './components/GoogleAnalytic.js';
|
|
28
34
|
export { FacebookPixel } from './components/FacebookPixel.js';
|
|
29
35
|
export { TikTokPixel } from './components/TikTokPixel.js';
|
|
30
|
-
export {
|
|
31
|
-
export { PreviewPage } from './pages/preview.js';
|
|
32
|
-
export { default as ProductDetailPage } from './pages/product-detail.js';
|
|
33
|
-
export { default as StaticPage } from './pages/static.js';
|
|
34
|
-
export { BuilderPage } from './pages/builder.js';
|
|
35
|
-
export { StaticPageV2 } from './pages/static-v2.js';
|
|
36
|
+
export { parseHtml } from './libs/parse-html.js';
|
package/dist/esm/layouts/main.js
CHANGED
|
@@ -5,9 +5,10 @@ import { getFontStyleFromPageTemplate, getFontFromGlobalStyle } from '../google-
|
|
|
5
5
|
import { genCSS } from '../helpers/gen-css.js';
|
|
6
6
|
import { generateManifest } from '../helpers/generate-manifres.js';
|
|
7
7
|
import { getFallbackV2 } from '../helpers/get-fallback.js';
|
|
8
|
-
import { parseBuilderTemplateV2
|
|
8
|
+
import { parseBuilderTemplateV2 } from '../helpers/normalize.js';
|
|
9
9
|
import { parseJson, serializableJson } from '../helpers/parse-json.js';
|
|
10
10
|
import { getCustomFonts } from '../custom-fonts.js';
|
|
11
|
+
import { sentryCaptureException } from '../helpers/sentry.js';
|
|
11
12
|
|
|
12
13
|
const getStaticPagePropsPreview = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
13
14
|
try {
|
|
@@ -29,6 +30,10 @@ const getStaticPagePropsPreview = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
29
30
|
])
|
|
30
31
|
]);
|
|
31
32
|
if (theme.status === 'rejected') {
|
|
33
|
+
sentryCaptureException('PreviewThemePageDocument', JSON.stringify(theme), {
|
|
34
|
+
variables,
|
|
35
|
+
theme
|
|
36
|
+
});
|
|
32
37
|
throw new Error(theme.reason?.[0]);
|
|
33
38
|
}
|
|
34
39
|
const dataBuilder = theme.value.previewThemePage;
|
|
@@ -43,7 +48,7 @@ const getStaticPagePropsPreview = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
43
48
|
getFallbackV2(fetcher, pageTemplate),
|
|
44
49
|
getCustomFonts(themePageCustomFonts)
|
|
45
50
|
]);
|
|
46
|
-
const mobileOnly =
|
|
51
|
+
const mobileOnly = dataBuilder.isMobile ?? false;
|
|
47
52
|
const description = dataBuilder?.dataSEO?.find((item)=>item?.key === 'global-meta-description')?.value;
|
|
48
53
|
const thumbnail = parseJson(dataBuilder?.dataSEO?.find((item)=>item?.key === 'global-meta-thumbnail')?.value);
|
|
49
54
|
const shopMeta = shopifyMeta.status === 'fulfilled' ? shopifyMeta.value : undefined;
|
|
@@ -117,15 +122,15 @@ const getStaticPagePropsPreview = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
117
122
|
};
|
|
118
123
|
const languageIsoCode = shopMeta?.localization.language.isoCode ?? null;
|
|
119
124
|
const countryIsoCode = shopMeta?.localization.country.isoCode ?? null;
|
|
120
|
-
const locale = languageIsoCode
|
|
125
|
+
const locale = !languageIsoCode || !countryIsoCode ? null : `${languageIsoCode}-${countryIsoCode}`;
|
|
121
126
|
return serializableJson({
|
|
122
127
|
themeStyle: genCSS(dataBuilder?.themeStyle?.data, mobileOnly),
|
|
123
128
|
fontStyle,
|
|
124
129
|
elementFontStyle,
|
|
125
130
|
builderData: pageTemplate,
|
|
126
131
|
pageType,
|
|
127
|
-
moneyFormat: shopMeta?.shop
|
|
128
|
-
currency: shopMeta?.localization
|
|
132
|
+
moneyFormat: shopMeta?.shop.moneyFormat ?? null,
|
|
133
|
+
currency: shopMeta?.localization.country.currency.isoCode ?? null,
|
|
129
134
|
languageIsoCode,
|
|
130
135
|
countryIsoCode,
|
|
131
136
|
locale,
|
|
@@ -141,7 +146,6 @@ const getStaticPagePropsPreview = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
141
146
|
customCodeHeader: dataBuilder.customCode?.header ?? null,
|
|
142
147
|
customCodeBody: dataBuilder.customCode?.body ?? null,
|
|
143
148
|
customFonts,
|
|
144
|
-
pageBackground: extractPageBackground(dataBuilder),
|
|
145
149
|
interaction: dataBuilder?.interaction
|
|
146
150
|
});
|
|
147
151
|
} catch (err) {
|
|
@@ -4,7 +4,7 @@ import { getFontStyleFromPageTemplate, getFontFromGlobalStyle } from '../google-
|
|
|
4
4
|
import { genCSS } from '../helpers/gen-css.js';
|
|
5
5
|
import { generateManifest } from '../helpers/generate-manifres.js';
|
|
6
6
|
import { getFallbackV2 } from '../helpers/get-fallback.js';
|
|
7
|
-
import { parseBuilderTemplateV2
|
|
7
|
+
import { parseBuilderTemplateV2 } from '../helpers/normalize.js';
|
|
8
8
|
import { parseJson, serializableJson } from '../helpers/parse-json.js';
|
|
9
9
|
import { captureException } from '@sentry/nextjs';
|
|
10
10
|
import { getCustomFonts } from '../custom-fonts.js';
|
|
@@ -150,8 +150,7 @@ const getStaticPagePropsV2 = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
150
150
|
customCodeBody: dataBuilder.themePageCustomCode?.body ?? null,
|
|
151
151
|
pageHandle: dataBuilder.handle ?? null,
|
|
152
152
|
customFonts,
|
|
153
|
-
interaction: dataBuilder?.interaction
|
|
154
|
-
pageBackground: extractPageBackground(dataBuilder)
|
|
153
|
+
interaction: dataBuilder?.interaction
|
|
155
154
|
});
|
|
156
155
|
} catch (err) {
|
|
157
156
|
captureException(err);
|
|
@@ -81,14 +81,6 @@ const parseBuilderTemplate = (data)=>{
|
|
|
81
81
|
...data?.themePageCustomSections ?? []
|
|
82
82
|
], data?.sectionPosition);
|
|
83
83
|
};
|
|
84
|
-
const extractPageBackground = (data)=>{
|
|
85
|
-
try {
|
|
86
|
-
const pageBackgroundStr = data?.metafields?.find((item)=>item?.key === 'page_background')?.value;
|
|
87
|
-
return JSON.parse(pageBackgroundStr ?? '{}');
|
|
88
|
-
} catch {
|
|
89
|
-
return {};
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
84
|
const parseBuilderLibraryTemplate = (data)=>{
|
|
93
85
|
return normalizePageSectionResponseV2([
|
|
94
86
|
...data?.sections ?? []
|
|
@@ -100,4 +92,4 @@ const parseShopLibraryPageTemplate = (data)=>{
|
|
|
100
92
|
], data?.sectionPosition);
|
|
101
93
|
};
|
|
102
94
|
|
|
103
|
-
export {
|
|
95
|
+
export { normalizeBuilderData, normalizePageSectionResponseV2, parseBuilderLibraryTemplate, parseBuilderTemplate, parseBuilderTemplateV2, parseShopLibraryPageTemplate };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { withScope, captureMessage } from '@sentry/nextjs';
|
|
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 };
|
|
@@ -10,7 +10,7 @@ import FooterForPostPurchase from '../components/FooterForPostPurchase.js';
|
|
|
10
10
|
import Script from 'next/script';
|
|
11
11
|
import { useEffect } from 'react';
|
|
12
12
|
|
|
13
|
-
const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, fontStyle, elementFontStyle, customCodeHeader, shopToken, pageHandle, customFonts, isPostPurchase, shopName, productOffers, publicStoreFrontData, isPreview, interaction
|
|
13
|
+
const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, fontStyle, elementFontStyle, customCodeHeader, shopToken, pageHandle, customFonts, isPostPurchase, shopName, productOffers, publicStoreFrontData, isPreview, interaction })=>{
|
|
14
14
|
const router = useRouter();
|
|
15
15
|
const baseAssetURL = process.env.NEXT_GP_BASE_ASSET_URL || 'https://d3kbi0je7pp4lw.cloudfront.net';
|
|
16
16
|
useTrackingView(shopToken, pageHandle, router.isFallback);
|
|
@@ -78,14 +78,7 @@ const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, f
|
|
|
78
78
|
dangerouslySetInnerHTML: {
|
|
79
79
|
__html: customFonts
|
|
80
80
|
}
|
|
81
|
-
}, fontStyle)
|
|
82
|
-
pageBackground?.isUsePageBackground && pageBackground?.background && /*#__PURE__*/ jsx("style", {
|
|
83
|
-
children: `
|
|
84
|
-
body {
|
|
85
|
-
background: ${pageBackground.background};
|
|
86
|
-
}
|
|
87
|
-
`
|
|
88
|
-
}, `page_background_${pageBackground?.background}`)
|
|
81
|
+
}, fontStyle)
|
|
89
82
|
]
|
|
90
83
|
}),
|
|
91
84
|
/*#__PURE__*/ jsx(PageProvider, {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -42,10 +42,6 @@ type PageBuilderProps = {
|
|
|
42
42
|
customFonts?: string | null;
|
|
43
43
|
interaction?: ShopType.Maybe<Pick<ShopType.PublishedPageInteraction, "id" | "value">>;
|
|
44
44
|
timezone?: string;
|
|
45
|
-
pageBackground?: {
|
|
46
|
-
isUsePageBackground?: boolean;
|
|
47
|
-
background?: string;
|
|
48
|
-
};
|
|
49
45
|
};
|
|
50
46
|
type PageBuilderPropsV2 = {
|
|
51
47
|
builderData?: {
|
|
@@ -162,6 +158,36 @@ type RetryConfig = {
|
|
|
162
158
|
};
|
|
163
159
|
declare const retryWithDelay: <T = unknown>(fn: () => T, config?: RetryConfig) => Promise<T>;
|
|
164
160
|
|
|
161
|
+
type PreviewPageProps = {
|
|
162
|
+
components: Record<string, React.ComponentType<any>>;
|
|
163
|
+
pageType: ShopType.PublishedThemePageType;
|
|
164
|
+
};
|
|
165
|
+
declare const PreviewPage: React.FC<PreviewPageProps>;
|
|
166
|
+
|
|
167
|
+
type StaticPageProps = PageBuilderProps;
|
|
168
|
+
declare const StaticPage: React.FC<StaticPageProps & AdditionalPageBuilderProps>;
|
|
169
|
+
|
|
170
|
+
type BuilderPageProps = {
|
|
171
|
+
components: Record<string, React.ComponentType<any>>;
|
|
172
|
+
seo?: NextSeoProps;
|
|
173
|
+
themeStyle?: string | null;
|
|
174
|
+
fontStyle?: string | null;
|
|
175
|
+
header?: BuilderState;
|
|
176
|
+
footer?: BuilderState;
|
|
177
|
+
sectionData?: Record<string, SectionData$1>;
|
|
178
|
+
storefrontToken?: string | null;
|
|
179
|
+
storefrontHandle?: string | null;
|
|
180
|
+
shopToken?: string | null;
|
|
181
|
+
mode?: RenderMode;
|
|
182
|
+
pageType: ShopType.PublishedThemePageType;
|
|
183
|
+
editorImageToLayout?: boolean;
|
|
184
|
+
isThemeSectionEditor?: boolean;
|
|
185
|
+
hiddenToolbar?: boolean;
|
|
186
|
+
pageName: string;
|
|
187
|
+
isOriginTemplate?: boolean;
|
|
188
|
+
};
|
|
189
|
+
declare const BuilderPage: React.FC<BuilderPageProps>;
|
|
190
|
+
|
|
165
191
|
declare const getStaticPaths: GetStaticPaths;
|
|
166
192
|
|
|
167
193
|
type TypographyV2FontFamilyType = 'google' | 'custom' | 'theme' | 'bunny';
|
|
@@ -232,34 +258,6 @@ type Props = {
|
|
|
232
258
|
};
|
|
233
259
|
declare const TikTokPixel: ({ pixelId }: Props) => react_jsx_runtime.JSX.Element | null;
|
|
234
260
|
|
|
235
|
-
|
|
236
|
-
components: Record<string, React.ComponentType<any>>;
|
|
237
|
-
pageType: ShopType.PublishedThemePageType;
|
|
238
|
-
};
|
|
239
|
-
declare const PreviewPage: React.FC<PreviewPageProps>;
|
|
240
|
-
|
|
241
|
-
type StaticPageProps = PageBuilderProps;
|
|
242
|
-
declare const StaticPage: React.FC<StaticPageProps & AdditionalPageBuilderProps>;
|
|
243
|
-
|
|
244
|
-
type BuilderPageProps = {
|
|
245
|
-
components: Record<string, React.ComponentType<any>>;
|
|
246
|
-
seo?: NextSeoProps;
|
|
247
|
-
themeStyle?: string | null;
|
|
248
|
-
fontStyle?: string | null;
|
|
249
|
-
header?: BuilderState;
|
|
250
|
-
footer?: BuilderState;
|
|
251
|
-
sectionData?: Record<string, SectionData$1>;
|
|
252
|
-
storefrontToken?: string | null;
|
|
253
|
-
storefrontHandle?: string | null;
|
|
254
|
-
shopToken?: string | null;
|
|
255
|
-
mode?: RenderMode;
|
|
256
|
-
pageType: ShopType.PublishedThemePageType;
|
|
257
|
-
editorImageToLayout?: boolean;
|
|
258
|
-
isThemeSectionEditor?: boolean;
|
|
259
|
-
hiddenToolbar?: boolean;
|
|
260
|
-
pageName: string;
|
|
261
|
-
isOriginTemplate?: boolean;
|
|
262
|
-
};
|
|
263
|
-
declare const BuilderPage: React.FC<BuilderPageProps>;
|
|
261
|
+
declare const parseHtml: (key: string, html?: string | null, isHead?: boolean) => string | JSX.Element | JSX.Element[] | undefined;
|
|
264
262
|
|
|
265
|
-
export { AppPropsWithLayout, BuilderPage, CollectionDetailPage, CollectionPageProps, ErrorBoundary, ErrorFallback, FacebookPixel, GoogleAnalytic, NextPageWithLayout, Page404, Page500, PageBuilderProps,
|
|
263
|
+
export { AppPropsWithLayout, BuilderPage, CollectionDetailPage, CollectionPageProps, ErrorBoundary, ErrorFallback, FacebookPixel, GoogleAnalytic, NextPageWithLayout, Page404, Page500, PageBuilderProps, PreviewPage, ProductDetailPage, ProductPageProps, StaticPage, StaticPageProps, StaticPagePropsV2, StaticPageV2, TikTokPixel, createAppAPIFetcher, createFetcher, createShopifyFetcher, genCSS, getBuilderProps, getCollectionProps, getFallbackV2, getFontFromGlobalStyle, getFontFromGroupSetting, getFonts, getFontsFromDataBuilder, getHomePageProps, getHomePagePropsV2, getLayout, getPostPurchasePropsPreview, getPreviewProps, getProductProps, getStaticPagePropsPreview, getStaticPagePropsV2, getStaticPaths, getStorefrontApi, isBot, normalizePageSectionResponseV2, parseBuilderTemplateV2, parseHtml, retryWithDelay, usePagePreview, useTrackingView };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/pages",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"next": "latest"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@gem-sdk/core": "2.0.
|
|
30
|
-
"@gem-sdk/plugin-cookie-bar": "1.58.0
|
|
31
|
-
"@gem-sdk/plugin-quick-view": "1.58.0
|
|
32
|
-
"@gem-sdk/plugin-sticky-add-to-cart": "1.58.0
|
|
29
|
+
"@gem-sdk/core": "2.0.2",
|
|
30
|
+
"@gem-sdk/plugin-cookie-bar": "1.58.0",
|
|
31
|
+
"@gem-sdk/plugin-quick-view": "1.58.0",
|
|
32
|
+
"@gem-sdk/plugin-sticky-add-to-cart": "1.58.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"next": ">=13"
|