@vio-live/web-sdk 0.4.0 → 0.4.2

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.
@@ -381,8 +381,18 @@ declare class CartManager extends EventTarget {
381
381
  * slow response can't overwrite the state of a newer one. */
382
382
  private mutationSeq;
383
383
  private appliedSeq;
384
+ /** In-flight AddItem/UpdateItem/DeleteItem per sponsor. Callers that need
385
+ * the backend cart to reflect a just-made change (e.g. fetching shippings
386
+ * right after an add) should `await waitForCartMutations(sponsorId)` first
387
+ * — otherwise they can race the mutation and see the cart from before it
388
+ * landed (Alan, 2026-08-18: shippings queried before AddItem settled,
389
+ * came back empty). */
390
+ private inFlightMutations;
384
391
  constructor();
385
392
  private nextSeq;
393
+ /** Resolves once any in-flight AddItem/UpdateItem/DeleteItem for this
394
+ * sponsor has settled (success or failure). No-op if nothing is pending. */
395
+ waitForCartMutations(sponsorId: number): Promise<void>;
386
396
  /** Apply a backend response only if no newer response was applied already. */
387
397
  private applyBackendCart;
388
398
  /** Surface a cart sync problem to hosts/UI (and the console). */
@@ -611,6 +621,8 @@ interface KlarnaPaymentsApi {
611
621
  payment_method_category?: string;
612
622
  auto_finalize?: boolean;
613
623
  }, data: Record<string, unknown>, cb?: (res: KpAuthorizeResult) => void): void;
624
+ /** Debug/lifecycle events — e.g. 'fullscreenOverlayShown'/'fullscreenOverlayHidden'. */
625
+ on?(event: string, cb: () => void): void;
614
626
  }
615
627
  interface KlarnaGlobal {
616
628
  Payments: KlarnaPaymentsApi;
@@ -716,8 +728,9 @@ interface KlarnaPaymentsHandle {
716
728
  load(category?: string): Promise<{
717
729
  showForm: boolean;
718
730
  }>;
719
- /** Authorize the selected method and (on approval) create the order. */
720
- authorize(): Promise<void>;
731
+ /** Authorize a category (defaults to whatever's currently selected) and,
732
+ * on approval, create the order. */
733
+ authorize(category?: string): Promise<void>;
721
734
  /** Tear down the mounted widget. */
722
735
  unmount(): void;
723
736
  }
@@ -753,8 +766,12 @@ declare class CheckoutManager extends EventTarget {
753
766
  clearPaymentMethodsCache(): void;
754
767
  /**
755
768
  * Real shipping options from the backend cart (per supplier), mapped to the
756
- * KlarnaShippingOption shape (minor units). Empty array on failure — callers
757
- * fall back to the static KLARNA_SHIPPING_OPTIONS.
769
+ * KlarnaShippingOption shape (minor units). Empty array on failure/no
770
+ * options — Klarna callers use that as-is (no static fallback anymore, see
771
+ * 2026-08-18: it only ever papered over a race, now fixed via
772
+ * `waitForCartMutations`). `KLARNA_SHIPPING_OPTIONS` is still used
773
+ * separately by Apple Pay's synchronous sheet setup, which can't await
774
+ * this at all.
758
775
  */
759
776
  fetchAvailableShippings(sponsorId?: number): Promise<KlarnaShippingOption[]>;
760
777
  /** Set the chosen shipping per supplier on the backend cart. */
@@ -1,4 +1,4 @@
1
1
  import '../chunk-PBQSHIID.js';
2
- export { ADD_ITEM_MUTATION, 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, UPDATE_CHECKOUT_MUTATION, UPDATE_ITEM_MUTATION, UPDATE_SHIPPINGS_BY_SUPPLIER_MUTATION, Vio, VioApi, VioApiError, addItem, checkApplePayAvailability, createCart, createCheckout, createCommerceClient, createPaymentStripe, createPaymentVipps, createVioApi, deleteItem, displayPrice, executeCartGraphQL, formatPrice, getAvailablePaymentMethods, getCart, getCartGraphQLOptions, getCheckout, getCustomerSessionId, getGlobalCurrency, getLineItemsBySupplier, getVippsStatus, primaryImageUrl, showApplePaySheet, updateCheckout, updateItem, updateShippingsBySupplier } from '../chunk-NP2KCM7X.js';
2
+ export { ADD_ITEM_MUTATION, 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, UPDATE_CHECKOUT_MUTATION, UPDATE_ITEM_MUTATION, UPDATE_SHIPPINGS_BY_SUPPLIER_MUTATION, Vio, VioApi, VioApiError, addItem, checkApplePayAvailability, createCart, createCheckout, createCommerceClient, createPaymentStripe, createPaymentVipps, createVioApi, deleteItem, displayPrice, executeCartGraphQL, formatPrice, getAvailablePaymentMethods, getCart, getCartGraphQLOptions, getCheckout, getCustomerSessionId, getGlobalCurrency, getLineItemsBySupplier, getVippsStatus, primaryImageUrl, showApplePaySheet, updateCheckout, updateItem, updateShippingsBySupplier } from '../chunk-KMIARP6X.js';
3
3
  //# sourceMappingURL=index.js.map
4
4
  //# sourceMappingURL=index.js.map
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import './chunk-PBQSHIID.js';
2
- export { ADD_ITEM_MUTATION, 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, UPDATE_CHECKOUT_MUTATION, UPDATE_ITEM_MUTATION, UPDATE_SHIPPINGS_BY_SUPPLIER_MUTATION, Vio, VioApi, VioApiError, addItem, checkApplePayAvailability, createCart, createCheckout, createCommerceClient, createPaymentStripe, createPaymentVipps, createVioApi, deleteItem, displayPrice, executeCartGraphQL, formatPrice, getAvailablePaymentMethods, getCart, getCartGraphQLOptions, getCheckout, getCustomerSessionId, getGlobalCurrency, getLineItemsBySupplier, getVippsStatus, primaryImageUrl, showApplePaySheet, updateCheckout, updateItem, updateShippingsBySupplier } from './chunk-NP2KCM7X.js';
2
+ export { ADD_ITEM_MUTATION, 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, UPDATE_CHECKOUT_MUTATION, UPDATE_ITEM_MUTATION, UPDATE_SHIPPINGS_BY_SUPPLIER_MUTATION, Vio, VioApi, VioApiError, addItem, checkApplePayAvailability, createCart, createCheckout, createCommerceClient, createPaymentStripe, createPaymentVipps, createVioApi, deleteItem, displayPrice, executeCartGraphQL, formatPrice, getAvailablePaymentMethods, getCart, getCartGraphQLOptions, getCheckout, getCustomerSessionId, getGlobalCurrency, getLineItemsBySupplier, getVippsStatus, primaryImageUrl, showApplePaySheet, updateCheckout, updateItem, updateShippingsBySupplier } from './chunk-KMIARP6X.js';
3
3
  //# sourceMappingURL=index.js.map
4
4
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  import * as _lit_react from '@lit/react';
2
- import { V as VioCart$1, a as VioCheckout$1, b as VioProduct$1, c as VioProductCarousel$1, d as VioProductDetail$1 } from '../tokens-CvqQYURw.js';
3
- export { e as VioThemeOverrides, f as VioTokens, g as applyVioTheme } from '../tokens-CvqQYURw.js';
2
+ import { V as VioCart$1, a as VioCheckout$1, b as VioProduct$1, c as VioProductCarousel$1, d as VioProductDetail$1 } from '../tokens-DjVcB-RL.js';
3
+ export { e as VioThemeOverrides, f as VioTokens, g as applyVioTheme } from '../tokens-DjVcB-RL.js';
4
4
  import 'lit-html';
5
5
  import 'lit';
6
6
 
@@ -1,6 +1,6 @@
1
- import { registerVioElements, VioProduct, VioProductCarousel, VioProductDetail, VioCart, VioCheckout } from '../chunk-V5ZQG2H5.js';
2
- export { VioTokens, applyVioTheme } from '../chunk-V5ZQG2H5.js';
3
- import '../chunk-NP2KCM7X.js';
1
+ import { registerVioElements, VioProduct, VioProductCarousel, VioProductDetail, VioCart, VioCheckout } from '../chunk-D6IA4ZWL.js';
2
+ export { VioTokens, applyVioTheme } from '../chunk-D6IA4ZWL.js';
3
+ import '../chunk-KMIARP6X.js';
4
4
  import * as React from 'react';
5
5
 
6
6
  // node_modules/@lit/react/node/create-component.js
@@ -302,7 +302,7 @@ declare class VioCheckout extends LitElement {
302
302
  private klarnaAuthorizing;
303
303
  /** Chosen shipping option id (express flow) — drives the Klarna order total. */
304
304
  private selectedShipping;
305
- /** Real per-supplier shippings from the backend (empty → static fallback). */
305
+ /** Real per-supplier shippings from the backend. */
306
306
  private availableShippingsList;
307
307
  /** Payment method names enabled for the sponsor (backend-configured).
308
308
  * null = not loaded yet → all buttons render; [] = none enabled. */
@@ -374,7 +374,7 @@ declare class VioCheckout extends LitElement {
374
374
  /** Mount (or re-mount on amount change) the Klarna Payments widget. */
375
375
  private mountKlarnaIfNeeded;
376
376
  private unmountKlarna;
377
- /** Shippings in effect: backend per-supplier when loaded, static otherwise. */
377
+ /** Shippings in effect: backend per-supplier when loaded. */
378
378
  private get shippingList();
379
379
  /** Selected shipping option (express flow). */
380
380
  private get shippingOption();
@@ -1,4 +1,4 @@
1
- export { V as VioCart, a as VioCheckout, b as VioProduct, c as VioProductCarousel, d as VioProductDetail, e as VioThemeOverrides, f as VioTokens, g as applyVioTheme } from '../tokens-CvqQYURw.js';
1
+ export { V as VioCart, a as VioCheckout, b as VioProduct, c as VioProductCarousel, d as VioProductDetail, e as VioThemeOverrides, f as VioTokens, g as applyVioTheme } from '../tokens-DjVcB-RL.js';
2
2
  import 'lit-html';
3
3
  import 'lit';
4
4
 
package/dist/ui/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { registerVioElements } from '../chunk-V5ZQG2H5.js';
2
- export { VioCart, VioCheckout, VioProduct, VioProductCarousel, VioProductDetail, VioTokens, applyVioTheme, registerVioElements } from '../chunk-V5ZQG2H5.js';
3
- import '../chunk-NP2KCM7X.js';
1
+ import { registerVioElements } from '../chunk-D6IA4ZWL.js';
2
+ export { VioCart, VioCheckout, VioProduct, VioProductCarousel, VioProductDetail, VioTokens, applyVioTheme, registerVioElements } from '../chunk-D6IA4ZWL.js';
3
+ import '../chunk-KMIARP6X.js';
4
4
 
5
5
  // src/ui/index.ts
6
6
  registerVioElements();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vio-live/web-sdk",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Vio Web SDK — in-site shoppable + native checkout, designed for editorial commerce sites",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",