@vio-live/web-sdk 0.9.1 → 0.11.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.
@@ -802,6 +802,37 @@ interface QliroOrder {
802
802
  total_price?: number;
803
803
  }
804
804
 
805
+ /**
806
+ * Qliro's browser-side protocol (`q1`).
807
+ *
808
+ * The embedded widget publishes a `q1` object on the window and calls a
809
+ * globally-defined `q1Ready` once it has rendered. Everything the customer
810
+ * does inside the iframe — picking a shipping method, changing their address,
811
+ * having a payment declined — is only observable through these listeners.
812
+ * Without them the widget is a black box: the customer can change the
813
+ * shipping and our own summary keeps showing the old total.
814
+ *
815
+ * Two rules from Qliro's documentation shape this module:
816
+ *
817
+ * 1. **Lock before touching the backend.** Otherwise the customer can
818
+ * complete the purchase while the order is still being synchronized.
819
+ * 2. **Compare before unlocking.** Otherwise a second change interrupts the
820
+ * synchronization of the first.
821
+ *
822
+ * We compare on `MerchantUpdateVersion`, the token Qliro echoes back through
823
+ * `onOrderUpdated`, rather than on totals. Totals cannot be the test here: in
824
+ * the modes where Qliro owns the shipping amount our total and Qliro's
825
+ * legitimately differ, and the customer would sit locked out of a checkout
826
+ * that is in fact up to date.
827
+ */
828
+
829
+ interface QliroSyncResult {
830
+ order_id: string;
831
+ /** Token to wait for in `onOrderUpdated` before unlocking. */
832
+ update_version: string;
833
+ total_price: number;
834
+ }
835
+
805
836
  /**
806
837
  * Walley (former Collector) — embedded checkout via Vio Commerce.
807
838
  *
@@ -951,6 +982,8 @@ declare class CheckoutManager extends EventTarget {
951
982
  private applePayPublishableKey;
952
983
  private applePayConnectedAccount;
953
984
  private klarnaAvailableCache;
985
+ /** Live q1 listeners while a Qliro widget is mounted. */
986
+ private qliroController;
954
987
  private klarnaOrderInFlight;
955
988
  /** Last backend shippings fetched (per-supplier), for UI reuse. */
956
989
  private lastFetchedShippings;
@@ -1025,6 +1058,21 @@ declare class CheckoutManager extends EventTarget {
1025
1058
  * html_snippet into `container` (widget-does-everything, like Kustom).
1026
1059
  */
1027
1060
  mountQliroCheckout(container: HTMLElement, sponsorId?: number): Promise<QliroOrder>;
1061
+ /**
1062
+ * Everything the customer does inside the Qliro iframe, re-published as a
1063
+ * DOM event so a host page can follow a checkout it cannot see into.
1064
+ */
1065
+ private onQliroEvent;
1066
+ /**
1067
+ * Push the current cart onto the open Qliro order.
1068
+ *
1069
+ * Call it after changing the cart while the widget is open: it holds
1070
+ * `q1.lock()` across the round trip and unlocks once Qliro confirms it is
1071
+ * showing the new version. A no-op when no Qliro widget is mounted.
1072
+ */
1073
+ syncQliroOrder(): Promise<QliroSyncResult | null>;
1074
+ /** Drop the Qliro listeners and release any lock still held. */
1075
+ destroyQliroListeners(): void;
1028
1076
  /** Re-read the Qliro order owned by a checkout — the confirmation trip. */
1029
1077
  getQliroOrder(checkoutId: string, sponsorId?: number): Promise<QliroOrder | null>;
1030
1078
  /**
@@ -1202,7 +1250,7 @@ declare class CheckoutManager extends EventTarget {
1202
1250
  * the publisher-facing feature; NOT part of the Vio pipeline)
1203
1251
  * 3. `vio:analytics` DOM event — always when started (inspector/bridges)
1204
1252
  */
1205
- declare const ANALYTICS_EVENT_NAMES: readonly ["view_item_list", "select_item", "view_item", "add_to_cart", "view_cart", "begin_checkout", "purchase", "component_impression", "component_click", "ad_impression", "ad_click", "poll_impression", "contest_impression", "session_start", "session_end"];
1253
+ declare const ANALYTICS_EVENT_NAMES: readonly ["view_item_list", "select_item", "view_item", "add_to_cart", "remove_from_cart", "view_cart", "begin_checkout", "purchase", "component_impression", "component_click", "ad_impression", "ad_click", "poll_impression", "contest_impression", "session_start", "session_end", "checkout_error", "sdk_error"];
1206
1254
  type AnalyticsEventName = (typeof ANALYTICS_EVENT_NAMES)[number];
1207
1255
  /** Camel-case for DX; mapped to the snake_case wire format at build time. */
1208
1256
  interface AnalyticsContext {
@@ -1224,6 +1272,8 @@ interface AnalyticsContext {
1224
1272
  contentId?: string | number;
1225
1273
  /** Human-readable content snapshot; auto-filled from document.title. */
1226
1274
  contentTitle?: string;
1275
+ /** Código corto del fallo (`sdk_error` / `checkout_error`). */
1276
+ errorCode?: string;
1227
1277
  variant?: string;
1228
1278
  }
1229
1279
  interface AnalyticsItemInput {
@@ -1249,6 +1299,13 @@ interface TrackOptions {
1249
1299
  interface AnalyticsStartOptions {
1250
1300
  /** Where the SDK is embedded: 'vev' | 'replit' | 'custom' | … Default 'custom'. */
1251
1301
  host?: string;
1302
+ /**
1303
+ * Arrancar en modo cookieless hasta que el host llame `setConsent(true)`.
1304
+ * Default false: el SDK asume que el CMP del publisher ya decidió si nos
1305
+ * carga. Los publishers EU que necesitan medir antes del consentimiento
1306
+ * (o no pueden persistir sin él) ponen true.
1307
+ */
1308
+ requireConsent?: boolean;
1252
1309
  /**
1253
1310
  * Install the automatic funnel listeners (vio:added-to-cart,
1254
1311
  * vio:checkout-open, vio:open-cart, vio:payment-success). Default true.
@@ -1282,6 +1339,9 @@ declare class AnalyticsManager extends EventTarget {
1282
1339
  private retryNotBefore;
1283
1340
  private externalUserId;
1284
1341
  private sessionId;
1342
+ private requireConsent;
1343
+ private consentGranted;
1344
+ private anonIdCache;
1285
1345
  /** Set via start({ sessionId }) — the host owns the session, we follow. */
1286
1346
  private externalSessionId;
1287
1347
  private sessionStartedAt;
@@ -1295,6 +1355,16 @@ declare class AnalyticsManager extends EventTarget {
1295
1355
  * Install listeners + begin flushing. Explicit on purpose (no module
1296
1356
  * side-effects). Safe to call twice (second call only updates options).
1297
1357
  */
1358
+ /**
1359
+ * Consentimiento (ePrivacy/GDPR). Por defecto el SDK asume que el host ya
1360
+ * lo gestionó — su CMP decide si nos carga. Con `requireConsent: true`
1361
+ * arranca en modo **cookieless**: mide la visita con ids efímeros en
1362
+ * memoria y NO escribe nada en localStorage hasta que el host llame
1363
+ * `setConsent(true)`. Retirarlo borra lo persistido.
1364
+ */
1365
+ setConsent(granted: boolean): void;
1366
+ /** ¿Podemos escribir en el dispositivo? */
1367
+ private get canPersist();
1298
1368
  start(options?: AnalyticsStartOptions): void;
1299
1369
  /** Stop timers + listeners (tests / SPA unmount). Queue survives. */
1300
1370
  stop(): void;
@@ -1320,6 +1390,8 @@ declare class AnalyticsManager extends EventTarget {
1320
1390
  /** Force a flush (mostly for tests). */
1321
1391
  flush(): Promise<void>;
1322
1392
  private buildEvent;
1393
+ /** Guarda la sesión solo si podemos escribir en el dispositivo. */
1394
+ private persistSession;
1323
1395
  private anonId;
1324
1396
  /** Rolling session: renewed by activity, rotated after 30 min idle. */
1325
1397
  private ensureSession;
@@ -1384,6 +1456,6 @@ declare const Vio: VioFacade;
1384
1456
  *
1385
1457
  * RELEASE CHECKLIST: bump together with package.json (see CONTRIBUTING).
1386
1458
  */
1387
- declare const SDK_VERSION = "0.9.1";
1459
+ declare const SDK_VERSION = "0.11.0";
1388
1460
 
1389
1461
  export { ADD_ITEM_MUTATION, type AddManualOptions, type AddProductOptions, type AnalyticsCommerce, type AnalyticsContext, type AnalyticsEventName, type AnalyticsItemInput, AnalyticsManager, type AnalyticsStartOptions, type ApplePayConfig, type ApplePayResult, type BootstrapResponse, CREATE_CART_MUTATION, CREATE_CHECKOUT_MUTATION, CREATE_PAYMENT_STRIPE_MUTATION, CREATE_PAYMENT_VIPPS_MUTATION, type CartChangeDetail, type CartLineItem, CartManager, type CartQueryOptions, type CheckoutAddress, type CheckoutChangeDetail, CheckoutManager, type CheckoutState, CommerceClient, Configuration, type CreatePaymentVippsResponse, type CreatePaymentVippsVariables, DELETE_ITEM_MUTATION, type Environment, GET_AVAILABLE_PAYMENT_METHODS_QUERY, GET_CART_QUERY, GET_CHECKOUT_QUERY, GET_LINE_ITEMS_BY_SUPPLIER_QUERY, GET_VIPPS_STATUS_QUERY, type GetVippsStatusVariables, type ImageSize, type PaymentCompleteDetail, type PaymentMethod, type PaymentSelectDetail, type PlacementComponent, type Product, type ProductCategory, type ProductImage, type ProductOption, type ProductPrice, type ProductVariant, type ResolvedConfig, SDK_VERSION, type Sponsor, type SponsorCartState, type SponsorCommerceBlock, type TrackOptions, UPDATE_CHECKOUT_MUTATION, UPDATE_ITEM_MUTATION, UPDATE_SHIPPINGS_BY_SUPPLIER_MUTATION, Vio, VioApi, VioApiError, type VioConfig, type VippsPaymentState, type VippsStatusResult, 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 };
@@ -1,4 +1,4 @@
1
1
  import '../chunk-QYQQ5J6E.js';
2
- export { ADD_ITEM_MUTATION, 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, SDK_VERSION, 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-WKJRYYNI.js';
2
+ export { ADD_ITEM_MUTATION, 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, SDK_VERSION, 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-U2QG4IVJ.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-QYQQ5J6E.js';
2
- export { ADD_ITEM_MUTATION, 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, SDK_VERSION, 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-WKJRYYNI.js';
2
+ export { ADD_ITEM_MUTATION, 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, SDK_VERSION, 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-U2QG4IVJ.js';
3
3
  //# sourceMappingURL=index.js.map
4
4
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
- import { registerVioElements, VioProduct, VioProductCarousel, VioProductDetail, VioCart, VioCheckout } from '../chunk-PRMVVF5C.js';
2
- export { VioTokens, applyVioTheme } from '../chunk-PRMVVF5C.js';
3
- import '../chunk-WKJRYYNI.js';
1
+ import { registerVioElements, VioProduct, VioProductCarousel, VioProductDetail, VioCart, VioCheckout } from '../chunk-XU5LGUBU.js';
2
+ export { VioTokens, applyVioTheme } from '../chunk-XU5LGUBU.js';
3
+ import '../chunk-U2QG4IVJ.js';
4
4
  import * as React from 'react';
5
5
 
6
6
  // node_modules/@lit/react/node/create-component.js
package/dist/ui/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { registerVioElements } from '../chunk-PRMVVF5C.js';
2
- export { VioCart, VioCheckout, VioProduct, VioProductCarousel, VioProductDetail, VioTokens, applyVioTheme, registerVioElements } from '../chunk-PRMVVF5C.js';
3
- import '../chunk-WKJRYYNI.js';
1
+ import { registerVioElements } from '../chunk-XU5LGUBU.js';
2
+ export { VioCart, VioCheckout, VioProduct, VioProductCarousel, VioProductDetail, VioTokens, applyVioTheme, registerVioElements } from '../chunk-XU5LGUBU.js';
3
+ import '../chunk-U2QG4IVJ.js';
4
4
 
5
5
  // src/ui/index.ts
6
6
  registerVioElements();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vio-live/web-sdk",
3
- "version": "0.9.1",
4
- "description": "Vio Web SDK \u2014 in-site shoppable + native checkout, designed for editorial commerce sites",
3
+ "version": "0.11.0",
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",
7
7
  "module": "./dist/index.js",