@useinsider/guido 3.4.1-beta.6ed05e2 → 3.4.1-beta.7f60a52
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/composables/useActionsApi.js +9 -5
- package/dist/composables/useSave.js +13 -14
- package/dist/extensions/Blocks/Recommendation/block.js +47 -66
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +13 -41
- package/dist/extensions/Blocks/Unsubscribe/block.js +133 -49
- package/dist/extensions/Blocks/Unsubscribe/template.js +8 -8
- package/dist/extensions/Blocks/Unsubscribe/utils/constants.js +2 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +145 -144
- package/dist/src/composables/useActionsApi.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +1 -14
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +0 -8
- package/dist/src/extensions/Blocks/Unsubscribe/block.d.ts +20 -1
- package/dist/src/extensions/Blocks/Unsubscribe/utils/constants.d.ts +1 -0
- package/dist/utils/templatePreparation.js +64 -69
- package/package.json +1 -1
|
@@ -216,14 +216,6 @@ export declare const useRecommendationExtensionStore: import("pinia").StoreDefin
|
|
|
216
216
|
* Resets currentRecommendationId if it was the deleted block.
|
|
217
217
|
*/
|
|
218
218
|
removeBlockState(id: number): void;
|
|
219
|
-
/**
|
|
220
|
-
* Copies blockStates[fromId] into a new blockStates[toId] entry so a
|
|
221
|
-
* duplicated block immediately renders the source's products/filters
|
|
222
|
-
* without re-fetching from the API (SD-142352). No-op when the source
|
|
223
|
-
* was never selected (no entry in blockStates) — the caller falls back
|
|
224
|
-
* to setCurrentBlock's default initialization.
|
|
225
|
-
*/
|
|
226
|
-
cloneBlockState(fromId: number, toId: number): void;
|
|
227
219
|
/**
|
|
228
220
|
* Marks a block as initialized (initial API data has been fetched).
|
|
229
221
|
* Automatically cleaned up when removeBlockState deletes the block entry.
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type { ImmutableHtmlElementNode } from '@stripoinc/ui-editor-extensions';
|
|
1
|
+
import type { ImmutableHtmlElementNode, ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
|
|
2
2
|
import { Block, BlockCompositionType } from '@stripoinc/ui-editor-extensions';
|
|
3
3
|
export declare const UNSUBSCRIBE_BLOCK_ID = "unsubscribe-block";
|
|
4
4
|
export declare class UnsubscribeBlock extends Block {
|
|
5
5
|
private selectEventListener;
|
|
6
6
|
private cancelEventListener;
|
|
7
7
|
private currentNode?;
|
|
8
|
+
private linkStateByBlockId;
|
|
8
9
|
constructor();
|
|
9
10
|
getId(): string;
|
|
10
11
|
getIcon(): string;
|
|
@@ -12,9 +13,27 @@ export declare class UnsubscribeBlock extends Block {
|
|
|
12
13
|
getName(): string;
|
|
13
14
|
getDescription(): string;
|
|
14
15
|
getTemplate(): string;
|
|
16
|
+
getContextActionsIds(): string[];
|
|
15
17
|
onSelect(node: ImmutableHtmlElementNode): void;
|
|
18
|
+
onDocumentChanged(node: ImmutableHtmlNode): void;
|
|
16
19
|
onDelete(node: ImmutableHtmlElementNode): void;
|
|
17
20
|
onDestroy(): void;
|
|
21
|
+
private _hasUnsubscribeLink;
|
|
22
|
+
private _readBlockId;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the block's stable id, assigning one via the document modifier if
|
|
25
|
+
* the node has not been tagged yet. Idempotent: subsequent calls during
|
|
26
|
+
* the same document-change cycle (e.g. reentrant onDocumentChanged after
|
|
27
|
+
* `apply()`) short-circuit on the existing attribute.
|
|
28
|
+
*/
|
|
29
|
+
private _getOrAssignBlockId;
|
|
30
|
+
/**
|
|
31
|
+
* Generates a unique id by scanning the document for the highest existing
|
|
32
|
+
* `data-unsubscribe-block-id` and returning max+1. Mirrors the strategy
|
|
33
|
+
* used by RecommendationBlock so reloaded templates don't collide.
|
|
34
|
+
*/
|
|
35
|
+
private _generateNextBlockId;
|
|
36
|
+
private _warnLinkRemoved;
|
|
18
37
|
private _setupSelectEventListener;
|
|
19
38
|
private _removeSelectEventListener;
|
|
20
39
|
private _setupCancelEventListener;
|
|
@@ -6,4 +6,5 @@ export type UnsubscribeEvent = typeof UNSUBSCRIBE_EVENTS[keyof typeof UNSUBSCRIB
|
|
|
6
6
|
export declare const DATA_ATTRIBUTES: {
|
|
7
7
|
readonly PAGE_TYPE: "data-unsubscribe-page-type";
|
|
8
8
|
readonly PAGE_LIST: "data-unsubscribe-page-list";
|
|
9
|
+
readonly BLOCK_ID: "data-unsubscribe-block-id";
|
|
9
10
|
};
|
|
@@ -1,106 +1,101 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useHtmlCompiler as
|
|
3
|
-
import { DEFAULT_CURRENCY as
|
|
4
|
-
import { BLOCK_ROOT_SELECTOR as R, CONTAINER_SELECTOR as N } from "../extensions/Blocks/Recommendation/constants/selectors.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";
|
|
5
4
|
import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
6
|
-
import { DATA_ATTRIBUTES as
|
|
7
|
-
import { parsePageList as
|
|
8
|
-
import { useDynamicContentStore as
|
|
9
|
-
import { useUnsubscribeStore as
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
return
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
}),
|
|
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));
|
|
16
15
|
}
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return m.querySelectorAll(R).forEach((o) => {
|
|
21
|
-
if (!o.querySelector(N))
|
|
22
|
-
return;
|
|
23
|
-
const e = Number(o.getAttribute("recommendation-id"));
|
|
24
|
-
Number.isFinite(e) && e > 0 && n.add(e);
|
|
25
|
-
}), n;
|
|
26
|
-
}
|
|
27
|
-
function x(s) {
|
|
28
|
-
const a = new DOMParser().parseFromString(s, "text/html").querySelectorAll(".recommendation-block-v2");
|
|
29
|
-
if (a.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)
|
|
30
19
|
return;
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
var
|
|
34
|
-
const c =
|
|
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;
|
|
35
24
|
if (!Number.isFinite(r))
|
|
36
25
|
return;
|
|
37
|
-
const
|
|
38
|
-
if (!
|
|
26
|
+
const a = t.getAttribute("esd-ext-config");
|
|
27
|
+
if (!a)
|
|
39
28
|
return;
|
|
40
29
|
let e;
|
|
41
30
|
try {
|
|
42
|
-
e = JSON.parse(
|
|
31
|
+
e = JSON.parse(a);
|
|
43
32
|
} catch {
|
|
44
33
|
return;
|
|
45
34
|
}
|
|
46
35
|
if (!e || typeof e != "object" || Array.isArray(e))
|
|
47
36
|
return;
|
|
48
|
-
const
|
|
49
|
-
strategy: e.strategy ??
|
|
50
|
-
language: e.language ??
|
|
51
|
-
size: e.size ??
|
|
37
|
+
const p = {
|
|
38
|
+
strategy: e.strategy ?? s.strategy,
|
|
39
|
+
language: e.language ?? s.language,
|
|
40
|
+
size: e.size ?? s.size,
|
|
52
41
|
// Spread the default arrays so each block gets a fresh reference
|
|
53
42
|
// instead of sharing the singleton in DEFAULT_NODE_CONFIG.
|
|
54
|
-
productIds: e.productIds ?? [...
|
|
55
|
-
filters: e.filters ?? [...
|
|
56
|
-
shuffleProducts: e.shuffleProducts ??
|
|
57
|
-
currencyCode: ((
|
|
58
|
-
currencyAlignment: ((
|
|
59
|
-
currencyDecimalCount: ((
|
|
60
|
-
currencyDecimalSeparator: ((
|
|
61
|
-
currencyThousandSeparator: ((
|
|
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
|
|
62
51
|
};
|
|
63
|
-
|
|
52
|
+
l.seedBlockUrlConfig(r, p);
|
|
64
53
|
});
|
|
54
|
+
try {
|
|
55
|
+
await l.fetchRecommendationCreateData();
|
|
56
|
+
} catch (t) {
|
|
57
|
+
console.warn(
|
|
58
|
+
"Recommendation reference data pre-load failed; validator will skip the availability check.",
|
|
59
|
+
t
|
|
60
|
+
);
|
|
61
|
+
}
|
|
65
62
|
}
|
|
66
|
-
const
|
|
67
|
-
const
|
|
63
|
+
const _ = () => {
|
|
64
|
+
const i = P(), o = w(), { getCompiledEmail: m, getTemplateData: l } = C(), { compileHtml: t } = T();
|
|
68
65
|
return {
|
|
69
66
|
prepareTemplateDetails: async () => {
|
|
70
|
-
const { html: r, ampHtml:
|
|
67
|
+
const { html: r, ampHtml: a = "", ampErrors: e = [] } = await m({
|
|
71
68
|
minimize: !0,
|
|
72
69
|
resetDataSavedFlag: !1
|
|
73
|
-
}), { html:
|
|
74
|
-
|
|
75
|
-
const { compiledHtml:
|
|
76
|
-
Object.entries(A.recommendationCampaignUrls).filter(([D]) => T.has(Number(D)))
|
|
77
|
-
);
|
|
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();
|
|
78
73
|
return console.debug("HTML Compilation Stats:", {
|
|
79
|
-
originalSize:
|
|
80
|
-
compiledSize:
|
|
81
|
-
reduction: `${
|
|
82
|
-
appliedRules:
|
|
83
|
-
executionTime: `${
|
|
74
|
+
originalSize: n.originalSize,
|
|
75
|
+
compiledSize: n.compiledSize,
|
|
76
|
+
reduction: `${n.reductionPercentage.toFixed(2)}%`,
|
|
77
|
+
appliedRules: y,
|
|
78
|
+
executionTime: `${n.executionTime.toFixed(2)}ms`
|
|
84
79
|
}), {
|
|
85
80
|
dynamicContentList: h,
|
|
86
|
-
compiledHtml:
|
|
87
|
-
rawHtml:
|
|
88
|
-
css:
|
|
89
|
-
ampHtml:
|
|
81
|
+
compiledHtml: u,
|
|
82
|
+
rawHtml: p,
|
|
83
|
+
css: g,
|
|
84
|
+
ampHtml: a,
|
|
90
85
|
ampErrors: e,
|
|
91
|
-
modules:
|
|
86
|
+
modules: f.map(Number),
|
|
92
87
|
recommendation: {
|
|
93
|
-
campaignUrls:
|
|
88
|
+
campaignUrls: A.recommendationCampaignUrls,
|
|
94
89
|
configs: {}
|
|
95
90
|
},
|
|
96
91
|
unsubscribe: {
|
|
97
|
-
status:
|
|
98
|
-
config:
|
|
92
|
+
status: o.unsubscribePagesStatus,
|
|
93
|
+
config: E(u, o.selectedUnsubscribePages)
|
|
99
94
|
}
|
|
100
95
|
};
|
|
101
96
|
}
|
|
102
97
|
};
|
|
103
98
|
};
|
|
104
99
|
export {
|
|
105
|
-
|
|
100
|
+
_ as useTemplatePreparation
|
|
106
101
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.4.1-beta.
|
|
3
|
+
"version": "3.4.1-beta.7f60a52",
|
|
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",
|