@gem-sdk/pages 2.0.0-dev.1160 → 2.0.0-dev.1175

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.
@@ -1 +1 @@
1
- "use strict";var nextjs=require("@sentry/nextjs"),normalize=require("../helpers/normalize.js"),parseJson=require("../helpers/parse-json.js"),genCss=require("../helpers/gen-css.js"),googleFonts=require("../google-fonts.js"),customFonts=require("../custom-fonts.js");const getSharePageProps=e=>async t=>{try{let{sharedPage:s,customFonts:o}=await e([t]);if(!s)return null;let{page:r,themeStyle:n,share:a,pageSections:l,pageMeta:i,shopMeta:u,products:p,collections:g,articles:m}=s,c=normalize.parseBuilderTemplateV2(s),[h,F,d]=await Promise.all([googleFonts.getFontStyleFromPageTemplate(c),googleFonts.getFontFromGlobalStyle(n?.data),customFonts.getCustomFonts(o)]),j={defaultTitle:u?.shop?.name??"",title:a?.title,openGraph:{site_name:u?.shop?.name??"",locale:u?.localization?.country?.isoCode??"",title:a?.title??u?.shop?.name??"",description:a?.description??u?.shop?.description??"",images:a?.thumbnails?a.thumbnails:[]},nofollow:!0,noindex:!0};return parseJson.serializableJson({seo:j,builderData:c,page:r,themeStyle:genCss.genCSS(n?.data,!1),share:a,pageSections:l,pageMeta:i,shopMeta:u,products:p,collections:g,articles:m,elementFontStyle:h,fontStyle:F,customFonts:d})}catch(e){return nextjs.captureException(e),null}};exports.getSharePageProps=getSharePageProps;
1
+ "use strict";var nextjs=require("@sentry/nextjs"),normalize=require("../helpers/normalize.js"),parseJson=require("../helpers/parse-json.js"),genCss=require("../helpers/gen-css.js"),googleFonts=require("../google-fonts.js"),customFonts=require("../custom-fonts.js");const getSharePageProps=e=>async t=>{try{let{sharedPage:s,customFonts:o,products:r,collections:n,articles:a}=await e([t]);if(!s)return null;let{page:l,themeStyle:i,share:u,pageMeta:p,shopMeta:g}=s,{sectionPosition:m}=l,c=normalize.parseBuilderTemplateV2({...s,sectionPosition:m}),[h,F,d]=await Promise.all([googleFonts.getFontStyleFromPageTemplate(c),googleFonts.getFontFromGlobalStyle(i?.data),customFonts.getCustomFonts(o)]),j={defaultTitle:g?.shop?.name??"",title:u?.title,openGraph:{site_name:g?.shop?.name??"",locale:g?.localization?.country?.isoCode??"",title:u?.title??g?.shop?.name??"",description:u?.description??g?.shop?.description??"",images:u?.thumbnails?u.thumbnails:[]},nofollow:!0,noindex:!0};return parseJson.serializableJson({seo:j,builderData:c,page:l,themeStyle:genCss.genCSS(i?.data,!1),share:u,pageMeta:p,shopMeta:g,products:r,collections:n,articles:a,elementFontStyle:h,fontStyle:F,customFonts:d})}catch(e){return nextjs.captureException(e),null}};exports.getSharePageProps=getSharePageProps;
@@ -1 +1 @@
1
- "use strict";var getStorefrontApi=require("./get-storefront-api.js"),extractOperation=require("./helpers/extract-operation.js");const createFetcher=e=>{let r=e||process.env.NEXT_PUBLIC_SHOP_TOKEN;return async e=>{let[t,o,n]=e;if(!r)throw Error("shopToken is not defined");let s=process.env.NEXT_PUBLIC_API_URL;if(!s)throw Error("NEXT_PUBLIC_API_URL is not defined");let i=extractOperation.extractOperation(t);i&&(s=`${s}?gp-online-store-operation=${i}`);let a={"Content-Type":"application/json","X-GemX-Shop-Token":r};return fetch(s,{method:"POST",headers:a,body:JSON.stringify({query:t,variables:o,operationName:n})}).then(e=>e.json()).then(e=>e.errors?Promise.reject(e.errors):e.data)}},createAppAPIFetcher=(e,r)=>{let t=process.env.NEXT_APP_API_URL;return async o=>{let[n,s,i]=o;if(!e)throw Error("shopToken is not defined");if(!t)throw Error("NEXT_APP_API_URL is not defined");let a=extractOperation.extractOperation(n);a&&(t=`${t}?gp-online-store-operation=${a}`);let c={"Content-Type":"application/json",Authorization:`Token ${e}`,"X-GemX-Shop-ID":r||""};return fetch(`${t}?gp-online-store-operation=${i}`,{method:"POST",headers:c,body:JSON.stringify({query:n,variables:s,operationName:i})}).then(e=>e.json()).then(e=>e.errors?Promise.reject(e.errors):e.data)}},createShopifyFetcher=(e,r)=>{let t=e??process.env.NEXT_PUBLIC_STOREFRONT_TOKEN,o=r??process.env.NEXT_PUBLIC_STOREFRONT_HANDLE;return async e=>{if(!t)throw Error("NEXT_PUBLIC_STOREFRONT_TOKEN is not defined");if(!o)throw Error("NEXT_PUBLIC_STOREFRONT_HANDLE is not defined");let r={"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":t},[n,s]=e;return fetch(getStorefrontApi.getStorefrontApi(o),{method:"POST",headers:r,body:JSON.stringify({query:n,variables:s})}).then(e=>e.json()).then(e=>e.errors?Promise.reject(e.errors):e.data)}},createTemplateFetcher=e=>{let r=process.env.NEXT_PUBLIC_URL_SHARE_PAGE;return async()=>{if(!r)throw Error("NEXT_PUBLIC_URL_SHARE_PAGE is not defined");try{let t=await fetch(`${r}/share/page/${e}`,{method:"GET"});if(!t.ok)throw Error(`HTTP error! status: ${t.status}`);let o=await t.json();if(o.errors)throw Error(`API errors: ${JSON.stringify(o.errors)}`);return o.result}catch(e){throw console.error("Template fetcher error:",e),e}}};exports.createAppAPIFetcher=createAppAPIFetcher,exports.createFetcher=createFetcher,exports.createShopifyFetcher=createShopifyFetcher,exports.createTemplateFetcher=createTemplateFetcher;
1
+ "use strict";var getStorefrontApi=require("./get-storefront-api.js"),extractOperation=require("./helpers/extract-operation.js");const createFetcher=e=>{let r=e||process.env.NEXT_PUBLIC_SHOP_TOKEN;return async e=>{let[t,o,n]=e;if(!r)throw Error("shopToken is not defined");let s=process.env.NEXT_PUBLIC_API_URL;if(!s)throw Error("NEXT_PUBLIC_API_URL is not defined");let i=extractOperation.extractOperation(t);i&&(s=`${s}?gp-online-store-operation=${i}`);let a={"Content-Type":"application/json","X-GemX-Shop-Token":r};return fetch(s,{method:"POST",headers:a,body:JSON.stringify({query:t,variables:o,operationName:n})}).then(e=>e.json()).then(e=>e.errors?Promise.reject(e.errors):e.data)}},createAppAPIFetcher=(e,r)=>{let t=process.env.NEXT_APP_API_URL;return async o=>{let[n,s,i]=o;if(!e)throw Error("shopToken is not defined");if(!t)throw Error("NEXT_APP_API_URL is not defined");let a=extractOperation.extractOperation(n);a&&(t=`${t}?gp-online-store-operation=${a}`);let c={"Content-Type":"application/json",Authorization:`Token ${e}`,"X-GemX-Shop-ID":r||""};return fetch(`${t}?gp-online-store-operation=${i}`,{method:"POST",headers:c,body:JSON.stringify({query:n,variables:s,operationName:i})}).then(e=>e.json()).then(e=>e.errors?Promise.reject(e.errors):e.data)}},createShopifyFetcher=(e,r)=>{let t=e??process.env.NEXT_PUBLIC_STOREFRONT_TOKEN,o=r??process.env.NEXT_PUBLIC_STOREFRONT_HANDLE;return async e=>{if(!t)throw Error("NEXT_PUBLIC_STOREFRONT_TOKEN is not defined");if(!o)throw Error("NEXT_PUBLIC_STOREFRONT_HANDLE is not defined");let r={"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":t},[n,s]=e;return fetch(getStorefrontApi.getStorefrontApi(o),{method:"POST",headers:r,body:JSON.stringify({query:n,variables:s})}).then(e=>e.json()).then(e=>e.errors?Promise.reject(e.errors):e.data)}},createTemplateFetcher=e=>{let r=process.env.NEXT_PUBLIC_URL_SHARE_PAGE;return async t=>{if(!r)throw Error("NEXT_PUBLIC_URL_SHARE_PAGE is not defined");try{let t;let o=await fetch(`${r}/share/page/${e}`,{method:"GET"});if(!o.ok)throw Error(`HTTP error! status: ${o.status}`);try{t=await o.text()}catch(e){throw Error(`Invalid JSON response: ${e}`)}let n=JSON.parse(t);if(n.errors)throw Error(`API errors: ${JSON.stringify(n.errors)}`);return n.result}catch(e){throw console.error("Template fetcher error:",e),e}}};exports.createAppAPIFetcher=createAppAPIFetcher,exports.createFetcher=createFetcher,exports.createShopifyFetcher=createShopifyFetcher,exports.createTemplateFetcher=createTemplateFetcher;
@@ -1,5 +1,5 @@
1
- "use strict";var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),nextSeo=require("next-seo"),Head=require("next/head"),router=require("next/router"),parseHtml=require("../libs/parse-html.js"),react=require("react");const PreviewTemplate=({components:e,builderData:t,sectionData:s,seo:r,themeStyle:n,fontStyle:a,elementFontStyle:i,customCodeHeader:l,customFonts:u,productOffers:o,publicStoreFrontData:m,dynamicDiscountOffer:c,isPreview:d,pageBackground:x})=>{let g=router.useRouter(),{t:p}=core.useI18n(),j="custom-code-header";return(react.useEffect(()=>{let e=document.querySelectorAll(`[class*="${j}-"]`),t=[];e.length>1&&e.forEach(e=>{let s=e.className;if(t.includes(s)){e.remove();return}t.push(s)})},[]),g.isFallback)?jsxRuntime.jsx("div",{className:"gp-flex gp-h-[100vh] gp-items-center gp-justify-center",children:jsxRuntime.jsxs("div",{className:"gp-flex gp-gap-2",children:[jsxRuntime.jsx("span",{className:"gp-aspect-square gp-h-2 gp-animate-[flashing_500ms_infinite_alternate] gp-rounded-full gp-bg-slate-800"}),jsxRuntime.jsx("span",{className:"gp-aspect-square gp-h-2 gp-animate-[flashing_500ms_infinite_200ms_linear_alternate] gp-rounded-full gp-bg-slate-800"}),jsxRuntime.jsx("span",{className:"gp-aspect-square gp-h-2 gp-animate-[flashing_500ms_infinite_500ms_alternate] gp-rounded-full gp-bg-slate-800"})]})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(nextSeo.NextSeo,{...r}),jsxRuntime.jsxs(Head,{children:[parseHtml.parseHtml(j,l,!0),n&&jsxRuntime.jsx("style",{"data-id":"global-style",type:"text/css",dangerouslySetInnerHTML:{__html:n}},"global-style"),a&&jsxRuntime.jsx("style",{"data-id":"google-fonts",type:"text/css",dangerouslySetInnerHTML:{__html:a}},"google-fonts"),i&&i.map(e=>jsxRuntime.jsx("style",{"data-id":"google-element-fonts",type:"text/css",dangerouslySetInnerHTML:{__html:e}},e)),u&&jsxRuntime.jsx("style",{"data-id":"custom-element-fonts",type:"text/css",dangerouslySetInnerHTML:{__html:u}},a),x?.isUsePageBackground&&x?.background&&jsxRuntime.jsx("style",{children:`
1
+ "use strict";var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),nextSeo=require("next-seo"),Head=require("next/head"),router=require("next/router"),parseHtml=require("../libs/parse-html.js"),react=require("react");const PreviewTemplate=({components:e,builderData:t,sectionData:s,seo:r,themeStyle:n,fontStyle:a,elementFontStyle:i,customCodeHeader:l,customFonts:u,products:o,collections:c,articles:m,pageBackground:d,publicStoreFrontData:x})=>{let g=router.useRouter(),{t:p}=core.useI18n(),j="custom-code-header";return(react.useEffect(()=>{let e=document.querySelectorAll(`[class*="${j}-"]`),t=[];e.length>1&&e.forEach(e=>{let s=e.className;if(t.includes(s)){e.remove();return}t.push(s)})},[]),g.isFallback)?jsxRuntime.jsx("div",{className:"gp-flex gp-h-[100vh] gp-items-center gp-justify-center",children:jsxRuntime.jsxs("div",{className:"gp-flex gp-gap-2",children:[jsxRuntime.jsx("span",{className:"gp-aspect-square gp-h-2 gp-animate-[flashing_500ms_infinite_alternate] gp-rounded-full gp-bg-slate-800"}),jsxRuntime.jsx("span",{className:"gp-aspect-square gp-h-2 gp-animate-[flashing_500ms_infinite_200ms_linear_alternate] gp-rounded-full gp-bg-slate-800"}),jsxRuntime.jsx("span",{className:"gp-aspect-square gp-h-2 gp-animate-[flashing_500ms_infinite_500ms_alternate] gp-rounded-full gp-bg-slate-800"})]})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(nextSeo.NextSeo,{...r}),jsxRuntime.jsxs(Head,{children:[parseHtml.parseHtml(j,l,!0),n&&jsxRuntime.jsx("style",{"data-id":"global-style",type:"text/css",dangerouslySetInnerHTML:{__html:n}},"global-style"),a&&jsxRuntime.jsx("style",{"data-id":"google-fonts",type:"text/css",dangerouslySetInnerHTML:{__html:a}},"google-fonts"),i&&i.map(e=>jsxRuntime.jsx("style",{"data-id":"google-element-fonts",type:"text/css",dangerouslySetInnerHTML:{__html:e}},e)),u&&jsxRuntime.jsx("style",{"data-id":"custom-element-fonts",type:"text/css",dangerouslySetInnerHTML:{__html:u}},a),d?.isUsePageBackground&&d?.background&&jsxRuntime.jsx("style",{children:`
2
2
  body {
3
- background: ${x.background};
3
+ background: ${d.background};
4
4
  }
5
- `},`page_background_${x?.background}`)]}),jsxRuntime.jsx(core.PageProvider,{productOffers:o,publicStoreFrontData:m,dynamicDiscountOffer:c,children:jsxRuntime.jsx(core.BuilderComponentProvider,{components:e,children:jsxRuntime.jsx("div",{children:jsxRuntime.jsx(core.SectionProvider,{data:s,children:jsxRuntime.jsx(core.I18nProvider,{t:p,children:t?.map(e=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(core.BuilderProvider,{state:e.data,lazy:e.lazy,priority:e.priority,isPreview:d,children:jsxRuntime.jsx(core.Render,{uid:e.uid})},e.uid)}))})})})})})]})};exports.PreviewTemplate=PreviewTemplate;
5
+ `},`page_background_${d?.background}`)]}),jsxRuntime.jsx(core.PageProvider,{products:o,collections:c,articles:m,publicStoreFrontData:x,children:jsxRuntime.jsx(core.BuilderComponentProvider,{components:e,children:jsxRuntime.jsx("div",{children:jsxRuntime.jsx(core.SectionProvider,{data:s,children:jsxRuntime.jsx(core.I18nProvider,{t:p,children:t?.map(e=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(core.BuilderProvider,{state:e.data,lazy:e.lazy,priority:e.priority,isPreview:!0,children:jsxRuntime.jsx(core.Render,{uid:e.uid})},e.uid)}))})})})})})]})};exports.PreviewTemplate=PreviewTemplate;
@@ -1 +1 @@
1
- import{captureException as e}from"@sentry/nextjs";import{parseBuilderTemplateV2 as t}from"../helpers/normalize.js";import{serializableJson as o}from"../helpers/parse-json.js";import{genCSS as r}from"../helpers/gen-css.js";import{getFontStyleFromPageTemplate as s,getFontFromGlobalStyle as a}from"../google-fonts.js";import{getCustomFonts as i}from"../custom-fonts.js";let getSharePageProps=l=>async n=>{try{let{sharedPage:e,customFonts:m}=await l([n]);if(!e)return null;let{page:p,themeStyle:h,share:c,pageSections:u,pageMeta:f,shopMeta:d,products:g,collections:j,articles:y}=e,P=t(e),[b,w,x]=await Promise.all([s(P),a(h?.data),i(m)]),S={defaultTitle:d?.shop?.name??"",title:c?.title,openGraph:{site_name:d?.shop?.name??"",locale:d?.localization?.country?.isoCode??"",title:c?.title??d?.shop?.name??"",description:c?.description??d?.shop?.description??"",images:c?.thumbnails?c.thumbnails:[]},nofollow:!0,noindex:!0};return o({seo:S,builderData:P,page:p,themeStyle:r(h?.data,!1),share:c,pageSections:u,pageMeta:f,shopMeta:d,products:g,collections:j,articles:y,elementFontStyle:b,fontStyle:w,customFonts:x})}catch(t){return e(t),null}};export{getSharePageProps};
1
+ import{captureException as e}from"@sentry/nextjs";import{parseBuilderTemplateV2 as t}from"../helpers/normalize.js";import{serializableJson as o}from"../helpers/parse-json.js";import{genCSS as r}from"../helpers/gen-css.js";import{getFontStyleFromPageTemplate as s,getFontFromGlobalStyle as a}from"../google-fonts.js";import{getCustomFonts as i}from"../custom-fonts.js";let getSharePageProps=l=>async n=>{try{let{sharedPage:e,customFonts:m,products:p,collections:h,articles:c}=await l([n]);if(!e)return null;let{page:u,themeStyle:f,share:d,pageMeta:g,shopMeta:j}=e,{sectionPosition:y}=u,P=t({...e,sectionPosition:y}),[b,w,x]=await Promise.all([s(P),a(f?.data),i(m)]),S={defaultTitle:j?.shop?.name??"",title:d?.title,openGraph:{site_name:j?.shop?.name??"",locale:j?.localization?.country?.isoCode??"",title:d?.title??j?.shop?.name??"",description:d?.description??j?.shop?.description??"",images:d?.thumbnails?d.thumbnails:[]},nofollow:!0,noindex:!0};return o({seo:S,builderData:P,page:u,themeStyle:r(f?.data,!1),share:d,pageMeta:g,shopMeta:j,products:p,collections:h,articles:c,elementFontStyle:b,fontStyle:w,customFonts:x})}catch(t){return e(t),null}};export{getSharePageProps};
@@ -1 +1 @@
1
- import{getStorefrontApi as e}from"./get-storefront-api.js";import{extractOperation as r}from"./helpers/extract-operation.js";let createFetcher=e=>{let t=e||process.env.NEXT_PUBLIC_SHOP_TOKEN;return async e=>{let[o,n,s]=e;if(!t)throw Error("shopToken is not defined");let i=process.env.NEXT_PUBLIC_API_URL;if(!i)throw Error("NEXT_PUBLIC_API_URL is not defined");let h=r(o);h&&(i=`${i}?gp-online-store-operation=${h}`);let a={"Content-Type":"application/json","X-GemX-Shop-Token":t};return fetch(i,{method:"POST",headers:a,body:JSON.stringify({query:o,variables:n,operationName:s})}).then(e=>e.json()).then(e=>e.errors?Promise.reject(e.errors):e.data)}},createAppAPIFetcher=(e,t)=>{let o=process.env.NEXT_APP_API_URL;return async n=>{let[s,i,h]=n;if(!e)throw Error("shopToken is not defined");if(!o)throw Error("NEXT_APP_API_URL is not defined");let a=r(s);a&&(o=`${o}?gp-online-store-operation=${a}`);let c={"Content-Type":"application/json",Authorization:`Token ${e}`,"X-GemX-Shop-ID":t||""};return fetch(`${o}?gp-online-store-operation=${h}`,{method:"POST",headers:c,body:JSON.stringify({query:s,variables:i,operationName:h})}).then(e=>e.json()).then(e=>e.errors?Promise.reject(e.errors):e.data)}},createShopifyFetcher=(r,t)=>{let o=r??process.env.NEXT_PUBLIC_STOREFRONT_TOKEN,n=t??process.env.NEXT_PUBLIC_STOREFRONT_HANDLE;return async r=>{if(!o)throw Error("NEXT_PUBLIC_STOREFRONT_TOKEN is not defined");if(!n)throw Error("NEXT_PUBLIC_STOREFRONT_HANDLE is not defined");let t={"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":o},[s,i]=r;return fetch(e(n),{method:"POST",headers:t,body:JSON.stringify({query:s,variables:i})}).then(e=>e.json()).then(e=>e.errors?Promise.reject(e.errors):e.data)}},createTemplateFetcher=e=>{let r=process.env.NEXT_PUBLIC_URL_SHARE_PAGE;return async()=>{if(!r)throw Error("NEXT_PUBLIC_URL_SHARE_PAGE is not defined");try{let t=await fetch(`${r}/share/page/${e}`,{method:"GET"});if(!t.ok)throw Error(`HTTP error! status: ${t.status}`);let o=await t.json();if(o.errors)throw Error(`API errors: ${JSON.stringify(o.errors)}`);return o.result}catch(e){throw console.error("Template fetcher error:",e),e}}};export{createAppAPIFetcher,createFetcher,createShopifyFetcher,createTemplateFetcher};
1
+ import{getStorefrontApi as e}from"./get-storefront-api.js";import{extractOperation as r}from"./helpers/extract-operation.js";let createFetcher=e=>{let t=e||process.env.NEXT_PUBLIC_SHOP_TOKEN;return async e=>{let[o,n,s]=e;if(!t)throw Error("shopToken is not defined");let i=process.env.NEXT_PUBLIC_API_URL;if(!i)throw Error("NEXT_PUBLIC_API_URL is not defined");let a=r(o);a&&(i=`${i}?gp-online-store-operation=${a}`);let h={"Content-Type":"application/json","X-GemX-Shop-Token":t};return fetch(i,{method:"POST",headers:h,body:JSON.stringify({query:o,variables:n,operationName:s})}).then(e=>e.json()).then(e=>e.errors?Promise.reject(e.errors):e.data)}},createAppAPIFetcher=(e,t)=>{let o=process.env.NEXT_APP_API_URL;return async n=>{let[s,i,a]=n;if(!e)throw Error("shopToken is not defined");if(!o)throw Error("NEXT_APP_API_URL is not defined");let h=r(s);h&&(o=`${o}?gp-online-store-operation=${h}`);let c={"Content-Type":"application/json",Authorization:`Token ${e}`,"X-GemX-Shop-ID":t||""};return fetch(`${o}?gp-online-store-operation=${a}`,{method:"POST",headers:c,body:JSON.stringify({query:s,variables:i,operationName:a})}).then(e=>e.json()).then(e=>e.errors?Promise.reject(e.errors):e.data)}},createShopifyFetcher=(r,t)=>{let o=r??process.env.NEXT_PUBLIC_STOREFRONT_TOKEN,n=t??process.env.NEXT_PUBLIC_STOREFRONT_HANDLE;return async r=>{if(!o)throw Error("NEXT_PUBLIC_STOREFRONT_TOKEN is not defined");if(!n)throw Error("NEXT_PUBLIC_STOREFRONT_HANDLE is not defined");let t={"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":o},[s,i]=r;return fetch(e(n),{method:"POST",headers:t,body:JSON.stringify({query:s,variables:i})}).then(e=>e.json()).then(e=>e.errors?Promise.reject(e.errors):e.data)}},createTemplateFetcher=e=>{let r=process.env.NEXT_PUBLIC_URL_SHARE_PAGE;return async t=>{if(!r)throw Error("NEXT_PUBLIC_URL_SHARE_PAGE is not defined");try{let t;let o=await fetch(`${r}/share/page/${e}`,{method:"GET"});if(!o.ok)throw Error(`HTTP error! status: ${o.status}`);try{t=await o.text()}catch(e){throw Error(`Invalid JSON response: ${e}`)}let n=JSON.parse(t);if(n.errors)throw Error(`API errors: ${JSON.stringify(n.errors)}`);return n.result}catch(e){throw console.error("Template fetcher error:",e),e}}};export{createAppAPIFetcher,createFetcher,createShopifyFetcher,createTemplateFetcher};
@@ -1,5 +1,5 @@
1
- import{jsx as e,jsxs as t,Fragment as a}from"react/jsx-runtime";import{useI18n as r,PageProvider as l,BuilderComponentProvider as s,SectionProvider as n,I18nProvider as i,BuilderProvider as o,Render as d}from"@gem-sdk/core";import{NextSeo as p}from"next-seo";import c from"next/head";import{useRouter as g}from"next/router";import{parseHtml as m}from"../libs/parse-html.js";import{useEffect as u}from"react";let PreviewTemplate=({components:h,builderData:f,sectionData:y,seo:_,themeStyle:b,fontStyle:x,elementFontStyle:k,customCodeHeader:v,customFonts:N,productOffers:S,publicStoreFrontData:T,dynamicDiscountOffer:q,isPreview:H,pageBackground:I})=>{let L=g(),{t:M}=r(),P="custom-code-header";return(u(()=>{let e=document.querySelectorAll(`[class*="${P}-"]`),t=[];e.length>1&&e.forEach(e=>{let a=e.className;if(t.includes(a)){e.remove();return}t.push(a)})},[]),L.isFallback)?e("div",{className:"gp-flex gp-h-[100vh] gp-items-center gp-justify-center",children:t("div",{className:"gp-flex gp-gap-2",children:[e("span",{className:"gp-aspect-square gp-h-2 gp-animate-[flashing_500ms_infinite_alternate] gp-rounded-full gp-bg-slate-800"}),e("span",{className:"gp-aspect-square gp-h-2 gp-animate-[flashing_500ms_infinite_200ms_linear_alternate] gp-rounded-full gp-bg-slate-800"}),e("span",{className:"gp-aspect-square gp-h-2 gp-animate-[flashing_500ms_infinite_500ms_alternate] gp-rounded-full gp-bg-slate-800"})]})}):t(a,{children:[e(p,{..._}),t(c,{children:[m(P,v,!0),b&&e("style",{"data-id":"global-style",type:"text/css",dangerouslySetInnerHTML:{__html:b}},"global-style"),x&&e("style",{"data-id":"google-fonts",type:"text/css",dangerouslySetInnerHTML:{__html:x}},"google-fonts"),k&&k.map(t=>e("style",{"data-id":"google-element-fonts",type:"text/css",dangerouslySetInnerHTML:{__html:t}},t)),N&&e("style",{"data-id":"custom-element-fonts",type:"text/css",dangerouslySetInnerHTML:{__html:N}},x),I?.isUsePageBackground&&I?.background&&e("style",{children:`
1
+ import{jsx as e,jsxs as t,Fragment as a}from"react/jsx-runtime";import{useI18n as l,PageProvider as r,BuilderComponentProvider as s,SectionProvider as n,I18nProvider as i,BuilderProvider as o,Render as d}from"@gem-sdk/core";import{NextSeo as p}from"next-seo";import c from"next/head";import{useRouter as g}from"next/router";import{parseHtml as m}from"../libs/parse-html.js";import{useEffect as u}from"react";let PreviewTemplate=({components:h,builderData:f,sectionData:y,seo:_,themeStyle:b,fontStyle:x,elementFontStyle:k,customCodeHeader:v,customFonts:N,products:S,collections:T,articles:q,pageBackground:H,publicStoreFrontData:I})=>{let L=g(),{t:M}=l(),P="custom-code-header";return(u(()=>{let e=document.querySelectorAll(`[class*="${P}-"]`),t=[];e.length>1&&e.forEach(e=>{let a=e.className;if(t.includes(a)){e.remove();return}t.push(a)})},[]),L.isFallback)?e("div",{className:"gp-flex gp-h-[100vh] gp-items-center gp-justify-center",children:t("div",{className:"gp-flex gp-gap-2",children:[e("span",{className:"gp-aspect-square gp-h-2 gp-animate-[flashing_500ms_infinite_alternate] gp-rounded-full gp-bg-slate-800"}),e("span",{className:"gp-aspect-square gp-h-2 gp-animate-[flashing_500ms_infinite_200ms_linear_alternate] gp-rounded-full gp-bg-slate-800"}),e("span",{className:"gp-aspect-square gp-h-2 gp-animate-[flashing_500ms_infinite_500ms_alternate] gp-rounded-full gp-bg-slate-800"})]})}):t(a,{children:[e(p,{..._}),t(c,{children:[m(P,v,!0),b&&e("style",{"data-id":"global-style",type:"text/css",dangerouslySetInnerHTML:{__html:b}},"global-style"),x&&e("style",{"data-id":"google-fonts",type:"text/css",dangerouslySetInnerHTML:{__html:x}},"google-fonts"),k&&k.map(t=>e("style",{"data-id":"google-element-fonts",type:"text/css",dangerouslySetInnerHTML:{__html:t}},t)),N&&e("style",{"data-id":"custom-element-fonts",type:"text/css",dangerouslySetInnerHTML:{__html:N}},x),H?.isUsePageBackground&&H?.background&&e("style",{children:`
2
2
  body {
3
- background: ${I.background};
3
+ background: ${H.background};
4
4
  }
5
- `},`page_background_${I?.background}`)]}),e(l,{productOffers:S,publicStoreFrontData:T,dynamicDiscountOffer:q,children:e(s,{components:h,children:e("div",{children:e(n,{data:y,children:e(i,{t:M,children:f?.map(t=>e(a,{children:e(o,{state:t.data,lazy:t.lazy,priority:t.priority,isPreview:H,children:e(d,{uid:t.uid})},t.uid)}))})})})})})]})};export{PreviewTemplate};
5
+ `},`page_background_${H?.background}`)]}),e(r,{products:S,collections:T,articles:q,publicStoreFrontData:I,children:e(s,{components:h,children:e("div",{children:e(n,{data:y,children:e(i,{t:M,children:f?.map(t=>e(a,{children:e(o,{state:t.data,lazy:t.lazy,priority:t.priority,isPreview:!0,children:e(d,{uid:t.uid})},t.uid)}))})})})})})]})};export{PreviewTemplate};
@@ -106,9 +106,11 @@ type SharePageAPIResponse = {
106
106
  sharedPage: SharePageProps;
107
107
  products: any;
108
108
  collections: any;
109
+ articles: any;
109
110
  customFonts: ShopType.CustomFont[];
110
111
  };
111
- type SharePageProps = {
112
+ type SharePageProps = PageBuilderPropsV2 & {
113
+ publicStoreFrontData?: PublicStoreFrontData | null;
112
114
  seo?: NextSeoProps;
113
115
  builderData?: {
114
116
  uid: string;
@@ -119,7 +121,14 @@ type SharePageProps = {
119
121
  page?: any;
120
122
  themeStyle?: any;
121
123
  share?: any;
122
- pageSections?: any;
124
+ pageSections?: {
125
+ id: BigInt;
126
+ themePageID: BigInt;
127
+ shopID: BigInt;
128
+ cid: string;
129
+ name: string;
130
+ component: any;
131
+ };
123
132
  pageMeta?: any;
124
133
  shopMeta?: any;
125
134
  products?: any;
@@ -295,6 +304,6 @@ declare const BuilderPage: React.FC<BuilderPageProps>;
295
304
 
296
305
  declare const StaticPageV2: React.FC<StaticPagePropsV2 & AdditionalPageBuilderProps>;
297
306
 
298
- declare const PreviewTemplate: React.FC<StaticPagePropsV2 & AdditionalPageBuilderProps>;
307
+ declare const PreviewTemplate: React.FC<SharePageProps & AdditionalPageBuilderProps>;
299
308
 
300
309
  export { AppPropsWithLayout, BuilderPage, CollectionDetailPage, ErrorBoundary, ErrorFallback, FacebookPixel, GoogleAnalytic, NextPageWithLayout, Page404, Page500, PageBuilderProps, PageBuilderPropsV2, PreviewPage, PreviewTemplate, ProductDetailPage, SharePageAPIResponse, SharePageProps, StaticPage, StaticPagePropsV2, StaticPageV2, TikTokPixel, createAppAPIFetcher, createFetcher, createShopifyFetcher, createTemplateFetcher, genCSS, getBuilderProps, getCollectionProps, getFallbackV2, getFontFromGlobalStyle, getFontFromGroupSetting, getFonts, getFontsFromDataBuilder, getHomePageProps, getHomePagePropsV2, getLayout, getPostPurchasePropsPreview, getPreviewProps, getProductProps, getSharePageProps, getStaticPagePropsPreview, getStaticPagePropsV2, getStaticPaths, getStorefrontApi, isBot, normalizePageSectionResponseV2, parseBuilderTemplateV2, retryWithDelay, usePagePreview, useTrackingView };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/pages",
3
- "version": "2.0.0-dev.1160",
3
+ "version": "2.0.0-dev.1175",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",
@@ -26,7 +26,7 @@
26
26
  "next": "14.2.20"
27
27
  },
28
28
  "devDependencies": {
29
- "@gem-sdk/core": "2.0.0-dev.1156",
29
+ "@gem-sdk/core": "2.0.0-dev.1175",
30
30
  "@gem-sdk/plugin-cookie-bar": "2.0.0-dev.1156",
31
31
  "@gem-sdk/plugin-quick-view": "2.0.0-dev.1156",
32
32
  "@gem-sdk/plugin-sticky-add-to-cart": "2.0.0-dev.1156"