@behio/storefront-sdk 0.16.0 → 0.18.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-IVTS3F3H.mjs → chunk-L62FH6WI.mjs} +9 -0
- package/dist/{chunk-WNJ72O66.js → chunk-S7YSZHHD.js} +9 -0
- package/dist/{client-M8hW9taR.d.mts → client-B0ZSKaQh.d.mts} +52 -1
- package/dist/{client-M8hW9taR.d.ts → client-B0ZSKaQh.d.ts} +52 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/dist/next.d.mts +1 -1
- package/dist/next.d.ts +1 -1
- package/dist/next.js +2 -2
- package/dist/next.mjs +1 -1
- package/dist/react.d.mts +26 -3
- package/dist/react.d.ts +26 -3
- package/dist/react.js +159 -45
- package/dist/react.mjs +167 -53
- package/package.json +1 -1
|
@@ -156,6 +156,15 @@ var BehioStorefront = class {
|
|
|
156
156
|
query: locale ? { locale } : void 0
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Get the merchant-defined scripts (analytics, pixels, verification, custom
|
|
161
|
+
* head/body markup) to inject into the storefront. Returns only enabled
|
|
162
|
+
* entries. Render typed entries into their snippet and RAW verbatim; gate
|
|
163
|
+
* any entry with `consentRequired` behind the visitor's analytics consent.
|
|
164
|
+
*/
|
|
165
|
+
async getShopScripts() {
|
|
166
|
+
return this.request("GET", "/shop/scripts");
|
|
167
|
+
}
|
|
159
168
|
/** Set auth tokens (e.g. from localStorage) */
|
|
160
169
|
setTokens(tokens) {
|
|
161
170
|
this.accessToken = tokens.accessToken;
|
|
@@ -156,6 +156,15 @@ var BehioStorefront = class {
|
|
|
156
156
|
query: locale ? { locale } : void 0
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Get the merchant-defined scripts (analytics, pixels, verification, custom
|
|
161
|
+
* head/body markup) to inject into the storefront. Returns only enabled
|
|
162
|
+
* entries. Render typed entries into their snippet and RAW verbatim; gate
|
|
163
|
+
* any entry with `consentRequired` behind the visitor's analytics consent.
|
|
164
|
+
*/
|
|
165
|
+
async getShopScripts() {
|
|
166
|
+
return this.request("GET", "/shop/scripts");
|
|
167
|
+
}
|
|
159
168
|
/** Set auth tokens (e.g. from localStorage) */
|
|
160
169
|
setTokens(tokens) {
|
|
161
170
|
this.accessToken = tokens.accessToken;
|
|
@@ -58,6 +58,28 @@ interface ShopSeo {
|
|
|
58
58
|
ogDescription: string | null;
|
|
59
59
|
ogImage: string | null;
|
|
60
60
|
}
|
|
61
|
+
/** Kind of merchant-defined script. Typed presets render the right snippet from
|
|
62
|
+
* an id; RAW carries literal markup. */
|
|
63
|
+
type ShopScriptType = "GA4" | "GTM" | "META_PIXEL" | "GOOGLE_VERIFICATION" | "RAW";
|
|
64
|
+
/** Where in the document the script is injected. */
|
|
65
|
+
type ShopScriptPlacement = "HEAD" | "BODY_START" | "BODY_END";
|
|
66
|
+
/**
|
|
67
|
+
* A merchant-defined script delivered to the storefront for injection
|
|
68
|
+
* (analytics, pixels, verification, or arbitrary head/body markup).
|
|
69
|
+
* `value` is the id for typed entries, or the literal markup for RAW.
|
|
70
|
+
* When `consentRequired` is true the storefront must gate it behind the
|
|
71
|
+
* visitor's analytics cookie consent.
|
|
72
|
+
*/
|
|
73
|
+
interface ShopScript {
|
|
74
|
+
id: string;
|
|
75
|
+
type: ShopScriptType;
|
|
76
|
+
placement: ShopScriptPlacement;
|
|
77
|
+
value: string;
|
|
78
|
+
consentRequired: boolean;
|
|
79
|
+
}
|
|
80
|
+
interface ShopScripts {
|
|
81
|
+
scripts: ShopScript[];
|
|
82
|
+
}
|
|
61
83
|
/**
|
|
62
84
|
* Money amount displayed to a customer in a chosen currency.
|
|
63
85
|
*
|
|
@@ -356,6 +378,28 @@ interface Cart {
|
|
|
356
378
|
* min(balance, remaining due), last one partially), so they do not change
|
|
357
379
|
* `grandTotal` here; use them to list applied cards + balances in the cart. */
|
|
358
380
|
giftCards: GiftCardSummary[];
|
|
381
|
+
/** Bundle lines in the cart, separate from `items`. Manage with
|
|
382
|
+
* `cart.updateBundleQuantity` / `cart.removeBundle`. */
|
|
383
|
+
bundleLines: CartBundleLine[];
|
|
384
|
+
}
|
|
385
|
+
/** One product inside a bundle line. */
|
|
386
|
+
interface CartBundleLineItem {
|
|
387
|
+
productId: string;
|
|
388
|
+
name: string;
|
|
389
|
+
sku: string;
|
|
390
|
+
quantity: number;
|
|
391
|
+
}
|
|
392
|
+
/** A bundle added to the cart, with its own quantity + price snapshot. */
|
|
393
|
+
interface CartBundleLine {
|
|
394
|
+
id: string;
|
|
395
|
+
bundleId: string;
|
|
396
|
+
bundleSlug: string;
|
|
397
|
+
bundleName: string;
|
|
398
|
+
quantity: number;
|
|
399
|
+
/** Snapshot of the bundle's per-unit price when it was added. */
|
|
400
|
+
bundlePriceSnapshot: number;
|
|
401
|
+
currency: string;
|
|
402
|
+
items: CartBundleLineItem[];
|
|
359
403
|
}
|
|
360
404
|
/** A gift card applied to the cart, with its current balance. */
|
|
361
405
|
interface GiftCardSummary {
|
|
@@ -955,6 +999,13 @@ declare class BehioStorefront {
|
|
|
955
999
|
getShopInfo(): Promise<SdkResult<ShopInfo>>;
|
|
956
1000
|
/** Get SEO metadata for the shop homepage in the given locale (defaults to shop default). */
|
|
957
1001
|
getShopSeo(locale?: string): Promise<SdkResult<ShopSeo>>;
|
|
1002
|
+
/**
|
|
1003
|
+
* Get the merchant-defined scripts (analytics, pixels, verification, custom
|
|
1004
|
+
* head/body markup) to inject into the storefront. Returns only enabled
|
|
1005
|
+
* entries. Render typed entries into their snippet and RAW verbatim; gate
|
|
1006
|
+
* any entry with `consentRequired` behind the visitor's analytics consent.
|
|
1007
|
+
*/
|
|
1008
|
+
getShopScripts(): Promise<SdkResult<ShopScripts>>;
|
|
958
1009
|
/** Set auth tokens (e.g. from localStorage) */
|
|
959
1010
|
setTokens(tokens: {
|
|
960
1011
|
accessToken: string;
|
|
@@ -1362,4 +1413,4 @@ declare class ShippingModule {
|
|
|
1362
1413
|
}>>;
|
|
1363
1414
|
}
|
|
1364
1415
|
|
|
1365
|
-
export { type
|
|
1416
|
+
export { type OrderStatus as $, type AddressSuggestion as A, type BehioStorefrontConfig as B, type Category as C, type SubmitReturnInput as D, type CookieConsent as E, type FilterField as F, type GiftCardBalance as G, type CookieConsentInput as H, type SubmitQuoteInput as I, type BackInStockSubscription as J, type AddToCartInput as K, type AuthTokens as L, BehioApiError as M, type BundleItem as N, type OrderListItem as O, type ProductsQuery as P, type QuoteRequest as Q, type RegisterInput as R, type ShopInfo as S, type CartDiscount as T, type CartItem as U, type CheckoutAddress as V, type WishlistItem as W, type FulfillmentStatus as X, type LoginInput as Y, type MessageResponse as Z, type OrderItem as _, BehioStorefront as a, type PaymentStatus as a0, type ProductPrice as a1, type ProductReview as a2, type ProductVariant as a3, type AddressType as a4, AddressTypes as a5, type BehioErrorCode as a6, type BehioEventHandler as a7, type BehioEventType as a8, BehioNetworkError as a9, type SdkResult as aA, type ShippingMethodSummary as aB, type ShippingQuote as aC, type ShippingQuoteInput as aD, type ShopScript as aE, type ShopScriptPlacement as aF, type ShopScriptType as aG, err as aH, ok as aI, toSdkError as aJ, type CartBundleLine as aa, type CartBundleLineItem as ab, type CartItemProduct as ac, type CheckoutPaymentMethod as ad, type DataGroupFieldType as ae, FulfillmentStatuses as af, type GiftCardSummary as ag, type OrderStatusHistory as ah, OrderStatuses as ai, type OrderTracking as aj, type PageAttachment as ak, PaymentStatuses as al, type ProductMedia as am, type ProductMediaVariant as an, ProductSort as ao, type ProductSortValue as ap, type ProductVolumePrice as aq, type QuoteItem as ar, type RequestInterceptor as as, type RequestInterceptorConfig as at, type ResponseInterceptor as au, type ResponseInterceptorData as av, type ReturnRequestItem as aw, type ReturnStatusItem as ax, type ReturnableOrderItem as ay, type SdkError as az, type PaginatedResponse as b, type ProductListItem as c, type ProductDetail as d, type CategoryDetail as e, type ProductLabel as f, type Cart as g, type CustomerProfile as h, type CustomerAddress as i, type AddressDetail as j, type OrderDetail as k, type OrderAccessRequestResponse as l, type OrderAccessVerifyResponse as m, type CheckoutInput as n, type PageDetail as o, type Page as p, type ShopScripts as q, type ShopSeo as r, type Bundle as s, type CrossSellItem as t, type ActivePromotion as u, type ProductReviewsResponse as v, type SubmitReviewInput as w, type ReturnableOrder as x, type ReturnStatus as y, type ReturnRequest as z };
|
|
@@ -58,6 +58,28 @@ interface ShopSeo {
|
|
|
58
58
|
ogDescription: string | null;
|
|
59
59
|
ogImage: string | null;
|
|
60
60
|
}
|
|
61
|
+
/** Kind of merchant-defined script. Typed presets render the right snippet from
|
|
62
|
+
* an id; RAW carries literal markup. */
|
|
63
|
+
type ShopScriptType = "GA4" | "GTM" | "META_PIXEL" | "GOOGLE_VERIFICATION" | "RAW";
|
|
64
|
+
/** Where in the document the script is injected. */
|
|
65
|
+
type ShopScriptPlacement = "HEAD" | "BODY_START" | "BODY_END";
|
|
66
|
+
/**
|
|
67
|
+
* A merchant-defined script delivered to the storefront for injection
|
|
68
|
+
* (analytics, pixels, verification, or arbitrary head/body markup).
|
|
69
|
+
* `value` is the id for typed entries, or the literal markup for RAW.
|
|
70
|
+
* When `consentRequired` is true the storefront must gate it behind the
|
|
71
|
+
* visitor's analytics cookie consent.
|
|
72
|
+
*/
|
|
73
|
+
interface ShopScript {
|
|
74
|
+
id: string;
|
|
75
|
+
type: ShopScriptType;
|
|
76
|
+
placement: ShopScriptPlacement;
|
|
77
|
+
value: string;
|
|
78
|
+
consentRequired: boolean;
|
|
79
|
+
}
|
|
80
|
+
interface ShopScripts {
|
|
81
|
+
scripts: ShopScript[];
|
|
82
|
+
}
|
|
61
83
|
/**
|
|
62
84
|
* Money amount displayed to a customer in a chosen currency.
|
|
63
85
|
*
|
|
@@ -356,6 +378,28 @@ interface Cart {
|
|
|
356
378
|
* min(balance, remaining due), last one partially), so they do not change
|
|
357
379
|
* `grandTotal` here; use them to list applied cards + balances in the cart. */
|
|
358
380
|
giftCards: GiftCardSummary[];
|
|
381
|
+
/** Bundle lines in the cart, separate from `items`. Manage with
|
|
382
|
+
* `cart.updateBundleQuantity` / `cart.removeBundle`. */
|
|
383
|
+
bundleLines: CartBundleLine[];
|
|
384
|
+
}
|
|
385
|
+
/** One product inside a bundle line. */
|
|
386
|
+
interface CartBundleLineItem {
|
|
387
|
+
productId: string;
|
|
388
|
+
name: string;
|
|
389
|
+
sku: string;
|
|
390
|
+
quantity: number;
|
|
391
|
+
}
|
|
392
|
+
/** A bundle added to the cart, with its own quantity + price snapshot. */
|
|
393
|
+
interface CartBundleLine {
|
|
394
|
+
id: string;
|
|
395
|
+
bundleId: string;
|
|
396
|
+
bundleSlug: string;
|
|
397
|
+
bundleName: string;
|
|
398
|
+
quantity: number;
|
|
399
|
+
/** Snapshot of the bundle's per-unit price when it was added. */
|
|
400
|
+
bundlePriceSnapshot: number;
|
|
401
|
+
currency: string;
|
|
402
|
+
items: CartBundleLineItem[];
|
|
359
403
|
}
|
|
360
404
|
/** A gift card applied to the cart, with its current balance. */
|
|
361
405
|
interface GiftCardSummary {
|
|
@@ -955,6 +999,13 @@ declare class BehioStorefront {
|
|
|
955
999
|
getShopInfo(): Promise<SdkResult<ShopInfo>>;
|
|
956
1000
|
/** Get SEO metadata for the shop homepage in the given locale (defaults to shop default). */
|
|
957
1001
|
getShopSeo(locale?: string): Promise<SdkResult<ShopSeo>>;
|
|
1002
|
+
/**
|
|
1003
|
+
* Get the merchant-defined scripts (analytics, pixels, verification, custom
|
|
1004
|
+
* head/body markup) to inject into the storefront. Returns only enabled
|
|
1005
|
+
* entries. Render typed entries into their snippet and RAW verbatim; gate
|
|
1006
|
+
* any entry with `consentRequired` behind the visitor's analytics consent.
|
|
1007
|
+
*/
|
|
1008
|
+
getShopScripts(): Promise<SdkResult<ShopScripts>>;
|
|
958
1009
|
/** Set auth tokens (e.g. from localStorage) */
|
|
959
1010
|
setTokens(tokens: {
|
|
960
1011
|
accessToken: string;
|
|
@@ -1362,4 +1413,4 @@ declare class ShippingModule {
|
|
|
1362
1413
|
}>>;
|
|
1363
1414
|
}
|
|
1364
1415
|
|
|
1365
|
-
export { type
|
|
1416
|
+
export { type OrderStatus as $, type AddressSuggestion as A, type BehioStorefrontConfig as B, type Category as C, type SubmitReturnInput as D, type CookieConsent as E, type FilterField as F, type GiftCardBalance as G, type CookieConsentInput as H, type SubmitQuoteInput as I, type BackInStockSubscription as J, type AddToCartInput as K, type AuthTokens as L, BehioApiError as M, type BundleItem as N, type OrderListItem as O, type ProductsQuery as P, type QuoteRequest as Q, type RegisterInput as R, type ShopInfo as S, type CartDiscount as T, type CartItem as U, type CheckoutAddress as V, type WishlistItem as W, type FulfillmentStatus as X, type LoginInput as Y, type MessageResponse as Z, type OrderItem as _, BehioStorefront as a, type PaymentStatus as a0, type ProductPrice as a1, type ProductReview as a2, type ProductVariant as a3, type AddressType as a4, AddressTypes as a5, type BehioErrorCode as a6, type BehioEventHandler as a7, type BehioEventType as a8, BehioNetworkError as a9, type SdkResult as aA, type ShippingMethodSummary as aB, type ShippingQuote as aC, type ShippingQuoteInput as aD, type ShopScript as aE, type ShopScriptPlacement as aF, type ShopScriptType as aG, err as aH, ok as aI, toSdkError as aJ, type CartBundleLine as aa, type CartBundleLineItem as ab, type CartItemProduct as ac, type CheckoutPaymentMethod as ad, type DataGroupFieldType as ae, FulfillmentStatuses as af, type GiftCardSummary as ag, type OrderStatusHistory as ah, OrderStatuses as ai, type OrderTracking as aj, type PageAttachment as ak, PaymentStatuses as al, type ProductMedia as am, type ProductMediaVariant as an, ProductSort as ao, type ProductSortValue as ap, type ProductVolumePrice as aq, type QuoteItem as ar, type RequestInterceptor as as, type RequestInterceptorConfig as at, type ResponseInterceptor as au, type ResponseInterceptorData as av, type ReturnRequestItem as aw, type ReturnStatusItem as ax, type ReturnableOrderItem as ay, type SdkError as az, type PaginatedResponse as b, type ProductListItem as c, type ProductDetail as d, type CategoryDetail as e, type ProductLabel as f, type Cart as g, type CustomerProfile as h, type CustomerAddress as i, type AddressDetail as j, type OrderDetail as k, type OrderAccessRequestResponse as l, type OrderAccessVerifyResponse as m, type CheckoutInput as n, type PageDetail as o, type Page as p, type ShopScripts as q, type ShopSeo as r, type Bundle as s, type CrossSellItem as t, type ActivePromotion as u, type ProductReviewsResponse as v, type SubmitReviewInput as w, type ReturnableOrder as x, type ReturnStatus as y, type ReturnRequest as z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { u as ActivePromotion, K as AddToCartInput, j as AddressDetail, A as AddressSuggestion, a4 as AddressType, a5 as AddressTypes, L as AuthTokens, J as BackInStockSubscription, M as BehioApiError, a6 as BehioErrorCode, a7 as BehioEventHandler, a8 as BehioEventType, a9 as BehioNetworkError, a as BehioStorefront, B as BehioStorefrontConfig, s as Bundle, N as BundleItem, g as Cart, aa as CartBundleLine, ab as CartBundleLineItem, T as CartDiscount, U as CartItem, ac as CartItemProduct, C as Category, e as CategoryDetail, V as CheckoutAddress, n as CheckoutInput, ad as CheckoutPaymentMethod, E as CookieConsent, H as CookieConsentInput, t as CrossSellItem, i as CustomerAddress, h as CustomerProfile, ae as DataGroupFieldType, F as FilterField, X as FulfillmentStatus, af as FulfillmentStatuses, G as GiftCardBalance, ag as GiftCardSummary, Y as LoginInput, Z as MessageResponse, l as OrderAccessRequestResponse, m as OrderAccessVerifyResponse, k as OrderDetail, _ as OrderItem, O as OrderListItem, $ as OrderStatus, ah as OrderStatusHistory, ai as OrderStatuses, aj as OrderTracking, p as Page, ak as PageAttachment, o as PageDetail, b as PaginatedResponse, a0 as PaymentStatus, al as PaymentStatuses, d as ProductDetail, f as ProductLabel, c as ProductListItem, am as ProductMedia, an as ProductMediaVariant, a1 as ProductPrice, a2 as ProductReview, v as ProductReviewsResponse, ao as ProductSort, ap as ProductSortValue, a3 as ProductVariant, aq as ProductVolumePrice, P as ProductsQuery, ar as QuoteItem, Q as QuoteRequest, R as RegisterInput, as as RequestInterceptor, at as RequestInterceptorConfig, au as ResponseInterceptor, av as ResponseInterceptorData, z as ReturnRequest, aw as ReturnRequestItem, y as ReturnStatus, ax as ReturnStatusItem, x as ReturnableOrder, ay as ReturnableOrderItem, az as SdkError, aA as SdkResult, aB as ShippingMethodSummary, aC as ShippingQuote, aD as ShippingQuoteInput, S as ShopInfo, aE as ShopScript, aF as ShopScriptPlacement, aG as ShopScriptType, q as ShopScripts, r as ShopSeo, I as SubmitQuoteInput, D as SubmitReturnInput, w as SubmitReviewInput, W as WishlistItem, aH as err, aI as ok, aJ as toSdkError } from './client-B0ZSKaQh.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Format a price amount with currency using Intl.NumberFormat.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { u as ActivePromotion, K as AddToCartInput, j as AddressDetail, A as AddressSuggestion, a4 as AddressType, a5 as AddressTypes, L as AuthTokens, J as BackInStockSubscription, M as BehioApiError, a6 as BehioErrorCode, a7 as BehioEventHandler, a8 as BehioEventType, a9 as BehioNetworkError, a as BehioStorefront, B as BehioStorefrontConfig, s as Bundle, N as BundleItem, g as Cart, aa as CartBundleLine, ab as CartBundleLineItem, T as CartDiscount, U as CartItem, ac as CartItemProduct, C as Category, e as CategoryDetail, V as CheckoutAddress, n as CheckoutInput, ad as CheckoutPaymentMethod, E as CookieConsent, H as CookieConsentInput, t as CrossSellItem, i as CustomerAddress, h as CustomerProfile, ae as DataGroupFieldType, F as FilterField, X as FulfillmentStatus, af as FulfillmentStatuses, G as GiftCardBalance, ag as GiftCardSummary, Y as LoginInput, Z as MessageResponse, l as OrderAccessRequestResponse, m as OrderAccessVerifyResponse, k as OrderDetail, _ as OrderItem, O as OrderListItem, $ as OrderStatus, ah as OrderStatusHistory, ai as OrderStatuses, aj as OrderTracking, p as Page, ak as PageAttachment, o as PageDetail, b as PaginatedResponse, a0 as PaymentStatus, al as PaymentStatuses, d as ProductDetail, f as ProductLabel, c as ProductListItem, am as ProductMedia, an as ProductMediaVariant, a1 as ProductPrice, a2 as ProductReview, v as ProductReviewsResponse, ao as ProductSort, ap as ProductSortValue, a3 as ProductVariant, aq as ProductVolumePrice, P as ProductsQuery, ar as QuoteItem, Q as QuoteRequest, R as RegisterInput, as as RequestInterceptor, at as RequestInterceptorConfig, au as ResponseInterceptor, av as ResponseInterceptorData, z as ReturnRequest, aw as ReturnRequestItem, y as ReturnStatus, ax as ReturnStatusItem, x as ReturnableOrder, ay as ReturnableOrderItem, az as SdkError, aA as SdkResult, aB as ShippingMethodSummary, aC as ShippingQuote, aD as ShippingQuoteInput, S as ShopInfo, aE as ShopScript, aF as ShopScriptPlacement, aG as ShopScriptType, q as ShopScripts, r as ShopSeo, I as SubmitQuoteInput, D as SubmitReturnInput, w as SubmitReviewInput, W as WishlistItem, aH as err, aI as ok, aJ as toSdkError } from './client-B0ZSKaQh.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Format a price amount with currency using Intl.NumberFormat.
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var _chunkXWYDXBLGjs = require('./chunk-XWYDXBLG.js');
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkS7YSZHHDjs = require('./chunk-S7YSZHHD.js');
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
@@ -27,4 +27,4 @@ var _chunkWNJ72O66js = require('./chunk-WNJ72O66.js');
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
exports.AddressTypes =
|
|
30
|
+
exports.AddressTypes = _chunkS7YSZHHDjs.AddressTypes; exports.BehioApiError = _chunkS7YSZHHDjs.BehioApiError; exports.BehioNetworkError = _chunkS7YSZHHDjs.BehioNetworkError; exports.BehioStorefront = _chunkS7YSZHHDjs.BehioStorefront; exports.FulfillmentStatuses = _chunkS7YSZHHDjs.FulfillmentStatuses; exports.OrderStatuses = _chunkS7YSZHHDjs.OrderStatuses; exports.PaymentStatuses = _chunkS7YSZHHDjs.PaymentStatuses; exports.ProductSort = _chunkS7YSZHHDjs.ProductSort; exports.err = _chunkS7YSZHHDjs.err; exports.formatPrice = _chunkXWYDXBLGjs.formatPrice; exports.ok = _chunkS7YSZHHDjs.ok; exports.toSdkError = _chunkS7YSZHHDjs.toSdkError;
|
package/dist/index.mjs
CHANGED
package/dist/next.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BehioStorefrontConfig, a as BehioStorefront } from './client-
|
|
1
|
+
import { B as BehioStorefrontConfig, a as BehioStorefront } from './client-B0ZSKaQh.mjs';
|
|
2
2
|
|
|
3
3
|
interface GetBehioOptions extends Partial<BehioStorefrontConfig> {
|
|
4
4
|
/** Override the cart session cookie name (default: "behio_cart_session"). */
|
package/dist/next.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BehioStorefrontConfig, a as BehioStorefront } from './client-
|
|
1
|
+
import { B as BehioStorefrontConfig, a as BehioStorefront } from './client-B0ZSKaQh.js';
|
|
2
2
|
|
|
3
3
|
interface GetBehioOptions extends Partial<BehioStorefrontConfig> {
|
|
4
4
|
/** Override the cart session cookie name (default: "behio_cart_session"). */
|
package/dist/next.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkS7YSZHHDjs = require('./chunk-S7YSZHHD.js');
|
|
4
4
|
|
|
5
5
|
// src/next.ts
|
|
6
6
|
var _headers = require('next/headers');
|
|
@@ -18,7 +18,7 @@ async function getBehio(options = {}) {
|
|
|
18
18
|
const locale = _nullishCoalesce(options.locale, () => ( process.env.BEHIO_LOCALE));
|
|
19
19
|
const currency = _nullishCoalesce(options.currency, () => ( process.env.BEHIO_CURRENCY));
|
|
20
20
|
const cookieName = _nullishCoalesce(options.cartCookieName, () => ( CART_COOKIE_NAME));
|
|
21
|
-
const client = new (0,
|
|
21
|
+
const client = new (0, _chunkS7YSZHHDjs.BehioStorefront)({
|
|
22
22
|
apiKey,
|
|
23
23
|
...baseUrl ? { baseUrl } : {},
|
|
24
24
|
...locale ? { locale } : {},
|
package/dist/next.mjs
CHANGED
package/dist/react.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
3
3
|
import { QueryClient } from '@tanstack/react-query';
|
|
4
|
-
import { a as BehioStorefront, P as ProductsQuery, b as PaginatedResponse, c as ProductListItem, d as ProductDetail, C as Category, e as CategoryDetail, f as ProductLabel, F as FilterField, g as Cart, h as CustomerProfile, R as RegisterInput, i as CustomerAddress, A as AddressSuggestion, j as AddressDetail, O as OrderListItem, k as OrderDetail, l as OrderAccessRequestResponse, m as OrderAccessVerifyResponse, n as CheckoutInput, o as PageDetail, p as Page, S as ShopInfo, q as
|
|
5
|
-
export {
|
|
4
|
+
import { a as BehioStorefront, P as ProductsQuery, b as PaginatedResponse, c as ProductListItem, d as ProductDetail, C as Category, e as CategoryDetail, f as ProductLabel, F as FilterField, g as Cart, h as CustomerProfile, R as RegisterInput, i as CustomerAddress, A as AddressSuggestion, j as AddressDetail, O as OrderListItem, k as OrderDetail, l as OrderAccessRequestResponse, m as OrderAccessVerifyResponse, n as CheckoutInput, o as PageDetail, p as Page, S as ShopInfo, q as ShopScripts, r as ShopSeo, s as Bundle, t as CrossSellItem, u as ActivePromotion, G as GiftCardBalance, W as WishlistItem, v as ProductReviewsResponse, w as SubmitReviewInput, x as ReturnableOrder, y as ReturnStatus, z as ReturnRequest, D as SubmitReturnInput, E as CookieConsent, H as CookieConsentInput, Q as QuoteRequest, I as SubmitQuoteInput, J as BackInStockSubscription } from './client-B0ZSKaQh.mjs';
|
|
5
|
+
export { K as AddToCartInput, L as AuthTokens, M as BehioApiError, N as BundleItem, T as CartDiscount, U as CartItem, V as CheckoutAddress, X as FulfillmentStatus, Y as LoginInput, Z as MessageResponse, _ as OrderItem, $ as OrderStatus, a0 as PaymentStatus, a1 as ProductPrice, a2 as ProductReview, a3 as ProductVariant } from './client-B0ZSKaQh.mjs';
|
|
6
6
|
import * as _tanstack_query_core from '@tanstack/query-core';
|
|
7
7
|
export { formatPrice } from './index.mjs';
|
|
8
8
|
|
|
@@ -391,6 +391,16 @@ interface UseShopInfoOptions {
|
|
|
391
391
|
}
|
|
392
392
|
declare function useShopInfo(options?: UseShopInfoOptions): _tanstack_react_query.UseQueryResult<NoInfer<ShopInfo>, Error>;
|
|
393
393
|
|
|
394
|
+
interface UseShopScriptsOptions {
|
|
395
|
+
enabled?: boolean;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Fetch the merchant-defined storefront scripts (analytics, pixels, custom
|
|
399
|
+
* head/body markup). Render with the <StorefrontScripts> helper or manually;
|
|
400
|
+
* gate any entry with `consentRequired` behind the visitor's analytics consent.
|
|
401
|
+
*/
|
|
402
|
+
declare function useShopScripts(options?: UseShopScriptsOptions): _tanstack_react_query.UseQueryResult<NoInfer<ShopScripts>, Error>;
|
|
403
|
+
|
|
394
404
|
interface UseShopSeoOptions {
|
|
395
405
|
/** Override locale (ISO-639-1). Defaults to the shop's default locale. */
|
|
396
406
|
locale?: string;
|
|
@@ -481,6 +491,19 @@ interface CurrencySwitcherProps {
|
|
|
481
491
|
*/
|
|
482
492
|
declare function CurrencySwitcher({ className, labels, showWhenSingle, ariaLabel, children, }: CurrencySwitcherProps): react_jsx_runtime.JSX.Element | null;
|
|
483
493
|
|
|
494
|
+
interface StorefrontScriptsProps {
|
|
495
|
+
/** Override the visitor id; defaults to the `behio_visitor_id` localStorage value. */
|
|
496
|
+
visitorId?: string;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Injects the merchant-defined storefront scripts (GA4, GTM, Meta Pixel, Google
|
|
500
|
+
* verification, or raw head/body markup) configured in the Behio admin. Entries
|
|
501
|
+
* marked `consentRequired` are injected only once the visitor has granted
|
|
502
|
+
* analytics cookie consent; the rest are injected on mount. Mount once in the
|
|
503
|
+
* root layout, inside the BehioProvider.
|
|
504
|
+
*/
|
|
505
|
+
declare function StorefrontScripts({ visitorId: visitorIdProp }?: StorefrontScriptsProps): null;
|
|
506
|
+
|
|
484
507
|
/** List all active bundles. */
|
|
485
508
|
declare function useBundles(options?: {
|
|
486
509
|
enabled?: boolean;
|
|
@@ -1005,4 +1028,4 @@ declare function useNotifyWhenAvailable(): _tanstack_react_query.UseMutationResu
|
|
|
1005
1028
|
*/
|
|
1006
1029
|
declare function useBehioClient(): BehioStorefront;
|
|
1007
1030
|
|
|
1008
|
-
export { ActivePromotion, BehioProvider, type BehioProviderProps, Bundle, Cart, Category, CategoryDetail, CheckoutInput, CookieConsent, CookieConsentInput, CrossSellItem, CurrencySwitcher, type CurrencySwitcherProps, type CurrencySwitcherRenderProps, CustomerAddress, CustomerProfile, FilterField, GiftCardBalance, OrderDetail, OrderListItem, Page, PageDetail, PaginatedResponse, ProductDetail, ProductLabel, ProductListItem, ProductReviewsResponse, ProductsQuery, QuoteRequest, RegisterInput, ReturnRequest, ShopInfo, ShopSeo, type StorageAdapter, SubmitQuoteInput, SubmitReturnInput, SubmitReviewInput, type UseAddressAutocompleteOptions, type UseAddressAutocompleteReturn, type UseAddressesOptions, type UseCartCountOptions, type UseCartOptions, type UseCategoriesOptions, type UseCategoryOptions, type UseCurrencyResult, type UseCustomerOptions, type UseFeaturedOptions, type UseFiltersOptions, type UseLabelsOptions, type UseOrderOptions, type UseOrdersOptions, type UsePageOptions, type UsePagesOptions, type UseProductOptions, type UseProductsOptions, type UseSearchOptions, type UseShopInfoOptions, type UseShopSeoOptions, WishlistItem, cookieStorage, createMemoryStorage, detectStorage, localStorageAdapter, memoryStorage, useAddressAutocomplete, useAddresses, useAuth, useBehio, useBehioClient, useBundle, useBundles, useCart, useCartCount, useCategories, useCategory, useCheckout, useCookieConsent, useCrossSell, useCurrency, useCustomer, useFeatured, useFilters, useGiftCardBalance, useIsInWishlist, useLabels, useLookupReturnableOrder, useNotifyWhenAvailable, useOrder, useOrderAccess, useOrders, usePage, usePages, useProduct, useProductPromotions, useProductReviews, useProducts, useQuoteStatus, useReturnStatus, useSearch, useShopInfo, useShopSeo, useSubmitQuote, useSubmitReturn, useSubmitReview, useWishlist };
|
|
1031
|
+
export { ActivePromotion, BehioProvider, type BehioProviderProps, Bundle, Cart, Category, CategoryDetail, CheckoutInput, CookieConsent, CookieConsentInput, CrossSellItem, CurrencySwitcher, type CurrencySwitcherProps, type CurrencySwitcherRenderProps, CustomerAddress, CustomerProfile, FilterField, GiftCardBalance, OrderDetail, OrderListItem, Page, PageDetail, PaginatedResponse, ProductDetail, ProductLabel, ProductListItem, ProductReviewsResponse, ProductsQuery, QuoteRequest, RegisterInput, ReturnRequest, ShopInfo, ShopSeo, type StorageAdapter, StorefrontScripts, type StorefrontScriptsProps, SubmitQuoteInput, SubmitReturnInput, SubmitReviewInput, type UseAddressAutocompleteOptions, type UseAddressAutocompleteReturn, type UseAddressesOptions, type UseCartCountOptions, type UseCartOptions, type UseCategoriesOptions, type UseCategoryOptions, type UseCurrencyResult, type UseCustomerOptions, type UseFeaturedOptions, type UseFiltersOptions, type UseLabelsOptions, type UseOrderOptions, type UseOrdersOptions, type UsePageOptions, type UsePagesOptions, type UseProductOptions, type UseProductsOptions, type UseSearchOptions, type UseShopInfoOptions, type UseShopScriptsOptions, type UseShopSeoOptions, WishlistItem, cookieStorage, createMemoryStorage, detectStorage, localStorageAdapter, memoryStorage, useAddressAutocomplete, useAddresses, useAuth, useBehio, useBehioClient, useBundle, useBundles, useCart, useCartCount, useCategories, useCategory, useCheckout, useCookieConsent, useCrossSell, useCurrency, useCustomer, useFeatured, useFilters, useGiftCardBalance, useIsInWishlist, useLabels, useLookupReturnableOrder, useNotifyWhenAvailable, useOrder, useOrderAccess, useOrders, usePage, usePages, useProduct, useProductPromotions, useProductReviews, useProducts, useQuoteStatus, useReturnStatus, useSearch, useShopInfo, useShopScripts, useShopSeo, useSubmitQuote, useSubmitReturn, useSubmitReview, useWishlist };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
3
3
|
import { QueryClient } from '@tanstack/react-query';
|
|
4
|
-
import { a as BehioStorefront, P as ProductsQuery, b as PaginatedResponse, c as ProductListItem, d as ProductDetail, C as Category, e as CategoryDetail, f as ProductLabel, F as FilterField, g as Cart, h as CustomerProfile, R as RegisterInput, i as CustomerAddress, A as AddressSuggestion, j as AddressDetail, O as OrderListItem, k as OrderDetail, l as OrderAccessRequestResponse, m as OrderAccessVerifyResponse, n as CheckoutInput, o as PageDetail, p as Page, S as ShopInfo, q as
|
|
5
|
-
export {
|
|
4
|
+
import { a as BehioStorefront, P as ProductsQuery, b as PaginatedResponse, c as ProductListItem, d as ProductDetail, C as Category, e as CategoryDetail, f as ProductLabel, F as FilterField, g as Cart, h as CustomerProfile, R as RegisterInput, i as CustomerAddress, A as AddressSuggestion, j as AddressDetail, O as OrderListItem, k as OrderDetail, l as OrderAccessRequestResponse, m as OrderAccessVerifyResponse, n as CheckoutInput, o as PageDetail, p as Page, S as ShopInfo, q as ShopScripts, r as ShopSeo, s as Bundle, t as CrossSellItem, u as ActivePromotion, G as GiftCardBalance, W as WishlistItem, v as ProductReviewsResponse, w as SubmitReviewInput, x as ReturnableOrder, y as ReturnStatus, z as ReturnRequest, D as SubmitReturnInput, E as CookieConsent, H as CookieConsentInput, Q as QuoteRequest, I as SubmitQuoteInput, J as BackInStockSubscription } from './client-B0ZSKaQh.js';
|
|
5
|
+
export { K as AddToCartInput, L as AuthTokens, M as BehioApiError, N as BundleItem, T as CartDiscount, U as CartItem, V as CheckoutAddress, X as FulfillmentStatus, Y as LoginInput, Z as MessageResponse, _ as OrderItem, $ as OrderStatus, a0 as PaymentStatus, a1 as ProductPrice, a2 as ProductReview, a3 as ProductVariant } from './client-B0ZSKaQh.js';
|
|
6
6
|
import * as _tanstack_query_core from '@tanstack/query-core';
|
|
7
7
|
export { formatPrice } from './index.js';
|
|
8
8
|
|
|
@@ -391,6 +391,16 @@ interface UseShopInfoOptions {
|
|
|
391
391
|
}
|
|
392
392
|
declare function useShopInfo(options?: UseShopInfoOptions): _tanstack_react_query.UseQueryResult<NoInfer<ShopInfo>, Error>;
|
|
393
393
|
|
|
394
|
+
interface UseShopScriptsOptions {
|
|
395
|
+
enabled?: boolean;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Fetch the merchant-defined storefront scripts (analytics, pixels, custom
|
|
399
|
+
* head/body markup). Render with the <StorefrontScripts> helper or manually;
|
|
400
|
+
* gate any entry with `consentRequired` behind the visitor's analytics consent.
|
|
401
|
+
*/
|
|
402
|
+
declare function useShopScripts(options?: UseShopScriptsOptions): _tanstack_react_query.UseQueryResult<NoInfer<ShopScripts>, Error>;
|
|
403
|
+
|
|
394
404
|
interface UseShopSeoOptions {
|
|
395
405
|
/** Override locale (ISO-639-1). Defaults to the shop's default locale. */
|
|
396
406
|
locale?: string;
|
|
@@ -481,6 +491,19 @@ interface CurrencySwitcherProps {
|
|
|
481
491
|
*/
|
|
482
492
|
declare function CurrencySwitcher({ className, labels, showWhenSingle, ariaLabel, children, }: CurrencySwitcherProps): react_jsx_runtime.JSX.Element | null;
|
|
483
493
|
|
|
494
|
+
interface StorefrontScriptsProps {
|
|
495
|
+
/** Override the visitor id; defaults to the `behio_visitor_id` localStorage value. */
|
|
496
|
+
visitorId?: string;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Injects the merchant-defined storefront scripts (GA4, GTM, Meta Pixel, Google
|
|
500
|
+
* verification, or raw head/body markup) configured in the Behio admin. Entries
|
|
501
|
+
* marked `consentRequired` are injected only once the visitor has granted
|
|
502
|
+
* analytics cookie consent; the rest are injected on mount. Mount once in the
|
|
503
|
+
* root layout, inside the BehioProvider.
|
|
504
|
+
*/
|
|
505
|
+
declare function StorefrontScripts({ visitorId: visitorIdProp }?: StorefrontScriptsProps): null;
|
|
506
|
+
|
|
484
507
|
/** List all active bundles. */
|
|
485
508
|
declare function useBundles(options?: {
|
|
486
509
|
enabled?: boolean;
|
|
@@ -1005,4 +1028,4 @@ declare function useNotifyWhenAvailable(): _tanstack_react_query.UseMutationResu
|
|
|
1005
1028
|
*/
|
|
1006
1029
|
declare function useBehioClient(): BehioStorefront;
|
|
1007
1030
|
|
|
1008
|
-
export { ActivePromotion, BehioProvider, type BehioProviderProps, Bundle, Cart, Category, CategoryDetail, CheckoutInput, CookieConsent, CookieConsentInput, CrossSellItem, CurrencySwitcher, type CurrencySwitcherProps, type CurrencySwitcherRenderProps, CustomerAddress, CustomerProfile, FilterField, GiftCardBalance, OrderDetail, OrderListItem, Page, PageDetail, PaginatedResponse, ProductDetail, ProductLabel, ProductListItem, ProductReviewsResponse, ProductsQuery, QuoteRequest, RegisterInput, ReturnRequest, ShopInfo, ShopSeo, type StorageAdapter, SubmitQuoteInput, SubmitReturnInput, SubmitReviewInput, type UseAddressAutocompleteOptions, type UseAddressAutocompleteReturn, type UseAddressesOptions, type UseCartCountOptions, type UseCartOptions, type UseCategoriesOptions, type UseCategoryOptions, type UseCurrencyResult, type UseCustomerOptions, type UseFeaturedOptions, type UseFiltersOptions, type UseLabelsOptions, type UseOrderOptions, type UseOrdersOptions, type UsePageOptions, type UsePagesOptions, type UseProductOptions, type UseProductsOptions, type UseSearchOptions, type UseShopInfoOptions, type UseShopSeoOptions, WishlistItem, cookieStorage, createMemoryStorage, detectStorage, localStorageAdapter, memoryStorage, useAddressAutocomplete, useAddresses, useAuth, useBehio, useBehioClient, useBundle, useBundles, useCart, useCartCount, useCategories, useCategory, useCheckout, useCookieConsent, useCrossSell, useCurrency, useCustomer, useFeatured, useFilters, useGiftCardBalance, useIsInWishlist, useLabels, useLookupReturnableOrder, useNotifyWhenAvailable, useOrder, useOrderAccess, useOrders, usePage, usePages, useProduct, useProductPromotions, useProductReviews, useProducts, useQuoteStatus, useReturnStatus, useSearch, useShopInfo, useShopSeo, useSubmitQuote, useSubmitReturn, useSubmitReview, useWishlist };
|
|
1031
|
+
export { ActivePromotion, BehioProvider, type BehioProviderProps, Bundle, Cart, Category, CategoryDetail, CheckoutInput, CookieConsent, CookieConsentInput, CrossSellItem, CurrencySwitcher, type CurrencySwitcherProps, type CurrencySwitcherRenderProps, CustomerAddress, CustomerProfile, FilterField, GiftCardBalance, OrderDetail, OrderListItem, Page, PageDetail, PaginatedResponse, ProductDetail, ProductLabel, ProductListItem, ProductReviewsResponse, ProductsQuery, QuoteRequest, RegisterInput, ReturnRequest, ShopInfo, ShopSeo, type StorageAdapter, StorefrontScripts, type StorefrontScriptsProps, SubmitQuoteInput, SubmitReturnInput, SubmitReviewInput, type UseAddressAutocompleteOptions, type UseAddressAutocompleteReturn, type UseAddressesOptions, type UseCartCountOptions, type UseCartOptions, type UseCategoriesOptions, type UseCategoryOptions, type UseCurrencyResult, type UseCustomerOptions, type UseFeaturedOptions, type UseFiltersOptions, type UseLabelsOptions, type UseOrderOptions, type UseOrdersOptions, type UsePageOptions, type UsePagesOptions, type UseProductOptions, type UseProductsOptions, type UseSearchOptions, type UseShopInfoOptions, type UseShopScriptsOptions, type UseShopSeoOptions, WishlistItem, cookieStorage, createMemoryStorage, detectStorage, localStorageAdapter, memoryStorage, useAddressAutocomplete, useAddresses, useAuth, useBehio, useBehioClient, useBundle, useBundles, useCart, useCartCount, useCategories, useCategory, useCheckout, useCookieConsent, useCrossSell, useCurrency, useCustomer, useFeatured, useFilters, useGiftCardBalance, useIsInWishlist, useLabels, useLookupReturnableOrder, useNotifyWhenAvailable, useOrder, useOrderAccess, useOrders, usePage, usePages, useProduct, useProductPromotions, useProductReviews, useProducts, useQuoteStatus, useReturnStatus, useSearch, useShopInfo, useShopScripts, useShopSeo, useSubmitQuote, useSubmitReturn, useSubmitReview, useWishlist };
|
package/dist/react.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _chunkXWYDXBLGjs = require('./chunk-XWYDXBLG.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkS7YSZHHDjs = require('./chunk-S7YSZHHD.js');
|
|
7
7
|
|
|
8
8
|
// src/react/provider.tsx
|
|
9
9
|
var _react = require('react');
|
|
@@ -133,7 +133,7 @@ function BehioProvider({
|
|
|
133
133
|
const [activeCurrency, setActiveCurrency] = _react.useState.call(void 0, resolveInitialCurrency);
|
|
134
134
|
const clientRef = _react.useRef.call(void 0, null);
|
|
135
135
|
if (!clientRef.current) {
|
|
136
|
-
clientRef.current = new (0,
|
|
136
|
+
clientRef.current = new (0, _chunkS7YSZHHDjs.BehioStorefront)({
|
|
137
137
|
apiKey,
|
|
138
138
|
baseUrl,
|
|
139
139
|
...shopDomain ? { shopDomain } : {},
|
|
@@ -1070,6 +1070,17 @@ function useShopInfo(options) {
|
|
|
1070
1070
|
});
|
|
1071
1071
|
}
|
|
1072
1072
|
|
|
1073
|
+
// src/react/hooks/use-shop-scripts.ts
|
|
1074
|
+
|
|
1075
|
+
function useShopScripts(options) {
|
|
1076
|
+
const { client } = useBehio();
|
|
1077
|
+
return _reactquery.useQuery.call(void 0, {
|
|
1078
|
+
queryKey: ["behio", "shop-scripts"],
|
|
1079
|
+
queryFn: () => unwrap(client.getShopScripts()),
|
|
1080
|
+
enabled: _optionalChain([options, 'optionalAccess', _65 => _65.enabled]) !== false
|
|
1081
|
+
});
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1073
1084
|
// src/react/hooks/use-shop-seo.ts
|
|
1074
1085
|
|
|
1075
1086
|
function useShopSeo(options) {
|
|
@@ -1094,8 +1105,8 @@ function dedupe(values) {
|
|
|
1094
1105
|
function useCurrency() {
|
|
1095
1106
|
const { currency, setCurrency, configuredDefaultCurrency, configuredCurrencies } = useBehio();
|
|
1096
1107
|
const { data: shop, isLoading } = useShopInfo();
|
|
1097
|
-
const defaultCurrency = _nullishCoalesce(configuredDefaultCurrency, () => ( _optionalChain([shop, 'optionalAccess',
|
|
1098
|
-
const currencies = configuredCurrencies && configuredCurrencies.length > 0 ? dedupe(configuredCurrencies) : dedupe([defaultCurrency, ..._nullishCoalesce(_optionalChain([shop, 'optionalAccess',
|
|
1108
|
+
const defaultCurrency = _nullishCoalesce(configuredDefaultCurrency, () => ( _optionalChain([shop, 'optionalAccess', _66 => _66.defaultCurrency])));
|
|
1109
|
+
const currencies = configuredCurrencies && configuredCurrencies.length > 0 ? dedupe(configuredCurrencies) : dedupe([defaultCurrency, ..._nullishCoalesce(_optionalChain([shop, 'optionalAccess', _67 => _67.supportedCurrencies]), () => ( []))]);
|
|
1099
1110
|
return {
|
|
1100
1111
|
currency,
|
|
1101
1112
|
effectiveCurrency: _nullishCoalesce(currency, () => ( defaultCurrency)),
|
|
@@ -1118,7 +1129,7 @@ function CurrencySwitcher({
|
|
|
1118
1129
|
const { currencies, effectiveCurrency, setCurrency } = useCurrency();
|
|
1119
1130
|
if (currencies.length === 0) return null;
|
|
1120
1131
|
if (currencies.length <= 1 && !showWhenSingle) return null;
|
|
1121
|
-
const label = (code) => _nullishCoalesce(_optionalChain([labels, 'optionalAccess',
|
|
1132
|
+
const label = (code) => _nullishCoalesce(_optionalChain([labels, 'optionalAccess', _68 => _68[code]]), () => ( code));
|
|
1122
1133
|
if (children) {
|
|
1123
1134
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: children({ currencies, value: effectiveCurrency, setCurrency, label }) });
|
|
1124
1135
|
}
|
|
@@ -1134,6 +1145,132 @@ function CurrencySwitcher({
|
|
|
1134
1145
|
);
|
|
1135
1146
|
}
|
|
1136
1147
|
|
|
1148
|
+
// src/react/components/storefront-scripts.tsx
|
|
1149
|
+
|
|
1150
|
+
|
|
1151
|
+
// src/react/hooks/use-consent.ts
|
|
1152
|
+
|
|
1153
|
+
function useCookieConsent(visitorId) {
|
|
1154
|
+
const { client } = useBehio();
|
|
1155
|
+
const qc = _reactquery.useQueryClient.call(void 0, );
|
|
1156
|
+
const query = _reactquery.useQuery.call(void 0, {
|
|
1157
|
+
queryKey: ["behio", "consent", visitorId],
|
|
1158
|
+
queryFn: () => unwrap(client.consent.get(visitorId)),
|
|
1159
|
+
enabled: Boolean(visitorId)
|
|
1160
|
+
});
|
|
1161
|
+
const recordMutation = _reactquery.useMutation.call(void 0, {
|
|
1162
|
+
mutationFn: (input) => unwrap(client.consent.record(input)),
|
|
1163
|
+
onSuccess: () => qc.invalidateQueries({ queryKey: ["behio", "consent"] })
|
|
1164
|
+
});
|
|
1165
|
+
const revokeMutation = _reactquery.useMutation.call(void 0, {
|
|
1166
|
+
mutationFn: () => unwrap(client.consent.revoke(visitorId)),
|
|
1167
|
+
onSuccess: () => qc.invalidateQueries({ queryKey: ["behio", "consent"] })
|
|
1168
|
+
});
|
|
1169
|
+
return {
|
|
1170
|
+
...query,
|
|
1171
|
+
record: recordMutation.mutateAsync,
|
|
1172
|
+
revoke: revokeMutation.mutateAsync
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
// src/react/components/storefront-scripts.tsx
|
|
1177
|
+
var VISITOR_KEY = "behio_visitor_id";
|
|
1178
|
+
function partsFor(s) {
|
|
1179
|
+
const id = s.value.trim();
|
|
1180
|
+
switch (s.type) {
|
|
1181
|
+
case "GA4":
|
|
1182
|
+
return [
|
|
1183
|
+
{
|
|
1184
|
+
target: "head",
|
|
1185
|
+
html: `<script async src="https://www.googletagmanager.com/gtag/js?id=${id}"></script><script>window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments);}gtag('js',new Date());gtag('config','${id}');</script>`
|
|
1186
|
+
}
|
|
1187
|
+
];
|
|
1188
|
+
case "GTM":
|
|
1189
|
+
return [
|
|
1190
|
+
{
|
|
1191
|
+
target: "head",
|
|
1192
|
+
html: `<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','${id}');</script>`
|
|
1193
|
+
},
|
|
1194
|
+
{
|
|
1195
|
+
target: "body",
|
|
1196
|
+
html: `<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=${id}" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>`
|
|
1197
|
+
}
|
|
1198
|
+
];
|
|
1199
|
+
case "META_PIXEL":
|
|
1200
|
+
return [
|
|
1201
|
+
{
|
|
1202
|
+
target: "head",
|
|
1203
|
+
html: `<script>!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,document,'script','https://connect.facebook.net/en_US/fbevents.js');fbq('init','${id}');fbq('track','PageView');</script>`
|
|
1204
|
+
},
|
|
1205
|
+
{
|
|
1206
|
+
target: "body",
|
|
1207
|
+
html: `<noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=${id}&ev=PageView&noscript=1"/></noscript>`
|
|
1208
|
+
}
|
|
1209
|
+
];
|
|
1210
|
+
case "GOOGLE_VERIFICATION":
|
|
1211
|
+
return [{ target: "head", html: `<meta name="google-site-verification" content="${id}" />` }];
|
|
1212
|
+
case "RAW":
|
|
1213
|
+
default:
|
|
1214
|
+
return [{ target: s.placement === "HEAD" ? "head" : "body", html: s.value }];
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
function injectHtml(target, html) {
|
|
1218
|
+
const tpl = document.createElement("template");
|
|
1219
|
+
tpl.innerHTML = html;
|
|
1220
|
+
const added = [];
|
|
1221
|
+
Array.from(tpl.content.childNodes).forEach((node) => {
|
|
1222
|
+
if (node.nodeName === "SCRIPT") {
|
|
1223
|
+
const old = node;
|
|
1224
|
+
const script = document.createElement("script");
|
|
1225
|
+
for (const attr of Array.from(old.attributes)) script.setAttribute(attr.name, attr.value);
|
|
1226
|
+
script.text = old.text;
|
|
1227
|
+
target.appendChild(script);
|
|
1228
|
+
added.push(script);
|
|
1229
|
+
} else if (node.nodeType === Node.ELEMENT_NODE) {
|
|
1230
|
+
const clone = node.cloneNode(true);
|
|
1231
|
+
target.appendChild(clone);
|
|
1232
|
+
added.push(clone);
|
|
1233
|
+
}
|
|
1234
|
+
});
|
|
1235
|
+
return added;
|
|
1236
|
+
}
|
|
1237
|
+
function StorefrontScripts({ visitorId: visitorIdProp } = {}) {
|
|
1238
|
+
const { data } = useShopScripts();
|
|
1239
|
+
const [visitorId, setVisitorId] = _react.useState.call(void 0, _nullishCoalesce(visitorIdProp, () => ( "")));
|
|
1240
|
+
_react.useEffect.call(void 0, () => {
|
|
1241
|
+
if (visitorIdProp) return;
|
|
1242
|
+
try {
|
|
1243
|
+
const v = localStorage.getItem(VISITOR_KEY);
|
|
1244
|
+
if (v) setVisitorId(v);
|
|
1245
|
+
} catch (e6) {
|
|
1246
|
+
}
|
|
1247
|
+
}, [visitorIdProp]);
|
|
1248
|
+
const { data: consent } = useCookieConsent(visitorId || void 0);
|
|
1249
|
+
const analyticsOk = Boolean(_optionalChain([consent, 'optionalAccess', _69 => _69.analytics]));
|
|
1250
|
+
const scripts = _react.useMemo.call(void 0,
|
|
1251
|
+
() => (_nullishCoalesce(_optionalChain([data, 'optionalAccess', _70 => _70.scripts]), () => ( []))).filter((s) => !s.consentRequired || analyticsOk),
|
|
1252
|
+
[data, analyticsOk]
|
|
1253
|
+
);
|
|
1254
|
+
const signature = _react.useMemo.call(void 0,
|
|
1255
|
+
() => JSON.stringify(scripts.map((s) => [s.id, s.type, s.placement, s.value])),
|
|
1256
|
+
[scripts]
|
|
1257
|
+
);
|
|
1258
|
+
_react.useEffect.call(void 0, () => {
|
|
1259
|
+
if (typeof document === "undefined") return;
|
|
1260
|
+
const added = [];
|
|
1261
|
+
for (const s of scripts) {
|
|
1262
|
+
for (const part of partsFor(s)) {
|
|
1263
|
+
const target = part.target === "head" ? document.head : document.body;
|
|
1264
|
+
added.push(...injectHtml(target, part.html));
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
return () => {
|
|
1268
|
+
added.forEach((n) => n.remove());
|
|
1269
|
+
};
|
|
1270
|
+
}, [signature]);
|
|
1271
|
+
return null;
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1137
1274
|
// src/react/hooks/use-bundles.ts
|
|
1138
1275
|
|
|
1139
1276
|
function useBundles(options) {
|
|
@@ -1141,8 +1278,8 @@ function useBundles(options) {
|
|
|
1141
1278
|
return _reactquery.useQuery.call(void 0, {
|
|
1142
1279
|
queryKey: ["behio", "bundles"],
|
|
1143
1280
|
queryFn: () => unwrap(client.catalog.getBundles()),
|
|
1144
|
-
enabled: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1145
|
-
initialData: _optionalChain([options, 'optionalAccess',
|
|
1281
|
+
enabled: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _71 => _71.enabled]), () => ( true)),
|
|
1282
|
+
initialData: _optionalChain([options, 'optionalAccess', _72 => _72.initialData])
|
|
1146
1283
|
});
|
|
1147
1284
|
}
|
|
1148
1285
|
function useBundle(slug, options) {
|
|
@@ -1150,8 +1287,8 @@ function useBundle(slug, options) {
|
|
|
1150
1287
|
return _reactquery.useQuery.call(void 0, {
|
|
1151
1288
|
queryKey: ["behio", "bundle", slug],
|
|
1152
1289
|
queryFn: () => unwrap(client.catalog.getBundle(slug)),
|
|
1153
|
-
enabled: Boolean(slug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1154
|
-
initialData: _optionalChain([options, 'optionalAccess',
|
|
1290
|
+
enabled: Boolean(slug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _73 => _73.enabled]), () => ( true))),
|
|
1291
|
+
initialData: _optionalChain([options, 'optionalAccess', _74 => _74.initialData])
|
|
1155
1292
|
});
|
|
1156
1293
|
}
|
|
1157
1294
|
|
|
@@ -1162,8 +1299,8 @@ function useCrossSell(productSlug, options) {
|
|
|
1162
1299
|
return _reactquery.useQuery.call(void 0, {
|
|
1163
1300
|
queryKey: ["behio", "cross-sell", productSlug],
|
|
1164
1301
|
queryFn: () => unwrap(client.catalog.getCrossSell(productSlug)),
|
|
1165
|
-
enabled: Boolean(productSlug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1166
|
-
initialData: _optionalChain([options, 'optionalAccess',
|
|
1302
|
+
enabled: Boolean(productSlug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _75 => _75.enabled]), () => ( true))),
|
|
1303
|
+
initialData: _optionalChain([options, 'optionalAccess', _76 => _76.initialData])
|
|
1167
1304
|
});
|
|
1168
1305
|
}
|
|
1169
1306
|
|
|
@@ -1174,8 +1311,8 @@ function useProductPromotions(productSlug, options) {
|
|
|
1174
1311
|
return _reactquery.useQuery.call(void 0, {
|
|
1175
1312
|
queryKey: ["behio", "product-promotions", productSlug],
|
|
1176
1313
|
queryFn: () => unwrap(client.catalog.getProductPromotions(productSlug)),
|
|
1177
|
-
enabled: Boolean(productSlug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1178
|
-
refetchInterval: _optionalChain([options, 'optionalAccess',
|
|
1314
|
+
enabled: Boolean(productSlug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _77 => _77.enabled]), () => ( true))),
|
|
1315
|
+
refetchInterval: _optionalChain([options, 'optionalAccess', _78 => _78.refetchIntervalMs])
|
|
1179
1316
|
});
|
|
1180
1317
|
}
|
|
1181
1318
|
|
|
@@ -1183,11 +1320,11 @@ function useProductPromotions(productSlug, options) {
|
|
|
1183
1320
|
|
|
1184
1321
|
function useGiftCardBalance(code, options) {
|
|
1185
1322
|
const { client } = useBehio();
|
|
1186
|
-
const trimmed = _optionalChain([code, 'optionalAccess',
|
|
1323
|
+
const trimmed = _optionalChain([code, 'optionalAccess', _79 => _79.trim, 'call', _80 => _80()]);
|
|
1187
1324
|
return _reactquery.useQuery.call(void 0, {
|
|
1188
1325
|
queryKey: ["behio", "gift-card-balance", trimmed],
|
|
1189
1326
|
queryFn: () => unwrap(client.catalog.checkGiftCard(trimmed)),
|
|
1190
|
-
enabled: Boolean(trimmed && trimmed.length >= 6) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1327
|
+
enabled: Boolean(trimmed && trimmed.length >= 6) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _81 => _81.enabled]), () => ( true)))
|
|
1191
1328
|
});
|
|
1192
1329
|
}
|
|
1193
1330
|
|
|
@@ -1199,7 +1336,7 @@ function useWishlist(options) {
|
|
|
1199
1336
|
const query = _reactquery.useQuery.call(void 0, {
|
|
1200
1337
|
queryKey: ["behio", "wishlist"],
|
|
1201
1338
|
queryFn: () => unwrap(client.wishlist.get()),
|
|
1202
|
-
enabled: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1339
|
+
enabled: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _82 => _82.enabled]), () => ( true))
|
|
1203
1340
|
});
|
|
1204
1341
|
const addMutation = _reactquery.useMutation.call(void 0, {
|
|
1205
1342
|
mutationFn: (productId) => unwrap(client.wishlist.add(productId)),
|
|
@@ -1231,9 +1368,9 @@ function useIsInWishlist(productId) {
|
|
|
1231
1368
|
function useProductReviews(productId, options) {
|
|
1232
1369
|
const { client } = useBehio();
|
|
1233
1370
|
return _reactquery.useQuery.call(void 0, {
|
|
1234
|
-
queryKey: ["behio", "reviews", productId, _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1235
|
-
queryFn: () => unwrap(client.reviews.getProductReviews(productId, _optionalChain([options, 'optionalAccess',
|
|
1236
|
-
enabled: Boolean(productId) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1371
|
+
queryKey: ["behio", "reviews", productId, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _83 => _83.page]), () => ( 1))],
|
|
1372
|
+
queryFn: () => unwrap(client.reviews.getProductReviews(productId, _optionalChain([options, 'optionalAccess', _84 => _84.page]), _optionalChain([options, 'optionalAccess', _85 => _85.limit]))),
|
|
1373
|
+
enabled: Boolean(productId) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _86 => _86.enabled]), () => ( true)))
|
|
1237
1374
|
});
|
|
1238
1375
|
}
|
|
1239
1376
|
function useSubmitReview() {
|
|
@@ -1268,31 +1405,6 @@ function useReturnStatus(returnId, email) {
|
|
|
1268
1405
|
});
|
|
1269
1406
|
}
|
|
1270
1407
|
|
|
1271
|
-
// src/react/hooks/use-consent.ts
|
|
1272
|
-
|
|
1273
|
-
function useCookieConsent(visitorId) {
|
|
1274
|
-
const { client } = useBehio();
|
|
1275
|
-
const qc = _reactquery.useQueryClient.call(void 0, );
|
|
1276
|
-
const query = _reactquery.useQuery.call(void 0, {
|
|
1277
|
-
queryKey: ["behio", "consent", visitorId],
|
|
1278
|
-
queryFn: () => unwrap(client.consent.get(visitorId)),
|
|
1279
|
-
enabled: Boolean(visitorId)
|
|
1280
|
-
});
|
|
1281
|
-
const recordMutation = _reactquery.useMutation.call(void 0, {
|
|
1282
|
-
mutationFn: (input) => unwrap(client.consent.record(input)),
|
|
1283
|
-
onSuccess: () => qc.invalidateQueries({ queryKey: ["behio", "consent"] })
|
|
1284
|
-
});
|
|
1285
|
-
const revokeMutation = _reactquery.useMutation.call(void 0, {
|
|
1286
|
-
mutationFn: () => unwrap(client.consent.revoke(visitorId)),
|
|
1287
|
-
onSuccess: () => qc.invalidateQueries({ queryKey: ["behio", "consent"] })
|
|
1288
|
-
});
|
|
1289
|
-
return {
|
|
1290
|
-
...query,
|
|
1291
|
-
record: recordMutation.mutateAsync,
|
|
1292
|
-
revoke: revokeMutation.mutateAsync
|
|
1293
|
-
};
|
|
1294
|
-
}
|
|
1295
|
-
|
|
1296
1408
|
// src/react/hooks/use-quotes.ts
|
|
1297
1409
|
|
|
1298
1410
|
function useSubmitQuote() {
|
|
@@ -1373,4 +1485,6 @@ function useBehioClient() {
|
|
|
1373
1485
|
|
|
1374
1486
|
|
|
1375
1487
|
|
|
1376
|
-
|
|
1488
|
+
|
|
1489
|
+
|
|
1490
|
+
exports.BehioProvider = BehioProvider; exports.CurrencySwitcher = CurrencySwitcher; exports.StorefrontScripts = StorefrontScripts; exports.cookieStorage = cookieStorage; exports.createMemoryStorage = createMemoryStorage; exports.detectStorage = detectStorage; exports.formatPrice = _chunkXWYDXBLGjs.formatPrice; exports.localStorageAdapter = localStorageAdapter; exports.memoryStorage = memoryStorage; exports.useAddressAutocomplete = useAddressAutocomplete; exports.useAddresses = useAddresses; exports.useAuth = useAuth; exports.useBehio = useBehio; exports.useBehioClient = useBehioClient; exports.useBundle = useBundle; exports.useBundles = useBundles; exports.useCart = useCart; exports.useCartCount = useCartCount; exports.useCategories = useCategories; exports.useCategory = useCategory; exports.useCheckout = useCheckout; exports.useCookieConsent = useCookieConsent; exports.useCrossSell = useCrossSell; exports.useCurrency = useCurrency; exports.useCustomer = useCustomer; exports.useFeatured = useFeatured; exports.useFilters = useFilters; exports.useGiftCardBalance = useGiftCardBalance; exports.useIsInWishlist = useIsInWishlist; exports.useLabels = useLabels; exports.useLookupReturnableOrder = useLookupReturnableOrder; exports.useNotifyWhenAvailable = useNotifyWhenAvailable; exports.useOrder = useOrder; exports.useOrderAccess = useOrderAccess; exports.useOrders = useOrders; exports.usePage = usePage; exports.usePages = usePages; exports.useProduct = useProduct; exports.useProductPromotions = useProductPromotions; exports.useProductReviews = useProductReviews; exports.useProducts = useProducts; exports.useQuoteStatus = useQuoteStatus; exports.useReturnStatus = useReturnStatus; exports.useSearch = useSearch; exports.useShopInfo = useShopInfo; exports.useShopScripts = useShopScripts; exports.useShopSeo = useShopSeo; exports.useSubmitQuote = useSubmitQuote; exports.useSubmitReturn = useSubmitReturn; exports.useSubmitReview = useSubmitReview; exports.useWishlist = useWishlist;
|
package/dist/react.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-YJ45WIQZ.mjs";
|
|
4
4
|
import {
|
|
5
5
|
BehioStorefront
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-L62FH6WI.mjs";
|
|
7
7
|
|
|
8
8
|
// src/react/provider.tsx
|
|
9
9
|
import { useRef, useEffect, useMemo, useState, useCallback } from "react";
|
|
@@ -1070,12 +1070,23 @@ function useShopInfo(options) {
|
|
|
1070
1070
|
});
|
|
1071
1071
|
}
|
|
1072
1072
|
|
|
1073
|
-
// src/react/hooks/use-shop-
|
|
1073
|
+
// src/react/hooks/use-shop-scripts.ts
|
|
1074
1074
|
import { useQuery as useQuery16 } from "@tanstack/react-query";
|
|
1075
|
+
function useShopScripts(options) {
|
|
1076
|
+
const { client } = useBehio();
|
|
1077
|
+
return useQuery16({
|
|
1078
|
+
queryKey: ["behio", "shop-scripts"],
|
|
1079
|
+
queryFn: () => unwrap(client.getShopScripts()),
|
|
1080
|
+
enabled: options?.enabled !== false
|
|
1081
|
+
});
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
// src/react/hooks/use-shop-seo.ts
|
|
1085
|
+
import { useQuery as useQuery17 } from "@tanstack/react-query";
|
|
1075
1086
|
function useShopSeo(options) {
|
|
1076
1087
|
const { client } = useBehio();
|
|
1077
1088
|
const { locale, initialData, enabled = true } = options ?? {};
|
|
1078
|
-
return
|
|
1089
|
+
return useQuery17({
|
|
1079
1090
|
queryKey: ["behio", "shop-seo", locale ?? "_default"],
|
|
1080
1091
|
queryFn: () => unwrap(client.getShopSeo(locale)),
|
|
1081
1092
|
initialData,
|
|
@@ -1134,11 +1145,137 @@ function CurrencySwitcher({
|
|
|
1134
1145
|
);
|
|
1135
1146
|
}
|
|
1136
1147
|
|
|
1148
|
+
// src/react/components/storefront-scripts.tsx
|
|
1149
|
+
import { useEffect as useEffect4, useMemo as useMemo4, useState as useState8 } from "react";
|
|
1150
|
+
|
|
1151
|
+
// src/react/hooks/use-consent.ts
|
|
1152
|
+
import { useQuery as useQuery18, useMutation as useMutation8, useQueryClient as useQueryClient9 } from "@tanstack/react-query";
|
|
1153
|
+
function useCookieConsent(visitorId) {
|
|
1154
|
+
const { client } = useBehio();
|
|
1155
|
+
const qc = useQueryClient9();
|
|
1156
|
+
const query = useQuery18({
|
|
1157
|
+
queryKey: ["behio", "consent", visitorId],
|
|
1158
|
+
queryFn: () => unwrap(client.consent.get(visitorId)),
|
|
1159
|
+
enabled: Boolean(visitorId)
|
|
1160
|
+
});
|
|
1161
|
+
const recordMutation = useMutation8({
|
|
1162
|
+
mutationFn: (input) => unwrap(client.consent.record(input)),
|
|
1163
|
+
onSuccess: () => qc.invalidateQueries({ queryKey: ["behio", "consent"] })
|
|
1164
|
+
});
|
|
1165
|
+
const revokeMutation = useMutation8({
|
|
1166
|
+
mutationFn: () => unwrap(client.consent.revoke(visitorId)),
|
|
1167
|
+
onSuccess: () => qc.invalidateQueries({ queryKey: ["behio", "consent"] })
|
|
1168
|
+
});
|
|
1169
|
+
return {
|
|
1170
|
+
...query,
|
|
1171
|
+
record: recordMutation.mutateAsync,
|
|
1172
|
+
revoke: revokeMutation.mutateAsync
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
// src/react/components/storefront-scripts.tsx
|
|
1177
|
+
var VISITOR_KEY = "behio_visitor_id";
|
|
1178
|
+
function partsFor(s) {
|
|
1179
|
+
const id = s.value.trim();
|
|
1180
|
+
switch (s.type) {
|
|
1181
|
+
case "GA4":
|
|
1182
|
+
return [
|
|
1183
|
+
{
|
|
1184
|
+
target: "head",
|
|
1185
|
+
html: `<script async src="https://www.googletagmanager.com/gtag/js?id=${id}"></script><script>window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments);}gtag('js',new Date());gtag('config','${id}');</script>`
|
|
1186
|
+
}
|
|
1187
|
+
];
|
|
1188
|
+
case "GTM":
|
|
1189
|
+
return [
|
|
1190
|
+
{
|
|
1191
|
+
target: "head",
|
|
1192
|
+
html: `<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','${id}');</script>`
|
|
1193
|
+
},
|
|
1194
|
+
{
|
|
1195
|
+
target: "body",
|
|
1196
|
+
html: `<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=${id}" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>`
|
|
1197
|
+
}
|
|
1198
|
+
];
|
|
1199
|
+
case "META_PIXEL":
|
|
1200
|
+
return [
|
|
1201
|
+
{
|
|
1202
|
+
target: "head",
|
|
1203
|
+
html: `<script>!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,document,'script','https://connect.facebook.net/en_US/fbevents.js');fbq('init','${id}');fbq('track','PageView');</script>`
|
|
1204
|
+
},
|
|
1205
|
+
{
|
|
1206
|
+
target: "body",
|
|
1207
|
+
html: `<noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=${id}&ev=PageView&noscript=1"/></noscript>`
|
|
1208
|
+
}
|
|
1209
|
+
];
|
|
1210
|
+
case "GOOGLE_VERIFICATION":
|
|
1211
|
+
return [{ target: "head", html: `<meta name="google-site-verification" content="${id}" />` }];
|
|
1212
|
+
case "RAW":
|
|
1213
|
+
default:
|
|
1214
|
+
return [{ target: s.placement === "HEAD" ? "head" : "body", html: s.value }];
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
function injectHtml(target, html) {
|
|
1218
|
+
const tpl = document.createElement("template");
|
|
1219
|
+
tpl.innerHTML = html;
|
|
1220
|
+
const added = [];
|
|
1221
|
+
Array.from(tpl.content.childNodes).forEach((node) => {
|
|
1222
|
+
if (node.nodeName === "SCRIPT") {
|
|
1223
|
+
const old = node;
|
|
1224
|
+
const script = document.createElement("script");
|
|
1225
|
+
for (const attr of Array.from(old.attributes)) script.setAttribute(attr.name, attr.value);
|
|
1226
|
+
script.text = old.text;
|
|
1227
|
+
target.appendChild(script);
|
|
1228
|
+
added.push(script);
|
|
1229
|
+
} else if (node.nodeType === Node.ELEMENT_NODE) {
|
|
1230
|
+
const clone = node.cloneNode(true);
|
|
1231
|
+
target.appendChild(clone);
|
|
1232
|
+
added.push(clone);
|
|
1233
|
+
}
|
|
1234
|
+
});
|
|
1235
|
+
return added;
|
|
1236
|
+
}
|
|
1237
|
+
function StorefrontScripts({ visitorId: visitorIdProp } = {}) {
|
|
1238
|
+
const { data } = useShopScripts();
|
|
1239
|
+
const [visitorId, setVisitorId] = useState8(visitorIdProp ?? "");
|
|
1240
|
+
useEffect4(() => {
|
|
1241
|
+
if (visitorIdProp) return;
|
|
1242
|
+
try {
|
|
1243
|
+
const v = localStorage.getItem(VISITOR_KEY);
|
|
1244
|
+
if (v) setVisitorId(v);
|
|
1245
|
+
} catch {
|
|
1246
|
+
}
|
|
1247
|
+
}, [visitorIdProp]);
|
|
1248
|
+
const { data: consent } = useCookieConsent(visitorId || void 0);
|
|
1249
|
+
const analyticsOk = Boolean(consent?.analytics);
|
|
1250
|
+
const scripts = useMemo4(
|
|
1251
|
+
() => (data?.scripts ?? []).filter((s) => !s.consentRequired || analyticsOk),
|
|
1252
|
+
[data, analyticsOk]
|
|
1253
|
+
);
|
|
1254
|
+
const signature = useMemo4(
|
|
1255
|
+
() => JSON.stringify(scripts.map((s) => [s.id, s.type, s.placement, s.value])),
|
|
1256
|
+
[scripts]
|
|
1257
|
+
);
|
|
1258
|
+
useEffect4(() => {
|
|
1259
|
+
if (typeof document === "undefined") return;
|
|
1260
|
+
const added = [];
|
|
1261
|
+
for (const s of scripts) {
|
|
1262
|
+
for (const part of partsFor(s)) {
|
|
1263
|
+
const target = part.target === "head" ? document.head : document.body;
|
|
1264
|
+
added.push(...injectHtml(target, part.html));
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
return () => {
|
|
1268
|
+
added.forEach((n) => n.remove());
|
|
1269
|
+
};
|
|
1270
|
+
}, [signature]);
|
|
1271
|
+
return null;
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1137
1274
|
// src/react/hooks/use-bundles.ts
|
|
1138
|
-
import { useQuery as
|
|
1275
|
+
import { useQuery as useQuery19 } from "@tanstack/react-query";
|
|
1139
1276
|
function useBundles(options) {
|
|
1140
1277
|
const { client } = useBehio();
|
|
1141
|
-
return
|
|
1278
|
+
return useQuery19({
|
|
1142
1279
|
queryKey: ["behio", "bundles"],
|
|
1143
1280
|
queryFn: () => unwrap(client.catalog.getBundles()),
|
|
1144
1281
|
enabled: options?.enabled ?? true,
|
|
@@ -1147,7 +1284,7 @@ function useBundles(options) {
|
|
|
1147
1284
|
}
|
|
1148
1285
|
function useBundle(slug, options) {
|
|
1149
1286
|
const { client } = useBehio();
|
|
1150
|
-
return
|
|
1287
|
+
return useQuery19({
|
|
1151
1288
|
queryKey: ["behio", "bundle", slug],
|
|
1152
1289
|
queryFn: () => unwrap(client.catalog.getBundle(slug)),
|
|
1153
1290
|
enabled: Boolean(slug) && (options?.enabled ?? true),
|
|
@@ -1156,10 +1293,10 @@ function useBundle(slug, options) {
|
|
|
1156
1293
|
}
|
|
1157
1294
|
|
|
1158
1295
|
// src/react/hooks/use-cross-sell.ts
|
|
1159
|
-
import { useQuery as
|
|
1296
|
+
import { useQuery as useQuery20 } from "@tanstack/react-query";
|
|
1160
1297
|
function useCrossSell(productSlug, options) {
|
|
1161
1298
|
const { client } = useBehio();
|
|
1162
|
-
return
|
|
1299
|
+
return useQuery20({
|
|
1163
1300
|
queryKey: ["behio", "cross-sell", productSlug],
|
|
1164
1301
|
queryFn: () => unwrap(client.catalog.getCrossSell(productSlug)),
|
|
1165
1302
|
enabled: Boolean(productSlug) && (options?.enabled ?? true),
|
|
@@ -1168,10 +1305,10 @@ function useCrossSell(productSlug, options) {
|
|
|
1168
1305
|
}
|
|
1169
1306
|
|
|
1170
1307
|
// src/react/hooks/use-product-promotions.ts
|
|
1171
|
-
import { useQuery as
|
|
1308
|
+
import { useQuery as useQuery21 } from "@tanstack/react-query";
|
|
1172
1309
|
function useProductPromotions(productSlug, options) {
|
|
1173
1310
|
const { client } = useBehio();
|
|
1174
|
-
return
|
|
1311
|
+
return useQuery21({
|
|
1175
1312
|
queryKey: ["behio", "product-promotions", productSlug],
|
|
1176
1313
|
queryFn: () => unwrap(client.catalog.getProductPromotions(productSlug)),
|
|
1177
1314
|
enabled: Boolean(productSlug) && (options?.enabled ?? true),
|
|
@@ -1180,11 +1317,11 @@ function useProductPromotions(productSlug, options) {
|
|
|
1180
1317
|
}
|
|
1181
1318
|
|
|
1182
1319
|
// src/react/hooks/use-gift-card.ts
|
|
1183
|
-
import { useQuery as
|
|
1320
|
+
import { useQuery as useQuery22 } from "@tanstack/react-query";
|
|
1184
1321
|
function useGiftCardBalance(code, options) {
|
|
1185
1322
|
const { client } = useBehio();
|
|
1186
1323
|
const trimmed = code?.trim();
|
|
1187
|
-
return
|
|
1324
|
+
return useQuery22({
|
|
1188
1325
|
queryKey: ["behio", "gift-card-balance", trimmed],
|
|
1189
1326
|
queryFn: () => unwrap(client.catalog.checkGiftCard(trimmed)),
|
|
1190
1327
|
enabled: Boolean(trimmed && trimmed.length >= 6) && (options?.enabled ?? true)
|
|
@@ -1192,20 +1329,20 @@ function useGiftCardBalance(code, options) {
|
|
|
1192
1329
|
}
|
|
1193
1330
|
|
|
1194
1331
|
// src/react/hooks/use-wishlist.ts
|
|
1195
|
-
import { useQuery as
|
|
1332
|
+
import { useQuery as useQuery23, useMutation as useMutation9, useQueryClient as useQueryClient10 } from "@tanstack/react-query";
|
|
1196
1333
|
function useWishlist(options) {
|
|
1197
1334
|
const { client } = useBehio();
|
|
1198
|
-
const qc =
|
|
1199
|
-
const query =
|
|
1335
|
+
const qc = useQueryClient10();
|
|
1336
|
+
const query = useQuery23({
|
|
1200
1337
|
queryKey: ["behio", "wishlist"],
|
|
1201
1338
|
queryFn: () => unwrap(client.wishlist.get()),
|
|
1202
1339
|
enabled: options?.enabled ?? true
|
|
1203
1340
|
});
|
|
1204
|
-
const addMutation =
|
|
1341
|
+
const addMutation = useMutation9({
|
|
1205
1342
|
mutationFn: (productId) => unwrap(client.wishlist.add(productId)),
|
|
1206
1343
|
onSuccess: () => qc.invalidateQueries({ queryKey: ["behio", "wishlist"] })
|
|
1207
1344
|
});
|
|
1208
|
-
const removeMutation =
|
|
1345
|
+
const removeMutation = useMutation9({
|
|
1209
1346
|
mutationFn: (productId) => unwrap(client.wishlist.remove(productId)),
|
|
1210
1347
|
onSuccess: () => qc.invalidateQueries({ queryKey: ["behio", "wishlist"] })
|
|
1211
1348
|
});
|
|
@@ -1219,7 +1356,7 @@ function useWishlist(options) {
|
|
|
1219
1356
|
}
|
|
1220
1357
|
function useIsInWishlist(productId) {
|
|
1221
1358
|
const { client } = useBehio();
|
|
1222
|
-
return
|
|
1359
|
+
return useQuery23({
|
|
1223
1360
|
queryKey: ["behio", "wishlist-check", productId],
|
|
1224
1361
|
queryFn: () => unwrap(client.wishlist.isInWishlist(productId)),
|
|
1225
1362
|
enabled: Boolean(productId)
|
|
@@ -1227,10 +1364,10 @@ function useIsInWishlist(productId) {
|
|
|
1227
1364
|
}
|
|
1228
1365
|
|
|
1229
1366
|
// src/react/hooks/use-reviews.ts
|
|
1230
|
-
import { useQuery as
|
|
1367
|
+
import { useQuery as useQuery24, useMutation as useMutation10, useQueryClient as useQueryClient11 } from "@tanstack/react-query";
|
|
1231
1368
|
function useProductReviews(productId, options) {
|
|
1232
1369
|
const { client } = useBehio();
|
|
1233
|
-
return
|
|
1370
|
+
return useQuery24({
|
|
1234
1371
|
queryKey: ["behio", "reviews", productId, options?.page ?? 1],
|
|
1235
1372
|
queryFn: () => unwrap(client.reviews.getProductReviews(productId, options?.page, options?.limit)),
|
|
1236
1373
|
enabled: Boolean(productId) && (options?.enabled ?? true)
|
|
@@ -1238,63 +1375,38 @@ function useProductReviews(productId, options) {
|
|
|
1238
1375
|
}
|
|
1239
1376
|
function useSubmitReview() {
|
|
1240
1377
|
const { client } = useBehio();
|
|
1241
|
-
const qc =
|
|
1242
|
-
return
|
|
1378
|
+
const qc = useQueryClient11();
|
|
1379
|
+
return useMutation10({
|
|
1243
1380
|
mutationFn: (input) => unwrap(client.reviews.submit(input)),
|
|
1244
1381
|
onSuccess: (_, input) => qc.invalidateQueries({ queryKey: ["behio", "reviews", input.productId] })
|
|
1245
1382
|
});
|
|
1246
1383
|
}
|
|
1247
1384
|
|
|
1248
1385
|
// src/react/hooks/use-returns.ts
|
|
1249
|
-
import { useQuery as
|
|
1386
|
+
import { useQuery as useQuery25, useMutation as useMutation11 } from "@tanstack/react-query";
|
|
1250
1387
|
function useLookupReturnableOrder() {
|
|
1251
1388
|
const { client } = useBehio();
|
|
1252
|
-
return
|
|
1389
|
+
return useMutation11({
|
|
1253
1390
|
mutationFn: ({ orderNumber, email }) => unwrap(client.returns.lookupOrder(orderNumber, email))
|
|
1254
1391
|
});
|
|
1255
1392
|
}
|
|
1256
1393
|
function useSubmitReturn() {
|
|
1257
1394
|
const { client } = useBehio();
|
|
1258
|
-
return
|
|
1395
|
+
return useMutation11({
|
|
1259
1396
|
mutationFn: (input) => unwrap(client.returns.submit(input))
|
|
1260
1397
|
});
|
|
1261
1398
|
}
|
|
1262
1399
|
function useReturnStatus(returnId, email) {
|
|
1263
1400
|
const { client } = useBehio();
|
|
1264
|
-
return
|
|
1401
|
+
return useQuery25({
|
|
1265
1402
|
queryKey: ["behio", "return-status", returnId],
|
|
1266
1403
|
queryFn: () => unwrap(client.returns.getStatus(returnId, email)),
|
|
1267
1404
|
enabled: Boolean(returnId && email)
|
|
1268
1405
|
});
|
|
1269
1406
|
}
|
|
1270
1407
|
|
|
1271
|
-
// src/react/hooks/use-consent.ts
|
|
1272
|
-
import { useQuery as useQuery24, useMutation as useMutation11, useQueryClient as useQueryClient11 } from "@tanstack/react-query";
|
|
1273
|
-
function useCookieConsent(visitorId) {
|
|
1274
|
-
const { client } = useBehio();
|
|
1275
|
-
const qc = useQueryClient11();
|
|
1276
|
-
const query = useQuery24({
|
|
1277
|
-
queryKey: ["behio", "consent", visitorId],
|
|
1278
|
-
queryFn: () => unwrap(client.consent.get(visitorId)),
|
|
1279
|
-
enabled: Boolean(visitorId)
|
|
1280
|
-
});
|
|
1281
|
-
const recordMutation = useMutation11({
|
|
1282
|
-
mutationFn: (input) => unwrap(client.consent.record(input)),
|
|
1283
|
-
onSuccess: () => qc.invalidateQueries({ queryKey: ["behio", "consent"] })
|
|
1284
|
-
});
|
|
1285
|
-
const revokeMutation = useMutation11({
|
|
1286
|
-
mutationFn: () => unwrap(client.consent.revoke(visitorId)),
|
|
1287
|
-
onSuccess: () => qc.invalidateQueries({ queryKey: ["behio", "consent"] })
|
|
1288
|
-
});
|
|
1289
|
-
return {
|
|
1290
|
-
...query,
|
|
1291
|
-
record: recordMutation.mutateAsync,
|
|
1292
|
-
revoke: revokeMutation.mutateAsync
|
|
1293
|
-
};
|
|
1294
|
-
}
|
|
1295
|
-
|
|
1296
1408
|
// src/react/hooks/use-quotes.ts
|
|
1297
|
-
import { useMutation as useMutation12, useQuery as
|
|
1409
|
+
import { useMutation as useMutation12, useQuery as useQuery26 } from "@tanstack/react-query";
|
|
1298
1410
|
function useSubmitQuote() {
|
|
1299
1411
|
const { client } = useBehio();
|
|
1300
1412
|
return useMutation12({
|
|
@@ -1303,7 +1415,7 @@ function useSubmitQuote() {
|
|
|
1303
1415
|
}
|
|
1304
1416
|
function useQuoteStatus(quoteId, email) {
|
|
1305
1417
|
const { client } = useBehio();
|
|
1306
|
-
return
|
|
1418
|
+
return useQuery26({
|
|
1307
1419
|
queryKey: ["behio", "quote-status", quoteId],
|
|
1308
1420
|
queryFn: () => unwrap(client.quotes.getStatus(quoteId, email)),
|
|
1309
1421
|
enabled: Boolean(quoteId && email)
|
|
@@ -1326,6 +1438,7 @@ function useBehioClient() {
|
|
|
1326
1438
|
export {
|
|
1327
1439
|
BehioProvider,
|
|
1328
1440
|
CurrencySwitcher,
|
|
1441
|
+
StorefrontScripts,
|
|
1329
1442
|
cookieStorage,
|
|
1330
1443
|
createMemoryStorage,
|
|
1331
1444
|
detectStorage,
|
|
@@ -1368,6 +1481,7 @@ export {
|
|
|
1368
1481
|
useReturnStatus,
|
|
1369
1482
|
useSearch,
|
|
1370
1483
|
useShopInfo,
|
|
1484
|
+
useShopScripts,
|
|
1371
1485
|
useShopSeo,
|
|
1372
1486
|
useSubmitQuote,
|
|
1373
1487
|
useSubmitReturn,
|