@numueg/theme-sdk 0.5.2 → 0.6.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
@@ -1,10 +1,10 @@
1
1
  import { i as Store, e as Product, b as Collection, C as Cart, c as Customer, P as Page, S as SizeChart, g as ProductVariant } from './entities-6MGANln7.mjs';
2
2
  export { A as Address, a as CartItem, O as Order, d as OrderItem, f as ProductImage, j as ProductOption, h as SizeChartMode } from './entities-6MGANln7.mjs';
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-D0QybTQS.mjs';
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-D0QybTQS.mjs';
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-D8MOopvi.mjs';
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-D8MOopvi.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 { L as LocalizationState, T as ThemeMountContext, a as ThemeRenderArgs, M as MenuItemData } from './mount-DH9dz3dq.mjs';
7
- export { C as CartContext, b as CollectionContext, c as CustomerContext, d as LocalizationContext, N as NavigationContext, P as PageContext, e as ProductContext, S as ShopContext, f as ThemeMountPage, g as ThemeSettingsContext, h as buildThemeElement, m as mountTheme } from './mount-DH9dz3dq.mjs';
6
+ import { L as LocalizationState, T as ThemeMountContext, a as ThemeRenderArgs, M as MenuItemData } from './mount-BGumg1JM.mjs';
7
+ export { C as CartContext, b as CollectionContext, c as CustomerContext, d as LocalizationContext, N as NavigationContext, P as PageContext, e as ProductContext, S as ShopContext, f as ThemeMountPage, g as ThemeSettingsContext, h as buildThemeElement, m as mountTheme } from './mount-BGumg1JM.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';
@@ -1251,6 +1251,11 @@ interface ImageProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, "src" | "
1251
1251
  * "eager" for above-the-fold imagery.
1252
1252
  */
1253
1253
  loading?: "eager" | "lazy";
1254
+ /**
1255
+ * Above-the-fold? When true, forces loading="eager" + fetchPriority="high"
1256
+ * (overrides `loading`). Use on the hero / LCP image. Default false.
1257
+ */
1258
+ priority?: boolean;
1254
1259
  /**
1255
1260
  * Shopify-style frame. When set (e.g. "3/4", "16/9", "1/1") the image is
1256
1261
  * wrapped in a fixed-aspect, overflow-hidden box and the `<img>` fills it.
@@ -1284,7 +1289,67 @@ interface ImageProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, "src" | "
1284
1289
  * If `src` is empty/null, renders a placeholder div so the layout
1285
1290
  * doesn't shift while a merchant configures images in the customizer.
1286
1291
  */
1287
- declare function Image({ src, alt, sizes, responsive, loading, aspectRatio, objectFit, objectPosition, transform, className, style, ...rest }: ImageProps): react.JSX.Element;
1292
+ declare function Image({ src, alt, sizes, responsive, loading, priority, aspectRatio, objectFit, objectPosition, transform, className, style, ...rest }: ImageProps): react.JSX.Element;
1293
+
1294
+ interface HeroMediaProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, "src" | "srcSet" | "alt" | "style"> {
1295
+ /** Desktop (primary) image URL. */
1296
+ src: string | null | undefined;
1297
+ alt: string;
1298
+ /** Desktop focal/zoom/rotation (`asImageTransform(setting)`). */
1299
+ transform?: ImageTransform | null;
1300
+ /** Optional mobile art-direction image. When set → swaps below `breakpoint`. */
1301
+ mobileSrc?: string | null;
1302
+ /** Mobile focal/zoom/rotation. Falls back to the desktop transform's focal. */
1303
+ mobileTransform?: ImageTransform | null;
1304
+ /** Server-crop box aspect for desktop, e.g. "16/9". Match the theme container. */
1305
+ desktopAspect?: string;
1306
+ /** Server-crop box aspect for mobile, e.g. "4/5". */
1307
+ mobileAspect?: string;
1308
+ /** object-fit. Default "cover". Pass "contain" for letterboxed art. */
1309
+ fit?: "cover" | "contain";
1310
+ /** Above-the-fold? Default true → loading=eager + fetchPriority=high. */
1311
+ priority?: boolean;
1312
+ /** sizes attribute. Hero is full-width → default "100vw". */
1313
+ sizes?: string;
1314
+ /** Below this width (px) the mobile image is used. Default 768. */
1315
+ breakpoint?: number;
1316
+ /**
1317
+ * Pre-fetch the alternate (off-breakpoint) image so a Desktop↔Mobile swap is an
1318
+ * instant cache hit instead of a flash-and-fetch. Default true. Set false to save
1319
+ * the one extra background request when smooth resizing isn't worth the bandwidth.
1320
+ */
1321
+ preloadAlternate?: boolean;
1322
+ className?: string;
1323
+ style?: CSSProperties;
1324
+ }
1325
+ /**
1326
+ * <HeroMedia> — above-the-fold hero image for V3 themes.
1327
+ *
1328
+ * - Real responsive srcSet routed through /api/image-transform (resize + AVIF/WebP,
1329
+ * + focal smart-crop when Cloudflare Image Resizing is enabled).
1330
+ * - LCP perf defaults: loading=eager + fetchPriority=high (disable via priority={false}).
1331
+ * - Non-destructive focal/zoom/rotation framing via applyImageTransform.
1332
+ * - Optional MOBILE art-direction image: a different bitmap below `breakpoint`.
1333
+ *
1334
+ * ## Why matchMedia, not <picture><source media>
1335
+ * Art direction is resolved in JS (a `matchMedia` listener) rather than a native
1336
+ * `<picture><source media>`. A native `<picture>` does NOT reliably re-pick its source
1337
+ * when an EMBEDDED preview resizes its iframe — exactly what the theme editor's
1338
+ * Desktop/Mobile toggle does — so the hero would stay stuck on the desktop bitmap at
1339
+ * mobile sizes. CSS media queries DO re-evaluate on that resize (Tailwind flips the
1340
+ * container to portrait), and `matchMedia` shares that engine, so the swap is
1341
+ * deterministic. The state initialises from `matchMedia` so the first client paint is
1342
+ * already correct (V3 themes mount client-side) — no desktop→mobile flash on phones.
1343
+ *
1344
+ * ## Smooth swap
1345
+ * The off-breakpoint image is pre-warmed (low priority, after paint) so toggling the
1346
+ * breakpoint — the editor switch, or a window resize — paints from cache instantly
1347
+ * instead of fetching on demand. See `preloadAlternate`.
1348
+ *
1349
+ * When `mobileSrc` is omitted this is a single responsive <img> filling its parent —
1350
+ * the theme keeps its own wrapper/sizing, identical to a raw <img> plus srcSet + perf.
1351
+ */
1352
+ declare function HeroMedia({ src, alt, transform, mobileSrc, mobileTransform, desktopAspect, mobileAspect, fit, priority, sizes, breakpoint, preloadAlternate, className, style, ...rest }: HeroMediaProps): react.JSX.Element;
1288
1353
 
1289
1354
  interface LogoProps {
1290
1355
  /** Explicit logo URL; falls back to global_settings.logo_url then shop.logo_url. */
@@ -2202,4 +2267,4 @@ declare function pickTranslations(bundle: LocaleBundle, locale: string): LocaleM
2202
2267
  */
2203
2268
  declare function buildLocaleBundle<T extends Record<string, unknown>>(modules: T): LocaleBundle;
2204
2269
 
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 };
2270
+ 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, HeroMedia, type HeroMediaProps, 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
@@ -1,10 +1,10 @@
1
1
  import { i as Store, e as Product, b as Collection, C as Cart, c as Customer, P as Page, S as SizeChart, g as ProductVariant } from './entities-6MGANln7.js';
2
2
  export { A as Address, a as CartItem, O as Order, d as OrderItem, f as ProductImage, j as ProductOption, h as SizeChartMode } from './entities-6MGANln7.js';
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-D0QybTQS.js';
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-D0QybTQS.js';
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-D8MOopvi.js';
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-D8MOopvi.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 { L as LocalizationState, T as ThemeMountContext, a as ThemeRenderArgs, M as MenuItemData } from './mount-BN2mz_wx.js';
7
- export { C as CartContext, b as CollectionContext, c as CustomerContext, d as LocalizationContext, N as NavigationContext, P as PageContext, e as ProductContext, S as ShopContext, f as ThemeMountPage, g as ThemeSettingsContext, h as buildThemeElement, m as mountTheme } from './mount-BN2mz_wx.js';
6
+ import { L as LocalizationState, T as ThemeMountContext, a as ThemeRenderArgs, M as MenuItemData } from './mount-Bt-4ken5.js';
7
+ export { C as CartContext, b as CollectionContext, c as CustomerContext, d as LocalizationContext, N as NavigationContext, P as PageContext, e as ProductContext, S as ShopContext, f as ThemeMountPage, g as ThemeSettingsContext, h as buildThemeElement, m as mountTheme } from './mount-Bt-4ken5.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';
@@ -1251,6 +1251,11 @@ interface ImageProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, "src" | "
1251
1251
  * "eager" for above-the-fold imagery.
1252
1252
  */
1253
1253
  loading?: "eager" | "lazy";
1254
+ /**
1255
+ * Above-the-fold? When true, forces loading="eager" + fetchPriority="high"
1256
+ * (overrides `loading`). Use on the hero / LCP image. Default false.
1257
+ */
1258
+ priority?: boolean;
1254
1259
  /**
1255
1260
  * Shopify-style frame. When set (e.g. "3/4", "16/9", "1/1") the image is
1256
1261
  * wrapped in a fixed-aspect, overflow-hidden box and the `<img>` fills it.
@@ -1284,7 +1289,67 @@ interface ImageProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, "src" | "
1284
1289
  * If `src` is empty/null, renders a placeholder div so the layout
1285
1290
  * doesn't shift while a merchant configures images in the customizer.
1286
1291
  */
1287
- declare function Image({ src, alt, sizes, responsive, loading, aspectRatio, objectFit, objectPosition, transform, className, style, ...rest }: ImageProps): react.JSX.Element;
1292
+ declare function Image({ src, alt, sizes, responsive, loading, priority, aspectRatio, objectFit, objectPosition, transform, className, style, ...rest }: ImageProps): react.JSX.Element;
1293
+
1294
+ interface HeroMediaProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, "src" | "srcSet" | "alt" | "style"> {
1295
+ /** Desktop (primary) image URL. */
1296
+ src: string | null | undefined;
1297
+ alt: string;
1298
+ /** Desktop focal/zoom/rotation (`asImageTransform(setting)`). */
1299
+ transform?: ImageTransform | null;
1300
+ /** Optional mobile art-direction image. When set → swaps below `breakpoint`. */
1301
+ mobileSrc?: string | null;
1302
+ /** Mobile focal/zoom/rotation. Falls back to the desktop transform's focal. */
1303
+ mobileTransform?: ImageTransform | null;
1304
+ /** Server-crop box aspect for desktop, e.g. "16/9". Match the theme container. */
1305
+ desktopAspect?: string;
1306
+ /** Server-crop box aspect for mobile, e.g. "4/5". */
1307
+ mobileAspect?: string;
1308
+ /** object-fit. Default "cover". Pass "contain" for letterboxed art. */
1309
+ fit?: "cover" | "contain";
1310
+ /** Above-the-fold? Default true → loading=eager + fetchPriority=high. */
1311
+ priority?: boolean;
1312
+ /** sizes attribute. Hero is full-width → default "100vw". */
1313
+ sizes?: string;
1314
+ /** Below this width (px) the mobile image is used. Default 768. */
1315
+ breakpoint?: number;
1316
+ /**
1317
+ * Pre-fetch the alternate (off-breakpoint) image so a Desktop↔Mobile swap is an
1318
+ * instant cache hit instead of a flash-and-fetch. Default true. Set false to save
1319
+ * the one extra background request when smooth resizing isn't worth the bandwidth.
1320
+ */
1321
+ preloadAlternate?: boolean;
1322
+ className?: string;
1323
+ style?: CSSProperties;
1324
+ }
1325
+ /**
1326
+ * <HeroMedia> — above-the-fold hero image for V3 themes.
1327
+ *
1328
+ * - Real responsive srcSet routed through /api/image-transform (resize + AVIF/WebP,
1329
+ * + focal smart-crop when Cloudflare Image Resizing is enabled).
1330
+ * - LCP perf defaults: loading=eager + fetchPriority=high (disable via priority={false}).
1331
+ * - Non-destructive focal/zoom/rotation framing via applyImageTransform.
1332
+ * - Optional MOBILE art-direction image: a different bitmap below `breakpoint`.
1333
+ *
1334
+ * ## Why matchMedia, not <picture><source media>
1335
+ * Art direction is resolved in JS (a `matchMedia` listener) rather than a native
1336
+ * `<picture><source media>`. A native `<picture>` does NOT reliably re-pick its source
1337
+ * when an EMBEDDED preview resizes its iframe — exactly what the theme editor's
1338
+ * Desktop/Mobile toggle does — so the hero would stay stuck on the desktop bitmap at
1339
+ * mobile sizes. CSS media queries DO re-evaluate on that resize (Tailwind flips the
1340
+ * container to portrait), and `matchMedia` shares that engine, so the swap is
1341
+ * deterministic. The state initialises from `matchMedia` so the first client paint is
1342
+ * already correct (V3 themes mount client-side) — no desktop→mobile flash on phones.
1343
+ *
1344
+ * ## Smooth swap
1345
+ * The off-breakpoint image is pre-warmed (low priority, after paint) so toggling the
1346
+ * breakpoint — the editor switch, or a window resize — paints from cache instantly
1347
+ * instead of fetching on demand. See `preloadAlternate`.
1348
+ *
1349
+ * When `mobileSrc` is omitted this is a single responsive <img> filling its parent —
1350
+ * the theme keeps its own wrapper/sizing, identical to a raw <img> plus srcSet + perf.
1351
+ */
1352
+ declare function HeroMedia({ src, alt, transform, mobileSrc, mobileTransform, desktopAspect, mobileAspect, fit, priority, sizes, breakpoint, preloadAlternate, className, style, ...rest }: HeroMediaProps): react.JSX.Element;
1288
1353
 
1289
1354
  interface LogoProps {
1290
1355
  /** Explicit logo URL; falls back to global_settings.logo_url then shop.logo_url. */
@@ -2202,4 +2267,4 @@ declare function pickTranslations(bundle: LocaleBundle, locale: string): LocaleM
2202
2267
  */
2203
2268
  declare function buildLocaleBundle<T extends Record<string, unknown>>(modules: T): LocaleBundle;
2204
2269
 
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 };
2270
+ 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, HeroMedia, type HeroMediaProps, 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
@@ -7,7 +7,7 @@ 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.5.2" ;
10
+ var SDK_VERSION = "0.6.1" ;
11
11
  var REQUIRED_TEMPLATES = [
12
12
  "home",
13
13
  "product",
@@ -1937,7 +1937,7 @@ function NuMuProvider({
1937
1937
  const [cart, setCart] = useState(
1938
1938
  initialCart || { ...EMPTY_CART, currency: store.currency }
1939
1939
  );
1940
- const [loading, setLoading] = useState(false);
1940
+ const [loading, setLoading] = useState(!initialCart);
1941
1941
  const [locale, setLocale] = useState(() => {
1942
1942
  if (initialLocale) return initialLocale;
1943
1943
  if (typeof document !== "undefined") {
@@ -2094,6 +2094,8 @@ function NuMuProvider({
2094
2094
  setCart(normalizeCartFromServer(data));
2095
2095
  }
2096
2096
  } catch {
2097
+ } finally {
2098
+ if (!cancelled) setLoading(false);
2097
2099
  }
2098
2100
  })();
2099
2101
  return () => {
@@ -2740,6 +2742,7 @@ function Image({
2740
2742
  sizes = "(min-width: 1024px) 25vw, (min-width: 640px) 50vw, 100vw",
2741
2743
  responsive = true,
2742
2744
  loading = "lazy",
2745
+ priority = false,
2743
2746
  aspectRatio,
2744
2747
  objectFit,
2745
2748
  objectPosition,
@@ -2776,6 +2779,7 @@ function Image({
2776
2779
  );
2777
2780
  }
2778
2781
  const srcSet = responsive ? buildSrcSet(src) : void 0;
2782
+ const effLoading = priority ? "eager" : loading;
2779
2783
  const effFit = objectFit ?? (framed ? "cover" : void 0);
2780
2784
  const fitStyle = transform ? applyImageTransform(transform, effFit === "contain" ? "contain" : "cover") : {
2781
2785
  ...effFit ? { objectFit: effFit } : {},
@@ -2788,7 +2792,8 @@ function Image({
2788
2792
  alt,
2789
2793
  srcSet: srcSet || void 0,
2790
2794
  sizes: srcSet ? sizes : void 0,
2791
- loading,
2795
+ loading: effLoading,
2796
+ fetchPriority: priority ? "high" : void 0,
2792
2797
  decoding: "async",
2793
2798
  className: framed ? void 0 : className,
2794
2799
  style: framed ? { width: "100%", height: "100%", display: "block", ...fitStyle } : { ...fitStyle, ...style },
@@ -2812,6 +2817,111 @@ function Image({
2812
2817
  }
2813
2818
  );
2814
2819
  }
2820
+ var HERO_WIDTHS = [640, 768, 1024, 1280, 1920];
2821
+ var DEFAULT_BREAKPOINT = 768;
2822
+ var DESKTOP_BASE_WIDTH = 1920;
2823
+ var MOBILE_BASE_WIDTH = 1280;
2824
+ function heroSrcSet(url, opts) {
2825
+ return HERO_WIDTHS.map((w) => `${focalSrc(url, { width: w, ...opts })} ${w}w`).join(", ");
2826
+ }
2827
+ function HeroMedia({
2828
+ src,
2829
+ alt,
2830
+ transform,
2831
+ mobileSrc,
2832
+ mobileTransform,
2833
+ desktopAspect,
2834
+ mobileAspect,
2835
+ fit = "cover",
2836
+ priority = true,
2837
+ sizes = "100vw",
2838
+ breakpoint = DEFAULT_BREAKPOINT,
2839
+ preloadAlternate = true,
2840
+ className,
2841
+ style,
2842
+ ...rest
2843
+ }) {
2844
+ const hasMobile = !!mobileSrc;
2845
+ const mobileQuery = `(max-width: ${breakpoint - 1}px)`;
2846
+ const [isMobile, setIsMobile] = useState(
2847
+ () => hasMobile && typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia(mobileQuery).matches
2848
+ );
2849
+ const [rawFallback, setRawFallback] = useState(false);
2850
+ const { onError: themeOnError, ...imgRest } = rest;
2851
+ const handleError = (e) => {
2852
+ if (!rawFallback) setRawFallback(true);
2853
+ else themeOnError?.(e);
2854
+ };
2855
+ useEffect(() => {
2856
+ if (!hasMobile || typeof window === "undefined" || typeof window.matchMedia !== "function") {
2857
+ return;
2858
+ }
2859
+ const mq = window.matchMedia(mobileQuery);
2860
+ const sync = () => setIsMobile(mq.matches);
2861
+ sync();
2862
+ mq.addEventListener?.("change", sync);
2863
+ return () => mq.removeEventListener?.("change", sync);
2864
+ }, [hasMobile, mobileQuery]);
2865
+ const desktopFocal = transform?.focal;
2866
+ const mobileFocal = mobileTransform?.focal ?? desktopFocal;
2867
+ const desktopCrop = desktopAspect ? { focal: desktopFocal, aspect: desktopAspect, fit } : {};
2868
+ const mobileCrop = {
2869
+ focal: mobileFocal,
2870
+ aspect: mobileAspect,
2871
+ fit
2872
+ };
2873
+ useEffect(() => {
2874
+ if (!preloadAlternate || !hasMobile || !src || !mobileSrc) return;
2875
+ if (typeof window === "undefined" || typeof window.Image !== "function") return;
2876
+ const altUrl = isMobile ? rawFallback ? src : focalSrc(src, { width: DESKTOP_BASE_WIDTH, ...desktopCrop }) : rawFallback ? mobileSrc : focalSrc(mobileSrc, { width: MOBILE_BASE_WIDTH, ...mobileCrop });
2877
+ if (!altUrl) return;
2878
+ const im = new window.Image();
2879
+ im.onerror = () => {
2880
+ };
2881
+ try {
2882
+ im.fetchPriority = "low";
2883
+ } catch {
2884
+ }
2885
+ im.decoding = "async";
2886
+ im.src = altUrl;
2887
+ if (typeof im.decode === "function") im.decode().catch(() => {
2888
+ });
2889
+ }, [preloadAlternate, hasMobile, src, mobileSrc, isMobile, rawFallback]);
2890
+ if (!src) {
2891
+ return /* @__PURE__ */ jsx(
2892
+ "div",
2893
+ {
2894
+ className,
2895
+ role: "img",
2896
+ "aria-label": alt,
2897
+ style: { width: "100%", height: "100%", backgroundColor: "rgba(0,0,0,0.05)", ...style }
2898
+ }
2899
+ );
2900
+ }
2901
+ const useMobile = hasMobile && isMobile;
2902
+ const activeUrl = useMobile ? mobileSrc : src;
2903
+ const activeCrop = useMobile ? mobileCrop : desktopCrop;
2904
+ const activeBase = useMobile ? MOBILE_BASE_WIDTH : DESKTOP_BASE_WIDTH;
2905
+ const activeSrc = rawFallback ? activeUrl : focalSrc(activeUrl, { width: activeBase, ...activeCrop });
2906
+ const activeSrcSet = rawFallback ? void 0 : heroSrcSet(activeUrl, activeCrop);
2907
+ const fitStyle = applyImageTransform(useMobile ? mobileTransform ?? transform : transform, fit);
2908
+ return /* @__PURE__ */ jsx(
2909
+ "img",
2910
+ {
2911
+ src: activeSrc,
2912
+ srcSet: activeSrcSet,
2913
+ sizes: activeSrcSet ? sizes : void 0,
2914
+ alt,
2915
+ loading: priority ? "eager" : "lazy",
2916
+ fetchPriority: priority ? "high" : void 0,
2917
+ decoding: "async",
2918
+ onError: handleError,
2919
+ className,
2920
+ style: { width: "100%", height: "100%", display: "block", ...fitStyle, ...style },
2921
+ ...imgRest
2922
+ }
2923
+ );
2924
+ }
2815
2925
  var str = (v) => typeof v === "string" ? v : "";
2816
2926
  var NONE_HEIGHT = { small: 28, medium: 36, large: 48 };
2817
2927
  function Logo({
@@ -4059,6 +4169,6 @@ function buildLocaleBundle(modules) {
4059
4169
  return bundle;
4060
4170
  }
4061
4171
 
4062
- 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 };
4172
+ export { AddToCartButton, Block, CartContext, CollectionCard, CollectionContext, CollectionProvider, CurrencySwitcher, CustomerContext, EditableImage, EditableText, Form, HeroMedia, 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 };
4063
4173
  //# sourceMappingURL=index.mjs.map
4064
4174
  //# sourceMappingURL=index.mjs.map