@gem-sdk/pages 1.14.0-dev.780 → 1.14.0-dev.785
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 genFonts=require("./helpers/gen-fonts.js");const
|
|
1
|
+
"use strict";var genFonts=require("./helpers/gen-fonts.js");const composeFonts=e=>{let t=e.filter((e,t,n)=>t===n.findIndex(t=>t.family===e.family));return t.map(t=>{let n=e.filter(e=>e.family===t.family).reduce((e,t)=>[...e,...t.variants],[]).filter((e,t,n)=>t===n.findIndex(t=>t===e));return{...t,variants:n}})},createFontUrl=(e,t)=>{let n=e.filter(e=>"google"===e.type||!e.type);if(!n.length)return;let r=new URLSearchParams,o=t?.display||"swap",a=n.filter((e,t,n)=>t===n.findIndex(t=>t.family===e.family)),l=composeFonts(a).map(e=>`${e.family.replace(/ /g,"+")}:${e.variants.join(",")}`).join("|");return r.append("family",l),r.append("display",o),t?.subset&&r.append("subset",t.subset),t?.effect&&r.append("effect",t.effect),`https://fonts.googleapis.com/css?${decodeURIComponent(r.toString())}`};async function getFonts(e,t){let n=createFontUrl(e,t);if(!n)return"";try{return`@import url('${n}');`}catch(e){return""}}const getFontFromGlobalStyle=e=>{if(!e)return"";try{let t=JSON.parse(e),n=t?.font??{},r=Object.entries(n).map(([,e])=>e);return getFonts(r)}catch{return""}};async function getFontStyleFromPageTemplate(e){let t=e.map(e=>getFonts(genFonts.getFontsFromDataBuilder(e.data)));return await Promise.all(t)}exports.composeFonts=composeFonts,exports.createFontUrl=createFontUrl,exports.getFontFromGlobalStyle=getFontFromGlobalStyle,exports.getFontStyleFromPageTemplate=getFontStyleFromPageTemplate,exports.getFonts=getFonts;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getFontsFromDataBuilder as e}from"./helpers/gen-fonts.js";let
|
|
1
|
+
import{getFontsFromDataBuilder as e}from"./helpers/gen-fonts.js";let composeFonts=e=>{let t=e.filter((e,t,n)=>t===n.findIndex(t=>t.family===e.family));return t.map(t=>{let n=e.filter(e=>e.family===t.family).reduce((e,t)=>[...e,...t.variants],[]).filter((e,t,n)=>t===n.findIndex(t=>t===e));return{...t,variants:n}})},createFontUrl=(e,t)=>{let n=e.filter(e=>"google"===e.type||!e.type);if(!n.length)return;let r=new URLSearchParams,a=t?.display||"swap",o=n.filter((e,t,n)=>t===n.findIndex(t=>t.family===e.family)),l=composeFonts(o).map(e=>`${e.family.replace(/ /g,"+")}:${e.variants.join(",")}`).join("|");return r.append("family",l),r.append("display",a),t?.subset&&r.append("subset",t.subset),t?.effect&&r.append("effect",t.effect),`https://fonts.googleapis.com/css?${decodeURIComponent(r.toString())}`};async function getFonts(e,t){let n=createFontUrl(e,t);if(!n)return"";try{return`@import url('${n}');`}catch(e){return""}}let getFontFromGlobalStyle=e=>{if(!e)return"";try{let t=JSON.parse(e),n=t?.font??{},r=Object.entries(n).map(([,e])=>e);return getFonts(r)}catch{return""}};async function getFontStyleFromPageTemplate(t){let n=t.map(t=>getFonts(e(t.data)));return await Promise.all(n)}export{composeFonts,createFontUrl,getFontFromGlobalStyle,getFontStyleFromPageTemplate,getFonts};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -189,8 +189,8 @@ type FontOption = {
|
|
|
189
189
|
subset?: string;
|
|
190
190
|
effect?: string;
|
|
191
191
|
};
|
|
192
|
-
declare function getFonts(fonts: FontItem[], option?: FontOption
|
|
193
|
-
declare const getFontFromGlobalStyle: (data?: string
|
|
192
|
+
declare function getFonts(fonts: FontItem[], option?: FontOption): Promise<string>;
|
|
193
|
+
declare const getFontFromGlobalStyle: (data?: string) => Promise<string> | "";
|
|
194
194
|
|
|
195
195
|
declare const getFontsFromDataBuilder: (dataBuilder: Record<string, any>) => FontItem[];
|
|
196
196
|
declare const getFontFromGroupSetting: (fonts: FontItem[], groupSetting: Record<string, any>) => void;
|