@useinsider/guido 3.4.1 → 3.5.0
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/README.md +2 -0
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +50 -48
- package/dist/components/organisms/extensions/recommendation/FilterItem.vue.js +2 -2
- package/dist/components/organisms/extensions/recommendation/FilterItem.vue2.js +49 -49
- package/dist/composables/useActionsApi.js +9 -5
- package/dist/composables/useSave.js +13 -14
- package/dist/config/migrator/itemsBlockMigrator.js +28 -18
- package/dist/extensions/Blocks/Recommendation/block.js +90 -45
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +33 -14
- package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +24 -16
- 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/guido.css +1 -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 +10 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +5 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/filterUtil.d.ts +2 -0
- 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/src/stores/config.test.d.ts +1 -0
- package/dist/src/vitest.setup.d.ts +0 -0
- package/dist/stores/config.js +24 -23
- package/dist/utils/templatePreparation.js +51 -43
- package/package.json +3 -2
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Filter } from '@@/Types/recommendation';
|
|
2
2
|
export declare function safeDecodeURIComponent(value: string): string;
|
|
3
3
|
export declare function parseTagList(value: string): string[];
|
|
4
|
+
export declare function encodeTagList(tags: string[]): string;
|
|
5
|
+
export declare function isValidFilterTag(tag: string): boolean;
|
|
4
6
|
/**
|
|
5
7
|
* Generates the complete query with outer group operators
|
|
6
8
|
* @param filters Array of Filter objects
|
|
@@ -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
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
package/dist/stores/config.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "../@types/config/schemas.js";
|
|
2
2
|
import "../@types/config/defaults.js";
|
|
3
|
-
import { parseConfig as
|
|
4
|
-
import { defineStore as
|
|
5
|
-
const
|
|
3
|
+
import { parseConfig as o } from "../@types/config/validator.js";
|
|
4
|
+
import { defineStore as r } from "pinia";
|
|
5
|
+
const f = r("guido-config", {
|
|
6
6
|
state: () => ({
|
|
7
7
|
initialized: !1,
|
|
8
8
|
config: null
|
|
@@ -75,64 +75,65 @@ const s = o("guido-config", {
|
|
|
75
75
|
* Get the template ID
|
|
76
76
|
*/
|
|
77
77
|
templateId: (i) => {
|
|
78
|
-
var e;
|
|
79
|
-
return ((e = i.config) == null ? void 0 : e.identity.templateId) ?? "";
|
|
78
|
+
var e, t;
|
|
79
|
+
return ((t = (e = i.config) == null ? void 0 : e.identity) == null ? void 0 : t.templateId) ?? "";
|
|
80
80
|
},
|
|
81
81
|
/**
|
|
82
82
|
* Get the user ID
|
|
83
83
|
*/
|
|
84
84
|
userId: (i) => {
|
|
85
|
-
var e;
|
|
86
|
-
return ((e = i.config) == null ? void 0 : e.identity.userId) ?? "";
|
|
85
|
+
var e, t;
|
|
86
|
+
return ((t = (e = i.config) == null ? void 0 : e.identity) == null ? void 0 : t.userId) ?? "";
|
|
87
87
|
},
|
|
88
88
|
/**
|
|
89
89
|
* Get the variation ID
|
|
90
90
|
*/
|
|
91
91
|
variationId: (i) => {
|
|
92
|
-
var e;
|
|
93
|
-
return ((e = i.config) == null ? void 0 : e.identity.variationId) ?? "";
|
|
92
|
+
var e, t;
|
|
93
|
+
return ((t = (e = i.config) == null ? void 0 : e.identity) == null ? void 0 : t.variationId) ?? "";
|
|
94
94
|
},
|
|
95
95
|
/**
|
|
96
96
|
* Get the partner name
|
|
97
97
|
*/
|
|
98
98
|
partnerName: (i) => {
|
|
99
|
-
var e;
|
|
100
|
-
return ((e = i.config) == null ? void 0 : e.partner.name) ?? "";
|
|
99
|
+
var e, t;
|
|
100
|
+
return ((t = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : t.name) ?? "";
|
|
101
101
|
},
|
|
102
102
|
/**
|
|
103
103
|
* Get the product type
|
|
104
104
|
*/
|
|
105
105
|
productType: (i) => {
|
|
106
|
-
var e;
|
|
107
|
-
return ((e = i.config) == null ? void 0 : e.partner.productType) ?? 60;
|
|
106
|
+
var e, t;
|
|
107
|
+
return ((t = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : t.productType) ?? 60;
|
|
108
108
|
},
|
|
109
109
|
/**
|
|
110
110
|
* Get the message type
|
|
111
111
|
*/
|
|
112
112
|
messageType: (i) => {
|
|
113
|
-
var e;
|
|
114
|
-
return ((e = i.config) == null ? void 0 : e.partner.messageType) ?? 1;
|
|
113
|
+
var e, t;
|
|
114
|
+
return ((t = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : t.messageType) ?? 1;
|
|
115
115
|
},
|
|
116
116
|
/**
|
|
117
117
|
* Get the username
|
|
118
118
|
*/
|
|
119
119
|
username: (i) => {
|
|
120
|
-
var e;
|
|
121
|
-
return ((e = i.config) == null ? void 0 : e.partner.username) ?? "Guido User";
|
|
120
|
+
var e, t;
|
|
121
|
+
return ((t = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : t.username) ?? "Guido User";
|
|
122
122
|
},
|
|
123
123
|
/**
|
|
124
124
|
* Check if header should be shown
|
|
125
125
|
*/
|
|
126
126
|
showHeader: (i) => {
|
|
127
|
-
var e;
|
|
128
|
-
return ((e = i.config) == null ? void 0 : e.ui.showHeader) ?? !0;
|
|
127
|
+
var e, t;
|
|
128
|
+
return ((t = (e = i.config) == null ? void 0 : e.ui) == null ? void 0 : t.showHeader) ?? !0;
|
|
129
129
|
},
|
|
130
130
|
/**
|
|
131
131
|
* Check if a specific feature is enabled
|
|
132
132
|
*/
|
|
133
|
+
// eslint-disable-next-line @stylistic/max-len
|
|
133
134
|
isFeatureEnabled: (i) => (e) => {
|
|
134
|
-
var t;
|
|
135
|
-
return ((t = i.config) == null ? void 0 : t.features[e]) ?? !0;
|
|
135
|
+
var t, n;
|
|
136
|
+
return ((n = (t = i.config) == null ? void 0 : t.features) == null ? void 0 : n[e]) ?? !0;
|
|
136
137
|
}
|
|
137
138
|
},
|
|
138
139
|
actions: {
|
|
@@ -140,7 +141,7 @@ const s = o("guido-config", {
|
|
|
140
141
|
* Initialize the config store with validated configuration
|
|
141
142
|
*/
|
|
142
143
|
init(i) {
|
|
143
|
-
const e =
|
|
144
|
+
const e = o(i);
|
|
144
145
|
this.config = e, this.initialized = !0;
|
|
145
146
|
},
|
|
146
147
|
/**
|
|
@@ -152,5 +153,5 @@ const s = o("guido-config", {
|
|
|
152
153
|
}
|
|
153
154
|
});
|
|
154
155
|
export {
|
|
155
|
-
|
|
156
|
+
f as useConfigStore
|
|
156
157
|
};
|
|
@@ -1,79 +1,87 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useHtmlCompiler as
|
|
3
|
-
import { DEFAULT_CURRENCY as
|
|
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
|
|
6
|
-
import { parsePageList as
|
|
7
|
-
import { useDynamicContentStore as
|
|
8
|
-
import { useUnsubscribeStore as
|
|
9
|
-
function
|
|
10
|
-
const
|
|
11
|
-
return
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
}),
|
|
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
|
-
function
|
|
16
|
+
async function U(i) {
|
|
17
17
|
const m = new DOMParser().parseFromString(i, "text/html").querySelectorAll(".recommendation-block-v2");
|
|
18
18
|
if (m.length === 0)
|
|
19
19
|
return;
|
|
20
|
-
const
|
|
21
|
-
m.forEach((
|
|
22
|
-
var g, f, u, n,
|
|
23
|
-
const c =
|
|
24
|
-
if (!Number.isFinite(
|
|
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
|
+
if (!Number.isFinite(r))
|
|
25
25
|
return;
|
|
26
|
-
const
|
|
27
|
-
if (!
|
|
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(
|
|
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
37
|
const p = {
|
|
38
|
-
strategy: e.strategy ??
|
|
39
|
-
language: e.language ??
|
|
40
|
-
size: e.size ??
|
|
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 ?? [...
|
|
44
|
-
filters: e.filters ?? [...
|
|
45
|
-
shuffleProducts: e.shuffleProducts ??
|
|
46
|
-
currencyCode: ((g = e.currency) == null ? void 0 : g.code) ??
|
|
47
|
-
currencyAlignment: ((f = e.currency) == null ? void 0 : f.alignment) ??
|
|
48
|
-
currencyDecimalCount: ((u = e.currency) == null ? void 0 : u.decimalCount) ??
|
|
49
|
-
currencyDecimalSeparator: ((n = e.currency) == null ? void 0 : n.decimalSeparator) ??
|
|
50
|
-
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
|
|
51
51
|
};
|
|
52
|
-
|
|
52
|
+
l.seedBlockUrlConfig(r, p);
|
|
53
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
|
+
}
|
|
54
62
|
}
|
|
55
63
|
const _ = () => {
|
|
56
|
-
const i =
|
|
64
|
+
const i = P(), o = w(), { getCompiledEmail: m, getTemplateData: l } = C(), { compileHtml: t } = T();
|
|
57
65
|
return {
|
|
58
66
|
prepareTemplateDetails: async () => {
|
|
59
|
-
const { html:
|
|
67
|
+
const { html: r, ampHtml: a = "", ampErrors: e = [] } = await m({
|
|
60
68
|
minimize: !0,
|
|
61
69
|
resetDataSavedFlag: !1
|
|
62
|
-
}), { html: p, css: g, syncModulesIds: f = [] } = await
|
|
63
|
-
|
|
64
|
-
const { compiledHtml: u, stats: n, appliedRules:
|
|
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();
|
|
65
73
|
return console.debug("HTML Compilation Stats:", {
|
|
66
74
|
originalSize: n.originalSize,
|
|
67
75
|
compiledSize: n.compiledSize,
|
|
68
76
|
reduction: `${n.reductionPercentage.toFixed(2)}%`,
|
|
69
|
-
appliedRules:
|
|
77
|
+
appliedRules: y,
|
|
70
78
|
executionTime: `${n.executionTime.toFixed(2)}ms`
|
|
71
79
|
}), {
|
|
72
80
|
dynamicContentList: h,
|
|
73
81
|
compiledHtml: u,
|
|
74
82
|
rawHtml: p,
|
|
75
83
|
css: g,
|
|
76
|
-
ampHtml:
|
|
84
|
+
ampHtml: a,
|
|
77
85
|
ampErrors: e,
|
|
78
86
|
modules: f.map(Number),
|
|
79
87
|
recommendation: {
|
|
@@ -81,8 +89,8 @@ const _ = () => {
|
|
|
81
89
|
configs: {}
|
|
82
90
|
},
|
|
83
91
|
unsubscribe: {
|
|
84
|
-
status:
|
|
85
|
-
config:
|
|
92
|
+
status: o.unsubscribePagesStatus,
|
|
93
|
+
config: E(u, o.selectedUnsubscribePages)
|
|
86
94
|
}
|
|
87
95
|
};
|
|
88
96
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
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",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"lint": "NODE_OPTIONS=--max-old-space-size=2048 eslint ./ && bun run type-check",
|
|
25
25
|
"lint:fix": "NODE_OPTIONS=--max-old-space-size=2048 eslint --fix ./",
|
|
26
26
|
"type-check": "vue-tsc --noEmit --project tsconfig.config.json && vue-tsc --noEmit --project tsconfig.app.json",
|
|
27
|
-
"test": "vitest run",
|
|
27
|
+
"test": "vitest run --coverage",
|
|
28
28
|
"test:watch": "vitest",
|
|
29
29
|
"test:visual-update": "npx playwright test --update-snapshots --reporter html",
|
|
30
30
|
"prepare": "husky",
|
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
"@typescript-eslint/parser": "7.18.0",
|
|
62
62
|
"@useinsider/eslint-config": "1.5.3",
|
|
63
63
|
"@vitejs/plugin-vue2": "2.3.1",
|
|
64
|
+
"@vitest/coverage-v8": "2.1.9",
|
|
64
65
|
"eslint": "8.57.1",
|
|
65
66
|
"eslint-config-airbnb-base": "15.0.0",
|
|
66
67
|
"eslint-config-airbnb-typescript": "18.0.0",
|