@designcrowd/library.brand-page 5.15.12 → 5.15.13

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 (42) hide show
  1. package/lib/src/{CreatedOnBrandCrowd-de-de-DFKc_so0.js → CreatedOnBrandCrowd-de-de-C5FXWLML.js} +1 -1
  2. package/lib/src/{CreatedOnBrandCrowd-en-us-40QRcYUX.js → CreatedOnBrandCrowd-en-us-G_4dcPih.js} +1 -1
  3. package/lib/src/{CreatedOnBrandCrowd-es-es-DMfH3fRr.js → CreatedOnBrandCrowd-es-es-BRncVaEZ.js} +1 -1
  4. package/lib/src/{CreatedOnBrandCrowd-fr-fr-DbNQrijo.js → CreatedOnBrandCrowd-fr-ca-DPFhUq3i.js} +1 -1
  5. package/lib/src/{CreatedOnBrandCrowd-fr-ca-DbNQrijo.js → CreatedOnBrandCrowd-fr-fr-DPFhUq3i.js} +1 -1
  6. package/lib/src/{CreatedOnBrandCrowd-pt-pt-V3Xcyi3r.js → CreatedOnBrandCrowd-pt-br-DKWkP6IS.js} +1 -1
  7. package/lib/src/{CreatedOnBrandCrowd-pt-br-V3Xcyi3r.js → CreatedOnBrandCrowd-pt-pt-DKWkP6IS.js} +1 -1
  8. package/lib/src/{CreatedOnDcom-de-de-DpegN5_e.js → CreatedOnDcom-de-de-CMMOIPW8.js} +1 -1
  9. package/lib/src/{CreatedOnDcom-en-us-ByiQFMkC.js → CreatedOnDcom-en-us-DS6QmZZJ.js} +1 -1
  10. package/lib/src/{CreatedOnDcom-es-es-5eBXXPKs.js → CreatedOnDcom-es-es-DjUY-mfY.js} +1 -1
  11. package/lib/src/{CreatedOnDcom-fr-ca-DRMV4ACI.js → CreatedOnDcom-fr-ca-DX8LU2Yu.js} +1 -1
  12. package/lib/src/{CreatedOnDcom-fr-fr-CQrrHapF.js → CreatedOnDcom-fr-fr-BDLSIYqq.js} +1 -1
  13. package/lib/src/{CreatedOnDcom-pt-br-8bqzVFM8.js → CreatedOnDcom-pt-br-Bcp-qwUZ.js} +1 -1
  14. package/lib/src/{CreatedOnDcom-pt-pt-Dgv_C7cs.js → CreatedOnDcom-pt-pt-DtolTWh9.js} +1 -1
  15. package/lib/src/brand-page/utils/logo.util.d.ts +19 -0
  16. package/lib/src/brand-page/utils/logo.util.js +79 -1
  17. package/lib/src/brand-page/utils/migration/migration-07.js +7 -17
  18. package/lib/src/brand-page/utils/migration/migration-08.d.ts +5 -0
  19. package/lib/src/brand-page/utils/migration/migration-08.js +71 -0
  20. package/lib/src/brand-page/utils/migration.util.js +6 -0
  21. package/lib/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.js +6 -2
  22. package/lib/src/clients/fabric-render-client.js +1 -1
  23. package/lib/src/css/library.brand-page-brandCrowd.min.css +2 -2
  24. package/lib/src/css/library.brand-page-brandPage.min.css +2 -2
  25. package/lib/src/css/library.brand-page-designCom.min.css +2 -2
  26. package/lib/src/css/library.brand-page-preview.min.css +2 -2
  27. package/lib/src/index.d.ts +1 -1
  28. package/lib/src/index.mjs +53 -52
  29. package/lib/src/{lib-CF7FYBeS.js → lib-B3L785Hu.js} +11279 -11170
  30. package/lib/src/lib.js +1 -1
  31. package/package.json +1 -1
  32. package/src/brand-page/components/logo/LogoRender.vue +2 -1
  33. package/src/brand-page/utils/__snapshots__/migration.util.test.ts.snap +3 -3
  34. package/src/brand-page/utils/logo.util.ts +130 -1
  35. package/src/brand-page/utils/migration/migration-07.test.ts +2 -0
  36. package/src/brand-page/utils/migration/migration-07.ts +8 -25
  37. package/src/brand-page/utils/migration/migration-08.test.ts +398 -0
  38. package/src/brand-page/utils/migration/migration-08.ts +118 -0
  39. package/src/brand-page/utils/migration.util.ts +6 -0
  40. package/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.ts +11 -2
  41. package/src/clients/fabric-render-client.ts +1 -1
  42. package/src/lib.ts +4 -1
@@ -0,0 +1,118 @@
1
+ import {
2
+ DEFAULT_LOGO_HEIGHT,
3
+ DEFAULT_LOGO_WIDTH,
4
+ BRAND_PAGE_TYPES,
5
+ } from '../..';
6
+ import { FabricRenderClient } from '../../../clients/fabric-render-client';
7
+ import type { MigrationData } from '../migration.util';
8
+ import { isLogoContent } from '../model.util';
9
+ import type { LogoContent } from '../../models/logo.model';
10
+ import {
11
+ calculateLogoDimensions,
12
+ safeGetLogoImageFromLogoImageUrl,
13
+ } from '../logo.util';
14
+
15
+ export const migration08 = async (
16
+ migrationResult: MigrationData,
17
+ options: {
18
+ isServerRender: boolean;
19
+ isUserDraft?: boolean;
20
+ },
21
+ ): Promise<MigrationData> => {
22
+ const { brandPageModel } = migrationResult;
23
+
24
+ if (
25
+ brandPageModel.brandPageType !== BRAND_PAGE_TYPES.default &&
26
+ brandPageModel.brandPageType !== BRAND_PAGE_TYPES.brandContact
27
+ ) {
28
+ return migrationResult;
29
+ }
30
+
31
+ if (options.isUserDraft !== undefined && !options.isUserDraft) {
32
+ return migrationResult;
33
+ }
34
+
35
+ if (options.isServerRender !== undefined && options.isServerRender) {
36
+ migrationResult.useOldLogoRenderSize = true;
37
+
38
+ return migrationResult;
39
+ }
40
+
41
+ try {
42
+ const fabricClient = FabricRenderClient.getInstance();
43
+
44
+ const logoContents: {
45
+ content: LogoContent;
46
+ pageIndex: number;
47
+ contentIndex: number;
48
+ }[] = [];
49
+
50
+ brandPageModel.pages.forEach((page, pageIndex) => {
51
+ page.contents.forEach((content, contentIndex) => {
52
+ if (isLogoContent(content)) {
53
+ logoContents.push({ content, pageIndex, contentIndex });
54
+ }
55
+ });
56
+ });
57
+
58
+ const logoDataPromises = logoContents.map(async ({ content }) => {
59
+ if (content.logoTemplateImage?.logoTemplateToken) {
60
+ const logoData =
61
+ await fabricClient.getLogoSvgUrlByLogoTemplateImageAsync(
62
+ content.logoTemplateImage,
63
+ );
64
+
65
+ return { content, logoData };
66
+ }
67
+
68
+ if (content.logoImage?.logoDraftToken) {
69
+ const logoData = await fabricClient.getLogoSvgUrlByLogoImageAsync({
70
+ logoDraftToken: content.logoImage.logoDraftToken,
71
+ logoVariation: content.logoImage.logoVariation,
72
+ });
73
+
74
+ return { content, logoData };
75
+ }
76
+
77
+ return { content, logoData: null };
78
+ });
79
+
80
+ const results = await Promise.all(logoDataPromises);
81
+
82
+ // Apply dimensions to each logo content
83
+ results.forEach(({ content, logoData }) => {
84
+ if (logoData && logoData.width && logoData.height) {
85
+ const currentMaxWidth = content.logoImageWidth || DEFAULT_LOGO_WIDTH;
86
+ const currentMaxHeight = content.logoImageHeight || DEFAULT_LOGO_HEIGHT;
87
+
88
+ const dimensions = calculateLogoDimensions(
89
+ logoData,
90
+ currentMaxWidth,
91
+ currentMaxHeight,
92
+ );
93
+
94
+ content.logoImageHeight = dimensions.height;
95
+ content.logoImageWidth = dimensions.width;
96
+ }
97
+ // else if (!logoData) {
98
+ // // Fallback logic when no logo data is available
99
+ // const currentMaxHeight = content.logoImageHeight || DEFAULT_LOGO_HEIGHT;
100
+ // const heightValue = parseFloat(currentMaxHeight);
101
+ // const newHeight =
102
+ // heightValue >= 7
103
+ // ? Math.round(heightValue * 0.7)
104
+ // : Math.round(heightValue * 0.8);
105
+
106
+ // content.logoImageHeight = `${newHeight}rem`;
107
+ // content.logoImageWidth = `${newHeight}rem`;
108
+ // }
109
+ });
110
+ } catch (error) {
111
+ console.warn('Migration 08: Failed to fetch logo dimensions:', error);
112
+ migrationResult.useOldLogoRenderSize = true;
113
+
114
+ return migrationResult;
115
+ }
116
+
117
+ return migrationResult;
118
+ };
@@ -10,6 +10,7 @@ import { migration06 } from './migration/migration-06';
10
10
  import { migration05_1 } from './migration/migration-05_1';
11
11
  import { migration05_2 } from './migration/migration-05_2';
12
12
  import { migration07 } from './migration/migration-07';
13
+ import { migration08 } from './migration/migration-08';
13
14
  export interface MigrationData {
14
15
  brandPageModel: BrandPageModel;
15
16
  useOldLogoRenderSize: boolean;
@@ -83,6 +84,11 @@ const MIGRATION_TABLE = [
83
84
  description:
84
85
  'Migrating logo render sizes for logo content, header and footer sections',
85
86
  },
87
+ {
88
+ version: 8,
89
+ migrateFn: migration08,
90
+ description: 'Migrating logo content sizes for brandPage and brandContact',
91
+ },
86
92
  ] as MigrationTableItem[];
87
93
 
88
94
  export const GetLatestModelVersion = () =>
@@ -91,6 +91,7 @@ import { getAiContentIndexByTemplateTokenAndNumberOfVariations } from '../../uti
91
91
  import {
92
92
  applyLogoTemplateImageToBrandPageTemplateModel,
93
93
  getOptimalLogoSize,
94
+ recalculateLogoContentDimensions,
94
95
  } from '../../../brand-page/utils/logo.util';
95
96
  import type { ShopConfigData } from '../../../brand-page/models/shop.model';
96
97
  import { FabricRenderClient } from '../../../clients/fabric-render-client';
@@ -816,6 +817,8 @@ export const useBrandPageMakerStore = defineStore('brandPageMaker', {
816
817
  });
817
818
  }
818
819
 
820
+ const pageSettingsStore = useUiPageSettingsStore();
821
+
819
822
  if (brandPageContainerStore.isPrePurchase) {
820
823
  await editableLogoStore.setStateAsync({
821
824
  defaultPrimaryText: businessName,
@@ -844,8 +847,6 @@ export const useBrandPageMakerStore = defineStore('brandPageMaker', {
844
847
  });
845
848
  }
846
849
 
847
- const pageSettingsStore = useUiPageSettingsStore();
848
-
849
850
  if (
850
851
  !brandPageContainerStore.designDraftToken &&
851
852
  !userStore.isAdmin &&
@@ -883,6 +884,14 @@ export const useBrandPageMakerStore = defineStore('brandPageMaker', {
883
884
  VIEWPORTS.desktop
884
885
  ].logoImageHeight = newLogoSize;
885
886
  }
887
+ } else if (
888
+ this.isBrandPageOrIsBrandContact &&
889
+ brandPageContainerStore.isPrePurchase
890
+ ) {
891
+ recalculateLogoContentDimensions(
892
+ pageSettingsStore,
893
+ editableLogoStore.editableLogoVariations,
894
+ );
886
895
  }
887
896
 
888
897
  const backgroundStyles = new BackgroundStyles(
@@ -120,7 +120,7 @@ export class FabricRenderClient {
120
120
  },
121
121
  outputFormat: LogoOutputFormat = 'base64svgjson',
122
122
  ) {
123
- return `${this.baseUrl}/asset/logotemplate/brand-page/${logoTemplateImage.logoTemplateToken}?dimensionsType=preview_image_transparent_no_buffer&outputFormat=${outputFormat}&logoTemplateVersion=${logoTemplateImage.logoTemplateVersion}&text=${encodeURIComponent(logoTemplateImage.logoTemplateText)}`;
123
+ return `${this.baseUrl}/asset/logotemplate/brand-page/${logoTemplateImage.logoTemplateToken}?dimensionsType=preview_image_transparent_no_buffer&outputFormat=${outputFormat}&logoTemplateVersion=${logoTemplateImage.logoTemplateVersion}&text=${encodeURIComponent(logoTemplateImage.logoTemplateText)}&applyAutoLayout=true`;
124
124
  }
125
125
 
126
126
  public getLogoVariationUrlByLogoVariationIndex(
package/src/lib.ts CHANGED
@@ -57,7 +57,10 @@ export {
57
57
  } from './brand-page/utils';
58
58
  export * as brandPageUtils from './brand-page/utils';
59
59
  export type { CriticalResourceURLs } from './brand-page/utils/view-model.util';
60
- export { getOptimalLogoSize } from './brand-page/utils/logo.util';
60
+ export {
61
+ getOptimalLogoSize,
62
+ calculateOptimizedLogoDimensions,
63
+ } from './brand-page/utils/logo.util';
61
64
  export { sanitizeRTEHtml } from './brand-page-maker/utils';
62
65
  export { getPageSlugFromPageTitle } from './brand-page-maker/utils/slug.util';
63
66