@useinsider/guido 3.24.0-beta.88c24c1 → 3.24.0-beta.8e9f4e2

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 (39) hide show
  1. package/README.md +6 -2
  2. package/dist/@types/config/schemas.js +9 -11
  3. package/dist/components/Guido.vue.js +1 -1
  4. package/dist/components/Guido.vue2.js +1 -1
  5. package/dist/composables/useActionsApi.js +2 -2
  6. package/dist/composables/useEditorTrackingIds.js +49 -0
  7. package/dist/composables/useHtmlCompiler.js +2 -0
  8. package/dist/composables/useSave.js +52 -57
  9. package/dist/composables/useSaveValidation.js +110 -118
  10. package/dist/composables/useStripo.js +70 -70
  11. package/dist/composables/validators/useUnsubscribeBlockValidator.js +33 -48
  12. package/dist/config/compiler/htmlCompilerRules.js +14 -6
  13. package/dist/config/migrator/recommendation/inferLegacyConfig.js +133 -0
  14. package/dist/config/migrator/recommendationMigrator.js +69 -63
  15. package/dist/enums/save-validation.js +1 -1
  16. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +10 -8
  17. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +28 -24
  18. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +23 -22
  19. package/dist/guido.css +1 -1
  20. package/dist/package.json.js +4 -4
  21. package/dist/services/templateLibraryApi.js +39 -36
  22. package/dist/src/@types/config/schemas.d.ts +0 -4
  23. package/dist/src/composables/useConfig.d.ts +0 -2
  24. package/dist/src/composables/useEditorTrackingIds.d.ts +7 -0
  25. package/dist/src/composables/useSaveValidation.d.ts +1 -1
  26. package/dist/src/composables/useStripo.d.ts +1 -1
  27. package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +0 -4
  28. package/dist/src/config/migrator/recommendation/inferLegacyConfig.d.ts +6 -0
  29. package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +1 -1
  30. package/dist/src/config/migrator/recommendationMigrator.d.ts +1 -5
  31. package/dist/src/enums/save-validation.d.ts +1 -2
  32. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
  33. package/dist/src/stores/config.d.ts +0 -20
  34. package/dist/src/utils/linkTrackingIds.d.ts +19 -0
  35. package/dist/src/utils/trimHrefWhitespace.d.ts +5 -0
  36. package/dist/utils/linkTrackingIds.js +82 -48
  37. package/dist/utils/templatePreparation.js +30 -33
  38. package/dist/utils/trimHrefWhitespace.js +10 -0
  39. package/package.json +1 -1
@@ -110,7 +110,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
110
110
  linkTrackingIds: boolean;
111
111
  allowSaveWithErrors: boolean;
112
112
  reusableRecommendationStrategy: boolean;
113
- blockUnsubscribeLinks: boolean;
114
113
  };
115
114
  blocks: {
116
115
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -257,7 +256,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
257
256
  linkTrackingIds: boolean;
258
257
  allowSaveWithErrors: boolean;
259
258
  reusableRecommendationStrategy: boolean;
260
- blockUnsubscribeLinks: boolean;
261
259
  };
262
260
  blocks: {
263
261
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -404,7 +402,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
404
402
  linkTrackingIds: boolean;
405
403
  allowSaveWithErrors: boolean;
406
404
  reusableRecommendationStrategy: boolean;
407
- blockUnsubscribeLinks: boolean;
408
405
  };
409
406
  blocks: {
410
407
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -551,7 +548,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
551
548
  linkTrackingIds: boolean;
552
549
  allowSaveWithErrors: boolean;
553
550
  reusableRecommendationStrategy: boolean;
554
- blockUnsubscribeLinks: boolean;
555
551
  };
556
552
  blocks: {
557
553
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -698,7 +694,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
698
694
  linkTrackingIds: boolean;
699
695
  allowSaveWithErrors: boolean;
700
696
  reusableRecommendationStrategy: boolean;
701
- blockUnsubscribeLinks: boolean;
702
697
  };
703
698
  blocks: {
704
699
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -845,7 +840,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
845
840
  linkTrackingIds: boolean;
846
841
  allowSaveWithErrors: boolean;
847
842
  reusableRecommendationStrategy: boolean;
848
- blockUnsubscribeLinks: boolean;
849
843
  };
850
844
  blocks: {
851
845
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -992,7 +986,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
992
986
  linkTrackingIds: boolean;
993
987
  allowSaveWithErrors: boolean;
994
988
  reusableRecommendationStrategy: boolean;
995
- blockUnsubscribeLinks: boolean;
996
989
  };
997
990
  blocks: {
998
991
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -1139,7 +1132,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1139
1132
  linkTrackingIds: boolean;
1140
1133
  allowSaveWithErrors: boolean;
1141
1134
  reusableRecommendationStrategy: boolean;
1142
- blockUnsubscribeLinks: boolean;
1143
1135
  };
1144
1136
  blocks: {
1145
1137
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -1286,7 +1278,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1286
1278
  linkTrackingIds: boolean;
1287
1279
  allowSaveWithErrors: boolean;
1288
1280
  reusableRecommendationStrategy: boolean;
1289
- blockUnsubscribeLinks: boolean;
1290
1281
  };
1291
1282
  blocks: {
1292
1283
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -1433,7 +1424,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1433
1424
  linkTrackingIds: boolean;
1434
1425
  allowSaveWithErrors: boolean;
1435
1426
  reusableRecommendationStrategy: boolean;
1436
- blockUnsubscribeLinks: boolean;
1437
1427
  };
1438
1428
  blocks: {
1439
1429
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -1580,7 +1570,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1580
1570
  linkTrackingIds: boolean;
1581
1571
  allowSaveWithErrors: boolean;
1582
1572
  reusableRecommendationStrategy: boolean;
1583
- blockUnsubscribeLinks: boolean;
1584
1573
  };
1585
1574
  blocks: {
1586
1575
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -1727,7 +1716,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1727
1716
  linkTrackingIds: boolean;
1728
1717
  allowSaveWithErrors: boolean;
1729
1718
  reusableRecommendationStrategy: boolean;
1730
- blockUnsubscribeLinks: boolean;
1731
1719
  };
1732
1720
  blocks: {
1733
1721
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -1874,7 +1862,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
1874
1862
  linkTrackingIds: boolean;
1875
1863
  allowSaveWithErrors: boolean;
1876
1864
  reusableRecommendationStrategy: boolean;
1877
- blockUnsubscribeLinks: boolean;
1878
1865
  };
1879
1866
  blocks: {
1880
1867
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -2021,7 +2008,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
2021
2008
  linkTrackingIds: boolean;
2022
2009
  allowSaveWithErrors: boolean;
2023
2010
  reusableRecommendationStrategy: boolean;
2024
- blockUnsubscribeLinks: boolean;
2025
2011
  };
2026
2012
  blocks: {
2027
2013
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -2168,7 +2154,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
2168
2154
  linkTrackingIds: boolean;
2169
2155
  allowSaveWithErrors: boolean;
2170
2156
  reusableRecommendationStrategy: boolean;
2171
- blockUnsubscribeLinks: boolean;
2172
2157
  };
2173
2158
  blocks: {
2174
2159
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -2315,7 +2300,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
2315
2300
  linkTrackingIds: boolean;
2316
2301
  allowSaveWithErrors: boolean;
2317
2302
  reusableRecommendationStrategy: boolean;
2318
- blockUnsubscribeLinks: boolean;
2319
2303
  };
2320
2304
  blocks: {
2321
2305
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -2462,7 +2446,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
2462
2446
  linkTrackingIds: boolean;
2463
2447
  allowSaveWithErrors: boolean;
2464
2448
  reusableRecommendationStrategy: boolean;
2465
- blockUnsubscribeLinks: boolean;
2466
2449
  };
2467
2450
  blocks: {
2468
2451
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -2621,7 +2604,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
2621
2604
  linkTrackingIds: boolean;
2622
2605
  allowSaveWithErrors: boolean;
2623
2606
  reusableRecommendationStrategy: boolean;
2624
- blockUnsubscribeLinks: boolean;
2625
2607
  };
2626
2608
  blocks: {
2627
2609
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -2768,7 +2750,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
2768
2750
  linkTrackingIds: boolean;
2769
2751
  allowSaveWithErrors: boolean;
2770
2752
  reusableRecommendationStrategy: boolean;
2771
- blockUnsubscribeLinks: boolean;
2772
2753
  };
2773
2754
  blocks: {
2774
2755
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -2917,7 +2898,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
2917
2898
  linkTrackingIds: boolean;
2918
2899
  allowSaveWithErrors: boolean;
2919
2900
  reusableRecommendationStrategy: boolean;
2920
- blockUnsubscribeLinks: boolean;
2921
2901
  };
2922
2902
  blocks: {
2923
2903
  excludeDefaults: ("amp-accordion" | "amp-carousel" | "amp-form-controls" | "banner-block" | "button-block" | "html-block" | "image-block" | "menu-block" | "social-block" | "spacer-block" | "text-block" | "timer-block" | "video-block")[];
@@ -20,6 +20,25 @@ export declare function readTrackSeq(html: string): number;
20
20
  * Scans the document because a rewrite can strip the seq host but keep the ids.
21
21
  */
22
22
  export declare function readTrackFloor(html: string, persistedCounter?: number): number;
23
+ export interface TrackingIdPlan {
24
+ /** Final id per anchor, in the order the raw values were given. */
25
+ ids: number[];
26
+ reassigned: boolean[];
27
+ nextSeq: number;
28
+ seqChanged: boolean;
29
+ changed: boolean;
30
+ }
31
+ /**
32
+ * The id rule shared by the string transform and the editor-model writer: `rawIds` are the
33
+ * anchors' current `data-ins-track-id` values in document order ('' when absent).
34
+ */
35
+ export declare function planTrackingIds(rawIds: readonly string[], persistedSeq: number, floor?: number): TrackingIdPlan;
36
+ /** Reads a `data-ins-track-seq` attribute value the way readTrackSeq reads it from HTML. */
37
+ export declare function parseTrackSeq(value: string | null): number;
38
+ /** The `data-ins-track-id` value of every `<a>` opening tag in `html`, in order ('' when absent). */
39
+ export declare function readAnchorTrackIds(html: string): string[];
40
+ /** Writes `ids[i]` onto the i-th `<a>` opening tag of `html`; `null` or a missing entry leaves it untouched. */
41
+ export declare function writeAnchorTrackIds(html: string, ids: readonly (number | null)[]): string;
23
42
  /**
24
43
  * Ensures every <a> opening tag carries a unique positive-integer id and the
25
44
  * document records the id high-water mark. Ids are minted above
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Browsers ignore whitespace around an href, but the send-time link rewrite does not:
3
+ * a trailing space ends up inside the path and a leading one skips the tracking params.
4
+ */
5
+ export declare function trimHrefWhitespace(html: string): string;
@@ -1,56 +1,90 @@
1
- const g = "data-ins-track-id", $ = "data-ins-track-seq", E = `(?:[^>"']|"[^"]*"|'[^']*')*`, f = new RegExp(`<a\\b${E}>`, "gi"), b = new RegExp(`<body\\b${E}>`, "i"), N = new RegExp(`<html\\b${E}>`, "i"), I = new RegExp(`\\b${g}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i"), S = new RegExp(`\\b${$}\\s*=\\s*(?:"(\\d+)"|'(\\d+)'|(\\d+))`, "i"), p = "ins-track-seq", _ = new RegExp(`<!--\\s*${p}:(\\d+)\\s*-->`, "i"), w = /^[1-9][0-9]{0,14}$/, k = 999999999999999;
2
- function m(e) {
3
- const n = Number(e);
4
- return Number.isSafeInteger(n) && n > 0 ? n : 0;
5
- }
6
- function M(e) {
7
- var a;
8
- const n = (s) => {
9
- var r;
10
- const o = (r = s.exec(e)) == null ? void 0 : r[0];
11
- return o ? S.exec(o) : null;
12
- }, t = n(b) ?? n(N), c = (t == null ? void 0 : t[1]) ?? (t == null ? void 0 : t[2]) ?? (t == null ? void 0 : t[3]) ?? ((a = _.exec(e)) == null ? void 0 : a[1]) ?? "";
13
- return m(c);
14
- }
15
- function P(e, n = 0) {
16
- let t = 0;
17
- [...e.matchAll(f)].forEach(([a]) => {
18
- const s = I.exec(a), o = s ? s[1] ?? s[2] ?? s[3] ?? "" : "";
19
- w.test(o) && (t = Math.max(t, Number(o)));
1
+ const l = "data-ins-track-id", E = "data-ins-track-seq", A = `(?:[^>"']|"[^"]*"|'[^']*')*`, k = new RegExp(`<a\\b${A}>`, "gi"), R = new RegExp(`<body\\b${A}>`, "i"), _ = new RegExp(`<html\\b${A}>`, "i"), m = new RegExp(`\\b${l}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i"), f = new RegExp(`\\b${E}\\s*=\\s*(?:"(\\d+)"|'(\\d+)'|(\\d+))`, "i"), p = "ins-track-seq", x = new RegExp(`<!--\\s*${p}:(\\d+)\\s*-->`, "i"), $ = /^[1-9][0-9]{0,14}$/, q = 999999999999999;
2
+ function I(e) {
3
+ const c = Number(e);
4
+ return Number.isSafeInteger(c) && c > 0 ? c : 0;
5
+ }
6
+ function T(e) {
7
+ return [...e.matchAll(k)].map((c) => {
8
+ const [n] = c, t = m.exec(n), r = t ? t[1] ?? t[2] ?? t[3] ?? "" : "";
9
+ return { index: c.index, tag: n, attrMatch: t, rawValue: r };
20
10
  });
21
- const c = Number.isSafeInteger(n) && n > 0 ? n : 0;
22
- return Math.max(M(e), t, c);
23
- }
24
- function q(e, n) {
25
- const t = `${$}="${n}"`, c = b.exec(e) ?? N.exec(e);
26
- if (c) {
27
- const [s] = c, o = S.exec(s), r = o ? s.replace(o[0], t) : s.replace(/\/?>$/, (T) => ` ${t}${T}`);
28
- return e.slice(0, c.index) + r + e.slice(c.index + s.length);
11
+ }
12
+ function b(e) {
13
+ var r;
14
+ const c = (s) => {
15
+ var a;
16
+ const o = (a = s.exec(e)) == null ? void 0 : a[0];
17
+ return o ? f.exec(o) : null;
18
+ }, n = c(R) ?? c(_), t = (n == null ? void 0 : n[1]) ?? (n == null ? void 0 : n[2]) ?? (n == null ? void 0 : n[3]) ?? ((r = x.exec(e)) == null ? void 0 : r[1]) ?? "";
19
+ return I(t);
20
+ }
21
+ function h(e, c = 0) {
22
+ let n = 0;
23
+ T(e).forEach(({ rawValue: r }) => {
24
+ $.test(r) && (n = Math.max(n, Number(r)));
25
+ });
26
+ const t = Number.isSafeInteger(c) && c > 0 ? c : 0;
27
+ return Math.max(b(e), n, t);
28
+ }
29
+ function w(e, c) {
30
+ const n = `${E}="${c}"`, t = R.exec(e) ?? _.exec(e);
31
+ if (t) {
32
+ const [s] = t, o = f.exec(s), a = o ? s.replace(o[0], n) : s.replace(/\/?>$/, (u) => ` ${n}${u}`);
33
+ return e.slice(0, t.index) + a + e.slice(t.index + s.length);
29
34
  }
30
- const a = `<!--${p}:${n}-->`;
31
- return _.test(e) ? e.replace(_, a) : `${a}${e}`;
35
+ const r = `<!--${p}:${c}-->`;
36
+ return x.test(e) ? e.replace(x, r) : `${r}${e}`;
32
37
  }
33
- function D(e, n, t) {
34
- const c = `${g}="${t}"`;
35
- return n ? e.replace(n[0], c) : e.replace(/^<a\b/i, (a) => `${a} ${c}`);
38
+ function M(e, c, n) {
39
+ const t = `${l}="${n}"`;
40
+ return c ? e.replace(c[0], t) : e.replace(/^<a\b/i, (r) => `${r} ${t}`);
36
41
  }
37
- function C(e, n = 0) {
42
+ function C(e, c, n = 0) {
38
43
  const t = /* @__PURE__ */ new Set();
39
- let c = 0;
40
- const a = [...e.matchAll(f)].map((i) => {
41
- const [l] = i, u = I.exec(l), R = u ? u[1] ?? u[2] ?? u[3] ?? "" : "";
42
- let x = null;
43
- return w.test(R) && !t.has(Number(R)) && (x = Number(R), t.add(x), c = Math.max(c, x)), { index: i.index, tag: l, attrMatch: u, id: x };
44
- }), s = M(e), o = Number.isSafeInteger(n) && n > 0 && n < k ? n : 0;
45
- let r = Math.max(s, c, o), T = "", d = 0, A = !1;
46
- return a.forEach((i) => {
47
- T += e.slice(d, i.index), i.id === null ? (r += 1, T += D(i.tag, i.attrMatch, r), A = !0) : T += i.tag, d = i.index + i.tag.length;
48
- }), T += e.slice(d), r > 0 && s !== r && (T = q(T, r), A = !0), { html: T, changed: A, nextSeq: r };
44
+ let r = 0;
45
+ const s = e.map((i) => {
46
+ if (!$.test(i) || t.has(Number(i)))
47
+ return null;
48
+ const d = Number(i);
49
+ return t.add(d), r = Math.max(r, d), d;
50
+ }), o = Number.isSafeInteger(n) && n > 0 && n < q ? n : 0;
51
+ let a = Math.max(c, r, o);
52
+ const u = s.map((i) => i === null), S = s.map((i) => i !== null ? i : (a += 1, a)), g = a > 0 && c !== a;
53
+ return { ids: S, reassigned: u, nextSeq: a, seqChanged: g, changed: g || u.includes(!0) };
54
+ }
55
+ function D(e) {
56
+ return e !== null && /^\d+$/.test(e) ? I(e) : 0;
57
+ }
58
+ function N(e, c, n) {
59
+ let t = "", r = 0;
60
+ return c.forEach((s, o) => {
61
+ const a = n[o] ?? null;
62
+ t += e.slice(r, s.index), t += a === null ? s.tag : M(s.tag, s.attrMatch, a), r = s.index + s.tag.length;
63
+ }), t + e.slice(r);
64
+ }
65
+ function P(e) {
66
+ return T(e).map((c) => c.rawValue);
67
+ }
68
+ function K(e, c) {
69
+ return N(e, T(e), c);
70
+ }
71
+ function O(e, c = 0) {
72
+ const n = T(e), t = C(n.map((s) => s.rawValue), b(e), c);
73
+ let r = N(
74
+ e,
75
+ n,
76
+ t.ids.map((s, o) => t.reassigned[o] ? s : null)
77
+ );
78
+ return t.seqChanged && (r = w(r, t.nextSeq)), { html: r, changed: t.changed, nextSeq: t.nextSeq };
49
79
  }
50
80
  export {
51
- g as TRACK_ID_ATTRIBUTE,
52
- $ as TRACK_SEQ_ATTRIBUTE,
53
- C as assignTrackingIds,
54
- P as readTrackFloor,
55
- M as readTrackSeq
81
+ l as TRACK_ID_ATTRIBUTE,
82
+ E as TRACK_SEQ_ATTRIBUTE,
83
+ O as assignTrackingIds,
84
+ D as parseTrackSeq,
85
+ C as planTrackingIds,
86
+ P as readAnchorTrackIds,
87
+ h as readTrackFloor,
88
+ b as readTrackSeq,
89
+ K as writeAnchorTrackIds
56
90
  };
@@ -1,5 +1,6 @@
1
- import { useActionsApi as E } from "../composables/useActionsApi.js";
2
- import { useConfig as F } from "../composables/useConfig.js";
1
+ import { useActionsApi as x } from "../composables/useActionsApi.js";
2
+ import { useConfig as D } from "../composables/useConfig.js";
3
+ import { useEditorTrackingIds as F } from "../composables/useEditorTrackingIds.js";
3
4
  import { useHtmlCompiler as I } from "../composables/useHtmlCompiler.js";
4
5
  import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
5
6
  import { toBlockUrlConfig as R } from "../extensions/Blocks/Recommendation/utils/blockUrlConfig.js";
@@ -7,10 +8,9 @@ import { DATA_ATTRIBUTES as g } from "../extensions/Blocks/Unsubscribe/utils/con
7
8
  import { parsePageList as U } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
8
9
  import { useDynamicContentStore as L } from "../stores/dynamic-content.js";
9
10
  import { useEditorStore as N } from "../stores/editor.js";
10
- import { useUnsubscribeStore as v } from "../stores/unsubscribe.js";
11
- import { isPlainObject as z } from "./genericUtil.js";
12
- import { assignTrackingIds as M } from "./linkTrackingIds.js";
13
- function O(n) {
11
+ import { useUnsubscribeStore as z } from "../stores/unsubscribe.js";
12
+ import { isPlainObject as v } from "./genericUtil.js";
13
+ function M(n) {
14
14
  const r = new DOMParser().parseFromString(n, "text/html").querySelectorAll(`[${g.PAGE_LIST}]`), e = [];
15
15
  return r.forEach((i) => {
16
16
  const t = i.getAttribute(g.PAGE_LIST);
@@ -26,16 +26,16 @@ async function S(n) {
26
26
  const i = e.getAttribute("recommendation-id"), t = i ? Number(i) : NaN;
27
27
  if (!Number.isFinite(t))
28
28
  return;
29
- const m = e.getAttribute("esd-ext-config");
30
- if (!m)
29
+ const c = e.getAttribute("esd-ext-config");
30
+ if (!c)
31
31
  return;
32
32
  let a;
33
33
  try {
34
- a = JSON.parse(m);
34
+ a = JSON.parse(c);
35
35
  } catch {
36
36
  return;
37
37
  }
38
- z(a) && r.seedBlockUrlConfig(t, R(a));
38
+ v(a) && r.seedBlockUrlConfig(t, R(a));
39
39
  });
40
40
  try {
41
41
  await r.fetchRecommendationCreateData();
@@ -46,40 +46,37 @@ async function S(n) {
46
46
  );
47
47
  }
48
48
  }
49
- const Z = () => {
50
- const n = L(), c = N(), o = v(), { getCompiledEmail: r, getTemplateData: e, updateHtmlAndCss: i } = E(), { compileHtml: t, compileAmpHtml: m } = I(), { isFeatureEnabled: a } = F();
49
+ const Y = () => {
50
+ const n = L(), s = N(), o = z(), { getCompiledEmail: r, getTemplateData: e } = x(), { writeTrackingIds: i } = F(), { compileHtml: t, compileAmpHtml: c } = I(), { isFeatureEnabled: a } = D();
51
51
  return {
52
52
  prepareTemplateDetails: async (h) => {
53
- let { html: s, css: u, syncModulesIds: y = [] } = h ?? await e();
54
- if (a("linkTrackingIds"))
55
- try {
56
- const { html: d, changed: x, nextSeq: D } = M(s, c.trackIdSessionFloor);
57
- c.trackIdSessionFloor = D, x && (s = d, await i(d, u));
58
- } catch (d) {
59
- console.error("Tracking-id step failed, saving anyway:", d);
60
- }
61
- const { html: T, ampHtml: p = "", ampErrors: A = [] } = await r({
53
+ let { html: m, css: p, syncModulesIds: u = [] } = h ?? await e();
54
+ if (a("linkTrackingIds")) {
55
+ const { changed: P, nextSeq: E } = i(s.trackIdSessionFloor);
56
+ s.trackIdSessionFloor = E, P && ({ html: m, css: p, syncModulesIds: u = [] } = await e());
57
+ }
58
+ const { html: T, ampHtml: d = "", ampErrors: w = [] } = await r({
62
59
  minimize: !0,
63
60
  resetDataSavedFlag: !1
64
61
  });
65
- o.selectedUnsubscribePages.length && await o.fetchTemplates(), await S(s);
66
- const { compiledHtml: w, stats: l, appliedRules: C } = t(T), H = p && m(p).compiledHtml, k = n.getSelectedDynamicContentList, P = b(), f = O(s);
62
+ o.selectedUnsubscribePages.length && await o.fetchTemplates(), await S(m);
63
+ const { compiledHtml: A, stats: l, appliedRules: y } = t(T), C = d && c(d).compiledHtml, k = n.getSelectedDynamicContentList, H = b(), f = M(m);
67
64
  return console.debug("HTML Compilation Stats:", {
68
65
  originalSize: l.originalSize,
69
66
  compiledSize: l.compiledSize,
70
67
  reduction: `${l.reductionPercentage.toFixed(2)}%`,
71
- appliedRules: C,
68
+ appliedRules: y,
72
69
  executionTime: `${l.executionTime.toFixed(2)}ms`
73
70
  }), {
74
71
  dynamicContentList: k,
75
- compiledHtml: w,
76
- rawHtml: s,
77
- css: u,
78
- ampHtml: H,
79
- ampErrors: A,
80
- modules: y.map(Number),
72
+ compiledHtml: A,
73
+ rawHtml: m,
74
+ css: p,
75
+ ampHtml: C,
76
+ ampErrors: w,
77
+ modules: u.map(Number),
81
78
  recommendation: {
82
- campaignUrls: P.recommendationCampaignUrls,
79
+ campaignUrls: H.recommendationCampaignUrls,
83
80
  configs: {}
84
81
  },
85
82
  unsubscribe: {
@@ -94,6 +91,6 @@ const Z = () => {
94
91
  };
95
92
  };
96
93
  export {
97
- O as getHtmlReferencedUnsubscribePages,
98
- Z as useTemplatePreparation
94
+ M as getHtmlReferencedUnsubscribePages,
95
+ Y as useTemplatePreparation
99
96
  };
@@ -0,0 +1,10 @@
1
+ const E = /(<[a-z][\w:-]*(?:\s[^>]*?)?\shref\s*=\s*)(["'])([\s\S]*?)\2/gi, c = /^(?:\s|&nbsp;|&#160;|&#xa0;)+|(?:\s|&nbsp;|&#160;|&#xa0;)+$/gi;
2
+ function a(e) {
3
+ return !e || !/href/i.test(e) ? e : e.replace(E, (i, s, r, n) => {
4
+ const t = n.replace(c, "");
5
+ return `${s}${r}${t}${r}`;
6
+ });
7
+ }
8
+ export {
9
+ a as trimHrefWhitespace
10
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.24.0-beta.88c24c1",
3
+ "version": "3.24.0-beta.8e9f4e2",
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",