@numueg/theme-sdk 0.4.0 → 0.5.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
@@ -1286,6 +1286,29 @@ interface ImageProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, "src" | "
1286
1286
  */
1287
1287
  declare function Image({ src, alt, sizes, responsive, loading, aspectRatio, objectFit, objectPosition, transform, className, style, ...rest }: ImageProps): react.JSX.Element;
1288
1288
 
1289
+ interface LogoProps {
1290
+ /** Explicit logo URL; falls back to global_settings.logo_url then shop.logo_url. */
1291
+ src?: string | null;
1292
+ /** Alt text; falls back to the brand name / shop name. */
1293
+ alt?: string;
1294
+ /** Overrides `global_settings.logo_shape` (none/square/rounded/circle/triangle). */
1295
+ shape?: string;
1296
+ /** Overrides `global_settings.logo_size` (small/medium/large). */
1297
+ size?: string;
1298
+ className?: string;
1299
+ style?: CSSProperties;
1300
+ /** Rendered when there is no logo URL (e.g. brand-name text). */
1301
+ fallback?: ReactNode;
1302
+ }
1303
+ /**
1304
+ * Engine-level store logo. Reads `logo_url`, `logo_shape`, and `logo_size` from
1305
+ * the theme's global settings (overridable via props), and renders a plain
1306
+ * `<img>` with the chosen shape/size applied via inline styles — so it works in
1307
+ * any theme regardless of its CSS setup and keeps **animated GIF logos playing**
1308
+ * under every shape. Renders `fallback` (or nothing) when no logo is set.
1309
+ */
1310
+ declare function Logo({ src, alt, shape, size, className, style, fallback, }: LogoProps): react.JSX.Element;
1311
+
1289
1312
  interface LinkProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "href"> {
1290
1313
  /**
1291
1314
  * Path relative to the storefront root, e.g. "/products/foo",
@@ -2051,6 +2074,76 @@ declare function computeGlobalStyleTokens(globalSettings: GlobalSettings): Compu
2051
2074
  */
2052
2075
  declare function applyGlobalStyleTokens(globalSettings: GlobalSettings, el: HTMLElement | null | undefined): void;
2053
2076
 
2077
+ /**
2078
+ * Engine-level logo appearance (shape + size).
2079
+ *
2080
+ * A merchant can crop the store logo into a shape and pick its size from the
2081
+ * theme editor's global settings (`logo_shape` / `logo_size`). The logic lives
2082
+ * here — once, in the SDK — so EVERY V3 theme renders the chosen shape the same
2083
+ * way instead of each theme re-implementing it.
2084
+ *
2085
+ * Why inline styles (not Tailwind classes): the SDK is consumed from
2086
+ * `node_modules`, which a theme's Tailwind build does not scan — so utility
2087
+ * classes like `rounded-full` / `h-16` would never be generated. Inline
2088
+ * `CSSProperties` are self-contained and work in any theme regardless of its
2089
+ * CSS setup. The shapes are pure CSS (border-radius / clip-path) applied to a
2090
+ * plain `<img>`, so animated **GIF logos keep playing** under every shape.
2091
+ */
2092
+
2093
+ type LogoShape = "none" | "square" | "rounded" | "circle" | "triangle";
2094
+ type LogoSize = "small" | "medium" | "large";
2095
+ /** Bilingual options for the `logo_shape` global setting (schema authoring). */
2096
+ declare const LOGO_SHAPE_OPTIONS: readonly [{
2097
+ readonly value: "none";
2098
+ readonly label: "Original";
2099
+ readonly label_ar: "الأصلي";
2100
+ }, {
2101
+ readonly value: "square";
2102
+ readonly label: "Square";
2103
+ readonly label_ar: "مربع";
2104
+ }, {
2105
+ readonly value: "rounded";
2106
+ readonly label: "Rounded square";
2107
+ readonly label_ar: "مربع بزوايا دائرية";
2108
+ }, {
2109
+ readonly value: "circle";
2110
+ readonly label: "Circle";
2111
+ readonly label_ar: "دائرة";
2112
+ }, {
2113
+ readonly value: "triangle";
2114
+ readonly label: "Triangle";
2115
+ readonly label_ar: "مثلث";
2116
+ }];
2117
+ /** Bilingual options for the `logo_size` global setting (schema authoring). */
2118
+ declare const LOGO_SIZE_OPTIONS: readonly [{
2119
+ readonly value: "small";
2120
+ readonly label: "Small";
2121
+ readonly label_ar: "صغير";
2122
+ }, {
2123
+ readonly value: "medium";
2124
+ readonly label: "Medium";
2125
+ readonly label_ar: "متوسط";
2126
+ }, {
2127
+ readonly value: "large";
2128
+ readonly label: "Large";
2129
+ readonly label_ar: "كبير";
2130
+ }];
2131
+ /**
2132
+ * Inline style for a logo `<img>` given the merchant's shape + size.
2133
+ *
2134
+ * Returns `undefined` for `none` (and unknown shapes) so the theme keeps its
2135
+ * own native logo sizing untouched — only an explicitly chosen shape overrides
2136
+ * it. A shaped logo gets a fixed square box with `object-fit: cover` plus the
2137
+ * shape (border-radius for square/rounded/circle, clip-path for triangle).
2138
+ */
2139
+ declare function logoImgStyle(shape: string | undefined, size: string | undefined): CSSProperties | undefined;
2140
+ /**
2141
+ * Derived CSS-custom-property tokens for the chosen logo shape/size. Emitted by
2142
+ * `computeGlobalStyleTokens` so host-rendered surfaces (e.g. the checkout
2143
+ * header) can match the storefront logo. Returns `{}` for `none`.
2144
+ */
2145
+ declare function logoStyleTokens(shape: string | undefined, size: string | undefined): Record<string, string>;
2146
+
2054
2147
  /**
2055
2148
  * Theme-bundled locale files: load + merge.
2056
2149
  *
@@ -2109,4 +2202,4 @@ declare function pickTranslations(bundle: LocaleBundle, locale: string): LocaleM
2109
2202
  */
2110
2203
  declare function buildLocaleBundle<T extends Record<string, unknown>>(modules: T): LocaleBundle;
2111
2204
 
2112
- export { AddToCartButton, type AddressInput, type AnalyticsApi, type AnalyticsPayload, type AppManifestBlock, type AppPayload, type AppState, Block, BlockInstance, BlockProps$1 as BlockProps, BlockSchema, Cart, type CheckoutAddress, type CheckoutApi, type CheckoutSessionState, type CheckoutStep, Collection, CollectionCard, type CollectionCardProps, type CollectionCardSlots, CollectionProvider, type ComputedStyleTokens, type CurrencyConfig, type CurrencyState, CurrencySwitcher, type CurrencySwitcherProps, Customer, type CustomerAddress, type CustomerAddressesState, type DefineBlockInput, type DefineSectionInput, type DefinedBlock, type DefinedSection, type DynamicResolveContext, type DynamicSourceRef, EditableImage, type EditableImageProps, EditableText, type EditableTextProps, type FocalSrcOptions, Form, type GiftCardBalance, ICON_NAMES, Icon, IconMap, type IconProps, Image, type ImageTransform, Link, type LocaleBundle, type LocaleMessages, LocaleSwitcher, type LocaleSwitcherProps, MenuItemData, Money, MountResult, type NavigationItem, type NavigationState, NuMuProvider, type OrderDetail, type OrderListEntry, type OrderListState, type OrderState, Page, type PlaceOrderResult, Product, ProductCard, type ProductCardProps, type ProductCardSlots, ProductProvider, ProductVariant, type RelatedProductsState, type ReorderResult, type ReorderSkipReason, type ReorderSkippedItem, RichText, type RichTextProps, type SearchResults, type SearchState, Section, SectionContext, SectionInstance, SectionProps$1 as SectionProps, SectionSchema, type ShippingRateOption, type ShopWithHelpers, SizeChart, Store, type ThemeEntry, ThemeMountContext, ThemeRenderArgs, ThemeSettingsV3, type UseGiftCardBalance, type UseReorder, type UseSearchOptions, type UseShippingRatesOptions, type UseShippingRatesState, type UseVariantSelection, type WishlistItem, type WishlistState, applyGlobalStyleTokens, applyImageTransform, asImageTransform, assetUrl, availableValues, buildLocaleBundle, clearSdkSingleton, collectBlocks, collectSections, computeGlobalStyleTokens, defaultVariant, defineBlock, defineSection, defineThemeEntry, dynamicSource, findVariantByOptions, flattenMessages, focalSrc, getReactSingleton, getSdkSingleton, isDefinedBlock, isDefinedSection, isDynamicSource, isSdkAvailable, pickTranslations, registerReactSingleton, registerSdkSingleton, resolveDynamicValue, resolveFontStack, resolveSettingsMap, resolveSizeChart, resolveSourcePath, sanitizeHtml, useAnalytics, useApp, useCart, useCheckout, useCollection, useCollectionOptional, useCollections, useCurrency, useCurrentTemplate, useCustomer, useCustomerActions, useCustomerAddresses, useDirection, useFieldTranslation, useGiftCardBalance, useImage, useLocale, useLocalization, useMoney, useNavigation, useNumberFormat, useOrder, useOrders, usePage, useProduct, useProductOptional, useProductSizeChart, useProducts, useRelatedProducts, useReorder, useResolvedSettings, useSearch, useSection, useSectionOptional, useShippingRates, useShop, useThemeSettings, useTranslation, useVariantSelection, useWishlist };
2205
+ export { AddToCartButton, type AddressInput, type AnalyticsApi, type AnalyticsPayload, type AppManifestBlock, type AppPayload, type AppState, Block, BlockInstance, BlockProps$1 as BlockProps, BlockSchema, Cart, type CheckoutAddress, type CheckoutApi, type CheckoutSessionState, type CheckoutStep, Collection, CollectionCard, type CollectionCardProps, type CollectionCardSlots, CollectionProvider, type ComputedStyleTokens, type CurrencyConfig, type CurrencyState, CurrencySwitcher, type CurrencySwitcherProps, Customer, type CustomerAddress, type CustomerAddressesState, type DefineBlockInput, type DefineSectionInput, type DefinedBlock, type DefinedSection, type DynamicResolveContext, type DynamicSourceRef, EditableImage, type EditableImageProps, EditableText, type EditableTextProps, type FocalSrcOptions, Form, type GiftCardBalance, ICON_NAMES, Icon, IconMap, type IconProps, Image, type ImageTransform, LOGO_SHAPE_OPTIONS, LOGO_SIZE_OPTIONS, Link, type LocaleBundle, type LocaleMessages, LocaleSwitcher, type LocaleSwitcherProps, Logo, type LogoProps, type LogoShape, type LogoSize, MenuItemData, Money, MountResult, type NavigationItem, type NavigationState, NuMuProvider, type OrderDetail, type OrderListEntry, type OrderListState, type OrderState, Page, type PlaceOrderResult, Product, ProductCard, type ProductCardProps, type ProductCardSlots, ProductProvider, ProductVariant, type RelatedProductsState, type ReorderResult, type ReorderSkipReason, type ReorderSkippedItem, RichText, type RichTextProps, type SearchResults, type SearchState, Section, SectionContext, SectionInstance, SectionProps$1 as SectionProps, SectionSchema, type ShippingRateOption, type ShopWithHelpers, SizeChart, Store, type ThemeEntry, ThemeMountContext, ThemeRenderArgs, ThemeSettingsV3, type UseGiftCardBalance, type UseReorder, type UseSearchOptions, type UseShippingRatesOptions, type UseShippingRatesState, type UseVariantSelection, type WishlistItem, type WishlistState, applyGlobalStyleTokens, applyImageTransform, asImageTransform, assetUrl, availableValues, buildLocaleBundle, clearSdkSingleton, collectBlocks, collectSections, computeGlobalStyleTokens, defaultVariant, defineBlock, defineSection, defineThemeEntry, dynamicSource, findVariantByOptions, flattenMessages, focalSrc, getReactSingleton, getSdkSingleton, isDefinedBlock, isDefinedSection, isDynamicSource, isSdkAvailable, logoImgStyle, logoStyleTokens, pickTranslations, registerReactSingleton, registerSdkSingleton, resolveDynamicValue, resolveFontStack, resolveSettingsMap, resolveSizeChart, resolveSourcePath, sanitizeHtml, useAnalytics, useApp, useCart, useCheckout, useCollection, useCollectionOptional, useCollections, useCurrency, useCurrentTemplate, useCustomer, useCustomerActions, useCustomerAddresses, useDirection, useFieldTranslation, useGiftCardBalance, useImage, useLocale, useLocalization, useMoney, useNavigation, useNumberFormat, useOrder, useOrders, usePage, useProduct, useProductOptional, useProductSizeChart, useProducts, useRelatedProducts, useReorder, useResolvedSettings, useSearch, useSection, useSectionOptional, useShippingRates, useShop, useThemeSettings, useTranslation, useVariantSelection, useWishlist };
package/dist/index.d.ts CHANGED
@@ -1286,6 +1286,29 @@ interface ImageProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, "src" | "
1286
1286
  */
1287
1287
  declare function Image({ src, alt, sizes, responsive, loading, aspectRatio, objectFit, objectPosition, transform, className, style, ...rest }: ImageProps): react.JSX.Element;
1288
1288
 
1289
+ interface LogoProps {
1290
+ /** Explicit logo URL; falls back to global_settings.logo_url then shop.logo_url. */
1291
+ src?: string | null;
1292
+ /** Alt text; falls back to the brand name / shop name. */
1293
+ alt?: string;
1294
+ /** Overrides `global_settings.logo_shape` (none/square/rounded/circle/triangle). */
1295
+ shape?: string;
1296
+ /** Overrides `global_settings.logo_size` (small/medium/large). */
1297
+ size?: string;
1298
+ className?: string;
1299
+ style?: CSSProperties;
1300
+ /** Rendered when there is no logo URL (e.g. brand-name text). */
1301
+ fallback?: ReactNode;
1302
+ }
1303
+ /**
1304
+ * Engine-level store logo. Reads `logo_url`, `logo_shape`, and `logo_size` from
1305
+ * the theme's global settings (overridable via props), and renders a plain
1306
+ * `<img>` with the chosen shape/size applied via inline styles — so it works in
1307
+ * any theme regardless of its CSS setup and keeps **animated GIF logos playing**
1308
+ * under every shape. Renders `fallback` (or nothing) when no logo is set.
1309
+ */
1310
+ declare function Logo({ src, alt, shape, size, className, style, fallback, }: LogoProps): react.JSX.Element;
1311
+
1289
1312
  interface LinkProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "href"> {
1290
1313
  /**
1291
1314
  * Path relative to the storefront root, e.g. "/products/foo",
@@ -2051,6 +2074,76 @@ declare function computeGlobalStyleTokens(globalSettings: GlobalSettings): Compu
2051
2074
  */
2052
2075
  declare function applyGlobalStyleTokens(globalSettings: GlobalSettings, el: HTMLElement | null | undefined): void;
2053
2076
 
2077
+ /**
2078
+ * Engine-level logo appearance (shape + size).
2079
+ *
2080
+ * A merchant can crop the store logo into a shape and pick its size from the
2081
+ * theme editor's global settings (`logo_shape` / `logo_size`). The logic lives
2082
+ * here — once, in the SDK — so EVERY V3 theme renders the chosen shape the same
2083
+ * way instead of each theme re-implementing it.
2084
+ *
2085
+ * Why inline styles (not Tailwind classes): the SDK is consumed from
2086
+ * `node_modules`, which a theme's Tailwind build does not scan — so utility
2087
+ * classes like `rounded-full` / `h-16` would never be generated. Inline
2088
+ * `CSSProperties` are self-contained and work in any theme regardless of its
2089
+ * CSS setup. The shapes are pure CSS (border-radius / clip-path) applied to a
2090
+ * plain `<img>`, so animated **GIF logos keep playing** under every shape.
2091
+ */
2092
+
2093
+ type LogoShape = "none" | "square" | "rounded" | "circle" | "triangle";
2094
+ type LogoSize = "small" | "medium" | "large";
2095
+ /** Bilingual options for the `logo_shape` global setting (schema authoring). */
2096
+ declare const LOGO_SHAPE_OPTIONS: readonly [{
2097
+ readonly value: "none";
2098
+ readonly label: "Original";
2099
+ readonly label_ar: "الأصلي";
2100
+ }, {
2101
+ readonly value: "square";
2102
+ readonly label: "Square";
2103
+ readonly label_ar: "مربع";
2104
+ }, {
2105
+ readonly value: "rounded";
2106
+ readonly label: "Rounded square";
2107
+ readonly label_ar: "مربع بزوايا دائرية";
2108
+ }, {
2109
+ readonly value: "circle";
2110
+ readonly label: "Circle";
2111
+ readonly label_ar: "دائرة";
2112
+ }, {
2113
+ readonly value: "triangle";
2114
+ readonly label: "Triangle";
2115
+ readonly label_ar: "مثلث";
2116
+ }];
2117
+ /** Bilingual options for the `logo_size` global setting (schema authoring). */
2118
+ declare const LOGO_SIZE_OPTIONS: readonly [{
2119
+ readonly value: "small";
2120
+ readonly label: "Small";
2121
+ readonly label_ar: "صغير";
2122
+ }, {
2123
+ readonly value: "medium";
2124
+ readonly label: "Medium";
2125
+ readonly label_ar: "متوسط";
2126
+ }, {
2127
+ readonly value: "large";
2128
+ readonly label: "Large";
2129
+ readonly label_ar: "كبير";
2130
+ }];
2131
+ /**
2132
+ * Inline style for a logo `<img>` given the merchant's shape + size.
2133
+ *
2134
+ * Returns `undefined` for `none` (and unknown shapes) so the theme keeps its
2135
+ * own native logo sizing untouched — only an explicitly chosen shape overrides
2136
+ * it. A shaped logo gets a fixed square box with `object-fit: cover` plus the
2137
+ * shape (border-radius for square/rounded/circle, clip-path for triangle).
2138
+ */
2139
+ declare function logoImgStyle(shape: string | undefined, size: string | undefined): CSSProperties | undefined;
2140
+ /**
2141
+ * Derived CSS-custom-property tokens for the chosen logo shape/size. Emitted by
2142
+ * `computeGlobalStyleTokens` so host-rendered surfaces (e.g. the checkout
2143
+ * header) can match the storefront logo. Returns `{}` for `none`.
2144
+ */
2145
+ declare function logoStyleTokens(shape: string | undefined, size: string | undefined): Record<string, string>;
2146
+
2054
2147
  /**
2055
2148
  * Theme-bundled locale files: load + merge.
2056
2149
  *
@@ -2109,4 +2202,4 @@ declare function pickTranslations(bundle: LocaleBundle, locale: string): LocaleM
2109
2202
  */
2110
2203
  declare function buildLocaleBundle<T extends Record<string, unknown>>(modules: T): LocaleBundle;
2111
2204
 
2112
- export { AddToCartButton, type AddressInput, type AnalyticsApi, type AnalyticsPayload, type AppManifestBlock, type AppPayload, type AppState, Block, BlockInstance, BlockProps$1 as BlockProps, BlockSchema, Cart, type CheckoutAddress, type CheckoutApi, type CheckoutSessionState, type CheckoutStep, Collection, CollectionCard, type CollectionCardProps, type CollectionCardSlots, CollectionProvider, type ComputedStyleTokens, type CurrencyConfig, type CurrencyState, CurrencySwitcher, type CurrencySwitcherProps, Customer, type CustomerAddress, type CustomerAddressesState, type DefineBlockInput, type DefineSectionInput, type DefinedBlock, type DefinedSection, type DynamicResolveContext, type DynamicSourceRef, EditableImage, type EditableImageProps, EditableText, type EditableTextProps, type FocalSrcOptions, Form, type GiftCardBalance, ICON_NAMES, Icon, IconMap, type IconProps, Image, type ImageTransform, Link, type LocaleBundle, type LocaleMessages, LocaleSwitcher, type LocaleSwitcherProps, MenuItemData, Money, MountResult, type NavigationItem, type NavigationState, NuMuProvider, type OrderDetail, type OrderListEntry, type OrderListState, type OrderState, Page, type PlaceOrderResult, Product, ProductCard, type ProductCardProps, type ProductCardSlots, ProductProvider, ProductVariant, type RelatedProductsState, type ReorderResult, type ReorderSkipReason, type ReorderSkippedItem, RichText, type RichTextProps, type SearchResults, type SearchState, Section, SectionContext, SectionInstance, SectionProps$1 as SectionProps, SectionSchema, type ShippingRateOption, type ShopWithHelpers, SizeChart, Store, type ThemeEntry, ThemeMountContext, ThemeRenderArgs, ThemeSettingsV3, type UseGiftCardBalance, type UseReorder, type UseSearchOptions, type UseShippingRatesOptions, type UseShippingRatesState, type UseVariantSelection, type WishlistItem, type WishlistState, applyGlobalStyleTokens, applyImageTransform, asImageTransform, assetUrl, availableValues, buildLocaleBundle, clearSdkSingleton, collectBlocks, collectSections, computeGlobalStyleTokens, defaultVariant, defineBlock, defineSection, defineThemeEntry, dynamicSource, findVariantByOptions, flattenMessages, focalSrc, getReactSingleton, getSdkSingleton, isDefinedBlock, isDefinedSection, isDynamicSource, isSdkAvailable, pickTranslations, registerReactSingleton, registerSdkSingleton, resolveDynamicValue, resolveFontStack, resolveSettingsMap, resolveSizeChart, resolveSourcePath, sanitizeHtml, useAnalytics, useApp, useCart, useCheckout, useCollection, useCollectionOptional, useCollections, useCurrency, useCurrentTemplate, useCustomer, useCustomerActions, useCustomerAddresses, useDirection, useFieldTranslation, useGiftCardBalance, useImage, useLocale, useLocalization, useMoney, useNavigation, useNumberFormat, useOrder, useOrders, usePage, useProduct, useProductOptional, useProductSizeChart, useProducts, useRelatedProducts, useReorder, useResolvedSettings, useSearch, useSection, useSectionOptional, useShippingRates, useShop, useThemeSettings, useTranslation, useVariantSelection, useWishlist };
2205
+ export { AddToCartButton, type AddressInput, type AnalyticsApi, type AnalyticsPayload, type AppManifestBlock, type AppPayload, type AppState, Block, BlockInstance, BlockProps$1 as BlockProps, BlockSchema, Cart, type CheckoutAddress, type CheckoutApi, type CheckoutSessionState, type CheckoutStep, Collection, CollectionCard, type CollectionCardProps, type CollectionCardSlots, CollectionProvider, type ComputedStyleTokens, type CurrencyConfig, type CurrencyState, CurrencySwitcher, type CurrencySwitcherProps, Customer, type CustomerAddress, type CustomerAddressesState, type DefineBlockInput, type DefineSectionInput, type DefinedBlock, type DefinedSection, type DynamicResolveContext, type DynamicSourceRef, EditableImage, type EditableImageProps, EditableText, type EditableTextProps, type FocalSrcOptions, Form, type GiftCardBalance, ICON_NAMES, Icon, IconMap, type IconProps, Image, type ImageTransform, LOGO_SHAPE_OPTIONS, LOGO_SIZE_OPTIONS, Link, type LocaleBundle, type LocaleMessages, LocaleSwitcher, type LocaleSwitcherProps, Logo, type LogoProps, type LogoShape, type LogoSize, MenuItemData, Money, MountResult, type NavigationItem, type NavigationState, NuMuProvider, type OrderDetail, type OrderListEntry, type OrderListState, type OrderState, Page, type PlaceOrderResult, Product, ProductCard, type ProductCardProps, type ProductCardSlots, ProductProvider, ProductVariant, type RelatedProductsState, type ReorderResult, type ReorderSkipReason, type ReorderSkippedItem, RichText, type RichTextProps, type SearchResults, type SearchState, Section, SectionContext, SectionInstance, SectionProps$1 as SectionProps, SectionSchema, type ShippingRateOption, type ShopWithHelpers, SizeChart, Store, type ThemeEntry, ThemeMountContext, ThemeRenderArgs, ThemeSettingsV3, type UseGiftCardBalance, type UseReorder, type UseSearchOptions, type UseShippingRatesOptions, type UseShippingRatesState, type UseVariantSelection, type WishlistItem, type WishlistState, applyGlobalStyleTokens, applyImageTransform, asImageTransform, assetUrl, availableValues, buildLocaleBundle, clearSdkSingleton, collectBlocks, collectSections, computeGlobalStyleTokens, defaultVariant, defineBlock, defineSection, defineThemeEntry, dynamicSource, findVariantByOptions, flattenMessages, focalSrc, getReactSingleton, getSdkSingleton, isDefinedBlock, isDefinedSection, isDynamicSource, isSdkAvailable, logoImgStyle, logoStyleTokens, pickTranslations, registerReactSingleton, registerSdkSingleton, resolveDynamicValue, resolveFontStack, resolveSettingsMap, resolveSizeChart, resolveSourcePath, sanitizeHtml, useAnalytics, useApp, useCart, useCheckout, useCollection, useCollectionOptional, useCollections, useCurrency, useCurrentTemplate, useCustomer, useCustomerActions, useCustomerAddresses, useDirection, useFieldTranslation, useGiftCardBalance, useImage, useLocale, useLocalization, useMoney, useNavigation, useNumberFormat, useOrder, useOrders, usePage, useProduct, useProductOptional, useProductSizeChart, useProducts, useRelatedProducts, useReorder, useResolvedSettings, useSearch, useSection, useSectionOptional, useShippingRates, useShop, useThemeSettings, useTranslation, useVariantSelection, useWishlist };
package/dist/index.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
  import { createContext, forwardRef, useState, useImperativeHandle, useEffect, useCallback, useMemo, useRef, useContext, StrictMode, createElement, Component } from 'react';
2
2
  import { hydrateRoot, createRoot } from 'react-dom/client';
3
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
4
4
 
5
5
  // src/types/theme.ts
6
6
  var MAX_BLOCK_DEPTH = 5;
7
7
 
8
8
  // src/validation/index.ts
9
9
  var THEME_CONTRACT_VERSION = 1;
10
- var SDK_VERSION = "0.4.0" ;
10
+ var SDK_VERSION = "0.5.1" ;
11
11
  var REQUIRED_TEMPLATES = [
12
12
  "home",
13
13
  "product",
@@ -707,7 +707,7 @@ function useOrder(id) {
707
707
  const [tick, setTick] = useState(0);
708
708
  useEffect(() => {
709
709
  if (typeof window === "undefined") return;
710
- if (!customer || !id) {
710
+ if (!id) {
711
711
  setOrder(null);
712
712
  setError(null);
713
713
  setLoading(false);
@@ -718,14 +718,15 @@ function useOrder(id) {
718
718
  setError(null);
719
719
  void (async () => {
720
720
  try {
721
- const res = await fetch(
722
- `/api/customer/me/orders/${encodeURIComponent(id)}`,
723
- {
724
- method: "GET",
725
- credentials: "include",
726
- cache: "no-store"
727
- }
728
- );
721
+ const trackUrl = `/api/storefront/track/${encodeURIComponent(id)}`;
722
+ let res = customer ? await fetch(`/api/customer/me/orders/${encodeURIComponent(id)}`, {
723
+ method: "GET",
724
+ credentials: "include",
725
+ cache: "no-store"
726
+ }) : await fetch(trackUrl, { cache: "no-store" });
727
+ if (!res.ok && customer) {
728
+ res = await fetch(trackUrl, { cache: "no-store" });
729
+ }
729
730
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
730
731
  const body = unwrap(await res.json());
731
732
  if (cancelled) return;
@@ -2328,6 +2329,64 @@ function NuMuProvider({
2328
2329
  function ProductProvider({ product, children }) {
2329
2330
  return /* @__PURE__ */ jsx(ProductContext.Provider, { value: product, children });
2330
2331
  }
2332
+ function CollectionProvider({ collection, children }) {
2333
+ return /* @__PURE__ */ jsx(CollectionContext.Provider, { value: collection, children });
2334
+ }
2335
+
2336
+ // src/utils/logoStyle.ts
2337
+ var LOGO_SHAPE_OPTIONS = [
2338
+ { value: "none", label: "Original", label_ar: "\u0627\u0644\u0623\u0635\u0644\u064A" },
2339
+ { value: "square", label: "Square", label_ar: "\u0645\u0631\u0628\u0639" },
2340
+ { value: "rounded", label: "Rounded square", label_ar: "\u0645\u0631\u0628\u0639 \u0628\u0632\u0648\u0627\u064A\u0627 \u062F\u0627\u0626\u0631\u064A\u0629" },
2341
+ { value: "circle", label: "Circle", label_ar: "\u062F\u0627\u0626\u0631\u0629" },
2342
+ { value: "triangle", label: "Triangle", label_ar: "\u0645\u062B\u0644\u062B" }
2343
+ ];
2344
+ var LOGO_SIZE_OPTIONS = [
2345
+ { value: "small", label: "Small", label_ar: "\u0635\u063A\u064A\u0631" },
2346
+ { value: "medium", label: "Medium", label_ar: "\u0645\u062A\u0648\u0633\u0637" },
2347
+ { value: "large", label: "Large", label_ar: "\u0643\u0628\u064A\u0631" }
2348
+ ];
2349
+ var SHAPED_PX = {
2350
+ small: { plain: 32, rounded: 48 },
2351
+ medium: { plain: 40, rounded: 64 },
2352
+ large: { plain: 56, rounded: 80 }
2353
+ };
2354
+ function normalizeSize(size) {
2355
+ return size === "large" || size === "medium" ? size : "small";
2356
+ }
2357
+ function logoImgStyle(shape, size) {
2358
+ if (!shape || shape === "none") return void 0;
2359
+ const s = normalizeSize(size);
2360
+ const isRound = shape === "circle" || shape === "rounded";
2361
+ const px = isRound ? SHAPED_PX[s].rounded : SHAPED_PX[s].plain;
2362
+ const base = {
2363
+ height: px,
2364
+ width: px,
2365
+ objectFit: "cover",
2366
+ flex: "0 0 auto"
2367
+ };
2368
+ switch (shape) {
2369
+ case "circle":
2370
+ return { ...base, borderRadius: "9999px" };
2371
+ case "rounded":
2372
+ return { ...base, borderRadius: "0.5rem" };
2373
+ case "triangle":
2374
+ return { ...base, clipPath: "polygon(50% 0%, 100% 100%, 0% 100%)" };
2375
+ case "square":
2376
+ default:
2377
+ return base;
2378
+ }
2379
+ }
2380
+ function logoStyleTokens(shape, size) {
2381
+ const style = logoImgStyle(shape, size);
2382
+ if (!style) return {};
2383
+ const box = `${style.height}px`;
2384
+ return {
2385
+ "--theme-logo-box": box,
2386
+ "--theme-logo-radius": typeof style.borderRadius === "string" ? style.borderRadius : "0",
2387
+ "--theme-logo-clip": typeof style.clipPath === "string" ? style.clipPath : "none"
2388
+ };
2389
+ }
2331
2390
 
2332
2391
  // src/utils/styleTokens.ts
2333
2392
  var COLOR_ROLE_ALIASES = {
@@ -2468,6 +2527,12 @@ function computeGlobalStyleTokens(globalSettings) {
2468
2527
  pushHref(FONT_REGISTRY[value]?.href);
2469
2528
  }
2470
2529
  }
2530
+ const gs = globalSettings;
2531
+ const logoTokens = logoStyleTokens(
2532
+ typeof gs.logo_shape === "string" ? gs.logo_shape : void 0,
2533
+ typeof gs.logo_size === "string" ? gs.logo_size : void 0
2534
+ );
2535
+ for (const [k, v] of Object.entries(logoTokens)) cssVars[k] = v;
2471
2536
  return { cssVars, fontHrefs };
2472
2537
  }
2473
2538
  function applyGlobalStyleTokens(globalSettings, el) {
@@ -2510,6 +2575,16 @@ function pickDemo(ctx, themeSettings) {
2510
2575
  const t = themeSettings.templates;
2511
2576
  return !t || Object.keys(t).length === 0;
2512
2577
  }
2578
+ function wrapEntityProviders(app, pageData) {
2579
+ let inner = app;
2580
+ if (pageData.collection) {
2581
+ inner = /* @__PURE__ */ jsx(CollectionProvider, { collection: pageData.collection, children: inner });
2582
+ }
2583
+ if (pageData.product) {
2584
+ inner = /* @__PURE__ */ jsx(ProductProvider, { product: pageData.product, children: inner });
2585
+ }
2586
+ return inner;
2587
+ }
2513
2588
  var ThemeMountBridge = forwardRef(function ThemeMountBridge2({ ctx, mountEl, renderApp }, ref) {
2514
2589
  const [themeSettings, setThemeSettings] = useState(
2515
2590
  ctx.themeSettings
@@ -2550,7 +2625,7 @@ var ThemeMountBridge = forwardRef(function ThemeMountBridge2({ ctx, mountEl, ren
2550
2625
  initialProducts: pageData.products,
2551
2626
  initialCollections: pageData.collections,
2552
2627
  currentTemplate: template,
2553
- children: pageData.product ? /* @__PURE__ */ jsx(ProductProvider, { product: pageData.product, children: app }) : app
2628
+ children: wrapEntityProviders(app, pageData)
2554
2629
  }
2555
2630
  );
2556
2631
  });
@@ -2586,9 +2661,6 @@ function defineThemeEntry(renderApp) {
2586
2661
  createApp: (ctx) => buildThemeElement(ctx, null, renderApp)
2587
2662
  };
2588
2663
  }
2589
- function CollectionProvider({ collection, children }) {
2590
- return /* @__PURE__ */ jsx(CollectionContext.Provider, { value: collection, children });
2591
- }
2592
2664
  function Money({
2593
2665
  amount,
2594
2666
  currency,
@@ -2739,6 +2811,43 @@ function Image({
2739
2811
  }
2740
2812
  );
2741
2813
  }
2814
+ var str = (v) => typeof v === "string" ? v : "";
2815
+ var NONE_HEIGHT = { small: 28, medium: 36, large: 48 };
2816
+ function Logo({
2817
+ src,
2818
+ alt,
2819
+ shape,
2820
+ size,
2821
+ className,
2822
+ style,
2823
+ fallback
2824
+ }) {
2825
+ const settings = useThemeSettings();
2826
+ const shop = useShop();
2827
+ const g = settings?.global_settings ?? {};
2828
+ const url = str(src) || str(g.logo_url) || shop?.logo_url || "";
2829
+ const resolvedShape = shape || str(g.logo_shape) || "none";
2830
+ const resolvedSize = size || str(g.logo_size) || "small";
2831
+ const altText = alt || str(g.brand_name) || shop?.name || "";
2832
+ if (!url) return /* @__PURE__ */ jsx(Fragment, { children: fallback ?? null });
2833
+ const shaped = resolvedShape !== "none";
2834
+ const imgStyle = shaped ? { ...logoImgStyle(resolvedShape, resolvedSize), ...style } : {
2835
+ height: NONE_HEIGHT[resolvedSize] ?? NONE_HEIGHT.small,
2836
+ width: "auto",
2837
+ objectFit: "contain",
2838
+ ...style
2839
+ };
2840
+ return /* @__PURE__ */ jsx(
2841
+ "img",
2842
+ {
2843
+ src: url,
2844
+ alt: altText,
2845
+ className,
2846
+ style: imgStyle,
2847
+ loading: "eager"
2848
+ }
2849
+ );
2850
+ }
2742
2851
  var ABSOLUTE_URL = /^[a-z]+:|^\/\//i;
2743
2852
  function Link({ to, children, ...rest }) {
2744
2853
  const shop = useShop();
@@ -3949,6 +4058,6 @@ function buildLocaleBundle(modules) {
3949
4058
  return bundle;
3950
4059
  }
3951
4060
 
3952
- export { AddToCartButton, Block, CartContext, CollectionCard, CollectionContext, CollectionProvider, CurrencySwitcher, CustomerContext, EditableImage, EditableText, Form, ICON_NAMES, Icon, IconMap, Image, KNOWN_SETTING_TYPES, KNOWN_TEMPLATES, Link, LocaleSwitcher, LocalizationContext, MAX_BLOCK_DEPTH, Money, NavigationContext, NuMuProvider, PageContext, ProductCard, ProductContext, ProductProvider, REQUIRED_TEMPLATES, RichText, SDK_VERSION, Section, SectionContext, ShopContext, THEME_CONTRACT_VERSION, ThemeSettingsContext, applyGlobalStyleTokens, applyImageTransform, asImageTransform, assetUrl, availableValues, buildLocaleBundle, buildThemeElement, clearSdkSingleton, collectBlocks, collectSections, computeGlobalStyleTokens, defaultVariant, defineBlock, defineSection, defineThemeEntry, dynamicSource, findVariantByOptions, flattenMessages, focalSrc, getReactSingleton, getSdkSingleton, isDefinedBlock, isDefinedSection, isDynamicSource, isSdkAvailable, mergeResults, mountTheme, pickTranslations, registerReactSingleton, registerSdkSingleton, resolveDynamicValue, resolveFontStack, resolveSettingsMap, resolveSizeChart, resolveSourcePath, resolveThemeSettings, sanitizeHtml, useAnalytics, useApp, useCart, useCheckout, useCollection, useCollectionOptional, useCollections, useCurrency, useCurrentTemplate, useCustomer, useCustomerActions, useCustomerAddresses, useDirection, useFieldTranslation, useGiftCardBalance, useImage, useLocale, useLocalization, useMoney, useNavigation, useNumberFormat, useOrder, useOrders, usePage, useProduct, useProductOptional, useProductSizeChart, useProducts, useRelatedProducts, useReorder, useResolvedSettings, useSearch, useSection, useSectionOptional, useShippingRates, useShop, useThemeSettings, useTranslation, useVariantSelection, useWishlist, validateBuiltManifest, validateManifest, validateSectionSchema, validateSettingsAgainstSchema };
4061
+ export { AddToCartButton, Block, CartContext, CollectionCard, CollectionContext, CollectionProvider, CurrencySwitcher, CustomerContext, EditableImage, EditableText, Form, ICON_NAMES, Icon, IconMap, Image, KNOWN_SETTING_TYPES, KNOWN_TEMPLATES, LOGO_SHAPE_OPTIONS, LOGO_SIZE_OPTIONS, Link, LocaleSwitcher, LocalizationContext, Logo, MAX_BLOCK_DEPTH, Money, NavigationContext, NuMuProvider, PageContext, ProductCard, ProductContext, ProductProvider, REQUIRED_TEMPLATES, RichText, SDK_VERSION, Section, SectionContext, ShopContext, THEME_CONTRACT_VERSION, ThemeSettingsContext, applyGlobalStyleTokens, applyImageTransform, asImageTransform, assetUrl, availableValues, buildLocaleBundle, buildThemeElement, clearSdkSingleton, collectBlocks, collectSections, computeGlobalStyleTokens, defaultVariant, defineBlock, defineSection, defineThemeEntry, dynamicSource, findVariantByOptions, flattenMessages, focalSrc, getReactSingleton, getSdkSingleton, isDefinedBlock, isDefinedSection, isDynamicSource, isSdkAvailable, logoImgStyle, logoStyleTokens, mergeResults, mountTheme, pickTranslations, registerReactSingleton, registerSdkSingleton, resolveDynamicValue, resolveFontStack, resolveSettingsMap, resolveSizeChart, resolveSourcePath, resolveThemeSettings, sanitizeHtml, useAnalytics, useApp, useCart, useCheckout, useCollection, useCollectionOptional, useCollections, useCurrency, useCurrentTemplate, useCustomer, useCustomerActions, useCustomerAddresses, useDirection, useFieldTranslation, useGiftCardBalance, useImage, useLocale, useLocalization, useMoney, useNavigation, useNumberFormat, useOrder, useOrders, usePage, useProduct, useProductOptional, useProductSizeChart, useProducts, useRelatedProducts, useReorder, useResolvedSettings, useSearch, useSection, useSectionOptional, useShippingRates, useShop, useThemeSettings, useTranslation, useVariantSelection, useWishlist, validateBuiltManifest, validateManifest, validateSectionSchema, validateSettingsAgainstSchema };
3953
4062
  //# sourceMappingURL=index.mjs.map
3954
4063
  //# sourceMappingURL=index.mjs.map