@gem-sdk/pages 1.9.44 → 1.9.60

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 CHANGED
@@ -14,6 +14,8 @@ var getLayout = require('./libs/get-layout.js');
14
14
  var genCss = require('./libs/helpers/gen-css.js');
15
15
  var useTrackingView = require('./libs/hooks/use-tracking-view.js');
16
16
  var userAgent = require('./libs/helpers/user-agent.js');
17
+ var normalize = require('./libs/helpers/normalize.js');
18
+ var getFallback = require('./libs/helpers/get-fallback.js');
17
19
  var collectionDetail = require('./pages/collection-detail.js');
18
20
  var preview = require('./pages/preview.js');
19
21
  var productDetail = require('./pages/product-detail.js');
@@ -48,6 +50,9 @@ exports.getLayout = getLayout.getLayout;
48
50
  exports.genCSS = genCss.genCSS;
49
51
  exports.useTrackingView = useTrackingView.useTrackingView;
50
52
  exports.isBot = userAgent.isBot;
53
+ exports.normalizePageSectionResponseV2 = normalize.normalizePageSectionResponseV2;
54
+ exports.parseBuilderTemplateV2 = normalize.parseBuilderTemplateV2;
55
+ exports.getFallbackV2 = getFallback.getFallbackV2;
51
56
  exports.CollectionDetailPage = collectionDetail.default;
52
57
  exports.PreviewPage = preview.PreviewPage;
53
58
  exports.ProductDetailPage = productDetail.default;
@@ -9,12 +9,12 @@ async function getFontForUA(url, UA) {
9
9
  }
10
10
  }).then((res)=>res.text());
11
11
  }
12
- const createFontUrl = (fontList, option)=>{
13
- const fonts = fontList.filter((font)=>font.type === 'google');
14
- if (!fonts.length) return;
12
+ const createFontUrl = (fonts, option)=>{
13
+ const googleFonts = fonts.filter((font)=>font.type === 'google' || !font.type);
14
+ if (!googleFonts.length) return;
15
15
  const params = new URLSearchParams();
16
16
  const display = option?.display || 'swap';
17
- const family = fonts.filter((font, index, arr)=>{
17
+ const family = googleFonts.filter((font, index, arr)=>{
18
18
  return index === arr.findIndex((t)=>t.family === font.family);
19
19
  }).map((font)=>{
20
20
  return `${font.family.replace(/ /g, '+')}:${font.variants.join(',')}`;
@@ -49,11 +49,11 @@ const getFontFromGlobalStyle = (data)=>{
49
49
  if (!data) return '';
50
50
  try {
51
51
  const globalStyle = JSON.parse(data);
52
- const fonts = globalStyle?.font ?? {};
53
- const font = Object.entries(fonts).map(([, value])=>{
52
+ const fontData = globalStyle?.font ?? {};
53
+ const fonts = Object.entries(fontData).map(([, value])=>{
54
54
  return value;
55
- }).filter((font)=>font.type === 'google');
56
- return getFonts(font);
55
+ });
56
+ return getFonts(fonts);
57
57
  } catch {
58
58
  return '';
59
59
  }
@@ -85,5 +85,6 @@ const parseBuilderTemplate = (data)=>{
85
85
  };
86
86
 
87
87
  exports.normalizeBuilderData = normalizeBuilderData;
88
+ exports.normalizePageSectionResponseV2 = normalizePageSectionResponseV2;
88
89
  exports.parseBuilderTemplate = parseBuilderTemplate;
89
90
  exports.parseBuilderTemplateV2 = parseBuilderTemplateV2;
package/dist/esm/index.js CHANGED
@@ -12,6 +12,8 @@ export { getLayout } from './libs/get-layout.js';
12
12
  export { genCSS } from './libs/helpers/gen-css.js';
13
13
  export { useTrackingView } from './libs/hooks/use-tracking-view.js';
14
14
  export { isBot } from './libs/helpers/user-agent.js';
15
+ export { normalizePageSectionResponseV2, parseBuilderTemplateV2 } from './libs/helpers/normalize.js';
16
+ export { getFallbackV2 } from './libs/helpers/get-fallback.js';
15
17
  export { default as CollectionDetailPage } from './pages/collection-detail.js';
16
18
  export { PreviewPage } from './pages/preview.js';
17
19
  export { default as ProductDetailPage } from './pages/product-detail.js';
@@ -7,12 +7,12 @@ async function getFontForUA(url, UA) {
7
7
  }
8
8
  }).then((res)=>res.text());
9
9
  }
10
- const createFontUrl = (fontList, option)=>{
11
- const fonts = fontList.filter((font)=>font.type === 'google');
12
- if (!fonts.length) return;
10
+ const createFontUrl = (fonts, option)=>{
11
+ const googleFonts = fonts.filter((font)=>font.type === 'google' || !font.type);
12
+ if (!googleFonts.length) return;
13
13
  const params = new URLSearchParams();
14
14
  const display = option?.display || 'swap';
15
- const family = fonts.filter((font, index, arr)=>{
15
+ const family = googleFonts.filter((font, index, arr)=>{
16
16
  return index === arr.findIndex((t)=>t.family === font.family);
17
17
  }).map((font)=>{
18
18
  return `${font.family.replace(/ /g, '+')}:${font.variants.join(',')}`;
@@ -47,11 +47,11 @@ const getFontFromGlobalStyle = (data)=>{
47
47
  if (!data) return '';
48
48
  try {
49
49
  const globalStyle = JSON.parse(data);
50
- const fonts = globalStyle?.font ?? {};
51
- const font = Object.entries(fonts).map(([, value])=>{
50
+ const fontData = globalStyle?.font ?? {};
51
+ const fonts = Object.entries(fontData).map(([, value])=>{
52
52
  return value;
53
- }).filter((font)=>font.type === 'google');
54
- return getFonts(font);
53
+ });
54
+ return getFonts(fonts);
55
55
  } catch {
56
56
  return '';
57
57
  }
@@ -82,4 +82,4 @@ const parseBuilderTemplate = (data)=>{
82
82
  ], data?.sectionPosition);
83
83
  };
84
84
 
85
- export { normalizeBuilderData, parseBuilderTemplate, parseBuilderTemplateV2 };
85
+ export { normalizeBuilderData, normalizePageSectionResponseV2, parseBuilderTemplate, parseBuilderTemplateV2 };
@@ -1,4 +1,4 @@
1
- import { BuilderState, SectionData, ShopType, RenderMode, CollectionQueryResponse, FetchFunc, ProductSelectFragment } from '@gem-sdk/core';
1
+ import { BuilderState, SectionData as SectionData$1, ShopType, RenderMode, CollectionQueryResponse, FetchFunc, ProductSelectFragment, PublishedThemePageSelectFragment } from '@gem-sdk/core';
2
2
  import { NextPage, GetStaticPaths } from 'next';
3
3
  import { NextSeoProps } from 'next-seo';
4
4
  import { AppProps } from 'next/app';
@@ -9,7 +9,7 @@ import { Component } from 'react';
9
9
  type PageBuilderProps = {
10
10
  seo?: NextSeoProps;
11
11
  builderData?: BuilderState;
12
- sectionData?: Record<string, SectionData>;
12
+ sectionData?: Record<string, SectionData$1>;
13
13
  themeStyle?: string | null;
14
14
  fontStyle?: string | null;
15
15
  swr?: React.ComponentProps<typeof SWRConfig>['value'];
@@ -92,6 +92,28 @@ declare const useTrackingView: (token?: string | null, handle?: string | null, i
92
92
 
93
93
  declare function isBot(input: string): boolean;
94
94
 
95
+ type SectionData = {
96
+ id: string;
97
+ component?: string;
98
+ [key: string]: any;
99
+ };
100
+ declare function normalizePageSectionResponseV2(sections?: ShopType.Maybe<SectionData>[], orders?: string[]): {
101
+ uid: string;
102
+ lazy: boolean;
103
+ priority: boolean;
104
+ data: any;
105
+ }[];
106
+ declare const parseBuilderTemplateV2: (data?: PublishedThemePageSelectFragment) => {
107
+ uid: string;
108
+ lazy: boolean;
109
+ priority: boolean;
110
+ data: any;
111
+ }[];
112
+
113
+ declare const getFallbackV2: (fetcher: FetchFunc, data: {
114
+ data: any;
115
+ }[]) => Promise<{}>;
116
+
95
117
  type PreviewPageProps = {
96
118
  components: Record<string, React.ComponentType<any>>;
97
119
  pageType: ShopType.PublishedThemePageType;
@@ -108,7 +130,7 @@ type BuilderPageProps = {
108
130
  fontStyle?: string | null;
109
131
  header?: BuilderState;
110
132
  footer?: BuilderState;
111
- sectionData?: Record<string, SectionData>;
133
+ sectionData?: Record<string, SectionData$1>;
112
134
  storefrontToken?: string | null;
113
135
  storefrontHandle?: string | null;
114
136
  shopToken?: string | null;
@@ -183,4 +205,4 @@ type Props = {
183
205
  };
184
206
  declare const TikTokPixel: ({ pixelId }: Props) => JSX.Element | null;
185
207
 
186
- export { AppPropsWithLayout, BuilderPage, CollectionDetailPage, CollectionPageProps, ErrorBoundary, ErrorFallback, FacebookPixel, GoogleAnalytic, NextPageWithLayout, Page404, Page500, PageBuilderProps, PreviewPage, ProductDetailPage, ProductPageProps, StaticPage, StaticPageProps, StaticPagePropsV2, StaticPageV2, TikTokPixel, createFetcher, createShopifyFetcher, genCSS, getBuilderProps, getCollectionProps, getFontFromGlobalStyle, getFonts, getHomePageProps, getHomePagePropsV2, getLayout, getPreviewProps, getProductProps, getStaticPageProps, getStaticPagePropsPreview, getStaticPagePropsV2, getStaticPaths, getStorefrontApi, isBot, useTrackingView };
208
+ export { AppPropsWithLayout, BuilderPage, CollectionDetailPage, CollectionPageProps, ErrorBoundary, ErrorFallback, FacebookPixel, GoogleAnalytic, NextPageWithLayout, Page404, Page500, PageBuilderProps, PreviewPage, ProductDetailPage, ProductPageProps, StaticPage, StaticPageProps, StaticPagePropsV2, StaticPageV2, TikTokPixel, createFetcher, createShopifyFetcher, genCSS, getBuilderProps, getCollectionProps, getFallbackV2, getFontFromGlobalStyle, getFonts, getHomePageProps, getHomePagePropsV2, getLayout, getPreviewProps, getProductProps, getStaticPageProps, getStaticPagePropsPreview, getStaticPagePropsV2, getStaticPaths, getStorefrontApi, isBot, normalizePageSectionResponseV2, parseBuilderTemplateV2, useTrackingView };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/pages",
3
- "version": "1.9.44",
3
+ "version": "1.9.60",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",
@@ -19,10 +19,10 @@
19
19
  "test": "jest -c ./../../helpers/jest.config.ts"
20
20
  },
21
21
  "dependencies": {
22
- "@sentry/nextjs": "7.46.0",
22
+ "@sentry/nextjs": "7.47.0",
23
23
  "deepmerge": "4.3.1",
24
24
  "html-react-parser": "3.0.15",
25
- "next-seo": "^5.15.0"
25
+ "next-seo": "^6.0.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@gem-sdk/core": "*",