@gem-sdk/pages 1.51.0 → 1.53.0-dev.107

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.
Files changed (36) hide show
  1. package/dist/cjs/components/builder/Body.js +28 -0
  2. package/dist/cjs/components/builder/Header.js +4 -1
  3. package/dist/cjs/components/builder/InteractionSelectOnPageHeader.js +69 -0
  4. package/dist/cjs/components/builder/PopupManager.js +1 -1
  5. package/dist/cjs/components/builder/SwitchView.js +1 -0
  6. package/dist/cjs/components/builder/Toolbar.js +3 -1
  7. package/dist/cjs/components/builder/Toolbox.js +59 -2
  8. package/dist/cjs/libs/api/get-post-purchase-props-preview.js +111 -10
  9. package/dist/cjs/libs/api/get-static-page-props-preview.js +2 -1
  10. package/dist/cjs/libs/api/get-static-page-props-v2.js +15 -4
  11. package/dist/cjs/libs/google-fonts.js +20 -11
  12. package/dist/cjs/libs/helpers/check-option-font.js +65 -0
  13. package/dist/cjs/libs/helpers/normalize.js +6 -0
  14. package/dist/cjs/libs/hooks/useSelectModeInteraction.js +16 -0
  15. package/dist/cjs/pages/builder.js +4 -11
  16. package/dist/cjs/pages/static-v2.js +18 -5
  17. package/dist/cjs/store/libs-store.js +14 -0
  18. package/dist/esm/components/builder/Body.js +24 -0
  19. package/dist/esm/components/builder/Header.js +5 -2
  20. package/dist/esm/components/builder/InteractionSelectOnPageHeader.js +65 -0
  21. package/dist/esm/components/builder/PopupManager.js +1 -1
  22. package/dist/esm/components/builder/SwitchView.js +1 -0
  23. package/dist/esm/components/builder/Toolbar.js +3 -1
  24. package/dist/esm/components/builder/Toolbox.js +59 -2
  25. package/dist/esm/libs/api/get-post-purchase-props-preview.js +111 -13
  26. package/dist/esm/libs/api/get-static-page-props-preview.js +2 -1
  27. package/dist/esm/libs/api/get-static-page-props-v2.js +16 -5
  28. package/dist/esm/libs/google-fonts.js +20 -11
  29. package/dist/esm/libs/helpers/check-option-font.js +63 -0
  30. package/dist/esm/libs/helpers/normalize.js +6 -1
  31. package/dist/esm/libs/hooks/useSelectModeInteraction.js +14 -0
  32. package/dist/esm/pages/builder.js +5 -12
  33. package/dist/esm/pages/static-v2.js +18 -5
  34. package/dist/esm/store/libs-store.js +12 -0
  35. package/dist/types/index.d.ts +12 -4
  36. package/package.json +5 -5
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var react = require('react');
7
+ var core = require('@gem-sdk/core');
8
+ var CollectionGlobalProvider = require('../../pages/CollectionGlobalProvider.js');
9
+
10
+ const Body = ({ pageType, isThemeSectionEditor })=>{
11
+ const interactionData = core.usePageStore((s)=>s.interactionData);
12
+ const isInteractionSelectModeClass = react.useMemo(()=>interactionData?.isSelectOnPage ? 'interaction-select-mode' : '', [
13
+ interactionData?.isSelectOnPage
14
+ ]);
15
+ return /*#__PURE__*/ jsxRuntime.jsx("div", {
16
+ id: "storefront",
17
+ className: `${isThemeSectionEditor ? 'theme-section-editor' : ''} ${pageType === 'POST_PURCHASE' ? 'post-purchase-page' : ''} ${isInteractionSelectModeClass}`,
18
+ children: pageType === 'GP_COLLECTION' ? /*#__PURE__*/ jsxRuntime.jsx(CollectionGlobalProvider.default, {
19
+ children: /*#__PURE__*/ jsxRuntime.jsx(core.RenderPreview, {
20
+ uid: "ROOT"
21
+ })
22
+ }) : /*#__PURE__*/ jsxRuntime.jsx(core.RenderPreview, {
23
+ uid: "ROOT"
24
+ })
25
+ });
26
+ };
27
+
28
+ exports.default = Body;
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
  var core = require('@gem-sdk/core');
7
7
  var SwitchView = require('./SwitchView.js');
8
+ var InteractionSelectOnPageHeader = require('./InteractionSelectOnPageHeader.js');
8
9
 
9
10
  const defaultMargin = {
10
11
  desktop: '16px',
@@ -21,6 +22,7 @@ const sizeCheck = {
21
22
  const Header = (props)=>{
22
23
  const { pageType, isOriginTemplate } = props;
23
24
  const layoutSetting = core.useShopStore((s)=>s.layoutSettings);
25
+ const isSelectOnPage = core.usePageStore((s)=>s.interactionData?.isSelectOnPage);
24
26
  const activeHeader = layoutSetting?.showHeader || isOriginTemplate;
25
27
  const headerColor = activeHeader ? HEADER_ON_COLOR : HEADER_OFF_COLOR;
26
28
  return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
@@ -177,7 +179,8 @@ const Header = (props)=>{
177
179
  })
178
180
  ]
179
181
  })
180
- })
182
+ }),
183
+ isSelectOnPage && /*#__PURE__*/ jsxRuntime.jsx(InteractionSelectOnPageHeader.default, {})
181
184
  ]
182
185
  });
183
186
  };
@@ -0,0 +1,69 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var core = require('@gem-sdk/core');
7
+ var useSelectModeInteraction = require('../../libs/hooks/useSelectModeInteraction.js');
8
+
9
+ const InteractionSelectOnPageHeader = ()=>{
10
+ const selectType = core.usePageStore((s)=>s.interactionData?.selectType);
11
+ const setInteractionSelectType = core.usePageStore((s)=>s.setInteractionSelectType);
12
+ const { closeSelectOnPage } = core.useInteraction();
13
+ const { changeSelectMode } = useSelectModeInteraction.useSelectModeInteraction();
14
+ const handleSetInteraction = (type)=>{
15
+ setInteractionSelectType(type);
16
+ changeSelectMode(type);
17
+ };
18
+ return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
19
+ children: [
20
+ /*#__PURE__*/ jsxRuntime.jsxs("header", {
21
+ className: "gp-flex gp-justify-between gp-items-center gp-h-10 gp-fixed gp-top-0 gp-left-0 gp-w-full gp-z-100 gp-bg-[#151515] gp-text-white interaction-select-mode-header",
22
+ children: [
23
+ /*#__PURE__*/ jsxRuntime.jsx("div", {
24
+ className: "gp-ml-4 gp-text-xs gp-mt-1",
25
+ children: "Select mode enabled"
26
+ }),
27
+ /*#__PURE__*/ jsxRuntime.jsxs("section", {
28
+ className: "gp-flex gp-bg-[#151515]/[0.15] gp-items-center gp-h-full gp-rounded-b-lg gp-pt-1 gp-gap-1",
29
+ children: [
30
+ /*#__PURE__*/ jsxRuntime.jsx("button", {
31
+ onClick: ()=>handleSetInteraction('ELEMENT'),
32
+ className: `gp-h-full gp-w-[444px] gp-items-center gp-justify-center gp-bg-[#333333] gp-text-[12px] gp-leading-5 gp-font-medium gp-flex gp-rounded-t-[8px] ${selectType === 'ELEMENT' ? 'gp-bg-[#3C67FF] gp-text-[#F9F9F9]' : 'gp-text-[#AAAAAA]'}`,
33
+ children: "Choose an element on page"
34
+ }),
35
+ /*#__PURE__*/ jsxRuntime.jsx("button", {
36
+ onClick: ()=>handleSetInteraction('PAGE'),
37
+ className: `gp-h-full gp-w-[444px] gp-items-center gp-justify-center gp-bg-[#333333] gp-text-[12px] gp-leading-5 gp-font-medium gp-flex gp-rounded-t-[8px] ${selectType === 'PAGE' ? 'gp-bg-[#3C67FF] gp-text-[#F9F9F9]' : 'gp-text-[#AAAAAA]'}`,
38
+ children: "Use entire page"
39
+ })
40
+ ]
41
+ }),
42
+ /*#__PURE__*/ jsxRuntime.jsx("button", {
43
+ onClick: closeSelectOnPage,
44
+ className: "gp-h-10 gp-w-10 gp-flex gp-items-center gp-justify-center gp-rounded-bl-lg",
45
+ children: /*#__PURE__*/ jsxRuntime.jsx("svg", {
46
+ width: "12",
47
+ height: "12",
48
+ viewBox: "0 0 12 12",
49
+ fill: "none",
50
+ xmlns: "http://www.w3.org/2000/svg",
51
+ children: /*#__PURE__*/ jsxRuntime.jsx("path", {
52
+ d: "M9.96967 11.0303C10.2626 11.3232 10.7374 11.3232 11.0303 11.0303C11.3232 10.7374 11.3232 10.2626 11.0303 9.96967L7.06066 6L11.0303 2.03033C11.3232 1.73744 11.3232 1.26256 11.0303 0.96967C10.7374 0.676777 10.2626 0.676777 9.96967 0.96967L6 4.93934L2.03033 0.96967C1.73744 0.676777 1.26256 0.676777 0.96967 0.96967C0.676777 1.26256 0.676777 1.73744 0.96967 2.03033L4.93934 6L0.96967 9.96967C0.676777 10.2626 0.676777 10.7374 0.96967 11.0303C1.26256 11.3232 1.73744 11.3232 2.03033 11.0303L6 7.06066L9.96967 11.0303Z",
53
+ fill: "#F9F9F9"
54
+ })
55
+ })
56
+ })
57
+ ]
58
+ }),
59
+ /*#__PURE__*/ jsxRuntime.jsx("div", {
60
+ className: `gp-w-full gp-fixed gp-top-0 gp-left-0 gp-border-[#3C67FF] gp-mt-[40px] gp-z-[999] ${selectType === 'PAGE' ? 'gp-z-[999] gp-border-[4px] gp-bg-[#3c67ff]/[0.25]' : 'gp-border-[2px] gp-pointer-events-none'}`,
61
+ style: {
62
+ height: 'calc(100% - 40px)'
63
+ }
64
+ })
65
+ ]
66
+ });
67
+ };
68
+
69
+ exports.default = InteractionSelectOnPageHeader;
@@ -33,7 +33,7 @@ const PopupManager = ()=>{
33
33
  onSetActiveModal
34
34
  ]);
35
35
  return /*#__PURE__*/ jsxRuntime.jsx("div", {
36
- className: "gp-pointer-events-none gp-fixed gp-inset-y-0 gp-right-0 gp-z-10 gp-flex gp-w-10 gp-flex-col gp-items-center gp-justify-center gp-gap-1 gp-overflow-y-auto gp-overflow-x-hidden gp-text-sm",
36
+ className: "gp-popup-trigger-button gp-pointer-events-none gp-fixed gp-inset-y-0 gp-right-0 gp-z-10 gp-flex gp-w-10 gp-flex-col gp-items-center gp-justify-center gp-gap-1 gp-overflow-y-auto gp-overflow-x-hidden gp-text-sm",
37
37
  children: popups?.map((item)=>{
38
38
  const display = item?.advanced?.d;
39
39
  return /*#__PURE__*/ jsxRuntime.jsx("div", {
@@ -178,6 +178,7 @@ const Devices = ()=>{
178
178
  ]
179
179
  })
180
180
  });
181
+ return null;
181
182
  };
182
183
 
183
184
  exports.default = Devices;
@@ -579,12 +579,14 @@ const Toolbar = ()=>{
579
579
  if (await isElementInsideArticle()) {
580
580
  articleId = currentComponentActive.current?.articleId || '';
581
581
  }
582
+ console.log('$parent$parent', $parent);
582
583
  const event = new CustomEvent('editor:toolbar:force-active-component', {
583
584
  bubbles: true,
584
585
  detail: {
585
586
  componentUid: uid,
586
587
  productId,
587
- articleId
588
+ articleId,
589
+ elementTag: $parent.getAttribute('data-component-tag') || ''
588
590
  }
589
591
  });
590
592
  outHover($parent);
@@ -10,6 +10,8 @@ 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');
13
15
 
14
16
  const globalStyleId = 'global-style';
15
17
  const Toolbox = ()=>{
@@ -35,7 +37,13 @@ const Toolbox = ()=>{
35
37
  const changeLayoutSettings = core.useShopStore((s)=>s.changeLayoutSettings);
36
38
  const changeCreateThemeSectionCount = core.useShopStore((s)=>s.changeCreateThemeSectionCount);
37
39
  const changeShopPlan = core.useShopStore((s)=>s.changeShopPlan);
40
+ const changeFontType = libsStore.libsStore((s)=>s.changeFontType);
41
+ const fontType = libsStore.libsStore((s)=>s.fontType);
38
42
  const clearModal = core.useModalStore((s)=>s.clearModal);
43
+ const setInteractionIsSelectOnPage = core.usePageStore((s)=>s.setInteractionIsSelectOnPage);
44
+ const setInteractionItem = core.usePageStore((s)=>s.setInteractionItem);
45
+ const setInteractionSelectType = core.usePageStore((s)=>s.setInteractionSelectType);
46
+ const setInteractionSettingType = core.usePageStore((s)=>s.setInteractionSettingType);
39
47
  const fonts = react.useMemo(()=>genFonts.getFontsFromDataBuilder(state), [
40
48
  state
41
49
  ]);
@@ -64,6 +72,12 @@ const Toolbox = ()=>{
64
72
  });
65
73
  // append new fonts
66
74
  for (const font of fonts){
75
+ if ([
76
+ 'bunny',
77
+ 'google'
78
+ ].includes(font.type) && checkOptionFont.checkNotInOptionFont(font.family, fontType)) {
79
+ return;
80
+ }
67
81
  if (font.type !== 'custom') {
68
82
  if (font.variants?.length) {
69
83
  for (const variant of font.variants){
@@ -75,7 +89,7 @@ const Toolbox = ()=>{
75
89
  const variantName = variant;
76
90
  const url = googleFonts.createFontUrl([
77
91
  cloneFont
78
- ]);
92
+ ], undefined, fontType);
79
93
  if (url) {
80
94
  const googleFont = document.querySelector(`.${className}[data-font="${fontName}"][data-font-variant="${variantName}"]`);
81
95
  if (googleFont) {
@@ -278,6 +292,13 @@ const Toolbox = ()=>{
278
292
  }, [
279
293
  changeShopPlan
280
294
  ]);
295
+ const onUpdateFontType = react.useCallback((e)=>{
296
+ const fontType = e.detail;
297
+ if (!fontType) return;
298
+ changeFontType(fontType);
299
+ }, [
300
+ changeFontType
301
+ ]);
281
302
  const onUpdateDynamicProduct = react.useCallback((e)=>{
282
303
  const product = e.detail;
283
304
  if (!product) return;
@@ -329,6 +350,30 @@ const Toolbox = ()=>{
329
350
  }, [
330
351
  setSalePageProductId
331
352
  ]);
353
+ const onUpdateInteractionIsSelectOnPage = react.useCallback((e)=>{
354
+ const isSelectOnPage = e.detail.value;
355
+ const mode = e.detail.mode;
356
+ const settingType = e.detail.settingType;
357
+ setInteractionIsSelectOnPage(isSelectOnPage);
358
+ setInteractionSelectType(mode);
359
+ setInteractionSettingType(settingType);
360
+ }, [
361
+ setInteractionIsSelectOnPage,
362
+ setInteractionSelectType,
363
+ setInteractionSettingType
364
+ ]);
365
+ const onUpdateInteractionSettingType = react.useCallback((e)=>{
366
+ const settingType = e.detail.settingType;
367
+ setInteractionSettingType(settingType);
368
+ }, [
369
+ setInteractionSettingType
370
+ ]);
371
+ const onUpdateInteractionItem = react.useCallback((e)=>{
372
+ const interactionItem = e.detail;
373
+ setInteractionItem(interactionItem);
374
+ }, [
375
+ setInteractionItem
376
+ ]);
332
377
  react.useEffect(()=>{
333
378
  if (fonts) {
334
379
  setFontsToHead('google-font-element', fonts);
@@ -356,6 +401,10 @@ const Toolbox = ()=>{
356
401
  window.addEventListener('update-item-attribute', onUpdateItemAttribute);
357
402
  window.addEventListener('set-product-offer', onUpdateProductOffers);
358
403
  window.addEventListener('update-sale-page-product-id', onUpdateSalePageProductId);
404
+ window.addEventListener('update-interaction-is-select-on-page', onUpdateInteractionIsSelectOnPage);
405
+ window.addEventListener('update-interaction-item', onUpdateInteractionItem);
406
+ window.addEventListener('update-interaction-setting-type', onUpdateInteractionSettingType);
407
+ window.addEventListener('update-font-type', onUpdateFontType);
359
408
  return ()=>{
360
409
  window.removeEventListener('update-shop-info', onChangeShopInfo);
361
410
  window.removeEventListener('revalidate-query', onRevalidateQuery);
@@ -375,6 +424,10 @@ const Toolbox = ()=>{
375
424
  window.removeEventListener('update-item-attribute', onUpdateItemAttribute);
376
425
  window.removeEventListener('set-product-offer', onUpdateProductOffers);
377
426
  window.removeEventListener('update-sale-page-product-id', onUpdateSalePageProductId);
427
+ window.removeEventListener('update-interaction-is-select-on-page', onUpdateInteractionIsSelectOnPage);
428
+ window.removeEventListener('update-interaction-item', onUpdateInteractionItem);
429
+ window.removeEventListener('update-interaction-setting-type', onUpdateInteractionSettingType);
430
+ window.removeEventListener('update-font-type', onUpdateFontType);
378
431
  };
379
432
  }, [
380
433
  onAddEntity,
@@ -395,7 +448,11 @@ const Toolbox = ()=>{
395
448
  onUpdateItemName,
396
449
  onUpdateItemAttribute,
397
450
  onUpdateProductOffers,
398
- onUpdateSalePageProductId
451
+ onUpdateSalePageProductId,
452
+ onUpdateInteractionItem,
453
+ onUpdateInteractionIsSelectOnPage,
454
+ onUpdateInteractionSettingType,
455
+ onUpdateFontType
399
456
  ]);
400
457
  return /*#__PURE__*/ jsxRuntime.jsx("div", {
401
458
  className: "toolbox"
@@ -119,22 +119,120 @@ const fetchThemePageDataByTemplateID = async (data, fetcher)=>{
119
119
  productOffers: productOffers
120
120
  };
121
121
  };
122
- const getPostPurchasePropsPreview = (fetcher, librarySaleFunnelID, storeFrontFetcher)=>async (id, currentOfferID)=>{
122
+ const fetchShopLibraryPageDataByID = async (data, fetcher)=>{
123
+ const variables = {
124
+ shopLibraryPageId: data.shopLibraryPageId
125
+ };
126
+ const [theme, storeProperty, saleFunnelDiscounts] = await Promise.allSettled([
127
+ fetcher([
128
+ core.ShopLibraryPageDocument,
129
+ variables
130
+ ]),
131
+ fetcher([
132
+ core.StorePropertyDocument
133
+ ]),
134
+ fetcher([
135
+ core.SaleFunnelDiscountsDocument,
136
+ {
137
+ where: {
138
+ saleFunnelOfferID: data.currentOfferID
139
+ }
140
+ }
141
+ ])
142
+ ]);
143
+ if (theme.status === 'rejected') {
144
+ throw new Error(theme.reason?.[0]);
145
+ }
146
+ if (saleFunnelDiscounts.status === 'rejected') {
147
+ throw new Error(saleFunnelDiscounts.reason?.[0]);
148
+ }
149
+ return {
150
+ dataBuilder: theme.value.shopLibraryPage,
151
+ pageStyle: undefined,
152
+ storeProperty,
153
+ productOffers: saleFunnelDiscounts.value.saleFunnelDiscounts?.edges?.filter((item)=>item?.node?.objectType === 'PRODUCT' && item?.node?.type === 'ORDER_VALUE') || []
154
+ };
155
+ };
156
+ const fetchLibraryTemplateDataByID = async (data, fetcher)=>{
157
+ const variables = {
158
+ libraryTemplateId: data.libraryTemplateId
159
+ };
160
+ const [theme, storeProperty, saleFunnelDiscounts] = await Promise.allSettled([
161
+ fetcher([
162
+ core.LibraryTemplateDocument,
163
+ variables
164
+ ]),
165
+ fetcher([
166
+ core.StorePropertyDocument
167
+ ]),
168
+ fetcher([
169
+ core.SaleFunnelDiscountsDocument,
170
+ {
171
+ where: {
172
+ saleFunnelOfferID: data.currentOfferID
173
+ }
174
+ }
175
+ ])
176
+ ]);
177
+ if (theme.status === 'rejected') {
178
+ throw new Error(theme.reason?.[0]);
179
+ }
180
+ if (saleFunnelDiscounts.status === 'rejected') {
181
+ throw new Error(saleFunnelDiscounts.reason?.[0]);
182
+ }
183
+ return {
184
+ dataBuilder: theme.value.libraryTemplate,
185
+ pageStyle: undefined,
186
+ storeProperty,
187
+ productOffers: saleFunnelDiscounts.value.saleFunnelDiscounts?.edges?.filter((item)=>item?.node?.objectType === 'PRODUCT' && item?.node?.type === 'ORDER_VALUE') || []
188
+ };
189
+ };
190
+ const getRelevantPageData = async (data)=>{
191
+ const { id, currentOfferID, fetcher, isLibraryTemplate, librarySaleFunnelID, isShopLibraryPage } = data;
192
+ if (librarySaleFunnelID) {
193
+ return await fetchThemePageDataByTemplateID({
194
+ libraryTemplateId: id,
195
+ currentOfferID,
196
+ librarySaleFunnelID
197
+ }, fetcher);
198
+ }
199
+ if (isShopLibraryPage && currentOfferID) {
200
+ return await fetchShopLibraryPageDataByID({
201
+ shopLibraryPageId: id,
202
+ currentOfferID
203
+ }, fetcher);
204
+ }
205
+ if (isLibraryTemplate && currentOfferID) {
206
+ return await fetchLibraryTemplateDataByID({
207
+ libraryTemplateId: id,
208
+ currentOfferID
209
+ }, fetcher);
210
+ }
211
+ if (currentOfferID) {
212
+ return await fetchPostPurchasePageDataByID({
213
+ themePageId: id,
214
+ currentOfferID
215
+ }, fetcher);
216
+ }
217
+ return await fetchSalePageDataByID({
218
+ themePageId: id
219
+ }, fetcher);
220
+ };
221
+ const getPostPurchasePropsPreview = (fetcher, librarySaleFunnelID, storeFrontFetcher)=>async (data)=>{
123
222
  try {
124
- const { dataBuilder, storeProperty, productOffers, pageStyle } = librarySaleFunnelID ? await fetchThemePageDataByTemplateID({
125
- libraryTemplateId: id,
223
+ const { id, currentOfferID, isLibraryTemplate, isShopLibraryPage } = data;
224
+ const { dataBuilder, storeProperty, productOffers, pageStyle } = await getRelevantPageData({
225
+ id,
126
226
  currentOfferID,
227
+ fetcher,
228
+ isLibraryTemplate,
229
+ isShopLibraryPage,
127
230
  librarySaleFunnelID
128
- }, fetcher) : currentOfferID ? await fetchPostPurchasePageDataByID({
129
- themePageId: id,
130
- currentOfferID
131
- }, fetcher) : await fetchSalePageDataByID({
132
- themePageId: id
133
- }, fetcher);
231
+ });
134
232
  if (!dataBuilder) {
135
233
  throw new Error(`No data builder found for slug: /preview/${id}`);
136
234
  }
137
- const pageTemplate = librarySaleFunnelID ? normalize.parseBuilderLibraryTemplate(dataBuilder) : normalize.parseBuilderTemplateV2(dataBuilder);
235
+ const pageTemplate = librarySaleFunnelID || isLibraryTemplate && currentOfferID ? normalize.parseBuilderLibraryTemplate(dataBuilder) : isShopLibraryPage ? normalize.parseShopLibraryPageTemplate(dataBuilder) : normalize.parseBuilderTemplateV2(dataBuilder);
138
236
  const gemPagesStoreFrontFetcher = storeFrontFetcher || fetcher;
139
237
  const [elementFontStyle, fontStyle, fallback] = await Promise.all([
140
238
  googleFonts.getFontStyleFromPageTemplate(pageTemplate),
@@ -160,7 +258,10 @@ const getPostPurchasePropsPreview = (fetcher, librarySaleFunnelID, storeFrontFet
160
258
  }
161
259
  };
162
260
 
261
+ exports.fetchLibraryTemplateDataByID = fetchLibraryTemplateDataByID;
163
262
  exports.fetchPostPurchasePageDataByID = fetchPostPurchasePageDataByID;
164
263
  exports.fetchSalePageDataByID = fetchSalePageDataByID;
264
+ exports.fetchShopLibraryPageDataByID = fetchShopLibraryPageDataByID;
165
265
  exports.fetchThemePageDataByTemplateID = fetchThemePageDataByTemplateID;
166
266
  exports.getPostPurchasePropsPreview = getPostPurchasePropsPreview;
267
+ exports.getRelevantPageData = getRelevantPageData;
@@ -139,7 +139,8 @@ const getStaticPagePropsPreview = (fetcher, shopifyFetcher)=>async (slug)=>{
139
139
  facebookPixelId: dataBuilder.themePageAnalytic?.fbPixelID ?? null,
140
140
  tiktokPixelId: dataBuilder.themePageAnalytic?.tiktokPixelID ?? null,
141
141
  customCodeHeader: dataBuilder.themePageCustomCode?.header ?? null,
142
- customCodeBody: dataBuilder.themePageCustomCode?.body ?? null
142
+ customCodeBody: dataBuilder.themePageCustomCode?.body ?? null,
143
+ interaction: dataBuilder?.interaction
143
144
  });
144
145
  } catch (err) {
145
146
  nextjs.captureException(err);
@@ -18,7 +18,7 @@ const getStaticPagePropsV2 = (fetcher, shopifyFetcher)=>async (slug)=>{
18
18
  slug,
19
19
  slugType: pageType
20
20
  };
21
- const [theme, storeProperty, shopifyMeta] = await Promise.allSettled([
21
+ const [theme, storeProperty, shopifyMeta, publishedShopMetas] = await Promise.allSettled([
22
22
  fetcher([
23
23
  core.PublishedThemePagesDocument,
24
24
  variables
@@ -28,11 +28,21 @@ 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
+ }
31
39
  ])
32
40
  ]);
33
41
  if (theme.status === 'rejected') {
34
42
  throw new Error(theme.reason?.[0]);
35
43
  }
44
+ const publishedShopMetaValue = publishedShopMetas.status === 'fulfilled' ? publishedShopMetas.value : undefined;
45
+ const sourceFont = publishedShopMetaValue?.publishedShopMetas?.find((item)=>item?.key === 'source_font');
36
46
  const dataBuilder = theme.value.publishedThemePages?.[0];
37
47
  const themePageCustomFonts = theme.value?.publishedThemePages?.[0]?.themePageCustomFonts;
38
48
  if (!dataBuilder) {
@@ -40,8 +50,8 @@ const getStaticPagePropsV2 = (fetcher, shopifyFetcher)=>async (slug)=>{
40
50
  }
41
51
  const pageTemplate = normalize.parseBuilderTemplateV2(dataBuilder);
42
52
  const [elementFontStyle, fontStyle, fallback, customFonts$1] = await Promise.all([
43
- googleFonts.getFontStyleFromPageTemplate(pageTemplate),
44
- googleFonts.getFontFromGlobalStyle(dataBuilder?.pageStyle?.data),
53
+ googleFonts.getFontStyleFromPageTemplate(pageTemplate, sourceFont?.value),
54
+ googleFonts.getFontFromGlobalStyle(dataBuilder?.pageStyle?.data, sourceFont?.value),
45
55
  getFallback.getFallbackV2(fetcher, pageTemplate),
46
56
  customFonts.getCustomFonts(themePageCustomFonts)
47
57
  ]);
@@ -141,7 +151,8 @@ const getStaticPagePropsV2 = (fetcher, shopifyFetcher)=>async (slug)=>{
141
151
  customCodeHeader: dataBuilder.themePageCustomCode?.header ?? null,
142
152
  customCodeBody: dataBuilder.themePageCustomCode?.body ?? null,
143
153
  pageHandle: dataBuilder.handle ?? null,
144
- customFonts: customFonts$1
154
+ customFonts: customFonts$1,
155
+ interaction: dataBuilder?.interaction
145
156
  });
146
157
  } catch (err) {
147
158
  nextjs.captureException(err);
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var checkOptionFont = require('./helpers/check-option-font.js');
3
4
  var genFonts = require('./helpers/gen-fonts.js');
4
5
 
5
6
  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';
@@ -35,12 +36,17 @@ const composeFonts = (fonts)=>{
35
36
  };
36
37
  });
37
38
  };
38
- const createFontUrl = (fonts, option)=>{
39
- const googleFonts = fonts.filter((font)=>font.type === 'google' || !font.type);
40
- if (!googleFonts.length) return;
39
+ const createFontUrl = (fonts, option, fontType)=>{
40
+ const mainFonts = fonts.filter((font)=>{
41
+ return !([
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;
41
47
  const params = new URLSearchParams();
42
48
  const display = option?.display || 'swap';
43
- const uniqFonts = googleFonts.filter((font, index, arr)=>{
49
+ const uniqFonts = mainFonts.filter((font, index, arr)=>{
44
50
  return index === arr.findIndex((t)=>t.family === font.family);
45
51
  });
46
52
  const family = composeFonts(uniqFonts).map((font)=>{
@@ -54,13 +60,16 @@ const createFontUrl = (fonts, option)=>{
54
60
  if (option?.effect) {
55
61
  params.append('effect', option.effect);
56
62
  }
57
- return `https://fonts.googleapis.com/css?${decodeURIComponent(params.toString())}`;
63
+ const bunnyFontUrl = `https://fonts.bunny.net/css?family=${family}`;
64
+ const googleFontUrl = `https://fonts.googleapis.com/css?${decodeURIComponent(params.toString())}`;
65
+ return fontType === 'bunny' ? bunnyFontUrl : googleFontUrl;
58
66
  };
59
- async function getFonts(fonts, option, isImportFontByUrl = true) {
67
+ // eslint-disable-next-line max-params
68
+ async function getFonts(fonts, option, isImportFontByUrl = true, fontType) {
60
69
  /**
61
70
  * The order of IE -> Chrome is important, other wise chrome starts loading woff1.
62
71
  * CSS cascading 🤷‍♂️.
63
- */ const url = createFontUrl(fonts, option);
72
+ */ const url = createFontUrl(fonts, option, fontType);
64
73
  if (!url) return '';
65
74
  try {
66
75
  if (isImportFontByUrl) return `@import url('${url}');`;
@@ -82,7 +91,7 @@ async function getFonts(fonts, option, isImportFontByUrl = true) {
82
91
  return '';
83
92
  }
84
93
  }
85
- const getFontFromGlobalStyle = (data)=>{
94
+ const getFontFromGlobalStyle = (data, sourceFont)=>{
86
95
  if (!data) return '';
87
96
  try {
88
97
  const globalStyle = JSON.parse(data);
@@ -90,14 +99,14 @@ const getFontFromGlobalStyle = (data)=>{
90
99
  const fonts = Object.entries(fontData).map(([, value])=>{
91
100
  return value;
92
101
  });
93
- return getFonts(fonts);
102
+ return getFonts(fonts, undefined, undefined, sourceFont);
94
103
  } catch {
95
104
  return '';
96
105
  }
97
106
  };
98
- async function getFontStyleFromPageTemplate(pageTemplate) {
107
+ async function getFontStyleFromPageTemplate(pageTemplate, sourceFont) {
99
108
  const fontStyle = pageTemplate.map((sectionData)=>{
100
- return getFonts(genFonts.getFontsFromDataBuilder(sectionData.data));
109
+ return getFonts(genFonts.getFontsFromDataBuilder(sectionData.data), undefined, undefined, sourceFont);
101
110
  });
102
111
  return await Promise.all(fontStyle);
103
112
  }
@@ -0,0 +1,65 @@
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;
@@ -88,9 +88,15 @@ const parseBuilderLibraryTemplate = (data)=>{
88
88
  ...data?.sections ?? []
89
89
  ], data?.sectionPosition);
90
90
  };
91
+ const parseShopLibraryPageTemplate = (data)=>{
92
+ return normalizePageSectionResponseV2([
93
+ ...data?.shopLibrarySections ?? []
94
+ ], data?.sectionPosition);
95
+ };
91
96
 
92
97
  exports.normalizeBuilderData = normalizeBuilderData;
93
98
  exports.normalizePageSectionResponseV2 = normalizePageSectionResponseV2;
94
99
  exports.parseBuilderLibraryTemplate = parseBuilderLibraryTemplate;
95
100
  exports.parseBuilderTemplate = parseBuilderTemplate;
96
101
  exports.parseBuilderTemplateV2 = parseBuilderTemplateV2;
102
+ exports.parseShopLibraryPageTemplate = parseShopLibraryPageTemplate;
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ const useSelectModeInteraction = ()=>{
4
+ const changeSelectMode = (mode)=>{
5
+ const event = new CustomEvent('editor:interaction:change-select-mode', {
6
+ bubbles: true,
7
+ detail: mode
8
+ });
9
+ window.dispatchEvent(event);
10
+ };
11
+ return {
12
+ changeSelectMode
13
+ };
14
+ };
15
+
16
+ exports.useSelectModeInteraction = useSelectModeInteraction;