@behio/storefront-sdk 2.5.1 → 2.6.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/README.md +10 -3
- package/dist/{chunk-AD2VKVVM.js → chunk-JCHJ2HW4.js} +85 -20
- package/dist/{chunk-L5QBTEJ4.mjs → chunk-WQVG4HW7.mjs} +83 -18
- package/dist/{client-DEE8yg6v.d.mts → client-xoomjG8Z.d.mts} +8 -8
- package/dist/{client-DEE8yg6v.d.ts → client-xoomjG8Z.d.ts} +8 -8
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -3
- package/dist/index.mjs +3 -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 +4 -0
- package/dist/react.d.ts +4 -0
- package/dist/react.js +82 -18
- package/dist/react.mjs +82 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -269,15 +269,22 @@ does not double quantities. Expired links fail with
|
|
|
269
269
|
`be.storefront.cartLinkExpired`. Answer `GET /cart/link/_probe` with header
|
|
270
270
|
`x-behio-cart-link: 1` so Behio Chat knows the storefront supports links.
|
|
271
271
|
|
|
272
|
-
### Cart summary for page scripts (2.
|
|
272
|
+
### Cart summary for page scripts (2.6)
|
|
273
273
|
|
|
274
274
|
Browser cart responses dispatch `behio:cart` on `window` with
|
|
275
275
|
`{total, currency, itemCount}` and keep the last value in `window.__behioCart`
|
|
276
276
|
(Behio Chat reads it for cart-value greetings). Carts with
|
|
277
|
-
`totalsAvailable: false
|
|
277
|
+
`totalsAvailable: false`, failed reads and changed customer/pricing context
|
|
278
|
+
clear the last value and dispatch `detail: null`. Null means unknown, whereas
|
|
279
|
+
`{total: 0, itemCount: 0, currency}` is a confirmed empty cart. Listeners must
|
|
280
|
+
handle both. The count comes from the authoritative `cart.itemCount`, including
|
|
281
|
+
bundle units. Older responses cannot restore a newer summary.
|
|
282
|
+
Storefronts that mutate the cart on
|
|
278
283
|
the server (Server Actions, snapshot routes) call
|
|
279
284
|
`publishCartSummary({total, currency, itemCount})` on the client after each
|
|
280
|
-
fresh cart
|
|
285
|
+
fresh cart. Call `clearCartSummary()` when that snapshot fails, has unavailable
|
|
286
|
+
totals or requires login. Both functions do nothing during SSR. Behio Chat
|
|
287
|
+
cancels cart-value greetings and removes stale cart text when the value clears.
|
|
281
288
|
|
|
282
289
|
### Bundle offers and galleries (2.0, unreleased)
|
|
283
290
|
|
|
@@ -167,6 +167,9 @@ var BehioStorefront = class {
|
|
|
167
167
|
this.refreshPromise = null;
|
|
168
168
|
this.requestContextVersion = 0;
|
|
169
169
|
this.authContextVersion = 0;
|
|
170
|
+
this.cartSummarySequence = 0;
|
|
171
|
+
this.cartSummaryWrites = /* @__PURE__ */ new Set();
|
|
172
|
+
this.cartSummaryWriteVersion = 0;
|
|
170
173
|
// Event emitter
|
|
171
174
|
this.listeners = /* @__PURE__ */ new Map();
|
|
172
175
|
// Interceptors
|
|
@@ -210,6 +213,11 @@ var BehioStorefront = class {
|
|
|
210
213
|
this.subscriptions = new SubscriptionsModule(this);
|
|
211
214
|
this.certificates = new CourseCertificatesModule(this);
|
|
212
215
|
}
|
|
216
|
+
invalidateCartSummary() {
|
|
217
|
+
++this.cartSummarySequence;
|
|
218
|
+
this.cartSummaryWrites.clear();
|
|
219
|
+
clearCartSummary();
|
|
220
|
+
}
|
|
213
221
|
/** @internal Opaque generation, never a token or customer identifier. */
|
|
214
222
|
getRequestContextVersion() {
|
|
215
223
|
return this.requestContextVersion;
|
|
@@ -328,6 +336,7 @@ var BehioStorefront = class {
|
|
|
328
336
|
if (this.accessToken !== tokens.accessToken || this.refreshToken !== tokens.refreshToken) {
|
|
329
337
|
this.authContextVersion++;
|
|
330
338
|
this.requestContextVersion++;
|
|
339
|
+
this.invalidateCartSummary();
|
|
331
340
|
}
|
|
332
341
|
this.accessToken = tokens.accessToken;
|
|
333
342
|
this.refreshToken = tokens.refreshToken;
|
|
@@ -337,6 +346,7 @@ var BehioStorefront = class {
|
|
|
337
346
|
if (this.accessToken || this.refreshToken) {
|
|
338
347
|
this.authContextVersion++;
|
|
339
348
|
this.requestContextVersion++;
|
|
349
|
+
this.invalidateCartSummary();
|
|
340
350
|
}
|
|
341
351
|
this.accessToken = void 0;
|
|
342
352
|
this.refreshToken = void 0;
|
|
@@ -351,7 +361,10 @@ var BehioStorefront = class {
|
|
|
351
361
|
}
|
|
352
362
|
/** Set cart session token (e.g. from cookie) */
|
|
353
363
|
setCartSession(token) {
|
|
354
|
-
if (this.cartSession !== token)
|
|
364
|
+
if (this.cartSession !== token) {
|
|
365
|
+
this.requestContextVersion++;
|
|
366
|
+
this.invalidateCartSummary();
|
|
367
|
+
}
|
|
355
368
|
this.cartSession = token;
|
|
356
369
|
}
|
|
357
370
|
/** Get cart session token */
|
|
@@ -360,7 +373,10 @@ var BehioStorefront = class {
|
|
|
360
373
|
}
|
|
361
374
|
/** Clear cart session */
|
|
362
375
|
clearCartSession() {
|
|
363
|
-
if (this.cartSession)
|
|
376
|
+
if (this.cartSession) {
|
|
377
|
+
this.requestContextVersion++;
|
|
378
|
+
this.invalidateCartSummary();
|
|
379
|
+
}
|
|
364
380
|
this.cartSession = void 0;
|
|
365
381
|
}
|
|
366
382
|
// --- Default currency / locale (runtime-switchable) ---
|
|
@@ -371,7 +387,10 @@ var BehioStorefront = class {
|
|
|
371
387
|
* (falls back to the shop's default currency server-side).
|
|
372
388
|
*/
|
|
373
389
|
setCurrency(currency) {
|
|
374
|
-
if (this.defaultCurrency !== (currency || void 0))
|
|
390
|
+
if (this.defaultCurrency !== (currency || void 0)) {
|
|
391
|
+
this.requestContextVersion++;
|
|
392
|
+
this.invalidateCartSummary();
|
|
393
|
+
}
|
|
375
394
|
this.defaultCurrency = currency || void 0;
|
|
376
395
|
}
|
|
377
396
|
/** Get the current default currency, if any. */
|
|
@@ -382,7 +401,10 @@ var BehioStorefront = class {
|
|
|
382
401
|
setCountry(country) {
|
|
383
402
|
const normalized = _optionalChain([country, 'optionalAccess', _3 => _3.trim, 'call', _4 => _4(), 'access', _5 => _5.toUpperCase, 'call', _6 => _6()]);
|
|
384
403
|
const next = normalized && /^[A-Z]{2}$/.test(normalized) ? normalized : void 0;
|
|
385
|
-
if (this.defaultCountry !== next)
|
|
404
|
+
if (this.defaultCountry !== next) {
|
|
405
|
+
this.requestContextVersion++;
|
|
406
|
+
this.invalidateCartSummary();
|
|
407
|
+
}
|
|
386
408
|
this.defaultCountry = next;
|
|
387
409
|
}
|
|
388
410
|
getCountry() {
|
|
@@ -390,7 +412,10 @@ var BehioStorefront = class {
|
|
|
390
412
|
}
|
|
391
413
|
/** Set the default locale sent on every catalog request (per-call wins). */
|
|
392
414
|
setLocale(locale) {
|
|
393
|
-
if (this.defaultLocale !== (locale || void 0))
|
|
415
|
+
if (this.defaultLocale !== (locale || void 0)) {
|
|
416
|
+
this.requestContextVersion++;
|
|
417
|
+
this.invalidateCartSummary();
|
|
418
|
+
}
|
|
394
419
|
this.defaultLocale = locale || void 0;
|
|
395
420
|
}
|
|
396
421
|
/** Get the current default locale, if any. */
|
|
@@ -476,15 +501,36 @@ var BehioStorefront = class {
|
|
|
476
501
|
* methods (behio.catalog.*, behio.cart.*, …) instead.
|
|
477
502
|
*/
|
|
478
503
|
async request(method, path, options) {
|
|
504
|
+
const isCart = path === "/cart" || path.startsWith("/cart/");
|
|
505
|
+
const sequence = isCart ? ++this.cartSummarySequence : 0;
|
|
506
|
+
const contextVersion = this.requestContextVersion;
|
|
507
|
+
const writeVersion = this.cartSummaryWriteVersion;
|
|
508
|
+
const isWrite = isCart && method !== "GET" && method !== "HEAD";
|
|
509
|
+
if (isWrite) {
|
|
510
|
+
this.cartSummaryWrites.add(sequence);
|
|
511
|
+
clearCartSummary();
|
|
512
|
+
}
|
|
513
|
+
const pageRevision = cartSummaryRevision(isCart);
|
|
479
514
|
try {
|
|
480
515
|
const data = await this.rawRequest(method, path, options);
|
|
481
|
-
if (
|
|
516
|
+
if (isWrite) ++this.cartSummaryWriteVersion;
|
|
517
|
+
if (isCart && pageRevision === cartSummaryRevision() && sequence === this.cartSummarySequence && contextVersion === this.requestContextVersion && this.cartSummaryWrites.size === (isWrite ? 1 : 0) && (isWrite || writeVersion === this.cartSummaryWriteVersion)) {
|
|
518
|
+
const cart = data;
|
|
519
|
+
const token = cart && Array.isArray(cart.items) ? cart.newSessionToken || cart.sessionToken : void 0;
|
|
520
|
+
if (token) this.setCartSession(token);
|
|
521
|
+
if (path === "/cart" && method === "DELETE") {
|
|
522
|
+
publishCartSummary({ total: 0, currency: _nullishCoalesce(this.defaultCurrency, () => ( null)), itemCount: 0 });
|
|
523
|
+
} else emitCartEvent(data);
|
|
524
|
+
}
|
|
482
525
|
return ok(data);
|
|
483
526
|
} catch (err2) {
|
|
527
|
+
if (isCart && pageRevision === cartSummaryRevision() && sequence === this.cartSummarySequence && contextVersion === this.requestContextVersion) clearCartSummary();
|
|
484
528
|
if (this.throwOnAvailabilityError && isAvailabilityFailure(err2)) {
|
|
485
529
|
throw err2;
|
|
486
530
|
}
|
|
487
531
|
return { data: null, error: toSdkError(err2) };
|
|
532
|
+
} finally {
|
|
533
|
+
if (isWrite) this.cartSummaryWrites.delete(sequence);
|
|
488
534
|
}
|
|
489
535
|
}
|
|
490
536
|
/**
|
|
@@ -2126,28 +2172,46 @@ var NewsletterModule = class {
|
|
|
2126
2172
|
);
|
|
2127
2173
|
}
|
|
2128
2174
|
};
|
|
2175
|
+
var summaryRevisionKey = /* @__PURE__ */ Symbol.for("behio.cart.summary.revision");
|
|
2176
|
+
function cartSummaryRevision(advance = false) {
|
|
2177
|
+
if (typeof window === "undefined") return 0;
|
|
2178
|
+
const page = window;
|
|
2179
|
+
const revision = (_nullishCoalesce(page[summaryRevisionKey], () => ( 0))) + (advance ? 1 : 0);
|
|
2180
|
+
if (advance) page[summaryRevisionKey] = revision;
|
|
2181
|
+
return revision;
|
|
2182
|
+
}
|
|
2183
|
+
function clearCartSummary() {
|
|
2184
|
+
if (typeof window === "undefined") return;
|
|
2185
|
+
cartSummaryRevision(true);
|
|
2186
|
+
window.__behioCart = null;
|
|
2187
|
+
try {
|
|
2188
|
+
window.dispatchEvent(new CustomEvent("behio:cart", { detail: null }));
|
|
2189
|
+
} catch (e6) {
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2129
2192
|
function publishCartSummary(summary) {
|
|
2130
|
-
if (typeof window === "undefined"
|
|
2131
|
-
if (!Number.isFinite(summary.total) || !Number.isFinite(summary.itemCount))
|
|
2132
|
-
|
|
2193
|
+
if (typeof window === "undefined") return;
|
|
2194
|
+
if (!summary || !Number.isFinite(summary.total) || summary.total < 0 || !Number.isFinite(summary.itemCount) || summary.itemCount < 0) {
|
|
2195
|
+
clearCartSummary();
|
|
2196
|
+
return;
|
|
2197
|
+
}
|
|
2198
|
+
cartSummaryRevision(true);
|
|
2199
|
+
const detail = { total: summary.total, currency: typeof summary.currency === "string" ? summary.currency : null, itemCount: summary.itemCount };
|
|
2200
|
+
window.__behioCart = detail;
|
|
2133
2201
|
try {
|
|
2134
|
-
window.__behioCart = detail;
|
|
2135
2202
|
window.dispatchEvent(new CustomEvent("behio:cart", { detail }));
|
|
2136
|
-
} catch (
|
|
2203
|
+
} catch (e7) {
|
|
2137
2204
|
}
|
|
2138
2205
|
}
|
|
2139
2206
|
function emitCartEvent(data) {
|
|
2140
2207
|
if (typeof window === "undefined") return;
|
|
2141
2208
|
const cart = data;
|
|
2142
2209
|
if (!cart || typeof cart !== "object" || !Array.isArray(cart.items)) return;
|
|
2143
|
-
if (cart.totalsAvailable === false)
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
currency: typeof cart.currency === "string" ? cart.currency : null,
|
|
2149
|
-
itemCount: items.reduce((n, i) => n + (typeof _optionalChain([i, 'optionalAccess', _53 => _53.quantity]) === "number" ? i.quantity : 1), 0)
|
|
2150
|
-
});
|
|
2210
|
+
if (cart.totalsAvailable === false || typeof cart.grandTotal !== "number" || typeof cart.itemCount !== "number") {
|
|
2211
|
+
clearCartSummary();
|
|
2212
|
+
return;
|
|
2213
|
+
}
|
|
2214
|
+
publishCartSummary({ total: cart.grandTotal, currency: typeof cart.currency === "string" ? cart.currency : null, itemCount: cart.itemCount });
|
|
2151
2215
|
}
|
|
2152
2216
|
|
|
2153
2217
|
|
|
@@ -2163,4 +2227,5 @@ function emitCartEvent(data) {
|
|
|
2163
2227
|
|
|
2164
2228
|
|
|
2165
2229
|
|
|
2166
|
-
|
|
2230
|
+
|
|
2231
|
+
exports.ProductSort = ProductSort; exports.OrderStatuses = OrderStatuses; exports.PaymentStatuses = PaymentStatuses; exports.FulfillmentStatuses = FulfillmentStatuses; exports.AddressTypes = AddressTypes; exports.BehioApiError = BehioApiError; exports.BehioNetworkError = BehioNetworkError; exports.ok = ok; exports.err = err; exports.toSdkError = toSdkError; exports.BehioStorefront = BehioStorefront; exports.clearCartSummary = clearCartSummary; exports.publishCartSummary = publishCartSummary;
|
|
@@ -167,6 +167,9 @@ var BehioStorefront = class {
|
|
|
167
167
|
this.refreshPromise = null;
|
|
168
168
|
this.requestContextVersion = 0;
|
|
169
169
|
this.authContextVersion = 0;
|
|
170
|
+
this.cartSummarySequence = 0;
|
|
171
|
+
this.cartSummaryWrites = /* @__PURE__ */ new Set();
|
|
172
|
+
this.cartSummaryWriteVersion = 0;
|
|
170
173
|
// Event emitter
|
|
171
174
|
this.listeners = /* @__PURE__ */ new Map();
|
|
172
175
|
// Interceptors
|
|
@@ -210,6 +213,11 @@ var BehioStorefront = class {
|
|
|
210
213
|
this.subscriptions = new SubscriptionsModule(this);
|
|
211
214
|
this.certificates = new CourseCertificatesModule(this);
|
|
212
215
|
}
|
|
216
|
+
invalidateCartSummary() {
|
|
217
|
+
++this.cartSummarySequence;
|
|
218
|
+
this.cartSummaryWrites.clear();
|
|
219
|
+
clearCartSummary();
|
|
220
|
+
}
|
|
213
221
|
/** @internal Opaque generation, never a token or customer identifier. */
|
|
214
222
|
getRequestContextVersion() {
|
|
215
223
|
return this.requestContextVersion;
|
|
@@ -328,6 +336,7 @@ var BehioStorefront = class {
|
|
|
328
336
|
if (this.accessToken !== tokens.accessToken || this.refreshToken !== tokens.refreshToken) {
|
|
329
337
|
this.authContextVersion++;
|
|
330
338
|
this.requestContextVersion++;
|
|
339
|
+
this.invalidateCartSummary();
|
|
331
340
|
}
|
|
332
341
|
this.accessToken = tokens.accessToken;
|
|
333
342
|
this.refreshToken = tokens.refreshToken;
|
|
@@ -337,6 +346,7 @@ var BehioStorefront = class {
|
|
|
337
346
|
if (this.accessToken || this.refreshToken) {
|
|
338
347
|
this.authContextVersion++;
|
|
339
348
|
this.requestContextVersion++;
|
|
349
|
+
this.invalidateCartSummary();
|
|
340
350
|
}
|
|
341
351
|
this.accessToken = void 0;
|
|
342
352
|
this.refreshToken = void 0;
|
|
@@ -351,7 +361,10 @@ var BehioStorefront = class {
|
|
|
351
361
|
}
|
|
352
362
|
/** Set cart session token (e.g. from cookie) */
|
|
353
363
|
setCartSession(token) {
|
|
354
|
-
if (this.cartSession !== token)
|
|
364
|
+
if (this.cartSession !== token) {
|
|
365
|
+
this.requestContextVersion++;
|
|
366
|
+
this.invalidateCartSummary();
|
|
367
|
+
}
|
|
355
368
|
this.cartSession = token;
|
|
356
369
|
}
|
|
357
370
|
/** Get cart session token */
|
|
@@ -360,7 +373,10 @@ var BehioStorefront = class {
|
|
|
360
373
|
}
|
|
361
374
|
/** Clear cart session */
|
|
362
375
|
clearCartSession() {
|
|
363
|
-
if (this.cartSession)
|
|
376
|
+
if (this.cartSession) {
|
|
377
|
+
this.requestContextVersion++;
|
|
378
|
+
this.invalidateCartSummary();
|
|
379
|
+
}
|
|
364
380
|
this.cartSession = void 0;
|
|
365
381
|
}
|
|
366
382
|
// --- Default currency / locale (runtime-switchable) ---
|
|
@@ -371,7 +387,10 @@ var BehioStorefront = class {
|
|
|
371
387
|
* (falls back to the shop's default currency server-side).
|
|
372
388
|
*/
|
|
373
389
|
setCurrency(currency) {
|
|
374
|
-
if (this.defaultCurrency !== (currency || void 0))
|
|
390
|
+
if (this.defaultCurrency !== (currency || void 0)) {
|
|
391
|
+
this.requestContextVersion++;
|
|
392
|
+
this.invalidateCartSummary();
|
|
393
|
+
}
|
|
375
394
|
this.defaultCurrency = currency || void 0;
|
|
376
395
|
}
|
|
377
396
|
/** Get the current default currency, if any. */
|
|
@@ -382,7 +401,10 @@ var BehioStorefront = class {
|
|
|
382
401
|
setCountry(country) {
|
|
383
402
|
const normalized = country?.trim().toUpperCase();
|
|
384
403
|
const next = normalized && /^[A-Z]{2}$/.test(normalized) ? normalized : void 0;
|
|
385
|
-
if (this.defaultCountry !== next)
|
|
404
|
+
if (this.defaultCountry !== next) {
|
|
405
|
+
this.requestContextVersion++;
|
|
406
|
+
this.invalidateCartSummary();
|
|
407
|
+
}
|
|
386
408
|
this.defaultCountry = next;
|
|
387
409
|
}
|
|
388
410
|
getCountry() {
|
|
@@ -390,7 +412,10 @@ var BehioStorefront = class {
|
|
|
390
412
|
}
|
|
391
413
|
/** Set the default locale sent on every catalog request (per-call wins). */
|
|
392
414
|
setLocale(locale) {
|
|
393
|
-
if (this.defaultLocale !== (locale || void 0))
|
|
415
|
+
if (this.defaultLocale !== (locale || void 0)) {
|
|
416
|
+
this.requestContextVersion++;
|
|
417
|
+
this.invalidateCartSummary();
|
|
418
|
+
}
|
|
394
419
|
this.defaultLocale = locale || void 0;
|
|
395
420
|
}
|
|
396
421
|
/** Get the current default locale, if any. */
|
|
@@ -476,15 +501,36 @@ var BehioStorefront = class {
|
|
|
476
501
|
* methods (behio.catalog.*, behio.cart.*, …) instead.
|
|
477
502
|
*/
|
|
478
503
|
async request(method, path, options) {
|
|
504
|
+
const isCart = path === "/cart" || path.startsWith("/cart/");
|
|
505
|
+
const sequence = isCart ? ++this.cartSummarySequence : 0;
|
|
506
|
+
const contextVersion = this.requestContextVersion;
|
|
507
|
+
const writeVersion = this.cartSummaryWriteVersion;
|
|
508
|
+
const isWrite = isCart && method !== "GET" && method !== "HEAD";
|
|
509
|
+
if (isWrite) {
|
|
510
|
+
this.cartSummaryWrites.add(sequence);
|
|
511
|
+
clearCartSummary();
|
|
512
|
+
}
|
|
513
|
+
const pageRevision = cartSummaryRevision(isCart);
|
|
479
514
|
try {
|
|
480
515
|
const data = await this.rawRequest(method, path, options);
|
|
481
|
-
if (
|
|
516
|
+
if (isWrite) ++this.cartSummaryWriteVersion;
|
|
517
|
+
if (isCart && pageRevision === cartSummaryRevision() && sequence === this.cartSummarySequence && contextVersion === this.requestContextVersion && this.cartSummaryWrites.size === (isWrite ? 1 : 0) && (isWrite || writeVersion === this.cartSummaryWriteVersion)) {
|
|
518
|
+
const cart = data;
|
|
519
|
+
const token = cart && Array.isArray(cart.items) ? cart.newSessionToken || cart.sessionToken : void 0;
|
|
520
|
+
if (token) this.setCartSession(token);
|
|
521
|
+
if (path === "/cart" && method === "DELETE") {
|
|
522
|
+
publishCartSummary({ total: 0, currency: this.defaultCurrency ?? null, itemCount: 0 });
|
|
523
|
+
} else emitCartEvent(data);
|
|
524
|
+
}
|
|
482
525
|
return ok(data);
|
|
483
526
|
} catch (err2) {
|
|
527
|
+
if (isCart && pageRevision === cartSummaryRevision() && sequence === this.cartSummarySequence && contextVersion === this.requestContextVersion) clearCartSummary();
|
|
484
528
|
if (this.throwOnAvailabilityError && isAvailabilityFailure(err2)) {
|
|
485
529
|
throw err2;
|
|
486
530
|
}
|
|
487
531
|
return { data: null, error: toSdkError(err2) };
|
|
532
|
+
} finally {
|
|
533
|
+
if (isWrite) this.cartSummaryWrites.delete(sequence);
|
|
488
534
|
}
|
|
489
535
|
}
|
|
490
536
|
/**
|
|
@@ -2126,12 +2172,33 @@ var NewsletterModule = class {
|
|
|
2126
2172
|
);
|
|
2127
2173
|
}
|
|
2128
2174
|
};
|
|
2175
|
+
var summaryRevisionKey = /* @__PURE__ */ Symbol.for("behio.cart.summary.revision");
|
|
2176
|
+
function cartSummaryRevision(advance = false) {
|
|
2177
|
+
if (typeof window === "undefined") return 0;
|
|
2178
|
+
const page = window;
|
|
2179
|
+
const revision = (page[summaryRevisionKey] ?? 0) + (advance ? 1 : 0);
|
|
2180
|
+
if (advance) page[summaryRevisionKey] = revision;
|
|
2181
|
+
return revision;
|
|
2182
|
+
}
|
|
2183
|
+
function clearCartSummary() {
|
|
2184
|
+
if (typeof window === "undefined") return;
|
|
2185
|
+
cartSummaryRevision(true);
|
|
2186
|
+
window.__behioCart = null;
|
|
2187
|
+
try {
|
|
2188
|
+
window.dispatchEvent(new CustomEvent("behio:cart", { detail: null }));
|
|
2189
|
+
} catch {
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2129
2192
|
function publishCartSummary(summary) {
|
|
2130
|
-
if (typeof window === "undefined"
|
|
2131
|
-
if (!Number.isFinite(summary.total) || !Number.isFinite(summary.itemCount))
|
|
2132
|
-
|
|
2193
|
+
if (typeof window === "undefined") return;
|
|
2194
|
+
if (!summary || !Number.isFinite(summary.total) || summary.total < 0 || !Number.isFinite(summary.itemCount) || summary.itemCount < 0) {
|
|
2195
|
+
clearCartSummary();
|
|
2196
|
+
return;
|
|
2197
|
+
}
|
|
2198
|
+
cartSummaryRevision(true);
|
|
2199
|
+
const detail = { total: summary.total, currency: typeof summary.currency === "string" ? summary.currency : null, itemCount: summary.itemCount };
|
|
2200
|
+
window.__behioCart = detail;
|
|
2133
2201
|
try {
|
|
2134
|
-
window.__behioCart = detail;
|
|
2135
2202
|
window.dispatchEvent(new CustomEvent("behio:cart", { detail }));
|
|
2136
2203
|
} catch {
|
|
2137
2204
|
}
|
|
@@ -2140,14 +2207,11 @@ function emitCartEvent(data) {
|
|
|
2140
2207
|
if (typeof window === "undefined") return;
|
|
2141
2208
|
const cart = data;
|
|
2142
2209
|
if (!cart || typeof cart !== "object" || !Array.isArray(cart.items)) return;
|
|
2143
|
-
if (cart.totalsAvailable === false)
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
currency: typeof cart.currency === "string" ? cart.currency : null,
|
|
2149
|
-
itemCount: items.reduce((n, i) => n + (typeof i?.quantity === "number" ? i.quantity : 1), 0)
|
|
2150
|
-
});
|
|
2210
|
+
if (cart.totalsAvailable === false || typeof cart.grandTotal !== "number" || typeof cart.itemCount !== "number") {
|
|
2211
|
+
clearCartSummary();
|
|
2212
|
+
return;
|
|
2213
|
+
}
|
|
2214
|
+
publishCartSummary({ total: cart.grandTotal, currency: typeof cart.currency === "string" ? cart.currency : null, itemCount: cart.itemCount });
|
|
2151
2215
|
}
|
|
2152
2216
|
|
|
2153
2217
|
export {
|
|
@@ -2162,5 +2226,6 @@ export {
|
|
|
2162
2226
|
err,
|
|
2163
2227
|
toSdkError,
|
|
2164
2228
|
BehioStorefront,
|
|
2229
|
+
clearCartSummary,
|
|
2165
2230
|
publishCartSummary
|
|
2166
2231
|
};
|
|
@@ -2896,6 +2896,10 @@ declare class BehioStorefront {
|
|
|
2896
2896
|
private cartSession?;
|
|
2897
2897
|
private requestContextVersion;
|
|
2898
2898
|
private authContextVersion;
|
|
2899
|
+
private cartSummarySequence;
|
|
2900
|
+
private cartSummaryWrites;
|
|
2901
|
+
private cartSummaryWriteVersion;
|
|
2902
|
+
private invalidateCartSummary;
|
|
2899
2903
|
/** @internal Opaque generation, never a token or customer identifier. */
|
|
2900
2904
|
getRequestContextVersion(): number;
|
|
2901
2905
|
/** @internal Refreshes must not restore a session that has been replaced. */
|
|
@@ -3834,13 +3838,9 @@ interface CartSummaryEvent {
|
|
|
3834
3838
|
currency: string | null;
|
|
3835
3839
|
itemCount: number;
|
|
3836
3840
|
}
|
|
3837
|
-
/**
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
* hodnoty kosiku, promenne {cartTotal}). SDK ji vola samo po kazde odpovedi
|
|
3841
|
-
* kosiku v prohlizeci. Sablona, ktera kosik meni na serveru (Server Actions,
|
|
3842
|
-
* vlastni route), ji zavola sama s aktualnim souhrnem. Na serveru nedela nic.
|
|
3843
|
-
*/
|
|
3841
|
+
/** Forget an unavailable or private cart. Null means unknown, never an empty cart. */
|
|
3842
|
+
declare function clearCartSummary(): void;
|
|
3843
|
+
/** Publish only authoritative current totals; server cart consumers call this after hydration and revalidation. */
|
|
3844
3844
|
declare function publishCartSummary(summary: CartSummaryEvent): void;
|
|
3845
3845
|
|
|
3846
|
-
export { type CourseCommentReply as $, type ActivePromotion as A, BehioStorefront as B, type CookieConsent as C, type Cart as D, type CartBundleLine as E, type CartBundleLineItem as F, type CartDiscount as G, type CartItem as H, type CartItemProduct as I, type CartLinkClaimed as J, type CartPromotion as K, type CartSummaryEvent as L, type Category as M, type CategoryDetail as N, type CertificateVerification as O, type ProductDetail as P, type CheckoutAddress as Q, type CheckoutInput as R, type SdkResult as S, type CheckoutPaymentMethod as T, type CheckoutPreview as U, type CheckoutResult as V, type CheckoutSettings as W, type CookieConsentInput as X, type CourseAttachment as Y, type CourseCertificate as Z, type CourseComment as _, type ProductVariant as a, type PaymentInstrument as a$, type CourseCommentsList as a0, type CourseDetail as a1, type CourseLesson as a2, type CourseListItem as a3, type CourseModule as a4, type CoursePostedComment as a5, type CourseProgress as a6, type CourseTutorMessage as a7, type CourseTutorThread as a8, type CrossSellItem as a9, type LoyaltyProgram as aA, type LoyaltySummary as aB, type LoyaltyTier as aC, type LoyaltyTierPerks as aD, type LoyaltyTransaction as aE, type Menu as aF, type MenuItem as aG, type MenuItemRef as aH, type MenuItemType as aI, type MessageResponse as aJ, type NewsletterOptInDefault as aK, type NewsletterSubscribeInput as aL, type NewsletterSubscribeResult as aM, type NewsletterUnsubscribeResult as aN, type OrderAccessRequestResponse as aO, type OrderAccessVerifyResponse as aP, type OrderDetail as aQ, type OrderItem as aR, type OrderListItem as aS, type OrderStatus as aT, type OrderStatusHistory as aU, OrderStatuses as aV, type OrderTracking as aW, type Page as aX, type PageAttachment as aY, type PageDetail as aZ, type PaginatedResponse as a_, type CurrencyDisplayFormat as aa, type CustomerAddress as ab, type CustomerProfile as ac, type DigitalDownload as ad, type DownloadUrl as ae, type Facet as af, type FacetAvailability as ag, type FacetCategory as ah, type FacetLabel as ai, type FacetPriceRange as aj, type FacetRange as ak, type FacetRatingBucket as al, type FacetValue as am, type FacetsResponse as an, type FilterField as ao, type FulfillmentStatus as ap, FulfillmentStatuses as aq, type GiftCardBalance as ar, type GiftCardPurchaseInput as as, type GiftCardPurchaseResult as at, type GiftCardSummary as au, type LessonNote as av, type LessonQuiz as aw, type LoginInput as ax, type LoyaltyBalance as ay, type LoyaltyNextTier as az, type StorefrontFormFieldError as b, type StockBehavior as b$, type PaymentStatus as b0, PaymentStatuses as b1, type PaymentSwift as b2, type PickupPoint as b3, type PickupPointHours as b4, type PickupPointsInput as b5, type PickupWidgetConfig as b6, type PriceDisplay as b7, type ProductAssetGroup as b8, type ProductAssetItem as b9, type RequestInterceptor as bA, type RequestInterceptorConfig as bB, type ResponseInterceptor as bC, type ResponseInterceptorData as bD, type ReturnRequest as bE, type ReturnRequestItem as bF, type ReturnStatus as bG, type ReturnStatusItem as bH, type ReturnableOrder as bI, type ReturnableOrderItem as bJ, type SdkError as bK, type ShippingMethodSummary as bL, type ShippingQuote as bM, type ShippingQuoteInput as bN, type ShopAppearance as bO, type ShopInfo as bP, type ShopScript as bQ, type ShopScriptPlacement as bR, type ShopScriptType as bS, type ShopScripts as bT, type ShopSeo as bU, type ShopSeoIdentity as bV, type SiteFormField as bW, type SiteFormFieldOption as bX, type SiteFormFieldType as bY, type Sitemap as bZ, type SitemapEntry as b_, type ProductAvailability as ba, type ProductGroup as bb, type ProductLabel as bc, type ProductListItem as bd, type ProductMedia as be, type ProductMediaVariant as bf, type ProductParameter as bg, type ProductParameterGroup as bh, type ProductParametersResponse as bi, type ProductPrice as bj, type ProductPromotionSummary as bk, type ProductReview as bl, type ProductReviewsResponse as bm, type ProductSibling as bn, ProductSort as bo, type ProductSortValue as bp, type ProductVolumePrice as bq, type ProductsQuery as br, type QuizAnswerInput as bs, type QuizAnswerResult as bt, type QuizQuestion as bu, type QuizResult as bv, type QuoteItem as bw, type QuoteRequest as bx, type RegisterInput as by, type RegisterResult as bz, type AddToCartInput as c, type StockMode as c0, type StorefrontForm as c1, type StorefrontFormFieldErrorCode as c2, type StorefrontFormFile as c3, type StorefrontFormSettings as c4, type StorefrontFormSubmitInput as c5, type StorefrontFormSubmitResult as c6, type StorefrontFormUpload as c7, type SubmitQuoteInput as c8, type SubmitReturnInput as c9, type SubmitReviewInput as ca, type Subscription as cb, type SubscriptionAction as cc, type SubscriptionFrequency as cd, type SubscriptionItem as ce, type SubscriptionStatus as cf, type TaxBreakdownLine as cg, type VariantAxis as ch, type VariantAxisValue as ci, type WishlistItem as cj,
|
|
3846
|
+
export { type CourseCommentReply as $, type ActivePromotion as A, BehioStorefront as B, type CookieConsent as C, type Cart as D, type CartBundleLine as E, type CartBundleLineItem as F, type CartDiscount as G, type CartItem as H, type CartItemProduct as I, type CartLinkClaimed as J, type CartPromotion as K, type CartSummaryEvent as L, type Category as M, type CategoryDetail as N, type CertificateVerification as O, type ProductDetail as P, type CheckoutAddress as Q, type CheckoutInput as R, type SdkResult as S, type CheckoutPaymentMethod as T, type CheckoutPreview as U, type CheckoutResult as V, type CheckoutSettings as W, type CookieConsentInput as X, type CourseAttachment as Y, type CourseCertificate as Z, type CourseComment as _, type ProductVariant as a, type PaymentInstrument as a$, type CourseCommentsList as a0, type CourseDetail as a1, type CourseLesson as a2, type CourseListItem as a3, type CourseModule as a4, type CoursePostedComment as a5, type CourseProgress as a6, type CourseTutorMessage as a7, type CourseTutorThread as a8, type CrossSellItem as a9, type LoyaltyProgram as aA, type LoyaltySummary as aB, type LoyaltyTier as aC, type LoyaltyTierPerks as aD, type LoyaltyTransaction as aE, type Menu as aF, type MenuItem as aG, type MenuItemRef as aH, type MenuItemType as aI, type MessageResponse as aJ, type NewsletterOptInDefault as aK, type NewsletterSubscribeInput as aL, type NewsletterSubscribeResult as aM, type NewsletterUnsubscribeResult as aN, type OrderAccessRequestResponse as aO, type OrderAccessVerifyResponse as aP, type OrderDetail as aQ, type OrderItem as aR, type OrderListItem as aS, type OrderStatus as aT, type OrderStatusHistory as aU, OrderStatuses as aV, type OrderTracking as aW, type Page as aX, type PageAttachment as aY, type PageDetail as aZ, type PaginatedResponse as a_, type CurrencyDisplayFormat as aa, type CustomerAddress as ab, type CustomerProfile as ac, type DigitalDownload as ad, type DownloadUrl as ae, type Facet as af, type FacetAvailability as ag, type FacetCategory as ah, type FacetLabel as ai, type FacetPriceRange as aj, type FacetRange as ak, type FacetRatingBucket as al, type FacetValue as am, type FacetsResponse as an, type FilterField as ao, type FulfillmentStatus as ap, FulfillmentStatuses as aq, type GiftCardBalance as ar, type GiftCardPurchaseInput as as, type GiftCardPurchaseResult as at, type GiftCardSummary as au, type LessonNote as av, type LessonQuiz as aw, type LoginInput as ax, type LoyaltyBalance as ay, type LoyaltyNextTier as az, type StorefrontFormFieldError as b, type StockBehavior as b$, type PaymentStatus as b0, PaymentStatuses as b1, type PaymentSwift as b2, type PickupPoint as b3, type PickupPointHours as b4, type PickupPointsInput as b5, type PickupWidgetConfig as b6, type PriceDisplay as b7, type ProductAssetGroup as b8, type ProductAssetItem as b9, type RequestInterceptor as bA, type RequestInterceptorConfig as bB, type ResponseInterceptor as bC, type ResponseInterceptorData as bD, type ReturnRequest as bE, type ReturnRequestItem as bF, type ReturnStatus as bG, type ReturnStatusItem as bH, type ReturnableOrder as bI, type ReturnableOrderItem as bJ, type SdkError as bK, type ShippingMethodSummary as bL, type ShippingQuote as bM, type ShippingQuoteInput as bN, type ShopAppearance as bO, type ShopInfo as bP, type ShopScript as bQ, type ShopScriptPlacement as bR, type ShopScriptType as bS, type ShopScripts as bT, type ShopSeo as bU, type ShopSeoIdentity as bV, type SiteFormField as bW, type SiteFormFieldOption as bX, type SiteFormFieldType as bY, type Sitemap as bZ, type SitemapEntry as b_, type ProductAvailability as ba, type ProductGroup as bb, type ProductLabel as bc, type ProductListItem as bd, type ProductMedia as be, type ProductMediaVariant as bf, type ProductParameter as bg, type ProductParameterGroup as bh, type ProductParametersResponse as bi, type ProductPrice as bj, type ProductPromotionSummary as bk, type ProductReview as bl, type ProductReviewsResponse as bm, type ProductSibling as bn, ProductSort as bo, type ProductSortValue as bp, type ProductVolumePrice as bq, type ProductsQuery as br, type QuizAnswerInput as bs, type QuizAnswerResult as bt, type QuizQuestion as bu, type QuizResult as bv, type QuoteItem as bw, type QuoteRequest as bx, type RegisterInput as by, type RegisterResult as bz, type AddToCartInput as c, type StockMode as c0, type StorefrontForm as c1, type StorefrontFormFieldErrorCode as c2, type StorefrontFormFile as c3, type StorefrontFormSettings as c4, type StorefrontFormSubmitInput as c5, type StorefrontFormSubmitResult as c6, type StorefrontFormUpload as c7, type SubmitQuoteInput as c8, type SubmitReturnInput as c9, type SubmitReviewInput as ca, type Subscription as cb, type SubscriptionAction as cc, type SubscriptionFrequency as cd, type SubscriptionItem as ce, type SubscriptionStatus as cf, type TaxBreakdownLine as cg, type VariantAxis as ch, type VariantAxisValue as ci, type WishlistItem as cj, clearCartSummary as ck, err as cl, ok as cm, publishCartSummary as cn, toSdkError as co, type AddressDetail as d, type AddressSuggestion as e, type AddressType as f, AddressTypes as g, type AuthTokens as h, type BackInStockSubscription as i, type BadgeTone as j, BehioApiError as k, type BehioErrorCode as l, type BehioEventHandler as m, type BehioEventType as n, BehioNetworkError as o, type BehioStorefrontConfig as p, type Blog as q, type BlogPostDetail as r, type BlogPostListItem as s, type BlogPostsPage as t, type BlogPostsQuery as u, type BlogSettings as v, type BlogTag as w, type Bundle as x, type BundleCatalogQuery as y, type BundleItem as z };
|
|
@@ -2896,6 +2896,10 @@ declare class BehioStorefront {
|
|
|
2896
2896
|
private cartSession?;
|
|
2897
2897
|
private requestContextVersion;
|
|
2898
2898
|
private authContextVersion;
|
|
2899
|
+
private cartSummarySequence;
|
|
2900
|
+
private cartSummaryWrites;
|
|
2901
|
+
private cartSummaryWriteVersion;
|
|
2902
|
+
private invalidateCartSummary;
|
|
2899
2903
|
/** @internal Opaque generation, never a token or customer identifier. */
|
|
2900
2904
|
getRequestContextVersion(): number;
|
|
2901
2905
|
/** @internal Refreshes must not restore a session that has been replaced. */
|
|
@@ -3834,13 +3838,9 @@ interface CartSummaryEvent {
|
|
|
3834
3838
|
currency: string | null;
|
|
3835
3839
|
itemCount: number;
|
|
3836
3840
|
}
|
|
3837
|
-
/**
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
* hodnoty kosiku, promenne {cartTotal}). SDK ji vola samo po kazde odpovedi
|
|
3841
|
-
* kosiku v prohlizeci. Sablona, ktera kosik meni na serveru (Server Actions,
|
|
3842
|
-
* vlastni route), ji zavola sama s aktualnim souhrnem. Na serveru nedela nic.
|
|
3843
|
-
*/
|
|
3841
|
+
/** Forget an unavailable or private cart. Null means unknown, never an empty cart. */
|
|
3842
|
+
declare function clearCartSummary(): void;
|
|
3843
|
+
/** Publish only authoritative current totals; server cart consumers call this after hydration and revalidation. */
|
|
3844
3844
|
declare function publishCartSummary(summary: CartSummaryEvent): void;
|
|
3845
3845
|
|
|
3846
|
-
export { type CourseCommentReply as $, type ActivePromotion as A, BehioStorefront as B, type CookieConsent as C, type Cart as D, type CartBundleLine as E, type CartBundleLineItem as F, type CartDiscount as G, type CartItem as H, type CartItemProduct as I, type CartLinkClaimed as J, type CartPromotion as K, type CartSummaryEvent as L, type Category as M, type CategoryDetail as N, type CertificateVerification as O, type ProductDetail as P, type CheckoutAddress as Q, type CheckoutInput as R, type SdkResult as S, type CheckoutPaymentMethod as T, type CheckoutPreview as U, type CheckoutResult as V, type CheckoutSettings as W, type CookieConsentInput as X, type CourseAttachment as Y, type CourseCertificate as Z, type CourseComment as _, type ProductVariant as a, type PaymentInstrument as a$, type CourseCommentsList as a0, type CourseDetail as a1, type CourseLesson as a2, type CourseListItem as a3, type CourseModule as a4, type CoursePostedComment as a5, type CourseProgress as a6, type CourseTutorMessage as a7, type CourseTutorThread as a8, type CrossSellItem as a9, type LoyaltyProgram as aA, type LoyaltySummary as aB, type LoyaltyTier as aC, type LoyaltyTierPerks as aD, type LoyaltyTransaction as aE, type Menu as aF, type MenuItem as aG, type MenuItemRef as aH, type MenuItemType as aI, type MessageResponse as aJ, type NewsletterOptInDefault as aK, type NewsletterSubscribeInput as aL, type NewsletterSubscribeResult as aM, type NewsletterUnsubscribeResult as aN, type OrderAccessRequestResponse as aO, type OrderAccessVerifyResponse as aP, type OrderDetail as aQ, type OrderItem as aR, type OrderListItem as aS, type OrderStatus as aT, type OrderStatusHistory as aU, OrderStatuses as aV, type OrderTracking as aW, type Page as aX, type PageAttachment as aY, type PageDetail as aZ, type PaginatedResponse as a_, type CurrencyDisplayFormat as aa, type CustomerAddress as ab, type CustomerProfile as ac, type DigitalDownload as ad, type DownloadUrl as ae, type Facet as af, type FacetAvailability as ag, type FacetCategory as ah, type FacetLabel as ai, type FacetPriceRange as aj, type FacetRange as ak, type FacetRatingBucket as al, type FacetValue as am, type FacetsResponse as an, type FilterField as ao, type FulfillmentStatus as ap, FulfillmentStatuses as aq, type GiftCardBalance as ar, type GiftCardPurchaseInput as as, type GiftCardPurchaseResult as at, type GiftCardSummary as au, type LessonNote as av, type LessonQuiz as aw, type LoginInput as ax, type LoyaltyBalance as ay, type LoyaltyNextTier as az, type StorefrontFormFieldError as b, type StockBehavior as b$, type PaymentStatus as b0, PaymentStatuses as b1, type PaymentSwift as b2, type PickupPoint as b3, type PickupPointHours as b4, type PickupPointsInput as b5, type PickupWidgetConfig as b6, type PriceDisplay as b7, type ProductAssetGroup as b8, type ProductAssetItem as b9, type RequestInterceptor as bA, type RequestInterceptorConfig as bB, type ResponseInterceptor as bC, type ResponseInterceptorData as bD, type ReturnRequest as bE, type ReturnRequestItem as bF, type ReturnStatus as bG, type ReturnStatusItem as bH, type ReturnableOrder as bI, type ReturnableOrderItem as bJ, type SdkError as bK, type ShippingMethodSummary as bL, type ShippingQuote as bM, type ShippingQuoteInput as bN, type ShopAppearance as bO, type ShopInfo as bP, type ShopScript as bQ, type ShopScriptPlacement as bR, type ShopScriptType as bS, type ShopScripts as bT, type ShopSeo as bU, type ShopSeoIdentity as bV, type SiteFormField as bW, type SiteFormFieldOption as bX, type SiteFormFieldType as bY, type Sitemap as bZ, type SitemapEntry as b_, type ProductAvailability as ba, type ProductGroup as bb, type ProductLabel as bc, type ProductListItem as bd, type ProductMedia as be, type ProductMediaVariant as bf, type ProductParameter as bg, type ProductParameterGroup as bh, type ProductParametersResponse as bi, type ProductPrice as bj, type ProductPromotionSummary as bk, type ProductReview as bl, type ProductReviewsResponse as bm, type ProductSibling as bn, ProductSort as bo, type ProductSortValue as bp, type ProductVolumePrice as bq, type ProductsQuery as br, type QuizAnswerInput as bs, type QuizAnswerResult as bt, type QuizQuestion as bu, type QuizResult as bv, type QuoteItem as bw, type QuoteRequest as bx, type RegisterInput as by, type RegisterResult as bz, type AddToCartInput as c, type StockMode as c0, type StorefrontForm as c1, type StorefrontFormFieldErrorCode as c2, type StorefrontFormFile as c3, type StorefrontFormSettings as c4, type StorefrontFormSubmitInput as c5, type StorefrontFormSubmitResult as c6, type StorefrontFormUpload as c7, type SubmitQuoteInput as c8, type SubmitReturnInput as c9, type SubmitReviewInput as ca, type Subscription as cb, type SubscriptionAction as cc, type SubscriptionFrequency as cd, type SubscriptionItem as ce, type SubscriptionStatus as cf, type TaxBreakdownLine as cg, type VariantAxis as ch, type VariantAxisValue as ci, type WishlistItem as cj,
|
|
3846
|
+
export { type CourseCommentReply as $, type ActivePromotion as A, BehioStorefront as B, type CookieConsent as C, type Cart as D, type CartBundleLine as E, type CartBundleLineItem as F, type CartDiscount as G, type CartItem as H, type CartItemProduct as I, type CartLinkClaimed as J, type CartPromotion as K, type CartSummaryEvent as L, type Category as M, type CategoryDetail as N, type CertificateVerification as O, type ProductDetail as P, type CheckoutAddress as Q, type CheckoutInput as R, type SdkResult as S, type CheckoutPaymentMethod as T, type CheckoutPreview as U, type CheckoutResult as V, type CheckoutSettings as W, type CookieConsentInput as X, type CourseAttachment as Y, type CourseCertificate as Z, type CourseComment as _, type ProductVariant as a, type PaymentInstrument as a$, type CourseCommentsList as a0, type CourseDetail as a1, type CourseLesson as a2, type CourseListItem as a3, type CourseModule as a4, type CoursePostedComment as a5, type CourseProgress as a6, type CourseTutorMessage as a7, type CourseTutorThread as a8, type CrossSellItem as a9, type LoyaltyProgram as aA, type LoyaltySummary as aB, type LoyaltyTier as aC, type LoyaltyTierPerks as aD, type LoyaltyTransaction as aE, type Menu as aF, type MenuItem as aG, type MenuItemRef as aH, type MenuItemType as aI, type MessageResponse as aJ, type NewsletterOptInDefault as aK, type NewsletterSubscribeInput as aL, type NewsletterSubscribeResult as aM, type NewsletterUnsubscribeResult as aN, type OrderAccessRequestResponse as aO, type OrderAccessVerifyResponse as aP, type OrderDetail as aQ, type OrderItem as aR, type OrderListItem as aS, type OrderStatus as aT, type OrderStatusHistory as aU, OrderStatuses as aV, type OrderTracking as aW, type Page as aX, type PageAttachment as aY, type PageDetail as aZ, type PaginatedResponse as a_, type CurrencyDisplayFormat as aa, type CustomerAddress as ab, type CustomerProfile as ac, type DigitalDownload as ad, type DownloadUrl as ae, type Facet as af, type FacetAvailability as ag, type FacetCategory as ah, type FacetLabel as ai, type FacetPriceRange as aj, type FacetRange as ak, type FacetRatingBucket as al, type FacetValue as am, type FacetsResponse as an, type FilterField as ao, type FulfillmentStatus as ap, FulfillmentStatuses as aq, type GiftCardBalance as ar, type GiftCardPurchaseInput as as, type GiftCardPurchaseResult as at, type GiftCardSummary as au, type LessonNote as av, type LessonQuiz as aw, type LoginInput as ax, type LoyaltyBalance as ay, type LoyaltyNextTier as az, type StorefrontFormFieldError as b, type StockBehavior as b$, type PaymentStatus as b0, PaymentStatuses as b1, type PaymentSwift as b2, type PickupPoint as b3, type PickupPointHours as b4, type PickupPointsInput as b5, type PickupWidgetConfig as b6, type PriceDisplay as b7, type ProductAssetGroup as b8, type ProductAssetItem as b9, type RequestInterceptor as bA, type RequestInterceptorConfig as bB, type ResponseInterceptor as bC, type ResponseInterceptorData as bD, type ReturnRequest as bE, type ReturnRequestItem as bF, type ReturnStatus as bG, type ReturnStatusItem as bH, type ReturnableOrder as bI, type ReturnableOrderItem as bJ, type SdkError as bK, type ShippingMethodSummary as bL, type ShippingQuote as bM, type ShippingQuoteInput as bN, type ShopAppearance as bO, type ShopInfo as bP, type ShopScript as bQ, type ShopScriptPlacement as bR, type ShopScriptType as bS, type ShopScripts as bT, type ShopSeo as bU, type ShopSeoIdentity as bV, type SiteFormField as bW, type SiteFormFieldOption as bX, type SiteFormFieldType as bY, type Sitemap as bZ, type SitemapEntry as b_, type ProductAvailability as ba, type ProductGroup as bb, type ProductLabel as bc, type ProductListItem as bd, type ProductMedia as be, type ProductMediaVariant as bf, type ProductParameter as bg, type ProductParameterGroup as bh, type ProductParametersResponse as bi, type ProductPrice as bj, type ProductPromotionSummary as bk, type ProductReview as bl, type ProductReviewsResponse as bm, type ProductSibling as bn, ProductSort as bo, type ProductSortValue as bp, type ProductVolumePrice as bq, type ProductsQuery as br, type QuizAnswerInput as bs, type QuizAnswerResult as bt, type QuizQuestion as bu, type QuizResult as bv, type QuoteItem as bw, type QuoteRequest as bx, type RegisterInput as by, type RegisterResult as bz, type AddToCartInput as c, type StockMode as c0, type StorefrontForm as c1, type StorefrontFormFieldErrorCode as c2, type StorefrontFormFile as c3, type StorefrontFormSettings as c4, type StorefrontFormSubmitInput as c5, type StorefrontFormSubmitResult as c6, type StorefrontFormUpload as c7, type SubmitQuoteInput as c8, type SubmitReturnInput as c9, type SubmitReviewInput as ca, type Subscription as cb, type SubscriptionAction as cc, type SubscriptionFrequency as cd, type SubscriptionItem as ce, type SubscriptionStatus as cf, type TaxBreakdownLine as cg, type VariantAxis as ch, type VariantAxisValue as ci, type WishlistItem as cj, clearCartSummary as ck, err as cl, ok as cm, publishCartSummary as cn, toSdkError as co, type AddressDetail as d, type AddressSuggestion as e, type AddressType as f, AddressTypes as g, type AuthTokens as h, type BackInStockSubscription as i, type BadgeTone as j, BehioApiError as k, type BehioErrorCode as l, type BehioEventHandler as m, type BehioEventType as n, BehioNetworkError as o, type BehioStorefrontConfig as p, type Blog as q, type BlogPostDetail as r, type BlogPostListItem as s, type BlogPostsPage as t, type BlogPostsQuery as u, type BlogSettings as v, type BlogTag as w, type Bundle as x, type BundleCatalogQuery as y, type BundleItem as z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as ProductDetail, a as ProductVariant, B as BehioStorefront, S as SdkResult, C as CookieConsent, b as StorefrontFormFieldError } from './client-
|
|
2
|
-
export { A as ActivePromotion, c as AddToCartInput, d as AddressDetail, e as AddressSuggestion, f as AddressType, g as AddressTypes, h as AuthTokens, i as BackInStockSubscription, j as BadgeTone, k as BehioApiError, l as BehioErrorCode, m as BehioEventHandler, n as BehioEventType, o as BehioNetworkError, p as BehioStorefrontConfig, q as Blog, r as BlogPostDetail, s as BlogPostListItem, t as BlogPostsPage, u as BlogPostsQuery, v as BlogSettings, w as BlogTag, x as Bundle, y as BundleCatalogQuery, z as BundleItem, D as Cart, E as CartBundleLine, F as CartBundleLineItem, G as CartDiscount, H as CartItem, I as CartItemProduct, J as CartLinkClaimed, K as CartPromotion, L as CartSummaryEvent, M as Category, N as CategoryDetail, O as CertificateVerification, Q as CheckoutAddress, R as CheckoutInput, T as CheckoutPaymentMethod, U as CheckoutPreview, V as CheckoutResult, W as CheckoutSettings, X as CookieConsentInput, Y as CourseAttachment, Z as CourseCertificate, _ as CourseComment, $ as CourseCommentReply, a0 as CourseCommentsList, a1 as CourseDetail, a2 as CourseLesson, a3 as CourseListItem, a4 as CourseModule, a5 as CoursePostedComment, a6 as CourseProgress, a7 as CourseTutorMessage, a8 as CourseTutorThread, a9 as CrossSellItem, aa as CurrencyDisplayFormat, ab as CustomerAddress, ac as CustomerProfile, ad as DigitalDownload, ae as DownloadUrl, af as Facet, ag as FacetAvailability, ah as FacetCategory, ai as FacetLabel, aj as FacetPriceRange, ak as FacetRange, al as FacetRatingBucket, am as FacetValue, an as FacetsResponse, ao as FilterField, ap as FulfillmentStatus, aq as FulfillmentStatuses, ar as GiftCardBalance, as as GiftCardPurchaseInput, at as GiftCardPurchaseResult, au as GiftCardSummary, av as LessonNote, aw as LessonQuiz, ax as LoginInput, ay as LoyaltyBalance, az as LoyaltyNextTier, aA as LoyaltyProgram, aB as LoyaltySummary, aC as LoyaltyTier, aD as LoyaltyTierPerks, aE as LoyaltyTransaction, aF as Menu, aG as MenuItem, aH as MenuItemRef, aI as MenuItemType, aJ as MessageResponse, aK as NewsletterOptInDefault, aL as NewsletterSubscribeInput, aM as NewsletterSubscribeResult, aN as NewsletterUnsubscribeResult, aO as OrderAccessRequestResponse, aP as OrderAccessVerifyResponse, aQ as OrderDetail, aR as OrderItem, aS as OrderListItem, aT as OrderStatus, aU as OrderStatusHistory, aV as OrderStatuses, aW as OrderTracking, aX as Page, aY as PageAttachment, aZ as PageDetail, a_ as PaginatedResponse, a$ as PaymentInstrument, b0 as PaymentStatus, b1 as PaymentStatuses, b2 as PaymentSwift, b3 as PickupPoint, b4 as PickupPointHours, b5 as PickupPointsInput, b6 as PickupWidgetConfig, b7 as PriceDisplay, b8 as ProductAssetGroup, b9 as ProductAssetItem, ba as ProductAvailability, bb as ProductGroup, bc as ProductLabel, bd as ProductListItem, be as ProductMedia, bf as ProductMediaVariant, bg as ProductParameter, bh as ProductParameterGroup, bi as ProductParametersResponse, bj as ProductPrice, bk as ProductPromotionSummary, bl as ProductReview, bm as ProductReviewsResponse, bn as ProductSibling, bo as ProductSort, bp as ProductSortValue, bq as ProductVolumePrice, br as ProductsQuery, bs as QuizAnswerInput, bt as QuizAnswerResult, bu as QuizQuestion, bv as QuizResult, bw as QuoteItem, bx as QuoteRequest, by as RegisterInput, bz as RegisterResult, bA as RequestInterceptor, bB as RequestInterceptorConfig, bC as ResponseInterceptor, bD as ResponseInterceptorData, bE as ReturnRequest, bF as ReturnRequestItem, bG as ReturnStatus, bH as ReturnStatusItem, bI as ReturnableOrder, bJ as ReturnableOrderItem, bK as SdkError, bL as ShippingMethodSummary, bM as ShippingQuote, bN as ShippingQuoteInput, bO as ShopAppearance, bP as ShopInfo, bQ as ShopScript, bR as ShopScriptPlacement, bS as ShopScriptType, bT as ShopScripts, bU as ShopSeo, bV as ShopSeoIdentity, bW as SiteFormField, bX as SiteFormFieldOption, bY as SiteFormFieldType, bZ as Sitemap, b_ as SitemapEntry, b$ as StockBehavior, c0 as StockMode, c1 as StorefrontForm, c2 as StorefrontFormFieldErrorCode, c3 as StorefrontFormFile, c4 as StorefrontFormSettings, c5 as StorefrontFormSubmitInput, c6 as StorefrontFormSubmitResult, c7 as StorefrontFormUpload, c8 as SubmitQuoteInput, c9 as SubmitReturnInput, ca as SubmitReviewInput, cb as Subscription, cc as SubscriptionAction, cd as SubscriptionFrequency, ce as SubscriptionItem, cf as SubscriptionStatus, cg as TaxBreakdownLine, ch as VariantAxis, ci as VariantAxisValue, cj as WishlistItem, ck as
|
|
1
|
+
import { P as ProductDetail, a as ProductVariant, B as BehioStorefront, S as SdkResult, C as CookieConsent, b as StorefrontFormFieldError } from './client-xoomjG8Z.mjs';
|
|
2
|
+
export { A as ActivePromotion, c as AddToCartInput, d as AddressDetail, e as AddressSuggestion, f as AddressType, g as AddressTypes, h as AuthTokens, i as BackInStockSubscription, j as BadgeTone, k as BehioApiError, l as BehioErrorCode, m as BehioEventHandler, n as BehioEventType, o as BehioNetworkError, p as BehioStorefrontConfig, q as Blog, r as BlogPostDetail, s as BlogPostListItem, t as BlogPostsPage, u as BlogPostsQuery, v as BlogSettings, w as BlogTag, x as Bundle, y as BundleCatalogQuery, z as BundleItem, D as Cart, E as CartBundleLine, F as CartBundleLineItem, G as CartDiscount, H as CartItem, I as CartItemProduct, J as CartLinkClaimed, K as CartPromotion, L as CartSummaryEvent, M as Category, N as CategoryDetail, O as CertificateVerification, Q as CheckoutAddress, R as CheckoutInput, T as CheckoutPaymentMethod, U as CheckoutPreview, V as CheckoutResult, W as CheckoutSettings, X as CookieConsentInput, Y as CourseAttachment, Z as CourseCertificate, _ as CourseComment, $ as CourseCommentReply, a0 as CourseCommentsList, a1 as CourseDetail, a2 as CourseLesson, a3 as CourseListItem, a4 as CourseModule, a5 as CoursePostedComment, a6 as CourseProgress, a7 as CourseTutorMessage, a8 as CourseTutorThread, a9 as CrossSellItem, aa as CurrencyDisplayFormat, ab as CustomerAddress, ac as CustomerProfile, ad as DigitalDownload, ae as DownloadUrl, af as Facet, ag as FacetAvailability, ah as FacetCategory, ai as FacetLabel, aj as FacetPriceRange, ak as FacetRange, al as FacetRatingBucket, am as FacetValue, an as FacetsResponse, ao as FilterField, ap as FulfillmentStatus, aq as FulfillmentStatuses, ar as GiftCardBalance, as as GiftCardPurchaseInput, at as GiftCardPurchaseResult, au as GiftCardSummary, av as LessonNote, aw as LessonQuiz, ax as LoginInput, ay as LoyaltyBalance, az as LoyaltyNextTier, aA as LoyaltyProgram, aB as LoyaltySummary, aC as LoyaltyTier, aD as LoyaltyTierPerks, aE as LoyaltyTransaction, aF as Menu, aG as MenuItem, aH as MenuItemRef, aI as MenuItemType, aJ as MessageResponse, aK as NewsletterOptInDefault, aL as NewsletterSubscribeInput, aM as NewsletterSubscribeResult, aN as NewsletterUnsubscribeResult, aO as OrderAccessRequestResponse, aP as OrderAccessVerifyResponse, aQ as OrderDetail, aR as OrderItem, aS as OrderListItem, aT as OrderStatus, aU as OrderStatusHistory, aV as OrderStatuses, aW as OrderTracking, aX as Page, aY as PageAttachment, aZ as PageDetail, a_ as PaginatedResponse, a$ as PaymentInstrument, b0 as PaymentStatus, b1 as PaymentStatuses, b2 as PaymentSwift, b3 as PickupPoint, b4 as PickupPointHours, b5 as PickupPointsInput, b6 as PickupWidgetConfig, b7 as PriceDisplay, b8 as ProductAssetGroup, b9 as ProductAssetItem, ba as ProductAvailability, bb as ProductGroup, bc as ProductLabel, bd as ProductListItem, be as ProductMedia, bf as ProductMediaVariant, bg as ProductParameter, bh as ProductParameterGroup, bi as ProductParametersResponse, bj as ProductPrice, bk as ProductPromotionSummary, bl as ProductReview, bm as ProductReviewsResponse, bn as ProductSibling, bo as ProductSort, bp as ProductSortValue, bq as ProductVolumePrice, br as ProductsQuery, bs as QuizAnswerInput, bt as QuizAnswerResult, bu as QuizQuestion, bv as QuizResult, bw as QuoteItem, bx as QuoteRequest, by as RegisterInput, bz as RegisterResult, bA as RequestInterceptor, bB as RequestInterceptorConfig, bC as ResponseInterceptor, bD as ResponseInterceptorData, bE as ReturnRequest, bF as ReturnRequestItem, bG as ReturnStatus, bH as ReturnStatusItem, bI as ReturnableOrder, bJ as ReturnableOrderItem, bK as SdkError, bL as ShippingMethodSummary, bM as ShippingQuote, bN as ShippingQuoteInput, bO as ShopAppearance, bP as ShopInfo, bQ as ShopScript, bR as ShopScriptPlacement, bS as ShopScriptType, bT as ShopScripts, bU as ShopSeo, bV as ShopSeoIdentity, bW as SiteFormField, bX as SiteFormFieldOption, bY as SiteFormFieldType, bZ as Sitemap, b_ as SitemapEntry, b$ as StockBehavior, c0 as StockMode, c1 as StorefrontForm, c2 as StorefrontFormFieldErrorCode, c3 as StorefrontFormFile, c4 as StorefrontFormSettings, c5 as StorefrontFormSubmitInput, c6 as StorefrontFormSubmitResult, c7 as StorefrontFormUpload, c8 as SubmitQuoteInput, c9 as SubmitReturnInput, ca as SubmitReviewInput, cb as Subscription, cc as SubscriptionAction, cd as SubscriptionFrequency, ce as SubscriptionItem, cf as SubscriptionStatus, cg as TaxBreakdownLine, ch as VariantAxis, ci as VariantAxisValue, cj as WishlistItem, ck as clearCartSummary, cl as err, cm as ok, cn as publishCartSummary, co as toSdkError } from './client-xoomjG8Z.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Format a price amount with currency using Intl.NumberFormat.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as ProductDetail, a as ProductVariant, B as BehioStorefront, S as SdkResult, C as CookieConsent, b as StorefrontFormFieldError } from './client-
|
|
2
|
-
export { A as ActivePromotion, c as AddToCartInput, d as AddressDetail, e as AddressSuggestion, f as AddressType, g as AddressTypes, h as AuthTokens, i as BackInStockSubscription, j as BadgeTone, k as BehioApiError, l as BehioErrorCode, m as BehioEventHandler, n as BehioEventType, o as BehioNetworkError, p as BehioStorefrontConfig, q as Blog, r as BlogPostDetail, s as BlogPostListItem, t as BlogPostsPage, u as BlogPostsQuery, v as BlogSettings, w as BlogTag, x as Bundle, y as BundleCatalogQuery, z as BundleItem, D as Cart, E as CartBundleLine, F as CartBundleLineItem, G as CartDiscount, H as CartItem, I as CartItemProduct, J as CartLinkClaimed, K as CartPromotion, L as CartSummaryEvent, M as Category, N as CategoryDetail, O as CertificateVerification, Q as CheckoutAddress, R as CheckoutInput, T as CheckoutPaymentMethod, U as CheckoutPreview, V as CheckoutResult, W as CheckoutSettings, X as CookieConsentInput, Y as CourseAttachment, Z as CourseCertificate, _ as CourseComment, $ as CourseCommentReply, a0 as CourseCommentsList, a1 as CourseDetail, a2 as CourseLesson, a3 as CourseListItem, a4 as CourseModule, a5 as CoursePostedComment, a6 as CourseProgress, a7 as CourseTutorMessage, a8 as CourseTutorThread, a9 as CrossSellItem, aa as CurrencyDisplayFormat, ab as CustomerAddress, ac as CustomerProfile, ad as DigitalDownload, ae as DownloadUrl, af as Facet, ag as FacetAvailability, ah as FacetCategory, ai as FacetLabel, aj as FacetPriceRange, ak as FacetRange, al as FacetRatingBucket, am as FacetValue, an as FacetsResponse, ao as FilterField, ap as FulfillmentStatus, aq as FulfillmentStatuses, ar as GiftCardBalance, as as GiftCardPurchaseInput, at as GiftCardPurchaseResult, au as GiftCardSummary, av as LessonNote, aw as LessonQuiz, ax as LoginInput, ay as LoyaltyBalance, az as LoyaltyNextTier, aA as LoyaltyProgram, aB as LoyaltySummary, aC as LoyaltyTier, aD as LoyaltyTierPerks, aE as LoyaltyTransaction, aF as Menu, aG as MenuItem, aH as MenuItemRef, aI as MenuItemType, aJ as MessageResponse, aK as NewsletterOptInDefault, aL as NewsletterSubscribeInput, aM as NewsletterSubscribeResult, aN as NewsletterUnsubscribeResult, aO as OrderAccessRequestResponse, aP as OrderAccessVerifyResponse, aQ as OrderDetail, aR as OrderItem, aS as OrderListItem, aT as OrderStatus, aU as OrderStatusHistory, aV as OrderStatuses, aW as OrderTracking, aX as Page, aY as PageAttachment, aZ as PageDetail, a_ as PaginatedResponse, a$ as PaymentInstrument, b0 as PaymentStatus, b1 as PaymentStatuses, b2 as PaymentSwift, b3 as PickupPoint, b4 as PickupPointHours, b5 as PickupPointsInput, b6 as PickupWidgetConfig, b7 as PriceDisplay, b8 as ProductAssetGroup, b9 as ProductAssetItem, ba as ProductAvailability, bb as ProductGroup, bc as ProductLabel, bd as ProductListItem, be as ProductMedia, bf as ProductMediaVariant, bg as ProductParameter, bh as ProductParameterGroup, bi as ProductParametersResponse, bj as ProductPrice, bk as ProductPromotionSummary, bl as ProductReview, bm as ProductReviewsResponse, bn as ProductSibling, bo as ProductSort, bp as ProductSortValue, bq as ProductVolumePrice, br as ProductsQuery, bs as QuizAnswerInput, bt as QuizAnswerResult, bu as QuizQuestion, bv as QuizResult, bw as QuoteItem, bx as QuoteRequest, by as RegisterInput, bz as RegisterResult, bA as RequestInterceptor, bB as RequestInterceptorConfig, bC as ResponseInterceptor, bD as ResponseInterceptorData, bE as ReturnRequest, bF as ReturnRequestItem, bG as ReturnStatus, bH as ReturnStatusItem, bI as ReturnableOrder, bJ as ReturnableOrderItem, bK as SdkError, bL as ShippingMethodSummary, bM as ShippingQuote, bN as ShippingQuoteInput, bO as ShopAppearance, bP as ShopInfo, bQ as ShopScript, bR as ShopScriptPlacement, bS as ShopScriptType, bT as ShopScripts, bU as ShopSeo, bV as ShopSeoIdentity, bW as SiteFormField, bX as SiteFormFieldOption, bY as SiteFormFieldType, bZ as Sitemap, b_ as SitemapEntry, b$ as StockBehavior, c0 as StockMode, c1 as StorefrontForm, c2 as StorefrontFormFieldErrorCode, c3 as StorefrontFormFile, c4 as StorefrontFormSettings, c5 as StorefrontFormSubmitInput, c6 as StorefrontFormSubmitResult, c7 as StorefrontFormUpload, c8 as SubmitQuoteInput, c9 as SubmitReturnInput, ca as SubmitReviewInput, cb as Subscription, cc as SubscriptionAction, cd as SubscriptionFrequency, ce as SubscriptionItem, cf as SubscriptionStatus, cg as TaxBreakdownLine, ch as VariantAxis, ci as VariantAxisValue, cj as WishlistItem, ck as
|
|
1
|
+
import { P as ProductDetail, a as ProductVariant, B as BehioStorefront, S as SdkResult, C as CookieConsent, b as StorefrontFormFieldError } from './client-xoomjG8Z.js';
|
|
2
|
+
export { A as ActivePromotion, c as AddToCartInput, d as AddressDetail, e as AddressSuggestion, f as AddressType, g as AddressTypes, h as AuthTokens, i as BackInStockSubscription, j as BadgeTone, k as BehioApiError, l as BehioErrorCode, m as BehioEventHandler, n as BehioEventType, o as BehioNetworkError, p as BehioStorefrontConfig, q as Blog, r as BlogPostDetail, s as BlogPostListItem, t as BlogPostsPage, u as BlogPostsQuery, v as BlogSettings, w as BlogTag, x as Bundle, y as BundleCatalogQuery, z as BundleItem, D as Cart, E as CartBundleLine, F as CartBundleLineItem, G as CartDiscount, H as CartItem, I as CartItemProduct, J as CartLinkClaimed, K as CartPromotion, L as CartSummaryEvent, M as Category, N as CategoryDetail, O as CertificateVerification, Q as CheckoutAddress, R as CheckoutInput, T as CheckoutPaymentMethod, U as CheckoutPreview, V as CheckoutResult, W as CheckoutSettings, X as CookieConsentInput, Y as CourseAttachment, Z as CourseCertificate, _ as CourseComment, $ as CourseCommentReply, a0 as CourseCommentsList, a1 as CourseDetail, a2 as CourseLesson, a3 as CourseListItem, a4 as CourseModule, a5 as CoursePostedComment, a6 as CourseProgress, a7 as CourseTutorMessage, a8 as CourseTutorThread, a9 as CrossSellItem, aa as CurrencyDisplayFormat, ab as CustomerAddress, ac as CustomerProfile, ad as DigitalDownload, ae as DownloadUrl, af as Facet, ag as FacetAvailability, ah as FacetCategory, ai as FacetLabel, aj as FacetPriceRange, ak as FacetRange, al as FacetRatingBucket, am as FacetValue, an as FacetsResponse, ao as FilterField, ap as FulfillmentStatus, aq as FulfillmentStatuses, ar as GiftCardBalance, as as GiftCardPurchaseInput, at as GiftCardPurchaseResult, au as GiftCardSummary, av as LessonNote, aw as LessonQuiz, ax as LoginInput, ay as LoyaltyBalance, az as LoyaltyNextTier, aA as LoyaltyProgram, aB as LoyaltySummary, aC as LoyaltyTier, aD as LoyaltyTierPerks, aE as LoyaltyTransaction, aF as Menu, aG as MenuItem, aH as MenuItemRef, aI as MenuItemType, aJ as MessageResponse, aK as NewsletterOptInDefault, aL as NewsletterSubscribeInput, aM as NewsletterSubscribeResult, aN as NewsletterUnsubscribeResult, aO as OrderAccessRequestResponse, aP as OrderAccessVerifyResponse, aQ as OrderDetail, aR as OrderItem, aS as OrderListItem, aT as OrderStatus, aU as OrderStatusHistory, aV as OrderStatuses, aW as OrderTracking, aX as Page, aY as PageAttachment, aZ as PageDetail, a_ as PaginatedResponse, a$ as PaymentInstrument, b0 as PaymentStatus, b1 as PaymentStatuses, b2 as PaymentSwift, b3 as PickupPoint, b4 as PickupPointHours, b5 as PickupPointsInput, b6 as PickupWidgetConfig, b7 as PriceDisplay, b8 as ProductAssetGroup, b9 as ProductAssetItem, ba as ProductAvailability, bb as ProductGroup, bc as ProductLabel, bd as ProductListItem, be as ProductMedia, bf as ProductMediaVariant, bg as ProductParameter, bh as ProductParameterGroup, bi as ProductParametersResponse, bj as ProductPrice, bk as ProductPromotionSummary, bl as ProductReview, bm as ProductReviewsResponse, bn as ProductSibling, bo as ProductSort, bp as ProductSortValue, bq as ProductVolumePrice, br as ProductsQuery, bs as QuizAnswerInput, bt as QuizAnswerResult, bu as QuizQuestion, bv as QuizResult, bw as QuoteItem, bx as QuoteRequest, by as RegisterInput, bz as RegisterResult, bA as RequestInterceptor, bB as RequestInterceptorConfig, bC as ResponseInterceptor, bD as ResponseInterceptorData, bE as ReturnRequest, bF as ReturnRequestItem, bG as ReturnStatus, bH as ReturnStatusItem, bI as ReturnableOrder, bJ as ReturnableOrderItem, bK as SdkError, bL as ShippingMethodSummary, bM as ShippingQuote, bN as ShippingQuoteInput, bO as ShopAppearance, bP as ShopInfo, bQ as ShopScript, bR as ShopScriptPlacement, bS as ShopScriptType, bT as ShopScripts, bU as ShopSeo, bV as ShopSeoIdentity, bW as SiteFormField, bX as SiteFormFieldOption, bY as SiteFormFieldType, bZ as Sitemap, b_ as SitemapEntry, b$ as StockBehavior, c0 as StockMode, c1 as StorefrontForm, c2 as StorefrontFormFieldErrorCode, c3 as StorefrontFormFile, c4 as StorefrontFormSettings, c5 as StorefrontFormSubmitInput, c6 as StorefrontFormSubmitResult, c7 as StorefrontFormUpload, c8 as SubmitQuoteInput, c9 as SubmitReturnInput, ca as SubmitReviewInput, cb as Subscription, cc as SubscriptionAction, cd as SubscriptionFrequency, ce as SubscriptionItem, cf as SubscriptionStatus, cg as TaxBreakdownLine, ch as VariantAxis, ci as VariantAxisValue, cj as WishlistItem, ck as clearCartSummary, cl as err, cm as ok, cn as publishCartSummary, co as toSdkError } from './client-xoomjG8Z.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Format a price amount with currency using Intl.NumberFormat.
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
var _chunkJCHJ2HW4js = require('./chunk-JCHJ2HW4.js');
|
|
15
16
|
|
|
16
17
|
// src/react/utils/format-price.ts
|
|
17
18
|
function formatPrice(amount, currency, locale, display) {
|
|
@@ -949,7 +950,7 @@ var GENERIC = {
|
|
|
949
950
|
en: "Something went wrong, please try again."
|
|
950
951
|
};
|
|
951
952
|
function bodyOf(err2) {
|
|
952
|
-
const body = err2 instanceof
|
|
953
|
+
const body = err2 instanceof _chunkJCHJ2HW4js.BehioApiError ? err2.body : err2 && typeof err2 === "object" && "body" in err2 ? err2.body : err2;
|
|
953
954
|
return body && typeof body === "object" ? body : null;
|
|
954
955
|
}
|
|
955
956
|
function errorCode(err2) {
|
|
@@ -1062,4 +1063,5 @@ function formFieldErrors(err2) {
|
|
|
1062
1063
|
|
|
1063
1064
|
|
|
1064
1065
|
|
|
1065
|
-
|
|
1066
|
+
|
|
1067
|
+
exports.AddressTypes = _chunkJCHJ2HW4js.AddressTypes; exports.BehioApiError = _chunkJCHJ2HW4js.BehioApiError; exports.BehioNetworkError = _chunkJCHJ2HW4js.BehioNetworkError; exports.BehioStorefront = _chunkJCHJ2HW4js.BehioStorefront; exports.FulfillmentStatuses = _chunkJCHJ2HW4js.FulfillmentStatuses; exports.OrderStatuses = _chunkJCHJ2HW4js.OrderStatuses; exports.PaymentStatuses = _chunkJCHJ2HW4js.PaymentStatuses; exports.ProductSort = _chunkJCHJ2HW4js.ProductSort; exports.VARIANT_QUERY_PARAM = VARIANT_QUERY_PARAM; exports.availableAxisValues = availableAxisValues; exports.buildVariantComparison = buildVariantComparison; exports.clearCartSummary = _chunkJCHJ2HW4js.clearCartSummary; exports.err = _chunkJCHJ2HW4js.err; exports.errorCode = errorCode; exports.errorMessage = errorMessage; exports.errorParams = errorParams; exports.findVariantByAttributes = findVariantByAttributes; exports.formFieldErrors = formFieldErrors; exports.formatPrice = formatPrice; exports.generateVisitorId = generateVisitorId; exports.getStoredVisitorId = getStoredVisitorId; exports.grantAnalyticsConsent = grantAnalyticsConsent; exports.ok = _chunkJCHJ2HW4js.ok; exports.publishCartSummary = _chunkJCHJ2HW4js.publishCartSummary; exports.resolveVariantContent = resolveVariantContent; exports.revokeAnalyticsConsent = revokeAnalyticsConsent; exports.toSdkError = _chunkJCHJ2HW4js.toSdkError; exports.trackEcommerceEvent = trackEcommerceEvent; exports.validationFieldMessages = validationFieldMessages; exports.variantFromQuery = variantFromQuery; exports.variantHref = variantHref;
|
package/dist/index.mjs
CHANGED
|
@@ -7,11 +7,12 @@ import {
|
|
|
7
7
|
OrderStatuses,
|
|
8
8
|
PaymentStatuses,
|
|
9
9
|
ProductSort,
|
|
10
|
+
clearCartSummary,
|
|
10
11
|
err,
|
|
11
12
|
ok,
|
|
12
13
|
publishCartSummary,
|
|
13
14
|
toSdkError
|
|
14
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-WQVG4HW7.mjs";
|
|
15
16
|
|
|
16
17
|
// src/react/utils/format-price.ts
|
|
17
18
|
function formatPrice(amount, currency, locale, display) {
|
|
@@ -1043,6 +1044,7 @@ export {
|
|
|
1043
1044
|
VARIANT_QUERY_PARAM,
|
|
1044
1045
|
availableAxisValues,
|
|
1045
1046
|
buildVariantComparison,
|
|
1047
|
+
clearCartSummary,
|
|
1046
1048
|
err,
|
|
1047
1049
|
errorCode,
|
|
1048
1050
|
errorMessage,
|
package/dist/next.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as BehioStorefrontConfig, B as BehioStorefront } from './client-
|
|
1
|
+
import { p as BehioStorefrontConfig, B as BehioStorefront } from './client-xoomjG8Z.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 { p as BehioStorefrontConfig, B as BehioStorefront } from './client-
|
|
1
|
+
import { p as BehioStorefrontConfig, B as BehioStorefront } from './client-xoomjG8Z.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 _chunkJCHJ2HW4js = require('./chunk-JCHJ2HW4.js');
|
|
4
4
|
|
|
5
5
|
// src/next.ts
|
|
6
6
|
var _headers = require('next/headers');
|
|
@@ -19,7 +19,7 @@ async function getBehio(options = {}) {
|
|
|
19
19
|
const locale = _nullishCoalesce(options.locale, () => ( process.env.BEHIO_LOCALE));
|
|
20
20
|
const currency = _nullishCoalesce(options.currency, () => ( process.env.BEHIO_CURRENCY));
|
|
21
21
|
const cookieName = _nullishCoalesce(options.cartCookieName, () => ( CART_COOKIE_NAME));
|
|
22
|
-
const client = new (0,
|
|
22
|
+
const client = new (0, _chunkJCHJ2HW4js.BehioStorefront)({
|
|
23
23
|
apiKey,
|
|
24
24
|
...baseUrl ? { baseUrl } : {},
|
|
25
25
|
...locale ? { locale } : {},
|
package/dist/next.mjs
CHANGED
package/dist/react.d.mts
CHANGED
|
@@ -2906,6 +2906,10 @@ declare class BehioStorefront {
|
|
|
2906
2906
|
private cartSession?;
|
|
2907
2907
|
private requestContextVersion;
|
|
2908
2908
|
private authContextVersion;
|
|
2909
|
+
private cartSummarySequence;
|
|
2910
|
+
private cartSummaryWrites;
|
|
2911
|
+
private cartSummaryWriteVersion;
|
|
2912
|
+
private invalidateCartSummary;
|
|
2909
2913
|
/** @internal Opaque generation, never a token or customer identifier. */
|
|
2910
2914
|
getRequestContextVersion(): number;
|
|
2911
2915
|
/** @internal Refreshes must not restore a session that has been replaced. */
|
package/dist/react.d.ts
CHANGED
|
@@ -2906,6 +2906,10 @@ declare class BehioStorefront {
|
|
|
2906
2906
|
private cartSession?;
|
|
2907
2907
|
private requestContextVersion;
|
|
2908
2908
|
private authContextVersion;
|
|
2909
|
+
private cartSummarySequence;
|
|
2910
|
+
private cartSummaryWrites;
|
|
2911
|
+
private cartSummaryWriteVersion;
|
|
2912
|
+
private invalidateCartSummary;
|
|
2909
2913
|
/** @internal Opaque generation, never a token or customer identifier. */
|
|
2910
2914
|
getRequestContextVersion(): number;
|
|
2911
2915
|
/** @internal Refreshes must not restore a session that has been replaced. */
|
package/dist/react.js
CHANGED
|
@@ -246,6 +246,9 @@ var BehioStorefront = class {
|
|
|
246
246
|
this.refreshPromise = null;
|
|
247
247
|
this.requestContextVersion = 0;
|
|
248
248
|
this.authContextVersion = 0;
|
|
249
|
+
this.cartSummarySequence = 0;
|
|
250
|
+
this.cartSummaryWrites = /* @__PURE__ */ new Set();
|
|
251
|
+
this.cartSummaryWriteVersion = 0;
|
|
249
252
|
// Event emitter
|
|
250
253
|
this.listeners = /* @__PURE__ */ new Map();
|
|
251
254
|
// Interceptors
|
|
@@ -289,6 +292,11 @@ var BehioStorefront = class {
|
|
|
289
292
|
this.subscriptions = new SubscriptionsModule(this);
|
|
290
293
|
this.certificates = new CourseCertificatesModule(this);
|
|
291
294
|
}
|
|
295
|
+
invalidateCartSummary() {
|
|
296
|
+
++this.cartSummarySequence;
|
|
297
|
+
this.cartSummaryWrites.clear();
|
|
298
|
+
clearCartSummary();
|
|
299
|
+
}
|
|
292
300
|
/** @internal Opaque generation, never a token or customer identifier. */
|
|
293
301
|
getRequestContextVersion() {
|
|
294
302
|
return this.requestContextVersion;
|
|
@@ -407,6 +415,7 @@ var BehioStorefront = class {
|
|
|
407
415
|
if (this.accessToken !== tokens.accessToken || this.refreshToken !== tokens.refreshToken) {
|
|
408
416
|
this.authContextVersion++;
|
|
409
417
|
this.requestContextVersion++;
|
|
418
|
+
this.invalidateCartSummary();
|
|
410
419
|
}
|
|
411
420
|
this.accessToken = tokens.accessToken;
|
|
412
421
|
this.refreshToken = tokens.refreshToken;
|
|
@@ -416,6 +425,7 @@ var BehioStorefront = class {
|
|
|
416
425
|
if (this.accessToken || this.refreshToken) {
|
|
417
426
|
this.authContextVersion++;
|
|
418
427
|
this.requestContextVersion++;
|
|
428
|
+
this.invalidateCartSummary();
|
|
419
429
|
}
|
|
420
430
|
this.accessToken = void 0;
|
|
421
431
|
this.refreshToken = void 0;
|
|
@@ -430,7 +440,10 @@ var BehioStorefront = class {
|
|
|
430
440
|
}
|
|
431
441
|
/** Set cart session token (e.g. from cookie) */
|
|
432
442
|
setCartSession(token) {
|
|
433
|
-
if (this.cartSession !== token)
|
|
443
|
+
if (this.cartSession !== token) {
|
|
444
|
+
this.requestContextVersion++;
|
|
445
|
+
this.invalidateCartSummary();
|
|
446
|
+
}
|
|
434
447
|
this.cartSession = token;
|
|
435
448
|
}
|
|
436
449
|
/** Get cart session token */
|
|
@@ -439,7 +452,10 @@ var BehioStorefront = class {
|
|
|
439
452
|
}
|
|
440
453
|
/** Clear cart session */
|
|
441
454
|
clearCartSession() {
|
|
442
|
-
if (this.cartSession)
|
|
455
|
+
if (this.cartSession) {
|
|
456
|
+
this.requestContextVersion++;
|
|
457
|
+
this.invalidateCartSummary();
|
|
458
|
+
}
|
|
443
459
|
this.cartSession = void 0;
|
|
444
460
|
}
|
|
445
461
|
// --- Default currency / locale (runtime-switchable) ---
|
|
@@ -450,7 +466,10 @@ var BehioStorefront = class {
|
|
|
450
466
|
* (falls back to the shop's default currency server-side).
|
|
451
467
|
*/
|
|
452
468
|
setCurrency(currency) {
|
|
453
|
-
if (this.defaultCurrency !== (currency || void 0))
|
|
469
|
+
if (this.defaultCurrency !== (currency || void 0)) {
|
|
470
|
+
this.requestContextVersion++;
|
|
471
|
+
this.invalidateCartSummary();
|
|
472
|
+
}
|
|
454
473
|
this.defaultCurrency = currency || void 0;
|
|
455
474
|
}
|
|
456
475
|
/** Get the current default currency, if any. */
|
|
@@ -461,7 +480,10 @@ var BehioStorefront = class {
|
|
|
461
480
|
setCountry(country) {
|
|
462
481
|
const normalized = country?.trim().toUpperCase();
|
|
463
482
|
const next = normalized && /^[A-Z]{2}$/.test(normalized) ? normalized : void 0;
|
|
464
|
-
if (this.defaultCountry !== next)
|
|
483
|
+
if (this.defaultCountry !== next) {
|
|
484
|
+
this.requestContextVersion++;
|
|
485
|
+
this.invalidateCartSummary();
|
|
486
|
+
}
|
|
465
487
|
this.defaultCountry = next;
|
|
466
488
|
}
|
|
467
489
|
getCountry() {
|
|
@@ -469,7 +491,10 @@ var BehioStorefront = class {
|
|
|
469
491
|
}
|
|
470
492
|
/** Set the default locale sent on every catalog request (per-call wins). */
|
|
471
493
|
setLocale(locale) {
|
|
472
|
-
if (this.defaultLocale !== (locale || void 0))
|
|
494
|
+
if (this.defaultLocale !== (locale || void 0)) {
|
|
495
|
+
this.requestContextVersion++;
|
|
496
|
+
this.invalidateCartSummary();
|
|
497
|
+
}
|
|
473
498
|
this.defaultLocale = locale || void 0;
|
|
474
499
|
}
|
|
475
500
|
/** Get the current default locale, if any. */
|
|
@@ -555,15 +580,36 @@ var BehioStorefront = class {
|
|
|
555
580
|
* methods (behio.catalog.*, behio.cart.*, …) instead.
|
|
556
581
|
*/
|
|
557
582
|
async request(method, path, options) {
|
|
583
|
+
const isCart = path === "/cart" || path.startsWith("/cart/");
|
|
584
|
+
const sequence = isCart ? ++this.cartSummarySequence : 0;
|
|
585
|
+
const contextVersion = this.requestContextVersion;
|
|
586
|
+
const writeVersion = this.cartSummaryWriteVersion;
|
|
587
|
+
const isWrite = isCart && method !== "GET" && method !== "HEAD";
|
|
588
|
+
if (isWrite) {
|
|
589
|
+
this.cartSummaryWrites.add(sequence);
|
|
590
|
+
clearCartSummary();
|
|
591
|
+
}
|
|
592
|
+
const pageRevision = cartSummaryRevision(isCart);
|
|
558
593
|
try {
|
|
559
594
|
const data = await this.rawRequest(method, path, options);
|
|
560
|
-
if (
|
|
595
|
+
if (isWrite) ++this.cartSummaryWriteVersion;
|
|
596
|
+
if (isCart && pageRevision === cartSummaryRevision() && sequence === this.cartSummarySequence && contextVersion === this.requestContextVersion && this.cartSummaryWrites.size === (isWrite ? 1 : 0) && (isWrite || writeVersion === this.cartSummaryWriteVersion)) {
|
|
597
|
+
const cart = data;
|
|
598
|
+
const token = cart && Array.isArray(cart.items) ? cart.newSessionToken || cart.sessionToken : void 0;
|
|
599
|
+
if (token) this.setCartSession(token);
|
|
600
|
+
if (path === "/cart" && method === "DELETE") {
|
|
601
|
+
publishCartSummary({ total: 0, currency: this.defaultCurrency ?? null, itemCount: 0 });
|
|
602
|
+
} else emitCartEvent(data);
|
|
603
|
+
}
|
|
561
604
|
return ok(data);
|
|
562
605
|
} catch (err) {
|
|
606
|
+
if (isCart && pageRevision === cartSummaryRevision() && sequence === this.cartSummarySequence && contextVersion === this.requestContextVersion) clearCartSummary();
|
|
563
607
|
if (this.throwOnAvailabilityError && isAvailabilityFailure(err)) {
|
|
564
608
|
throw err;
|
|
565
609
|
}
|
|
566
610
|
return { data: null, error: toSdkError(err) };
|
|
611
|
+
} finally {
|
|
612
|
+
if (isWrite) this.cartSummaryWrites.delete(sequence);
|
|
567
613
|
}
|
|
568
614
|
}
|
|
569
615
|
/**
|
|
@@ -2205,12 +2251,33 @@ var NewsletterModule = class {
|
|
|
2205
2251
|
);
|
|
2206
2252
|
}
|
|
2207
2253
|
};
|
|
2254
|
+
var summaryRevisionKey = /* @__PURE__ */ Symbol.for("behio.cart.summary.revision");
|
|
2255
|
+
function cartSummaryRevision(advance = false) {
|
|
2256
|
+
if (typeof window === "undefined") return 0;
|
|
2257
|
+
const page = window;
|
|
2258
|
+
const revision = (page[summaryRevisionKey] ?? 0) + (advance ? 1 : 0);
|
|
2259
|
+
if (advance) page[summaryRevisionKey] = revision;
|
|
2260
|
+
return revision;
|
|
2261
|
+
}
|
|
2262
|
+
function clearCartSummary() {
|
|
2263
|
+
if (typeof window === "undefined") return;
|
|
2264
|
+
cartSummaryRevision(true);
|
|
2265
|
+
window.__behioCart = null;
|
|
2266
|
+
try {
|
|
2267
|
+
window.dispatchEvent(new CustomEvent("behio:cart", { detail: null }));
|
|
2268
|
+
} catch {
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2208
2271
|
function publishCartSummary(summary) {
|
|
2209
|
-
if (typeof window === "undefined"
|
|
2210
|
-
if (!Number.isFinite(summary.total) || !Number.isFinite(summary.itemCount))
|
|
2211
|
-
|
|
2272
|
+
if (typeof window === "undefined") return;
|
|
2273
|
+
if (!summary || !Number.isFinite(summary.total) || summary.total < 0 || !Number.isFinite(summary.itemCount) || summary.itemCount < 0) {
|
|
2274
|
+
clearCartSummary();
|
|
2275
|
+
return;
|
|
2276
|
+
}
|
|
2277
|
+
cartSummaryRevision(true);
|
|
2278
|
+
const detail = { total: summary.total, currency: typeof summary.currency === "string" ? summary.currency : null, itemCount: summary.itemCount };
|
|
2279
|
+
window.__behioCart = detail;
|
|
2212
2280
|
try {
|
|
2213
|
-
window.__behioCart = detail;
|
|
2214
2281
|
window.dispatchEvent(new CustomEvent("behio:cart", { detail }));
|
|
2215
2282
|
} catch {
|
|
2216
2283
|
}
|
|
@@ -2219,14 +2286,11 @@ function emitCartEvent(data) {
|
|
|
2219
2286
|
if (typeof window === "undefined") return;
|
|
2220
2287
|
const cart = data;
|
|
2221
2288
|
if (!cart || typeof cart !== "object" || !Array.isArray(cart.items)) return;
|
|
2222
|
-
if (cart.totalsAvailable === false)
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
currency: typeof cart.currency === "string" ? cart.currency : null,
|
|
2228
|
-
itemCount: items.reduce((n, i) => n + (typeof i?.quantity === "number" ? i.quantity : 1), 0)
|
|
2229
|
-
});
|
|
2289
|
+
if (cart.totalsAvailable === false || typeof cart.grandTotal !== "number" || typeof cart.itemCount !== "number") {
|
|
2290
|
+
clearCartSummary();
|
|
2291
|
+
return;
|
|
2292
|
+
}
|
|
2293
|
+
publishCartSummary({ total: cart.grandTotal, currency: typeof cart.currency === "string" ? cart.currency : null, itemCount: cart.itemCount });
|
|
2230
2294
|
}
|
|
2231
2295
|
|
|
2232
2296
|
// src/react/context.ts
|
package/dist/react.mjs
CHANGED
|
@@ -136,6 +136,9 @@ var BehioStorefront = class {
|
|
|
136
136
|
this.refreshPromise = null;
|
|
137
137
|
this.requestContextVersion = 0;
|
|
138
138
|
this.authContextVersion = 0;
|
|
139
|
+
this.cartSummarySequence = 0;
|
|
140
|
+
this.cartSummaryWrites = /* @__PURE__ */ new Set();
|
|
141
|
+
this.cartSummaryWriteVersion = 0;
|
|
139
142
|
// Event emitter
|
|
140
143
|
this.listeners = /* @__PURE__ */ new Map();
|
|
141
144
|
// Interceptors
|
|
@@ -179,6 +182,11 @@ var BehioStorefront = class {
|
|
|
179
182
|
this.subscriptions = new SubscriptionsModule(this);
|
|
180
183
|
this.certificates = new CourseCertificatesModule(this);
|
|
181
184
|
}
|
|
185
|
+
invalidateCartSummary() {
|
|
186
|
+
++this.cartSummarySequence;
|
|
187
|
+
this.cartSummaryWrites.clear();
|
|
188
|
+
clearCartSummary();
|
|
189
|
+
}
|
|
182
190
|
/** @internal Opaque generation, never a token or customer identifier. */
|
|
183
191
|
getRequestContextVersion() {
|
|
184
192
|
return this.requestContextVersion;
|
|
@@ -297,6 +305,7 @@ var BehioStorefront = class {
|
|
|
297
305
|
if (this.accessToken !== tokens.accessToken || this.refreshToken !== tokens.refreshToken) {
|
|
298
306
|
this.authContextVersion++;
|
|
299
307
|
this.requestContextVersion++;
|
|
308
|
+
this.invalidateCartSummary();
|
|
300
309
|
}
|
|
301
310
|
this.accessToken = tokens.accessToken;
|
|
302
311
|
this.refreshToken = tokens.refreshToken;
|
|
@@ -306,6 +315,7 @@ var BehioStorefront = class {
|
|
|
306
315
|
if (this.accessToken || this.refreshToken) {
|
|
307
316
|
this.authContextVersion++;
|
|
308
317
|
this.requestContextVersion++;
|
|
318
|
+
this.invalidateCartSummary();
|
|
309
319
|
}
|
|
310
320
|
this.accessToken = void 0;
|
|
311
321
|
this.refreshToken = void 0;
|
|
@@ -320,7 +330,10 @@ var BehioStorefront = class {
|
|
|
320
330
|
}
|
|
321
331
|
/** Set cart session token (e.g. from cookie) */
|
|
322
332
|
setCartSession(token) {
|
|
323
|
-
if (this.cartSession !== token)
|
|
333
|
+
if (this.cartSession !== token) {
|
|
334
|
+
this.requestContextVersion++;
|
|
335
|
+
this.invalidateCartSummary();
|
|
336
|
+
}
|
|
324
337
|
this.cartSession = token;
|
|
325
338
|
}
|
|
326
339
|
/** Get cart session token */
|
|
@@ -329,7 +342,10 @@ var BehioStorefront = class {
|
|
|
329
342
|
}
|
|
330
343
|
/** Clear cart session */
|
|
331
344
|
clearCartSession() {
|
|
332
|
-
if (this.cartSession)
|
|
345
|
+
if (this.cartSession) {
|
|
346
|
+
this.requestContextVersion++;
|
|
347
|
+
this.invalidateCartSummary();
|
|
348
|
+
}
|
|
333
349
|
this.cartSession = void 0;
|
|
334
350
|
}
|
|
335
351
|
// --- Default currency / locale (runtime-switchable) ---
|
|
@@ -340,7 +356,10 @@ var BehioStorefront = class {
|
|
|
340
356
|
* (falls back to the shop's default currency server-side).
|
|
341
357
|
*/
|
|
342
358
|
setCurrency(currency) {
|
|
343
|
-
if (this.defaultCurrency !== (currency || void 0))
|
|
359
|
+
if (this.defaultCurrency !== (currency || void 0)) {
|
|
360
|
+
this.requestContextVersion++;
|
|
361
|
+
this.invalidateCartSummary();
|
|
362
|
+
}
|
|
344
363
|
this.defaultCurrency = currency || void 0;
|
|
345
364
|
}
|
|
346
365
|
/** Get the current default currency, if any. */
|
|
@@ -351,7 +370,10 @@ var BehioStorefront = class {
|
|
|
351
370
|
setCountry(country) {
|
|
352
371
|
const normalized = country?.trim().toUpperCase();
|
|
353
372
|
const next = normalized && /^[A-Z]{2}$/.test(normalized) ? normalized : void 0;
|
|
354
|
-
if (this.defaultCountry !== next)
|
|
373
|
+
if (this.defaultCountry !== next) {
|
|
374
|
+
this.requestContextVersion++;
|
|
375
|
+
this.invalidateCartSummary();
|
|
376
|
+
}
|
|
355
377
|
this.defaultCountry = next;
|
|
356
378
|
}
|
|
357
379
|
getCountry() {
|
|
@@ -359,7 +381,10 @@ var BehioStorefront = class {
|
|
|
359
381
|
}
|
|
360
382
|
/** Set the default locale sent on every catalog request (per-call wins). */
|
|
361
383
|
setLocale(locale) {
|
|
362
|
-
if (this.defaultLocale !== (locale || void 0))
|
|
384
|
+
if (this.defaultLocale !== (locale || void 0)) {
|
|
385
|
+
this.requestContextVersion++;
|
|
386
|
+
this.invalidateCartSummary();
|
|
387
|
+
}
|
|
363
388
|
this.defaultLocale = locale || void 0;
|
|
364
389
|
}
|
|
365
390
|
/** Get the current default locale, if any. */
|
|
@@ -445,15 +470,36 @@ var BehioStorefront = class {
|
|
|
445
470
|
* methods (behio.catalog.*, behio.cart.*, …) instead.
|
|
446
471
|
*/
|
|
447
472
|
async request(method, path, options) {
|
|
473
|
+
const isCart = path === "/cart" || path.startsWith("/cart/");
|
|
474
|
+
const sequence = isCart ? ++this.cartSummarySequence : 0;
|
|
475
|
+
const contextVersion = this.requestContextVersion;
|
|
476
|
+
const writeVersion = this.cartSummaryWriteVersion;
|
|
477
|
+
const isWrite = isCart && method !== "GET" && method !== "HEAD";
|
|
478
|
+
if (isWrite) {
|
|
479
|
+
this.cartSummaryWrites.add(sequence);
|
|
480
|
+
clearCartSummary();
|
|
481
|
+
}
|
|
482
|
+
const pageRevision = cartSummaryRevision(isCart);
|
|
448
483
|
try {
|
|
449
484
|
const data = await this.rawRequest(method, path, options);
|
|
450
|
-
if (
|
|
485
|
+
if (isWrite) ++this.cartSummaryWriteVersion;
|
|
486
|
+
if (isCart && pageRevision === cartSummaryRevision() && sequence === this.cartSummarySequence && contextVersion === this.requestContextVersion && this.cartSummaryWrites.size === (isWrite ? 1 : 0) && (isWrite || writeVersion === this.cartSummaryWriteVersion)) {
|
|
487
|
+
const cart = data;
|
|
488
|
+
const token = cart && Array.isArray(cart.items) ? cart.newSessionToken || cart.sessionToken : void 0;
|
|
489
|
+
if (token) this.setCartSession(token);
|
|
490
|
+
if (path === "/cart" && method === "DELETE") {
|
|
491
|
+
publishCartSummary({ total: 0, currency: this.defaultCurrency ?? null, itemCount: 0 });
|
|
492
|
+
} else emitCartEvent(data);
|
|
493
|
+
}
|
|
451
494
|
return ok(data);
|
|
452
495
|
} catch (err) {
|
|
496
|
+
if (isCart && pageRevision === cartSummaryRevision() && sequence === this.cartSummarySequence && contextVersion === this.requestContextVersion) clearCartSummary();
|
|
453
497
|
if (this.throwOnAvailabilityError && isAvailabilityFailure(err)) {
|
|
454
498
|
throw err;
|
|
455
499
|
}
|
|
456
500
|
return { data: null, error: toSdkError(err) };
|
|
501
|
+
} finally {
|
|
502
|
+
if (isWrite) this.cartSummaryWrites.delete(sequence);
|
|
457
503
|
}
|
|
458
504
|
}
|
|
459
505
|
/**
|
|
@@ -2095,12 +2141,33 @@ var NewsletterModule = class {
|
|
|
2095
2141
|
);
|
|
2096
2142
|
}
|
|
2097
2143
|
};
|
|
2144
|
+
var summaryRevisionKey = /* @__PURE__ */ Symbol.for("behio.cart.summary.revision");
|
|
2145
|
+
function cartSummaryRevision(advance = false) {
|
|
2146
|
+
if (typeof window === "undefined") return 0;
|
|
2147
|
+
const page = window;
|
|
2148
|
+
const revision = (page[summaryRevisionKey] ?? 0) + (advance ? 1 : 0);
|
|
2149
|
+
if (advance) page[summaryRevisionKey] = revision;
|
|
2150
|
+
return revision;
|
|
2151
|
+
}
|
|
2152
|
+
function clearCartSummary() {
|
|
2153
|
+
if (typeof window === "undefined") return;
|
|
2154
|
+
cartSummaryRevision(true);
|
|
2155
|
+
window.__behioCart = null;
|
|
2156
|
+
try {
|
|
2157
|
+
window.dispatchEvent(new CustomEvent("behio:cart", { detail: null }));
|
|
2158
|
+
} catch {
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2098
2161
|
function publishCartSummary(summary) {
|
|
2099
|
-
if (typeof window === "undefined"
|
|
2100
|
-
if (!Number.isFinite(summary.total) || !Number.isFinite(summary.itemCount))
|
|
2101
|
-
|
|
2162
|
+
if (typeof window === "undefined") return;
|
|
2163
|
+
if (!summary || !Number.isFinite(summary.total) || summary.total < 0 || !Number.isFinite(summary.itemCount) || summary.itemCount < 0) {
|
|
2164
|
+
clearCartSummary();
|
|
2165
|
+
return;
|
|
2166
|
+
}
|
|
2167
|
+
cartSummaryRevision(true);
|
|
2168
|
+
const detail = { total: summary.total, currency: typeof summary.currency === "string" ? summary.currency : null, itemCount: summary.itemCount };
|
|
2169
|
+
window.__behioCart = detail;
|
|
2102
2170
|
try {
|
|
2103
|
-
window.__behioCart = detail;
|
|
2104
2171
|
window.dispatchEvent(new CustomEvent("behio:cart", { detail }));
|
|
2105
2172
|
} catch {
|
|
2106
2173
|
}
|
|
@@ -2109,14 +2176,11 @@ function emitCartEvent(data) {
|
|
|
2109
2176
|
if (typeof window === "undefined") return;
|
|
2110
2177
|
const cart = data;
|
|
2111
2178
|
if (!cart || typeof cart !== "object" || !Array.isArray(cart.items)) return;
|
|
2112
|
-
if (cart.totalsAvailable === false)
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
currency: typeof cart.currency === "string" ? cart.currency : null,
|
|
2118
|
-
itemCount: items.reduce((n, i) => n + (typeof i?.quantity === "number" ? i.quantity : 1), 0)
|
|
2119
|
-
});
|
|
2179
|
+
if (cart.totalsAvailable === false || typeof cart.grandTotal !== "number" || typeof cart.itemCount !== "number") {
|
|
2180
|
+
clearCartSummary();
|
|
2181
|
+
return;
|
|
2182
|
+
}
|
|
2183
|
+
publishCartSummary({ total: cart.grandTotal, currency: typeof cart.currency === "string" ? cart.currency : null, itemCount: cart.itemCount });
|
|
2120
2184
|
}
|
|
2121
2185
|
|
|
2122
2186
|
// src/react/context.ts
|