@vio-live/web-sdk 0.19.0 → 0.21.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/dist/{chunk-NUNGU6LL.js → chunk-MRJR6DG5.js} +326 -38
- package/dist/chunk-MRJR6DG5.js.map +1 -0
- package/dist/{chunk-CMNTHF66.js → chunk-WTVGVDZX.js} +86 -18
- package/dist/chunk-WTVGVDZX.js.map +1 -0
- package/dist/core/index.d.ts +118 -5
- package/dist/core/index.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +3 -3
- package/dist/{tokens-IrVSMVcA.d.ts → tokens-Dkbfcd1L.d.ts} +12 -0
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-CMNTHF66.js.map +0 -1
- package/dist/chunk-NUNGU6LL.js.map +0 -1
|
@@ -1208,6 +1208,7 @@ query GetCheckout($checkoutId: String!) {
|
|
|
1208
1208
|
status
|
|
1209
1209
|
checkout_url
|
|
1210
1210
|
origin_payment_id
|
|
1211
|
+
duplicate_of
|
|
1211
1212
|
billing_address {
|
|
1212
1213
|
id
|
|
1213
1214
|
first_name
|
|
@@ -1538,6 +1539,7 @@ query GetVippsStatus($checkoutId: String!) {
|
|
|
1538
1539
|
Payment {
|
|
1539
1540
|
GetVippsStatus(checkout_id: $checkoutId) {
|
|
1540
1541
|
state
|
|
1542
|
+
duplicate_of
|
|
1541
1543
|
}
|
|
1542
1544
|
}
|
|
1543
1545
|
}
|
|
@@ -2216,7 +2218,7 @@ async function prepareApplePay(config) {
|
|
|
2216
2218
|
}
|
|
2217
2219
|
|
|
2218
2220
|
// src/core/version.ts
|
|
2219
|
-
var SDK_VERSION = "0.
|
|
2221
|
+
var SDK_VERSION = "0.21.0";
|
|
2220
2222
|
|
|
2221
2223
|
// src/core/checkout/payments/stripe-embedded.ts
|
|
2222
2224
|
var CREATE_PAYMENT_INTENT_STRIPE_MUTATION = `
|
|
@@ -5747,15 +5749,16 @@ var AnalyticsManager = class extends EventTarget {
|
|
|
5747
5749
|
if (!Configuration.isInitialized) return;
|
|
5748
5750
|
if (Date.now() < this.retryNotBefore) return;
|
|
5749
5751
|
const batch = this.queue.splice(0, MAX_QUEUE);
|
|
5752
|
+
const apiKey = Configuration.get().apiKey;
|
|
5750
5753
|
const body = JSON.stringify({
|
|
5751
|
-
apiKey
|
|
5754
|
+
apiKey,
|
|
5752
5755
|
sent_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5753
5756
|
events: batch
|
|
5754
5757
|
});
|
|
5755
5758
|
try {
|
|
5756
5759
|
const res = await fetch(`${eventsBase()}/v1/events`, {
|
|
5757
5760
|
method: "POST",
|
|
5758
|
-
headers: { "Content-Type": "application/json" },
|
|
5761
|
+
headers: { "Content-Type": "application/json", "X-Api-Key": apiKey },
|
|
5759
5762
|
body,
|
|
5760
5763
|
keepalive: batch.length <= 20
|
|
5761
5764
|
// keepalive caps payload at ~64KB
|
|
@@ -5783,7 +5786,7 @@ var AnalyticsManager = class extends EventTarget {
|
|
|
5783
5786
|
const boot = vioBootstrapCache();
|
|
5784
5787
|
const ctx = opts.context ?? {};
|
|
5785
5788
|
const context = compact({
|
|
5786
|
-
campaign_id: ctx
|
|
5789
|
+
campaign_id: resolveCampaignId(ctx, boot),
|
|
5787
5790
|
broadcast_id: ctx.broadcastId,
|
|
5788
5791
|
campaign_component_id: ctx.campaignComponentId,
|
|
5789
5792
|
app_placement_id: ctx.appPlacementId,
|
|
@@ -6027,8 +6030,10 @@ var AnalyticsManager = class extends EventTarget {
|
|
|
6027
6030
|
this.track("purchase", {
|
|
6028
6031
|
context: { sponsorId },
|
|
6029
6032
|
commerce: {
|
|
6033
|
+
// value / currency / items: the cart snapshot, on every path.
|
|
6030
6034
|
...snap ?? {},
|
|
6031
|
-
|
|
6035
|
+
// order_id: Vio's id for the purchase (never the provider's).
|
|
6036
|
+
...purchaseFromPaymentSuccess(d),
|
|
6032
6037
|
paymentMethod: d.method
|
|
6033
6038
|
}
|
|
6034
6039
|
});
|
|
@@ -6126,6 +6131,52 @@ function vioCart() {
|
|
|
6126
6131
|
return null;
|
|
6127
6132
|
}
|
|
6128
6133
|
}
|
|
6134
|
+
function resolveCampaignId(ctx, boot) {
|
|
6135
|
+
if (ctx.campaignId !== void 0) return ctx.campaignId;
|
|
6136
|
+
const defaultId = boot?.campaign?.id;
|
|
6137
|
+
const sponsorId = toNumber(ctx.sponsorId);
|
|
6138
|
+
if (sponsorId === void 0) return defaultId;
|
|
6139
|
+
try {
|
|
6140
|
+
const campaigns = Array.isArray(boot?.campaigns) ? boot.campaigns : [];
|
|
6141
|
+
const matches = campaigns.filter(
|
|
6142
|
+
(c) => !!c && typeof c === "object" && c.status === "active" && campaignSponsorIds(c).includes(sponsorId)
|
|
6143
|
+
);
|
|
6144
|
+
const chosen = matches.find((c) => c.id === defaultId) ?? matches[0];
|
|
6145
|
+
const chosenId = toNumber(chosen?.id);
|
|
6146
|
+
if (chosenId !== void 0) return chosenId;
|
|
6147
|
+
} catch {
|
|
6148
|
+
}
|
|
6149
|
+
return defaultId;
|
|
6150
|
+
}
|
|
6151
|
+
function campaignSponsorIds(campaign) {
|
|
6152
|
+
const ids = [];
|
|
6153
|
+
const primary = toNumber(campaign.primarySponsor?.id);
|
|
6154
|
+
if (primary !== void 0) ids.push(primary);
|
|
6155
|
+
const secondaries = Array.isArray(campaign.secondarySponsors) ? campaign.secondarySponsors : [];
|
|
6156
|
+
for (const s of secondaries) {
|
|
6157
|
+
const id = toNumber(s?.id);
|
|
6158
|
+
if (id !== void 0) ids.push(id);
|
|
6159
|
+
}
|
|
6160
|
+
return ids;
|
|
6161
|
+
}
|
|
6162
|
+
function purchaseFromPaymentSuccess(d) {
|
|
6163
|
+
const r = d.result ?? {};
|
|
6164
|
+
const orderId = firstId(d.orderId, r.confirmation?.orderId, d.checkoutId);
|
|
6165
|
+
return orderId !== void 0 ? { orderId } : {};
|
|
6166
|
+
}
|
|
6167
|
+
function firstId(...candidates) {
|
|
6168
|
+
for (const c of candidates) {
|
|
6169
|
+
if (c === void 0 || c === null) continue;
|
|
6170
|
+
const s = String(c);
|
|
6171
|
+
if (s !== "") return s;
|
|
6172
|
+
}
|
|
6173
|
+
return void 0;
|
|
6174
|
+
}
|
|
6175
|
+
function toNumber(value) {
|
|
6176
|
+
if (value === void 0 || value === null || value === "") return void 0;
|
|
6177
|
+
const n = Number(value);
|
|
6178
|
+
return Number.isFinite(n) ? n : void 0;
|
|
6179
|
+
}
|
|
6129
6180
|
function pushGa4(event) {
|
|
6130
6181
|
const commerceNames = /* @__PURE__ */ new Set([
|
|
6131
6182
|
"view_item_list",
|
|
@@ -6171,6 +6222,10 @@ var VioFacade = class {
|
|
|
6171
6222
|
/** Last bootstrap failure — short backoff so cart mutations don't hammer a
|
|
6172
6223
|
* dead endpoint on every call. */
|
|
6173
6224
|
this.bootstrapFailedAt = 0;
|
|
6225
|
+
/** Bumped by every init(). A bootstrap started under an older configuration
|
|
6226
|
+
* (another key or environment) is still in flight after a re-init; its answer
|
|
6227
|
+
* belongs to that configuration and must not land in this one. */
|
|
6228
|
+
this.generation = 0;
|
|
6174
6229
|
// Client-side managers — created lazily on first access. They don't
|
|
6175
6230
|
// need Vio.init() to work (state is purely local).
|
|
6176
6231
|
this.cartManager = null;
|
|
@@ -6184,6 +6239,7 @@ var VioFacade = class {
|
|
|
6184
6239
|
this.bootstrapPromise = null;
|
|
6185
6240
|
this.cachedBootstrap = null;
|
|
6186
6241
|
this.bootstrapFailedAt = 0;
|
|
6242
|
+
this.generation++;
|
|
6187
6243
|
this.checkoutManager?.clearPaymentMethodsCache();
|
|
6188
6244
|
}
|
|
6189
6245
|
get isInitialized() {
|
|
@@ -6223,6 +6279,11 @@ var VioFacade = class {
|
|
|
6223
6279
|
/**
|
|
6224
6280
|
* Bootstrap — fetches client config and caches it. Dedupes in-flight
|
|
6225
6281
|
* concurrent requests.
|
|
6282
|
+
*
|
|
6283
|
+
* A request that was started before the last init() (Vev starts with the key
|
|
6284
|
+
* the browser remembers, then the page's own key arrives) answers for a key
|
|
6285
|
+
* that is gone: it neither fills the cache nor arms the failure backoff, and
|
|
6286
|
+
* whoever awaited it gets the current configuration's bootstrap instead.
|
|
6226
6287
|
*/
|
|
6227
6288
|
async bootstrap() {
|
|
6228
6289
|
if (this.cachedBootstrap) return this.cachedBootstrap;
|
|
@@ -6230,17 +6291,24 @@ var VioFacade = class {
|
|
|
6230
6291
|
if (this.bootstrapFailedAt && Date.now() - this.bootstrapFailedAt < 5e3) {
|
|
6231
6292
|
throw new Error("[Vio] bootstrap recently failed \u2014 backing off");
|
|
6232
6293
|
}
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6294
|
+
const generation = this.generation;
|
|
6295
|
+
const promise = this.api.bootstrap().then(
|
|
6296
|
+
(res) => {
|
|
6297
|
+
if (generation !== this.generation) return this.bootstrap();
|
|
6298
|
+
this.cachedBootstrap = res;
|
|
6299
|
+
this.bootstrapFailedAt = 0;
|
|
6300
|
+
return res;
|
|
6301
|
+
},
|
|
6302
|
+
(err) => {
|
|
6303
|
+
if (generation !== this.generation) return this.bootstrap();
|
|
6304
|
+
this.bootstrapFailedAt = Date.now();
|
|
6305
|
+
throw err;
|
|
6306
|
+
}
|
|
6307
|
+
).finally(() => {
|
|
6308
|
+
if (this.bootstrapPromise === promise) this.bootstrapPromise = null;
|
|
6242
6309
|
});
|
|
6243
|
-
|
|
6310
|
+
this.bootstrapPromise = promise;
|
|
6311
|
+
return promise;
|
|
6244
6312
|
}
|
|
6245
6313
|
get bootstrapCache() {
|
|
6246
6314
|
return this.cachedBootstrap;
|
|
@@ -6329,6 +6397,6 @@ function vippsButtonAttributes(verb = "buy", opts = {}) {
|
|
|
6329
6397
|
};
|
|
6330
6398
|
}
|
|
6331
6399
|
|
|
6332
|
-
export { ADD_ITEM_MUTATION, ADYEN_RETURN_METHOD, ADYEN_RETURN_QUERY_KEYS, AdyenOriginError, AnalyticsManager, CREATE_CART_MUTATION, CREATE_CHECKOUT_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, KUSTOM_RETURN_QUERY_KEYS, SDK_VERSION, UPDATE_CHECKOUT_MUTATION, UPDATE_ITEM_MUTATION, UPDATE_SHIPPINGS_BY_SUPPLIER_MUTATION, VIPPS_BUTTON_SCRIPT, VIPPS_BUTTON_TAG, Vio, VioApi, VioApiError, __decorateClass, addItem, adyenReturnOutcome, adyenReturnParams, checkApplePayAvailability, createCart, createCheckout, createCommerceClient, createPaymentStripe, createPaymentVipps, createVioApi, deleteItem, displayPrice, ensureVippsButton, executeCartGraphQL, formatPrice, getAvailablePaymentMethods, getCart, getCartGraphQLOptions, getCheckout, getCustomerSessionId, getGlobalCurrency, getLineItemsBySupplier, getVippsStatus, kustomReturnOutcome, nexiReturnPaymentId, primaryImageUrl, readNexiPending, showApplePaySheet, updateCheckout, updateItem, updateShippingsBySupplier, vippsButtonAttributes };
|
|
6333
|
-
//# sourceMappingURL=chunk-
|
|
6334
|
-
//# sourceMappingURL=chunk-
|
|
6400
|
+
export { ADD_ITEM_MUTATION, ADYEN_RETURN_METHOD, ADYEN_RETURN_QUERY_KEYS, AdyenOriginError, AnalyticsManager, CREATE_CART_MUTATION, CREATE_CHECKOUT_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, KUSTOM_RETURN_QUERY_KEYS, SDK_VERSION, UPDATE_CHECKOUT_MUTATION, UPDATE_ITEM_MUTATION, UPDATE_SHIPPINGS_BY_SUPPLIER_MUTATION, VIPPS_BUTTON_SCRIPT, VIPPS_BUTTON_TAG, Vio, VioApi, VioApiError, __decorateClass, addItem, adyenReturnOutcome, adyenReturnParams, checkApplePayAvailability, createCart, createCheckout, createCommerceClient, createPaymentStripe, createPaymentVipps, createVioApi, deleteItem, displayPrice, ensureVippsButton, executeCartGraphQL, formatPrice, getAvailablePaymentMethods, getCart, getCartGraphQLOptions, getCheckout, getCustomerSessionId, getGlobalCurrency, getLineItemsBySupplier, getVippsStatus, kustomReturnOutcome, nexiReturnPaymentId, primaryImageUrl, purchaseFromPaymentSuccess, readNexiPending, resolveCampaignId, showApplePaySheet, updateCheckout, updateItem, updateShippingsBySupplier, vippsButtonAttributes };
|
|
6401
|
+
//# sourceMappingURL=chunk-WTVGVDZX.js.map
|
|
6402
|
+
//# sourceMappingURL=chunk-WTVGVDZX.js.map
|