@gem-sdk/pages 1.57.10-staging.3 → 1.57.12
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/components/builder/Toolbox.js +1 -21
- package/dist/cjs/libs/api/get-static-page-props-v2.js +3 -13
- package/dist/cjs/libs/google-fonts.js +11 -20
- package/dist/esm/components/builder/Toolbox.js +1 -21
- package/dist/esm/libs/api/get-static-page-props-v2.js +4 -14
- package/dist/esm/libs/google-fonts.js +11 -20
- package/dist/types/index.d.ts +3 -5
- package/package.json +5 -5
- package/dist/cjs/libs/helpers/check-option-font.js +0 -65
- package/dist/cjs/store/libs-store.js +0 -14
- package/dist/esm/libs/helpers/check-option-font.js +0 -63
- package/dist/esm/store/libs-store.js +0 -12
|
@@ -10,8 +10,6 @@ var googleFonts = require('../../libs/google-fonts.js');
|
|
|
10
10
|
var genCss = require('../../libs/helpers/gen-css.js');
|
|
11
11
|
var genFonts = require('../../libs/helpers/gen-fonts.js');
|
|
12
12
|
var shopifyCdnWithGoogleFonts = require('../../libs/shopify-cdn-with-google-fonts.js');
|
|
13
|
-
var libsStore = require('../../store/libs-store.js');
|
|
14
|
-
var checkOptionFont = require('../../libs/helpers/check-option-font.js');
|
|
15
13
|
|
|
16
14
|
const globalStyleId = 'global-style';
|
|
17
15
|
const Toolbox = ()=>{
|
|
@@ -37,8 +35,6 @@ const Toolbox = ()=>{
|
|
|
37
35
|
const changeLayoutSettings = core.useShopStore((s)=>s.changeLayoutSettings);
|
|
38
36
|
const changeCreateThemeSectionCount = core.useShopStore((s)=>s.changeCreateThemeSectionCount);
|
|
39
37
|
const changeShopPlan = core.useShopStore((s)=>s.changeShopPlan);
|
|
40
|
-
const changeFontType = libsStore.libsStore((s)=>s.changeFontType);
|
|
41
|
-
const fontType = libsStore.libsStore((s)=>s.fontType);
|
|
42
38
|
const clearModal = core.useModalStore((s)=>s.clearModal);
|
|
43
39
|
const changeLimitCreateThemeSection = core.useShopStore((s)=>s.changeLimitCreateThemeSection);
|
|
44
40
|
const setInteractionIsSelectOnPage = core.usePageStore((s)=>s.setInteractionIsSelectOnPage);
|
|
@@ -74,12 +70,6 @@ const Toolbox = ()=>{
|
|
|
74
70
|
});
|
|
75
71
|
// append new fonts
|
|
76
72
|
for (const font of fonts){
|
|
77
|
-
if ([
|
|
78
|
-
'bunny',
|
|
79
|
-
'google'
|
|
80
|
-
].includes(font.type) && checkOptionFont.checkNotInOptionFont(font.family, fontType)) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
73
|
if (font.type !== 'custom') {
|
|
84
74
|
if (font.variants?.length) {
|
|
85
75
|
for (const variant of font.variants){
|
|
@@ -91,7 +81,7 @@ const Toolbox = ()=>{
|
|
|
91
81
|
const variantName = variant;
|
|
92
82
|
const url = googleFonts.createFontUrl([
|
|
93
83
|
cloneFont
|
|
94
|
-
]
|
|
84
|
+
]);
|
|
95
85
|
if (url) {
|
|
96
86
|
const googleFont = document.querySelector(`.${className}[data-font="${fontName}"][data-font-variant="${variantName}"]`);
|
|
97
87
|
if (googleFont) {
|
|
@@ -294,13 +284,6 @@ const Toolbox = ()=>{
|
|
|
294
284
|
}, [
|
|
295
285
|
changeShopPlan
|
|
296
286
|
]);
|
|
297
|
-
const onUpdateFontType = react.useCallback((e)=>{
|
|
298
|
-
const fontType = e.detail;
|
|
299
|
-
if (!fontType) return;
|
|
300
|
-
changeFontType(fontType);
|
|
301
|
-
}, [
|
|
302
|
-
changeFontType
|
|
303
|
-
]);
|
|
304
287
|
const onUpdateDynamicProduct = react.useCallback((e)=>{
|
|
305
288
|
const product = e.detail;
|
|
306
289
|
if (!product) return;
|
|
@@ -422,7 +405,6 @@ const Toolbox = ()=>{
|
|
|
422
405
|
window.addEventListener('update-interaction-item', onUpdateInteractionItem);
|
|
423
406
|
window.addEventListener('update-interaction-setting-type', onUpdateInteractionSettingType);
|
|
424
407
|
window.addEventListener('change-sidebar-mode', onChangeSidebarMode);
|
|
425
|
-
window.addEventListener('update-font-type', onUpdateFontType);
|
|
426
408
|
return ()=>{
|
|
427
409
|
window.removeEventListener('update-shop-info', onChangeShopInfo);
|
|
428
410
|
window.removeEventListener('revalidate-query', onRevalidateQuery);
|
|
@@ -446,7 +428,6 @@ const Toolbox = ()=>{
|
|
|
446
428
|
window.removeEventListener('update-interaction-is-select-on-page', onUpdateInteractionIsSelectOnPage);
|
|
447
429
|
window.removeEventListener('update-interaction-item', onUpdateInteractionItem);
|
|
448
430
|
window.removeEventListener('update-interaction-setting-type', onUpdateInteractionSettingType);
|
|
449
|
-
window.removeEventListener('update-font-type', onUpdateFontType);
|
|
450
431
|
};
|
|
451
432
|
}, [
|
|
452
433
|
onAddEntity,
|
|
@@ -472,7 +453,6 @@ const Toolbox = ()=>{
|
|
|
472
453
|
onUpdateInteractionItem,
|
|
473
454
|
onUpdateInteractionIsSelectOnPage,
|
|
474
455
|
onUpdateInteractionSettingType,
|
|
475
|
-
onUpdateFontType,
|
|
476
456
|
onChangeSidebarMode
|
|
477
457
|
]);
|
|
478
458
|
return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
@@ -18,7 +18,7 @@ const getStaticPagePropsV2 = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
18
18
|
slug,
|
|
19
19
|
slugType: pageType
|
|
20
20
|
};
|
|
21
|
-
const [theme, storeProperty, shopifyMeta
|
|
21
|
+
const [theme, storeProperty, shopifyMeta] = await Promise.allSettled([
|
|
22
22
|
fetcher([
|
|
23
23
|
core.PublishedThemePagesDocument,
|
|
24
24
|
variables
|
|
@@ -28,21 +28,11 @@ const getStaticPagePropsV2 = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
28
28
|
]),
|
|
29
29
|
shopifyFetcher([
|
|
30
30
|
adapterShopify.ShopMetaDocument
|
|
31
|
-
]),
|
|
32
|
-
fetcher([
|
|
33
|
-
core.PublishedShopMetasDocument,
|
|
34
|
-
{
|
|
35
|
-
keys: [
|
|
36
|
-
'source_font'
|
|
37
|
-
]
|
|
38
|
-
}
|
|
39
31
|
])
|
|
40
32
|
]);
|
|
41
33
|
if (theme.status === 'rejected') {
|
|
42
34
|
throw new Error(theme.reason?.[0]);
|
|
43
35
|
}
|
|
44
|
-
const publishedShopMetaValue = publishedShopMetas.status === 'fulfilled' ? publishedShopMetas.value : undefined;
|
|
45
|
-
const sourceFont = publishedShopMetaValue?.publishedShopMetas?.find((item)=>item?.key === 'source_font');
|
|
46
36
|
const dataBuilder = theme.value.publishedThemePages?.[0];
|
|
47
37
|
const themePageCustomFonts = theme.value?.publishedThemePages?.[0]?.themePageCustomFonts;
|
|
48
38
|
if (!dataBuilder) {
|
|
@@ -50,8 +40,8 @@ const getStaticPagePropsV2 = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
50
40
|
}
|
|
51
41
|
const pageTemplate = normalize.parseBuilderTemplateV2(dataBuilder);
|
|
52
42
|
const [elementFontStyle, fontStyle, fallback, customFonts$1] = await Promise.all([
|
|
53
|
-
googleFonts.getFontStyleFromPageTemplate(pageTemplate
|
|
54
|
-
googleFonts.getFontFromGlobalStyle(dataBuilder?.pageStyle?.data
|
|
43
|
+
googleFonts.getFontStyleFromPageTemplate(pageTemplate),
|
|
44
|
+
googleFonts.getFontFromGlobalStyle(dataBuilder?.pageStyle?.data),
|
|
55
45
|
getFallback.getFallbackV2(fetcher, pageTemplate),
|
|
56
46
|
customFonts.getCustomFonts(themePageCustomFonts)
|
|
57
47
|
]);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var checkOptionFont = require('./helpers/check-option-font.js');
|
|
4
3
|
var genFonts = require('./helpers/gen-fonts.js');
|
|
5
4
|
|
|
6
5
|
const CHROME_UA = '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';
|
|
@@ -36,17 +35,12 @@ const composeFonts = (fonts)=>{
|
|
|
36
35
|
};
|
|
37
36
|
});
|
|
38
37
|
};
|
|
39
|
-
const createFontUrl = (fonts, option
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
'bunny',
|
|
43
|
-
'google'
|
|
44
|
-
].includes(font.type) && checkOptionFont.checkNotInOptionFont(font.family, fontType || 'google')) && (font.type === 'google' || font.type === 'bunny' || !font.type);
|
|
45
|
-
});
|
|
46
|
-
if (!mainFonts.length) return;
|
|
38
|
+
const createFontUrl = (fonts, option)=>{
|
|
39
|
+
const googleFonts = fonts.filter((font)=>font.type === 'google' || !font.type);
|
|
40
|
+
if (!googleFonts.length) return;
|
|
47
41
|
const params = new URLSearchParams();
|
|
48
42
|
const display = option?.display || 'swap';
|
|
49
|
-
const uniqFonts =
|
|
43
|
+
const uniqFonts = googleFonts.filter((font, index, arr)=>{
|
|
50
44
|
return index === arr.findIndex((t)=>t.family === font.family);
|
|
51
45
|
});
|
|
52
46
|
const family = composeFonts(uniqFonts).map((font)=>{
|
|
@@ -60,16 +54,13 @@ const createFontUrl = (fonts, option, fontType)=>{
|
|
|
60
54
|
if (option?.effect) {
|
|
61
55
|
params.append('effect', option.effect);
|
|
62
56
|
}
|
|
63
|
-
|
|
64
|
-
const googleFontUrl = `https://fonts.googleapis.com/css?${decodeURIComponent(params.toString())}`;
|
|
65
|
-
return fontType === 'bunny' ? bunnyFontUrl : googleFontUrl;
|
|
57
|
+
return `https://fonts.googleapis.com/css?${decodeURIComponent(params.toString())}`;
|
|
66
58
|
};
|
|
67
|
-
|
|
68
|
-
async function getFonts(fonts, option, isImportFontByUrl = true, fontType) {
|
|
59
|
+
async function getFonts(fonts, option, isImportFontByUrl = true) {
|
|
69
60
|
/**
|
|
70
61
|
* The order of IE -> Chrome is important, other wise chrome starts loading woff1.
|
|
71
62
|
* CSS cascading 🤷♂️.
|
|
72
|
-
*/ const url = createFontUrl(fonts, option
|
|
63
|
+
*/ const url = createFontUrl(fonts, option);
|
|
73
64
|
if (!url) return '';
|
|
74
65
|
try {
|
|
75
66
|
if (isImportFontByUrl) return `@import url('${url}');`;
|
|
@@ -91,7 +82,7 @@ async function getFonts(fonts, option, isImportFontByUrl = true, fontType) {
|
|
|
91
82
|
return '';
|
|
92
83
|
}
|
|
93
84
|
}
|
|
94
|
-
const getFontFromGlobalStyle = (data
|
|
85
|
+
const getFontFromGlobalStyle = (data)=>{
|
|
95
86
|
if (!data) return '';
|
|
96
87
|
try {
|
|
97
88
|
const globalStyle = JSON.parse(data);
|
|
@@ -99,14 +90,14 @@ const getFontFromGlobalStyle = (data, sourceFont)=>{
|
|
|
99
90
|
const fonts = Object.entries(fontData).map(([, value])=>{
|
|
100
91
|
return value;
|
|
101
92
|
});
|
|
102
|
-
return getFonts(fonts
|
|
93
|
+
return getFonts(fonts);
|
|
103
94
|
} catch {
|
|
104
95
|
return '';
|
|
105
96
|
}
|
|
106
97
|
};
|
|
107
|
-
async function getFontStyleFromPageTemplate(pageTemplate
|
|
98
|
+
async function getFontStyleFromPageTemplate(pageTemplate) {
|
|
108
99
|
const fontStyle = pageTemplate.map((sectionData)=>{
|
|
109
|
-
return getFonts(genFonts.getFontsFromDataBuilder(sectionData.data)
|
|
100
|
+
return getFonts(genFonts.getFontsFromDataBuilder(sectionData.data));
|
|
110
101
|
});
|
|
111
102
|
return await Promise.all(fontStyle);
|
|
112
103
|
}
|
|
@@ -6,8 +6,6 @@ import { createFontUrl } from '../../libs/google-fonts.js';
|
|
|
6
6
|
import { genCSS } from '../../libs/helpers/gen-css.js';
|
|
7
7
|
import { getFontsFromDataBuilder } from '../../libs/helpers/gen-fonts.js';
|
|
8
8
|
import { shopifyCdnWithGoogleFonts } from '../../libs/shopify-cdn-with-google-fonts.js';
|
|
9
|
-
import { libsStore } from '../../store/libs-store.js';
|
|
10
|
-
import { checkNotInOptionFont } from '../../libs/helpers/check-option-font.js';
|
|
11
9
|
|
|
12
10
|
const globalStyleId = 'global-style';
|
|
13
11
|
const Toolbox = ()=>{
|
|
@@ -33,8 +31,6 @@ const Toolbox = ()=>{
|
|
|
33
31
|
const changeLayoutSettings = useShopStore((s)=>s.changeLayoutSettings);
|
|
34
32
|
const changeCreateThemeSectionCount = useShopStore((s)=>s.changeCreateThemeSectionCount);
|
|
35
33
|
const changeShopPlan = useShopStore((s)=>s.changeShopPlan);
|
|
36
|
-
const changeFontType = libsStore((s)=>s.changeFontType);
|
|
37
|
-
const fontType = libsStore((s)=>s.fontType);
|
|
38
34
|
const clearModal = useModalStore((s)=>s.clearModal);
|
|
39
35
|
const changeLimitCreateThemeSection = useShopStore((s)=>s.changeLimitCreateThemeSection);
|
|
40
36
|
const setInteractionIsSelectOnPage = usePageStore((s)=>s.setInteractionIsSelectOnPage);
|
|
@@ -70,12 +66,6 @@ const Toolbox = ()=>{
|
|
|
70
66
|
});
|
|
71
67
|
// append new fonts
|
|
72
68
|
for (const font of fonts){
|
|
73
|
-
if ([
|
|
74
|
-
'bunny',
|
|
75
|
-
'google'
|
|
76
|
-
].includes(font.type) && checkNotInOptionFont(font.family, fontType)) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
69
|
if (font.type !== 'custom') {
|
|
80
70
|
if (font.variants?.length) {
|
|
81
71
|
for (const variant of font.variants){
|
|
@@ -87,7 +77,7 @@ const Toolbox = ()=>{
|
|
|
87
77
|
const variantName = variant;
|
|
88
78
|
const url = createFontUrl([
|
|
89
79
|
cloneFont
|
|
90
|
-
]
|
|
80
|
+
]);
|
|
91
81
|
if (url) {
|
|
92
82
|
const googleFont = document.querySelector(`.${className}[data-font="${fontName}"][data-font-variant="${variantName}"]`);
|
|
93
83
|
if (googleFont) {
|
|
@@ -290,13 +280,6 @@ const Toolbox = ()=>{
|
|
|
290
280
|
}, [
|
|
291
281
|
changeShopPlan
|
|
292
282
|
]);
|
|
293
|
-
const onUpdateFontType = useCallback((e)=>{
|
|
294
|
-
const fontType = e.detail;
|
|
295
|
-
if (!fontType) return;
|
|
296
|
-
changeFontType(fontType);
|
|
297
|
-
}, [
|
|
298
|
-
changeFontType
|
|
299
|
-
]);
|
|
300
283
|
const onUpdateDynamicProduct = useCallback((e)=>{
|
|
301
284
|
const product = e.detail;
|
|
302
285
|
if (!product) return;
|
|
@@ -418,7 +401,6 @@ const Toolbox = ()=>{
|
|
|
418
401
|
window.addEventListener('update-interaction-item', onUpdateInteractionItem);
|
|
419
402
|
window.addEventListener('update-interaction-setting-type', onUpdateInteractionSettingType);
|
|
420
403
|
window.addEventListener('change-sidebar-mode', onChangeSidebarMode);
|
|
421
|
-
window.addEventListener('update-font-type', onUpdateFontType);
|
|
422
404
|
return ()=>{
|
|
423
405
|
window.removeEventListener('update-shop-info', onChangeShopInfo);
|
|
424
406
|
window.removeEventListener('revalidate-query', onRevalidateQuery);
|
|
@@ -442,7 +424,6 @@ const Toolbox = ()=>{
|
|
|
442
424
|
window.removeEventListener('update-interaction-is-select-on-page', onUpdateInteractionIsSelectOnPage);
|
|
443
425
|
window.removeEventListener('update-interaction-item', onUpdateInteractionItem);
|
|
444
426
|
window.removeEventListener('update-interaction-setting-type', onUpdateInteractionSettingType);
|
|
445
|
-
window.removeEventListener('update-font-type', onUpdateFontType);
|
|
446
427
|
};
|
|
447
428
|
}, [
|
|
448
429
|
onAddEntity,
|
|
@@ -468,7 +449,6 @@ const Toolbox = ()=>{
|
|
|
468
449
|
onUpdateInteractionItem,
|
|
469
450
|
onUpdateInteractionIsSelectOnPage,
|
|
470
451
|
onUpdateInteractionSettingType,
|
|
471
|
-
onUpdateFontType,
|
|
472
452
|
onChangeSidebarMode
|
|
473
453
|
]);
|
|
474
454
|
return /*#__PURE__*/ jsx("div", {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PublishedThemePagesDocument, StorePropertyDocument
|
|
1
|
+
import { PublishedThemePagesDocument, StorePropertyDocument } from '@gem-sdk/core';
|
|
2
2
|
import { ShopMetaDocument } from '@gem-sdk/adapter-shopify';
|
|
3
3
|
import { getFontStyleFromPageTemplate, getFontFromGlobalStyle } from '../google-fonts.js';
|
|
4
4
|
import { genCSS } from '../helpers/gen-css.js';
|
|
@@ -16,7 +16,7 @@ const getStaticPagePropsV2 = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
16
16
|
slug,
|
|
17
17
|
slugType: pageType
|
|
18
18
|
};
|
|
19
|
-
const [theme, storeProperty, shopifyMeta
|
|
19
|
+
const [theme, storeProperty, shopifyMeta] = await Promise.allSettled([
|
|
20
20
|
fetcher([
|
|
21
21
|
PublishedThemePagesDocument,
|
|
22
22
|
variables
|
|
@@ -26,21 +26,11 @@ const getStaticPagePropsV2 = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
26
26
|
]),
|
|
27
27
|
shopifyFetcher([
|
|
28
28
|
ShopMetaDocument
|
|
29
|
-
]),
|
|
30
|
-
fetcher([
|
|
31
|
-
PublishedShopMetasDocument,
|
|
32
|
-
{
|
|
33
|
-
keys: [
|
|
34
|
-
'source_font'
|
|
35
|
-
]
|
|
36
|
-
}
|
|
37
29
|
])
|
|
38
30
|
]);
|
|
39
31
|
if (theme.status === 'rejected') {
|
|
40
32
|
throw new Error(theme.reason?.[0]);
|
|
41
33
|
}
|
|
42
|
-
const publishedShopMetaValue = publishedShopMetas.status === 'fulfilled' ? publishedShopMetas.value : undefined;
|
|
43
|
-
const sourceFont = publishedShopMetaValue?.publishedShopMetas?.find((item)=>item?.key === 'source_font');
|
|
44
34
|
const dataBuilder = theme.value.publishedThemePages?.[0];
|
|
45
35
|
const themePageCustomFonts = theme.value?.publishedThemePages?.[0]?.themePageCustomFonts;
|
|
46
36
|
if (!dataBuilder) {
|
|
@@ -48,8 +38,8 @@ const getStaticPagePropsV2 = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
48
38
|
}
|
|
49
39
|
const pageTemplate = parseBuilderTemplateV2(dataBuilder);
|
|
50
40
|
const [elementFontStyle, fontStyle, fallback, customFonts] = await Promise.all([
|
|
51
|
-
getFontStyleFromPageTemplate(pageTemplate
|
|
52
|
-
getFontFromGlobalStyle(dataBuilder?.pageStyle?.data
|
|
41
|
+
getFontStyleFromPageTemplate(pageTemplate),
|
|
42
|
+
getFontFromGlobalStyle(dataBuilder?.pageStyle?.data),
|
|
53
43
|
getFallbackV2(fetcher, pageTemplate),
|
|
54
44
|
getCustomFonts(themePageCustomFonts)
|
|
55
45
|
]);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { checkNotInOptionFont } from './helpers/check-option-font.js';
|
|
2
1
|
import { getFontsFromDataBuilder } from './helpers/gen-fonts.js';
|
|
3
2
|
|
|
4
3
|
const CHROME_UA = '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';
|
|
@@ -34,17 +33,12 @@ const composeFonts = (fonts)=>{
|
|
|
34
33
|
};
|
|
35
34
|
});
|
|
36
35
|
};
|
|
37
|
-
const createFontUrl = (fonts, option
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
'bunny',
|
|
41
|
-
'google'
|
|
42
|
-
].includes(font.type) && checkNotInOptionFont(font.family, fontType || 'google')) && (font.type === 'google' || font.type === 'bunny' || !font.type);
|
|
43
|
-
});
|
|
44
|
-
if (!mainFonts.length) return;
|
|
36
|
+
const createFontUrl = (fonts, option)=>{
|
|
37
|
+
const googleFonts = fonts.filter((font)=>font.type === 'google' || !font.type);
|
|
38
|
+
if (!googleFonts.length) return;
|
|
45
39
|
const params = new URLSearchParams();
|
|
46
40
|
const display = option?.display || 'swap';
|
|
47
|
-
const uniqFonts =
|
|
41
|
+
const uniqFonts = googleFonts.filter((font, index, arr)=>{
|
|
48
42
|
return index === arr.findIndex((t)=>t.family === font.family);
|
|
49
43
|
});
|
|
50
44
|
const family = composeFonts(uniqFonts).map((font)=>{
|
|
@@ -58,16 +52,13 @@ const createFontUrl = (fonts, option, fontType)=>{
|
|
|
58
52
|
if (option?.effect) {
|
|
59
53
|
params.append('effect', option.effect);
|
|
60
54
|
}
|
|
61
|
-
|
|
62
|
-
const googleFontUrl = `https://fonts.googleapis.com/css?${decodeURIComponent(params.toString())}`;
|
|
63
|
-
return fontType === 'bunny' ? bunnyFontUrl : googleFontUrl;
|
|
55
|
+
return `https://fonts.googleapis.com/css?${decodeURIComponent(params.toString())}`;
|
|
64
56
|
};
|
|
65
|
-
|
|
66
|
-
async function getFonts(fonts, option, isImportFontByUrl = true, fontType) {
|
|
57
|
+
async function getFonts(fonts, option, isImportFontByUrl = true) {
|
|
67
58
|
/**
|
|
68
59
|
* The order of IE -> Chrome is important, other wise chrome starts loading woff1.
|
|
69
60
|
* CSS cascading 🤷♂️.
|
|
70
|
-
*/ const url = createFontUrl(fonts, option
|
|
61
|
+
*/ const url = createFontUrl(fonts, option);
|
|
71
62
|
if (!url) return '';
|
|
72
63
|
try {
|
|
73
64
|
if (isImportFontByUrl) return `@import url('${url}');`;
|
|
@@ -89,7 +80,7 @@ async function getFonts(fonts, option, isImportFontByUrl = true, fontType) {
|
|
|
89
80
|
return '';
|
|
90
81
|
}
|
|
91
82
|
}
|
|
92
|
-
const getFontFromGlobalStyle = (data
|
|
83
|
+
const getFontFromGlobalStyle = (data)=>{
|
|
93
84
|
if (!data) return '';
|
|
94
85
|
try {
|
|
95
86
|
const globalStyle = JSON.parse(data);
|
|
@@ -97,14 +88,14 @@ const getFontFromGlobalStyle = (data, sourceFont)=>{
|
|
|
97
88
|
const fonts = Object.entries(fontData).map(([, value])=>{
|
|
98
89
|
return value;
|
|
99
90
|
});
|
|
100
|
-
return getFonts(fonts
|
|
91
|
+
return getFonts(fonts);
|
|
101
92
|
} catch {
|
|
102
93
|
return '';
|
|
103
94
|
}
|
|
104
95
|
};
|
|
105
|
-
async function getFontStyleFromPageTemplate(pageTemplate
|
|
96
|
+
async function getFontStyleFromPageTemplate(pageTemplate) {
|
|
106
97
|
const fontStyle = pageTemplate.map((sectionData)=>{
|
|
107
|
-
return getFonts(getFontsFromDataBuilder(sectionData.data)
|
|
98
|
+
return getFonts(getFontsFromDataBuilder(sectionData.data));
|
|
108
99
|
});
|
|
109
100
|
return await Promise.all(fontStyle);
|
|
110
101
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -189,9 +189,7 @@ declare const BuilderPage: React.FC<BuilderPageProps>;
|
|
|
189
189
|
|
|
190
190
|
declare const getStaticPaths: GetStaticPaths;
|
|
191
191
|
|
|
192
|
-
type TypographyV2FontFamilyType = 'google' | 'custom' | 'theme'
|
|
193
|
-
|
|
194
|
-
type FontType = 'bunny' | 'google';
|
|
192
|
+
type TypographyV2FontFamilyType = 'google' | 'custom' | 'theme';
|
|
195
193
|
|
|
196
194
|
type FontItem = {
|
|
197
195
|
type: TypographyV2FontFamilyType;
|
|
@@ -204,8 +202,8 @@ type FontOption = {
|
|
|
204
202
|
subset?: string;
|
|
205
203
|
effect?: string;
|
|
206
204
|
};
|
|
207
|
-
declare function getFonts(fonts: FontItem[], option?: FontOption, isImportFontByUrl?: boolean
|
|
208
|
-
declare const getFontFromGlobalStyle: (data?: string
|
|
205
|
+
declare function getFonts(fonts: FontItem[], option?: FontOption, isImportFontByUrl?: boolean): Promise<string>;
|
|
206
|
+
declare const getFontFromGlobalStyle: (data?: string) => "" | Promise<string>;
|
|
209
207
|
|
|
210
208
|
declare const getFontsFromDataBuilder: (dataBuilder: Record<string, any>) => FontItem[];
|
|
211
209
|
declare const getFontFromGroupSetting: (fonts: FontItem[], groupSetting: Record<string, any>) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/pages",
|
|
3
|
-
"version": "1.57.
|
|
3
|
+
"version": "1.57.12",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"next": "latest"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@gem-sdk/core": "1.57.
|
|
30
|
-
"@gem-sdk/plugin-cookie-bar": "1.57.
|
|
31
|
-
"@gem-sdk/plugin-quick-view": "1.57.
|
|
32
|
-
"@gem-sdk/plugin-sticky-add-to-cart": "1.57.
|
|
29
|
+
"@gem-sdk/core": "1.57.12",
|
|
30
|
+
"@gem-sdk/plugin-cookie-bar": "1.57.0",
|
|
31
|
+
"@gem-sdk/plugin-quick-view": "1.57.0",
|
|
32
|
+
"@gem-sdk/plugin-sticky-add-to-cart": "1.57.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"next": ">=13"
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const listFontsNotInBunny = [
|
|
4
|
-
'Anton SC',
|
|
5
|
-
'Arsenal SC',
|
|
6
|
-
'Baskervville SC',
|
|
7
|
-
'Beiruti',
|
|
8
|
-
'Bodoni Moda SC',
|
|
9
|
-
'Bona Nova SC',
|
|
10
|
-
'Bungee Tint',
|
|
11
|
-
'Edu AU VIC WA NT Hand',
|
|
12
|
-
'Fustat',
|
|
13
|
-
'Ga Maamli',
|
|
14
|
-
'Kalnia Glaze',
|
|
15
|
-
'Maname',
|
|
16
|
-
'Matemasie',
|
|
17
|
-
'Material Icons',
|
|
18
|
-
'Material Icons Outlined',
|
|
19
|
-
'Material Icons Round',
|
|
20
|
-
'Material Icons Sharp',
|
|
21
|
-
'Material Icons Two Tone',
|
|
22
|
-
'Material Symbols Outlined',
|
|
23
|
-
'Material Symbols Rounded',
|
|
24
|
-
'Material Symbols Sharp',
|
|
25
|
-
'Moderustic',
|
|
26
|
-
'New Amsterdam',
|
|
27
|
-
'Playwrite AR',
|
|
28
|
-
'Playwrite AT',
|
|
29
|
-
'Playwrite BE VLG',
|
|
30
|
-
'Playwrite BE WAL',
|
|
31
|
-
'Playwrite CL',
|
|
32
|
-
'Playwrite CU',
|
|
33
|
-
'Playwrite CZ',
|
|
34
|
-
'Playwrite DK Loopet',
|
|
35
|
-
'Playwrite DK Uloopet',
|
|
36
|
-
'Playwrite HR',
|
|
37
|
-
'Playwrite HR Lijeva',
|
|
38
|
-
'Playwrite HU',
|
|
39
|
-
'Playwrite PE',
|
|
40
|
-
'SUSE',
|
|
41
|
-
'Sankofa Display',
|
|
42
|
-
'Wittgenstein',
|
|
43
|
-
'Zain'
|
|
44
|
-
];
|
|
45
|
-
const listFontsNotInGoogle = [
|
|
46
|
-
'Arima Madurai',
|
|
47
|
-
'Coda Caption',
|
|
48
|
-
'Fredoka One',
|
|
49
|
-
'Gentium Book Basic',
|
|
50
|
-
'Kantumruy',
|
|
51
|
-
'Merienda One',
|
|
52
|
-
'Source Sans Pro',
|
|
53
|
-
'Source Serif Pro',
|
|
54
|
-
'Briem Hand',
|
|
55
|
-
'Pushster'
|
|
56
|
-
];
|
|
57
|
-
const objectFont = {
|
|
58
|
-
bunny: listFontsNotInBunny,
|
|
59
|
-
google: listFontsNotInGoogle
|
|
60
|
-
};
|
|
61
|
-
const checkNotInOptionFont = (currentfont, type)=>{
|
|
62
|
-
return objectFont?.[type]?.includes(currentfont);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
exports.checkNotInOptionFont = checkNotInOptionFont;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
const listFontsNotInBunny = [
|
|
2
|
-
'Anton SC',
|
|
3
|
-
'Arsenal SC',
|
|
4
|
-
'Baskervville SC',
|
|
5
|
-
'Beiruti',
|
|
6
|
-
'Bodoni Moda SC',
|
|
7
|
-
'Bona Nova SC',
|
|
8
|
-
'Bungee Tint',
|
|
9
|
-
'Edu AU VIC WA NT Hand',
|
|
10
|
-
'Fustat',
|
|
11
|
-
'Ga Maamli',
|
|
12
|
-
'Kalnia Glaze',
|
|
13
|
-
'Maname',
|
|
14
|
-
'Matemasie',
|
|
15
|
-
'Material Icons',
|
|
16
|
-
'Material Icons Outlined',
|
|
17
|
-
'Material Icons Round',
|
|
18
|
-
'Material Icons Sharp',
|
|
19
|
-
'Material Icons Two Tone',
|
|
20
|
-
'Material Symbols Outlined',
|
|
21
|
-
'Material Symbols Rounded',
|
|
22
|
-
'Material Symbols Sharp',
|
|
23
|
-
'Moderustic',
|
|
24
|
-
'New Amsterdam',
|
|
25
|
-
'Playwrite AR',
|
|
26
|
-
'Playwrite AT',
|
|
27
|
-
'Playwrite BE VLG',
|
|
28
|
-
'Playwrite BE WAL',
|
|
29
|
-
'Playwrite CL',
|
|
30
|
-
'Playwrite CU',
|
|
31
|
-
'Playwrite CZ',
|
|
32
|
-
'Playwrite DK Loopet',
|
|
33
|
-
'Playwrite DK Uloopet',
|
|
34
|
-
'Playwrite HR',
|
|
35
|
-
'Playwrite HR Lijeva',
|
|
36
|
-
'Playwrite HU',
|
|
37
|
-
'Playwrite PE',
|
|
38
|
-
'SUSE',
|
|
39
|
-
'Sankofa Display',
|
|
40
|
-
'Wittgenstein',
|
|
41
|
-
'Zain'
|
|
42
|
-
];
|
|
43
|
-
const listFontsNotInGoogle = [
|
|
44
|
-
'Arima Madurai',
|
|
45
|
-
'Coda Caption',
|
|
46
|
-
'Fredoka One',
|
|
47
|
-
'Gentium Book Basic',
|
|
48
|
-
'Kantumruy',
|
|
49
|
-
'Merienda One',
|
|
50
|
-
'Source Sans Pro',
|
|
51
|
-
'Source Serif Pro',
|
|
52
|
-
'Briem Hand',
|
|
53
|
-
'Pushster'
|
|
54
|
-
];
|
|
55
|
-
const objectFont = {
|
|
56
|
-
bunny: listFontsNotInBunny,
|
|
57
|
-
google: listFontsNotInGoogle
|
|
58
|
-
};
|
|
59
|
-
const checkNotInOptionFont = (currentfont, type)=>{
|
|
60
|
-
return objectFont?.[type]?.includes(currentfont);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export { checkNotInOptionFont };
|