@useinsider/guido 3.24.0 → 3.25.0-beta.2954d1a
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 +7 -1
- package/dist/@types/config/schemas.js +9 -7
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +79 -77
- package/dist/composables/useActionsApi.js +2 -2
- package/dist/composables/useEditorTrackingIds.js +49 -0
- package/dist/composables/useHtmlCompiler.js +2 -0
- package/dist/composables/useModuleRepair.js +14 -12
- package/dist/composables/useStripo.js +70 -70
- package/dist/config/compiler/htmlCompilerRules.js +14 -6
- package/dist/config/migrator/index.js +16 -15
- package/dist/config/migrator/itemsPriceFormatMigrator.js +20 -0
- package/dist/config/migrator/recommendation/inferLegacyConfig.js +133 -0
- package/dist/config/migrator/recommendationMigrator.js +78 -64
- package/dist/extensions/Blocks/Items/block.js +115 -77
- package/dist/extensions/Blocks/Items/constants/currency.js +59 -14
- package/dist/extensions/Blocks/Items/controls/blockBackground/index.js +11 -0
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +34 -23
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +62 -51
- package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +18 -17
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -31
- package/dist/extensions/Blocks/Items/controls/priceFormat.js +135 -0
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +141 -120
- package/dist/extensions/Blocks/Items/enums/controlEnums.js +2 -2
- package/dist/extensions/Blocks/Items/extension.js +15 -13
- package/dist/extensions/Blocks/Items/items.css.js +19 -0
- package/dist/extensions/Blocks/Items/settingsPanel.js +35 -25
- package/dist/extensions/Blocks/Items/template.js +250 -212
- package/dist/extensions/Blocks/Items/utils/priceFormatOps.js +185 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +10 -8
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +28 -24
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +23 -22
- package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +1 -0
- package/dist/extensions/Blocks/controlFactories.js +104 -104
- package/dist/guido.css +1 -1
- package/dist/package.json.js +2 -2
- package/dist/services/templateLibraryApi.js +39 -36
- package/dist/src/@types/config/schemas.d.ts +4 -0
- package/dist/src/composables/useConfig.d.ts +2 -0
- package/dist/src/composables/useEditorTrackingIds.d.ts +7 -0
- package/dist/src/composables/useStripo.d.ts +1 -1
- package/dist/src/config/migrator/index.d.ts +4 -1
- package/dist/src/config/migrator/itemsPriceFormatMigrator.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/inferLegacyConfig.d.ts +6 -0
- package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +1 -1
- package/dist/src/config/migrator/recommendationMigrator.d.ts +1 -5
- package/dist/src/extensions/Blocks/Items/block.d.ts +6 -9
- package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +32 -0
- package/dist/src/extensions/Blocks/Items/controls/blockBackground/index.d.ts +15 -0
- package/dist/src/extensions/Blocks/Items/controls/priceFormat.d.ts +24 -0
- package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +2 -0
- package/dist/src/extensions/Blocks/Items/template.d.ts +4 -1
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +3 -0
- package/dist/src/extensions/Blocks/Items/utils/priceFormatOps.d.ts +66 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +12 -0
- package/dist/src/extensions/Blocks/controlFactories.d.ts +1 -1
- package/dist/src/stores/config.d.ts +20 -0
- package/dist/src/utils/itemsCurrencyRepair.d.ts +5 -1
- package/dist/src/utils/linkTrackingIds.d.ts +19 -0
- package/dist/src/utils/trimHrefWhitespace.d.ts +5 -0
- package/dist/utils/itemsCurrencyRepair.js +29 -24
- package/dist/utils/linkTrackingIds.js +82 -48
- package/dist/utils/pairProductVariables.js +119 -99
- package/dist/utils/templatePreparation.js +30 -33
- package/dist/utils/trimHrefWhitespace.js +10 -0
- package/package.json +1 -1
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useBlocksConfig as
|
|
3
|
-
import { useConfig as
|
|
4
|
-
import { useCustomInterfaceAppearance as
|
|
5
|
-
import { useFullStoryBridge as
|
|
6
|
-
import { useModuleRepair as
|
|
7
|
-
import { useStripoEventHandler as
|
|
8
|
-
import { useStripoNotifications as
|
|
9
|
-
import { useToaster as
|
|
10
|
-
import { localePatch as
|
|
1
|
+
import { useActionsApi as N } from "./useActionsApi.js";
|
|
2
|
+
import { useBlocksConfig as j } from "./useBlocksConfig.js";
|
|
3
|
+
import { useConfig as z } from "./useConfig.js";
|
|
4
|
+
import { useCustomInterfaceAppearance as v } from "./useCustomInterfaceAppearance.js";
|
|
5
|
+
import { useFullStoryBridge as $ } from "./useFullStoryBridge.js";
|
|
6
|
+
import { useModuleRepair as G } from "./useModuleRepair.js";
|
|
7
|
+
import { useStripoEventHandler as X } from "./useStripoEventHandler.js";
|
|
8
|
+
import { useStripoNotifications as J } from "./useStripoNotifications.js";
|
|
9
|
+
import { useToaster as K } from "./useToaster.js";
|
|
10
|
+
import { localePatch as Q } from "../config/i18n/index.js";
|
|
11
11
|
import { en as B } from "../config/i18n/en/index.js";
|
|
12
|
-
import { ToasterTypeOptions as
|
|
13
|
-
import { useStripoApi as
|
|
14
|
-
import
|
|
15
|
-
import { useEditorStore as
|
|
16
|
-
import { buildMergeTagEntries as
|
|
17
|
-
import { getStripoRuntimeBaseUrl as
|
|
18
|
-
let d = null,
|
|
19
|
-
const
|
|
20
|
-
const { features: u, template: m, isFeatureEnabled: p } =
|
|
12
|
+
import { ToasterTypeOptions as W } from "../enums/toaster.js";
|
|
13
|
+
import { useStripoApi as Y } from "../services/stripoApi.js";
|
|
14
|
+
import Z from "../static/styles/customEditorStyle.css.js";
|
|
15
|
+
import { useEditorStore as T } from "../stores/editor.js";
|
|
16
|
+
import { buildMergeTagEntries as ee, flattenDynamicContentList as te } from "../utils/genericUtil.js";
|
|
17
|
+
import { getStripoRuntimeBaseUrl as oe } from "../utils/stripoRuntime.js";
|
|
18
|
+
let d = null, F = !1;
|
|
19
|
+
const ke = (t) => {
|
|
20
|
+
const { features: u, template: m, isFeatureEnabled: p } = z(), { handleError: f, showToaster: A } = K(), { getToken: P, getCustomFonts: R, getSyncModulesStatus: U } = Y(), { handleEvent: V } = X(), { handleModuleAdd: D } = G(), { getStripoBlocksConfig: I } = j(), { getStripoNotifications: L } = J(), g = () => d || (d = new Promise((n, a) => {
|
|
21
21
|
if (document.getElementById("UiEditorScript")) {
|
|
22
|
-
|
|
22
|
+
n();
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
const i =
|
|
25
|
+
const i = oe();
|
|
26
26
|
if (!i) {
|
|
27
|
-
|
|
27
|
+
a(
|
|
28
28
|
new Error("guido.stripo.version is not set in package.json. Please configure the Stripo version.")
|
|
29
29
|
);
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
}, document.body.appendChild(
|
|
32
|
+
const s = `${i}UIEditor.js`, e = document.createElement("script");
|
|
33
|
+
e.id = "UiEditorScript", e.type = "module", e.src = s, e.onload = () => {
|
|
34
|
+
F = !0, n();
|
|
35
|
+
}, e.onerror = () => {
|
|
36
|
+
e.remove(), a(new Error(`Failed to load Stripo UIEditor script from S3: ${s}`));
|
|
37
|
+
}, document.body.appendChild(e);
|
|
38
38
|
}), d.catch(() => {
|
|
39
39
|
d = null;
|
|
40
|
-
}), d),
|
|
41
|
-
var
|
|
42
|
-
const o =
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
40
|
+
}), d), q = async (n, a, i, s = [], e = !1, c = !1) => {
|
|
41
|
+
var w, k, b, _;
|
|
42
|
+
const o = T(), { html: S, css: y } = n, { baseBlocks: E, extensions: x } = await I();
|
|
43
|
+
t.mark("blocks_config_ready");
|
|
44
|
+
const h = ((w = u.value) == null ? void 0 : w.displayConditions) ?? !0, O = ((k = u.value) == null ? void 0 : k.modulesDisabled) ?? !1, C = c || (((b = m.value) == null ? void 0 : b.forceRecreate) ?? !1), H = "https://email-static.useinsider.com https://edge.fullstory.com https://rs.fullstory.com";
|
|
45
|
+
t.setTemplate({ html: S, css: y, forceRecreate: C }), v().importCss(), t.mark("init_editor"), await window.UIEditor.initEditor(
|
|
46
46
|
document.querySelector("#guido-editor"),
|
|
47
47
|
{
|
|
48
|
-
metadata:
|
|
49
|
-
html:
|
|
50
|
-
css:
|
|
51
|
-
forceRecreate:
|
|
48
|
+
metadata: a,
|
|
49
|
+
html: S,
|
|
50
|
+
css: y,
|
|
51
|
+
forceRecreate: C,
|
|
52
52
|
locale: "en",
|
|
53
53
|
undoButtonSelector: "#guido__undo-button",
|
|
54
54
|
redoButtonSelector: "#guido__redo-button",
|
|
@@ -58,12 +58,12 @@ const we = (e) => {
|
|
|
58
58
|
customAppearanceMergetags: !p("liquidSyntax"),
|
|
59
59
|
customAppearanceMergetagsBorderColor: "#f1f3fe",
|
|
60
60
|
customAppearanceMergetagsBackgroundColor: "#f1f3fe",
|
|
61
|
-
customViewStyles:
|
|
62
|
-
conditionsEnabled:
|
|
63
|
-
customConditionsEnabled:
|
|
61
|
+
customViewStyles: Z,
|
|
62
|
+
conditionsEnabled: h,
|
|
63
|
+
customConditionsEnabled: h,
|
|
64
64
|
enableXSSSecurity: !0,
|
|
65
|
-
modulesDisabled:
|
|
66
|
-
syncModulesEnabled:
|
|
65
|
+
modulesDisabled: O,
|
|
66
|
+
syncModulesEnabled: e,
|
|
67
67
|
messageSettingsEnabled: !0,
|
|
68
68
|
displayGmailAnnotations: !0,
|
|
69
69
|
displayHiddenPreheader: !1,
|
|
@@ -73,37 +73,37 @@ const we = (e) => {
|
|
|
73
73
|
copyPasteEnabled: !1,
|
|
74
74
|
selectElementAfterDrop: !0,
|
|
75
75
|
sameFontSizeForOutlook: !0,
|
|
76
|
-
allowedScriptSourceDomains:
|
|
77
|
-
...
|
|
76
|
+
allowedScriptSourceDomains: H,
|
|
77
|
+
...E ? { baseBlocks: E } : {},
|
|
78
78
|
editorFonts: {
|
|
79
79
|
showDefaultStandardFonts: !0,
|
|
80
80
|
showDefaultNotStandardFonts: !0,
|
|
81
|
-
customFonts:
|
|
81
|
+
customFonts: s
|
|
82
82
|
},
|
|
83
83
|
mergeTags: [
|
|
84
84
|
{
|
|
85
|
-
entries:
|
|
85
|
+
entries: ee(
|
|
86
86
|
i.preselectedDynamicContentList,
|
|
87
|
-
|
|
87
|
+
te((_ = m.value) == null ? void 0 : _.dynamicContentList),
|
|
88
88
|
p("liquidSyntax")
|
|
89
89
|
)
|
|
90
90
|
}
|
|
91
91
|
],
|
|
92
92
|
async onTokenRefreshRequest(r) {
|
|
93
93
|
try {
|
|
94
|
-
|
|
95
|
-
const l = await
|
|
96
|
-
|
|
94
|
+
t.mark("token_start");
|
|
95
|
+
const l = await P();
|
|
96
|
+
t.mark("token_end"), r(l);
|
|
97
97
|
} catch (l) {
|
|
98
98
|
f(l, "Failed to refresh token");
|
|
99
99
|
}
|
|
100
100
|
},
|
|
101
101
|
onTemplateLoaded() {
|
|
102
102
|
try {
|
|
103
|
-
const { activateCustomViewStyles: r, updateTimerInClonedTemplate: l } =
|
|
104
|
-
|
|
103
|
+
const { activateCustomViewStyles: r, updateTimerInClonedTemplate: l } = N(), { injectFullStory: M } = $();
|
|
104
|
+
v().importCss(), r(), M(), l(), i.onReady(), o.isStripoInitialized = !0, o.loadingStatus = !1, setTimeout(() => {
|
|
105
105
|
o.hasChanges = !1;
|
|
106
|
-
}, 1e3),
|
|
106
|
+
}, 1e3), t.markReady();
|
|
107
107
|
} catch (r) {
|
|
108
108
|
f(r, "Failed to load custom interface appearance");
|
|
109
109
|
}
|
|
@@ -120,9 +120,9 @@ const we = (e) => {
|
|
|
120
120
|
onDataChanged() {
|
|
121
121
|
o.hasChanges = !0, o.changeSeq += 1;
|
|
122
122
|
},
|
|
123
|
-
onEvent:
|
|
124
|
-
onModuleAdd:
|
|
125
|
-
notifications:
|
|
123
|
+
onEvent: V,
|
|
124
|
+
onModuleAdd: D,
|
|
125
|
+
notifications: L(),
|
|
126
126
|
// Stripo deselects the block on any click outside the canvas, so every surface
|
|
127
127
|
// that belongs to the block's own flow has to be listed here (SD-153273).
|
|
128
128
|
ignoreClickOutsideSelectors: [
|
|
@@ -132,29 +132,29 @@ const we = (e) => {
|
|
|
132
132
|
".in-modal-v2-wrapper",
|
|
133
133
|
".in-toasts-wrapper"
|
|
134
134
|
],
|
|
135
|
-
extensions:
|
|
136
|
-
localePatch:
|
|
135
|
+
extensions: x,
|
|
136
|
+
localePatch: Q
|
|
137
137
|
}
|
|
138
138
|
);
|
|
139
139
|
};
|
|
140
|
-
return { initPlugin: async (a,
|
|
141
|
-
const
|
|
140
|
+
return { initPlugin: async (n, a, i, s = !1) => {
|
|
141
|
+
const e = T();
|
|
142
142
|
try {
|
|
143
|
-
|
|
144
|
-
const [
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
t.mark("plugin_start"), t.setScriptPreloaded(F), await g(), t.mark("script_ready");
|
|
144
|
+
const [c, o] = await Promise.all([
|
|
145
|
+
R(),
|
|
146
|
+
U()
|
|
147
147
|
]);
|
|
148
|
-
|
|
148
|
+
t.mark("fonts_sync_ready"), e.syncModulesEnabled = o, await q(n, a, i, c, o, s);
|
|
149
149
|
} catch {
|
|
150
|
-
|
|
151
|
-
type:
|
|
150
|
+
e.loadingStatus = !1, A({
|
|
151
|
+
type: W.Error,
|
|
152
152
|
message: B["An error has occurred. Please report the error code to support."],
|
|
153
153
|
actionButton: {
|
|
154
154
|
text: B["Reload page"],
|
|
155
155
|
onClick: () => window.location.reload()
|
|
156
156
|
}
|
|
157
|
-
}),
|
|
157
|
+
}), t.markFailed();
|
|
158
158
|
}
|
|
159
159
|
}, preloadRuntime: () => {
|
|
160
160
|
g().catch(() => {
|
|
@@ -162,5 +162,5 @@ const we = (e) => {
|
|
|
162
162
|
} };
|
|
163
163
|
};
|
|
164
164
|
export {
|
|
165
|
-
|
|
165
|
+
ke as useStripo
|
|
166
166
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { stripFontTags as
|
|
2
|
-
|
|
1
|
+
import { stripFontTags as c } from "../../utils/stripFontTags.js";
|
|
2
|
+
import { trimHrefWhitespace as l } from "../../utils/trimHrefWhitespace.js";
|
|
3
|
+
const f = [
|
|
3
4
|
{
|
|
4
5
|
id: "fix-url-encoding-start",
|
|
5
6
|
description: "Replace {%22 with %7B%22 to fix URL encoding",
|
|
@@ -58,9 +59,16 @@ const d = [
|
|
|
58
59
|
id: "strip-font-tags",
|
|
59
60
|
description: 'Unwrap browser-translate-injected <font dir="auto"> tags, keeping inner content; other <font> elements are left intact.',
|
|
60
61
|
type: "custom",
|
|
61
|
-
processor: (e) =>
|
|
62
|
+
processor: (e) => c(e),
|
|
62
63
|
priority: 15
|
|
63
64
|
},
|
|
65
|
+
{
|
|
66
|
+
id: "trim-href-whitespace",
|
|
67
|
+
description: "Trim leading/trailing whitespace and from every href value",
|
|
68
|
+
type: "custom",
|
|
69
|
+
processor: (e) => l(e),
|
|
70
|
+
priority: 16
|
|
71
|
+
},
|
|
64
72
|
{
|
|
65
73
|
id: "remove-apty-iframe",
|
|
66
74
|
description: "Cleanup Apty Iframe Code",
|
|
@@ -157,8 +165,8 @@ const d = [
|
|
|
157
165
|
processor: (e) => {
|
|
158
166
|
const t = (i) => i.toString(16).padStart(2, "0");
|
|
159
167
|
return e.replace(/rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/gi, (i, o, n, r) => {
|
|
160
|
-
const [s, a,
|
|
161
|
-
return s > 255 || a > 255 ||
|
|
168
|
+
const [s, a, p] = [Number(o), Number(n), Number(r)];
|
|
169
|
+
return s > 255 || a > 255 || p > 255 ? i : `#${t(s)}${t(a)}${t(p)}`;
|
|
162
170
|
}).replace(/#([0-9a-f])\1([0-9a-f])\2([0-9a-f])\3\b/gi, "#$1$2$3");
|
|
163
171
|
},
|
|
164
172
|
priority: 44
|
|
@@ -200,5 +208,5 @@ const d = [
|
|
|
200
208
|
}
|
|
201
209
|
];
|
|
202
210
|
export {
|
|
203
|
-
|
|
211
|
+
f as defaultHtmlCompilerRules
|
|
204
212
|
};
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { migrateCheckbox as
|
|
2
|
-
import { migrateCouponBlock as
|
|
3
|
-
import { migrateFullStoryScripts as
|
|
4
|
-
import { migrateItemsBlock as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { migrateCheckbox as e } from "./checkboxMigrator.js";
|
|
2
|
+
import { migrateCouponBlock as a } from "./couponBlockMigrator.js";
|
|
3
|
+
import { migrateFullStoryScripts as c } from "./fullStoryScriptMigrator.js";
|
|
4
|
+
import { migrateItemsBlock as g } from "./itemsBlockMigrator.js";
|
|
5
|
+
import { migrateItemsPriceFormat as n } from "./itemsPriceFormatMigrator.js";
|
|
6
|
+
import { migrateProductNameLink as p } from "./productNameLinkMigrator.js";
|
|
7
|
+
import { migrateRadioButton as f } from "./radioButtonMigrator.js";
|
|
8
|
+
import { migrateRecommendation as l } from "./recommendationMigrator.js";
|
|
9
|
+
import { migrateRecommendationPartnerScope as d } from "./recommendationPartnerMigrator.js";
|
|
10
|
+
import { migrateRecommendationTitle as s } from "./recommendationTitleMigrator.js";
|
|
11
|
+
import { migrateSocialIcons as k } from "./socialIconMigrator.js";
|
|
12
|
+
import { migrateUnsubscribe as P } from "./unsubscribeMigrator.js";
|
|
13
|
+
const H = async (t, i = {}, r, o) => {
|
|
14
|
+
let m = t;
|
|
15
|
+
return m = e(m), m = f(m), m = await P(m), m = a(m), m = l(m, i), r && (m = d(m, r)), m = s(m), m = g(m), o != null && o.itemsPriceFormatting && (m = n(m)), m = p(m), m = k(m), m = c(m), m;
|
|
15
16
|
};
|
|
16
17
|
export {
|
|
17
|
-
|
|
18
|
+
H as migrate
|
|
18
19
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ITEMS_PRICE_FORMAT_ATTR as e } from "../../extensions/Blocks/Items/constants/currency.js";
|
|
2
|
+
import { applyPriceFormatOpsToElement as o, planPriceFormatOps as n, snapshotPriceFormatFromElement as c } from "../../extensions/Blocks/Items/utils/priceFormatOps.js";
|
|
3
|
+
import { protectLiquid as i, restoreLiquid as s } from "../../utils/liquidProtection.js";
|
|
4
|
+
const m = `td.ins-product-td.items-block-v2:not([${e.DECIMAL_COUNT}])`, a = (r) => o(
|
|
5
|
+
r,
|
|
6
|
+
n(c(r), { convertLegacy: !0 })
|
|
7
|
+
);
|
|
8
|
+
function T(r) {
|
|
9
|
+
if (typeof r != "string" || !r.includes("ins-product-td"))
|
|
10
|
+
return r;
|
|
11
|
+
try {
|
|
12
|
+
const t = new DOMParser().parseFromString(i(r), "text/html");
|
|
13
|
+
return Array.from(t.querySelectorAll(m)).map(a).includes(!0) ? s(t.documentElement.outerHTML) : r;
|
|
14
|
+
} catch (t) {
|
|
15
|
+
return console.error("ItemsPriceFormatMigrator failed:", t), r;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
T as migrateItemsPriceFormat
|
|
20
|
+
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { MAX_PRODUCTS_PER_ROW as _ } from "../../../extensions/Blocks/Recommendation/constants/layout.js";
|
|
2
|
+
const T = "td.product-card", x = '[class*="ext-product-"]', d = ".ext-ins-attr p[product-attr]", y = ".ext-ins-attr", S = ["font-family", "font-size", "font-weight", "font-style"], a = [
|
|
3
|
+
["p_image", ".ext-product-image"],
|
|
4
|
+
["p_name", ".ext-product-name"],
|
|
5
|
+
["p_price", ".ext-product-price"],
|
|
6
|
+
["p_original_price", ".ext-product-original-price"],
|
|
7
|
+
["p_omnibus_price", ".ext-product-omnibus-price", !0],
|
|
8
|
+
["p_omnibus_discount", ".ext-product-omnibus-discount", !0],
|
|
9
|
+
["p_button", ".ext-product-button"]
|
|
10
|
+
], l = a.map(([, t]) => t).join(", ");
|
|
11
|
+
function s(t, e) {
|
|
12
|
+
const n = new RegExp(`(?:^|;)\\s*${e}\\s*:\\s*([^;]+)`, "i"), r = ((t == null ? void 0 : t.getAttribute("style")) ?? "").match(n);
|
|
13
|
+
return (r == null ? void 0 : r[1].trim()) || void 0;
|
|
14
|
+
}
|
|
15
|
+
function p(t) {
|
|
16
|
+
return /^none\b/.test(s(t, "display") ?? "");
|
|
17
|
+
}
|
|
18
|
+
function h(t) {
|
|
19
|
+
return p(t) || p(t.closest("tr"));
|
|
20
|
+
}
|
|
21
|
+
function f(t) {
|
|
22
|
+
const e = {};
|
|
23
|
+
return S.forEach((n) => {
|
|
24
|
+
const r = s(t, n);
|
|
25
|
+
r && (e[n] = r);
|
|
26
|
+
}), Object.keys(e).length > 0 ? e : void 0;
|
|
27
|
+
}
|
|
28
|
+
function g(t) {
|
|
29
|
+
return Object.keys(t).length > 0 ? t : void 0;
|
|
30
|
+
}
|
|
31
|
+
function m(t) {
|
|
32
|
+
const e = t.querySelector("p") ?? t, n = f(e), r = s(e, "color"), i = t.getAttribute("align") ?? s(e, "text-align"), o = s(e, "line-height");
|
|
33
|
+
return g({
|
|
34
|
+
...n ? { textStyle: n } : {},
|
|
35
|
+
...r ? { textColor: { color: r } } : {},
|
|
36
|
+
...i ? { textAlign: { align: i } } : {},
|
|
37
|
+
...o ? { textLineSpacing: { lineSpacing: o } } : {}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function A(t) {
|
|
41
|
+
var u;
|
|
42
|
+
const e = t.querySelector("a") ?? t, n = (u = e.textContent) == null ? void 0 : u.trim(), r = s(e, "background-color") ?? s(e, "background"), i = s(e, "color"), o = f(e), c = t.getAttribute("align");
|
|
43
|
+
return g({
|
|
44
|
+
...n ? { buttonText: { text: n } } : {},
|
|
45
|
+
...r ? { buttonColor: { color: r } } : {},
|
|
46
|
+
...i ? { textButtonColor: { color: i } } : {},
|
|
47
|
+
...o ? { buttonStyle: o } : {},
|
|
48
|
+
...c ? { buttonAlign: { align: c } } : {}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function C(t) {
|
|
52
|
+
const e = t.querySelector("img"), n = Number(e == null ? void 0 : e.getAttribute("width")), r = Number(e == null ? void 0 : e.getAttribute("height")), i = { ...n > 0 ? { width: n } : {}, ...r > 0 ? { height: r } : {} };
|
|
53
|
+
return Object.keys(i).length > 0 ? { imageSize: i } : void 0;
|
|
54
|
+
}
|
|
55
|
+
function R(t, e) {
|
|
56
|
+
switch (t) {
|
|
57
|
+
case "p_image":
|
|
58
|
+
return C(e);
|
|
59
|
+
case "p_button":
|
|
60
|
+
return A(e);
|
|
61
|
+
default:
|
|
62
|
+
return m(e);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function L(t, e) {
|
|
66
|
+
const n = Array.from(t.querySelectorAll(`[class*="show-recommendation-${e}-"]`));
|
|
67
|
+
return n.length > 0 ? n : Array.from(t.querySelectorAll(T));
|
|
68
|
+
}
|
|
69
|
+
function w(t, e) {
|
|
70
|
+
const n = (o) => e.filter((c) => o.contains(c)).length;
|
|
71
|
+
let r = e[0].parentElement;
|
|
72
|
+
for (; r && r !== t && n(r) < 2; )
|
|
73
|
+
r = r.parentElement;
|
|
74
|
+
if (!r || r === t)
|
|
75
|
+
return e.length === 1 ? 1 : void 0;
|
|
76
|
+
const i = r.tagName === "TBODY" || r.tagName === "TABLE" ? 1 : n(r);
|
|
77
|
+
return Math.min(i, _);
|
|
78
|
+
}
|
|
79
|
+
function v(t) {
|
|
80
|
+
const e = Array.from(t.querySelectorAll(x)).filter((n) => !n.matches(l) && !n.querySelector(l)).flatMap((n) => Array.from(n.classList).filter((r) => r.startsWith("ext-product-")));
|
|
81
|
+
return [...new Set(e)];
|
|
82
|
+
}
|
|
83
|
+
function O(t, e, n) {
|
|
84
|
+
const r = t.closest(y) ?? t, i = m(r);
|
|
85
|
+
return {
|
|
86
|
+
variable: `p_attribute_${e}`,
|
|
87
|
+
variableType: "p_attribute",
|
|
88
|
+
value: t.getAttribute("product-attr") ?? "",
|
|
89
|
+
positionIdx: n,
|
|
90
|
+
hidden: h(r),
|
|
91
|
+
...i ? { theme: i } : {}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function N(t) {
|
|
95
|
+
const e = /* @__PURE__ */ new Set(), n = [];
|
|
96
|
+
let r = 0;
|
|
97
|
+
t.querySelectorAll(`${l}, ${d}`).forEach((o) => {
|
|
98
|
+
if (o.matches(d)) {
|
|
99
|
+
n.push(O(o, r, n.length)), r += 1;
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const c = a.find(
|
|
103
|
+
([b, E]) => !e.has(b) && o.matches(E)
|
|
104
|
+
);
|
|
105
|
+
if (!c)
|
|
106
|
+
return;
|
|
107
|
+
const u = R(c[0], o);
|
|
108
|
+
e.add(c[0]), n.push({
|
|
109
|
+
variable: c[0],
|
|
110
|
+
positionIdx: n.length,
|
|
111
|
+
hidden: h(o),
|
|
112
|
+
...u ? { theme: u } : {}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
const i = a.filter(([o, , c]) => !c && !e.has(o)).map(([o]) => ({ variable: o, hidden: !0 }));
|
|
116
|
+
return [...n, ...i];
|
|
117
|
+
}
|
|
118
|
+
function q(t, e) {
|
|
119
|
+
const n = L(t, e);
|
|
120
|
+
if (n.length === 0)
|
|
121
|
+
return null;
|
|
122
|
+
const r = v(n[0]);
|
|
123
|
+
return r.length > 0 ? (console.warn(
|
|
124
|
+
`[RecommendationMigrator] Block id=${e} — legacy card cells the rebuild cannot map: ${r.join(", ")}`
|
|
125
|
+
), null) : {
|
|
126
|
+
totalCount: n.length,
|
|
127
|
+
rowCount: w(t, n),
|
|
128
|
+
composition: { variables: N(n[0]) }
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
export {
|
|
132
|
+
q as inferLegacyConfig
|
|
133
|
+
};
|
|
@@ -1,59 +1,71 @@
|
|
|
1
1
|
import { BlockId as b } from "../../enums/block.js";
|
|
2
|
-
import { DEFAULT_NODE_CONFIG as
|
|
3
|
-
import { ATTR_RECOMMENDATION_TITLE as
|
|
4
|
-
import { useTemplateStore as
|
|
5
|
-
import { mapComposition as
|
|
6
|
-
import { isPriceOnNextLine as
|
|
7
|
-
import { buildBlockHtml as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
import { DEFAULT_NODE_CONFIG as h } from "../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
3
|
+
import { ATTR_RECOMMENDATION_TITLE as y } from "../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
4
|
+
import { useTemplateStore as x } from "../../stores/template.js";
|
|
5
|
+
import { mapComposition as S } from "./recommendation/compositionMapper.js";
|
|
6
|
+
import { isPriceOnNextLine as L, extractCurrencyFromBlock as A, isOldPriceFirst as B, withRenderedTextTheme as E, extractTitleText as w, hasEmptyTitle as O, hasVisibleTitle as N, extractCardBgColor as P, isPartnerManagedBlock as H, extractRenderedBlockPadding as I } from "./recommendation/extractors.js";
|
|
7
|
+
import { buildBlockHtml as _ } from "./recommendation/htmlBuilder.js";
|
|
8
|
+
import { inferLegacyConfig as F } from "./recommendation/inferLegacyConfig.js";
|
|
9
|
+
import { parseRecommendationId as $, parseLegacyConfig as k } from "./recommendation/parseLegacyConfig.js";
|
|
10
|
+
import { mapSettings as D } from "./recommendation/settingsMapper.js";
|
|
11
|
+
import { mapBlockPadding as G } from "./recommendation/themeMapper.js";
|
|
12
|
+
const T = ":not(.recommendation-block-v2):not([esd-ext-config])", U = `td[class*="ins-recommendation-v3-block-"]${T}, td.product-block[esd-handler-name*="EmailRecommendationV3"]${T}`, V = "esd-dev-product-config";
|
|
13
|
+
function q(o) {
|
|
14
|
+
return !!(o != null && o.strategy);
|
|
15
|
+
}
|
|
16
|
+
function K(o, e, c) {
|
|
17
|
+
var g, f, u;
|
|
18
|
+
const t = $(e);
|
|
15
19
|
if (t === null)
|
|
16
20
|
return console.warn(
|
|
17
21
|
"[RecommendationMigrator] Skipping block — missing/invalid `ins-recommendation-v3-campaign-id`"
|
|
18
22
|
), !1;
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
23
|
+
const s = e.hasAttribute(V), m = c[String(t)];
|
|
24
|
+
if (!s && !q(m))
|
|
25
|
+
return console.warn(
|
|
26
|
+
`[RecommendationMigrator] Skipping block id=${t} — no \`esd-dev-product-config\` and no recommendationConfigs strategy to rebuild from`
|
|
27
|
+
), !1;
|
|
28
|
+
const i = s ? k(e) : F(e, t);
|
|
29
|
+
if (!i)
|
|
21
30
|
return console.warn(
|
|
22
|
-
`[RecommendationMigrator] Aborting block id=${t} — \`esd-dev-product-config\`
|
|
31
|
+
`[RecommendationMigrator] Aborting block id=${t} — \`esd-dev-product-config\` empty or unparsable, or the rendered markup could not be inferred`
|
|
23
32
|
), !1;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
s || console.info(
|
|
34
|
+
`[RecommendationMigrator] Block id=${t} has no \`esd-dev-product-config\` — rebuilt from its rendered markup`
|
|
35
|
+
);
|
|
36
|
+
const r = m ?? {}, n = {
|
|
37
|
+
...r,
|
|
38
|
+
currencySettings: r.currencySettings ?? A(e),
|
|
39
|
+
isPriceMovedToNextLine: r.isPriceMovedToNextLine ?? L(e)
|
|
40
|
+
}, d = D(n, i, t), a = S(
|
|
41
|
+
E((g = i.composition) == null ? void 0 : g.variables, e),
|
|
42
|
+
{ oldPriceFirst: B(e) }
|
|
43
|
+
), C = w(e);
|
|
44
|
+
O(e) ? a.visibility[y] = !1 : a.titleVariable || (a.visibility[y] = N(e));
|
|
45
|
+
const v = P(e), M = {
|
|
46
|
+
...d,
|
|
35
47
|
strategyId: "",
|
|
36
|
-
composition:
|
|
37
|
-
visibility:
|
|
38
|
-
previousTitleHtml:
|
|
39
|
-
textTrimming:
|
|
40
|
-
},
|
|
48
|
+
composition: a.composition,
|
|
49
|
+
visibility: a.visibility,
|
|
50
|
+
previousTitleHtml: h.previousTitleHtml,
|
|
51
|
+
textTrimming: a.anyTextTrimming
|
|
52
|
+
}, l = H(e), R = `
|
|
41
53
|
<table>
|
|
42
54
|
<tbody>
|
|
43
55
|
<tr>
|
|
44
56
|
<td class="esd-structure" align="left">
|
|
45
57
|
<table width="100%" cellpadding="0" cellspacing="0">
|
|
46
58
|
<tbody>
|
|
47
|
-
<tr>${
|
|
48
|
-
nodeConfig:
|
|
49
|
-
composition:
|
|
50
|
-
cardBg:
|
|
51
|
-
titleText:
|
|
59
|
+
<tr>${_({
|
|
60
|
+
nodeConfig: M,
|
|
61
|
+
composition: a,
|
|
62
|
+
cardBg: v,
|
|
63
|
+
titleText: C,
|
|
52
64
|
legacyId: e.getAttribute("id") ?? void 0,
|
|
53
65
|
legacyBgColor: e.getAttribute("bgcolor") ?? void 0,
|
|
54
|
-
preserveInnerHtml:
|
|
55
|
-
skipCompile:
|
|
56
|
-
blockPadding:
|
|
66
|
+
preserveInnerHtml: l ? e.innerHTML : void 0,
|
|
67
|
+
skipCompile: l,
|
|
68
|
+
blockPadding: G(((u = (f = i.theme) == null ? void 0 : f.blockPadding) == null ? void 0 : u.desktop) ?? I(e))
|
|
57
69
|
})}</tr>
|
|
58
70
|
</tbody>
|
|
59
71
|
</table>
|
|
@@ -61,40 +73,42 @@ function $(c, e, m) {
|
|
|
61
73
|
</tr>
|
|
62
74
|
</tbody>
|
|
63
75
|
</table>
|
|
64
|
-
`,
|
|
65
|
-
return !
|
|
76
|
+
`, p = o.parseFromString(R, "text/html").querySelector("td.esd-structure");
|
|
77
|
+
return !p || !e.parentNode ? (console.warn(
|
|
66
78
|
`[RecommendationMigrator] Aborting block id=${t} — failed to construct new HTML element`
|
|
67
|
-
), !1) : (e.parentNode.replaceChild(
|
|
79
|
+
), !1) : (e.parentNode.replaceChild(p, e), !0);
|
|
68
80
|
}
|
|
69
|
-
function
|
|
70
|
-
const
|
|
81
|
+
function ne(o, e = {}) {
|
|
82
|
+
const c = new DOMParser();
|
|
71
83
|
let t;
|
|
72
84
|
try {
|
|
73
|
-
t =
|
|
74
|
-
} catch (
|
|
75
|
-
return console.error("[RecommendationMigrator] Failed to parse template:",
|
|
85
|
+
t = c.parseFromString(o, "text/html");
|
|
86
|
+
} catch (r) {
|
|
87
|
+
return console.error("[RecommendationMigrator] Failed to parse template:", r), o;
|
|
76
88
|
}
|
|
77
|
-
const
|
|
89
|
+
const s = Array.from(t.querySelectorAll(U)), m = s.filter((r) => {
|
|
90
|
+
var n;
|
|
91
|
+
return !((n = r.parentElement) != null && n.closest(".recommendation-block-v2")) && !s.some((d) => d !== r && d.contains(r));
|
|
92
|
+
});
|
|
93
|
+
let i = 0;
|
|
94
|
+
m.forEach((r) => {
|
|
95
|
+
try {
|
|
96
|
+
K(c, r, e) && (i += 1);
|
|
97
|
+
} catch (n) {
|
|
98
|
+
console.error("[RecommendationMigrator] Unexpected error migrating block:", n);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
78
101
|
try {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
...
|
|
82
|
-
[b.Recommendation]:
|
|
102
|
+
x().$patch((n) => {
|
|
103
|
+
n.migrations = {
|
|
104
|
+
...n.migrations,
|
|
105
|
+
[b.Recommendation]: i
|
|
83
106
|
};
|
|
84
107
|
});
|
|
85
108
|
} catch {
|
|
86
109
|
}
|
|
87
|
-
|
|
88
|
-
return c;
|
|
89
|
-
let o = 0;
|
|
90
|
-
return r.forEach((n) => {
|
|
91
|
-
try {
|
|
92
|
-
$(m, n, e) && (o += 1);
|
|
93
|
-
} catch (a) {
|
|
94
|
-
console.error("[RecommendationMigrator] Unexpected error migrating block:", a);
|
|
95
|
-
}
|
|
96
|
-
}), o > 0 && console.info(`[RecommendationMigrator] Migrated ${o} legacy Recommendation block(s)`), t.documentElement.outerHTML;
|
|
110
|
+
return i === 0 ? o : (console.info(`[RecommendationMigrator] Migrated ${i} legacy Recommendation block(s)`), t.documentElement.outerHTML);
|
|
97
111
|
}
|
|
98
112
|
export {
|
|
99
|
-
|
|
113
|
+
ne as migrateRecommendation
|
|
100
114
|
};
|