@gem-sdk/pages 1.63.8 → 1.63.16

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.
@@ -9,6 +9,7 @@ var generateManifres = require('../helpers/generate-manifres.js');
9
9
  var getFallback = require('../helpers/get-fallback.js');
10
10
  var normalize = require('../helpers/normalize.js');
11
11
  var parseJson = require('../helpers/parse-json.js');
12
+ var customFonts = require('../custom-fonts.js');
12
13
 
13
14
  const getStaticPagePropsPreview = (fetcher, shopifyFetcher)=>async (slug)=>{
14
15
  try {
@@ -19,9 +20,8 @@ const getStaticPagePropsPreview = (fetcher, shopifyFetcher)=>async (slug)=>{
19
20
  };
20
21
  const [theme, storeProperty, shopifyMeta] = await Promise.allSettled([
21
22
  fetcher([
22
- core.PreviewPageDocument,
23
- variables,
24
- 'previewPage'
23
+ core.PreviewThemePageDocument,
24
+ variables
25
25
  ]),
26
26
  fetcher([
27
27
  core.StorePropertyDocument
@@ -33,19 +33,21 @@ const getStaticPagePropsPreview = (fetcher, shopifyFetcher)=>async (slug)=>{
33
33
  if (theme.status === 'rejected') {
34
34
  throw new Error(theme.reason?.[0]);
35
35
  }
36
- const dataBuilder = theme.value.previewPage;
36
+ const dataBuilder = theme.value.previewThemePage;
37
37
  if (!dataBuilder) {
38
38
  throw new Error(`No data builder found for slug: /preview/${slug}`);
39
39
  }
40
+ const themePageCustomFonts = dataBuilder.customFonts;
40
41
  const pageTemplate = normalize.parseBuilderTemplateV2(dataBuilder);
41
- const [elementFontStyle, fontStyle, fallback] = await Promise.all([
42
+ const [elementFontStyle, fontStyle, fallback, customFonts$1] = await Promise.all([
42
43
  googleFonts.getFontStyleFromPageTemplate(pageTemplate),
43
- googleFonts.getFontFromGlobalStyle(dataBuilder?.pageStyle?.data),
44
- getFallback.getFallbackV2(fetcher, pageTemplate)
44
+ googleFonts.getFontFromGlobalStyle(dataBuilder?.themeStyle?.data),
45
+ getFallback.getFallbackV2(fetcher, pageTemplate),
46
+ customFonts.getCustomFonts(themePageCustomFonts)
45
47
  ]);
46
48
  const mobileOnly = dataBuilder.isMobile ?? false;
47
- const description = dataBuilder?.themePageDataSEO?.find((item)=>item?.key === 'global-meta-description')?.value;
48
- const thumbnail = parseJson.parseJson(dataBuilder?.themePageDataSEO?.find((item)=>item?.key === 'global-meta-thumbnail')?.value);
49
+ const description = dataBuilder?.dataSEO?.find((item)=>item?.key === 'global-meta-description')?.value;
50
+ const thumbnail = parseJson.parseJson(dataBuilder?.dataSEO?.find((item)=>item?.key === 'global-meta-thumbnail')?.value);
49
51
  const shopMeta = shopifyMeta.status === 'fulfilled' ? shopifyMeta.value : undefined;
50
52
  const shopData = storeProperty.status === 'fulfilled' ? storeProperty.value : undefined;
51
53
  const favicon = shopData?.storeProperty?.favicon ?? '/favicon/favicon-32x32.png';
@@ -119,7 +121,7 @@ const getStaticPagePropsPreview = (fetcher, shopifyFetcher)=>async (slug)=>{
119
121
  const countryIsoCode = shopMeta?.localization.country.isoCode ?? null;
120
122
  const locale = !languageIsoCode || !countryIsoCode ? null : `${languageIsoCode}-${countryIsoCode}`;
121
123
  return parseJson.serializableJson({
122
- themeStyle: genCss.genCSS(dataBuilder?.pageStyle?.data, mobileOnly),
124
+ themeStyle: genCss.genCSS(dataBuilder?.themeStyle?.data, mobileOnly),
123
125
  fontStyle,
124
126
  elementFontStyle,
125
127
  builderData: pageTemplate,
@@ -135,11 +137,13 @@ const getStaticPagePropsPreview = (fetcher, shopifyFetcher)=>async (slug)=>{
135
137
  swatches: parseJson.parseJson(shopData?.storeProperty?.swatchesConfig),
136
138
  seo,
137
139
  mobileOnly,
138
- gaTrackingId: dataBuilder.themePageAnalytic?.gaTrackingID ?? null,
139
- facebookPixelId: dataBuilder.themePageAnalytic?.fbPixelID ?? null,
140
- tiktokPixelId: dataBuilder.themePageAnalytic?.tiktokPixelID ?? null,
141
- customCodeHeader: dataBuilder.themePageCustomCode?.header ?? null,
142
- customCodeBody: dataBuilder.themePageCustomCode?.body ?? null
140
+ gaTrackingId: dataBuilder.analytic?.gaTrackingID ?? null,
141
+ facebookPixelId: dataBuilder.analytic?.fbPixelID ?? null,
142
+ tiktokPixelId: dataBuilder.analytic?.tiktokPixelID ?? null,
143
+ customCodeHeader: dataBuilder.customCode?.header ?? null,
144
+ customCodeBody: dataBuilder.customCode?.body ?? null,
145
+ customFonts: customFonts$1,
146
+ interaction: dataBuilder?.interaction
143
147
  });
144
148
  } catch (err) {
145
149
  nextjs.captureException(err);
@@ -17,6 +17,14 @@ const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, f
17
17
  const baseAssetURL = process.env.NEXT_GP_BASE_ASSET_URL || 'https://d3kbi0je7pp4lw.cloudfront.net';
18
18
  useTrackingView.useTrackingView(shopToken, pageHandle, router$1.isFallback);
19
19
  const customCodeHeaderID = 'custom-code-header';
20
+ react.useEffect(()=>{
21
+ const customCodeHeaderElement = document.querySelectorAll(`#${customCodeHeaderID}`);
22
+ if (customCodeHeaderElement.length > 1) {
23
+ customCodeHeaderElement.forEach((script, index)=>{
24
+ if (index !== 0) script.remove();
25
+ });
26
+ }
27
+ }, []);
20
28
  if (router$1.isFallback) {
21
29
  return /*#__PURE__*/ jsxRuntime.jsx("div", {
22
30
  className: "gp-flex gp-h-[100vh] gp-items-center gp-justify-center",
@@ -36,14 +44,6 @@ const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, f
36
44
  })
37
45
  });
38
46
  }
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
- }, []);
47
47
  return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
48
48
  children: [
49
49
  /*#__PURE__*/ jsxRuntime.jsx(nextSeo.NextSeo, {
@@ -1,4 +1,4 @@
1
- import { PreviewPageDocument, StorePropertyDocument } from '@gem-sdk/core';
1
+ import { PreviewThemePageDocument, StorePropertyDocument } from '@gem-sdk/core';
2
2
  import { ShopMetaDocument } from '@gem-sdk/adapter-shopify';
3
3
  import { captureException } from '@sentry/nextjs';
4
4
  import { getFontStyleFromPageTemplate, getFontFromGlobalStyle } from '../google-fonts.js';
@@ -7,6 +7,7 @@ import { generateManifest } from '../helpers/generate-manifres.js';
7
7
  import { getFallbackV2 } from '../helpers/get-fallback.js';
8
8
  import { parseBuilderTemplateV2 } from '../helpers/normalize.js';
9
9
  import { parseJson, serializableJson } from '../helpers/parse-json.js';
10
+ import { getCustomFonts } from '../custom-fonts.js';
10
11
 
11
12
  const getStaticPagePropsPreview = (fetcher, shopifyFetcher)=>async (slug)=>{
12
13
  try {
@@ -17,9 +18,8 @@ const getStaticPagePropsPreview = (fetcher, shopifyFetcher)=>async (slug)=>{
17
18
  };
18
19
  const [theme, storeProperty, shopifyMeta] = await Promise.allSettled([
19
20
  fetcher([
20
- PreviewPageDocument,
21
- variables,
22
- 'previewPage'
21
+ PreviewThemePageDocument,
22
+ variables
23
23
  ]),
24
24
  fetcher([
25
25
  StorePropertyDocument
@@ -31,19 +31,21 @@ const getStaticPagePropsPreview = (fetcher, shopifyFetcher)=>async (slug)=>{
31
31
  if (theme.status === 'rejected') {
32
32
  throw new Error(theme.reason?.[0]);
33
33
  }
34
- const dataBuilder = theme.value.previewPage;
34
+ const dataBuilder = theme.value.previewThemePage;
35
35
  if (!dataBuilder) {
36
36
  throw new Error(`No data builder found for slug: /preview/${slug}`);
37
37
  }
38
+ const themePageCustomFonts = dataBuilder.customFonts;
38
39
  const pageTemplate = parseBuilderTemplateV2(dataBuilder);
39
- const [elementFontStyle, fontStyle, fallback] = await Promise.all([
40
+ const [elementFontStyle, fontStyle, fallback, customFonts] = await Promise.all([
40
41
  getFontStyleFromPageTemplate(pageTemplate),
41
- getFontFromGlobalStyle(dataBuilder?.pageStyle?.data),
42
- getFallbackV2(fetcher, pageTemplate)
42
+ getFontFromGlobalStyle(dataBuilder?.themeStyle?.data),
43
+ getFallbackV2(fetcher, pageTemplate),
44
+ getCustomFonts(themePageCustomFonts)
43
45
  ]);
44
46
  const mobileOnly = dataBuilder.isMobile ?? false;
45
- const description = dataBuilder?.themePageDataSEO?.find((item)=>item?.key === 'global-meta-description')?.value;
46
- const thumbnail = parseJson(dataBuilder?.themePageDataSEO?.find((item)=>item?.key === 'global-meta-thumbnail')?.value);
47
+ const description = dataBuilder?.dataSEO?.find((item)=>item?.key === 'global-meta-description')?.value;
48
+ const thumbnail = parseJson(dataBuilder?.dataSEO?.find((item)=>item?.key === 'global-meta-thumbnail')?.value);
47
49
  const shopMeta = shopifyMeta.status === 'fulfilled' ? shopifyMeta.value : undefined;
48
50
  const shopData = storeProperty.status === 'fulfilled' ? storeProperty.value : undefined;
49
51
  const favicon = shopData?.storeProperty?.favicon ?? '/favicon/favicon-32x32.png';
@@ -117,7 +119,7 @@ const getStaticPagePropsPreview = (fetcher, shopifyFetcher)=>async (slug)=>{
117
119
  const countryIsoCode = shopMeta?.localization.country.isoCode ?? null;
118
120
  const locale = !languageIsoCode || !countryIsoCode ? null : `${languageIsoCode}-${countryIsoCode}`;
119
121
  return serializableJson({
120
- themeStyle: genCSS(dataBuilder?.pageStyle?.data, mobileOnly),
122
+ themeStyle: genCSS(dataBuilder?.themeStyle?.data, mobileOnly),
121
123
  fontStyle,
122
124
  elementFontStyle,
123
125
  builderData: pageTemplate,
@@ -133,11 +135,13 @@ const getStaticPagePropsPreview = (fetcher, shopifyFetcher)=>async (slug)=>{
133
135
  swatches: parseJson(shopData?.storeProperty?.swatchesConfig),
134
136
  seo,
135
137
  mobileOnly,
136
- gaTrackingId: dataBuilder.themePageAnalytic?.gaTrackingID ?? null,
137
- facebookPixelId: dataBuilder.themePageAnalytic?.fbPixelID ?? null,
138
- tiktokPixelId: dataBuilder.themePageAnalytic?.tiktokPixelID ?? null,
139
- customCodeHeader: dataBuilder.themePageCustomCode?.header ?? null,
140
- customCodeBody: dataBuilder.themePageCustomCode?.body ?? null
138
+ gaTrackingId: dataBuilder.analytic?.gaTrackingID ?? null,
139
+ facebookPixelId: dataBuilder.analytic?.fbPixelID ?? null,
140
+ tiktokPixelId: dataBuilder.analytic?.tiktokPixelID ?? null,
141
+ customCodeHeader: dataBuilder.customCode?.header ?? null,
142
+ customCodeBody: dataBuilder.customCode?.body ?? null,
143
+ customFonts,
144
+ interaction: dataBuilder?.interaction
141
145
  });
142
146
  } catch (err) {
143
147
  captureException(err);
@@ -15,6 +15,14 @@ const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, f
15
15
  const baseAssetURL = process.env.NEXT_GP_BASE_ASSET_URL || 'https://d3kbi0je7pp4lw.cloudfront.net';
16
16
  useTrackingView(shopToken, pageHandle, router.isFallback);
17
17
  const customCodeHeaderID = 'custom-code-header';
18
+ useEffect(()=>{
19
+ const customCodeHeaderElement = document.querySelectorAll(`#${customCodeHeaderID}`);
20
+ if (customCodeHeaderElement.length > 1) {
21
+ customCodeHeaderElement.forEach((script, index)=>{
22
+ if (index !== 0) script.remove();
23
+ });
24
+ }
25
+ }, []);
18
26
  if (router.isFallback) {
19
27
  return /*#__PURE__*/ jsx("div", {
20
28
  className: "gp-flex gp-h-[100vh] gp-items-center gp-justify-center",
@@ -34,14 +42,6 @@ const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, f
34
42
  })
35
43
  });
36
44
  }
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
- }, []);
45
45
  return /*#__PURE__*/ jsxs(Fragment, {
46
46
  children: [
47
47
  /*#__PURE__*/ jsx(NextSeo, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/pages",
3
- "version": "1.63.8",
3
+ "version": "1.63.16",
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.63.3",
29
+ "@gem-sdk/core": "1.63.16",
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"