@gem-sdk/pages 1.60.10 → 1.63.8

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.
@@ -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(Script, {
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
- return /*#__PURE__*/ jsxRuntime.jsx(Script, {
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
  });
@@ -3,16 +3,20 @@
3
3
  var jsxRuntime = require('react/jsx-runtime');
4
4
  var core = require('@gem-sdk/core');
5
5
  var nextSeo = require('next-seo');
6
+ var Head = require('next/head');
6
7
  var router = require('next/router');
7
8
  var useTrackingView = require('../libs/hooks/use-tracking-view.js');
9
+ var parseHtml = require('../libs/parse-html.js');
8
10
  var Header = require('../components/builder/Header.js');
9
11
  var FooterForPostPurchase = require('../components/FooterForPostPurchase.js');
10
12
  var Script = require('next/script');
13
+ var react = require('react');
11
14
 
12
- const StaticPageV2 = ({ components, builderData, sectionData, seo, shopToken, pageHandle, isPostPurchase, shopName, productOffers, publicStoreFrontData, isPreview, interaction })=>{
15
+ const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, fontStyle, elementFontStyle, customCodeHeader, shopToken, pageHandle, customFonts, isPostPurchase, shopName, productOffers, publicStoreFrontData, isPreview, interaction })=>{
13
16
  const router$1 = router.useRouter();
14
17
  const baseAssetURL = process.env.NEXT_GP_BASE_ASSET_URL || 'https://d3kbi0je7pp4lw.cloudfront.net';
15
18
  useTrackingView.useTrackingView(shopToken, pageHandle, router$1.isFallback);
19
+ const customCodeHeaderID = 'custom-code-header';
16
20
  if (router$1.isFallback) {
17
21
  return /*#__PURE__*/ jsxRuntime.jsx("div", {
18
22
  className: "gp-flex gp-h-[100vh] gp-items-center gp-justify-center",
@@ -32,11 +36,52 @@ const StaticPageV2 = ({ components, builderData, sectionData, seo, shopToken, pa
32
36
  })
33
37
  });
34
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
+ }, []);
35
47
  return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
36
48
  children: [
37
49
  /*#__PURE__*/ jsxRuntime.jsx(nextSeo.NextSeo, {
38
50
  ...seo
39
51
  }),
52
+ /*#__PURE__*/ jsxRuntime.jsxs(Head, {
53
+ children: [
54
+ parseHtml.parseHtml(customCodeHeaderID, customCodeHeader, true),
55
+ themeStyle && /*#__PURE__*/ jsxRuntime.jsx("style", {
56
+ "data-id": "global-style",
57
+ type: "text/css",
58
+ dangerouslySetInnerHTML: {
59
+ __html: themeStyle
60
+ }
61
+ }, "global-style"),
62
+ fontStyle && /*#__PURE__*/ jsxRuntime.jsx("style", {
63
+ "data-id": "google-fonts",
64
+ type: "text/css",
65
+ dangerouslySetInnerHTML: {
66
+ __html: fontStyle
67
+ }
68
+ }, "google-fonts"),
69
+ elementFontStyle && elementFontStyle.map((fontStyle)=>/*#__PURE__*/ jsxRuntime.jsx("style", {
70
+ "data-id": "google-element-fonts",
71
+ type: "text/css",
72
+ dangerouslySetInnerHTML: {
73
+ __html: fontStyle
74
+ }
75
+ }, fontStyle)),
76
+ customFonts && /*#__PURE__*/ jsxRuntime.jsx("style", {
77
+ "data-id": "custom-element-fonts",
78
+ type: "text/css",
79
+ dangerouslySetInnerHTML: {
80
+ __html: customFonts
81
+ }
82
+ }, fontStyle)
83
+ ]
84
+ }),
40
85
  /*#__PURE__*/ jsxRuntime.jsx(core.PageProvider, {
41
86
  productOffers: productOffers,
42
87
  publicStoreFrontData: publicStoreFrontData,
@@ -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(Script, {
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
- return /*#__PURE__*/ jsx(Script, {
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
  });
@@ -1,16 +1,20 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { PageProvider, BuilderComponentProvider, SectionProvider, BuilderProvider, Render } from '@gem-sdk/core';
3
3
  import { NextSeo } from 'next-seo';
4
+ import Head from 'next/head';
4
5
  import { useRouter } from 'next/router';
5
6
  import { useTrackingView } from '../libs/hooks/use-tracking-view.js';
7
+ import { parseHtml } from '../libs/parse-html.js';
6
8
  import Header from '../components/builder/Header.js';
7
9
  import FooterForPostPurchase from '../components/FooterForPostPurchase.js';
8
10
  import Script from 'next/script';
11
+ import { useEffect } from 'react';
9
12
 
10
- const StaticPageV2 = ({ components, builderData, sectionData, seo, shopToken, pageHandle, 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 })=>{
11
14
  const router = useRouter();
12
15
  const baseAssetURL = process.env.NEXT_GP_BASE_ASSET_URL || 'https://d3kbi0je7pp4lw.cloudfront.net';
13
16
  useTrackingView(shopToken, pageHandle, router.isFallback);
17
+ const customCodeHeaderID = 'custom-code-header';
14
18
  if (router.isFallback) {
15
19
  return /*#__PURE__*/ jsx("div", {
16
20
  className: "gp-flex gp-h-[100vh] gp-items-center gp-justify-center",
@@ -30,11 +34,52 @@ const StaticPageV2 = ({ components, builderData, sectionData, seo, shopToken, pa
30
34
  })
31
35
  });
32
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
+ }, []);
33
45
  return /*#__PURE__*/ jsxs(Fragment, {
34
46
  children: [
35
47
  /*#__PURE__*/ jsx(NextSeo, {
36
48
  ...seo
37
49
  }),
50
+ /*#__PURE__*/ jsxs(Head, {
51
+ children: [
52
+ parseHtml(customCodeHeaderID, customCodeHeader, true),
53
+ themeStyle && /*#__PURE__*/ jsx("style", {
54
+ "data-id": "global-style",
55
+ type: "text/css",
56
+ dangerouslySetInnerHTML: {
57
+ __html: themeStyle
58
+ }
59
+ }, "global-style"),
60
+ fontStyle && /*#__PURE__*/ jsx("style", {
61
+ "data-id": "google-fonts",
62
+ type: "text/css",
63
+ dangerouslySetInnerHTML: {
64
+ __html: fontStyle
65
+ }
66
+ }, "google-fonts"),
67
+ elementFontStyle && elementFontStyle.map((fontStyle)=>/*#__PURE__*/ jsx("style", {
68
+ "data-id": "google-element-fonts",
69
+ type: "text/css",
70
+ dangerouslySetInnerHTML: {
71
+ __html: fontStyle
72
+ }
73
+ }, fontStyle)),
74
+ customFonts && /*#__PURE__*/ jsx("style", {
75
+ "data-id": "custom-element-fonts",
76
+ type: "text/css",
77
+ dangerouslySetInnerHTML: {
78
+ __html: customFonts
79
+ }
80
+ }, fontStyle)
81
+ ]
82
+ }),
38
83
  /*#__PURE__*/ jsx(PageProvider, {
39
84
  productOffers: productOffers,
40
85
  publicStoreFrontData: publicStoreFrontData,
@@ -118,7 +118,7 @@ declare const usePagePreview: (dataBuilder: ThemePageQueryResponse['themePage'],
118
118
  pageConfig: {
119
119
  mobileOnly: boolean;
120
120
  locale: string | null;
121
- languageIsoCode: ("ID" | "AF" | "AM" | "AR" | "AZ" | "BE" | "BG" | "BM" | "BN" | "BO" | "BR" | "BS" | "CA" | "CU" | "CY" | "DE" | "DZ" | "EE" | "ES" | "ET" | "FI" | "FO" | "FR" | "GA" | "GD" | "GL" | "HR" | "HU" | "IS" | "IT" | "KI" | "KM" | "KN" | "KW" | "KY" | "LB" | "LT" | "LU" | "LV" | "MG" | "MK" | "ML" | "MN" | "MR" | "MS" | "MT" | "MY" | "NE" | "NL" | "NO" | "OM" | "PA" | "PL" | "PS" | "PT" | "RO" | "RU" | "RW" | "SD" | "SE" | "SG" | "SI" | "SK" | "SL" | "SN" | "SO" | "SR" | "SV" | "TA" | "TG" | "TH" | "TK" | "TO" | "TR" | "TT" | "UG" | "UZ" | "AK" | "AS" | "CE" | "CS" | "DA" | "EL" | "EN" | "EO" | "EU" | "FA" | "FF" | "FY" | "GU" | "GV" | "HA" | "HE" | "HI" | "HY" | "IA" | "IG" | "II" | "JA" | "JV" | "KA" | "KK" | "KL" | "KO" | "KS" | "KU" | "LG" | "LN" | "LO" | "MI" | "NB" | "ND" | "NN" | "OR" | "OS" | "PT_BR" | "PT_PT" | "QU" | "RM" | "RN" | "SQ" | "SU" | "SW" | "TE" | "TI" | "UK" | "UR" | "VI" | "VO" | "WO" | "XH" | "YI" | "YO" | "ZH" | "ZH_CN" | "ZH_TW" | "ZU") | null;
121
+ languageIsoCode: ("ID" | "AF" | "AM" | "AR" | "AZ" | "BE" | "BG" | "BM" | "BN" | "BO" | "BR" | "BS" | "CA" | "CU" | "CY" | "DE" | "DZ" | "EE" | "ES" | "ET" | "FI" | "FO" | "FR" | "GA" | "GD" | "GL" | "HR" | "HU" | "IS" | "IT" | "KI" | "KM" | "KN" | "KW" | "KY" | "LA" | "LB" | "LT" | "LU" | "LV" | "MG" | "MK" | "ML" | "MN" | "MO" | "MR" | "MS" | "MT" | "MY" | "NE" | "NL" | "NO" | "OM" | "PA" | "PL" | "PS" | "PT" | "RO" | "RU" | "RW" | "SA" | "SC" | "SD" | "SE" | "SG" | "SH" | "SI" | "SK" | "SL" | "SN" | "SO" | "SR" | "SV" | "TA" | "TG" | "TH" | "TK" | "TO" | "TR" | "TT" | "UG" | "UZ" | "AK" | "AS" | "CE" | "CKB" | "CS" | "DA" | "EL" | "EN" | "EO" | "EU" | "FA" | "FF" | "FIL" | "FY" | "GU" | "GV" | "HA" | "HE" | "HI" | "HY" | "IA" | "IG" | "II" | "JA" | "JV" | "KA" | "KK" | "KL" | "KO" | "KS" | "KU" | "LG" | "LN" | "LO" | "MI" | "NB" | "ND" | "NN" | "OR" | "OS" | "PT_BR" | "PT_PT" | "QU" | "RM" | "RN" | "SQ" | "SU" | "SW" | "TE" | "TI" | "UK" | "UR" | "VI" | "VO" | "WO" | "XH" | "YI" | "YO" | "ZH" | "ZH_CN" | "ZH_TW" | "ZU") | null;
122
122
  countryIsoCode: ("ID" | "AC" | "AD" | "AE" | "AF" | "AG" | "AI" | "AL" | "AM" | "AN" | "AO" | "AR" | "AT" | "AU" | "AW" | "AX" | "AZ" | "BA" | "BB" | "BD" | "BE" | "BF" | "BG" | "BH" | "BI" | "BJ" | "BL" | "BM" | "BN" | "BO" | "BQ" | "BR" | "BS" | "BT" | "BV" | "BW" | "BY" | "BZ" | "CA" | "CC" | "CD" | "CF" | "CG" | "CH" | "CI" | "CK" | "CL" | "CM" | "CN" | "CO" | "CR" | "CU" | "CV" | "CW" | "CX" | "CY" | "CZ" | "DE" | "DJ" | "DK" | "DM" | "DO" | "DZ" | "EC" | "EE" | "EG" | "EH" | "ER" | "ES" | "ET" | "FI" | "FJ" | "FK" | "FO" | "FR" | "GA" | "GB" | "GD" | "GE" | "GF" | "GG" | "GH" | "GI" | "GL" | "GM" | "GN" | "GP" | "GQ" | "GR" | "GS" | "GT" | "GW" | "GY" | "HK" | "HM" | "HN" | "HR" | "HT" | "HU" | "IE" | "IL" | "IM" | "IN" | "IO" | "IQ" | "IR" | "IS" | "IT" | "JE" | "JM" | "JO" | "JP" | "KE" | "KG" | "KH" | "KI" | "KM" | "KN" | "KP" | "KR" | "KW" | "KY" | "KZ" | "LA" | "LB" | "LC" | "LI" | "LK" | "LR" | "LS" | "LT" | "LU" | "LV" | "LY" | "MA" | "MC" | "MD" | "ME" | "MF" | "MG" | "MK" | "ML" | "MM" | "MN" | "MO" | "MQ" | "MR" | "MS" | "MT" | "MU" | "MV" | "MW" | "MX" | "MY" | "MZ" | "NA" | "NC" | "NE" | "NF" | "NG" | "NI" | "NL" | "NO" | "NP" | "NR" | "NU" | "NZ" | "OM" | "PA" | "PE" | "PF" | "PG" | "PH" | "PK" | "PL" | "PM" | "PN" | "PS" | "PT" | "PY" | "QA" | "RE" | "RO" | "RS" | "RU" | "RW" | "SA" | "SB" | "SC" | "SD" | "SE" | "SG" | "SH" | "SI" | "SJ" | "SK" | "SL" | "SM" | "SN" | "SO" | "SR" | "SS" | "ST" | "SV" | "SX" | "SY" | "SZ" | "TA" | "TC" | "TD" | "TF" | "TG" | "TH" | "TJ" | "TK" | "TL" | "TM" | "TN" | "TO" | "TR" | "TT" | "TV" | "TW" | "TZ" | "UA" | "UG" | "UM" | "US" | "UY" | "UZ" | "VA" | "VC" | "VE" | "VG" | "VN" | "VU" | "WF" | "WS" | "XK" | "YE" | "YT" | "ZA" | "ZM" | "ZW" | "ZZ") | null;
123
123
  moneyFormat: string | null;
124
124
  currency: ("AED" | "AFN" | "ALL" | "AMD" | "ANG" | "AOA" | "ARS" | "AUD" | "AWG" | "AZN" | "BAM" | "BBD" | "BDT" | "BGN" | "BHD" | "BIF" | "BMD" | "BND" | "BOB" | "BRL" | "BSD" | "BTN" | "BWP" | "BYN" | "BYR" | "BZD" | "CAD" | "CDF" | "CHF" | "CLP" | "CNY" | "COP" | "CRC" | "CVE" | "CZK" | "DJF" | "DKK" | "DOP" | "DZD" | "EGP" | "ERN" | "ETB" | "EUR" | "FJD" | "FKP" | "GBP" | "GEL" | "GHS" | "GIP" | "GMD" | "GNF" | "GTQ" | "GYD" | "HKD" | "HNL" | "HRK" | "HTG" | "HUF" | "IDR" | "ILS" | "INR" | "IQD" | "IRR" | "ISK" | "JEP" | "JMD" | "JOD" | "JPY" | "KES" | "KGS" | "KHR" | "KID" | "KMF" | "KRW" | "KWD" | "KYD" | "KZT" | "LAK" | "LBP" | "LKR" | "LRD" | "LSL" | "LTL" | "LVL" | "LYD" | "MAD" | "MDL" | "MGA" | "MKD" | "MMK" | "MNT" | "MOP" | "MRU" | "MUR" | "MVR" | "MWK" | "MXN" | "MYR" | "MZN" | "NAD" | "NGN" | "NIO" | "NOK" | "NPR" | "NZD" | "OMR" | "PAB" | "PEN" | "PGK" | "PHP" | "PKR" | "PLN" | "PYG" | "QAR" | "RON" | "RSD" | "RUB" | "RWF" | "SAR" | "SBD" | "SCR" | "SDG" | "SEK" | "SGD" | "SHP" | "SLL" | "SOS" | "SRD" | "SSP" | "STD" | "STN" | "SYP" | "SZL" | "THB" | "TJS" | "TMT" | "TND" | "TOP" | "TRY" | "TTD" | "TWD" | "TZS" | "UAH" | "UGX" | "USD" | "UYU" | "UZS" | "VED" | "VEF" | "VES" | "VND" | "VUV" | "WST" | "XAF" | "XCD" | "XOF" | "XPF" | "XXX" | "YER" | "ZAR" | "ZMW") | null;
@@ -257,6 +257,6 @@ type Props = {
257
257
  };
258
258
  declare const TikTokPixel: ({ pixelId }: Props) => react_jsx_runtime.JSX.Element | null;
259
259
 
260
- declare const parseHtml: (html?: string | null, isHead?: boolean) => string | JSX.Element | JSX.Element[] | undefined;
260
+ declare const parseHtml: (key: string, html?: string | null, isHead?: boolean) => string | JSX.Element | JSX.Element[] | undefined;
261
261
 
262
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/pages",
3
- "version": "1.60.10",
3
+ "version": "1.63.8",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",
@@ -26,7 +26,7 @@
26
26
  "next": "latest"
27
27
  },
28
28
  "devDependencies": {
29
- "@gem-sdk/core": "1.60.7",
29
+ "@gem-sdk/core": "1.63.3",
30
30
  "@gem-sdk/plugin-cookie-bar": "1.58.0",
31
31
  "@gem-sdk/plugin-quick-view": "1.58.0",
32
32
  "@gem-sdk/plugin-sticky-add-to-cart": "1.58.0"