@gem-sdk/pages 19.1.0-dev.1 → 19.1.0-staging.17
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,7 +1,7 @@
|
|
|
1
|
-
"use strict";var t=require("./helpers/check-option-font.js"),e=require("./helpers/gen-fonts.js"),r=require("./helpers/sentry.js"),n=require("./constants/theme-font-keys.js"),i=require("../constants/googleFontV1.js"),a=require("./data/fonts.js");const l="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36";async function
|
|
1
|
+
"use strict";var t=require("./helpers/check-option-font.js"),e=require("./helpers/gen-fonts.js"),r=require("./helpers/sentry.js"),n=require("./constants/theme-font-keys.js"),i=require("../constants/googleFontV1.js"),a=require("./data/fonts.js");const l="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36",o=t=>new Promise(e=>setTimeout(e,t));async function s(t,e){for(let n=0;n<=2;n++){let i=2===n;try{let a=await fetch(t,{headers:{"User-Agent":e},signal:AbortSignal.timeout(5e3)});if(200===a.status)return await a.text();if(a.status>=400&&a.status<500)return r.sentryCaptureException("getFontForUA",`Unexpected status ${a.status}`,{url:t,UA:e,attempt:n}),"";i&&r.sentryCaptureException("getFontForUA",`Unexpected status ${a.status}`,{url:t,UA:e,attempt:n})}catch(a){i&&r.sentryCaptureException("getFontForUA","Error fetching font",{url:t,UA:e,attempt:n,error:String(a)})}i||await o(300)}return""}const f=t=>{let e=t.filter((t,e,r)=>e===r.findIndex(e=>e.family===t.family));return e.map(e=>{let r=t.filter(t=>t.family===e.family).reduce((t,e)=>[...t,...e.variants],[]).filter((t,e,r)=>e===r.findIndex(e=>e===t));return{...e,variants:r}})},u={"Roboto Flex":"https://fonts.googleapis.com/css2?family=Roboto+Flex:opsz,wght@8..144,100..1000&display=swap"},c=t=>t?.trim().replace(/\s+/g,"+")??"",p=t=>t.includes("fonts.googleapis.com/css2")?"css2":t.includes("fonts.bunny.net")?"bunny":"css1",y=t=>{let e=c(t);return u[t]??u[e]},g={regular:"400",normal:"400",bold:"700",italic:"400italic"},m=new Set(i.googleFontFamilies),h=[...n.THEME_FONT_CSS_KEYS,...n.THEME_FONT_CSS_KEYS.map(t=>`--g-${t}`)],d=(e,r,n)=>{if(("google"===r||"google"===e.type)&&!m.has(e.family))return!1;let i="google"===e.type||"bunny"===e.type,a="theme"===e.type&&n,l=t.checkNotInOptionFont(e.family,r);return!(i&&l)&&(i||!e.type||a)},b=t=>{let e=String(t).toLowerCase().trim();return g[e]??t},S=t=>{let e=t=>{let e=String(t).toLowerCase().trim(),r=e.includes("italic"),n=e.replace("italic","").trim(),i=g[n]??n,a=parseInt(i,10)||400;return{weight:a,isItalic:r}};return[...t].sort((t,r)=>{let n=e(t),i=e(r);return n.weight!==i.weight?n.weight-i.weight:n.isItalic!==i.isItalic?n.isItalic?1:-1:0})},F=(t,e,r)=>{let n=f(t).map(t=>{let e=t.variants.map(t=>b(t)),r=S(e);return`${t.family.replace(/ /g,"+")}:${r.join(",")}`}).join("|");if("sans-serif"===n)return;let i=new URLSearchParams;return(i.append("family",n),i.append("display",r?.display||"swap"),"bunny"===e)?`https://fonts.bunny.net/css?${decodeURIComponent(i.toString())}`:(r?.subset&&i.append("subset",r.subset),r?.effect&&i.append("effect",r.effect),`https://fonts.googleapis.com/css?${decodeURIComponent(i.toString())}`)},v=(t,e,r,n)=>{let i=t.filter(t=>d(t,r||"google",n));if(!i.length)return;let a=i.filter((t,e,r)=>e===r.findIndex(e=>e.family===t.family)),l=[],o=[];for(let t of a){let e=y(t.family);e&&"bunny"!==r?l.push(e):o.push(t)}let s=o.length?F(o,r||"google",e):void 0;return l.length&&s?[...l,s]:s?[s,...l]:l};async function w(t,e,n=!0,i){let a=t.filter(t=>!h.includes(t.family)),o=v(a,e,i),f=Array.isArray(o)?o:o?[o]:[];if(!f.length)return"";if(n)return f.map(t=>`@import url('${t}');`).join("");let u=await Promise.all(f.map(async t=>{let e=await s(t,l);if(!e){let e=p(t);r.sentryCaptureException("getFonts",`Error fetching font ${e}`,{url:t,fontType:i,fontApiVersion:e})}return e})),c=f.map(t=>`@import url('${t}');`).join(""),y=u.map((t,e)=>t?"":`@import url('${f[e]}');`).join(""),g=y+u.join(""),m=new TextEncoder().encode(g).length;return m<51200?g:c}const j=(t,r)=>{let n=[];return t.forEach(t=>{n.push(...e.getFontsFromDataBuilder(t.data,r))}),f(n)},x=(t,e)=>{let r="400";if(null!=t){let e=String(t).toLowerCase().trim();r=b(e)}let n=r,i=e&&"italic"===e.toLowerCase();return i&&!r.includes("italic")&&(n=r.includes("i")?r:`${r}italic`),n},$="heading-",E="subheading-",O="paragraph-",C=t=>{let e=t?.typography??{},r=t?.font??{},n=new Map;Object.entries(e).forEach(([t,e])=>{if(!e||"object"!=typeof e)return;let i=t.startsWith($)||t.startsWith(E)?r.heading?"heading":void 0:t.startsWith(O)&&r.body?"body":void 0,a=e.desktop,l=a?.fontFamily,o=l||i;["desktop","mobile","tablet"].forEach(t=>{let i=e[t];if(!i||"object"!=typeof i)return;let l=i.fontFamily||o;if(!l||"string"!=typeof l||!r[l])return;let s=i.fontWeight??a?.fontWeight,f=i.fontStyle??a?.fontStyle;if(null==s)return;let u=x(s,f);n.has(l)||n.set(l,new Set),n.get(l).add(u)})});let i={};return n.forEach((t,e)=>{let n=r[e];n&&(i[e]={variants:Array.from(t).sort(),family:n.family,type:n.type})}),i},W=t=>{let e=t?.typography??{},r=t?.font??{},n=t?.font??{},i={};return Object.entries(e).forEach(([t,e])=>{if(!e||"object"!=typeof e)return;let a=e.desktop,l=e.mobile,o=e.tablet,s=t.startsWith($)||t.startsWith(E)?n.heading?"heading":void 0:t.startsWith(O)&&n.body?"body":void 0,f=a?.fontFamily||l?.fontFamily||o?.fontFamily||s;if(!f||"string"!=typeof f)return;let u=r[f],c=n[f],p=u?.family||c?.family||f,y=u?.type||c?.type||"google";p&&(i[t]={family:p,type:y})}),i},T=async(t,e)=>{if(!t)return"";try{let r=JSON.parse(t),n=r?.font??{},i=Object.values(n),a=C(r);Object.keys(a).length>0&&(i=Object.entries(n).filter(([t])=>a[t]).map(([t,e])=>({...e,variants:a[t].variants})));let l=f(i);return w(l,void 0,void 0,e)}catch{return""}};async function k(t,e,r){let n,i=null;if(r)try{i=JSON.parse(r),n=W(i)}catch{}let a=j(t,n);if(!i){if(0===a.length)return[];let t=await w(a,void 0,void 0,e);return t?[t]:[]}let l=C(i),o=new Map;for(let t of Object.values(l)){let e=o.get(t.family);if(!e){o.set(t.family,new Set(t.variants));continue}t.variants.forEach(t=>e.add(t))}if(0===(a=a.map(t=>{let e=o.get(t.family);if(!e)return t;let r=t.variants.filter(t=>!e.has(t));return 0===r.length?null:{...t,variants:r}}).filter(t=>null!==t)).length)return[];let s=await w(a,void 0,void 0,e);return s?[s]:[]}let A=null;function I({fontFamily:t,fontStyle:e,fontWeight:r,src:n,fontDisplay:i}){let a=n.replace(/^"|"$/g,""),l=`@font-face {
|
|
2
2
|
`;return l+=` font-family: '${t}';
|
|
3
3
|
font-style: ${e};
|
|
4
4
|
font-weight: ${r};
|
|
5
5
|
`,i&&(l+=` font-display: ${i};
|
|
6
6
|
`),l+=` src: ${a};
|
|
7
|
-
}`}function _({variant:t}){let e=t.trim().toLowerCase();if("regular"===e||"400"===e)return{fontStyle:"normal",fontWeight:"400"};if("italic"===e)return{fontStyle:"italic",fontWeight:"400"};if("bold"===e||"700"===e)return{fontStyle:"normal",fontWeight:"700"};let r=e.endsWith("i")||e.endsWith("italic"),n=e.replace(/i(talic)?$/,"").trim()||"400";return{fontStyle:r?"italic":"normal",fontWeight:n}}async function M({fonts:t,sourceFont:e}){let n=t.filter(t=>!h.includes(t.family));if(!n.length)return"";let i="bunny"===e,
|
|
7
|
+
}`}function _({variant:t}){let e=t.trim().toLowerCase();if("regular"===e||"400"===e)return{fontStyle:"normal",fontWeight:"400"};if("italic"===e)return{fontStyle:"italic",fontWeight:"400"};if("bold"===e||"700"===e)return{fontStyle:"normal",fontWeight:"700"};let r=e.endsWith("i")||e.endsWith("italic"),n=e.replace(/i(talic)?$/,"").trim()||"400";return{fontStyle:r?"italic":"normal",fontWeight:n}}async function M({fonts:t,sourceFont:e}){let n=t.filter(t=>!h.includes(t.family));if(!n.length)return"";let i="bunny"===e,o=i?null:function(){if(A)return A;for(let t of(A={},a.default.fonts)){let e=`${t.fontFamily}_${t.fontStyle}_${t.fontWeight}`.replace(/\s+/g,"");A[e]=t}return A}(),f=await Promise.all(n.map(async t=>{let n=[],i=[];for(let e of t.variants){if(o){let{fontStyle:r,fontWeight:i}=_({variant:e}),a=`${t.family}_${r}_${i}`.replace(/\s+/g,""),l=o[a];if(l){n.push(I(l));continue}}i.push(e)}if(i.length){let a=v([{...t,variants:i}],void 0,e),o=Array.isArray(a)?a:a?[a]:[],f=await Promise.all(o.map(t=>s(t,l)));for(let e=0;e<f.length;e++){let a=f[e];a?n.push(a):r.sentryCaptureException("resolveFontFaces","API fallback returned empty CSS",{family:t.family,variants:i,url:o[e]})}}return n.length?n.join("\n"):""}));return f.filter(Boolean).join("\n")}async function U({data:t,sourceFont:e}){if(!t)return"";try{let r="string"==typeof t?JSON.parse(t):t,n=r?.font??{},i=Object.values(n),a=C(r);return Object.keys(a).length>0&&(i=Object.entries(n).filter(([t])=>a[t]).map(([t,e])=>Object.assign({},e,{variants:a[t].variants}))),M({fonts:f(i),sourceFont:e})}catch{return""}}async function L({pageTemplate:t,sourceFont:e,data:r}){let n,i=null;if(r)try{i="string"==typeof r?JSON.parse(r):r,n=W(i)}catch(t){console.log(t)}let a=j(t,n);if(!i){if(!a.length)return[];let t=await M({fonts:a,sourceFont:e});return t?[t]:[]}let l=C(i),o=new Map,s=new Map,f=(t,e)=>`${t}::${e}`;for(let t of Object.values(l))if(t.type){let e=f(t.family,t.type),r=o.get(e);r?t.variants.forEach(t=>r.add(t)):o.set(e,new Set(t.variants))}else{let e=s.get(t.family);e?t.variants.forEach(t=>e.add(t)):s.set(t.family,new Set(t.variants))}if(!(a=a.map(t=>{let e=o.get(f(t.family,t.type))||s.get(t.family);if(!e)return t;let r=t.variants.filter(t=>!e.has(t));return r.length?Object.assign({},t,{variants:r}):null}).filter(t=>null!==t)).length)return[];let u=await M({fonts:a,sourceFont:e});return u?[u]:[]}exports.composeFonts=f,exports.createFontUrls=v,exports.extractTypographyVariants=C,exports.getFontFromGlobalStyle=(t,e)=>{if(!t)return"";try{let r=JSON.parse(t),n=r?.font??{},i=Object.entries(n).map(([,t])=>t);return w(i,void 0,void 0,e)}catch{return""}},exports.getFontLinkFromGlobalStyle=T,exports.getFontStyleFromPageTemplate=k,exports.getFonts=w,exports.getStaticFontFacesFromGlobalStyle=U,exports.getStaticFontFacesFromPageTemplate=L,exports.mapTypographyToFontFamily=W,exports.parseVariant=_,exports.staticFontToCSS=I;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime"),s=require("@gem-sdk/core"),t=require("next-seo"),r=require("next/head"),a=require("next/router"),n=require("../libs/parse-html.js"),i=require("../components/builder/Header.js"),l=require("../components/FooterForPostPurchase.js"),o=require("next/script"),d=require("react"),c=require("../libs/hooks/usePageViewedTracking.js");exports.StaticPageV2=({components:g,builderData:u,sectionData:p,seo:m,themeStyle:h,fontStyle:x,elementFontStyle:j,customCodeHeader:f,customFonts:y,isPostPurchase:_,shopName:v,productOffers:P,publicStoreFrontData:b,dynamicDiscountOffer:S,isPreview:q,interaction:k,pageBackground:N,sellingPlanSetting:T,buyerConsentPreCheck:H,id:I,shopID:E,domainTrackingIlp:L})=>{let M=a.useRouter(),{t:$}=s.useI18n(),w=process.env.NEXT_GP_BASE_ASSET_URL||"https://assets
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),s=require("@gem-sdk/core"),t=require("next-seo"),r=require("next/head"),a=require("next/router"),n=require("../libs/parse-html.js"),i=require("../components/builder/Header.js"),l=require("../components/FooterForPostPurchase.js"),o=require("next/script"),d=require("react"),c=require("../libs/hooks/usePageViewedTracking.js");exports.StaticPageV2=({components:g,builderData:u,sectionData:p,seo:m,themeStyle:h,fontStyle:x,elementFontStyle:j,customCodeHeader:f,customFonts:y,isPostPurchase:_,shopName:v,productOffers:P,publicStoreFrontData:b,dynamicDiscountOffer:S,isPreview:q,interaction:k,pageBackground:N,sellingPlanSetting:T,buyerConsentPreCheck:H,id:I,shopID:E,domainTrackingIlp:L})=>{let M=a.useRouter(),{t:$}=s.useI18n(),w=process.env.NEXT_GP_BASE_ASSET_URL||"https://assets.gemcommerce.xyz";c.usePageViewedTracking({id:I,shopID:E,domain:L});let F="custom-code-header";if(d.useEffect(()=>{let e=document.querySelectorAll(`[class*="${F}-"]`),s=[];e.length>1&&e.forEach(e=>{let t=e.className;if(s.includes(t)){e.remove();return}s.push(t)})},[]),M.isFallback)return e.jsx("div",{className:"gp-flex gp-h-[100vh] gp-items-center gp-justify-center",children:e.jsxs("div",{className:"gp-flex gp-gap-2",children:[e.jsx("span",{className:"gp-aspect-square gp-h-2 gp-animate-[flashing_500ms_infinite_alternate] gp-rounded-full gp-bg-slate-800"}),e.jsx("span",{className:"gp-aspect-square gp-h-2 gp-animate-[flashing_500ms_infinite_200ms_linear_alternate] gp-rounded-full gp-bg-slate-800"}),e.jsx("span",{className:"gp-aspect-square gp-h-2 gp-animate-[flashing_500ms_infinite_500ms_alternate] gp-rounded-full gp-bg-slate-800"})]})});let A=(k?.value||[]).length>0;return e.jsxs(e.Fragment,{children:[e.jsx(t.NextSeo,{...m}),e.jsxs(r,{children:[n.parseHtml(F,f,!0),h&&e.jsx("style",{"data-id":"global-style",type:"text/css",dangerouslySetInnerHTML:{__html:h}},"global-style"),x&&e.jsx("style",{"data-id":"google-fonts",type:"text/css",dangerouslySetInnerHTML:{__html:x}},"google-fonts"),j&&j.map(s=>e.jsx("style",{"data-id":"google-element-fonts",type:"text/css",dangerouslySetInnerHTML:{__html:s}},s)),y&&e.jsx("style",{"data-id":"custom-element-fonts",type:"text/css",dangerouslySetInnerHTML:{__html:y}},x),N?.isUsePageBackground&&N?.background&&e.jsx("style",{children:`
|
|
2
2
|
body {
|
|
3
3
|
background: ${N.background};
|
|
4
4
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{checkNotInOptionFont as t}from"./helpers/check-option-font.js";import{getFontsFromDataBuilder as e}from"./helpers/gen-fonts.js";import{sentryCaptureException as r}from"./helpers/sentry.js";import{THEME_FONT_CSS_KEYS as n}from"./constants/theme-font-keys.js";import{googleFontFamilies as i}from"../constants/googleFontV1.js";import
|
|
2
|
-
`;return
|
|
1
|
+
import{checkNotInOptionFont as t}from"./helpers/check-option-font.js";import{getFontsFromDataBuilder as e}from"./helpers/gen-fonts.js";import{sentryCaptureException as r}from"./helpers/sentry.js";import{THEME_FONT_CSS_KEYS as n}from"./constants/theme-font-keys.js";import{googleFontFamilies as i}from"../constants/googleFontV1.js";import a from"./data/fonts.js";let l="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36",o=t=>new Promise(e=>setTimeout(e,t));async function s(t,e){for(let n=0;n<=2;n++){let i=2===n;try{let a=await fetch(t,{headers:{"User-Agent":e},signal:AbortSignal.timeout(5e3)});if(200===a.status)return await a.text();if(a.status>=400&&a.status<500)return r("getFontForUA",`Unexpected status ${a.status}`,{url:t,UA:e,attempt:n}),"";i&&r("getFontForUA",`Unexpected status ${a.status}`,{url:t,UA:e,attempt:n})}catch(a){i&&r("getFontForUA","Error fetching font",{url:t,UA:e,attempt:n,error:String(a)})}i||await o(300)}return""}let f=t=>{let e=t.filter((t,e,r)=>e===r.findIndex(e=>e.family===t.family));return e.map(e=>{let r=t.filter(t=>t.family===e.family).reduce((t,e)=>[...t,...e.variants],[]).filter((t,e,r)=>e===r.findIndex(e=>e===t));return{...e,variants:r}})},c={"Roboto Flex":"https://fonts.googleapis.com/css2?family=Roboto+Flex:opsz,wght@8..144,100..1000&display=swap"},u=t=>t?.trim().replace(/\s+/g,"+")??"",y=t=>t.includes("fonts.googleapis.com/css2")?"css2":t.includes("fonts.bunny.net")?"bunny":"css1",p=t=>{let e=u(t);return c[t]??c[e]},g={regular:"400",normal:"400",bold:"700",italic:"400italic"},m=new Set(i),h=[...n,...n.map(t=>`--g-${t}`)],d=(e,r,n)=>{if(("google"===r||"google"===e.type)&&!m.has(e.family))return!1;let i="google"===e.type||"bunny"===e.type,a="theme"===e.type&&n,l=t(e.family,r);return!(i&&l)&&(i||!e.type||a)},b=t=>{let e=String(t).toLowerCase().trim();return g[e]??t},v=t=>{let e=t=>{let e=String(t).toLowerCase().trim(),r=e.includes("italic"),n=e.replace("italic","").trim(),i=g[n]??n,a=parseInt(i,10)||400;return{weight:a,isItalic:r}};return[...t].sort((t,r)=>{let n=e(t),i=e(r);return n.weight!==i.weight?n.weight-i.weight:n.isItalic!==i.isItalic?n.isItalic?1:-1:0})},S=(t,e,r)=>{let n=f(t).map(t=>{let e=t.variants.map(t=>b(t)),r=v(e);return`${t.family.replace(/ /g,"+")}:${r.join(",")}`}).join("|");if("sans-serif"===n)return;let i=new URLSearchParams;return(i.append("family",n),i.append("display",r?.display||"swap"),"bunny"===e)?`https://fonts.bunny.net/css?${decodeURIComponent(i.toString())}`:(r?.subset&&i.append("subset",r.subset),r?.effect&&i.append("effect",r.effect),`https://fonts.googleapis.com/css?${decodeURIComponent(i.toString())}`)},w=(t,e,r,n)=>{let i=t.filter(t=>d(t,r||"google",n));if(!i.length)return;let a=i.filter((t,e,r)=>e===r.findIndex(e=>e.family===t.family)),l=[],o=[];for(let t of a){let e=p(t.family);e&&"bunny"!==r?l.push(e):o.push(t)}let s=o.length?S(o,r||"google",e):void 0;return l.length&&s?[...l,s]:s?[s,...l]:l};async function F(t,e,n=!0,i){let a=t.filter(t=>!h.includes(t.family)),o=w(a,e,i),f=Array.isArray(o)?o:o?[o]:[];if(!f.length)return"";if(n)return f.map(t=>`@import url('${t}');`).join("");let c=await Promise.all(f.map(async t=>{let e=await s(t,l);if(!e){let e=y(t);r("getFonts",`Error fetching font ${e}`,{url:t,fontType:i,fontApiVersion:e})}return e})),u=f.map(t=>`@import url('${t}');`).join(""),p=c.map((t,e)=>t?"":`@import url('${f[e]}');`).join(""),g=p+c.join(""),m=new TextEncoder().encode(g).length;return m<51200?g:u}let j=(t,r)=>{let n=[];return t.forEach(t=>{n.push(...e(t.data,r))}),f(n)},$=(t,e)=>{let r="400";if(null!=t){let e=String(t).toLowerCase().trim();r=b(e)}let n=r,i=e&&"italic"===e.toLowerCase();return i&&!r.includes("italic")&&(n=r.includes("i")?r:`${r}italic`),n},O="heading-",W="subheading-",A="paragraph-",k=t=>{let e=t?.typography??{},r=t?.font??{},n=new Map;Object.entries(e).forEach(([t,e])=>{if(!e||"object"!=typeof e)return;let i=t.startsWith(O)||t.startsWith(W)?r.heading?"heading":void 0:t.startsWith(A)&&r.body?"body":void 0,a=e.desktop,l=a?.fontFamily,o=l||i;["desktop","mobile","tablet"].forEach(t=>{let i=e[t];if(!i||"object"!=typeof i)return;let l=i.fontFamily||o;if(!l||"string"!=typeof l||!r[l])return;let s=i.fontWeight??a?.fontWeight,f=i.fontStyle??a?.fontStyle;if(null==s)return;let c=$(s,f);n.has(l)||n.set(l,new Set),n.get(l).add(c)})});let i={};return n.forEach((t,e)=>{let n=r[e];n&&(i[e]={variants:Array.from(t).sort(),family:n.family,type:n.type})}),i},x=t=>{let e=t?.typography??{},r=t?.font??{},n=t?.font??{},i={};return Object.entries(e).forEach(([t,e])=>{if(!e||"object"!=typeof e)return;let a=e.desktop,l=e.mobile,o=e.tablet,s=t.startsWith(O)||t.startsWith(W)?n.heading?"heading":void 0:t.startsWith(A)&&n.body?"body":void 0,f=a?.fontFamily||l?.fontFamily||o?.fontFamily||s;if(!f||"string"!=typeof f)return;let c=r[f],u=n[f],y=c?.family||u?.family||f,p=c?.type||u?.type||"google";y&&(i[t]={family:y,type:p})}),i},E=async(t,e)=>{if(!t)return"";try{let r=JSON.parse(t),n=r?.font??{},i=Object.values(n),a=k(r);Object.keys(a).length>0&&(i=Object.entries(n).filter(([t])=>a[t]).map(([t,e])=>({...e,variants:a[t].variants})));let l=f(i);return F(l,void 0,void 0,e)}catch{return""}},I=(t,e)=>{if(!t)return"";try{let r=JSON.parse(t),n=r?.font??{},i=Object.entries(n).map(([,t])=>t);return F(i,void 0,void 0,e)}catch{return""}};async function C(t,e,r){let n,i=null;if(r)try{i=JSON.parse(r),n=x(i)}catch{}let a=j(t,n);if(!i){if(0===a.length)return[];let t=await F(a,void 0,void 0,e);return t?[t]:[]}let l=k(i),o=new Map;for(let t of Object.values(l)){let e=o.get(t.family);if(!e){o.set(t.family,new Set(t.variants));continue}t.variants.forEach(t=>e.add(t))}if(0===(a=a.map(t=>{let e=o.get(t.family);if(!e)return t;let r=t.variants.filter(t=>!e.has(t));return 0===r.length?null:{...t,variants:r}}).filter(t=>null!==t)).length)return[];let s=await F(a,void 0,void 0,e);return s?[s]:[]}let U=null;function T({fontFamily:t,fontStyle:e,fontWeight:r,src:n,fontDisplay:i}){let a=n.replace(/^"|"$/g,""),l=`@font-face {
|
|
2
|
+
`;return l+=` font-family: '${t}';
|
|
3
3
|
font-style: ${e};
|
|
4
4
|
font-weight: ${r};
|
|
5
|
-
`,i&&(
|
|
6
|
-
`),
|
|
7
|
-
}`}function
|
|
5
|
+
`,i&&(l+=` font-display: ${i};
|
|
6
|
+
`),l+=` src: ${a};
|
|
7
|
+
}`}function L({variant:t}){let e=t.trim().toLowerCase();if("regular"===e||"400"===e)return{fontStyle:"normal",fontWeight:"400"};if("italic"===e)return{fontStyle:"italic",fontWeight:"400"};if("bold"===e||"700"===e)return{fontStyle:"normal",fontWeight:"700"};let r=e.endsWith("i")||e.endsWith("italic"),n=e.replace(/i(talic)?$/,"").trim()||"400";return{fontStyle:r?"italic":"normal",fontWeight:n}}async function M({fonts:t,sourceFont:e}){let n=t.filter(t=>!h.includes(t.family));if(!n.length)return"";let i="bunny"===e,o=i?null:function(){if(U)return U;for(let t of(U={},a.fonts)){let e=`${t.fontFamily}_${t.fontStyle}_${t.fontWeight}`.replace(/\s+/g,"");U[e]=t}return U}(),f=await Promise.all(n.map(async t=>{let n=[],i=[];for(let e of t.variants){if(o){let{fontStyle:r,fontWeight:i}=L({variant:e}),a=`${t.family}_${r}_${i}`.replace(/\s+/g,""),l=o[a];if(l){n.push(T(l));continue}}i.push(e)}if(i.length){let a=w([{...t,variants:i}],void 0,e),o=Array.isArray(a)?a:a?[a]:[],f=await Promise.all(o.map(t=>s(t,l)));for(let e=0;e<f.length;e++){let a=f[e];a?n.push(a):r("resolveFontFaces","API fallback returned empty CSS",{family:t.family,variants:i,url:o[e]})}}return n.length?n.join("\n"):""}));return f.filter(Boolean).join("\n")}async function P({data:t,sourceFont:e}){if(!t)return"";try{let r="string"==typeof t?JSON.parse(t):t,n=r?.font??{},i=Object.values(n),a=k(r);return Object.keys(a).length>0&&(i=Object.entries(n).filter(([t])=>a[t]).map(([t,e])=>Object.assign({},e,{variants:a[t].variants}))),M({fonts:f(i),sourceFont:e})}catch{return""}}async function _({pageTemplate:t,sourceFont:e,data:r}){let n,i=null;if(r)try{i="string"==typeof r?JSON.parse(r):r,n=x(i)}catch(t){console.log(t)}let a=j(t,n);if(!i){if(!a.length)return[];let t=await M({fonts:a,sourceFont:e});return t?[t]:[]}let l=k(i),o=new Map,s=new Map,f=(t,e)=>`${t}::${e}`;for(let t of Object.values(l))if(t.type){let e=f(t.family,t.type),r=o.get(e);r?t.variants.forEach(t=>r.add(t)):o.set(e,new Set(t.variants))}else{let e=s.get(t.family);e?t.variants.forEach(t=>e.add(t)):s.set(t.family,new Set(t.variants))}if(!(a=a.map(t=>{let e=o.get(f(t.family,t.type))||s.get(t.family);if(!e)return t;let r=t.variants.filter(t=>!e.has(t));return r.length?Object.assign({},t,{variants:r}):null}).filter(t=>null!==t)).length)return[];let c=await M({fonts:a,sourceFont:e});return c?[c]:[]}export{f as composeFonts,w as createFontUrls,k as extractTypographyVariants,I as getFontFromGlobalStyle,E as getFontLinkFromGlobalStyle,C as getFontStyleFromPageTemplate,F as getFonts,P as getStaticFontFacesFromGlobalStyle,_ as getStaticFontFacesFromPageTemplate,x as mapTypographyToFontFamily,L as parseVariant,T as staticFontToCSS};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment as s}from"react/jsx-runtime";import{useI18n as a,PageProvider as r,BuilderComponentProvider as n,I18nProvider as l,SectionProvider as o,BuilderProvider as i,Render as p}from"@gem-sdk/core";import{NextSeo as
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as s}from"react/jsx-runtime";import{useI18n as a,PageProvider as r,BuilderComponentProvider as n,I18nProvider as l,SectionProvider as o,BuilderProvider as i,Render as p}from"@gem-sdk/core";import{NextSeo as c}from"next-seo";import d from"next/head";import{useRouter as g}from"next/router";import{parseHtml as m}from"../libs/parse-html.js";import u from"../components/builder/Header.js";import h from"../components/FooterForPostPurchase.js";import f from"next/script";import{useEffect as y}from"react";import{usePageViewedTracking as _}from"../libs/hooks/usePageViewedTracking.js";let b=({components:b,builderData:v,sectionData:S,seo:x,themeStyle:P,fontStyle:k,elementFontStyle:N,customCodeHeader:T,customFonts:j,isPostPurchase:H,shopName:I,productOffers:L,publicStoreFrontData:M,dynamicDiscountOffer:$,isPreview:E,interaction:q,pageBackground:w,sellingPlanSetting:A,buyerConsentPreCheck:F,id:O,shopID:z,domainTrackingIlp:C})=>{let D=g(),{t:U}=a(),B=process.env.NEXT_GP_BASE_ASSET_URL||"https://assets.gemcommerce.xyz";_({id:O,shopID:z,domain:C});let R="custom-code-header";if(y(()=>{let e=document.querySelectorAll(`[class*="${R}-"]`),t=[];e.length>1&&e.forEach(e=>{let s=e.className;if(t.includes(s)){e.remove();return}t.push(s)})},[]),D.isFallback)return 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"})]})});let V=(q?.value||[]).length>0;return t(s,{children:[e(c,{...x}),t(d,{children:[m(R,T,!0),P&&e("style",{"data-id":"global-style",type:"text/css",dangerouslySetInnerHTML:{__html:P}},"global-style"),k&&e("style",{"data-id":"google-fonts",type:"text/css",dangerouslySetInnerHTML:{__html:k}},"google-fonts"),N&&N.map(t=>e("style",{"data-id":"google-element-fonts",type:"text/css",dangerouslySetInnerHTML:{__html:t}},t)),j&&e("style",{"data-id":"custom-element-fonts",type:"text/css",dangerouslySetInnerHTML:{__html:j}},k),w?.isUsePageBackground&&w?.background&&e("style",{children:`
|
|
2
2
|
body {
|
|
3
3
|
background: ${w.background};
|
|
4
4
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/pages",
|
|
3
|
-
"version": "19.1.0-
|
|
3
|
+
"version": "19.1.0-staging.17",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"next": "14.2.35"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@gem-sdk/core": "19.1.0-
|
|
31
|
-
"@gem-sdk/plugin-cookie-bar": "19.1.0-
|
|
32
|
-
"@gem-sdk/plugin-quick-view": "19.1.0-
|
|
33
|
-
"@gem-sdk/plugin-sticky-add-to-cart": "19.1.0-
|
|
30
|
+
"@gem-sdk/core": "19.1.0-staging.12",
|
|
31
|
+
"@gem-sdk/plugin-cookie-bar": "19.1.0-staging.9",
|
|
32
|
+
"@gem-sdk/plugin-quick-view": "19.1.0-staging.9",
|
|
33
|
+
"@gem-sdk/plugin-sticky-add-to-cart": "19.1.0-staging.9"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"next": "14.2.35"
|