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

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:a,articles:n}=await e([t]);if(!s)return null;let{page:l,themeStyle:i,share:u,pageMeta:m,shopMeta:g}=s,{sectionPosition:p}=l,h=normalize.parseBuilderTemplateV2({...s,sectionPosition:p}),[c,F,y]=await Promise.all([googleFonts.getFontStyleFromPageTemplate(h),googleFonts.getFontFromGlobalStyle(i?.data),customFonts.getCustomFonts(o)]),j=u?.thumbnails?Array.isArray(u.thumbnails)?u.thumbnails.map(e=>({url:e})):"string"==typeof u.thumbnails?[{url:u.thumbnails}]:[]:[],b={defaultTitle:g?.shop?.name??"",title:u?.title,openGraph:{site_name:g?.shop?.name??"",locale:g?.localization?.country?.isoCode??"",title:u?.title??g?.shop?.name??"",images:j},nofollow:!0,noindex:!0};return parseJson.serializableJson({seo:b,builderData:h,page:l,themeStyle:genCss.genCSS(i?.data,!1),share:u,pageMeta:m,shopMeta:g,products:r,collections:a,articles:n,elementFontStyle:c,fontStyle:F,customFonts:y})}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"),Head=require("next/head"),router=require("next/router"),parseHtml=require("../libs/parse-html.js"),react=require("react");const PreviewTemplate=({components:e,builderData:s,sectionData:t,themeStyle:r,fontStyle:n,elementFontStyle:a,customCodeHeader:i,customFonts:l,products:u,collections:c,articles:o,pageBackground:m,publicStoreFrontData:d})=>{let g=router.useRouter(),{t:x}=core.useI18n(),p="custom-code-header";return(react.useEffect(()=>{let e=document.querySelectorAll(`[class*="${p}-"]`),s=[];e.length>1&&e.forEach(e=>{let t=e.className;if(s.includes(t)){e.remove();return}s.push(t)})},[]),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.jsxs(Head,{children:[parseHtml.parseHtml(p,i,!0),r&&jsxRuntime.jsx("style",{"data-id":"global-style",type:"text/css",dangerouslySetInnerHTML:{__html:r}},"global-style"),n&&jsxRuntime.jsx("style",{"data-id":"google-fonts",type:"text/css",dangerouslySetInnerHTML:{__html:n}},"google-fonts"),a&&a.map(e=>jsxRuntime.jsx("style",{"data-id":"google-element-fonts",type:"text/css",dangerouslySetInnerHTML:{__html:e}},e)),l&&jsxRuntime.jsx("style",{"data-id":"custom-element-fonts",type:"text/css",dangerouslySetInnerHTML:{__html:l}},n),m?.isUsePageBackground&&m?.background&&jsxRuntime.jsx("style",{children:`
2
2
  body {
3
- background: ${x.background};
3
+ background: ${m.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_${m?.background}`)]}),jsxRuntime.jsx(core.PageProvider,{products:u,collections:c,articles:o,publicStoreFrontData:d,children:jsxRuntime.jsx(core.BuilderComponentProvider,{components:e,children:jsxRuntime.jsx("div",{children:jsxRuntime.jsx(core.SectionProvider,{data:t,children:jsxRuntime.jsx(core.I18nProvider,{t:x,children:s?.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 t}from"@sentry/nextjs";import{parseBuilderTemplateV2 as e}from"../helpers/normalize.js";import{serializableJson as r}from"../helpers/parse-json.js";import{genCSS as o}from"../helpers/gen-css.js";import{getFontStyleFromPageTemplate as a,getFontFromGlobalStyle as s}from"../google-fonts.js";import{getCustomFonts as l}from"../custom-fonts.js";let getSharePageProps=i=>async n=>{try{let{sharedPage:t,customFonts:m,products:p,collections:u,articles:h}=await i([n]);if(!t)return null;let{page:f,themeStyle:c,share:g,pageMeta:y,shopMeta:j}=t,{sectionPosition:b}=f,d=e({...t,sectionPosition:b}),[P,w,x]=await Promise.all([a(d),s(c?.data),l(m)]),S=g?.thumbnails?Array.isArray(g.thumbnails)?g.thumbnails.map(t=>({url:t})):"string"==typeof g.thumbnails?[{url:g.thumbnails}]:[]:[],z={defaultTitle:j?.shop?.name??"",title:g?.title,openGraph:{site_name:j?.shop?.name??"",locale:j?.localization?.country?.isoCode??"",title:g?.title??j?.shop?.name??"",images:S},nofollow:!0,noindex:!0};return r({seo:z,builderData:d,page:f,themeStyle:o(c?.data,!1),share:g,pageMeta:y,shopMeta:j,products:p,collections:u,articles:h,elementFontStyle:P,fontStyle:w,customFonts:x})}catch(e){return t(e),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 c from"next/head";import{useRouter as p}from"next/router";import{parseHtml as g}from"../libs/parse-html.js";import{useEffect as m}from"react";let PreviewTemplate=({components:u,builderData:h,sectionData:f,themeStyle:y,fontStyle:_,elementFontStyle:b,customCodeHeader:x,customFonts:k,products:v,collections:N,articles:S,pageBackground:T,publicStoreFrontData:q})=>{let H=p(),{t:I}=l(),L="custom-code-header";return(m(()=>{let e=document.querySelectorAll(`[class*="${L}-"]`),t=[];e.length>1&&e.forEach(e=>{let a=e.className;if(t.includes(a)){e.remove();return}t.push(a)})},[]),H.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:[t(c,{children:[g(L,x,!0),y&&e("style",{"data-id":"global-style",type:"text/css",dangerouslySetInnerHTML:{__html:y}},"global-style"),_&&e("style",{"data-id":"google-fonts",type:"text/css",dangerouslySetInnerHTML:{__html:_}},"google-fonts"),b&&b.map(t=>e("style",{"data-id":"google-element-fonts",type:"text/css",dangerouslySetInnerHTML:{__html:t}},t)),k&&e("style",{"data-id":"custom-element-fonts",type:"text/css",dangerouslySetInnerHTML:{__html:k}},_),T?.isUsePageBackground&&T?.background&&e("style",{children:`
2
2
  body {
3
- background: ${I.background};
3
+ background: ${T.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_${T?.background}`)]}),e(r,{products:v,collections:N,articles:S,publicStoreFrontData:q,children:e(s,{components:u,children:e("div",{children:e(n,{data:f,children:e(i,{t:I,children:h?.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,17 @@ 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 SharePageType = {
113
+ designerName?: string | null;
114
+ id: string;
115
+ thumbnails?: string[] | null;
116
+ title: string;
117
+ };
118
+ type SharePageProps = PageBuilderPropsV2 & {
119
+ publicStoreFrontData?: PublicStoreFrontData | null;
112
120
  seo?: NextSeoProps;
113
121
  builderData?: {
114
122
  uid: string;
@@ -118,8 +126,15 @@ type SharePageProps = {
118
126
  }[];
119
127
  page?: any;
120
128
  themeStyle?: any;
121
- share?: any;
122
- pageSections?: any;
129
+ share?: SharePageType;
130
+ pageSections?: {
131
+ id: BigInt;
132
+ themePageID: BigInt;
133
+ shopID: BigInt;
134
+ cid: string;
135
+ name: string;
136
+ component: any;
137
+ };
123
138
  pageMeta?: any;
124
139
  shopMeta?: any;
125
140
  products?: any;
@@ -295,6 +310,6 @@ declare const BuilderPage: React.FC<BuilderPageProps>;
295
310
 
296
311
  declare const StaticPageV2: React.FC<StaticPagePropsV2 & AdditionalPageBuilderProps>;
297
312
 
298
- declare const PreviewTemplate: React.FC<StaticPagePropsV2 & AdditionalPageBuilderProps>;
313
+ declare const PreviewTemplate: React.FC<SharePageProps & AdditionalPageBuilderProps>;
299
314
 
300
315
  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.1181",
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"