@gem-sdk/pages 1.60.9 → 1.60.12
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/index.js +2 -0
- package/dist/cjs/layouts/main.js +1 -1
- package/dist/cjs/libs/parse-html.js +6 -5
- package/dist/cjs/pages/static-v2.js +13 -3
- package/dist/esm/index.js +1 -0
- package/dist/esm/layouts/main.js +1 -1
- package/dist/esm/libs/parse-html.js +6 -5
- package/dist/esm/pages/static-v2.js +13 -3
- package/dist/types/index.d.ts +3 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -35,6 +35,7 @@ var _500 = require('./pages/500.js');
|
|
|
35
35
|
var GoogleAnalytic = require('./components/GoogleAnalytic.js');
|
|
36
36
|
var FacebookPixel = require('./components/FacebookPixel.js');
|
|
37
37
|
var TikTokPixel = require('./components/TikTokPixel.js');
|
|
38
|
+
var parseHtml = require('./libs/parse-html.js');
|
|
38
39
|
|
|
39
40
|
|
|
40
41
|
|
|
@@ -78,3 +79,4 @@ exports.Page500 = _500.Page500;
|
|
|
78
79
|
exports.GoogleAnalytic = GoogleAnalytic.GoogleAnalytic;
|
|
79
80
|
exports.FacebookPixel = FacebookPixel.FacebookPixel;
|
|
80
81
|
exports.TikTokPixel = TikTokPixel.TikTokPixel;
|
|
82
|
+
exports.parseHtml = parseHtml.parseHtml;
|
package/dist/cjs/layouts/main.js
CHANGED
|
@@ -10,7 +10,7 @@ const MainLayout = ({ children, ...props })=>{
|
|
|
10
10
|
const mobileOnly = core.useShopStore((s)=>s.mobileOnly);
|
|
11
11
|
return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
12
12
|
children: [
|
|
13
|
-
parseHtml.parseHtml(props?.customCodeBody),
|
|
13
|
+
parseHtml.parseHtml('custom-code-body', props?.customCodeBody),
|
|
14
14
|
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
15
15
|
className: core.cls({
|
|
16
16
|
'gp-max-w-mobile gp-mx-auto gp-w-full': mobileOnly
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var parse = require('html-react-parser');
|
|
5
|
-
var Script = require('next/script');
|
|
6
5
|
|
|
7
|
-
const parseHtml = (html, isHead)=>{
|
|
6
|
+
const parseHtml = (key, html, isHead)=>{
|
|
8
7
|
if (!html) return undefined;
|
|
9
8
|
try {
|
|
10
9
|
return parse(html, {
|
|
@@ -12,16 +11,18 @@ const parseHtml = (html, isHead)=>{
|
|
|
12
11
|
if (node.type !== 'script' || !(node instanceof parse.Element)) return null;
|
|
13
12
|
const child = node.children?.[0];
|
|
14
13
|
if (!child) return null;
|
|
15
|
-
if (!(child instanceof parse.Text) && !isHead) return /*#__PURE__*/ jsxRuntime.jsx(
|
|
14
|
+
if (!(child instanceof parse.Text) && !isHead) return /*#__PURE__*/ jsxRuntime.jsx("script", {
|
|
15
|
+
id: key,
|
|
16
16
|
...node.attribs
|
|
17
|
-
});
|
|
17
|
+
}, key);
|
|
18
18
|
if (child instanceof parse.Text && isHead) {
|
|
19
19
|
return /*#__PURE__*/ jsxRuntime.jsx("script", {
|
|
20
|
+
id: key,
|
|
20
21
|
...node.attribs,
|
|
21
22
|
dangerouslySetInnerHTML: {
|
|
22
23
|
__html: child.data
|
|
23
24
|
}
|
|
24
|
-
});
|
|
25
|
+
}, key);
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
});
|
|
@@ -10,11 +10,13 @@ var parseHtml = require('../libs/parse-html.js');
|
|
|
10
10
|
var Header = require('../components/builder/Header.js');
|
|
11
11
|
var FooterForPostPurchase = require('../components/FooterForPostPurchase.js');
|
|
12
12
|
var Script = require('next/script');
|
|
13
|
+
var react = require('react');
|
|
13
14
|
|
|
14
15
|
const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, fontStyle, elementFontStyle, customCodeHeader, shopToken, pageHandle, customFonts, isPostPurchase, shopName, productOffers, publicStoreFrontData, isPreview, interaction })=>{
|
|
15
16
|
const router$1 = router.useRouter();
|
|
16
17
|
const baseAssetURL = process.env.NEXT_GP_BASE_ASSET_URL || 'https://d3kbi0je7pp4lw.cloudfront.net';
|
|
17
18
|
useTrackingView.useTrackingView(shopToken, pageHandle, router$1.isFallback);
|
|
19
|
+
const customCodeHeaderID = 'custom-code-header';
|
|
18
20
|
if (router$1.isFallback) {
|
|
19
21
|
return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
20
22
|
className: "gp-flex gp-h-[100vh] gp-items-center gp-justify-center",
|
|
@@ -34,6 +36,14 @@ const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, f
|
|
|
34
36
|
})
|
|
35
37
|
});
|
|
36
38
|
}
|
|
39
|
+
react.useEffect(()=>{
|
|
40
|
+
const customCodeHeaderElement = document.querySelectorAll(`#${customCodeHeaderID}`);
|
|
41
|
+
if (customCodeHeaderElement.length > 1) {
|
|
42
|
+
customCodeHeaderElement.forEach((script, index)=>{
|
|
43
|
+
if (index !== 0) script.remove();
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}, []);
|
|
37
47
|
return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
38
48
|
children: [
|
|
39
49
|
/*#__PURE__*/ jsxRuntime.jsx(nextSeo.NextSeo, {
|
|
@@ -41,21 +51,21 @@ const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, f
|
|
|
41
51
|
}),
|
|
42
52
|
/*#__PURE__*/ jsxRuntime.jsxs(Head, {
|
|
43
53
|
children: [
|
|
44
|
-
parseHtml.parseHtml(customCodeHeader, true),
|
|
54
|
+
parseHtml.parseHtml(customCodeHeaderID, customCodeHeader, true),
|
|
45
55
|
themeStyle && /*#__PURE__*/ jsxRuntime.jsx("style", {
|
|
46
56
|
"data-id": "global-style",
|
|
47
57
|
type: "text/css",
|
|
48
58
|
dangerouslySetInnerHTML: {
|
|
49
59
|
__html: themeStyle
|
|
50
60
|
}
|
|
51
|
-
}),
|
|
61
|
+
}, "global-style"),
|
|
52
62
|
fontStyle && /*#__PURE__*/ jsxRuntime.jsx("style", {
|
|
53
63
|
"data-id": "google-fonts",
|
|
54
64
|
type: "text/css",
|
|
55
65
|
dangerouslySetInnerHTML: {
|
|
56
66
|
__html: fontStyle
|
|
57
67
|
}
|
|
58
|
-
}),
|
|
68
|
+
}, "google-fonts"),
|
|
59
69
|
elementFontStyle && elementFontStyle.map((fontStyle)=>/*#__PURE__*/ jsxRuntime.jsx("style", {
|
|
60
70
|
"data-id": "google-element-fonts",
|
|
61
71
|
type: "text/css",
|
package/dist/esm/index.js
CHANGED
|
@@ -33,3 +33,4 @@ export { Page500 } from './pages/500.js';
|
|
|
33
33
|
export { GoogleAnalytic } from './components/GoogleAnalytic.js';
|
|
34
34
|
export { FacebookPixel } from './components/FacebookPixel.js';
|
|
35
35
|
export { TikTokPixel } from './components/TikTokPixel.js';
|
|
36
|
+
export { parseHtml } from './libs/parse-html.js';
|
package/dist/esm/layouts/main.js
CHANGED
|
@@ -6,7 +6,7 @@ const MainLayout = ({ children, ...props })=>{
|
|
|
6
6
|
const mobileOnly = useShopStore((s)=>s.mobileOnly);
|
|
7
7
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
8
8
|
children: [
|
|
9
|
-
parseHtml(props?.customCodeBody),
|
|
9
|
+
parseHtml('custom-code-body', props?.customCodeBody),
|
|
10
10
|
/*#__PURE__*/ jsx("div", {
|
|
11
11
|
className: cls({
|
|
12
12
|
'gp-max-w-mobile gp-mx-auto gp-w-full': mobileOnly
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import parse, { Element, Text } from 'html-react-parser';
|
|
3
|
-
import Script from 'next/script';
|
|
4
3
|
|
|
5
|
-
const parseHtml = (html, isHead)=>{
|
|
4
|
+
const parseHtml = (key, html, isHead)=>{
|
|
6
5
|
if (!html) return undefined;
|
|
7
6
|
try {
|
|
8
7
|
return parse(html, {
|
|
@@ -10,16 +9,18 @@ const parseHtml = (html, isHead)=>{
|
|
|
10
9
|
if (node.type !== 'script' || !(node instanceof Element)) return null;
|
|
11
10
|
const child = node.children?.[0];
|
|
12
11
|
if (!child) return null;
|
|
13
|
-
if (!(child instanceof Text) && !isHead) return /*#__PURE__*/ jsx(
|
|
12
|
+
if (!(child instanceof Text) && !isHead) return /*#__PURE__*/ jsx("script", {
|
|
13
|
+
id: key,
|
|
14
14
|
...node.attribs
|
|
15
|
-
});
|
|
15
|
+
}, key);
|
|
16
16
|
if (child instanceof Text && isHead) {
|
|
17
17
|
return /*#__PURE__*/ jsx("script", {
|
|
18
|
+
id: key,
|
|
18
19
|
...node.attribs,
|
|
19
20
|
dangerouslySetInnerHTML: {
|
|
20
21
|
__html: child.data
|
|
21
22
|
}
|
|
22
|
-
});
|
|
23
|
+
}, key);
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
});
|
|
@@ -8,11 +8,13 @@ import { parseHtml } from '../libs/parse-html.js';
|
|
|
8
8
|
import Header from '../components/builder/Header.js';
|
|
9
9
|
import FooterForPostPurchase from '../components/FooterForPostPurchase.js';
|
|
10
10
|
import Script from 'next/script';
|
|
11
|
+
import { useEffect } from 'react';
|
|
11
12
|
|
|
12
13
|
const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, fontStyle, elementFontStyle, customCodeHeader, shopToken, pageHandle, customFonts, isPostPurchase, shopName, productOffers, publicStoreFrontData, isPreview, interaction })=>{
|
|
13
14
|
const router = useRouter();
|
|
14
15
|
const baseAssetURL = process.env.NEXT_GP_BASE_ASSET_URL || 'https://d3kbi0je7pp4lw.cloudfront.net';
|
|
15
16
|
useTrackingView(shopToken, pageHandle, router.isFallback);
|
|
17
|
+
const customCodeHeaderID = 'custom-code-header';
|
|
16
18
|
if (router.isFallback) {
|
|
17
19
|
return /*#__PURE__*/ jsx("div", {
|
|
18
20
|
className: "gp-flex gp-h-[100vh] gp-items-center gp-justify-center",
|
|
@@ -32,6 +34,14 @@ const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, f
|
|
|
32
34
|
})
|
|
33
35
|
});
|
|
34
36
|
}
|
|
37
|
+
useEffect(()=>{
|
|
38
|
+
const customCodeHeaderElement = document.querySelectorAll(`#${customCodeHeaderID}`);
|
|
39
|
+
if (customCodeHeaderElement.length > 1) {
|
|
40
|
+
customCodeHeaderElement.forEach((script, index)=>{
|
|
41
|
+
if (index !== 0) script.remove();
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}, []);
|
|
35
45
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
36
46
|
children: [
|
|
37
47
|
/*#__PURE__*/ jsx(NextSeo, {
|
|
@@ -39,21 +49,21 @@ const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, f
|
|
|
39
49
|
}),
|
|
40
50
|
/*#__PURE__*/ jsxs(Head, {
|
|
41
51
|
children: [
|
|
42
|
-
parseHtml(customCodeHeader, true),
|
|
52
|
+
parseHtml(customCodeHeaderID, customCodeHeader, true),
|
|
43
53
|
themeStyle && /*#__PURE__*/ jsx("style", {
|
|
44
54
|
"data-id": "global-style",
|
|
45
55
|
type: "text/css",
|
|
46
56
|
dangerouslySetInnerHTML: {
|
|
47
57
|
__html: themeStyle
|
|
48
58
|
}
|
|
49
|
-
}),
|
|
59
|
+
}, "global-style"),
|
|
50
60
|
fontStyle && /*#__PURE__*/ jsx("style", {
|
|
51
61
|
"data-id": "google-fonts",
|
|
52
62
|
type: "text/css",
|
|
53
63
|
dangerouslySetInnerHTML: {
|
|
54
64
|
__html: fontStyle
|
|
55
65
|
}
|
|
56
|
-
}),
|
|
66
|
+
}, "google-fonts"),
|
|
57
67
|
elementFontStyle && elementFontStyle.map((fontStyle)=>/*#__PURE__*/ jsx("style", {
|
|
58
68
|
"data-id": "google-element-fonts",
|
|
59
69
|
type: "text/css",
|
package/dist/types/index.d.ts
CHANGED
|
@@ -257,4 +257,6 @@ type Props = {
|
|
|
257
257
|
};
|
|
258
258
|
declare const TikTokPixel: ({ pixelId }: Props) => react_jsx_runtime.JSX.Element | null;
|
|
259
259
|
|
|
260
|
-
|
|
260
|
+
declare const parseHtml: (key: string, html?: string | null, isHead?: boolean) => string | JSX.Element | JSX.Element[] | undefined;
|
|
261
|
+
|
|
262
|
+
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 };
|