@useinsider/guido 3.4.1-beta.5e1fcb5 → 3.4.1-beta.6ed05e2
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/extensions/Blocks/Recommendation/block.js +66 -47
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +41 -13
- package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +9 -9
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +14 -1
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +8 -0
- package/dist/src/vitest.setup.d.ts +0 -0
- package/dist/stores/config.js +24 -23
- package/dist/utils/templatePreparation.js +69 -64
- package/package.json +3 -2
- /package/dist/src/{extensions/Blocks/Recommendation/validation/requiredFields.test.d.ts → stores/config.test.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
# @useinsider/guido
|
|
10
10
|
|
|
11
|
+
[](http://coverus.internal.dataforce/app/project/github/useinsider/guido)
|
|
12
|
+
|
|
11
13
|
Guido is a Vue 2 + TypeScript wrapper for the Stripo Email Editor plugin. Easily embed the professional email editor in your Vue applications with a clean, type-safe configuration.
|
|
12
14
|
|
|
13
15
|
## Installation
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
var k = Object.defineProperty;
|
|
2
|
-
var B = (
|
|
3
|
-
var
|
|
2
|
+
var B = (a, i, t) => i in a ? k(a, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[i] = t;
|
|
3
|
+
var d = (a, i, t) => B(a, typeof i != "symbol" ? i + "" : i, t);
|
|
4
4
|
import { BlockId as _ } from "../../../enums/block.js";
|
|
5
|
-
import { getMigrationBannerHtml as
|
|
6
|
-
import { Block as
|
|
5
|
+
import { getMigrationBannerHtml as C } from "../../../utils/migrationBannerHtml.js";
|
|
6
|
+
import { Block as b, BlockCompositionType as R, ModificationDescription as y } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
7
7
|
import { regenerateMobileProductRows as A } from "./controls/main/utils.js";
|
|
8
|
-
import { ensureMobileCssRulesExist as
|
|
9
|
-
import { RecommendationConfigService as
|
|
10
|
-
import { useRecommendationExtensionStore as
|
|
11
|
-
import { getDefaultTemplate as
|
|
12
|
-
const h = _.Recommendation,
|
|
8
|
+
import { ensureMobileCssRulesExist as p, setMobileLayoutOptOut as f, hasMobileLayoutOptOut as N } from "./controls/mobileLayout/cssRules.js";
|
|
9
|
+
import { RecommendationConfigService as c } from "./services/configService.js";
|
|
10
|
+
import { useRecommendationExtensionStore as m } from "./store/recommendation.js";
|
|
11
|
+
import { getDefaultTemplate as D } from "./templates/grid/template.js";
|
|
12
|
+
const h = _.Recommendation, u = "recommendation-block-v2", l = "recommendation-id";
|
|
13
13
|
let I = !1;
|
|
14
|
-
class q extends
|
|
14
|
+
class q extends b {
|
|
15
15
|
constructor() {
|
|
16
16
|
super();
|
|
17
17
|
/**
|
|
18
18
|
* Stores the ID generated in getTemplate() so onCreated() can reuse it.
|
|
19
19
|
* This avoids generating a new (different) ID in onCreated().
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
d(this, "_pendingBlockId", null);
|
|
22
22
|
}
|
|
23
23
|
getId() {
|
|
24
24
|
return h;
|
|
@@ -27,7 +27,7 @@ class q extends R {
|
|
|
27
27
|
return "recommendation-icon";
|
|
28
28
|
}
|
|
29
29
|
getBlockCompositionType() {
|
|
30
|
-
return
|
|
30
|
+
return R.CONTAINER;
|
|
31
31
|
}
|
|
32
32
|
getName() {
|
|
33
33
|
return this.api.translate("Recommendation Block");
|
|
@@ -38,7 +38,7 @@ class q extends R {
|
|
|
38
38
|
);
|
|
39
39
|
}
|
|
40
40
|
getSettingsPanelTitleHtml() {
|
|
41
|
-
return
|
|
41
|
+
return C(
|
|
42
42
|
h,
|
|
43
43
|
this.api.translate("Recommendation Block"),
|
|
44
44
|
this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Recommendation block and test your message to ensure it works properly.")
|
|
@@ -59,7 +59,7 @@ class q extends R {
|
|
|
59
59
|
*/
|
|
60
60
|
getTemplate() {
|
|
61
61
|
const t = this._generateNextId();
|
|
62
|
-
return this._pendingBlockId = t,
|
|
62
|
+
return this._pendingBlockId = t, D(t);
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
65
|
* Called when a new block is dropped into the template
|
|
@@ -72,22 +72,22 @@ class q extends R {
|
|
|
72
72
|
const e = this._getRecommendationId(t);
|
|
73
73
|
if (e !== null && e > 0)
|
|
74
74
|
return;
|
|
75
|
-
const
|
|
76
|
-
this._pendingBlockId = null, this._assignRecommendationId(t,
|
|
77
|
-
const { config:
|
|
75
|
+
const o = this._pendingBlockId ?? this._generateNextId();
|
|
76
|
+
this._pendingBlockId = null, this._assignRecommendationId(t, o);
|
|
77
|
+
const { config: n, wasFreshDrop: s } = c.initializeConfig(
|
|
78
78
|
this.api,
|
|
79
79
|
t,
|
|
80
|
-
{ recommendationId:
|
|
81
|
-
),
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
|
|
80
|
+
{ recommendationId: o }
|
|
81
|
+
), r = m();
|
|
82
|
+
if (r.setCurrentBlock(o), s) {
|
|
83
|
+
p(this.api);
|
|
84
|
+
const g = this._getBlockElement(t);
|
|
85
|
+
g && (f(this.api, g, !0), A({
|
|
86
86
|
currentNode: t,
|
|
87
87
|
documentModifier: this.api.getDocumentModifier()
|
|
88
88
|
}));
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
r.patchCurrentBlockConfig({ language: n.language }, { triggerRefetch: !1 });
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
93
|
* Called when the document changes or template is loaded
|
|
@@ -100,20 +100,20 @@ class q extends R {
|
|
|
100
100
|
if (!(!t || !("getNodeConfig" in t))) {
|
|
101
101
|
if (!this._getRecommendationId(t)) {
|
|
102
102
|
const e = this._generateNextId();
|
|
103
|
-
this._assignRecommendationId(t, e),
|
|
103
|
+
this._assignRecommendationId(t, e), c.hasConfig(t) && c.updateConfig(
|
|
104
104
|
this.api,
|
|
105
105
|
t,
|
|
106
106
|
{ recommendationId: e },
|
|
107
107
|
"Assign recommendation ID to legacy block"
|
|
108
108
|
);
|
|
109
109
|
}
|
|
110
|
-
|
|
110
|
+
c.needsMigration(t) && this._migrateFromLegacy(t);
|
|
111
111
|
try {
|
|
112
|
-
I || (
|
|
113
|
-
const e =
|
|
114
|
-
if (
|
|
115
|
-
const
|
|
116
|
-
|
|
112
|
+
I || (p(this.api), I = !0);
|
|
113
|
+
const e = c.getConfig(t), o = this._getBlockElement(t);
|
|
114
|
+
if (o) {
|
|
115
|
+
const n = !e.mobileLayoutEnabled;
|
|
116
|
+
N(o) !== n && f(this.api, o, n);
|
|
117
117
|
}
|
|
118
118
|
} catch {
|
|
119
119
|
}
|
|
@@ -127,7 +127,26 @@ class q extends R {
|
|
|
127
127
|
*/
|
|
128
128
|
onDelete(t) {
|
|
129
129
|
const e = this._getRecommendationId(t);
|
|
130
|
-
e &&
|
|
130
|
+
e && m().removeBlockState(e);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Lifecycle hook fired when Stripo's UI Duplicate button copies a block.
|
|
134
|
+
* Stripo passes an `HtmlNodeModifier` already targeting the cloned node;
|
|
135
|
+
* its mutations are committed when this method returns. We stamp a fresh
|
|
136
|
+
* `recommendation-id` on the clone and seed its blockStates entry from
|
|
137
|
+
* the source so the duplicate enters the DOM as a fully independent block
|
|
138
|
+
* — no shared id, no shared store, no API refetch flash.
|
|
139
|
+
*
|
|
140
|
+
* Stripo does NOT fire `onCreated` for blocks created via duplicate
|
|
141
|
+
* (per Block.d.ts:54-69 — `onCreated` is drag-and-drop only), so this
|
|
142
|
+
* hook is the sole production path for clone id assignment.
|
|
143
|
+
*/
|
|
144
|
+
onCopy(t) {
|
|
145
|
+
const e = t.getTargetNode(), o = this._getRecommendationId(e), n = this._generateNextId(), s = c.getConfig(e);
|
|
146
|
+
if (t.setAttribute(l, n.toString()).setNodeConfig({ ...s, recommendationId: n }), o !== null && o > 0) {
|
|
147
|
+
const r = m();
|
|
148
|
+
r.cloneBlockState(o, n), r.setCurrentBlock(n);
|
|
149
|
+
}
|
|
131
150
|
}
|
|
132
151
|
/**
|
|
133
152
|
* Generates the next unique recommendation ID by scanning all existing blocks
|
|
@@ -137,10 +156,10 @@ class q extends R {
|
|
|
137
156
|
let t = 0;
|
|
138
157
|
try {
|
|
139
158
|
const e = this.api.getDocumentRoot();
|
|
140
|
-
e && "querySelectorAll" in e && e.querySelectorAll(`.${
|
|
141
|
-
if ("getAttribute" in
|
|
142
|
-
const
|
|
143
|
-
|
|
159
|
+
e && "querySelectorAll" in e && e.querySelectorAll(`.${u}`).forEach((n) => {
|
|
160
|
+
if ("getAttribute" in n) {
|
|
161
|
+
const s = n.getAttribute(l), r = s ? parseInt(s) : 0;
|
|
162
|
+
r > t && (t = r);
|
|
144
163
|
}
|
|
145
164
|
});
|
|
146
165
|
} catch {
|
|
@@ -154,11 +173,11 @@ class q extends R {
|
|
|
154
173
|
* added classes via setAttribute.
|
|
155
174
|
*/
|
|
156
175
|
_assignRecommendationId(t, e) {
|
|
157
|
-
const
|
|
158
|
-
if (!
|
|
176
|
+
const o = this._getBlockElement(t);
|
|
177
|
+
if (!o)
|
|
159
178
|
return;
|
|
160
|
-
const
|
|
161
|
-
|
|
179
|
+
const n = this.api.getDocumentModifier();
|
|
180
|
+
n.modifyHtml(o).setAttribute(l, e.toString()), n.apply(new y(`Assign recommendation ID ${e}`));
|
|
162
181
|
}
|
|
163
182
|
/**
|
|
164
183
|
* Gets the recommendation-id from a block node
|
|
@@ -167,11 +186,11 @@ class q extends R {
|
|
|
167
186
|
const e = this._getBlockElement(t);
|
|
168
187
|
if (!e || !("getAttribute" in e))
|
|
169
188
|
return null;
|
|
170
|
-
const
|
|
171
|
-
if (!
|
|
189
|
+
const o = e.getAttribute(l);
|
|
190
|
+
if (!o)
|
|
172
191
|
return null;
|
|
173
|
-
const
|
|
174
|
-
return Number.isNaN(
|
|
192
|
+
const n = parseInt(o);
|
|
193
|
+
return Number.isNaN(n) ? null : n;
|
|
175
194
|
}
|
|
176
195
|
/**
|
|
177
196
|
* Gets the block element (the element with BLOCK_CLASS)
|
|
@@ -179,16 +198,16 @@ class q extends R {
|
|
|
179
198
|
_getBlockElement(t) {
|
|
180
199
|
if ("getAttribute" in t) {
|
|
181
200
|
const e = t.getAttribute("class");
|
|
182
|
-
if (e && e.includes(
|
|
201
|
+
if (e && e.includes(u))
|
|
183
202
|
return t;
|
|
184
203
|
}
|
|
185
|
-
return "querySelector" in t ? t.querySelector(`.${
|
|
204
|
+
return "querySelector" in t ? t.querySelector(`.${u}`) ?? null : null;
|
|
186
205
|
}
|
|
187
206
|
/**
|
|
188
207
|
* Migrate configuration from legacy format
|
|
189
208
|
*/
|
|
190
209
|
_migrateFromLegacy(t) {
|
|
191
|
-
|
|
210
|
+
c.migrateFromDataAttributes(this.api, t);
|
|
192
211
|
}
|
|
193
212
|
}
|
|
194
213
|
export {
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { getRecommendationFeedSourceMaps as
|
|
2
|
-
import { useRecommendationApi as
|
|
1
|
+
import { getRecommendationFeedSourceMaps as S, getOperatorOptions as R, PriceAttributes as C } from "../../../../enums/extensions/recommendationBlock.js";
|
|
2
|
+
import { useRecommendationApi as y } from "../../../../services/recommendationApi.js";
|
|
3
3
|
import { useConfigStore as G } from "../../../../stores/config.js";
|
|
4
4
|
import { defineStore as P } from "pinia";
|
|
5
|
-
import { DEFAULT_CARDS_IN_ROW as
|
|
6
|
-
import { EXCLUDED_ALGORITHM_IDS as
|
|
7
|
-
import { getDefaultProducts as
|
|
5
|
+
import { DEFAULT_CARDS_IN_ROW as D } from "../constants/layout.js";
|
|
6
|
+
import { EXCLUDED_ALGORITHM_IDS as F } from "../constants/defaultConfig.js";
|
|
7
|
+
import { getDefaultProducts as g } from "../templates/utils.js";
|
|
8
8
|
import { generateCompleteFilterQuery as b } from "../utils/filterUtil.js";
|
|
9
9
|
import { isFilterValid as w } from "../validation/filterSchema.js";
|
|
10
10
|
import { isConfigValid as v } from "../validation/requiredFields.js";
|
|
11
|
-
const h =
|
|
11
|
+
const h = y();
|
|
12
12
|
let m = null, u = null, d = null;
|
|
13
13
|
function k() {
|
|
14
14
|
return {
|
|
15
|
-
cardsInRow:
|
|
15
|
+
cardsInRow: D,
|
|
16
16
|
currencySettings: {
|
|
17
17
|
name: "USD",
|
|
18
18
|
value: "USD",
|
|
@@ -114,8 +114,8 @@ const N = () => ({
|
|
|
114
114
|
return [...new Set(t.map((e) => e.filterGroup))].sort((e, r) => e - r);
|
|
115
115
|
},
|
|
116
116
|
getActivePredictiveAlgorithms: (t) => {
|
|
117
|
-
const e =
|
|
118
|
-
return t.activePredictiveAlgorithms.filter((n) => !
|
|
117
|
+
const e = S(), r = [];
|
|
118
|
+
return t.activePredictiveAlgorithms.filter((n) => !F.includes(n)).forEach((n) => {
|
|
119
119
|
r.push(...e.filter((c) => c.id === n));
|
|
120
120
|
}), r.map((n) => ({
|
|
121
121
|
text: n.name,
|
|
@@ -133,7 +133,7 @@ const N = () => ({
|
|
|
133
133
|
getFilterList() {
|
|
134
134
|
return Object.values(this.filterList).map((t) => {
|
|
135
135
|
let e;
|
|
136
|
-
return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` :
|
|
136
|
+
return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : C.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
|
|
137
137
|
text: t.displayName,
|
|
138
138
|
value: e,
|
|
139
139
|
type: t.attributeType
|
|
@@ -174,6 +174,34 @@ const N = () => ({
|
|
|
174
174
|
this.currentRecommendationId = n.length > 0 ? n[0] : null;
|
|
175
175
|
}
|
|
176
176
|
},
|
|
177
|
+
/**
|
|
178
|
+
* Copies blockStates[fromId] into a new blockStates[toId] entry so a
|
|
179
|
+
* duplicated block immediately renders the source's products/filters
|
|
180
|
+
* without re-fetching from the API (SD-142352). No-op when the source
|
|
181
|
+
* was never selected (no entry in blockStates) — the caller falls back
|
|
182
|
+
* to setCurrentBlock's default initialization.
|
|
183
|
+
*/
|
|
184
|
+
cloneBlockState(t, e) {
|
|
185
|
+
const r = this.blockStates[t];
|
|
186
|
+
!r || this.blockStates[e] || (this.blockStates = {
|
|
187
|
+
...this.blockStates,
|
|
188
|
+
[e]: {
|
|
189
|
+
...r,
|
|
190
|
+
recommendationProducts: [...r.recommendationProducts],
|
|
191
|
+
recommendationConfigs: {
|
|
192
|
+
...r.recommendationConfigs,
|
|
193
|
+
id: e,
|
|
194
|
+
filters: r.recommendationConfigs.filters.map((n) => ({ ...n })),
|
|
195
|
+
productIds: [...r.recommendationConfigs.productIds],
|
|
196
|
+
customAttributes: [...r.recommendationConfigs.customAttributes],
|
|
197
|
+
recommendedProducts: [...r.recommendationConfigs.recommendedProducts],
|
|
198
|
+
currencySettings: { ...r.recommendationConfigs.currencySettings }
|
|
199
|
+
},
|
|
200
|
+
filterSnapshot: null,
|
|
201
|
+
filterSelectionDrawerStatus: !1
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
},
|
|
177
205
|
/**
|
|
178
206
|
* Marks a block as initialized (initial API data has been fetched).
|
|
179
207
|
* Automatically cleaned up when removeBlockState deletes the block entry.
|
|
@@ -426,7 +454,7 @@ const N = () => ({
|
|
|
426
454
|
},
|
|
427
455
|
async _doFetchProducts() {
|
|
428
456
|
var p;
|
|
429
|
-
const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e, n = r.filters.filter((l) => l.isValid), c = b(n), i = ((p =
|
|
457
|
+
const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e, n = r.filters.filter((l) => l.isValid), c = b(n), i = ((p = S().find((l) => l.key === r.strategy)) == null ? void 0 : p.path) || "", o = G(), s = parseInt(r.size) || 6, a = {
|
|
430
458
|
locale: r.language,
|
|
431
459
|
currency: r.currencySettings.value,
|
|
432
460
|
partnerName: o.partnerName,
|
|
@@ -442,10 +470,10 @@ const N = () => ({
|
|
|
442
470
|
f = [];
|
|
443
471
|
}
|
|
444
472
|
if (this.blockStates[t]) {
|
|
445
|
-
const l = f.length > 0 ? f :
|
|
473
|
+
const l = f.length > 0 ? f : g(s);
|
|
446
474
|
l.length < s ? this.blockStates[t].recommendationProducts = [
|
|
447
475
|
...l,
|
|
448
|
-
...
|
|
476
|
+
...g(s - l.length)
|
|
449
477
|
] : l.length > s ? this.blockStates[t].recommendationProducts = l.slice(0, s) : this.blockStates[t].recommendationProducts = l;
|
|
450
478
|
}
|
|
451
479
|
}
|
|
@@ -9,25 +9,25 @@ const o = [
|
|
|
9
9
|
getValue: (e) => e.currencySettings.value,
|
|
10
10
|
getAvailableOptions: (e) => e.currencyList.map((n) => n.text)
|
|
11
11
|
}
|
|
12
|
-
],
|
|
13
|
-
function
|
|
12
|
+
], l = "newsletter.recommendation-fill-required-fields";
|
|
13
|
+
function u(e, n) {
|
|
14
14
|
return o.filter((t) => {
|
|
15
15
|
var a;
|
|
16
16
|
if (t.condition && !t.condition(e))
|
|
17
17
|
return !1;
|
|
18
|
-
const
|
|
19
|
-
if (!
|
|
18
|
+
const i = t.getValue(e);
|
|
19
|
+
if (!i)
|
|
20
20
|
return !0;
|
|
21
|
-
const
|
|
22
|
-
return
|
|
21
|
+
const r = (a = t.getAvailableOptions) == null ? void 0 : a.call(t, n);
|
|
22
|
+
return r !== void 0 && !r.includes(i);
|
|
23
23
|
}).map((t) => t.key);
|
|
24
24
|
}
|
|
25
25
|
function s(e, n) {
|
|
26
|
-
return
|
|
26
|
+
return u(e, n).length === 0;
|
|
27
27
|
}
|
|
28
28
|
export {
|
|
29
29
|
o as REQUIRED_RECOMMENDATION_FIELDS,
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
l as RecommendationRequiredFieldsKey,
|
|
31
|
+
u as getInvalidFields,
|
|
32
32
|
s as isConfigValid
|
|
33
33
|
};
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Supports multiple block instances with unique recommendation-id attributes.
|
|
7
7
|
*/
|
|
8
8
|
import type { BlockId } from '@@/Types/extensions/block';
|
|
9
|
-
import type { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
|
|
9
|
+
import type { HtmlNodeModifier, ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
|
|
10
10
|
import { Block, BlockCompositionType } from '@stripoinc/ui-editor-extensions';
|
|
11
11
|
export declare const BLOCK_ID: BlockId;
|
|
12
12
|
export declare class RecommendationBlock extends Block {
|
|
@@ -55,6 +55,19 @@ export declare class RecommendationBlock extends Block {
|
|
|
55
55
|
* @param node - The block node being deleted
|
|
56
56
|
*/
|
|
57
57
|
onDelete(node: ImmutableHtmlNode): void;
|
|
58
|
+
/**
|
|
59
|
+
* Lifecycle hook fired when Stripo's UI Duplicate button copies a block.
|
|
60
|
+
* Stripo passes an `HtmlNodeModifier` already targeting the cloned node;
|
|
61
|
+
* its mutations are committed when this method returns. We stamp a fresh
|
|
62
|
+
* `recommendation-id` on the clone and seed its blockStates entry from
|
|
63
|
+
* the source so the duplicate enters the DOM as a fully independent block
|
|
64
|
+
* — no shared id, no shared store, no API refetch flash.
|
|
65
|
+
*
|
|
66
|
+
* Stripo does NOT fire `onCreated` for blocks created via duplicate
|
|
67
|
+
* (per Block.d.ts:54-69 — `onCreated` is drag-and-drop only), so this
|
|
68
|
+
* hook is the sole production path for clone id assignment.
|
|
69
|
+
*/
|
|
70
|
+
onCopy(modifier: HtmlNodeModifier): void;
|
|
58
71
|
/**
|
|
59
72
|
* Generates the next unique recommendation ID by scanning all existing blocks
|
|
60
73
|
* in the document and finding the maximum existing ID + 1.
|
|
@@ -216,6 +216,14 @@ 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;
|
|
219
227
|
/**
|
|
220
228
|
* Marks a block as initialized (initial API data has been fetched).
|
|
221
229
|
* Automatically cleaned up when removeBlockState deletes the block entry.
|
|
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,101 +1,106 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useHtmlCompiler as
|
|
3
|
-
import { DEFAULT_CURRENCY as
|
|
1
|
+
import { useActionsApi as E } from "../composables/useActionsApi.js";
|
|
2
|
+
import { useHtmlCompiler as P } from "../composables/useHtmlCompiler.js";
|
|
3
|
+
import { DEFAULT_CURRENCY as p, DEFAULT_NODE_CONFIG as u } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
4
|
+
import { BLOCK_ROOT_SELECTOR as R, CONTAINER_SELECTOR as N } from "../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
4
5
|
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
|
-
}),
|
|
6
|
+
import { DATA_ATTRIBUTES as y } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
|
|
7
|
+
import { parsePageList as O } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
|
|
8
|
+
import { useDynamicContentStore as L } from "../stores/dynamic-content.js";
|
|
9
|
+
import { useUnsubscribeStore as F } from "../stores/unsubscribe.js";
|
|
10
|
+
function I(s, t) {
|
|
11
|
+
const n = new DOMParser().parseFromString(s, "text/html").querySelectorAll(`[${y.PAGE_LIST}]`), c = [];
|
|
12
|
+
return n.forEach((r) => {
|
|
13
|
+
const o = r.getAttribute(y.PAGE_LIST);
|
|
14
|
+
o && c.push(...O(o));
|
|
15
|
+
}), t.filter((r) => c.includes(r));
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
function w(s) {
|
|
18
|
+
var c, r;
|
|
19
|
+
const t = (r = (c = document.querySelector("ui-editor")) == null ? void 0 : c.shadowRoot) == null ? void 0 : r.querySelector("iframe"), m = (t == null ? void 0 : t.contentDocument) ?? new DOMParser().parseFromString(s, "text/html"), n = /* @__PURE__ */ new Set();
|
|
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)
|
|
19
30
|
return;
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
var
|
|
23
|
-
const c =
|
|
31
|
+
const m = b();
|
|
32
|
+
a.forEach((n) => {
|
|
33
|
+
var f, g, d, i, S;
|
|
34
|
+
const c = n.getAttribute("recommendation-id"), r = c ? Number(c) : NaN;
|
|
24
35
|
if (!Number.isFinite(r))
|
|
25
36
|
return;
|
|
26
|
-
const
|
|
27
|
-
if (!
|
|
37
|
+
const o = n.getAttribute("esd-ext-config");
|
|
38
|
+
if (!o)
|
|
28
39
|
return;
|
|
29
40
|
let e;
|
|
30
41
|
try {
|
|
31
|
-
e = JSON.parse(
|
|
42
|
+
e = JSON.parse(o);
|
|
32
43
|
} catch {
|
|
33
44
|
return;
|
|
34
45
|
}
|
|
35
46
|
if (!e || typeof e != "object" || Array.isArray(e))
|
|
36
47
|
return;
|
|
37
|
-
const
|
|
38
|
-
strategy: e.strategy ??
|
|
39
|
-
language: e.language ??
|
|
40
|
-
size: e.size ??
|
|
48
|
+
const l = {
|
|
49
|
+
strategy: e.strategy ?? u.strategy,
|
|
50
|
+
language: e.language ?? u.language,
|
|
51
|
+
size: e.size ?? u.size,
|
|
41
52
|
// Spread the default arrays so each block gets a fresh reference
|
|
42
53
|
// instead of sharing the singleton in DEFAULT_NODE_CONFIG.
|
|
43
|
-
productIds: e.productIds ?? [...
|
|
44
|
-
filters: e.filters ?? [...
|
|
45
|
-
shuffleProducts: e.shuffleProducts ??
|
|
46
|
-
currencyCode: ((
|
|
47
|
-
currencyAlignment: ((
|
|
48
|
-
currencyDecimalCount: ((
|
|
49
|
-
currencyDecimalSeparator: ((
|
|
50
|
-
currencyThousandSeparator: ((
|
|
54
|
+
productIds: e.productIds ?? [...u.productIds],
|
|
55
|
+
filters: e.filters ?? [...u.filters],
|
|
56
|
+
shuffleProducts: e.shuffleProducts ?? u.shuffleProducts,
|
|
57
|
+
currencyCode: ((f = e.currency) == null ? void 0 : f.code) ?? p.code,
|
|
58
|
+
currencyAlignment: ((g = e.currency) == null ? void 0 : g.alignment) ?? p.alignment,
|
|
59
|
+
currencyDecimalCount: ((d = e.currency) == null ? void 0 : d.decimalCount) ?? p.decimalCount,
|
|
60
|
+
currencyDecimalSeparator: ((i = e.currency) == null ? void 0 : i.decimalSeparator) ?? p.decimalSeparator,
|
|
61
|
+
currencyThousandSeparator: ((S = e.currency) == null ? void 0 : S.thousandSeparator) ?? p.thousandSeparator
|
|
51
62
|
};
|
|
52
|
-
|
|
63
|
+
m.seedBlockUrlConfig(r, l);
|
|
53
64
|
});
|
|
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
|
-
}
|
|
62
65
|
}
|
|
63
|
-
const
|
|
64
|
-
const
|
|
66
|
+
const G = () => {
|
|
67
|
+
const s = L(), t = F(), { getCompiledEmail: a, getTemplateData: m } = E(), { compileHtml: n } = P();
|
|
65
68
|
return {
|
|
66
69
|
prepareTemplateDetails: async () => {
|
|
67
|
-
const { html: r, ampHtml:
|
|
70
|
+
const { html: r, ampHtml: o = "", ampErrors: e = [] } = await a({
|
|
68
71
|
minimize: !0,
|
|
69
72
|
resetDataSavedFlag: !1
|
|
70
|
-
}), { html:
|
|
71
|
-
|
|
72
|
-
const { compiledHtml:
|
|
73
|
+
}), { html: l, css: f, syncModulesIds: g = [] } = await m();
|
|
74
|
+
t.selectedUnsubscribePages.length && await t.fetchTemplates(), x(l);
|
|
75
|
+
const { compiledHtml: d, stats: i, appliedRules: S } = n(r), h = s.getSelectedDynamicContentList, A = b(), T = w(l), C = Object.fromEntries(
|
|
76
|
+
Object.entries(A.recommendationCampaignUrls).filter(([D]) => T.has(Number(D)))
|
|
77
|
+
);
|
|
73
78
|
return console.debug("HTML Compilation Stats:", {
|
|
74
|
-
originalSize:
|
|
75
|
-
compiledSize:
|
|
76
|
-
reduction: `${
|
|
77
|
-
appliedRules:
|
|
78
|
-
executionTime: `${
|
|
79
|
+
originalSize: i.originalSize,
|
|
80
|
+
compiledSize: i.compiledSize,
|
|
81
|
+
reduction: `${i.reductionPercentage.toFixed(2)}%`,
|
|
82
|
+
appliedRules: S,
|
|
83
|
+
executionTime: `${i.executionTime.toFixed(2)}ms`
|
|
79
84
|
}), {
|
|
80
85
|
dynamicContentList: h,
|
|
81
|
-
compiledHtml:
|
|
82
|
-
rawHtml:
|
|
83
|
-
css:
|
|
84
|
-
ampHtml:
|
|
86
|
+
compiledHtml: d,
|
|
87
|
+
rawHtml: l,
|
|
88
|
+
css: f,
|
|
89
|
+
ampHtml: o,
|
|
85
90
|
ampErrors: e,
|
|
86
|
-
modules:
|
|
91
|
+
modules: g.map(Number),
|
|
87
92
|
recommendation: {
|
|
88
|
-
campaignUrls:
|
|
93
|
+
campaignUrls: C,
|
|
89
94
|
configs: {}
|
|
90
95
|
},
|
|
91
96
|
unsubscribe: {
|
|
92
|
-
status:
|
|
93
|
-
config:
|
|
97
|
+
status: t.unsubscribePagesStatus,
|
|
98
|
+
config: I(d, t.selectedUnsubscribePages)
|
|
94
99
|
}
|
|
95
100
|
};
|
|
96
101
|
}
|
|
97
102
|
};
|
|
98
103
|
};
|
|
99
104
|
export {
|
|
100
|
-
|
|
105
|
+
G as useTemplatePreparation
|
|
101
106
|
};
|
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.6ed05e2",
|
|
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",
|
|
File without changes
|