@useinsider/guido 3.6.0-beta.3e80683 → 3.6.0-beta.46ce04f

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 (37) hide show
  1. package/dist/composables/useHtmlValidator.js +131 -102
  2. package/dist/composables/useRecommendation.js +34 -33
  3. package/dist/config/compiler/utils/recommendationCompilerUtils.js +28 -27
  4. package/dist/config/compiler/utils/recommendationIgnoreUtils.js +15 -0
  5. package/dist/config/migrator/recommendation/extractors.js +44 -22
  6. package/dist/config/migrator/recommendation/htmlBuilder.js +175 -169
  7. package/dist/config/migrator/recommendationMigrator.js +30 -31
  8. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +21 -15
  9. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +38 -24
  10. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +57 -52
  11. package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +45 -34
  12. package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +3 -2
  13. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +62 -52
  14. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +74 -67
  15. package/dist/extensions/Blocks/Recommendation/controls/syncInfoMessage.js +7 -6
  16. package/dist/extensions/Blocks/Recommendation/extension.js +6 -5
  17. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +3 -2
  18. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +14 -9
  19. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +3 -2
  20. package/dist/extensions/Blocks/Recommendation/templates/index.js +5 -4
  21. package/dist/extensions/Blocks/Recommendation/utils/partnerCustomizations.js +21 -0
  22. package/dist/src/composables/useHtmlValidator.d.ts +9 -0
  23. package/dist/src/config/compiler/utils/recommendationIgnoreUtils.d.ts +17 -0
  24. package/dist/src/config/compiler/utils/recommendationIgnoreUtils.test.d.ts +1 -0
  25. package/dist/src/config/migrator/recommendation/extractors.d.ts +15 -0
  26. package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +8 -0
  27. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  28. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +21 -0
  29. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +7 -0
  30. package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +5 -0
  31. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +6 -0
  32. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +9 -0
  33. package/dist/src/extensions/Blocks/Recommendation/utils/partnerCustomizations.d.ts +7 -0
  34. package/dist/src/utils/templatePreparation.d.ts +0 -16
  35. package/dist/utils/templatePreparation.js +57 -58
  36. package/package.json +1 -1
  37. /package/dist/src/{utils/templatePreparation.test.d.ts → composables/useHtmlValidator.test.d.ts} +0 -0
@@ -8,4 +8,12 @@ export declare function buildBlockHtml(params: {
8
8
  extraClasses?: string;
9
9
  legacyId?: string;
10
10
  legacyBgColor?: string;
11
+ /**
12
+ * When set, the block's existing inner HTML is preserved verbatim instead
13
+ * of regenerating product rows — used for partner-customized blocks so
14
+ * their hand-authored `{{...}}` variables survive migration.
15
+ */
16
+ preserveInnerHtml?: string;
17
+ /** Adds the `ins-skip-compile` opt-out class to the migrated block. */
18
+ skipCompile?: boolean;
11
19
  }): string;
@@ -8,6 +8,6 @@
8
8
  */
9
9
  export { RecommendationBlockId } from './blockIds';
10
10
  export { RecommendationControlId } from './controlIds';
11
- export { BLOCK_ROOT_SELECTOR, CONTAINER_SELECTOR, DESKTOP_CONTAINER_SELECTOR, MOBILE_CONTAINER_SELECTOR, MOBILE_ROW_SELECTOR, CSS_CLASS_RECO_BUTTON, CURRENCY_ATTR, ATTR_PRODUCT_IMAGE, ATTR_PRODUCT_NAME, ATTR_PRODUCT_PRICE, ATTR_PRODUCT_OLD_PRICE, ATTR_PRODUCT_OMNIBUS_PRICE, ATTR_PRODUCT_OMNIBUS_DISCOUNT, ATTR_PRODUCT_BUTTON, ATTR_CUSTOM_PREFIX, ATTR_DATA_CUSTOM_ATTRIBUTES, ATTR_PRODUCT_ATTR, BUILT_IN_DEFAULT_ATTRIBUTES, } from './selectors';
11
+ export { BLOCK_ROOT_SELECTOR, CONTAINER_SELECTOR, DESKTOP_CONTAINER_SELECTOR, MOBILE_CONTAINER_SELECTOR, MOBILE_ROW_SELECTOR, CSS_CLASS_RECO_BUTTON, CSS_CLASS_SKIP_COMPILE, RECOMMENDATION_VARIABLE_BUILTIN_ATTRIBUTES, CURRENCY_ATTR, ATTR_PRODUCT_IMAGE, ATTR_PRODUCT_NAME, ATTR_PRODUCT_PRICE, ATTR_PRODUCT_OLD_PRICE, ATTR_PRODUCT_OMNIBUS_PRICE, ATTR_PRODUCT_OMNIBUS_DISCOUNT, ATTR_PRODUCT_BUTTON, ATTR_CUSTOM_PREFIX, ATTR_DATA_CUSTOM_ATTRIBUTES, ATTR_PRODUCT_ATTR, BUILT_IN_DEFAULT_ATTRIBUTES, } from './selectors';
12
12
  export { LAYOUT_VALUES, LAYOUT_OPTIONS, DEFAULT_PRODUCTS_PER_ROW, DEFAULT_CARDS_IN_ROW, DEFAULT_MOBILE_CARDS_IN_ROW, MAX_PRODUCT_COUNT, MIN_PRODUCT_COUNT, MAX_PRODUCTS_PER_ROW, MIN_PRODUCTS_PER_ROW, MAX_MOBILE_PRODUCTS_PER_ROW, MIN_MOBILE_PRODUCTS_PER_ROW, DEFAULT_COLUMN_SPACING, DEFAULT_ROW_SPACING, DEFAULT_MOBILE_COLUMN_SPACING, DEFAULT_MOBILE_ROW_SPACING, MIN_SPACING, MAX_SPACING, SPACING_STEP, } from './layout';
13
13
  export { DEFAULT_NODE_CONFIG, DEFAULT_CURRENCY, DEFAULT_COMPOSITION, DEFAULT_VISIBILITY, CURRENT_CONFIG_VERSION, EXCLUDED_ALGORITHM_IDS, } from './defaultConfig';
@@ -23,6 +23,18 @@ export declare const MOBILE_ROW_SELECTOR = ".ins-recommendation-mobile-row";
23
23
  * `{{cId_pIdx_url}}` template variable.
24
24
  */
25
25
  export declare const CSS_CLASS_RECO_BUTTON = "reco-v3-button";
26
+ /**
27
+ * Opt-out class for partners who want to inject their own template variables
28
+ * into a recommendation block. When present on `.recommendation-block-v2`,
29
+ * Guido skips ONLY its product-data → template-variable substitution
30
+ * (`replaceProductAttributes`) for that block — partners author their own
31
+ * `{{recoId_index_attribute}}` variables. Everything else (campaign URL
32
+ * building, hidden-row removal, Outlook image widths, text-trim CSS, discount
33
+ * conditions, store hydration, store-level config validation, and general HTML
34
+ * optimizations) still applies. The class is preserved in the final compiled
35
+ * output so partners may use it for their own styling.
36
+ */
37
+ export declare const CSS_CLASS_SKIP_COMPILE = "ins-skip-compile";
26
38
  /**
27
39
  * Currency HTML attributes set on the block element
28
40
  * These are read by the HTML compiler at runtime to format prices
@@ -61,3 +73,12 @@ export declare const ATTR_PRODUCT_ATTR = "product-attr";
61
73
  * Used to exclude these from the custom attribute dropdown to prevent duplication with toggles.
62
74
  */
63
75
  export declare const BUILT_IN_DEFAULT_ATTRIBUTES: Set<string>;
76
+ /**
77
+ * Attribute names valid inside a `{{recoId_index_attributeName}}` template
78
+ * variable regardless of the account's custom attribute list. Every built-in
79
+ * composition attribute is valid, plus `currency` and `discount` which the
80
+ * compiler emits but are not composition toggles. Custom attributes are
81
+ * validated separately against the account's fetched attribute list
82
+ * (`stripo/email-recommendation-attributes`).
83
+ */
84
+ export declare const RECOMMENDATION_VARIABLE_BUILTIN_ATTRIBUTES: Set<string>;
@@ -17,6 +17,13 @@ export declare class RecommendationCardCompositionControl extends CommonControl
17
17
  getId(): string;
18
18
  getTemplate(): string;
19
19
  onRender(): void;
20
+ /**
21
+ * Card composition restructures the block (toggles/reorders/adds attribute
22
+ * cells), which would corrupt a partner-managed (`ins-skip-compile`) block's
23
+ * preserved markup. There is no native tab-disable API, so the whole control
24
+ * container is rendered inert (greyed + non-interactive) instead.
25
+ */
26
+ _syncDisabledState(): void;
20
27
  onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
21
28
  onDestroy(): void;
22
29
  private _initializeComposition;
@@ -21,6 +21,11 @@ export declare class LayoutOrientationControl extends CommonControl {
21
21
  getTemplate(): string;
22
22
  onRender(): void;
23
23
  onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
24
+ /**
25
+ * Layout orientation restructures the whole block, which is meaningless for
26
+ * partner-managed (`ins-skip-compile`) blocks — disable the control there.
27
+ */
28
+ _syncDisabledState(): void;
24
29
  _setFormValues(): void;
25
30
  /**
26
31
  * Handles layout change
@@ -30,6 +30,12 @@ export declare class ProductLayoutControl extends CommonControl {
30
30
  getTemplate(): string;
31
31
  onRender(): void;
32
32
  onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
33
+ /**
34
+ * Products-per-row and mobile-layout restructure the block, which is
35
+ * meaningless for partner-managed (`ins-skip-compile`) blocks — disable
36
+ * these inputs there. Disabling coexists with the visibility logic above.
37
+ */
38
+ _syncDisabledState(): void;
33
39
  onDestroy(): void;
34
40
  _setFormValues(): void;
35
41
  /**
@@ -35,6 +35,15 @@ interface DocumentModifier {
35
35
  * @returns The block element or null if not found
36
36
  */
37
37
  export declare function getBlockElement(currentNode: ImmutableHtmlNode | null | undefined): ImmutableHtmlNode | null;
38
+ /**
39
+ * True when the recommendation block has opted out of Guido's content
40
+ * regeneration via the `ins-skip-compile` class. Partner-managed blocks carry
41
+ * hand-authored `{{...}}` variables in their cells, so Guido must never
42
+ * overwrite their content with product data (regenerate / in-place update).
43
+ * @param currentNode - The current template node
44
+ * @returns True if the block opted out of content regeneration
45
+ */
46
+ export declare function isPartnerManagedBlock(currentNode: ImmutableHtmlNode | null | undefined): boolean;
38
47
  /**
39
48
  * Gets the current layout orientation from the block's data attribute
40
49
  * Supports both old (horizontal/vertical) and new (list/grid) values for backward compatibility
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Returns the extra recommendation feed query params for an account, if any.
3
+ * Accounts without customizations get an empty object.
4
+ * @param partnerName Account subdomain (`config.partner.name`)
5
+ * @param strategy Recommendation strategy key of the block
6
+ */
7
+ export declare function getPartnerRecommendationParams(partnerName: string, strategy: string): Record<string, string>;
@@ -1,20 +1,4 @@
1
1
  import type { SavedTemplateDetails } from '@@/Types/stripo';
2
- /**
3
- * Collects every unsubscribe page id referenced by the unsubscribe blocks
4
- * present in the email HTML, deduped.
5
- *
6
- * The email's unsubscribe link is variation-scoped on the backend, which
7
- * resolves the page to render from the page ids the FE persists for that
8
- * variation. Those ids must reflect the blocks actually in the email — not a
9
- * UI-only selection store — otherwise a block that entered the editor by any
10
- * path other than the page-selection UI (e.g. a dropped saved module) sends an
11
- * empty association and the backend falls back to the default page.
12
- *
13
- * Read from raw editor HTML: the `data-unsubscribe-page-list` attribute lives
14
- * on the block node there (the save-time sync-module extractor relies on the
15
- * same source), so it is reliably present regardless of how the block was added.
16
- */
17
- export declare function getHtmlReferencedUnsubscribePages(html: string): number[];
18
2
  export declare const useTemplatePreparation: () => {
19
3
  prepareTemplateDetails: () => Promise<Omit<SavedTemplateDetails, "metadata">>;
20
4
  };
@@ -1,58 +1,58 @@
1
- import { useActionsApi as T } from "../composables/useActionsApi.js";
2
- import { useHtmlCompiler as D } from "../composables/useHtmlCompiler.js";
3
- import { DEFAULT_CURRENCY as l, DEFAULT_NODE_CONFIG as a } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
1
+ import { useActionsApi as C } from "../composables/useActionsApi.js";
2
+ import { useHtmlCompiler as T } from "../composables/useHtmlCompiler.js";
3
+ import { DEFAULT_CURRENCY as d, DEFAULT_NODE_CONFIG as s } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
4
4
  import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
5
- import { DATA_ATTRIBUTES as h } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
6
- import { parsePageList as P } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
7
- import { useDynamicContentStore as w } from "../stores/dynamic-content.js";
8
- import { useUnsubscribeStore as E } from "../stores/unsubscribe.js";
9
- function U(c) {
10
- const n = new DOMParser().parseFromString(c, "text/html").querySelectorAll(`[${h.PAGE_LIST}]`), t = [];
11
- return n.forEach((s) => {
12
- const r = s.getAttribute(h.PAGE_LIST);
13
- r && t.push(...P(r));
14
- }), [...new Set(t)];
5
+ import { DATA_ATTRIBUTES as S } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
6
+ import { parsePageList as D } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
7
+ import { useDynamicContentStore as P } from "../stores/dynamic-content.js";
8
+ import { useUnsubscribeStore as w } from "../stores/unsubscribe.js";
9
+ function E(i, o) {
10
+ const t = new DOMParser().parseFromString(i, "text/html").querySelectorAll(`[${S.PAGE_LIST}]`), c = [];
11
+ return t.forEach((r) => {
12
+ const a = r.getAttribute(S.PAGE_LIST);
13
+ a && c.push(...D(a));
14
+ }), o.filter((r) => c.includes(r));
15
15
  }
16
- async function F(c) {
17
- const i = new DOMParser().parseFromString(c, "text/html").querySelectorAll(".recommendation-block-v2");
18
- if (i.length === 0)
16
+ async function U(i) {
17
+ const m = new DOMParser().parseFromString(i, "text/html").querySelectorAll(".recommendation-block-v2");
18
+ if (m.length === 0)
19
19
  return;
20
- const n = b();
21
- i.forEach((t) => {
22
- var p, g, f, o, y;
23
- const s = t.getAttribute("recommendation-id"), r = s ? Number(s) : NaN;
20
+ const l = b();
21
+ m.forEach((t) => {
22
+ var g, f, u, n, y;
23
+ const c = t.getAttribute("recommendation-id"), r = c ? Number(c) : NaN;
24
24
  if (!Number.isFinite(r))
25
25
  return;
26
- const d = t.getAttribute("esd-ext-config");
27
- if (!d)
26
+ const a = t.getAttribute("esd-ext-config");
27
+ if (!a)
28
28
  return;
29
29
  let e;
30
30
  try {
31
- e = JSON.parse(d);
31
+ e = JSON.parse(a);
32
32
  } catch {
33
33
  return;
34
34
  }
35
35
  if (!e || typeof e != "object" || Array.isArray(e))
36
36
  return;
37
- const m = {
38
- strategy: e.strategy ?? a.strategy,
39
- language: e.language ?? a.language,
40
- size: e.size ?? a.size,
37
+ const p = {
38
+ strategy: e.strategy ?? s.strategy,
39
+ language: e.language ?? s.language,
40
+ size: e.size ?? s.size,
41
41
  // Spread the default arrays so each block gets a fresh reference
42
42
  // instead of sharing the singleton in DEFAULT_NODE_CONFIG.
43
- productIds: e.productIds ?? [...a.productIds],
44
- filters: e.filters ?? [...a.filters],
45
- shuffleProducts: e.shuffleProducts ?? a.shuffleProducts,
46
- currencyCode: ((p = e.currency) == null ? void 0 : p.code) ?? l.code,
47
- currencyAlignment: ((g = e.currency) == null ? void 0 : g.alignment) ?? l.alignment,
48
- currencyDecimalCount: ((f = e.currency) == null ? void 0 : f.decimalCount) ?? l.decimalCount,
49
- currencyDecimalSeparator: ((o = e.currency) == null ? void 0 : o.decimalSeparator) ?? l.decimalSeparator,
50
- currencyThousandSeparator: ((y = e.currency) == null ? void 0 : y.thousandSeparator) ?? l.thousandSeparator
43
+ productIds: e.productIds ?? [...s.productIds],
44
+ filters: e.filters ?? [...s.filters],
45
+ shuffleProducts: e.shuffleProducts ?? s.shuffleProducts,
46
+ currencyCode: ((g = e.currency) == null ? void 0 : g.code) ?? d.code,
47
+ currencyAlignment: ((f = e.currency) == null ? void 0 : f.alignment) ?? d.alignment,
48
+ currencyDecimalCount: ((u = e.currency) == null ? void 0 : u.decimalCount) ?? d.decimalCount,
49
+ currencyDecimalSeparator: ((n = e.currency) == null ? void 0 : n.decimalSeparator) ?? d.decimalSeparator,
50
+ currencyThousandSeparator: ((y = e.currency) == null ? void 0 : y.thousandSeparator) ?? d.thousandSeparator
51
51
  };
52
- n.seedBlockUrlConfig(r, m);
52
+ l.seedBlockUrlConfig(r, p);
53
53
  });
54
54
  try {
55
- await n.fetchRecommendationCreateData();
55
+ await l.fetchRecommendationCreateData();
56
56
  } catch (t) {
57
57
  console.warn(
58
58
  "Recommendation reference data pre-load failed; validator will skip the availability check.",
@@ -60,43 +60,42 @@ async function F(c) {
60
60
  );
61
61
  }
62
62
  }
63
- const k = () => {
64
- const c = w(), u = E(), { getCompiledEmail: i, getTemplateData: n } = T(), { compileHtml: t } = D();
63
+ const _ = () => {
64
+ const i = P(), o = w(), { getCompiledEmail: m, getTemplateData: l } = C(), { compileHtml: t } = T();
65
65
  return {
66
66
  prepareTemplateDetails: async () => {
67
- const { html: r, ampHtml: d = "", ampErrors: e = [] } = await i({
67
+ const { html: r, ampHtml: a = "", ampErrors: e = [] } = await m({
68
68
  minimize: !0,
69
69
  resetDataSavedFlag: !1
70
- }), { html: m, css: p, syncModulesIds: g = [] } = await n();
71
- u.selectedUnsubscribePages.length && await u.fetchTemplates(), await F(m);
72
- const { compiledHtml: f, stats: o, appliedRules: y } = t(r), A = c.getSelectedDynamicContentList, C = b(), S = U(m);
70
+ }), { html: p, css: g, syncModulesIds: f = [] } = await l();
71
+ o.selectedUnsubscribePages.length && await o.fetchTemplates(), await U(p);
72
+ const { compiledHtml: u, stats: n, appliedRules: y } = t(r), h = i.getSelectedDynamicContentList, A = b();
73
73
  return console.debug("HTML Compilation Stats:", {
74
- originalSize: o.originalSize,
75
- compiledSize: o.compiledSize,
76
- reduction: `${o.reductionPercentage.toFixed(2)}%`,
74
+ originalSize: n.originalSize,
75
+ compiledSize: n.compiledSize,
76
+ reduction: `${n.reductionPercentage.toFixed(2)}%`,
77
77
  appliedRules: y,
78
- executionTime: `${o.executionTime.toFixed(2)}ms`
78
+ executionTime: `${n.executionTime.toFixed(2)}ms`
79
79
  }), {
80
- dynamicContentList: A,
81
- compiledHtml: f,
82
- rawHtml: m,
83
- css: p,
84
- ampHtml: d,
80
+ dynamicContentList: h,
81
+ compiledHtml: u,
82
+ rawHtml: p,
83
+ css: g,
84
+ ampHtml: a,
85
85
  ampErrors: e,
86
- modules: g.map(Number),
86
+ modules: f.map(Number),
87
87
  recommendation: {
88
- campaignUrls: C.recommendationCampaignUrls,
88
+ campaignUrls: A.recommendationCampaignUrls,
89
89
  configs: {}
90
90
  },
91
91
  unsubscribe: {
92
- status: S.length > 0,
93
- config: S
92
+ status: o.unsubscribePagesStatus,
93
+ config: E(u, o.selectedUnsubscribePages)
94
94
  }
95
95
  };
96
96
  }
97
97
  };
98
98
  };
99
99
  export {
100
- U as getHtmlReferencedUnsubscribePages,
101
- k as useTemplatePreparation
100
+ _ as useTemplatePreparation
102
101
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.6.0-beta.3e80683",
3
+ "version": "3.6.0-beta.46ce04f",
4
4
  "description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
5
5
  "main": "./dist/guido.umd.cjs",
6
6
  "module": "./dist/library.js",