@gem-sdk/pages 2.0.0-dev.1230 → 2.0.0-dev.1231
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/libs/api/get-preview-content-props.js +1 -1
- package/dist/cjs/libs/helpers/generate-seo-links.js +1 -1
- package/dist/cjs/pages/preview-template.js +2 -2
- package/dist/esm/libs/api/get-preview-content-props.js +1 -1
- package/dist/esm/libs/helpers/generate-seo-links.js +1 -1
- package/dist/esm/pages/preview-template.js +2 -2
- package/dist/types/index.d.ts +3 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var core=require("@gem-sdk/core"),nextjs=require("@sentry/nextjs"),customFonts=require("../custom-fonts.js"),googleFonts=require("../google-fonts.js"),genCss=require("../helpers/gen-css.js"),normalize=require("../helpers/normalize.js"),parseJson=require("../helpers/parse-json.js"),fetcher=require("../fetcher.js"),getCollectionSharePageProps=require("./get-collection-share-page-props.js");const getSharePageContentProps=e=>async t=>{try{let{sharedPage:l,customFonts:
|
|
1
|
+
"use strict";var core=require("@gem-sdk/core"),nextjs=require("@sentry/nextjs"),customFonts=require("../custom-fonts.js"),googleFonts=require("../google-fonts.js"),genCss=require("../helpers/gen-css.js"),normalize=require("../helpers/normalize.js"),parseJson=require("../helpers/parse-json.js"),fetcher=require("../fetcher.js"),getCollectionSharePageProps=require("./get-collection-share-page-props.js");const getSharePageContentProps=e=>async t=>{try{let{sharedPage:l,customFonts:o,publicToken:r}=await e([t]);if(!l||!r)return null;let{page:s,themeStyle:n,pageMeta:a,shopMeta:u,moneyFormat:c,moneyWithCurrencyFormat:i}=l,{sectionPosition:p}=s??{},g=normalize.parseBuilderTemplateV2({...l,sectionPosition:p}),P=null,f=null;if(s?.type==="GP_COLLECTION"){let e=(a??[]).find(e=>"selected_preview_collection"===e.key)?.value,t=e?JSON.parse(e??{}):null;f=t?.collectionId}let[h,d,C,m,y]=await Promise.allSettled([googleFonts.getFontStyleFromPageTemplate(g),googleFonts.getFontFromGlobalStyle(n?.data),customFonts.getCustomFonts(o),fetcher.createFetcher(r)([core.StorePropertyDocument]),s?.type==="GP_COLLECTION"?getCollectionSharePageProps.getCollectionSharePageProps(fetcher.createFetcher(r))(f??void 0):null]);P="fulfilled"===y.status?y.value?.collection:null;let F="fulfilled"===h.status?h.value:null,S="fulfilled"===d.status?d.value:null,j="fulfilled"===C.status?C.value:null,v="fulfilled"===m.status?m.value:void 0;return parseJson.serializableJson({builderData:g,page:s,themeStyle:genCss.genCSS(n?.data,!1),pageMeta:a,shopMeta:u,elementFontStyle:F,fontStyle:S,customFonts:j,publicStoreFrontData:r?{token:r,endpoint:process.env.NEXT_PUBLIC_API_URL??""}:null,pageType:s?.type,moneyFormat:c,moneyWithCurrencyFormat:i,swatches:parseJson.parseJson(v?.storeProperty?.swatchesConfig),collection:P,dynamicCollection:s?.type==="GP_COLLECTION"?{collectionId:P?.baseID}:null})}catch(e){return nextjs.captureException(e),null}};exports.getSharePageContentProps=getSharePageContentProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var genFavicon=require("./gen-favicon.js")
|
|
1
|
+
"use strict";var genFavicon=require("./gen-favicon.js");const generateFaviconLinks=e=>[{rel:"icon",sizes:"32x32",href:genFavicon.genResizeFaviconUrl(e,32)},{rel:"icon",sizes:"16x16",href:genFavicon.genResizeFaviconUrl(e,16)},{rel:"apple-touch-icon",sizes:"180x180",href:genFavicon.genResizeFaviconUrl(e,180)}],generateSeoLinks=({favicon:e})=>[...generateFaviconLinks(e)];exports.generateFaviconLinks=generateFaviconLinks,exports.generateSeoLinks=generateSeoLinks;
|
|
@@ -1,5 +1,5 @@
|
|
|
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"),dynamic=require("next/dynamic");const PreviewTemplate=({components:e,builderData:t,sectionData:s,themeStyle:r,fontStyle:n,elementFontStyle:i,customCodeHeader:a,customFonts:l,pageBackground:u,publicStoreFrontData:c,page:m,collection:o})=>{let
|
|
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"),dynamic=require("next/dynamic");const PreviewTemplate=({components:e,builderData:t,sectionData:s,themeStyle:r,fontStyle:n,elementFontStyle:i,customCodeHeader:a,customFonts:l,pageBackground:u,publicStoreFrontData:c,page:m,collection:o,dynamicCollection:d})=>{let x=router.useRouter(),{t:g}=core.useI18n(),p="custom-code-header",j=dynamic(()=>import("@gem-sdk/core").then(e=>e.CollectionProvider)),h=m?.type==="GP_COLLECTION"?j:react.Fragment;return(react.useEffect(()=>{let e=document.querySelectorAll(`[class*="${p}-"]`),t=[];e.length>1&&e.forEach(e=>{let s=e.className;if(t.includes(s)){e.remove();return}t.push(s)})},[]),x.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,a,!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"),i&&i.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),u?.isUsePageBackground&&u?.background&&jsxRuntime.jsx("style",{children:`
|
|
2
2
|
body {
|
|
3
3
|
background: ${u.background};
|
|
4
4
|
}
|
|
5
|
-
`},`page_background_${u?.background}`)]}),jsxRuntime.jsx(core.PageProvider,{publicStoreFrontData:c,children:jsxRuntime.jsx(
|
|
5
|
+
`},`page_background_${u?.background}`)]}),jsxRuntime.jsx(core.PageProvider,{publicStoreFrontData:c,dynamicCollection:d,children:jsxRuntime.jsx(h,{collection:o,children:jsxRuntime.jsx(core.BuilderComponentProvider,{components:e,children:jsxRuntime.jsx("div",{children:jsxRuntime.jsx(core.SectionProvider,{data:s,children:jsxRuntime.jsx(core.I18nProvider,{t:g,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{StorePropertyDocument as e}from"@gem-sdk/core";import{captureException as
|
|
1
|
+
import{StorePropertyDocument as e}from"@gem-sdk/core";import{captureException as l}from"@sentry/nextjs";import{getCustomFonts as t}from"../custom-fonts.js";import{getFontStyleFromPageTemplate as o,getFontFromGlobalStyle as r}from"../google-fonts.js";import{genCSS as s}from"../helpers/gen-css.js";import{parseBuilderTemplateV2 as n}from"../helpers/normalize.js";import{serializableJson as a,parseJson as i}from"../helpers/parse-json.js";import{createFetcher as u}from"../fetcher.js";import{getCollectionSharePageProps as p}from"./get-collection-share-page-props.js";let getSharePageContentProps=f=>async c=>{try{let{sharedPage:l,customFonts:m,publicToken:d}=await f([c]);if(!l||!d)return null;let{page:g,themeStyle:y,pageMeta:h,shopMeta:C,moneyFormat:P,moneyWithCurrencyFormat:v}=l,{sectionPosition:j}=g??{},I=n({...l,sectionPosition:j}),L=null,_=null;if(g?.type==="GP_COLLECTION"){let e=(h??[]).find(e=>"selected_preview_collection"===e.key)?.value,l=e?JSON.parse(e??{}):null;_=l?.collectionId}let[O,S,w,N,T]=await Promise.allSettled([o(I),r(y?.data),t(m),u(d)([e]),g?.type==="GP_COLLECTION"?p(u(d))(_??void 0):null]);L="fulfilled"===T.status?T.value?.collection:null;let E="fulfilled"===O.status?O.value:null,b="fulfilled"===S.status?S.value:null,k="fulfilled"===w.status?w.value:null,D="fulfilled"===N.status?N.value:void 0;return a({builderData:I,page:g,themeStyle:s(y?.data,!1),pageMeta:h,shopMeta:C,elementFontStyle:E,fontStyle:b,customFonts:k,publicStoreFrontData:d?{token:d,endpoint:process.env.NEXT_PUBLIC_API_URL??""}:null,pageType:g?.type,moneyFormat:P,moneyWithCurrencyFormat:v,swatches:i(D?.storeProperty?.swatchesConfig),collection:L,dynamicCollection:g?.type==="GP_COLLECTION"?{collectionId:L?.baseID}:null})}catch(e){return l(e),null}};export{getSharePageContentProps};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{genResizeFaviconUrl as e}from"./gen-favicon.js";
|
|
1
|
+
import{genResizeFaviconUrl as e}from"./gen-favicon.js";let generateFaviconLinks=n=>[{rel:"icon",sizes:"32x32",href:e(n,32)},{rel:"icon",sizes:"16x16",href:e(n,16)},{rel:"apple-touch-icon",sizes:"180x180",href:e(n,180)}],generateSeoLinks=({favicon:e})=>[...generateFaviconLinks(e)];export{generateFaviconLinks,generateSeoLinks};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment as a}from"react/jsx-runtime";import{useI18n as l,PageProvider as r,BuilderComponentProvider as n,SectionProvider as s,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,Fragment as u}from"react";import h from"next/dynamic";let PreviewTemplate=({components:f,builderData:y,sectionData:_,themeStyle:b,fontStyle:x,elementFontStyle:k,customCodeHeader:v,customFonts:N,pageBackground:T,publicStoreFrontData:L,page:P,collection:S})=>{let
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as a}from"react/jsx-runtime";import{useI18n as l,PageProvider as r,BuilderComponentProvider as n,SectionProvider as s,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,Fragment as u}from"react";import h from"next/dynamic";let PreviewTemplate=({components:f,builderData:y,sectionData:_,themeStyle:b,fontStyle:x,elementFontStyle:k,customCodeHeader:v,customFonts:N,pageBackground:T,publicStoreFrontData:L,page:P,collection:S,dynamicCollection:I})=>{let q=p(),{t:C}=l(),H="custom-code-header",M=h(()=>import("@gem-sdk/core").then(e=>e.CollectionProvider)),j=P?.type==="GP_COLLECTION"?M:u;return(m(()=>{let e=document.querySelectorAll(`[class*="${H}-"]`),t=[];e.length>1&&e.forEach(e=>{let a=e.className;if(t.includes(a)){e.remove();return}t.push(a)})},[]),q.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(H,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),T?.isUsePageBackground&&T?.background&&e("style",{children:`
|
|
2
2
|
body {
|
|
3
3
|
background: ${T.background};
|
|
4
4
|
}
|
|
5
|
-
`},`page_background_${T?.background}`)]}),e(r,{publicStoreFrontData:L,children:e(j,{collection:S,children:e(n,{components:f,children:e("div",{children:e(s,{data:_,children:e(i,{t:
|
|
5
|
+
`},`page_background_${T?.background}`)]}),e(r,{publicStoreFrontData:L,dynamicCollection:I,children:e(j,{collection:S,children:e(n,{components:f,children:e("div",{children:e(s,{data:_,children:e(i,{t:C,children:y?.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};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -58,6 +58,9 @@ type PageBuilderPropsV2 = {
|
|
|
58
58
|
type AdditionalPageBuilderProps = {
|
|
59
59
|
components: Record<string, React__default.ComponentType<any>>;
|
|
60
60
|
collection?: any;
|
|
61
|
+
dynamicCollection?: {
|
|
62
|
+
collectionId?: string;
|
|
63
|
+
};
|
|
61
64
|
};
|
|
62
65
|
type NextPageWithLayout<P = PageBuilderProps, IP = P> = NextPage<P, IP> & {
|
|
63
66
|
getLayout?: (page: React__default.ReactElement, pageProps?: any) => React__default.ReactNode;
|