@vio-live/web-sdk 0.33.0 → 0.35.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 +75 -0
- package/README.md +137 -13
- package/dist/chunk-3YFJFDSN.js +3 -0
- package/dist/{chunk-QGJUBVH3.js.map → chunk-3YFJFDSN.js.map} +1 -1
- package/dist/{chunk-T5B74YBQ.js → chunk-F7LE5AZY.js} +315 -51
- package/dist/chunk-F7LE5AZY.js.map +1 -0
- package/dist/{chunk-ZORYG4W3.js → chunk-QA5R4VYF.js} +279 -40
- package/dist/chunk-QA5R4VYF.js.map +1 -0
- package/dist/core/index.d.ts +64 -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-C-LsqKQH.d.ts} +116 -11
- 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,154 @@ 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 onGlobalDetailLayoutChange(listener) {
|
|
1185
|
+
const s = store();
|
|
1186
|
+
s.listeners.add(listener);
|
|
1187
|
+
return () => s.listeners.delete(listener);
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1042
1190
|
// src/core/buyer-ref.ts
|
|
1043
1191
|
var BUYER_REF_MAX_LENGTH = 128;
|
|
1044
1192
|
var BUYER_REF_PATTERN = /^[A-Za-z0-9._~-]+$/;
|
|
@@ -1057,18 +1205,18 @@ var FEATURE_TOKENS = {
|
|
|
1057
1205
|
};
|
|
1058
1206
|
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
1207
|
var refused = /* @__PURE__ */ new Set();
|
|
1060
|
-
var
|
|
1208
|
+
var warned2 = /* @__PURE__ */ new Set();
|
|
1061
1209
|
function gatewayHas(feature) {
|
|
1062
1210
|
return !refused.has(feature);
|
|
1063
1211
|
}
|
|
1064
1212
|
function resetGatewayFeatures(feature) {
|
|
1065
1213
|
if (feature) {
|
|
1066
1214
|
refused.delete(feature);
|
|
1067
|
-
|
|
1215
|
+
warned2.delete(feature);
|
|
1068
1216
|
return;
|
|
1069
1217
|
}
|
|
1070
1218
|
refused.clear();
|
|
1071
|
-
|
|
1219
|
+
warned2.clear();
|
|
1072
1220
|
}
|
|
1073
1221
|
function messagesOf(err) {
|
|
1074
1222
|
if (!err || typeof err !== "object") return [];
|
|
@@ -1097,8 +1245,8 @@ async function withGatewayFeature(feature, request) {
|
|
|
1097
1245
|
} catch (err) {
|
|
1098
1246
|
if (!isUnknownFeatureError(err, feature)) throw err;
|
|
1099
1247
|
refused.add(feature);
|
|
1100
|
-
if (!
|
|
1101
|
-
|
|
1248
|
+
if (!warned2.has(feature) && typeof console !== "undefined") {
|
|
1249
|
+
warned2.add(feature);
|
|
1102
1250
|
console.warn(
|
|
1103
1251
|
`[Vio] the commerce gateway does not know "${FEATURE_TOKENS[feature][0]}" (${feature}) yet \u2014 sent without it on this page load:`,
|
|
1104
1252
|
messagesOf(err)[0] ?? ""
|
|
@@ -3029,7 +3177,9 @@ var CartManager = class extends EventTarget {
|
|
|
3029
3177
|
// Attribution of the removed units: their most recent origin.
|
|
3030
3178
|
slot: removedOrigin?.slot,
|
|
3031
3179
|
campaignId: removedOrigin?.campaignId,
|
|
3032
|
-
contentId: removedOrigin?.contentId
|
|
3180
|
+
contentId: removedOrigin?.contentId,
|
|
3181
|
+
// The detail layout of those units (0.34), when they came from one.
|
|
3182
|
+
...removedOrigin?.layoutId ? { layout: normalizeLayoutOrigin(removedOrigin) } : {}
|
|
3033
3183
|
}
|
|
3034
3184
|
})
|
|
3035
3185
|
);
|
|
@@ -3315,10 +3465,11 @@ function normalizeOrigin(origin) {
|
|
|
3315
3465
|
if (typeof origin.contentTitle === "string" && origin.contentTitle.trim()) {
|
|
3316
3466
|
out.contentTitle = origin.contentTitle.trim().slice(0, CONTENT_TITLE_MAX_LENGTH);
|
|
3317
3467
|
}
|
|
3468
|
+
Object.assign(out, normalizeLayoutOrigin(origin));
|
|
3318
3469
|
return out;
|
|
3319
3470
|
}
|
|
3320
3471
|
function sameOrigin(a, b) {
|
|
3321
|
-
return a.campaignId === b.campaignId && a.slot === b.slot && a.contentId === b.contentId && a.componentKind === b.componentKind;
|
|
3472
|
+
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
3473
|
}
|
|
3323
3474
|
function latestOrigin(line) {
|
|
3324
3475
|
const origins = Array.isArray(line.origins) ? line.origins : [];
|
|
@@ -3526,10 +3677,10 @@ function normalizeEntry(raw) {
|
|
|
3526
3677
|
return { checkoutId, sponsorId, name: nameOf(r.name), logoUrl: urlOrNull(r.logoUrl), ...channelId ? { channelId } : {} };
|
|
3527
3678
|
}
|
|
3528
3679
|
function readEntries() {
|
|
3529
|
-
const
|
|
3530
|
-
if (
|
|
3680
|
+
const store2 = storageRefusedWrite ? null : sessionStore();
|
|
3681
|
+
if (store2) {
|
|
3531
3682
|
try {
|
|
3532
|
-
const raw =
|
|
3683
|
+
const raw = store2.getItem(CHECKOUT_SPONSOR_STORAGE_KEY);
|
|
3533
3684
|
if (!raw) return [];
|
|
3534
3685
|
const parsed = JSON.parse(raw);
|
|
3535
3686
|
if (Array.isArray(parsed)) {
|
|
@@ -3542,10 +3693,10 @@ function readEntries() {
|
|
|
3542
3693
|
}
|
|
3543
3694
|
function writeEntries(entries) {
|
|
3544
3695
|
inMemory = entries.slice();
|
|
3545
|
-
const
|
|
3546
|
-
if (!
|
|
3696
|
+
const store2 = sessionStore();
|
|
3697
|
+
if (!store2) return;
|
|
3547
3698
|
try {
|
|
3548
|
-
|
|
3699
|
+
store2.setItem(CHECKOUT_SPONSOR_STORAGE_KEY, JSON.stringify(entries));
|
|
3549
3700
|
} catch {
|
|
3550
3701
|
storageRefusedWrite = true;
|
|
3551
3702
|
}
|
|
@@ -3804,7 +3955,7 @@ async function prepareApplePay(config) {
|
|
|
3804
3955
|
}
|
|
3805
3956
|
|
|
3806
3957
|
// src/core/version.ts
|
|
3807
|
-
var SDK_VERSION = "0.
|
|
3958
|
+
var SDK_VERSION = "0.35.0";
|
|
3808
3959
|
|
|
3809
3960
|
// src/core/checkout/payments/stripe-embedded.ts
|
|
3810
3961
|
var CREATE_PAYMENT_INTENT_STRIPE_MUTATION = `
|
|
@@ -5905,7 +6056,7 @@ var CheckoutManager = class _CheckoutManager extends EventTarget {
|
|
|
5905
6056
|
}
|
|
5906
6057
|
const opts = await this.gqlOptions(spId);
|
|
5907
6058
|
const attribution = await this.attributionFor(spId);
|
|
5908
|
-
let checkoutId = this.state?.checkoutId;
|
|
6059
|
+
let checkoutId = this.state?.sponsorId === spId ? this.state.checkoutId : void 0;
|
|
5909
6060
|
if (!checkoutId) {
|
|
5910
6061
|
const checkoutRes = attribution ? await createCheckout(cartId, opts, { attribution }) : await createCheckout(cartId, opts);
|
|
5911
6062
|
checkoutId = checkoutRes?.id;
|
|
@@ -7777,7 +7928,8 @@ function cartSlicesFrom(lines, resolveCampaign, fallbackCurrency) {
|
|
|
7777
7928
|
if (Number.isFinite(sponsorId)) slice.sponsors.add(sponsorId);
|
|
7778
7929
|
if (origin.slot) slice.slots.add(origin.slot);
|
|
7779
7930
|
if (origin.contentId) slice.contents.add(origin.contentId);
|
|
7780
|
-
const
|
|
7931
|
+
const layout = itemLayoutOf(origin);
|
|
7932
|
+
const itemKey = `${line.productId}::${line.variantId ?? ""}::${layoutKeyOf(layout)}`;
|
|
7781
7933
|
const item = slice.items.get(itemKey);
|
|
7782
7934
|
if (item) item.quantity = (item.quantity ?? 0) + origin.quantity;
|
|
7783
7935
|
else {
|
|
@@ -7787,7 +7939,8 @@ function cartSlicesFrom(lines, resolveCampaign, fallbackCurrency) {
|
|
|
7787
7939
|
brand: line.brand,
|
|
7788
7940
|
variantId: line.variantId,
|
|
7789
7941
|
price: unitPrice,
|
|
7790
|
-
quantity: origin.quantity
|
|
7942
|
+
quantity: origin.quantity,
|
|
7943
|
+
...layout
|
|
7791
7944
|
});
|
|
7792
7945
|
}
|
|
7793
7946
|
slice.value += unitPrice * origin.quantity;
|
|
@@ -7809,6 +7962,48 @@ function cartSlicesFrom(lines, resolveCampaign, fallbackCurrency) {
|
|
|
7809
7962
|
function hasExplicitCampaign(lines) {
|
|
7810
7963
|
return lines.some((line) => lineOrigins(line).some((o) => o.campaignId !== void 0));
|
|
7811
7964
|
}
|
|
7965
|
+
function itemLayoutOf(origin) {
|
|
7966
|
+
const l = normalizeLayoutOrigin(origin);
|
|
7967
|
+
if (!l.layoutId) return {};
|
|
7968
|
+
return {
|
|
7969
|
+
layoutId: l.layoutId,
|
|
7970
|
+
layoutRevision: l.layoutRevision ?? "",
|
|
7971
|
+
experimentId: l.experimentId ?? "",
|
|
7972
|
+
experimentVariantId: l.variantId ?? ""
|
|
7973
|
+
};
|
|
7974
|
+
}
|
|
7975
|
+
function layoutKeyOf(layout) {
|
|
7976
|
+
return layout.layoutId ? [layout.layoutId, layout.layoutRevision, layout.experimentId, layout.experimentVariantId].join("|") : "";
|
|
7977
|
+
}
|
|
7978
|
+
function lineItemsByLayout(lines) {
|
|
7979
|
+
const out = [];
|
|
7980
|
+
for (const line of lines) {
|
|
7981
|
+
if (!line || typeof line !== "object") continue;
|
|
7982
|
+
const base = {
|
|
7983
|
+
productId: line.productId,
|
|
7984
|
+
name: line.name,
|
|
7985
|
+
brand: line.brand,
|
|
7986
|
+
variantId: line.variantId,
|
|
7987
|
+
price: line.unitPrice,
|
|
7988
|
+
quantity: line.quantity
|
|
7989
|
+
};
|
|
7990
|
+
const origins = lineOrigins(line);
|
|
7991
|
+
if (!origins.some((o) => normalizeLayoutOrigin(o).layoutId)) {
|
|
7992
|
+
out.push(base);
|
|
7993
|
+
continue;
|
|
7994
|
+
}
|
|
7995
|
+
const parts = /* @__PURE__ */ new Map();
|
|
7996
|
+
for (const origin of origins) {
|
|
7997
|
+
const layout = itemLayoutOf(origin);
|
|
7998
|
+
const key = layoutKeyOf(layout);
|
|
7999
|
+
const part = parts.get(key);
|
|
8000
|
+
if (part) part.quantity = (part.quantity ?? 0) + origin.quantity;
|
|
8001
|
+
else parts.set(key, { ...base, quantity: origin.quantity, ...layout });
|
|
8002
|
+
}
|
|
8003
|
+
out.push(...parts.values());
|
|
8004
|
+
}
|
|
8005
|
+
return out;
|
|
8006
|
+
}
|
|
7812
8007
|
|
|
7813
8008
|
// src/core/analytics/analytics-manager.ts
|
|
7814
8009
|
var ORDER_NUMBER_BACKOFF_MS = [500, 1e3, 2e3, 3e3, 3e3];
|
|
@@ -8130,21 +8325,27 @@ var AnalyticsManager = class extends EventTarget {
|
|
|
8130
8325
|
content_title: this.options.privateContent ? void 0 : capTitle(
|
|
8131
8326
|
ctx.contentTitle ?? content.title ?? (typeof document !== "undefined" && document.title ? document.title : void 0)
|
|
8132
8327
|
),
|
|
8133
|
-
variant: ctx.variant
|
|
8328
|
+
variant: ctx.variant,
|
|
8329
|
+
// The detail layout shown (0.34) — `view_item` of a non-default layout.
|
|
8330
|
+
layout_id: ctx.layoutId,
|
|
8331
|
+
layout_revision: ctx.layoutRevision,
|
|
8332
|
+
experiment_id: ctx.experimentId,
|
|
8333
|
+
variant_id: ctx.variantId
|
|
8134
8334
|
});
|
|
8135
8335
|
const com = opts.commerce;
|
|
8136
8336
|
const commerce = com ? compact({
|
|
8137
8337
|
// The collector rejects an event with more lines than its cap, whole.
|
|
8138
|
-
items: com.items?.slice(0, MAX_ITEMS).map(
|
|
8139
|
-
|
|
8338
|
+
items: com.items?.slice(0, MAX_ITEMS).map((i) => ({
|
|
8339
|
+
...compact({
|
|
8140
8340
|
product_id: String(i.productId),
|
|
8141
8341
|
name: this.options.privateContent ? void 0 : i.name,
|
|
8142
8342
|
brand: this.options.privateContent ? void 0 : i.brand,
|
|
8143
8343
|
variant_id: i.variantId !== void 0 ? String(i.variantId) : void 0,
|
|
8144
8344
|
price: i.price,
|
|
8145
8345
|
quantity: i.quantity
|
|
8146
|
-
})
|
|
8147
|
-
|
|
8346
|
+
}),
|
|
8347
|
+
...itemLayoutWire(i)
|
|
8348
|
+
})),
|
|
8148
8349
|
value: com.value,
|
|
8149
8350
|
currency: com.currency,
|
|
8150
8351
|
order_id: com.orderId,
|
|
@@ -8301,16 +8502,19 @@ var AnalyticsManager = class extends EventTarget {
|
|
|
8301
8502
|
this.track("add_to_cart", {
|
|
8302
8503
|
context: { sponsorId: d.sponsorId !== void 0 ? Number(d.sponsorId) : void 0, campaignId: campaignOf(d), slot: slotOf(d), componentTemplateId: templateOf(d), ...contentOf(d) },
|
|
8303
8504
|
commerce: {
|
|
8304
|
-
|
|
8505
|
+
// The detail layout the units were added from (0.34): the add's own
|
|
8506
|
+
// (`detail.layout`, set by <vio-product-detail>), '' when none.
|
|
8507
|
+
items: withLineLayouts([
|
|
8305
8508
|
{
|
|
8306
8509
|
productId: d.productId ?? line?.productId ?? "",
|
|
8307
8510
|
name: line?.name,
|
|
8308
8511
|
brand: line?.brand,
|
|
8309
8512
|
variantId: d.variantId ?? line?.variantId,
|
|
8310
8513
|
price: line?.unitPrice,
|
|
8311
|
-
quantity: d.quantity ?? 1
|
|
8514
|
+
quantity: d.quantity ?? 1,
|
|
8515
|
+
...itemLayoutOf(normalizeLayoutOrigin(d.layout))
|
|
8312
8516
|
}
|
|
8313
|
-
],
|
|
8517
|
+
]),
|
|
8314
8518
|
value: line ? line.unitPrice * (d.quantity ?? 1) : void 0,
|
|
8315
8519
|
currency: line?.currency
|
|
8316
8520
|
}
|
|
@@ -8322,16 +8526,17 @@ var AnalyticsManager = class extends EventTarget {
|
|
|
8322
8526
|
this.track("remove_from_cart", {
|
|
8323
8527
|
context: { sponsorId: d.sponsorId, campaignId: campaignOf(d), slot: slotOf(d), ...contentOf(d) },
|
|
8324
8528
|
commerce: {
|
|
8325
|
-
items: [
|
|
8529
|
+
items: withLineLayouts([
|
|
8326
8530
|
{
|
|
8327
8531
|
productId: d.productId,
|
|
8328
8532
|
variantId: d.variantId,
|
|
8329
8533
|
name: d.name,
|
|
8330
8534
|
brand: d.brand,
|
|
8331
8535
|
price: d.price,
|
|
8332
|
-
quantity: d.quantity
|
|
8536
|
+
quantity: d.quantity,
|
|
8537
|
+
...itemLayoutOf(normalizeLayoutOrigin(d.layout))
|
|
8333
8538
|
}
|
|
8334
|
-
],
|
|
8539
|
+
]),
|
|
8335
8540
|
value: (d.price ?? 0) * (d.quantity ?? 1),
|
|
8336
8541
|
currency: d.currency
|
|
8337
8542
|
}
|
|
@@ -8634,14 +8839,8 @@ var AnalyticsManager = class extends EventTarget {
|
|
|
8634
8839
|
}
|
|
8635
8840
|
if (items.length === 0) return null;
|
|
8636
8841
|
return {
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
name: i.name,
|
|
8640
|
-
brand: i.brand,
|
|
8641
|
-
variantId: i.variantId,
|
|
8642
|
-
price: i.unitPrice,
|
|
8643
|
-
quantity: i.quantity
|
|
8644
|
-
})),
|
|
8842
|
+
// One item per line and detail layout (0.34), each saying its layout.
|
|
8843
|
+
items: withLineLayouts(lineItemsByLayout(items)),
|
|
8645
8844
|
value: items.reduce((sum, i) => sum + i.unitPrice * (i.quantity ?? 1), 0),
|
|
8646
8845
|
currency: items[0]?.currency ?? this.lastCartSnapshot?.currency
|
|
8647
8846
|
};
|
|
@@ -8695,6 +8894,27 @@ function impressionCommerce(read) {
|
|
|
8695
8894
|
return void 0;
|
|
8696
8895
|
}
|
|
8697
8896
|
}
|
|
8897
|
+
function itemLayoutWire(i) {
|
|
8898
|
+
if (i.layoutId === void 0 && i.layoutRevision === void 0 && i.experimentId === void 0 && i.experimentVariantId === void 0) {
|
|
8899
|
+
return {};
|
|
8900
|
+
}
|
|
8901
|
+
const token = (v) => layoutToken(v) ?? "";
|
|
8902
|
+
return {
|
|
8903
|
+
layout_id: token(i.layoutId),
|
|
8904
|
+
layout_revision: token(i.layoutRevision),
|
|
8905
|
+
experiment_id: token(i.experimentId),
|
|
8906
|
+
experiment_variant_id: token(i.experimentVariantId)
|
|
8907
|
+
};
|
|
8908
|
+
}
|
|
8909
|
+
function withLineLayouts(items) {
|
|
8910
|
+
return items?.map((i) => ({
|
|
8911
|
+
...i,
|
|
8912
|
+
layoutId: i.layoutId ?? "",
|
|
8913
|
+
layoutRevision: i.layoutRevision ?? "",
|
|
8914
|
+
experimentId: i.experimentId ?? "",
|
|
8915
|
+
experimentVariantId: i.experimentVariantId ?? ""
|
|
8916
|
+
}));
|
|
8917
|
+
}
|
|
8698
8918
|
function compact(obj) {
|
|
8699
8919
|
const out = {};
|
|
8700
8920
|
for (const [k, v] of Object.entries(obj)) {
|
|
@@ -8762,7 +8982,7 @@ function capTitle(value) {
|
|
|
8762
8982
|
return value.length > CONTENT_TITLE_MAX_LENGTH ? value.slice(0, CONTENT_TITLE_MAX_LENGTH) : value;
|
|
8763
8983
|
}
|
|
8764
8984
|
function sliceCommerce(slice) {
|
|
8765
|
-
return { items: slice.items, value: slice.value, currency: slice.currency };
|
|
8985
|
+
return { items: withLineLayouts(slice.items), value: slice.value, currency: slice.currency };
|
|
8766
8986
|
}
|
|
8767
8987
|
function slotOf(detail) {
|
|
8768
8988
|
return typeof detail.slot === "string" && detail.slot.trim() ? detail.slot.trim() : void 0;
|
|
@@ -9096,6 +9316,25 @@ var VioFacade = class {
|
|
|
9096
9316
|
}
|
|
9097
9317
|
return resolveContent(init);
|
|
9098
9318
|
}
|
|
9319
|
+
/**
|
|
9320
|
+
* Page-wide options of every `<vio-product-detail>` (0.34). `layout` orders
|
|
9321
|
+
* the sections below the gallery — `{ id, revision, sections, experimentId?,
|
|
9322
|
+
* variantId? }`; `null` goes back to the default; a detail's own `layout`
|
|
9323
|
+
* wins. Open details re-render at once, later ones open with it. A key left
|
|
9324
|
+
* out of the call is left as it is. See README «Section order and layout
|
|
9325
|
+
* tracking».
|
|
9326
|
+
*/
|
|
9327
|
+
configureDetail(options = {}) {
|
|
9328
|
+
if (options && typeof options === "object" && "layout" in options) setGlobalDetailLayout(options.layout ?? null);
|
|
9329
|
+
}
|
|
9330
|
+
/**
|
|
9331
|
+
* The layout a `<vio-product-detail>` without its own `layout` applies now:
|
|
9332
|
+
* the page's (`source: 'global'`) or the default. A detail's own is
|
|
9333
|
+
* `el.appliedLayout`. A copy; never throws.
|
|
9334
|
+
*/
|
|
9335
|
+
detailLayout() {
|
|
9336
|
+
return copyAppliedLayout(resolveDetailLayout(null));
|
|
9337
|
+
}
|
|
9099
9338
|
get isInitialized() {
|
|
9100
9339
|
return Configuration.isInitialized;
|
|
9101
9340
|
}
|
|
@@ -9978,6 +10217,6 @@ function vippsButtonAttributes(verb = "buy", opts = {}) {
|
|
|
9978
10217
|
};
|
|
9979
10218
|
}
|
|
9980
10219
|
|
|
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-
|
|
10220
|
+
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, 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 };
|
|
10221
|
+
//# sourceMappingURL=chunk-QA5R4VYF.js.map
|
|
10222
|
+
//# sourceMappingURL=chunk-QA5R4VYF.js.map
|