@vio-live/web-sdk 0.33.0 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +90 -0
- package/README.md +139 -13
- package/dist/chunk-3YFJFDSN.js +3 -0
- package/dist/{chunk-QGJUBVH3.js.map → chunk-3YFJFDSN.js.map} +1 -1
- package/dist/{chunk-ZORYG4W3.js → chunk-6PQFXUOW.js} +294 -40
- package/dist/chunk-6PQFXUOW.js.map +1 -0
- package/dist/{chunk-T5B74YBQ.js → chunk-DEREQRCM.js} +423 -109
- package/dist/chunk-DEREQRCM.js.map +1 -0
- package/dist/core/index.d.ts +65 -3
- package/dist/core/index.js +2 -2
- package/dist/detail-layout-BI556w8p.d.ts +76 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -2
- package/dist/react/index.d.ts +4 -2
- package/dist/react/index.js +5 -4
- package/dist/react/index.js.map +1 -1
- package/dist/{tokens-B7GVA_qB.d.ts → tokens-BGzSC3vK.d.ts} +133 -13
- package/dist/ui/index.d.ts +2 -1
- package/dist/ui/index.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-QGJUBVH3.js +0 -3
- package/dist/chunk-T5B74YBQ.js.map +0 -1
- package/dist/chunk-ZORYG4W3.js.map +0 -1
|
@@ -1039,6 +1039,168 @@ async function currentPrivacyMode() {
|
|
|
1039
1039
|
}
|
|
1040
1040
|
}
|
|
1041
1041
|
|
|
1042
|
+
// src/core/detail-layout.ts
|
|
1043
|
+
var DETAIL_SECTION_IDS = [
|
|
1044
|
+
"brand",
|
|
1045
|
+
"title",
|
|
1046
|
+
"stock",
|
|
1047
|
+
"price",
|
|
1048
|
+
"options",
|
|
1049
|
+
"purchase",
|
|
1050
|
+
"highlights",
|
|
1051
|
+
"description",
|
|
1052
|
+
"shippingReturns"
|
|
1053
|
+
];
|
|
1054
|
+
var ESSENTIAL_DETAIL_SECTIONS = ["title", "price", "options", "purchase"];
|
|
1055
|
+
var LAYOUT_TOKEN = /^[A-Za-z0-9._:-]{1,64}$/;
|
|
1056
|
+
function layoutToken(value) {
|
|
1057
|
+
if (typeof value !== "string") return void 0;
|
|
1058
|
+
const v = value.trim();
|
|
1059
|
+
return LAYOUT_TOKEN.test(v) ? v : void 0;
|
|
1060
|
+
}
|
|
1061
|
+
var KNOWN = new Set(DETAIL_SECTION_IDS);
|
|
1062
|
+
function defaultDetailLayout() {
|
|
1063
|
+
return { id: "default", revision: "0", sections: [...DETAIL_SECTION_IDS], adjusted: [], source: "default" };
|
|
1064
|
+
}
|
|
1065
|
+
var warned = /* @__PURE__ */ new Set();
|
|
1066
|
+
function warnOnce(key, message) {
|
|
1067
|
+
if (warned.has(key)) return;
|
|
1068
|
+
warned.add(key);
|
|
1069
|
+
if (typeof console !== "undefined") console.warn("[Vio] detail layout ignored:", message);
|
|
1070
|
+
}
|
|
1071
|
+
function normalizeDetailLayout(raw) {
|
|
1072
|
+
if (raw === null || raw === void 0) return null;
|
|
1073
|
+
if (typeof raw !== "object" || Array.isArray(raw)) {
|
|
1074
|
+
warnOnce(`type:${typeof raw}`, "it must be an object");
|
|
1075
|
+
return null;
|
|
1076
|
+
}
|
|
1077
|
+
const r = raw;
|
|
1078
|
+
const id = layoutToken(r.id);
|
|
1079
|
+
if (!id) {
|
|
1080
|
+
warnOnce(`id:${String(r.id)}`, `invalid id ${JSON.stringify(r.id)} (\u2264 64 chars of A-Z a-z 0-9 . _ : -)`);
|
|
1081
|
+
return null;
|
|
1082
|
+
}
|
|
1083
|
+
if (!Array.isArray(r.sections)) {
|
|
1084
|
+
warnOnce(`sections:${id}`, `layout ${id}: sections must be an array of section ids`);
|
|
1085
|
+
return null;
|
|
1086
|
+
}
|
|
1087
|
+
const out = {
|
|
1088
|
+
id,
|
|
1089
|
+
revision: layoutToken(r.revision) ?? "",
|
|
1090
|
+
sections: r.sections.map((s) => typeof s === "string" ? s.trim() : String(s))
|
|
1091
|
+
};
|
|
1092
|
+
const experimentId = layoutToken(r.experimentId);
|
|
1093
|
+
if (experimentId) out.experimentId = experimentId;
|
|
1094
|
+
const variantId = layoutToken(r.variantId);
|
|
1095
|
+
if (variantId) out.variantId = variantId;
|
|
1096
|
+
return out;
|
|
1097
|
+
}
|
|
1098
|
+
function effectiveDetailSections(requested) {
|
|
1099
|
+
const sections = [];
|
|
1100
|
+
const adjusted = [];
|
|
1101
|
+
for (const raw of requested) {
|
|
1102
|
+
const s = String(raw).slice(0, 64);
|
|
1103
|
+
if (!KNOWN.has(s)) {
|
|
1104
|
+
adjusted.push({ section: s, reason: "unknown" });
|
|
1105
|
+
continue;
|
|
1106
|
+
}
|
|
1107
|
+
if (sections.includes(s)) {
|
|
1108
|
+
adjusted.push({ section: s, reason: "duplicate" });
|
|
1109
|
+
continue;
|
|
1110
|
+
}
|
|
1111
|
+
sections.push(s);
|
|
1112
|
+
}
|
|
1113
|
+
for (const essential of ESSENTIAL_DETAIL_SECTIONS) {
|
|
1114
|
+
if (!sections.includes(essential)) {
|
|
1115
|
+
sections.push(essential);
|
|
1116
|
+
adjusted.push({ section: essential, reason: "added-essential" });
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
return { sections, adjusted };
|
|
1120
|
+
}
|
|
1121
|
+
function resolveDetailLayout(elementLayout, globalLayout = currentGlobalDetailLayout()) {
|
|
1122
|
+
const own = normalizeDetailLayout(elementLayout);
|
|
1123
|
+
const page = own ? null : normalizeDetailLayout(globalLayout);
|
|
1124
|
+
const chosen = own ?? page;
|
|
1125
|
+
if (!chosen) return defaultDetailLayout();
|
|
1126
|
+
const { sections, adjusted } = effectiveDetailSections(chosen.sections);
|
|
1127
|
+
return {
|
|
1128
|
+
id: chosen.id,
|
|
1129
|
+
revision: chosen.revision,
|
|
1130
|
+
...chosen.experimentId ? { experimentId: chosen.experimentId } : {},
|
|
1131
|
+
...chosen.variantId ? { variantId: chosen.variantId } : {},
|
|
1132
|
+
sections,
|
|
1133
|
+
adjusted,
|
|
1134
|
+
source: own ? "element" : "global"
|
|
1135
|
+
};
|
|
1136
|
+
}
|
|
1137
|
+
function copyAppliedLayout(applied) {
|
|
1138
|
+
return { ...applied, sections: [...applied.sections], adjusted: applied.adjusted.map((a) => ({ ...a })) };
|
|
1139
|
+
}
|
|
1140
|
+
function layoutSignature(applied) {
|
|
1141
|
+
return [applied.source, applied.id, applied.revision, applied.experimentId ?? "", applied.variantId ?? "", applied.sections.join(",")].join("|");
|
|
1142
|
+
}
|
|
1143
|
+
function layoutOriginOf(applied) {
|
|
1144
|
+
if (!applied || applied.source === "default") return {};
|
|
1145
|
+
return {
|
|
1146
|
+
layoutId: applied.id,
|
|
1147
|
+
...applied.revision ? { layoutRevision: applied.revision } : {},
|
|
1148
|
+
...applied.experimentId ? { experimentId: applied.experimentId } : {},
|
|
1149
|
+
...applied.variantId ? { variantId: applied.variantId } : {}
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1152
|
+
function normalizeLayoutOrigin(origin) {
|
|
1153
|
+
if (!origin || typeof origin !== "object") return {};
|
|
1154
|
+
const o = origin;
|
|
1155
|
+
const layoutId = layoutToken(o.layoutId);
|
|
1156
|
+
if (!layoutId) return {};
|
|
1157
|
+
const out = { layoutId };
|
|
1158
|
+
const layoutRevision = layoutToken(o.layoutRevision);
|
|
1159
|
+
if (layoutRevision) out.layoutRevision = layoutRevision;
|
|
1160
|
+
const experimentId = layoutToken(o.experimentId);
|
|
1161
|
+
if (experimentId) out.experimentId = experimentId;
|
|
1162
|
+
const variantId = layoutToken(o.variantId);
|
|
1163
|
+
if (variantId) out.variantId = variantId;
|
|
1164
|
+
return out;
|
|
1165
|
+
}
|
|
1166
|
+
function store() {
|
|
1167
|
+
const g = globalThis;
|
|
1168
|
+
return g.__VIO_DETAIL_LAYOUT__ ??= { layout: null, listeners: /* @__PURE__ */ new Set() };
|
|
1169
|
+
}
|
|
1170
|
+
function currentGlobalDetailLayout() {
|
|
1171
|
+
return store().layout;
|
|
1172
|
+
}
|
|
1173
|
+
function setGlobalDetailLayout(layout) {
|
|
1174
|
+
const s = store();
|
|
1175
|
+
s.layout = layout ?? null;
|
|
1176
|
+
normalizeDetailLayout(s.layout);
|
|
1177
|
+
for (const listener of [...s.listeners]) {
|
|
1178
|
+
try {
|
|
1179
|
+
listener();
|
|
1180
|
+
} catch {
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
function currentGlobalDescriptionLabel() {
|
|
1185
|
+
return store().descriptionLabel ?? null;
|
|
1186
|
+
}
|
|
1187
|
+
function setGlobalDescriptionLabel(label) {
|
|
1188
|
+
const s = store();
|
|
1189
|
+
const text3 = typeof label === "string" ? label.trim() : "";
|
|
1190
|
+
s.descriptionLabel = text3 && text3.length <= 40 ? text3 : null;
|
|
1191
|
+
for (const listener of [...s.listeners]) {
|
|
1192
|
+
try {
|
|
1193
|
+
listener();
|
|
1194
|
+
} catch {
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
function onGlobalDetailLayoutChange(listener) {
|
|
1199
|
+
const s = store();
|
|
1200
|
+
s.listeners.add(listener);
|
|
1201
|
+
return () => s.listeners.delete(listener);
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1042
1204
|
// src/core/buyer-ref.ts
|
|
1043
1205
|
var BUYER_REF_MAX_LENGTH = 128;
|
|
1044
1206
|
var BUYER_REF_PATTERN = /^[A-Za-z0-9._~-]+$/;
|
|
@@ -1057,18 +1219,18 @@ var FEATURE_TOKENS = {
|
|
|
1057
1219
|
};
|
|
1058
1220
|
var UNKNOWN_PATTERN = /cannot query field|unknown field|unknown argument|unknown type|is not defined by type|not defined by type|field "[^"]+" is not defined/i;
|
|
1059
1221
|
var refused = /* @__PURE__ */ new Set();
|
|
1060
|
-
var
|
|
1222
|
+
var warned2 = /* @__PURE__ */ new Set();
|
|
1061
1223
|
function gatewayHas(feature) {
|
|
1062
1224
|
return !refused.has(feature);
|
|
1063
1225
|
}
|
|
1064
1226
|
function resetGatewayFeatures(feature) {
|
|
1065
1227
|
if (feature) {
|
|
1066
1228
|
refused.delete(feature);
|
|
1067
|
-
|
|
1229
|
+
warned2.delete(feature);
|
|
1068
1230
|
return;
|
|
1069
1231
|
}
|
|
1070
1232
|
refused.clear();
|
|
1071
|
-
|
|
1233
|
+
warned2.clear();
|
|
1072
1234
|
}
|
|
1073
1235
|
function messagesOf(err) {
|
|
1074
1236
|
if (!err || typeof err !== "object") return [];
|
|
@@ -1097,8 +1259,8 @@ async function withGatewayFeature(feature, request) {
|
|
|
1097
1259
|
} catch (err) {
|
|
1098
1260
|
if (!isUnknownFeatureError(err, feature)) throw err;
|
|
1099
1261
|
refused.add(feature);
|
|
1100
|
-
if (!
|
|
1101
|
-
|
|
1262
|
+
if (!warned2.has(feature) && typeof console !== "undefined") {
|
|
1263
|
+
warned2.add(feature);
|
|
1102
1264
|
console.warn(
|
|
1103
1265
|
`[Vio] the commerce gateway does not know "${FEATURE_TOKENS[feature][0]}" (${feature}) yet \u2014 sent without it on this page load:`,
|
|
1104
1266
|
messagesOf(err)[0] ?? ""
|
|
@@ -3029,7 +3191,9 @@ var CartManager = class extends EventTarget {
|
|
|
3029
3191
|
// Attribution of the removed units: their most recent origin.
|
|
3030
3192
|
slot: removedOrigin?.slot,
|
|
3031
3193
|
campaignId: removedOrigin?.campaignId,
|
|
3032
|
-
contentId: removedOrigin?.contentId
|
|
3194
|
+
contentId: removedOrigin?.contentId,
|
|
3195
|
+
// The detail layout of those units (0.34), when they came from one.
|
|
3196
|
+
...removedOrigin?.layoutId ? { layout: normalizeLayoutOrigin(removedOrigin) } : {}
|
|
3033
3197
|
}
|
|
3034
3198
|
})
|
|
3035
3199
|
);
|
|
@@ -3315,10 +3479,11 @@ function normalizeOrigin(origin) {
|
|
|
3315
3479
|
if (typeof origin.contentTitle === "string" && origin.contentTitle.trim()) {
|
|
3316
3480
|
out.contentTitle = origin.contentTitle.trim().slice(0, CONTENT_TITLE_MAX_LENGTH);
|
|
3317
3481
|
}
|
|
3482
|
+
Object.assign(out, normalizeLayoutOrigin(origin));
|
|
3318
3483
|
return out;
|
|
3319
3484
|
}
|
|
3320
3485
|
function sameOrigin(a, b) {
|
|
3321
|
-
return a.campaignId === b.campaignId && a.slot === b.slot && a.contentId === b.contentId && a.componentKind === b.componentKind;
|
|
3486
|
+
return a.campaignId === b.campaignId && a.slot === b.slot && a.contentId === b.contentId && a.componentKind === b.componentKind && a.layoutId === b.layoutId && a.layoutRevision === b.layoutRevision && a.experimentId === b.experimentId && a.variantId === b.variantId;
|
|
3322
3487
|
}
|
|
3323
3488
|
function latestOrigin(line) {
|
|
3324
3489
|
const origins = Array.isArray(line.origins) ? line.origins : [];
|
|
@@ -3526,10 +3691,10 @@ function normalizeEntry(raw) {
|
|
|
3526
3691
|
return { checkoutId, sponsorId, name: nameOf(r.name), logoUrl: urlOrNull(r.logoUrl), ...channelId ? { channelId } : {} };
|
|
3527
3692
|
}
|
|
3528
3693
|
function readEntries() {
|
|
3529
|
-
const
|
|
3530
|
-
if (
|
|
3694
|
+
const store2 = storageRefusedWrite ? null : sessionStore();
|
|
3695
|
+
if (store2) {
|
|
3531
3696
|
try {
|
|
3532
|
-
const raw =
|
|
3697
|
+
const raw = store2.getItem(CHECKOUT_SPONSOR_STORAGE_KEY);
|
|
3533
3698
|
if (!raw) return [];
|
|
3534
3699
|
const parsed = JSON.parse(raw);
|
|
3535
3700
|
if (Array.isArray(parsed)) {
|
|
@@ -3542,10 +3707,10 @@ function readEntries() {
|
|
|
3542
3707
|
}
|
|
3543
3708
|
function writeEntries(entries) {
|
|
3544
3709
|
inMemory = entries.slice();
|
|
3545
|
-
const
|
|
3546
|
-
if (!
|
|
3710
|
+
const store2 = sessionStore();
|
|
3711
|
+
if (!store2) return;
|
|
3547
3712
|
try {
|
|
3548
|
-
|
|
3713
|
+
store2.setItem(CHECKOUT_SPONSOR_STORAGE_KEY, JSON.stringify(entries));
|
|
3549
3714
|
} catch {
|
|
3550
3715
|
storageRefusedWrite = true;
|
|
3551
3716
|
}
|
|
@@ -3804,7 +3969,7 @@ async function prepareApplePay(config) {
|
|
|
3804
3969
|
}
|
|
3805
3970
|
|
|
3806
3971
|
// src/core/version.ts
|
|
3807
|
-
var SDK_VERSION = "0.
|
|
3972
|
+
var SDK_VERSION = "0.36.0";
|
|
3808
3973
|
|
|
3809
3974
|
// src/core/checkout/payments/stripe-embedded.ts
|
|
3810
3975
|
var CREATE_PAYMENT_INTENT_STRIPE_MUTATION = `
|
|
@@ -5905,7 +6070,7 @@ var CheckoutManager = class _CheckoutManager extends EventTarget {
|
|
|
5905
6070
|
}
|
|
5906
6071
|
const opts = await this.gqlOptions(spId);
|
|
5907
6072
|
const attribution = await this.attributionFor(spId);
|
|
5908
|
-
let checkoutId = this.state?.checkoutId;
|
|
6073
|
+
let checkoutId = this.state?.sponsorId === spId ? this.state.checkoutId : void 0;
|
|
5909
6074
|
if (!checkoutId) {
|
|
5910
6075
|
const checkoutRes = attribution ? await createCheckout(cartId, opts, { attribution }) : await createCheckout(cartId, opts);
|
|
5911
6076
|
checkoutId = checkoutRes?.id;
|
|
@@ -7777,7 +7942,8 @@ function cartSlicesFrom(lines, resolveCampaign, fallbackCurrency) {
|
|
|
7777
7942
|
if (Number.isFinite(sponsorId)) slice.sponsors.add(sponsorId);
|
|
7778
7943
|
if (origin.slot) slice.slots.add(origin.slot);
|
|
7779
7944
|
if (origin.contentId) slice.contents.add(origin.contentId);
|
|
7780
|
-
const
|
|
7945
|
+
const layout = itemLayoutOf(origin);
|
|
7946
|
+
const itemKey = `${line.productId}::${line.variantId ?? ""}::${layoutKeyOf(layout)}`;
|
|
7781
7947
|
const item = slice.items.get(itemKey);
|
|
7782
7948
|
if (item) item.quantity = (item.quantity ?? 0) + origin.quantity;
|
|
7783
7949
|
else {
|
|
@@ -7787,7 +7953,8 @@ function cartSlicesFrom(lines, resolveCampaign, fallbackCurrency) {
|
|
|
7787
7953
|
brand: line.brand,
|
|
7788
7954
|
variantId: line.variantId,
|
|
7789
7955
|
price: unitPrice,
|
|
7790
|
-
quantity: origin.quantity
|
|
7956
|
+
quantity: origin.quantity,
|
|
7957
|
+
...layout
|
|
7791
7958
|
});
|
|
7792
7959
|
}
|
|
7793
7960
|
slice.value += unitPrice * origin.quantity;
|
|
@@ -7809,6 +7976,48 @@ function cartSlicesFrom(lines, resolveCampaign, fallbackCurrency) {
|
|
|
7809
7976
|
function hasExplicitCampaign(lines) {
|
|
7810
7977
|
return lines.some((line) => lineOrigins(line).some((o) => o.campaignId !== void 0));
|
|
7811
7978
|
}
|
|
7979
|
+
function itemLayoutOf(origin) {
|
|
7980
|
+
const l = normalizeLayoutOrigin(origin);
|
|
7981
|
+
if (!l.layoutId) return {};
|
|
7982
|
+
return {
|
|
7983
|
+
layoutId: l.layoutId,
|
|
7984
|
+
layoutRevision: l.layoutRevision ?? "",
|
|
7985
|
+
experimentId: l.experimentId ?? "",
|
|
7986
|
+
experimentVariantId: l.variantId ?? ""
|
|
7987
|
+
};
|
|
7988
|
+
}
|
|
7989
|
+
function layoutKeyOf(layout) {
|
|
7990
|
+
return layout.layoutId ? [layout.layoutId, layout.layoutRevision, layout.experimentId, layout.experimentVariantId].join("|") : "";
|
|
7991
|
+
}
|
|
7992
|
+
function lineItemsByLayout(lines) {
|
|
7993
|
+
const out = [];
|
|
7994
|
+
for (const line of lines) {
|
|
7995
|
+
if (!line || typeof line !== "object") continue;
|
|
7996
|
+
const base = {
|
|
7997
|
+
productId: line.productId,
|
|
7998
|
+
name: line.name,
|
|
7999
|
+
brand: line.brand,
|
|
8000
|
+
variantId: line.variantId,
|
|
8001
|
+
price: line.unitPrice,
|
|
8002
|
+
quantity: line.quantity
|
|
8003
|
+
};
|
|
8004
|
+
const origins = lineOrigins(line);
|
|
8005
|
+
if (!origins.some((o) => normalizeLayoutOrigin(o).layoutId)) {
|
|
8006
|
+
out.push(base);
|
|
8007
|
+
continue;
|
|
8008
|
+
}
|
|
8009
|
+
const parts = /* @__PURE__ */ new Map();
|
|
8010
|
+
for (const origin of origins) {
|
|
8011
|
+
const layout = itemLayoutOf(origin);
|
|
8012
|
+
const key = layoutKeyOf(layout);
|
|
8013
|
+
const part = parts.get(key);
|
|
8014
|
+
if (part) part.quantity = (part.quantity ?? 0) + origin.quantity;
|
|
8015
|
+
else parts.set(key, { ...base, quantity: origin.quantity, ...layout });
|
|
8016
|
+
}
|
|
8017
|
+
out.push(...parts.values());
|
|
8018
|
+
}
|
|
8019
|
+
return out;
|
|
8020
|
+
}
|
|
7812
8021
|
|
|
7813
8022
|
// src/core/analytics/analytics-manager.ts
|
|
7814
8023
|
var ORDER_NUMBER_BACKOFF_MS = [500, 1e3, 2e3, 3e3, 3e3];
|
|
@@ -8130,21 +8339,27 @@ var AnalyticsManager = class extends EventTarget {
|
|
|
8130
8339
|
content_title: this.options.privateContent ? void 0 : capTitle(
|
|
8131
8340
|
ctx.contentTitle ?? content.title ?? (typeof document !== "undefined" && document.title ? document.title : void 0)
|
|
8132
8341
|
),
|
|
8133
|
-
variant: ctx.variant
|
|
8342
|
+
variant: ctx.variant,
|
|
8343
|
+
// The detail layout shown (0.34) — `view_item` of a non-default layout.
|
|
8344
|
+
layout_id: ctx.layoutId,
|
|
8345
|
+
layout_revision: ctx.layoutRevision,
|
|
8346
|
+
experiment_id: ctx.experimentId,
|
|
8347
|
+
variant_id: ctx.variantId
|
|
8134
8348
|
});
|
|
8135
8349
|
const com = opts.commerce;
|
|
8136
8350
|
const commerce = com ? compact({
|
|
8137
8351
|
// The collector rejects an event with more lines than its cap, whole.
|
|
8138
|
-
items: com.items?.slice(0, MAX_ITEMS).map(
|
|
8139
|
-
|
|
8352
|
+
items: com.items?.slice(0, MAX_ITEMS).map((i) => ({
|
|
8353
|
+
...compact({
|
|
8140
8354
|
product_id: String(i.productId),
|
|
8141
8355
|
name: this.options.privateContent ? void 0 : i.name,
|
|
8142
8356
|
brand: this.options.privateContent ? void 0 : i.brand,
|
|
8143
8357
|
variant_id: i.variantId !== void 0 ? String(i.variantId) : void 0,
|
|
8144
8358
|
price: i.price,
|
|
8145
8359
|
quantity: i.quantity
|
|
8146
|
-
})
|
|
8147
|
-
|
|
8360
|
+
}),
|
|
8361
|
+
...itemLayoutWire(i)
|
|
8362
|
+
})),
|
|
8148
8363
|
value: com.value,
|
|
8149
8364
|
currency: com.currency,
|
|
8150
8365
|
order_id: com.orderId,
|
|
@@ -8301,16 +8516,19 @@ var AnalyticsManager = class extends EventTarget {
|
|
|
8301
8516
|
this.track("add_to_cart", {
|
|
8302
8517
|
context: { sponsorId: d.sponsorId !== void 0 ? Number(d.sponsorId) : void 0, campaignId: campaignOf(d), slot: slotOf(d), componentTemplateId: templateOf(d), ...contentOf(d) },
|
|
8303
8518
|
commerce: {
|
|
8304
|
-
|
|
8519
|
+
// The detail layout the units were added from (0.34): the add's own
|
|
8520
|
+
// (`detail.layout`, set by <vio-product-detail>), '' when none.
|
|
8521
|
+
items: withLineLayouts([
|
|
8305
8522
|
{
|
|
8306
8523
|
productId: d.productId ?? line?.productId ?? "",
|
|
8307
8524
|
name: line?.name,
|
|
8308
8525
|
brand: line?.brand,
|
|
8309
8526
|
variantId: d.variantId ?? line?.variantId,
|
|
8310
8527
|
price: line?.unitPrice,
|
|
8311
|
-
quantity: d.quantity ?? 1
|
|
8528
|
+
quantity: d.quantity ?? 1,
|
|
8529
|
+
...itemLayoutOf(normalizeLayoutOrigin(d.layout))
|
|
8312
8530
|
}
|
|
8313
|
-
],
|
|
8531
|
+
]),
|
|
8314
8532
|
value: line ? line.unitPrice * (d.quantity ?? 1) : void 0,
|
|
8315
8533
|
currency: line?.currency
|
|
8316
8534
|
}
|
|
@@ -8322,16 +8540,17 @@ var AnalyticsManager = class extends EventTarget {
|
|
|
8322
8540
|
this.track("remove_from_cart", {
|
|
8323
8541
|
context: { sponsorId: d.sponsorId, campaignId: campaignOf(d), slot: slotOf(d), ...contentOf(d) },
|
|
8324
8542
|
commerce: {
|
|
8325
|
-
items: [
|
|
8543
|
+
items: withLineLayouts([
|
|
8326
8544
|
{
|
|
8327
8545
|
productId: d.productId,
|
|
8328
8546
|
variantId: d.variantId,
|
|
8329
8547
|
name: d.name,
|
|
8330
8548
|
brand: d.brand,
|
|
8331
8549
|
price: d.price,
|
|
8332
|
-
quantity: d.quantity
|
|
8550
|
+
quantity: d.quantity,
|
|
8551
|
+
...itemLayoutOf(normalizeLayoutOrigin(d.layout))
|
|
8333
8552
|
}
|
|
8334
|
-
],
|
|
8553
|
+
]),
|
|
8335
8554
|
value: (d.price ?? 0) * (d.quantity ?? 1),
|
|
8336
8555
|
currency: d.currency
|
|
8337
8556
|
}
|
|
@@ -8634,14 +8853,8 @@ var AnalyticsManager = class extends EventTarget {
|
|
|
8634
8853
|
}
|
|
8635
8854
|
if (items.length === 0) return null;
|
|
8636
8855
|
return {
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
name: i.name,
|
|
8640
|
-
brand: i.brand,
|
|
8641
|
-
variantId: i.variantId,
|
|
8642
|
-
price: i.unitPrice,
|
|
8643
|
-
quantity: i.quantity
|
|
8644
|
-
})),
|
|
8856
|
+
// One item per line and detail layout (0.34), each saying its layout.
|
|
8857
|
+
items: withLineLayouts(lineItemsByLayout(items)),
|
|
8645
8858
|
value: items.reduce((sum, i) => sum + i.unitPrice * (i.quantity ?? 1), 0),
|
|
8646
8859
|
currency: items[0]?.currency ?? this.lastCartSnapshot?.currency
|
|
8647
8860
|
};
|
|
@@ -8695,6 +8908,27 @@ function impressionCommerce(read) {
|
|
|
8695
8908
|
return void 0;
|
|
8696
8909
|
}
|
|
8697
8910
|
}
|
|
8911
|
+
function itemLayoutWire(i) {
|
|
8912
|
+
if (i.layoutId === void 0 && i.layoutRevision === void 0 && i.experimentId === void 0 && i.experimentVariantId === void 0) {
|
|
8913
|
+
return {};
|
|
8914
|
+
}
|
|
8915
|
+
const token = (v) => layoutToken(v) ?? "";
|
|
8916
|
+
return {
|
|
8917
|
+
layout_id: token(i.layoutId),
|
|
8918
|
+
layout_revision: token(i.layoutRevision),
|
|
8919
|
+
experiment_id: token(i.experimentId),
|
|
8920
|
+
experiment_variant_id: token(i.experimentVariantId)
|
|
8921
|
+
};
|
|
8922
|
+
}
|
|
8923
|
+
function withLineLayouts(items) {
|
|
8924
|
+
return items?.map((i) => ({
|
|
8925
|
+
...i,
|
|
8926
|
+
layoutId: i.layoutId ?? "",
|
|
8927
|
+
layoutRevision: i.layoutRevision ?? "",
|
|
8928
|
+
experimentId: i.experimentId ?? "",
|
|
8929
|
+
experimentVariantId: i.experimentVariantId ?? ""
|
|
8930
|
+
}));
|
|
8931
|
+
}
|
|
8698
8932
|
function compact(obj) {
|
|
8699
8933
|
const out = {};
|
|
8700
8934
|
for (const [k, v] of Object.entries(obj)) {
|
|
@@ -8762,7 +8996,7 @@ function capTitle(value) {
|
|
|
8762
8996
|
return value.length > CONTENT_TITLE_MAX_LENGTH ? value.slice(0, CONTENT_TITLE_MAX_LENGTH) : value;
|
|
8763
8997
|
}
|
|
8764
8998
|
function sliceCommerce(slice) {
|
|
8765
|
-
return { items: slice.items, value: slice.value, currency: slice.currency };
|
|
8999
|
+
return { items: withLineLayouts(slice.items), value: slice.value, currency: slice.currency };
|
|
8766
9000
|
}
|
|
8767
9001
|
function slotOf(detail) {
|
|
8768
9002
|
return typeof detail.slot === "string" && detail.slot.trim() ? detail.slot.trim() : void 0;
|
|
@@ -9096,6 +9330,26 @@ var VioFacade = class {
|
|
|
9096
9330
|
}
|
|
9097
9331
|
return resolveContent(init);
|
|
9098
9332
|
}
|
|
9333
|
+
/**
|
|
9334
|
+
* Page-wide options of every `<vio-product-detail>` (0.34). `layout` orders
|
|
9335
|
+
* the sections below the gallery — `{ id, revision, sections, experimentId?,
|
|
9336
|
+
* variantId? }`; `null` goes back to the default; a detail's own `layout`
|
|
9337
|
+
* wins. Open details re-render at once, later ones open with it. A key left
|
|
9338
|
+
* out of the call is left as it is. See README «Section order and layout
|
|
9339
|
+
* tracking».
|
|
9340
|
+
*/
|
|
9341
|
+
configureDetail(options = {}) {
|
|
9342
|
+
if (options && typeof options === "object" && "layout" in options) setGlobalDetailLayout(options.layout ?? null);
|
|
9343
|
+
if (options && typeof options === "object" && "descriptionLabel" in options) setGlobalDescriptionLabel(options.descriptionLabel ?? null);
|
|
9344
|
+
}
|
|
9345
|
+
/**
|
|
9346
|
+
* The layout a `<vio-product-detail>` without its own `layout` applies now:
|
|
9347
|
+
* the page's (`source: 'global'`) or the default. A detail's own is
|
|
9348
|
+
* `el.appliedLayout`. A copy; never throws.
|
|
9349
|
+
*/
|
|
9350
|
+
detailLayout() {
|
|
9351
|
+
return copyAppliedLayout(resolveDetailLayout(null));
|
|
9352
|
+
}
|
|
9099
9353
|
get isInitialized() {
|
|
9100
9354
|
return Configuration.isInitialized;
|
|
9101
9355
|
}
|
|
@@ -9978,6 +10232,6 @@ function vippsButtonAttributes(verb = "buy", opts = {}) {
|
|
|
9978
10232
|
};
|
|
9979
10233
|
}
|
|
9980
10234
|
|
|
9981
|
-
export { ADD_ITEM_MUTATION, ADYEN_RETURN_METHOD, ADYEN_RETURN_QUERY_KEYS, AdyenOriginError, AnalyticsManager, BUYER_REF_MAX_LENGTH, CHECKOUT_ATTRIBUTION_CAPS, CHECKOUT_SPONSOR_STORAGE_KEY, CLIENT_LANDING_URL_MAX_LENGTH, CONTENT_URL_MAX_LENGTH, CREATE_CART_MUTATION, CREATE_CHECKOUT_MUTATION, CREATE_CHECKOUT_WITH_ATTRIBUTION_MUTATION, CREATE_PAYMENT_STRIPE_MUTATION, CREATE_PAYMENT_VIPPS_MUTATION, CartManager, CheckoutManager, CommerceClient, Configuration, DELETE_ITEM_MUTATION, GET_AVAILABLE_PAYMENT_METHODS_QUERY, GET_CART_QUERY, GET_CHECKOUT_QUERY, GET_LINE_ITEMS_BY_SUPPLIER_QUERY, GET_VIPPS_STATUS_QUERY, GRAPHQL_INT_MAX, INTERNAL_KEY, INTERNAL_PARAM, KUSTOM_RETURN_QUERY_KEYS, LINE_ORIGIN_CAPS, SDK_VERSION, UPDATE_CHECKOUT_MUTATION, UPDATE_CHECKOUT_WITH_ATTRIBUTION_MUTATION, UPDATE_ITEM_MUTATION, UPDATE_ITEM_WITH_ORIGIN_MUTATION, UPDATE_SHIPPINGS_BY_SUPPLIER_MUTATION, VIPPS_BUTTON_SCRIPT, VIPPS_BUTTON_TAG, Vio, VioApi, VioApiError, __decorateClass, activeCampaignEntry, addItem, adyenReturnOutcome, adyenReturnParams, autoSlotDisplayName, autoSlotId, buyerRefOf, campaignCandidates, capContentUrl, cartSlicesFrom, checkApplePayAvailability, checkoutAttributionOf, checkoutSponsorOf, componentKindOf, createCart, createCheckout, createCommerceClient, createPaymentStripe, createPaymentVipps, createVioApi, deleteItem, displayPrice, dominantCampaignOf, ensureVippsButton, entryContextOf, executeCartGraphQL, formatPrice, gatewayHas, gatewayHasBuyerRef, getAvailablePaymentMethods, getCart, getCartGraphQLOptions, getCheckout, getCheckoutReference, getCustomerSessionId, getGlobalCountryCode, getGlobalCurrency, getLineItemsBySupplier, getVippsStatus, isUnknownFeatureError, isUnknownTokenError, isValidPhone, kustomReturnOutcome, landingUrl, lineOriginWire, lineOrigins, nexiReturnPaymentId, normalizeBuyerRef, normalizeOrigin, normalizeScope, normalizeSlotId, normalizeSlotKind, originAndPath, primaryImageUrl, purchaseFromPaymentSuccess, purchaseIdsOf, readInternal, readNexiPending, rememberedCheckoutSponsor, resetGatewayFeatures, resolveCampaignId, resolveClientContext, resolveContent, resolveInternal, resolveLanding, resolveSlotCampaign, sameOrigin, shippingDescriptionOf, showApplePaySheet, sponsorCampaignEntry, sponsorIdentityFrom, storageGet, storedLanding, toCampaignId, updateCheckout, updateItem, updateShippingsBySupplier, vippsButtonAttributes, withGatewayFeature, writeInternal };
|
|
9982
|
-
//# sourceMappingURL=chunk-
|
|
9983
|
-
//# sourceMappingURL=chunk-
|
|
10235
|
+
export { ADD_ITEM_MUTATION, ADYEN_RETURN_METHOD, ADYEN_RETURN_QUERY_KEYS, AdyenOriginError, AnalyticsManager, BUYER_REF_MAX_LENGTH, CHECKOUT_ATTRIBUTION_CAPS, CHECKOUT_SPONSOR_STORAGE_KEY, CLIENT_LANDING_URL_MAX_LENGTH, CONTENT_URL_MAX_LENGTH, CREATE_CART_MUTATION, CREATE_CHECKOUT_MUTATION, CREATE_CHECKOUT_WITH_ATTRIBUTION_MUTATION, CREATE_PAYMENT_STRIPE_MUTATION, CREATE_PAYMENT_VIPPS_MUTATION, CartManager, CheckoutManager, CommerceClient, Configuration, DELETE_ITEM_MUTATION, DETAIL_SECTION_IDS, ESSENTIAL_DETAIL_SECTIONS, GET_AVAILABLE_PAYMENT_METHODS_QUERY, GET_CART_QUERY, GET_CHECKOUT_QUERY, GET_LINE_ITEMS_BY_SUPPLIER_QUERY, GET_VIPPS_STATUS_QUERY, GRAPHQL_INT_MAX, INTERNAL_KEY, INTERNAL_PARAM, KUSTOM_RETURN_QUERY_KEYS, LINE_ORIGIN_CAPS, SDK_VERSION, UPDATE_CHECKOUT_MUTATION, UPDATE_CHECKOUT_WITH_ATTRIBUTION_MUTATION, UPDATE_ITEM_MUTATION, UPDATE_ITEM_WITH_ORIGIN_MUTATION, UPDATE_SHIPPINGS_BY_SUPPLIER_MUTATION, VIPPS_BUTTON_SCRIPT, VIPPS_BUTTON_TAG, Vio, VioApi, VioApiError, __decorateClass, activeCampaignEntry, addItem, adyenReturnOutcome, adyenReturnParams, autoSlotDisplayName, autoSlotId, buyerRefOf, campaignCandidates, capContentUrl, cartSlicesFrom, checkApplePayAvailability, checkoutAttributionOf, checkoutSponsorOf, componentKindOf, copyAppliedLayout, createCart, createCheckout, createCommerceClient, createPaymentStripe, createPaymentVipps, createVioApi, currentGlobalDescriptionLabel, defaultDetailLayout, deleteItem, displayPrice, dominantCampaignOf, effectiveDetailSections, ensureVippsButton, entryContextOf, executeCartGraphQL, formatPrice, gatewayHas, gatewayHasBuyerRef, getAvailablePaymentMethods, getCart, getCartGraphQLOptions, getCheckout, getCheckoutReference, getCustomerSessionId, getGlobalCountryCode, getGlobalCurrency, getLineItemsBySupplier, getVippsStatus, isUnknownFeatureError, isUnknownTokenError, isValidPhone, kustomReturnOutcome, landingUrl, layoutOriginOf, layoutSignature, lineOriginWire, lineOrigins, nexiReturnPaymentId, normalizeBuyerRef, normalizeDetailLayout, normalizeOrigin, normalizeScope, normalizeSlotId, normalizeSlotKind, onGlobalDetailLayoutChange, originAndPath, primaryImageUrl, purchaseFromPaymentSuccess, purchaseIdsOf, readInternal, readNexiPending, rememberedCheckoutSponsor, resetGatewayFeatures, resolveCampaignId, resolveClientContext, resolveContent, resolveDetailLayout, resolveInternal, resolveLanding, resolveSlotCampaign, sameOrigin, shippingDescriptionOf, showApplePaySheet, sponsorCampaignEntry, sponsorIdentityFrom, storageGet, storedLanding, toCampaignId, updateCheckout, updateItem, updateShippingsBySupplier, vippsButtonAttributes, withGatewayFeature, writeInternal };
|
|
10236
|
+
//# sourceMappingURL=chunk-6PQFXUOW.js.map
|
|
10237
|
+
//# sourceMappingURL=chunk-6PQFXUOW.js.map
|