@behio/storefront-sdk 0.32.0 → 0.34.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@behio/storefront-sdk",
3
- "version": "0.32.0",
3
+ "version": "0.34.0",
4
4
  "description": "TypeScript SDK for Behio Headless E-Shop — core client + React hooks",
5
5
  "author": "Behio",
6
6
  "license": "MIT",
@@ -1,40 +0,0 @@
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; }// src/react/utils/format-price.ts
2
- function formatPrice(amount, currency, locale) {
3
- const resolvedLocale = _nullishCoalesce(locale, () => ( "cs"));
4
- try {
5
- return new Intl.NumberFormat(resolvedLocale, {
6
- style: "currency",
7
- currency,
8
- minimumFractionDigits: Number.isInteger(amount) ? 0 : 2,
9
- maximumFractionDigits: 2
10
- }).format(amount);
11
- } catch (e) {
12
- return `${amount} ${currency}`;
13
- }
14
- }
15
-
16
- // src/analytics.ts
17
- function trackEcommerceEvent(event, payload) {
18
- if (typeof window === "undefined") return;
19
- const w = window;
20
- try {
21
- _optionalChain([w, 'access', _ => _.__behioEcommerceSink, 'optionalCall', _2 => _2(event, payload)]);
22
- } catch (e2) {
23
- }
24
- try {
25
- if (typeof w.gtag === "function") {
26
- w.gtag("event", event, payload);
27
- return;
28
- }
29
- if (Array.isArray(w.dataLayer)) {
30
- w.dataLayer.push({ ecommerce: null });
31
- w.dataLayer.push({ event, ecommerce: payload });
32
- }
33
- } catch (e3) {
34
- }
35
- }
36
-
37
-
38
-
39
-
40
- exports.formatPrice = formatPrice; exports.trackEcommerceEvent = trackEcommerceEvent;
@@ -1,40 +0,0 @@
1
- // src/react/utils/format-price.ts
2
- function formatPrice(amount, currency, locale) {
3
- const resolvedLocale = locale ?? "cs";
4
- try {
5
- return new Intl.NumberFormat(resolvedLocale, {
6
- style: "currency",
7
- currency,
8
- minimumFractionDigits: Number.isInteger(amount) ? 0 : 2,
9
- maximumFractionDigits: 2
10
- }).format(amount);
11
- } catch {
12
- return `${amount} ${currency}`;
13
- }
14
- }
15
-
16
- // src/analytics.ts
17
- function trackEcommerceEvent(event, payload) {
18
- if (typeof window === "undefined") return;
19
- const w = window;
20
- try {
21
- w.__behioEcommerceSink?.(event, payload);
22
- } catch {
23
- }
24
- try {
25
- if (typeof w.gtag === "function") {
26
- w.gtag("event", event, payload);
27
- return;
28
- }
29
- if (Array.isArray(w.dataLayer)) {
30
- w.dataLayer.push({ ecommerce: null });
31
- w.dataLayer.push({ event, ecommerce: payload });
32
- }
33
- } catch {
34
- }
35
- }
36
-
37
- export {
38
- formatPrice,
39
- trackEcommerceEvent
40
- };