@numueg/theme-sdk 0.10.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -3,8 +3,8 @@ export { A as Address, a as CartItem, O as Order, d as OrderItem, f as ProductIm
3
3
  import { T as ThemeSettingsV3, c as SectionInstance, M as MountResult, B as BlockInstance, b as BlockSchema, a as BlockProps$1, f as SectionSchema, e as SectionProps$1 } from './theme-CNTB4KnU.mjs';
4
4
  export { E as ExternalThemeMetadata, h as MAX_BLOCK_DEPTH, P as PageTemplate, i as PresetBlock, S as SectionGroup, d as SectionPreset, g as SettingDefinition } from './theme-CNTB4KnU.mjs';
5
5
  export { KNOWN_SETTING_TYPES, KNOWN_TEMPLATES, REQUIRED_TEMPLATES, SDK_VERSION, THEME_CONTRACT_VERSION, ValidationIssue, ValidationResult, mergeResults, validateBuiltManifest, validateManifest, validateSectionSchema, validateSettingsAgainstSchema } from './validation.mjs';
6
- import { C as CartContextValue, L as LocalizationState, a as CurrencyState, T as ThemeMountContext, b as ThemeRenderArgs, M as MenuItemData } from './mount-eAhGgGtZ.mjs';
7
- export { c as CartContext, d as CartMutationResult, e as CollectionContext, f as CurrencyConfig, g as CurrencyContext, h as CustomerContext, i as LocalizationContext, N as NavigationContext, P as PageContext, j as ProductContext, S as ShopContext, k as ThemeMountPage, l as ThemeSettingsContext, m as buildThemeElement, n as mountTheme } from './mount-eAhGgGtZ.mjs';
6
+ import { C as CartContextValue, L as LocalizationState, a as CurrencyState, T as ThemeMountContext, b as ThemeRenderArgs, M as MenuItemData } from './mount-BDo4a42I.mjs';
7
+ export { c as CartContext, d as CartMutationResult, e as CollectionContext, f as CurrencyConfig, g as CurrencyContext, h as CustomerContext, i as LocalizationContext, N as NavigationContext, P as PageContext, j as ProductContext, S as ShopContext, k as ThemeMountPage, l as ThemeSettingsContext, m as buildThemeElement, n as mountTheme } from './mount-BDo4a42I.mjs';
8
8
  import * as react from 'react';
9
9
  import { ReactElement, ReactNode, ElementType, CSSProperties, ImgHTMLAttributes, AnchorHTMLAttributes, ButtonHTMLAttributes, HTMLAttributes, FormHTMLAttributes, ComponentType } from 'react';
10
10
  export { resolveThemeSettings } from './normalize.mjs';
package/dist/index.d.ts CHANGED
@@ -3,8 +3,8 @@ export { A as Address, a as CartItem, O as Order, d as OrderItem, f as ProductIm
3
3
  import { T as ThemeSettingsV3, c as SectionInstance, M as MountResult, B as BlockInstance, b as BlockSchema, a as BlockProps$1, f as SectionSchema, e as SectionProps$1 } from './theme-CNTB4KnU.js';
4
4
  export { E as ExternalThemeMetadata, h as MAX_BLOCK_DEPTH, P as PageTemplate, i as PresetBlock, S as SectionGroup, d as SectionPreset, g as SettingDefinition } from './theme-CNTB4KnU.js';
5
5
  export { KNOWN_SETTING_TYPES, KNOWN_TEMPLATES, REQUIRED_TEMPLATES, SDK_VERSION, THEME_CONTRACT_VERSION, ValidationIssue, ValidationResult, mergeResults, validateBuiltManifest, validateManifest, validateSectionSchema, validateSettingsAgainstSchema } from './validation.js';
6
- import { C as CartContextValue, L as LocalizationState, a as CurrencyState, T as ThemeMountContext, b as ThemeRenderArgs, M as MenuItemData } from './mount-HbnOAYZ-.js';
7
- export { c as CartContext, d as CartMutationResult, e as CollectionContext, f as CurrencyConfig, g as CurrencyContext, h as CustomerContext, i as LocalizationContext, N as NavigationContext, P as PageContext, j as ProductContext, S as ShopContext, k as ThemeMountPage, l as ThemeSettingsContext, m as buildThemeElement, n as mountTheme } from './mount-HbnOAYZ-.js';
6
+ import { C as CartContextValue, L as LocalizationState, a as CurrencyState, T as ThemeMountContext, b as ThemeRenderArgs, M as MenuItemData } from './mount-DQZu8aBB.js';
7
+ export { c as CartContext, d as CartMutationResult, e as CollectionContext, f as CurrencyConfig, g as CurrencyContext, h as CustomerContext, i as LocalizationContext, N as NavigationContext, P as PageContext, j as ProductContext, S as ShopContext, k as ThemeMountPage, l as ThemeSettingsContext, m as buildThemeElement, n as mountTheme } from './mount-DQZu8aBB.js';
8
8
  import * as react from 'react';
9
9
  import { ReactElement, ReactNode, ElementType, CSSProperties, ImgHTMLAttributes, AnchorHTMLAttributes, ButtonHTMLAttributes, HTMLAttributes, FormHTMLAttributes, ComponentType } from 'react';
10
10
  export { resolveThemeSettings } from './normalize.js';
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  export { resolveThemeSettings } from './chunk-XF2FGIVS.mjs';
2
- export { KNOWN_SETTING_TYPES, KNOWN_TEMPLATES, REQUIRED_TEMPLATES, SDK_VERSION, THEME_CONTRACT_VERSION, mergeResults, validateBuiltManifest, validateManifest, validateSectionSchema, validateSettingsAgainstSchema } from './chunk-EB2ESBLD.mjs';
3
- import { ShopContext, ThemeSettingsContext, CurrentTemplateContext, PageContext, LocalizationContext, CurrencyContext, CartContext, CustomerContext, NavigationContext, CollectionContext, ProductContext, useShop, useLocalization, useCustomer, useThemeSettings } from './chunk-4TMO5Y5W.mjs';
4
- export { CartContext, CollectionContext, CurrencyContext, CustomerContext, LocalizationContext, NavigationContext, PageContext, ProductContext, ShopContext, ThemeSettingsContext, useCollections, useCustomer, useDirection, useFieldTranslation, useLocale, useLocalization, useNumberFormat, usePage, useProducts, useShop, useThemeSettings, useTranslation } from './chunk-4TMO5Y5W.mjs';
2
+ export { KNOWN_SETTING_TYPES, KNOWN_TEMPLATES, REQUIRED_TEMPLATES, SDK_VERSION, THEME_CONTRACT_VERSION, mergeResults, validateBuiltManifest, validateManifest, validateSectionSchema, validateSettingsAgainstSchema } from './chunk-QFFTHIFZ.mjs';
3
+ import { ShopContext, ThemeSettingsContext, CurrentTemplateContext, PageContext, LocalizationContext, CurrencyContext, CartContext, CustomerContext, NavigationContext, CollectionContext, ProductContext, useShop, useLocalization, useCustomer, useThemeSettings } from './chunk-ZYZZG4JR.mjs';
4
+ export { CartContext, CollectionContext, CurrencyContext, CustomerContext, LocalizationContext, NavigationContext, PageContext, ProductContext, ShopContext, ThemeSettingsContext, useCollections, useCustomer, useDirection, useFieldTranslation, useLocale, useLocalization, useNumberFormat, usePage, useProducts, useShop, useThemeSettings, useTranslation } from './chunk-ZYZZG4JR.mjs';
5
5
  import { createContext, forwardRef, useState, useImperativeHandle, useEffect, useCallback, useMemo, useRef, useContext, useSyncExternalStore, StrictMode, createElement, Component } from 'react';
6
6
  import { hydrateRoot, createRoot } from 'react-dom/client';
7
7
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
@@ -588,10 +588,11 @@ function getFingerprint() {
588
588
  }
589
589
  function dispatchAnalyticsEvent(eventName, payload = {}) {
590
590
  if (typeof window === "undefined") return;
591
+ const eventId = crypto.randomUUID();
591
592
  try {
592
593
  window.dispatchEvent(
593
594
  new CustomEvent("numu:analytics:event", {
594
- detail: { event: eventName, payload, ts: Date.now() }
595
+ detail: { event: eventName, payload, event_id: eventId, ts: Date.now() }
595
596
  })
596
597
  );
597
598
  } catch {
@@ -599,7 +600,7 @@ function dispatchAnalyticsEvent(eventName, payload = {}) {
599
600
  const step = EVENT_TO_FUNNEL_STEP[eventName] ?? null;
600
601
  const customerId = readCustomerId();
601
602
  const body = step ? {
602
- event_id: crypto.randomUUID(),
603
+ event_id: eventId,
603
604
  path: window.location.pathname,
604
605
  fingerprint: getFingerprint(),
605
606
  step,
@@ -610,6 +611,7 @@ function dispatchAnalyticsEvent(eventName, payload = {}) {
610
611
  } : {
611
612
  event: eventName,
612
613
  payload,
614
+ event_id: eventId,
613
615
  ts: Date.now(),
614
616
  attribution: readAttribution() ?? void 0,
615
617
  customer_id: customerId ?? void 0
@@ -1492,8 +1494,9 @@ async function postCartMutation(endpoint, body, applyCart, reserveToken) {
1492
1494
  return { ok: false, status: res.status, message };
1493
1495
  }
1494
1496
  const json = await res.json();
1495
- applyCart(unwrapCart(json));
1496
- return { ok: true, status: res.status };
1497
+ const applied = unwrapCart(json);
1498
+ applyCart(applied);
1499
+ return { ok: true, status: res.status, cart: normalizeCartFromServer(applied) };
1497
1500
  }
1498
1501
  function NuMuProvider({
1499
1502
  store,
@@ -1741,6 +1744,10 @@ function NuMuProvider({
1741
1744
  if (!result.ok) return result;
1742
1745
  try {
1743
1746
  if (typeof window !== "undefined") {
1747
+ const line = result.cart?.items.find(
1748
+ (it) => variantId ? it.variant_id === variantId : it.product_id === productId
1749
+ );
1750
+ const value = line && typeof line.price === "number" && line.price > 0 ? Math.round(line.price * qty * 100) / 100 : void 0;
1744
1751
  window.dispatchEvent(
1745
1752
  new CustomEvent("numu:analytics:event", {
1746
1753
  detail: {
@@ -1748,7 +1755,8 @@ function NuMuProvider({
1748
1755
  payload: {
1749
1756
  content_ids: [productId],
1750
1757
  content_type: "product",
1751
- num_items: qty
1758
+ num_items: qty,
1759
+ ...value !== void 0 ? { value, currency: result.cart?.currency } : {}
1752
1760
  },
1753
1761
  event_id: eventId
1754
1762
  }