@useinsider/guido 3.19.0 → 3.20.0-beta.05ce01c
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 +22 -3
- package/dist/@types/config/schemas.js +76 -53
- package/dist/components/Guido.vue.js +4 -4
- package/dist/components/Guido.vue2.js +105 -89
- package/dist/components/organisms/AutoSaveController.vue2.js +10 -8
- package/dist/components/organisms/base/AuthErrorModal.vue.js +18 -0
- package/dist/components/organisms/base/AuthErrorModal.vue2.js +42 -0
- package/dist/components/organisms/base/Toaster.vue2.js +13 -12
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +13 -11
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +78 -57
- package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js +18 -0
- package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue2.js +25 -0
- package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue2.js +28 -42
- package/dist/components/organisms/header/EditorActions.vue.js +2 -2
- package/dist/components/organisms/header/EditorActions.vue2.js +83 -48
- package/dist/components/organisms/header/LeftSlot.vue.js +5 -5
- package/dist/components/organisms/header/LeftSlot.vue2.js +16 -12
- package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +28 -24
- package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.js +21 -0
- package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue2.js +46 -0
- package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.js +21 -0
- package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue2.js +47 -0
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +20 -0
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue2.js +50 -0
- package/dist/components/wrappers/WpDrawer.vue.js +9 -7
- package/dist/components/wrappers/WpDrawer.vue2.js +1 -1
- package/dist/components/wrappers/WpModal.vue.js +1 -1
- package/dist/components/wrappers/WpModal.vue2.js +4 -3
- package/dist/composables/useActionsApi.js +52 -47
- package/dist/composables/useAuthError.js +52 -0
- package/dist/composables/useAutoSave.js +44 -42
- package/dist/composables/useCodeEditorApi.js +23 -9
- package/dist/composables/useCortexBlueprintBridge.js +122 -54
- package/dist/composables/useCustomInterfaceAppearance.js +65 -51
- package/dist/composables/useEmailTemplateApplier.js +111 -50
- package/dist/composables/useHtmlCompiler.js +37 -26
- package/dist/composables/useHtmlValidator.js +89 -82
- package/dist/composables/useHttp.js +64 -54
- package/dist/composables/useLegacyStrategyConversion.js +65 -0
- package/dist/composables/useRecommendation.js +40 -35
- package/dist/composables/useSave.js +93 -45
- package/dist/composables/useSaveValidation.js +284 -0
- package/dist/composables/useSaveValidationRollout.js +20 -0
- package/dist/composables/useStripo.js +43 -39
- package/dist/composables/useToaster.js +18 -22
- package/dist/composables/useTranslations.js +3 -2
- package/dist/composables/useVersionHistoryApi.js +33 -24
- package/dist/composables/validators/useCouponBlockValidator.js +24 -21
- package/dist/composables/validators/useLiquidValidator.js +15 -15
- package/dist/composables/validators/useUnsubscribeBlockValidator.js +34 -27
- package/dist/config/migrator/index.js +14 -13
- package/dist/config/migrator/itemsBlockMigrator.js +236 -248
- package/dist/config/migrator/recommendationMigrator.js +28 -21
- package/dist/config/migrator/recommendationPartnerMigrator.js +56 -0
- package/dist/enums/extensions/recommendationBlock.js +51 -34
- package/dist/enums/save-validation.js +4 -0
- package/dist/extensions/Blocks/Items/constants/cardLayout.js +20 -0
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +18 -17
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +114 -105
- package/dist/extensions/Blocks/Items/enums/productEnums.js +14 -9
- package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +11 -9
- package/dist/extensions/Blocks/Items/template.js +219 -204
- package/dist/extensions/Blocks/Recommendation/block.js +65 -45
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +21 -20
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +103 -90
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +150 -52
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +74 -74
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +274 -92
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js +42 -0
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +26 -16
- package/dist/extensions/Blocks/Recommendation/utils/partnerCustomizations.js +3 -1
- package/dist/extensions/Blocks/Recommendation/utils/partnerScope.js +25 -0
- package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +24 -0
- package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +21 -12
- package/dist/guido.css +1 -1
- package/dist/services/recommendationApi.js +46 -37
- package/dist/services/settingsApi.js +11 -0
- package/dist/src/@types/config/schemas.d.ts +36 -0
- package/dist/src/@types/save-validation.d.ts +19 -0
- package/dist/src/components/Guido.vue.d.ts +17 -1
- package/dist/src/components/organisms/base/AuthErrorModal.vue.d.ts +2 -0
- package/dist/src/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.d.ts +2 -0
- package/dist/src/components/organisms/header/EditorActions.vue.d.ts +17 -1
- package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +17 -1
- package/dist/src/components/organisms/header/RightSlot.vue.d.ts +17 -1
- package/dist/src/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.d.ts +2 -0
- package/dist/src/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.d.ts +2 -0
- package/dist/src/components/organisms/validation/ValidationErrorDrawer.vue.d.ts +2 -0
- package/dist/src/components/wrappers/WpDrawer.vue.d.ts +4 -3
- package/dist/src/components/wrappers/WpModal.vue.d.ts +5 -1
- package/dist/src/composables/useAuthError.d.ts +12 -0
- package/dist/src/composables/useAutoSave.d.ts +4 -1
- package/dist/src/composables/useConfig.d.ts +8 -0
- package/dist/src/composables/useCortexBlueprintBridge.d.ts +2 -3
- package/dist/src/composables/useEmailTemplateApplier.d.ts +18 -5
- package/dist/src/composables/useGuidoActions.d.ts +2 -0
- package/dist/src/composables/useHtmlValidator.d.ts +21 -0
- package/dist/src/composables/useHttp.d.ts +2 -0
- package/dist/src/composables/useLegacyStrategyConversion.d.ts +3 -0
- package/dist/src/composables/useSave.d.ts +6 -1
- package/dist/src/composables/useSaveValidation.d.ts +6 -0
- package/dist/src/composables/useSaveValidationRollout.d.ts +4 -0
- package/dist/src/composables/validators/useCouponBlockValidator.d.ts +3 -0
- package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +10 -0
- package/dist/src/config/migrator/index.d.ts +2 -1
- package/dist/src/config/migrator/recommendationPartnerMigrator.d.ts +19 -0
- package/dist/src/enums/extensions/recommendationBlock.d.ts +7 -1
- package/dist/src/enums/save-validation.d.ts +27 -0
- package/dist/src/extensions/Blocks/Items/constants/cardLayout.d.ts +44 -0
- package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +3 -0
- package/dist/src/extensions/Blocks/Items/template.d.ts +19 -0
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +10 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +10 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +7 -2
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +162 -1
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.d.ts +32 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/partnerScope.d.ts +33 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +14 -0
- package/dist/src/extensions/Blocks/Recommendation/validation/requiredFields.d.ts +4 -0
- package/dist/src/mock/cortexChatStore.d.ts +12 -0
- package/dist/src/services/recommendationApi.d.ts +2 -1
- package/dist/src/services/settingsApi.d.ts +6 -0
- package/dist/src/stores/config.d.ts +374 -0
- package/dist/src/stores/guido-email-editor.d.ts +20 -10
- package/dist/src/stores/onboarding.d.ts +812 -10
- package/dist/src/stores/recommendation.d.ts +5 -0
- package/dist/src/stores/save-validation.d.ts +22 -0
- package/dist/src/stores/setup-settings.d.ts +4 -0
- package/dist/src/utils/dateUtil.d.ts +10 -0
- package/dist/src/utils/genericUtil.d.ts +3 -0
- package/dist/src/utils/stripoEditorApi.d.ts +4 -0
- package/dist/src/utils/templatePreparation.d.ts +30 -0
- package/dist/static/assets/icons/filled-arrow-rising.svg.js +5 -0
- package/dist/static/assets/icons/line-info.svg.js +5 -0
- package/dist/static/styles/components/recommendation-strategy.css.js +113 -9
- package/dist/static/styles/components/skeleton.css.js +23 -0
- package/dist/static/styles/components/version-history.css.js +2 -6
- package/dist/stores/config.js +55 -24
- package/dist/stores/guido-email-editor.js +3 -1
- package/dist/stores/onboarding.js +50 -36
- package/dist/stores/save-validation.js +30 -0
- package/dist/stores/setup-settings.js +10 -0
- package/dist/stores/unsubscribe.js +3 -3
- package/dist/utils/pairProductVariables.js +71 -71
- package/dist/utils/stripoEditorApi.js +11 -0
- package/dist/utils/templatePreparation.js +54 -51
- package/package.json +2 -1
|
@@ -1,154 +1,84 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var M = (
|
|
4
|
-
import { BLOCK_ID as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { useTemplateStore as q } from "../../stores/template.js";
|
|
9
|
-
const x = {
|
|
10
|
-
img: {
|
|
11
|
-
pairsKey: "imageSrc",
|
|
12
|
-
defaultKey: "DEFAULT",
|
|
13
|
-
isArray: !0
|
|
14
|
-
},
|
|
15
|
-
name: {
|
|
16
|
-
pairsKey: "name",
|
|
17
|
-
defaultKey: "DEFAULT",
|
|
18
|
-
isArray: !0
|
|
19
|
-
},
|
|
20
|
-
url: {
|
|
21
|
-
pairsKey: "button",
|
|
22
|
-
defaultKey: "DEFAULT_HREF",
|
|
23
|
-
isArray: !1
|
|
24
|
-
},
|
|
25
|
-
formattedprice: {
|
|
26
|
-
pairsKey: "price",
|
|
27
|
-
defaultKey: "DEFAULT_PRICE_FORMATTED",
|
|
28
|
-
isArray: !1
|
|
29
|
-
},
|
|
30
|
-
productcurrency: {
|
|
31
|
-
pairsKey: "price",
|
|
32
|
-
defaultKey: "DEFAULT_CURRENCY",
|
|
33
|
-
isArray: !1
|
|
34
|
-
},
|
|
35
|
-
quantity: {
|
|
36
|
-
pairsKey: "quantity",
|
|
37
|
-
defaultKey: "DEFAULT",
|
|
38
|
-
isArray: !1
|
|
39
|
-
},
|
|
40
|
-
price: {
|
|
41
|
-
pairsKey: "price",
|
|
42
|
-
defaultKey: "DEFAULT_PRICE",
|
|
43
|
-
isArray: !1
|
|
44
|
-
},
|
|
45
|
-
originalprice: {
|
|
46
|
-
pairsKey: "originalPrice",
|
|
47
|
-
defaultKey: "DEFAULT_PRICE",
|
|
48
|
-
isArray: !1
|
|
49
|
-
},
|
|
50
|
-
originalformattedprice: {
|
|
51
|
-
pairsKey: "originalPrice",
|
|
52
|
-
defaultKey: "DEFAULT_PRICE_FORMATTED",
|
|
53
|
-
isArray: !1
|
|
54
|
-
},
|
|
55
|
-
single_price: {
|
|
56
|
-
pairsKey: "price",
|
|
57
|
-
defaultKey: "DEFAULT_SINGLE_PRICE",
|
|
58
|
-
isArray: !1
|
|
59
|
-
},
|
|
60
|
-
single_formattedprice: {
|
|
61
|
-
pairsKey: "price",
|
|
62
|
-
defaultKey: "DEFAULT_SINGLE_PRICE_FORMATTED",
|
|
63
|
-
isArray: !1
|
|
64
|
-
},
|
|
65
|
-
single_originalprice: {
|
|
66
|
-
pairsKey: "originalPrice",
|
|
67
|
-
defaultKey: "DEFAULT_SINGLE_PRICE",
|
|
68
|
-
isArray: !1
|
|
69
|
-
},
|
|
70
|
-
single_originalformattedprice: {
|
|
71
|
-
pairsKey: "originalPrice",
|
|
72
|
-
defaultKey: "DEFAULT_SINGLE_PRICE_FORMATTED",
|
|
73
|
-
isArray: !1
|
|
74
|
-
}
|
|
75
|
-
};
|
|
1
|
+
var q = Object.defineProperty;
|
|
2
|
+
var v = (c, t, e) => t in c ? q(c, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[t] = e;
|
|
3
|
+
var M = (c, t, e) => v(c, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { BLOCK_ID as R } from "../../extensions/Blocks/Items/block.js";
|
|
5
|
+
import { ItemInCartOptions as h, DefaultConfigValues as b, SETTINGS_ENUMS as _ } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
|
|
6
|
+
import { getDefaultTemplate as L } from "../../extensions/Blocks/Items/template.js";
|
|
7
|
+
import { useTemplateStore as x } from "../../stores/template.js";
|
|
76
8
|
function O() {
|
|
77
9
|
return String(Date.now() + Math.floor(Math.random() * 1e3));
|
|
78
10
|
}
|
|
79
|
-
function
|
|
80
|
-
return
|
|
81
|
-
CartItems:
|
|
82
|
-
BrowsedItems:
|
|
83
|
-
PurchasedItems:
|
|
84
|
-
CART_ITEMS:
|
|
85
|
-
BROWSED_ITEMS:
|
|
86
|
-
PURCHASED_ITEMS:
|
|
87
|
-
}[
|
|
11
|
+
function P(c) {
|
|
12
|
+
return c ? {
|
|
13
|
+
CartItems: _.ITEMS_TYPE.CART_ITEMS,
|
|
14
|
+
BrowsedItems: _.ITEMS_TYPE.BROWSED_ITEMS,
|
|
15
|
+
PurchasedItems: _.ITEMS_TYPE.PURCHASED_ITEMS,
|
|
16
|
+
CART_ITEMS: _.ITEMS_TYPE.CART_ITEMS,
|
|
17
|
+
BROWSED_ITEMS: _.ITEMS_TYPE.BROWSED_ITEMS,
|
|
18
|
+
PURCHASED_ITEMS: _.ITEMS_TYPE.PURCHASED_ITEMS
|
|
19
|
+
}[c] || _.ITEMS_TYPE.CART_ITEMS : _.ITEMS_TYPE.CART_ITEMS;
|
|
88
20
|
}
|
|
89
|
-
function
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
21
|
+
function V(c) {
|
|
22
|
+
return c.classList.contains("esd-browsed-items-block") ? _.ITEMS_TYPE.BROWSED_ITEMS : c.classList.contains("esd-purchased-items-block") ? _.ITEMS_TYPE.PURCHASED_ITEMS : _.ITEMS_TYPE.CART_ITEMS;
|
|
23
|
+
}
|
|
24
|
+
function D(c) {
|
|
25
|
+
var o;
|
|
26
|
+
const t = (i, u) => i == null ? u : i === "1" || i === "true", e = (i, u) => i || u, a = c["data-type"] || c["data-source"], r = P(a), d = h[r];
|
|
27
|
+
let n = c["data-cart_items_select_control_value"] || ((o = d == null ? void 0 : d[0]) == null ? void 0 : o.value) || b.cartItemsSelectControlValue;
|
|
93
28
|
if (n && !n.includes("{{") && /^\d+$/.test(n)) {
|
|
94
|
-
const
|
|
95
|
-
u && u[
|
|
29
|
+
const i = parseInt(n) - 1, u = h[r];
|
|
30
|
+
u && u[i] && (n = u[i].value);
|
|
96
31
|
}
|
|
97
32
|
return {
|
|
98
33
|
initialized: !0,
|
|
99
|
-
blockInstanceId:
|
|
100
|
-
source:
|
|
101
|
-
type:
|
|
34
|
+
blockInstanceId: e(c["data-block-instance-id"], O()),
|
|
35
|
+
source: r,
|
|
36
|
+
type: r,
|
|
102
37
|
itemsSelectValue: n,
|
|
103
|
-
orientation:
|
|
104
|
-
nameTrimming: t(
|
|
105
|
-
priceHideDiscount: t(
|
|
106
|
-
priceFormatted: t(
|
|
107
|
-
priceSinglePrice: t(
|
|
108
|
-
priceCurrencySymbol:
|
|
109
|
-
|
|
110
|
-
|
|
38
|
+
orientation: c["data-card_orientation_control_value"] || _.ORIENTATION.VERTICAL,
|
|
39
|
+
nameTrimming: t(c["data-product_name_control_trim"], !0),
|
|
40
|
+
priceHideDiscount: t(c["data-product_price_control_nodup"], !0),
|
|
41
|
+
priceFormatted: t(c["data-product_price_control_formated"], !0),
|
|
42
|
+
priceSinglePrice: t(c["data-product_price_control_single_price"], !1),
|
|
43
|
+
priceCurrencySymbol: e(
|
|
44
|
+
c["data-product_price_control_currency_symbol"],
|
|
45
|
+
b.productPriceCurrencySymbolControlValue
|
|
111
46
|
),
|
|
112
|
-
priceCurrencyLocation:
|
|
113
|
-
|
|
114
|
-
|
|
47
|
+
priceCurrencyLocation: e(
|
|
48
|
+
c["data-product_price_currency_location"],
|
|
49
|
+
b.productPriceCurrencyLocationControlValue
|
|
115
50
|
),
|
|
116
|
-
priceOrientation:
|
|
117
|
-
quantityControlEnabled: t(
|
|
118
|
-
buttonLink:
|
|
119
|
-
imageLink:
|
|
120
|
-
buttonLabel:
|
|
121
|
-
buttonFullWidth: t(
|
|
122
|
-
imageVisible: t(
|
|
123
|
-
nameVisible: t(
|
|
124
|
-
quantityVisible: t(
|
|
125
|
-
priceVisible: t(
|
|
126
|
-
originalPriceVisible: t(
|
|
127
|
-
buttonVisible: t(
|
|
51
|
+
priceOrientation: c["data-product_original_price_control_orientation"] || "horizontal",
|
|
52
|
+
quantityControlEnabled: t(c["data-product_quantity_control_enabled"], !0),
|
|
53
|
+
buttonLink: e(c["data-product_button_link"], b.productButtonLinkControlValue),
|
|
54
|
+
imageLink: e(c["data-product_image_link"], b.productImageLinkControlValue),
|
|
55
|
+
buttonLabel: e(c["data-product_button_control_label"], "Buy"),
|
|
56
|
+
buttonFullWidth: t(c["data-product_button_control_atw"], !0),
|
|
57
|
+
imageVisible: t(c["data-product_image_control_enabled"], !0),
|
|
58
|
+
nameVisible: t(c["data-product_name_control_enabled"], !0),
|
|
59
|
+
quantityVisible: t(c["data-product_quantity_control_enabled"], !0),
|
|
60
|
+
priceVisible: t(c["data-product_price_control_enabled"], !0),
|
|
61
|
+
originalPriceVisible: t(c["data-product_original_price_control_enabled"], !0),
|
|
62
|
+
buttonVisible: t(c["data-product_button_control_enabled"], !0)
|
|
128
63
|
};
|
|
129
64
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
browsed_item: "BROWSED_ITEMS",
|
|
133
|
-
purchased_item: "PURCHASED_ITEMS"
|
|
134
|
-
};
|
|
135
|
-
function $(o, t) {
|
|
136
|
-
const r = {
|
|
65
|
+
function H(c, t) {
|
|
66
|
+
const e = {
|
|
137
67
|
CART_ITEMS: `{{Abandoned Cart Item (${t}) Image}}`,
|
|
138
68
|
BROWSED_ITEMS: `{{Browsed Item (${t}) Image}}`,
|
|
139
69
|
PURCHASED_ITEMS: `{{Purchased Item (${t}) Image}}`
|
|
140
70
|
};
|
|
141
|
-
return
|
|
71
|
+
return e[c] || e.CART_ITEMS;
|
|
142
72
|
}
|
|
143
|
-
function
|
|
144
|
-
const
|
|
73
|
+
function $(c, t) {
|
|
74
|
+
const e = {
|
|
145
75
|
CART_ITEMS: `{{Abandoned Cart Item (${t}) Url}}`,
|
|
146
76
|
BROWSED_ITEMS: `{{Browsed Item (${t}) Url}}`,
|
|
147
77
|
PURCHASED_ITEMS: `{{Purchased Item (${t}) Url}}`
|
|
148
78
|
};
|
|
149
|
-
return
|
|
79
|
+
return e[c] || e.CART_ITEMS;
|
|
150
80
|
}
|
|
151
|
-
class
|
|
81
|
+
class F {
|
|
152
82
|
constructor() {
|
|
153
83
|
M(this, "parser");
|
|
154
84
|
this.parser = new DOMParser();
|
|
@@ -157,42 +87,40 @@ class H {
|
|
|
157
87
|
try {
|
|
158
88
|
if (!this.containsItemsBlock(t))
|
|
159
89
|
return this.backfillV2ProductTdAttributes(t);
|
|
160
|
-
|
|
161
|
-
r = this.replaceTemplateVariables(r);
|
|
162
|
-
const c = this.parser.parseFromString(r, "text/html"), a = c.querySelectorAll(
|
|
90
|
+
const e = this.removeJinjaConditionals(t), a = this.parser.parseFromString(e, "text/html"), r = a.querySelectorAll(
|
|
163
91
|
"td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
|
|
164
92
|
);
|
|
165
|
-
return
|
|
166
|
-
n.migrations = { ...n.migrations, [
|
|
167
|
-
}),
|
|
168
|
-
const
|
|
169
|
-
orientation:
|
|
170
|
-
itemsType:
|
|
171
|
-
itemId:
|
|
172
|
-
currencySymbol:
|
|
173
|
-
currencyLocation:
|
|
174
|
-
formattedPrice:
|
|
175
|
-
configBlockAttributes:
|
|
93
|
+
return x().$patch((n) => {
|
|
94
|
+
n.migrations = { ...n.migrations, [R]: r.length };
|
|
95
|
+
}), r.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), e) : (r.forEach((n) => {
|
|
96
|
+
const o = this.extractConfiguration(n), i = L({
|
|
97
|
+
orientation: o.orientation,
|
|
98
|
+
itemsType: o.itemsType,
|
|
99
|
+
itemId: o.itemId,
|
|
100
|
+
currencySymbol: o.currencySymbol,
|
|
101
|
+
currencyLocation: o.currencyLocation,
|
|
102
|
+
formattedPrice: o.formattedPrice,
|
|
103
|
+
configBlockAttributes: o.configBlockAttributes,
|
|
176
104
|
migrate: !0,
|
|
177
|
-
nameStyles:
|
|
178
|
-
buttonStyles:
|
|
179
|
-
priceStyles:
|
|
180
|
-
originalPriceStyles:
|
|
181
|
-
quantityStyles:
|
|
182
|
-
nodeConfig:
|
|
183
|
-
}),
|
|
184
|
-
`<table><tbody><tr>${
|
|
105
|
+
nameStyles: o.nameStyles,
|
|
106
|
+
buttonStyles: o.buttonStyles,
|
|
107
|
+
priceStyles: o.priceStyles,
|
|
108
|
+
originalPriceStyles: o.originalPriceStyles,
|
|
109
|
+
quantityStyles: o.quantityStyles,
|
|
110
|
+
nodeConfig: D(o.configBlockAttributes)
|
|
111
|
+
}), l = this.parser.parseFromString(
|
|
112
|
+
`<table><tbody><tr>${i}</tr></tbody></table>`,
|
|
185
113
|
"text/html"
|
|
186
114
|
).querySelector("td");
|
|
187
|
-
if (
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
const
|
|
191
|
-
|
|
115
|
+
if (l && n.parentNode) {
|
|
116
|
+
const s = D(o.configBlockAttributes);
|
|
117
|
+
l.setAttribute("esd-ext-config", JSON.stringify(s)), l.setAttribute("data-type", s.type);
|
|
118
|
+
const p = l.querySelector("esd-config-block");
|
|
119
|
+
p && p.remove(), n.parentNode.replaceChild(l, n);
|
|
192
120
|
}
|
|
193
|
-
}),
|
|
194
|
-
} catch (
|
|
195
|
-
return console.error("ItemsBlockMigrator failed:",
|
|
121
|
+
}), a.documentElement.outerHTML);
|
|
122
|
+
} catch (e) {
|
|
123
|
+
return console.error("ItemsBlockMigrator failed:", e), t;
|
|
196
124
|
}
|
|
197
125
|
}
|
|
198
126
|
/**
|
|
@@ -202,28 +130,118 @@ class H {
|
|
|
202
130
|
* - UI styles from product elements (name, price, button, quantity, etc.)
|
|
203
131
|
*/
|
|
204
132
|
extractConfiguration(t) {
|
|
205
|
-
var C
|
|
206
|
-
const
|
|
207
|
-
(
|
|
208
|
-
),
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
const y = t.querySelector('a[product-attr="name"]'), A = (y == null ? void 0 : y.getAttribute("style")) || void 0, f = t.querySelector('a[product-attr="button"]'), m = (f == null ? void 0 : f.getAttribute("style")) || void 0, R = (e == null ? void 0 : e.getAttribute("style")) || void 0, E = t.querySelector("p.original-price"), L = (E == null ? void 0 : E.getAttribute("style")) || void 0, T = t.querySelector('[product-attr="quantity"]'), B = (T == null ? void 0 : T.getAttribute("style")) || void 0;
|
|
133
|
+
var C;
|
|
134
|
+
const e = P(
|
|
135
|
+
this.readSelfOrDescendantAttribute(t, "data-type") || V(t)
|
|
136
|
+
), a = this.readSelfOrDescendantAttribute(t, "data-number") || "1", r = parseInt(a) - 1, d = h[e], n = ((C = d == null ? void 0 : d[r]) == null ? void 0 : C.value) || d[0].value, o = this.extractConfigBlockAttributes(t, e, a);
|
|
137
|
+
this.applyDomFallbacks(t, o);
|
|
138
|
+
const i = t.querySelector('[product-attr="price"]'), u = o["data-product_price_control_currency_symbol"], l = o["data-product_price_currency_location"] || "0", s = o["data-product_price_control_formated"], p = s !== "false" && s !== "0", S = o["data-card_orientation_control_value"] === "horizontal" ? "horizontal" : "vertical", y = t.querySelector('a[product-attr="name"]'), f = (y == null ? void 0 : y.getAttribute("style")) || void 0, g = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'), I = (g == null ? void 0 : g.getAttribute("style")) || void 0, w = (i == null ? void 0 : i.getAttribute("style")) || void 0, m = t.querySelector("p.original-price") ?? t.querySelector('[product-attr="originalPrice"]'), A = m != null && m.getAttribute("style") ? m : (m == null ? void 0 : m.closest("p")) ?? m, k = (A == null ? void 0 : A.getAttribute("style")) || void 0, E = t.querySelector('[product-attr="quantity"]'), B = (E == null ? void 0 : E.getAttribute("style")) || void 0;
|
|
212
139
|
return {
|
|
213
140
|
orientation: S,
|
|
214
|
-
itemsType:
|
|
141
|
+
itemsType: e,
|
|
215
142
|
itemId: n,
|
|
216
|
-
currencySymbol:
|
|
217
|
-
currencyLocation:
|
|
218
|
-
formattedPrice:
|
|
219
|
-
configBlockAttributes:
|
|
220
|
-
nameStyles:
|
|
221
|
-
buttonStyles:
|
|
222
|
-
priceStyles:
|
|
223
|
-
originalPriceStyles:
|
|
143
|
+
currencySymbol: u,
|
|
144
|
+
currencyLocation: l,
|
|
145
|
+
formattedPrice: p,
|
|
146
|
+
configBlockAttributes: o,
|
|
147
|
+
nameStyles: f,
|
|
148
|
+
buttonStyles: I,
|
|
149
|
+
priceStyles: w,
|
|
150
|
+
originalPriceStyles: k,
|
|
224
151
|
quantityStyles: B
|
|
225
152
|
};
|
|
226
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* DOM fallback for hand-edited templates. The esd-config-block is authoritative only for
|
|
156
|
+
* the keys it ACTUALLY carries — every other key follows the live markup, whether the block
|
|
157
|
+
* was deleted outright or (far more common) survives carrying only a couple of `_opened`
|
|
158
|
+
* attributes. Without the per-key split, one such stub block shadows the whole DOM and the
|
|
159
|
+
* card migrates with the boilerplate defaults: caption "Buy", USD, full-width button.
|
|
160
|
+
*/
|
|
161
|
+
applyDomFallbacks(t, e) {
|
|
162
|
+
var S, y;
|
|
163
|
+
const a = t.querySelector("esd-config-block"), r = (...f) => !a || f.every((g) => !(a.getAttribute(g) ?? "").trim());
|
|
164
|
+
Object.entries({
|
|
165
|
+
image: '[product-attr="imageSrc"]',
|
|
166
|
+
name: '[product-attr="name"]',
|
|
167
|
+
price: '[product-attr="price"]',
|
|
168
|
+
original_price: '[product-attr="originalPrice"], p.original-price',
|
|
169
|
+
quantity: '[product-attr="quantity"]',
|
|
170
|
+
button: '[product-attr="button"]'
|
|
171
|
+
}).forEach(([f, g]) => {
|
|
172
|
+
const I = `data-product_${f}_control_enabled`;
|
|
173
|
+
r(I) && (e[I] = t.querySelector(g) ? "true" : "false");
|
|
174
|
+
}), r("data-card_orientation_control_value") && (e["data-card_orientation_control_value"] = t.querySelector('[colspan="2"]') ? "vertical" : "horizontal");
|
|
175
|
+
const n = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'), o = (S = n == null ? void 0 : n.textContent) == null ? void 0 : S.replace(/\s+/g, " ").trim();
|
|
176
|
+
o && r("data-product_button_control_label") && (e["data-product_button_control_label"] = o);
|
|
177
|
+
const i = (n == null ? void 0 : n.getAttribute("style")) || "";
|
|
178
|
+
r("data-product_button_control_atw") && /display:\s*inline/.test(i) && !/(?:^|;)\s*width\s*:\s*100%/.test(i) && (e["data-product_button_control_atw"] = "false");
|
|
179
|
+
const u = t.querySelector('[product-attr="imageSrc"]'), l = u ? this.readImageSize(u) : null, s = (l == null ? void 0 : l.height) ?? (l == null ? void 0 : l.width), p = (l == null ? void 0 : l.width) ?? (l == null ? void 0 : l.height);
|
|
180
|
+
s && r("data-product_image_control_image-height") && (e["data-product_image_control_image-height"] = s), p && r("data-product_image_control_image-width") && (e["data-product_image_control_image-width"] = p), this.applyPriceDomFallbacks(t, e, r);
|
|
181
|
+
const T = ((y = t.querySelector('[product-attr="name"]')) == null ? void 0 : y.getAttribute("style")) || "";
|
|
182
|
+
r("data-product_name_control_trim") && /white-space:\s*normal/.test(T) && (e["data-product_name_control_trim"] = "0");
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Carries the price cell's own currency/format attributes into the config attributes when
|
|
186
|
+
* the config block omits them. extractConfiguration used to read the cell separately for the
|
|
187
|
+
* rendered markup while nodeConfig kept the defaults — so a ₺/after card migrated rendering
|
|
188
|
+
* ₺ but reporting USD/before to the settings panel, and the first unrelated price edit wrote
|
|
189
|
+
* the default back over the real value.
|
|
190
|
+
*/
|
|
191
|
+
applyPriceDomFallbacks(t, e, a) {
|
|
192
|
+
var u;
|
|
193
|
+
const r = t.querySelector('[product-attr="price"]') ?? t.querySelector('[product-attr="originalPrice"]');
|
|
194
|
+
if (!r)
|
|
195
|
+
return;
|
|
196
|
+
const d = (u = r.getAttribute("data-currency_symbol")) == null ? void 0 : u.trim();
|
|
197
|
+
d && a("data-product_price_control_currency_symbol") && (e["data-product_price_control_currency_symbol"] = d);
|
|
198
|
+
const n = r.getAttribute("data-curency");
|
|
199
|
+
if (n && a("data-product_price_currency_location", "data-product_price_control_curency")) {
|
|
200
|
+
const l = n === "after" ? "1" : "0";
|
|
201
|
+
e["data-product_price_currency_location"] = l, e["data-product_price_control_curency"] = l;
|
|
202
|
+
}
|
|
203
|
+
const o = r.getAttribute("data-formated");
|
|
204
|
+
o && a("data-product_price_control_formated") && (e["data-product_price_control_formated"] = o);
|
|
205
|
+
const i = r.getAttribute("data-single_price");
|
|
206
|
+
i && a("data-product_price_control_single_price") && (e["data-product_price_control_single_price"] = i);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Reads an attribute from the block element itself before falling back to a descendant.
|
|
210
|
+
* Real legacy markup carries data-type/data-number on the `.ins-product-td` AND on the
|
|
211
|
+
* esd-config-block; when an author deletes the config block only the td's copy survives.
|
|
212
|
+
*/
|
|
213
|
+
readSelfOrDescendantAttribute(t, e) {
|
|
214
|
+
var a;
|
|
215
|
+
return t.getAttribute(e) || ((a = t.querySelector(`[${e}]`)) == null ? void 0 : a.getAttribute(e)) || null;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Reads the product image's pixel size — `width`/`height` attributes first, then px values
|
|
219
|
+
* in the inline style. An explicit `width`/`height` wins over `max-*`, which is only an
|
|
220
|
+
* upper bound; `max-*` still covers the common `width: 100%` case, where no pixel size can
|
|
221
|
+
* be read from the property itself. Each side is null when it carries no pixel size.
|
|
222
|
+
*/
|
|
223
|
+
readImageSize(t) {
|
|
224
|
+
return {
|
|
225
|
+
width: this.readImageDimension(t, "width"),
|
|
226
|
+
height: this.readImageDimension(t, "height")
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* One side of readImageSize. `width="0"` is not a size — authors who override the real
|
|
231
|
+
* dimensions in CSS zero out the attributes, and taking the 0 collapses the migrated image
|
|
232
|
+
* to nothing, so only a positive integer counts as an answer.
|
|
233
|
+
*/
|
|
234
|
+
readImageDimension(t, e) {
|
|
235
|
+
var u;
|
|
236
|
+
const a = (l) => {
|
|
237
|
+
const s = (l ?? "").trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i), p = s ? Math.floor(parseFloat(s[1])) : 0;
|
|
238
|
+
return p > 0 ? String(p) : null;
|
|
239
|
+
}, r = a((u = t.getAttribute(e)) == null ? void 0 : u.trim());
|
|
240
|
+
if (r)
|
|
241
|
+
return r;
|
|
242
|
+
const d = t.getAttribute("style") || "", n = new RegExp(`(?:^|;)\\s*${e}:\\s*(\\d+(?:\\.\\d+)?)px`), o = new RegExp(`max-${e}:\\s*(\\d+(?:\\.\\d+)?)px`), i = d.match(n) || d.match(o);
|
|
243
|
+
return a(i == null ? void 0 : i[1]);
|
|
244
|
+
}
|
|
227
245
|
/**
|
|
228
246
|
* Extracts all data-* attributes from the esd-config-block element
|
|
229
247
|
* Returns a key-value mapping of all configuration attributes
|
|
@@ -231,27 +249,27 @@ class H {
|
|
|
231
249
|
* @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
|
|
232
250
|
* @param itemNumber - The item number (1-based index)
|
|
233
251
|
*/
|
|
234
|
-
extractConfigBlockAttributes(t,
|
|
235
|
-
const
|
|
236
|
-
if (
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
252
|
+
extractConfigBlockAttributes(t, e, a) {
|
|
253
|
+
const r = t.querySelector("esd-config-block"), d = {};
|
|
254
|
+
if (r) {
|
|
255
|
+
if (Array.from(r.attributes).forEach((o) => {
|
|
256
|
+
o.name.startsWith("data-") && (d[o.name] = o.value);
|
|
257
|
+
}), d["data-cart_items_select_control_value"]) {
|
|
258
|
+
const o = d["data-cart_items_select_control_value"];
|
|
259
|
+
if (/^\d+$/.test(o)) {
|
|
260
|
+
const i = parseInt(o) - 1, u = h[e];
|
|
261
|
+
u && u[i] && (d["data-cart_items_select_control_value"] = u[i].value);
|
|
262
|
+
}
|
|
245
263
|
}
|
|
264
|
+
if (d["data-product_price_control_curency"]) {
|
|
265
|
+
const o = d["data-product_price_control_curency"];
|
|
266
|
+
let i = o;
|
|
267
|
+
o === "before" ? i = "0" : o === "after" && (i = "1"), d["data-product_price_control_curency"] = i, d["data-product_price_currency_location"] = i;
|
|
268
|
+
}
|
|
269
|
+
(!d["data-product_price_control_currency_symbol"] || d["data-product_price_control_currency_symbol"].trim() === "") && (d["data-product_price_control_currency_symbol"] = "USD");
|
|
246
270
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
let l = e;
|
|
250
|
-
e === "before" ? l = "0" : e === "after" && (l = "1"), i["data-product_price_control_curency"] = l, i["data-product_price_currency_location"] = l;
|
|
251
|
-
}
|
|
252
|
-
(!i["data-product_price_control_currency_symbol"] || i["data-product_price_control_currency_symbol"].trim() === "") && (i["data-product_price_control_currency_symbol"] = "USD");
|
|
253
|
-
const n = { ...this.getDefaultConfigBlockAttributes(), ...i };
|
|
254
|
-
return n["data-type"] = r, n["data-source"] = r, n["data-product_image_link"] = $(r, c), n["data-product_button_link"] = N(r, c), n;
|
|
271
|
+
const n = { ...this.getDefaultConfigBlockAttributes(), ...d };
|
|
272
|
+
return n["data-type"] = e, n["data-source"] = e, n["data-product_image_link"] = H(e, a), n["data-product_button_link"] = $(e, a), n;
|
|
255
273
|
}
|
|
256
274
|
/**
|
|
257
275
|
* Returns default esd-config-block attributes based on the old template structure
|
|
@@ -325,25 +343,27 @@ class H {
|
|
|
325
343
|
backfillV2ProductTdAttributes(t) {
|
|
326
344
|
if (!t.includes("ins-product-td") || !t.includes("esd-ext-config"))
|
|
327
345
|
return t;
|
|
328
|
-
const
|
|
329
|
-
let
|
|
330
|
-
return
|
|
331
|
-
|
|
332
|
-
const
|
|
333
|
-
|
|
346
|
+
const e = this.parser.parseFromString(t, "text/html");
|
|
347
|
+
let a = !1;
|
|
348
|
+
return e.querySelectorAll(".ins-product-td").forEach((r) => {
|
|
349
|
+
r.hasAttribute("width") && (r.removeAttribute("width"), a = !0), r.classList.contains("esd-container-frame") && (r.classList.remove("esd-container-frame"), a = !0);
|
|
350
|
+
const d = r.querySelector("table.ins-product-wrapper");
|
|
351
|
+
d != null && d.hasAttribute("width") && d.getAttribute("width") !== "100%" && (d.setAttribute("width", "100%"), a = !0);
|
|
352
|
+
const n = r.getAttribute("esd-ext-config");
|
|
353
|
+
let o = null;
|
|
334
354
|
try {
|
|
335
|
-
|
|
355
|
+
o = n ? JSON.parse(n) : null;
|
|
336
356
|
} catch {
|
|
337
357
|
}
|
|
338
|
-
if (!
|
|
358
|
+
if (!o || (!r.getAttribute("data-nodup") && typeof o.priceHideDiscount == "boolean" && (r.setAttribute("data-nodup", String(o.priceHideDiscount)), a = !0), r.getAttribute("data-type")))
|
|
339
359
|
return;
|
|
340
|
-
const
|
|
341
|
-
if (!
|
|
360
|
+
const i = o.type || o.source;
|
|
361
|
+
if (!i)
|
|
342
362
|
return;
|
|
343
|
-
|
|
344
|
-
const
|
|
345
|
-
|
|
346
|
-
}),
|
|
363
|
+
r.setAttribute("data-type", i), a = !0;
|
|
364
|
+
const u = typeof o.itemsSelectValue == "string" ? o.itemsSelectValue.match(/\((\d+)\)/) : null;
|
|
365
|
+
u && r.getAttribute("data-number") !== u[1] && r.setAttribute("data-number", u[1]);
|
|
366
|
+
}), a ? e.documentElement.outerHTML : t;
|
|
347
367
|
}
|
|
348
368
|
/**
|
|
349
369
|
* Fast check for the presence of any items block (cart / browsed / purchased)
|
|
@@ -364,54 +384,22 @@ class H {
|
|
|
364
384
|
* contains display condition Jinja scripts that should NOT be removed.
|
|
365
385
|
*/
|
|
366
386
|
removeJinjaConditionals(t) {
|
|
367
|
-
const
|
|
368
|
-
let
|
|
369
|
-
return
|
|
387
|
+
const e = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", a = t.match(/esd-custom-display-conditions="[^"]*"/);
|
|
388
|
+
let r = a ? t.replace(a[0], e) : t;
|
|
389
|
+
return r = r.replace(
|
|
370
390
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(>|>)\s*\d+\s*%\}/g,
|
|
371
391
|
""
|
|
372
|
-
),
|
|
392
|
+
), r = r.replace(
|
|
373
393
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!=|!=)\s*\1_originalprice_\d+\s*%\}/g,
|
|
374
394
|
""
|
|
375
|
-
),
|
|
395
|
+
), r = r.replace(/\{%\s*endif\s*%\}/g, ""), a && (r = r.replace(e, a[0])), r = r.replace(/\n\s*\n\s*\n/g, `
|
|
376
396
|
|
|
377
|
-
`),
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
* Replaces template variables with default values from productPairs
|
|
381
|
-
* Supports all block types by detecting prefix and using appropriate type:
|
|
382
|
-
*
|
|
383
|
-
* Examples:
|
|
384
|
-
* - {{ins_apr_img_1}} → https://web-image.useinsider.com/.../img_1.jpeg (CART_ITEMS)
|
|
385
|
-
* - {{browsed_item_name_2}} → 'Set of Sprite Yoga Straps' (BROWSED_ITEMS)
|
|
386
|
-
* - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
|
|
387
|
-
*/
|
|
388
|
-
replaceTemplateVariables(t) {
|
|
389
|
-
const { PAIRS_FOR_EXTENSION: r } = K;
|
|
390
|
-
return t.replace(/{{([^}]+)}}/g, (c, a) => {
|
|
391
|
-
const i = a.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
|
|
392
|
-
if (!i)
|
|
393
|
-
return c;
|
|
394
|
-
const [, n, e, l] = i, u = V[n];
|
|
395
|
-
if (!u)
|
|
396
|
-
return console.warn(`Unknown variable prefix: ${n}`), c;
|
|
397
|
-
const s = x[e];
|
|
398
|
-
if (!s)
|
|
399
|
-
return console.warn(`Unknown variable suffix mapping for: ${e}`), c;
|
|
400
|
-
const { pairsKey: _, defaultKey: d, isArray: b } = s, y = r[_][u];
|
|
401
|
-
if (!y)
|
|
402
|
-
return console.warn(`No data found for: ${_}.${u}`), c;
|
|
403
|
-
if (b) {
|
|
404
|
-
const f = parseInt(l) - 1, m = y[d];
|
|
405
|
-
return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${_}.${u}.${d}[${f}]`), c);
|
|
406
|
-
}
|
|
407
|
-
const A = y[d];
|
|
408
|
-
return A !== void 0 ? String(A) : (console.warn(`Default value not found: ${_}.${u}.${d}`), c);
|
|
409
|
-
});
|
|
397
|
+
`), r;
|
|
410
398
|
}
|
|
411
399
|
}
|
|
412
|
-
function
|
|
413
|
-
return new
|
|
400
|
+
function J(c) {
|
|
401
|
+
return new F().migrate(c);
|
|
414
402
|
}
|
|
415
403
|
export {
|
|
416
|
-
|
|
404
|
+
J as migrateItemsBlock
|
|
417
405
|
};
|