@anker-in/shopify-react 0.1.1-beta.1 → 0.1.1-beta.3

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.
@@ -1,6 +1,7 @@
1
1
  import * as swr_mutation from 'swr/mutation';
2
2
  import { SWRMutationConfiguration } from 'swr/mutation';
3
- import { CartLineInput as CartLineInput$1, NormalizedCart, UpdateCartLinesOptions, HasMetafieldsIdentifier, NormalizedProduct, NormalizedProductVariant, NormalizedLineItem, Media, NormalizedCollection, CollectionsConnection, NormalizedBlog, NormalizedArticle } from '@anker-in/shopify-sdk';
3
+ import * as _anker_in_shopify_sdk from '@anker-in/shopify-sdk';
4
+ import { CartLineInput as CartLineInput$1, NormalizedCart, UpdateCartLinesOptions, HasMetafieldsIdentifier, NormalizedProduct, NormalizedProductVariant, NormalizedLineItem, Attribute as Attribute$1, Media, NormalizedCollection, CollectionsConnection, NormalizedBlog, NormalizedArticle } from '@anker-in/shopify-sdk';
4
5
  import { A as AddToCartLineItem, G as GtmParams, B as BuyNowTrackConfig, d as PlusMemberShippingMethodConfig, e as PlusMemberSettingsMetafields, D as DeliveryPlusType, f as SelectedPlusMemberProduct, i as DeliveryData } from './types-CICUnw0v.mjs';
5
6
  import Decimal from 'decimal.js';
6
7
  import * as swr from 'swr';
@@ -427,8 +428,108 @@ type AutoFreeGiftList = AutoFreeGiftItem[] | [];
427
428
  * 此 Hook 不产生任何副作用。
428
429
  * 使用示例:
429
430
  * const { qualifyingGift, nextTierGoal, activeCampaign, isLoading } = useCalcAutoFreeGift(cart, autoFreeGiftConfig);
431
+ *
432
+ * 也可以传入 lines 参数来计算加购前的赠品:
433
+ * const { qualifyingGift, nextTierGoal, activeCampaign, isLoading } = useCalcAutoFreeGift(cart, autoFreeGiftConfig, customer, lines);
430
434
  */
431
- declare const useCalcAutoFreeGift: (cart: any, autoFreeGiftConfig: AutoFreeGiftConfig, customer: any) => FunctionGiftResult;
435
+ declare const useCalcAutoFreeGift: (cart: any, autoFreeGiftConfig: AutoFreeGiftConfig, customer: any, lines?: AddToCartLineItem[]) => FunctionGiftResult;
436
+
437
+ interface GiveawayProduct {
438
+ handle: string;
439
+ sku: string;
440
+ }
441
+ interface Breakpoint {
442
+ breakpoint: string;
443
+ giveawayProducts: GiveawayProduct[];
444
+ }
445
+ interface Campaign {
446
+ activityAvailableQuery?: string;
447
+ activityQroperty?: string;
448
+ breakpoints?: Array<{
449
+ breakpoint: string;
450
+ giveawayProducts: GiveawayProduct[];
451
+ }>;
452
+ includeTags?: string[];
453
+ useTotalAmount?: boolean;
454
+ }
455
+ interface UseScriptAutoFreeGiftResult {
456
+ involvedLines: NormalizedLineItem[];
457
+ reorder: (a: NormalizedLineItem, b: NormalizedLineItem) => number;
458
+ disableCodeRemove: boolean;
459
+ nextFreeGiftLevel: Breakpoint | null;
460
+ freeGiftLevel: Breakpoint | null;
461
+ involvedSubTotal: Decimal;
462
+ giftProductsResult?: NormalizedProduct[];
463
+ }
464
+ declare const useScriptAutoFreeGift: ({ campaign, _giveaway, cart, locale: providedLocale, lines, }: {
465
+ campaign: Campaign | null;
466
+ _giveaway: string;
467
+ cart: NormalizedCart | undefined;
468
+ locale?: string;
469
+ lines?: AddToCartLineItem[];
470
+ }) => UseScriptAutoFreeGiftResult;
471
+
472
+ interface UseCalcGiftsFromLinesOptions {
473
+ /** Lines to calculate gifts from (AddToCartLineItem format) */
474
+ lines: AddToCartLineItem[];
475
+ /** Auto free gift configuration (Function gift) */
476
+ autoFreeGiftConfig?: AutoFreeGiftConfig;
477
+ /** Customer information (required for function gift) */
478
+ customer?: any;
479
+ /** Script gift campaign configuration */
480
+ scriptCampaign?: any;
481
+ /** Script giveaway attribute key */
482
+ scriptGiveawayKey?: string;
483
+ /** Locale for product fetching (optional, will use from ShopifyProvider if not provided) */
484
+ locale?: string;
485
+ }
486
+ interface UseCalcGiftsFromLinesResult {
487
+ /** Function gift calculation result */
488
+ functionGift: FunctionGiftResult;
489
+ /** Script gift calculation result */
490
+ scriptGift: UseScriptAutoFreeGiftResult;
491
+ /** All gift lines that need to be added to cart (combined from both) */
492
+ allGiftLines: CartLineInput[];
493
+ /** Whether any gifts are available */
494
+ hasGifts: boolean;
495
+ }
496
+ /**
497
+ * Calculate gifts from AddToCartLineItem[] before adding to cart
498
+ * Supports both function-based gifts (useCalcAutoFreeGift) and script-based gifts (useScriptAutoFreeGift)
499
+ *
500
+ * Automatically uses locale from ShopifyProvider and cart from CartContext if not provided.
501
+ *
502
+ * @example
503
+ * ```tsx
504
+ * // Basic usage (locale from context, customer required for function gift)
505
+ * const { allGiftLines, hasGifts } = useCalcGiftsFromLines({
506
+ * lines: [{ variant: myVariant, quantity: 2 }],
507
+ * customer: currentCustomer,
508
+ * autoFreeGiftConfig: functionGiftConfig,
509
+ * scriptCampaign: scriptGiftConfig,
510
+ * })
511
+ *
512
+ * // Script gift only (no customer needed)
513
+ * const { allGiftLines, hasGifts } = useCalcGiftsFromLines({
514
+ * lines: [{ variant: myVariant, quantity: 2 }],
515
+ * scriptCampaign: scriptGiftConfig,
516
+ * })
517
+ *
518
+ * // With custom locale
519
+ * const { allGiftLines, hasGifts } = useCalcGiftsFromLines({
520
+ * lines: [{ variant: myVariant, quantity: 2 }],
521
+ * customer: currentCustomer,
522
+ * locale: 'fr',
523
+ * autoFreeGiftConfig: functionGiftConfig,
524
+ * })
525
+ *
526
+ * // Then add both products and gifts to cart
527
+ * await addToCart({
528
+ * lineItems: [...lines, ...allGiftLines]
529
+ * })
530
+ * ```
531
+ */
532
+ declare function useCalcGiftsFromLines({ lines, customer, scriptGiveawayKey, }: UseCalcGiftsFromLinesOptions): UseCalcGiftsFromLinesResult;
432
533
 
433
534
  declare enum OrderDiscountType {
434
535
  PERCENTAGE = 1,// 百分比折扣
@@ -896,11 +997,55 @@ interface HasPlusMemberInCartResult {
896
997
  */
897
998
  declare function useHasPlusMemberInCart({ memberSetting, cart, }: UseHasPlusMemberInCartProps): HasPlusMemberInCartResult;
898
999
 
1000
+ interface UseAddPlusMemberProductsToCartProps {
1001
+ /** 购物车数据 */
1002
+ cart?: NormalizedCart;
1003
+ /** Plus Member 配置 */
1004
+ memberSetting?: PlusMemberSettingsMetafields;
1005
+ /** 选中的会员模式 */
1006
+ selectedPlusMemberMode: DeliveryPlusType;
1007
+ /** 选中的会员产品 */
1008
+ selectedPlusMemberProduct?: SelectedPlusMemberProduct;
1009
+ }
1010
+ /**
1011
+ * 返回需要添加到购物车的 Plus Member 产品
1012
+ *
1013
+ * 该 hook 会根据用户选择的会员模式和购物车现有状态,
1014
+ * 返回需要添加的会员产品。如果不需要添加会员产品,则返回 undefined。
1015
+ *
1016
+ * @param props - Hook 参数
1017
+ * @param props.cart - 购物车数据
1018
+ * @param props.memberSetting - Plus Member 配置
1019
+ * @param props.selectedPlusMemberMode - 选中的会员模式
1020
+ * @param props.selectedPlusMemberProduct - 选中的会员产品
1021
+ * @returns Plus Member 产品对象或 undefined
1022
+ *
1023
+ * @example
1024
+ * ```tsx
1025
+ * const plusMemberProduct = useAddPlusMemberProductsToCart({
1026
+ * cart,
1027
+ * memberSetting,
1028
+ * selectedPlusMemberMode: DeliveryPlusType.MONTHLY,
1029
+ * selectedPlusMemberProduct: { product, variant },
1030
+ * })
1031
+ *
1032
+ * // plusMemberProduct 格式:
1033
+ * // {
1034
+ * // product: NormalizedProduct,
1035
+ * // variant: NormalizedProductVariant
1036
+ * // }
1037
+ * // 或 undefined (当不需要添加会员产品时)
1038
+ * ```
1039
+ */
1040
+ declare function useAddPlusMemberProductsToCart({ cart, memberSetting, selectedPlusMemberMode, selectedPlusMemberProduct, }: UseAddPlusMemberProductsToCartProps): {
1041
+ product: _anker_in_shopify_sdk.NormalizedProduct;
1042
+ variant: _anker_in_shopify_sdk.NormalizedProductVariant;
1043
+ } | undefined;
1044
+
899
1045
  interface PlusMemberProviderProps<TProduct = any, TVariant = any, TProfile = any> {
900
1046
  variant: TVariant;
901
1047
  product: TProduct;
902
- metafields: PlusMemberSettingsMetafields;
903
- shopCommon?: Record<string, any>;
1048
+ memberSetting: PlusMemberSettingsMetafields;
904
1049
  initialSelectedPlusMemberMode?: DeliveryPlusType;
905
1050
  profile?: TProfile;
906
1051
  locale?: string;
@@ -913,7 +1058,6 @@ interface PlusMemberProviderProps<TProduct = any, TVariant = any, TProfile = any
913
1058
  * @param variant - Product variant
914
1059
  * @param product - Product
915
1060
  * @param metafields - Plus member settings from metafields
916
- * @param shopCommon - Shop common settings
917
1061
  * @param initialSelectedPlusMemberMode - Initial selected mode (default: 'free')
918
1062
  * @param profile - User profile
919
1063
  * @param locale - Locale code
@@ -924,8 +1068,7 @@ interface PlusMemberProviderProps<TProduct = any, TVariant = any, TProfile = any
924
1068
  * <PlusMemberProvider
925
1069
  * variant={variant}
926
1070
  * product={product}
927
- * metafields={memberSettings}
928
- * shopCommon={shopCommon}
1071
+ * memberSetting={memberSetting}
929
1072
  * profile={profile}
930
1073
  * locale={locale}
931
1074
  * >
@@ -933,7 +1076,7 @@ interface PlusMemberProviderProps<TProduct = any, TVariant = any, TProfile = any
933
1076
  * </PlusMemberProvider>
934
1077
  * ```
935
1078
  */
936
- declare const PlusMemberProvider: <TProduct = any, TVariant = any, TProfile = any>({ variant, product, shopCommon, metafields, initialSelectedPlusMemberMode, profile, locale, children, }: PropsWithChildren<PlusMemberProviderProps<TProduct, TVariant, TProfile>>) => react_jsx_runtime.JSX.Element;
1079
+ declare const PlusMemberProvider: <TProduct = any, TVariant = any, TProfile = any>({ variant, product, memberSetting, initialSelectedPlusMemberMode, profile, locale, children, }: PropsWithChildren<PlusMemberProviderProps<TProduct, TVariant, TProfile>>) => react_jsx_runtime.JSX.Element;
937
1080
 
938
1081
  declare const getReferralAttributes: () => {
939
1082
  key: string;
@@ -969,40 +1112,6 @@ declare const useCartItemQuantityLimit: ({ cart, cartItem, config, }: {
969
1112
  max: number;
970
1113
  };
971
1114
 
972
- interface GiveawayProduct {
973
- handle: string;
974
- sku: string;
975
- }
976
- interface Breakpoint {
977
- breakpoint: string;
978
- giveawayProducts: GiveawayProduct[];
979
- }
980
- interface Campaign {
981
- activityAvailableQuery?: string;
982
- activityQroperty?: string;
983
- breakpoints?: Array<{
984
- breakpoint: string;
985
- giveawayProducts: GiveawayProduct[];
986
- }>;
987
- includeTags?: string[];
988
- useTotalAmount?: boolean;
989
- }
990
- interface UseScriptAutoFreeGiftResult {
991
- involvedLines: NormalizedLineItem[];
992
- reorder: (a: NormalizedLineItem, b: NormalizedLineItem) => number;
993
- disableCodeRemove: boolean;
994
- nextFreeGiftLevel: Breakpoint | null;
995
- freeGiftLevel: Breakpoint | null;
996
- involvedSubTotal: Decimal;
997
- giftProductsResult?: NormalizedProduct[];
998
- }
999
- declare const useScriptAutoFreeGift: ({ campaign, _giveaway, cart, locale: providedLocale, }: {
1000
- campaign: Campaign | null;
1001
- _giveaway: string;
1002
- cart: NormalizedCart | undefined;
1003
- locale?: string;
1004
- }) => UseScriptAutoFreeGiftResult;
1005
-
1006
1115
  declare const useUpdateLineCodeAmountAttributes: ({ cart, mutateCart, isCartLoading, setLoadingState, metafieldIdentifiers, }: {
1007
1116
  cart?: NormalizedCart;
1008
1117
  mutateCart: (cart: NormalizedCart | undefined) => void;
@@ -1044,23 +1153,30 @@ declare const CODE_AMOUNT_KEY = "_sku_code_money";
1044
1153
  declare const SCRIPT_CODE_AMOUNT_KEY = "_code_money";
1045
1154
  declare const MAIN_PRODUCT_CODE: string[];
1046
1155
 
1156
+ /**
1157
+ * Normalize AddToCartLineItem[] to NormalizedLineItem[] format
1158
+ * This is used to calculate gifts from lines before they are added to cart
1159
+ */
1160
+ declare function normalizeAddToCartLines(lines: AddToCartLineItem[]): NormalizedLineItem[];
1161
+ /**
1162
+ * Create a mock cart structure from AddToCartLineItem[]
1163
+ * This is useful for calculating gifts before actual cart operations
1164
+ */
1165
+ declare function createMockCartFromLines(lines: AddToCartLineItem[], existingCart?: any): any;
1166
+
1047
1167
  declare const getQuery: () => Record<string, string>;
1048
1168
  declare function atobID(id: string): string | undefined;
1049
1169
  declare function btoaID(id: string, type?: 'ProductVariant' | 'Product'): string;
1050
1170
 
1051
1171
  declare const getMatchedMainProductSubTotal: (cartData: any, variant_list: AutoFreeGiftMainProduct["variant_id_list"], main_product: AutoFreeGiftMainProduct) => any;
1172
+ declare const safeParse: (str: string) => any;
1052
1173
  declare const getDiscountEnvAttributeValue: (attributes?: {
1053
1174
  key: string;
1054
1175
  value: string;
1055
1176
  }[]) => any;
1056
- declare const isAttributesEqual: (attrs1?: {
1177
+ declare const checkAttributesUpdateNeeded: (oldAttributes: Attribute$1[], newAttributes: Attribute$1[], customAttributesNeedRemove: {
1057
1178
  key: string;
1058
- value: string;
1059
- }[], attrs2?: {
1060
- key: string;
1061
- value: string;
1062
1179
  }[]) => boolean;
1063
- declare const safeParseJson: (str: string) => any;
1064
1180
  declare function preCheck(rule_conditions: RuleCondition[], userTags: string[], currentDealsTypes: string[]): boolean;
1065
1181
  declare const formatScriptAutoFreeGift: ({ scriptAutoFreeGiftResult, gradient_gifts, locale, }: {
1066
1182
  scriptAutoFreeGiftResult: UseScriptAutoFreeGiftResult;
@@ -1847,4 +1963,4 @@ declare function getCachedGeoLocation(cacheKey?: string): GeoLocationData | unde
1847
1963
  */
1848
1964
  declare function clearGeoLocationCache(cacheKey?: string): void;
1849
1965
 
1850
- export { defaultSWRMutationConfiguration as $, type AddCartLinesInput as A, type BuyNowInput as B, type CreateCartInput as C, type DiscountLabel as D, type GiftProductItem as E, RuleType as F, type GiftProduct as G, BuyRuleType as H, type FunctionGiftResult as I, type FormattedGift as J, type CartLineInput as K, type AutoFreeGiftItem as L, type MainProductInfo as M, type AutoFreeGiftList as N, type OrderDiscountResult as O, OrderDiscountType as P, OrderBasePriceType as Q, type RemoveCartLinesInput as R, SpendMoneyType as S, type TieredDiscount as T, type UpdateCartAttributesInput as U, type VariantItem as V, type OrderDiscountConfig as W, PriceDiscountType as X, PriceBasePriceType as Y, type PriceDiscountConfig as Z, currencyCodeMapping as _, useAddCartLines as a, usePlusAnnualProductVariant as a$, CUSTOMER_ATTRIBUTE_KEY as a0, CUSTOMER_SCRIPT_GIFT_KEY as a1, CODE_AMOUNT_KEY as a2, SCRIPT_CODE_AMOUNT_KEY as a3, MAIN_PRODUCT_CODE as a4, getQuery as a5, atobID as a6, btoaID as a7, getMatchedMainProductSubTotal as a8, getDiscountEnvAttributeValue as a9, type UseAllCollectionsOptions as aA, useAllCollections as aB, type UseCollectionsOptions as aC, useCollections as aD, type UseBlogOptions as aE, useBlog as aF, type UseAllBlogsOptions as aG, useAllBlogs as aH, type UseArticleOptions as aI, useArticle as aJ, type UseArticlesOptions as aK, useArticles as aL, type UseArticlesInBlogOptions as aM, useArticlesInBlog as aN, type SearchResultType as aO, type SearchResultItem as aP, type SearchResult as aQ, type UseSearchOptions as aR, useSearch as aS, type SiteInfo as aT, type UseSiteOptions as aU, useSite as aV, type ShippingMethodsContext as aW, type PlusMemberContextValue as aX, PlusMemberContext as aY, usePlusMemberContext as aZ, usePlusMonthlyProductVariant as a_, isAttributesEqual as aa, safeParseJson as ab, preCheck as ac, formatScriptAutoFreeGift as ad, formatFunctionAutoFreeGift as ae, useSelectedOptions as af, type SelectedOptionsResult as ag, type UseProductOptions as ah, useProduct as ai, type UseAllProductsOptions as aj, useAllProducts as ak, type UseProductsByHandlesOptions as al, useProductsByHandles as am, type Options as an, useVariant as ao, type UsePriceOptions as ap, type UsePriceResult as aq, usePrice as ar, useProductUrl as as, useUpdateVariantQuery as at, type ImageMedia as au, type VideoMedia as av, type VariantMedia as aw, useVariantMedia as ax, type UseCollectionOptions as ay, useCollection as az, useUpdateCartLines as b, type UseShippingMethodsOptions as b0, type UseShippingMethodsResult as b1, useShippingMethods as b2, useShippingMethodAvailableCheck as b3, useReplaceCartPlusMember as b4, usePlusMemberDeliveryCodes as b5, usePlusMemberItemCustomAttributes as b6, type CustomerOrder as b7, type Customer as b8, usePlusMemberCheckoutCustomAttributes as b9, type ExportCart as bA, type UseAutoRemovePlusMemberInCartProps as ba, useAutoRemovePlusMemberInCart as bb, type UseHasPlusMemberInCartProps as bc, type HasPlusMemberInCartResult as bd, useHasPlusMemberInCart as be, type PlusMemberProviderProps as bf, PlusMemberProvider as bg, type UseIntersectionOptions as bh, useIntersection as bi, type UseExposureOptions as bj, useExposure as bk, type GeoLocationData as bl, type LocaleMapping as bm, type UseGeoLocationOptions as bn, useGeoLocation as bo, getCachedGeoLocation as bp, clearGeoLocationCache as bq, type Attribute as br, type Discount as bs, type Image as bt, type Measurement as bu, type ExportSelectedOption as bv, type ExportProductVariant as bw, type ExportDiscountAllocations as bx, type ExportLineItem as by, type ExportDiscounts as bz, useRemoveCartLines as c, type ApplyCartCodesInput as d, useApplyCartCodes as e, type RemoveCartCodesInput as f, useRemoveCartCodes as g, useUpdateCartAttributes as h, type UseBuyNowOptions as i, useBuyNow as j, useCalcAutoFreeGift as k, useCalcOrderDiscount as l, getReferralAttributes as m, useCartAttributes as n, useCartItemQuantityLimit as o, type UseScriptAutoFreeGiftResult as p, useScriptAutoFreeGift as q, useUpdateLineCodeAmountAttributes as r, type AutoFreeGift as s, type AutoFreeGiftMainProduct as t, useCreateCart as u, type AutoFreeGiftConfig as v, type RuleCondition as w, type Config as x, type GiftTier as y, type RewardItem as z };
1966
+ export { PriceBasePriceType as $, type AddCartLinesInput as A, type BuyNowInput as B, type CreateCartInput as C, type DiscountLabel as D, type Config as E, type GiftTier as F, type GiftProduct as G, type RewardItem as H, type GiftProductItem as I, RuleType as J, BuyRuleType as K, type FunctionGiftResult as L, type MainProductInfo as M, type FormattedGift as N, type OrderDiscountResult as O, type CartLineInput as P, type AutoFreeGiftItem as Q, type RemoveCartLinesInput as R, SpendMoneyType as S, type AutoFreeGiftList as T, type UpdateCartAttributesInput as U, type VariantItem as V, OrderDiscountType as W, OrderBasePriceType as X, type TieredDiscount as Y, type OrderDiscountConfig as Z, PriceDiscountType as _, useAddCartLines as a, type ShippingMethodsContext as a$, type PriceDiscountConfig as a0, currencyCodeMapping as a1, defaultSWRMutationConfiguration as a2, CUSTOMER_ATTRIBUTE_KEY as a3, CUSTOMER_SCRIPT_GIFT_KEY as a4, CODE_AMOUNT_KEY as a5, SCRIPT_CODE_AMOUNT_KEY as a6, MAIN_PRODUCT_CODE as a7, getQuery as a8, atobID as a9, type VideoMedia as aA, type VariantMedia as aB, useVariantMedia as aC, type UseCollectionOptions as aD, useCollection as aE, type UseAllCollectionsOptions as aF, useAllCollections as aG, type UseCollectionsOptions as aH, useCollections as aI, type UseBlogOptions as aJ, useBlog as aK, type UseAllBlogsOptions as aL, useAllBlogs as aM, type UseArticleOptions as aN, useArticle as aO, type UseArticlesOptions as aP, useArticles as aQ, type UseArticlesInBlogOptions as aR, useArticlesInBlog as aS, type SearchResultType as aT, type SearchResultItem as aU, type SearchResult as aV, type UseSearchOptions as aW, useSearch as aX, type SiteInfo as aY, type UseSiteOptions as aZ, useSite as a_, btoaID as aa, normalizeAddToCartLines as ab, createMockCartFromLines as ac, getMatchedMainProductSubTotal as ad, safeParse as ae, getDiscountEnvAttributeValue as af, checkAttributesUpdateNeeded as ag, preCheck as ah, formatScriptAutoFreeGift as ai, formatFunctionAutoFreeGift as aj, useSelectedOptions as ak, type SelectedOptionsResult as al, type UseProductOptions as am, useProduct as an, type UseAllProductsOptions as ao, useAllProducts as ap, type UseProductsByHandlesOptions as aq, useProductsByHandles as ar, type Options as as, useVariant as at, type UsePriceOptions as au, type UsePriceResult as av, usePrice as aw, useProductUrl as ax, useUpdateVariantQuery as ay, type ImageMedia as az, useUpdateCartLines as b, type PlusMemberContextValue as b0, PlusMemberContext as b1, usePlusMemberContext as b2, usePlusMonthlyProductVariant as b3, usePlusAnnualProductVariant as b4, type UseShippingMethodsOptions as b5, type UseShippingMethodsResult as b6, useShippingMethods as b7, useShippingMethodAvailableCheck as b8, useReplaceCartPlusMember as b9, type Image as bA, type Measurement as bB, type ExportSelectedOption as bC, type ExportProductVariant as bD, type ExportDiscountAllocations as bE, type ExportLineItem as bF, type ExportDiscounts as bG, type ExportCart as bH, usePlusMemberDeliveryCodes as ba, usePlusMemberItemCustomAttributes as bb, type CustomerOrder as bc, type Customer as bd, usePlusMemberCheckoutCustomAttributes as be, type UseAutoRemovePlusMemberInCartProps as bf, useAutoRemovePlusMemberInCart as bg, type UseHasPlusMemberInCartProps as bh, type HasPlusMemberInCartResult as bi, useHasPlusMemberInCart as bj, type UseAddPlusMemberProductsToCartProps as bk, useAddPlusMemberProductsToCart as bl, type PlusMemberProviderProps as bm, PlusMemberProvider as bn, type UseIntersectionOptions as bo, useIntersection as bp, type UseExposureOptions as bq, useExposure as br, type GeoLocationData as bs, type LocaleMapping as bt, type UseGeoLocationOptions as bu, useGeoLocation as bv, getCachedGeoLocation as bw, clearGeoLocationCache as bx, type Attribute as by, type Discount as bz, useRemoveCartLines as c, type ApplyCartCodesInput as d, useApplyCartCodes as e, type RemoveCartCodesInput as f, useRemoveCartCodes as g, useUpdateCartAttributes as h, type UseBuyNowOptions as i, useBuyNow as j, useCalcAutoFreeGift as k, type UseCalcGiftsFromLinesOptions as l, type UseCalcGiftsFromLinesResult as m, useCalcGiftsFromLines as n, useCalcOrderDiscount as o, getReferralAttributes as p, useCartAttributes as q, useCartItemQuantityLimit as r, type UseScriptAutoFreeGiftResult as s, useScriptAutoFreeGift as t, useCreateCart as u, useUpdateLineCodeAmountAttributes as v, type AutoFreeGift as w, type AutoFreeGiftMainProduct as x, type AutoFreeGiftConfig as y, type RuleCondition as z };
@@ -1,6 +1,7 @@
1
1
  import * as swr_mutation from 'swr/mutation';
2
2
  import { SWRMutationConfiguration } from 'swr/mutation';
3
- import { CartLineInput as CartLineInput$1, NormalizedCart, UpdateCartLinesOptions, HasMetafieldsIdentifier, NormalizedProduct, NormalizedProductVariant, NormalizedLineItem, Media, NormalizedCollection, CollectionsConnection, NormalizedBlog, NormalizedArticle } from '@anker-in/shopify-sdk';
3
+ import * as _anker_in_shopify_sdk from '@anker-in/shopify-sdk';
4
+ import { CartLineInput as CartLineInput$1, NormalizedCart, UpdateCartLinesOptions, HasMetafieldsIdentifier, NormalizedProduct, NormalizedProductVariant, NormalizedLineItem, Attribute as Attribute$1, Media, NormalizedCollection, CollectionsConnection, NormalizedBlog, NormalizedArticle } from '@anker-in/shopify-sdk';
4
5
  import { A as AddToCartLineItem, G as GtmParams, B as BuyNowTrackConfig, d as PlusMemberShippingMethodConfig, e as PlusMemberSettingsMetafields, D as DeliveryPlusType, f as SelectedPlusMemberProduct, i as DeliveryData } from './types-CICUnw0v.js';
5
6
  import Decimal from 'decimal.js';
6
7
  import * as swr from 'swr';
@@ -427,8 +428,108 @@ type AutoFreeGiftList = AutoFreeGiftItem[] | [];
427
428
  * 此 Hook 不产生任何副作用。
428
429
  * 使用示例:
429
430
  * const { qualifyingGift, nextTierGoal, activeCampaign, isLoading } = useCalcAutoFreeGift(cart, autoFreeGiftConfig);
431
+ *
432
+ * 也可以传入 lines 参数来计算加购前的赠品:
433
+ * const { qualifyingGift, nextTierGoal, activeCampaign, isLoading } = useCalcAutoFreeGift(cart, autoFreeGiftConfig, customer, lines);
430
434
  */
431
- declare const useCalcAutoFreeGift: (cart: any, autoFreeGiftConfig: AutoFreeGiftConfig, customer: any) => FunctionGiftResult;
435
+ declare const useCalcAutoFreeGift: (cart: any, autoFreeGiftConfig: AutoFreeGiftConfig, customer: any, lines?: AddToCartLineItem[]) => FunctionGiftResult;
436
+
437
+ interface GiveawayProduct {
438
+ handle: string;
439
+ sku: string;
440
+ }
441
+ interface Breakpoint {
442
+ breakpoint: string;
443
+ giveawayProducts: GiveawayProduct[];
444
+ }
445
+ interface Campaign {
446
+ activityAvailableQuery?: string;
447
+ activityQroperty?: string;
448
+ breakpoints?: Array<{
449
+ breakpoint: string;
450
+ giveawayProducts: GiveawayProduct[];
451
+ }>;
452
+ includeTags?: string[];
453
+ useTotalAmount?: boolean;
454
+ }
455
+ interface UseScriptAutoFreeGiftResult {
456
+ involvedLines: NormalizedLineItem[];
457
+ reorder: (a: NormalizedLineItem, b: NormalizedLineItem) => number;
458
+ disableCodeRemove: boolean;
459
+ nextFreeGiftLevel: Breakpoint | null;
460
+ freeGiftLevel: Breakpoint | null;
461
+ involvedSubTotal: Decimal;
462
+ giftProductsResult?: NormalizedProduct[];
463
+ }
464
+ declare const useScriptAutoFreeGift: ({ campaign, _giveaway, cart, locale: providedLocale, lines, }: {
465
+ campaign: Campaign | null;
466
+ _giveaway: string;
467
+ cart: NormalizedCart | undefined;
468
+ locale?: string;
469
+ lines?: AddToCartLineItem[];
470
+ }) => UseScriptAutoFreeGiftResult;
471
+
472
+ interface UseCalcGiftsFromLinesOptions {
473
+ /** Lines to calculate gifts from (AddToCartLineItem format) */
474
+ lines: AddToCartLineItem[];
475
+ /** Auto free gift configuration (Function gift) */
476
+ autoFreeGiftConfig?: AutoFreeGiftConfig;
477
+ /** Customer information (required for function gift) */
478
+ customer?: any;
479
+ /** Script gift campaign configuration */
480
+ scriptCampaign?: any;
481
+ /** Script giveaway attribute key */
482
+ scriptGiveawayKey?: string;
483
+ /** Locale for product fetching (optional, will use from ShopifyProvider if not provided) */
484
+ locale?: string;
485
+ }
486
+ interface UseCalcGiftsFromLinesResult {
487
+ /** Function gift calculation result */
488
+ functionGift: FunctionGiftResult;
489
+ /** Script gift calculation result */
490
+ scriptGift: UseScriptAutoFreeGiftResult;
491
+ /** All gift lines that need to be added to cart (combined from both) */
492
+ allGiftLines: CartLineInput[];
493
+ /** Whether any gifts are available */
494
+ hasGifts: boolean;
495
+ }
496
+ /**
497
+ * Calculate gifts from AddToCartLineItem[] before adding to cart
498
+ * Supports both function-based gifts (useCalcAutoFreeGift) and script-based gifts (useScriptAutoFreeGift)
499
+ *
500
+ * Automatically uses locale from ShopifyProvider and cart from CartContext if not provided.
501
+ *
502
+ * @example
503
+ * ```tsx
504
+ * // Basic usage (locale from context, customer required for function gift)
505
+ * const { allGiftLines, hasGifts } = useCalcGiftsFromLines({
506
+ * lines: [{ variant: myVariant, quantity: 2 }],
507
+ * customer: currentCustomer,
508
+ * autoFreeGiftConfig: functionGiftConfig,
509
+ * scriptCampaign: scriptGiftConfig,
510
+ * })
511
+ *
512
+ * // Script gift only (no customer needed)
513
+ * const { allGiftLines, hasGifts } = useCalcGiftsFromLines({
514
+ * lines: [{ variant: myVariant, quantity: 2 }],
515
+ * scriptCampaign: scriptGiftConfig,
516
+ * })
517
+ *
518
+ * // With custom locale
519
+ * const { allGiftLines, hasGifts } = useCalcGiftsFromLines({
520
+ * lines: [{ variant: myVariant, quantity: 2 }],
521
+ * customer: currentCustomer,
522
+ * locale: 'fr',
523
+ * autoFreeGiftConfig: functionGiftConfig,
524
+ * })
525
+ *
526
+ * // Then add both products and gifts to cart
527
+ * await addToCart({
528
+ * lineItems: [...lines, ...allGiftLines]
529
+ * })
530
+ * ```
531
+ */
532
+ declare function useCalcGiftsFromLines({ lines, customer, scriptGiveawayKey, }: UseCalcGiftsFromLinesOptions): UseCalcGiftsFromLinesResult;
432
533
 
433
534
  declare enum OrderDiscountType {
434
535
  PERCENTAGE = 1,// 百分比折扣
@@ -896,11 +997,55 @@ interface HasPlusMemberInCartResult {
896
997
  */
897
998
  declare function useHasPlusMemberInCart({ memberSetting, cart, }: UseHasPlusMemberInCartProps): HasPlusMemberInCartResult;
898
999
 
1000
+ interface UseAddPlusMemberProductsToCartProps {
1001
+ /** 购物车数据 */
1002
+ cart?: NormalizedCart;
1003
+ /** Plus Member 配置 */
1004
+ memberSetting?: PlusMemberSettingsMetafields;
1005
+ /** 选中的会员模式 */
1006
+ selectedPlusMemberMode: DeliveryPlusType;
1007
+ /** 选中的会员产品 */
1008
+ selectedPlusMemberProduct?: SelectedPlusMemberProduct;
1009
+ }
1010
+ /**
1011
+ * 返回需要添加到购物车的 Plus Member 产品
1012
+ *
1013
+ * 该 hook 会根据用户选择的会员模式和购物车现有状态,
1014
+ * 返回需要添加的会员产品。如果不需要添加会员产品,则返回 undefined。
1015
+ *
1016
+ * @param props - Hook 参数
1017
+ * @param props.cart - 购物车数据
1018
+ * @param props.memberSetting - Plus Member 配置
1019
+ * @param props.selectedPlusMemberMode - 选中的会员模式
1020
+ * @param props.selectedPlusMemberProduct - 选中的会员产品
1021
+ * @returns Plus Member 产品对象或 undefined
1022
+ *
1023
+ * @example
1024
+ * ```tsx
1025
+ * const plusMemberProduct = useAddPlusMemberProductsToCart({
1026
+ * cart,
1027
+ * memberSetting,
1028
+ * selectedPlusMemberMode: DeliveryPlusType.MONTHLY,
1029
+ * selectedPlusMemberProduct: { product, variant },
1030
+ * })
1031
+ *
1032
+ * // plusMemberProduct 格式:
1033
+ * // {
1034
+ * // product: NormalizedProduct,
1035
+ * // variant: NormalizedProductVariant
1036
+ * // }
1037
+ * // 或 undefined (当不需要添加会员产品时)
1038
+ * ```
1039
+ */
1040
+ declare function useAddPlusMemberProductsToCart({ cart, memberSetting, selectedPlusMemberMode, selectedPlusMemberProduct, }: UseAddPlusMemberProductsToCartProps): {
1041
+ product: _anker_in_shopify_sdk.NormalizedProduct;
1042
+ variant: _anker_in_shopify_sdk.NormalizedProductVariant;
1043
+ } | undefined;
1044
+
899
1045
  interface PlusMemberProviderProps<TProduct = any, TVariant = any, TProfile = any> {
900
1046
  variant: TVariant;
901
1047
  product: TProduct;
902
- metafields: PlusMemberSettingsMetafields;
903
- shopCommon?: Record<string, any>;
1048
+ memberSetting: PlusMemberSettingsMetafields;
904
1049
  initialSelectedPlusMemberMode?: DeliveryPlusType;
905
1050
  profile?: TProfile;
906
1051
  locale?: string;
@@ -913,7 +1058,6 @@ interface PlusMemberProviderProps<TProduct = any, TVariant = any, TProfile = any
913
1058
  * @param variant - Product variant
914
1059
  * @param product - Product
915
1060
  * @param metafields - Plus member settings from metafields
916
- * @param shopCommon - Shop common settings
917
1061
  * @param initialSelectedPlusMemberMode - Initial selected mode (default: 'free')
918
1062
  * @param profile - User profile
919
1063
  * @param locale - Locale code
@@ -924,8 +1068,7 @@ interface PlusMemberProviderProps<TProduct = any, TVariant = any, TProfile = any
924
1068
  * <PlusMemberProvider
925
1069
  * variant={variant}
926
1070
  * product={product}
927
- * metafields={memberSettings}
928
- * shopCommon={shopCommon}
1071
+ * memberSetting={memberSetting}
929
1072
  * profile={profile}
930
1073
  * locale={locale}
931
1074
  * >
@@ -933,7 +1076,7 @@ interface PlusMemberProviderProps<TProduct = any, TVariant = any, TProfile = any
933
1076
  * </PlusMemberProvider>
934
1077
  * ```
935
1078
  */
936
- declare const PlusMemberProvider: <TProduct = any, TVariant = any, TProfile = any>({ variant, product, shopCommon, metafields, initialSelectedPlusMemberMode, profile, locale, children, }: PropsWithChildren<PlusMemberProviderProps<TProduct, TVariant, TProfile>>) => react_jsx_runtime.JSX.Element;
1079
+ declare const PlusMemberProvider: <TProduct = any, TVariant = any, TProfile = any>({ variant, product, memberSetting, initialSelectedPlusMemberMode, profile, locale, children, }: PropsWithChildren<PlusMemberProviderProps<TProduct, TVariant, TProfile>>) => react_jsx_runtime.JSX.Element;
937
1080
 
938
1081
  declare const getReferralAttributes: () => {
939
1082
  key: string;
@@ -969,40 +1112,6 @@ declare const useCartItemQuantityLimit: ({ cart, cartItem, config, }: {
969
1112
  max: number;
970
1113
  };
971
1114
 
972
- interface GiveawayProduct {
973
- handle: string;
974
- sku: string;
975
- }
976
- interface Breakpoint {
977
- breakpoint: string;
978
- giveawayProducts: GiveawayProduct[];
979
- }
980
- interface Campaign {
981
- activityAvailableQuery?: string;
982
- activityQroperty?: string;
983
- breakpoints?: Array<{
984
- breakpoint: string;
985
- giveawayProducts: GiveawayProduct[];
986
- }>;
987
- includeTags?: string[];
988
- useTotalAmount?: boolean;
989
- }
990
- interface UseScriptAutoFreeGiftResult {
991
- involvedLines: NormalizedLineItem[];
992
- reorder: (a: NormalizedLineItem, b: NormalizedLineItem) => number;
993
- disableCodeRemove: boolean;
994
- nextFreeGiftLevel: Breakpoint | null;
995
- freeGiftLevel: Breakpoint | null;
996
- involvedSubTotal: Decimal;
997
- giftProductsResult?: NormalizedProduct[];
998
- }
999
- declare const useScriptAutoFreeGift: ({ campaign, _giveaway, cart, locale: providedLocale, }: {
1000
- campaign: Campaign | null;
1001
- _giveaway: string;
1002
- cart: NormalizedCart | undefined;
1003
- locale?: string;
1004
- }) => UseScriptAutoFreeGiftResult;
1005
-
1006
1115
  declare const useUpdateLineCodeAmountAttributes: ({ cart, mutateCart, isCartLoading, setLoadingState, metafieldIdentifiers, }: {
1007
1116
  cart?: NormalizedCart;
1008
1117
  mutateCart: (cart: NormalizedCart | undefined) => void;
@@ -1044,23 +1153,30 @@ declare const CODE_AMOUNT_KEY = "_sku_code_money";
1044
1153
  declare const SCRIPT_CODE_AMOUNT_KEY = "_code_money";
1045
1154
  declare const MAIN_PRODUCT_CODE: string[];
1046
1155
 
1156
+ /**
1157
+ * Normalize AddToCartLineItem[] to NormalizedLineItem[] format
1158
+ * This is used to calculate gifts from lines before they are added to cart
1159
+ */
1160
+ declare function normalizeAddToCartLines(lines: AddToCartLineItem[]): NormalizedLineItem[];
1161
+ /**
1162
+ * Create a mock cart structure from AddToCartLineItem[]
1163
+ * This is useful for calculating gifts before actual cart operations
1164
+ */
1165
+ declare function createMockCartFromLines(lines: AddToCartLineItem[], existingCart?: any): any;
1166
+
1047
1167
  declare const getQuery: () => Record<string, string>;
1048
1168
  declare function atobID(id: string): string | undefined;
1049
1169
  declare function btoaID(id: string, type?: 'ProductVariant' | 'Product'): string;
1050
1170
 
1051
1171
  declare const getMatchedMainProductSubTotal: (cartData: any, variant_list: AutoFreeGiftMainProduct["variant_id_list"], main_product: AutoFreeGiftMainProduct) => any;
1172
+ declare const safeParse: (str: string) => any;
1052
1173
  declare const getDiscountEnvAttributeValue: (attributes?: {
1053
1174
  key: string;
1054
1175
  value: string;
1055
1176
  }[]) => any;
1056
- declare const isAttributesEqual: (attrs1?: {
1177
+ declare const checkAttributesUpdateNeeded: (oldAttributes: Attribute$1[], newAttributes: Attribute$1[], customAttributesNeedRemove: {
1057
1178
  key: string;
1058
- value: string;
1059
- }[], attrs2?: {
1060
- key: string;
1061
- value: string;
1062
1179
  }[]) => boolean;
1063
- declare const safeParseJson: (str: string) => any;
1064
1180
  declare function preCheck(rule_conditions: RuleCondition[], userTags: string[], currentDealsTypes: string[]): boolean;
1065
1181
  declare const formatScriptAutoFreeGift: ({ scriptAutoFreeGiftResult, gradient_gifts, locale, }: {
1066
1182
  scriptAutoFreeGiftResult: UseScriptAutoFreeGiftResult;
@@ -1847,4 +1963,4 @@ declare function getCachedGeoLocation(cacheKey?: string): GeoLocationData | unde
1847
1963
  */
1848
1964
  declare function clearGeoLocationCache(cacheKey?: string): void;
1849
1965
 
1850
- export { defaultSWRMutationConfiguration as $, type AddCartLinesInput as A, type BuyNowInput as B, type CreateCartInput as C, type DiscountLabel as D, type GiftProductItem as E, RuleType as F, type GiftProduct as G, BuyRuleType as H, type FunctionGiftResult as I, type FormattedGift as J, type CartLineInput as K, type AutoFreeGiftItem as L, type MainProductInfo as M, type AutoFreeGiftList as N, type OrderDiscountResult as O, OrderDiscountType as P, OrderBasePriceType as Q, type RemoveCartLinesInput as R, SpendMoneyType as S, type TieredDiscount as T, type UpdateCartAttributesInput as U, type VariantItem as V, type OrderDiscountConfig as W, PriceDiscountType as X, PriceBasePriceType as Y, type PriceDiscountConfig as Z, currencyCodeMapping as _, useAddCartLines as a, usePlusAnnualProductVariant as a$, CUSTOMER_ATTRIBUTE_KEY as a0, CUSTOMER_SCRIPT_GIFT_KEY as a1, CODE_AMOUNT_KEY as a2, SCRIPT_CODE_AMOUNT_KEY as a3, MAIN_PRODUCT_CODE as a4, getQuery as a5, atobID as a6, btoaID as a7, getMatchedMainProductSubTotal as a8, getDiscountEnvAttributeValue as a9, type UseAllCollectionsOptions as aA, useAllCollections as aB, type UseCollectionsOptions as aC, useCollections as aD, type UseBlogOptions as aE, useBlog as aF, type UseAllBlogsOptions as aG, useAllBlogs as aH, type UseArticleOptions as aI, useArticle as aJ, type UseArticlesOptions as aK, useArticles as aL, type UseArticlesInBlogOptions as aM, useArticlesInBlog as aN, type SearchResultType as aO, type SearchResultItem as aP, type SearchResult as aQ, type UseSearchOptions as aR, useSearch as aS, type SiteInfo as aT, type UseSiteOptions as aU, useSite as aV, type ShippingMethodsContext as aW, type PlusMemberContextValue as aX, PlusMemberContext as aY, usePlusMemberContext as aZ, usePlusMonthlyProductVariant as a_, isAttributesEqual as aa, safeParseJson as ab, preCheck as ac, formatScriptAutoFreeGift as ad, formatFunctionAutoFreeGift as ae, useSelectedOptions as af, type SelectedOptionsResult as ag, type UseProductOptions as ah, useProduct as ai, type UseAllProductsOptions as aj, useAllProducts as ak, type UseProductsByHandlesOptions as al, useProductsByHandles as am, type Options as an, useVariant as ao, type UsePriceOptions as ap, type UsePriceResult as aq, usePrice as ar, useProductUrl as as, useUpdateVariantQuery as at, type ImageMedia as au, type VideoMedia as av, type VariantMedia as aw, useVariantMedia as ax, type UseCollectionOptions as ay, useCollection as az, useUpdateCartLines as b, type UseShippingMethodsOptions as b0, type UseShippingMethodsResult as b1, useShippingMethods as b2, useShippingMethodAvailableCheck as b3, useReplaceCartPlusMember as b4, usePlusMemberDeliveryCodes as b5, usePlusMemberItemCustomAttributes as b6, type CustomerOrder as b7, type Customer as b8, usePlusMemberCheckoutCustomAttributes as b9, type ExportCart as bA, type UseAutoRemovePlusMemberInCartProps as ba, useAutoRemovePlusMemberInCart as bb, type UseHasPlusMemberInCartProps as bc, type HasPlusMemberInCartResult as bd, useHasPlusMemberInCart as be, type PlusMemberProviderProps as bf, PlusMemberProvider as bg, type UseIntersectionOptions as bh, useIntersection as bi, type UseExposureOptions as bj, useExposure as bk, type GeoLocationData as bl, type LocaleMapping as bm, type UseGeoLocationOptions as bn, useGeoLocation as bo, getCachedGeoLocation as bp, clearGeoLocationCache as bq, type Attribute as br, type Discount as bs, type Image as bt, type Measurement as bu, type ExportSelectedOption as bv, type ExportProductVariant as bw, type ExportDiscountAllocations as bx, type ExportLineItem as by, type ExportDiscounts as bz, useRemoveCartLines as c, type ApplyCartCodesInput as d, useApplyCartCodes as e, type RemoveCartCodesInput as f, useRemoveCartCodes as g, useUpdateCartAttributes as h, type UseBuyNowOptions as i, useBuyNow as j, useCalcAutoFreeGift as k, useCalcOrderDiscount as l, getReferralAttributes as m, useCartAttributes as n, useCartItemQuantityLimit as o, type UseScriptAutoFreeGiftResult as p, useScriptAutoFreeGift as q, useUpdateLineCodeAmountAttributes as r, type AutoFreeGift as s, type AutoFreeGiftMainProduct as t, useCreateCart as u, type AutoFreeGiftConfig as v, type RuleCondition as w, type Config as x, type GiftTier as y, type RewardItem as z };
1966
+ export { PriceBasePriceType as $, type AddCartLinesInput as A, type BuyNowInput as B, type CreateCartInput as C, type DiscountLabel as D, type Config as E, type GiftTier as F, type GiftProduct as G, type RewardItem as H, type GiftProductItem as I, RuleType as J, BuyRuleType as K, type FunctionGiftResult as L, type MainProductInfo as M, type FormattedGift as N, type OrderDiscountResult as O, type CartLineInput as P, type AutoFreeGiftItem as Q, type RemoveCartLinesInput as R, SpendMoneyType as S, type AutoFreeGiftList as T, type UpdateCartAttributesInput as U, type VariantItem as V, OrderDiscountType as W, OrderBasePriceType as X, type TieredDiscount as Y, type OrderDiscountConfig as Z, PriceDiscountType as _, useAddCartLines as a, type ShippingMethodsContext as a$, type PriceDiscountConfig as a0, currencyCodeMapping as a1, defaultSWRMutationConfiguration as a2, CUSTOMER_ATTRIBUTE_KEY as a3, CUSTOMER_SCRIPT_GIFT_KEY as a4, CODE_AMOUNT_KEY as a5, SCRIPT_CODE_AMOUNT_KEY as a6, MAIN_PRODUCT_CODE as a7, getQuery as a8, atobID as a9, type VideoMedia as aA, type VariantMedia as aB, useVariantMedia as aC, type UseCollectionOptions as aD, useCollection as aE, type UseAllCollectionsOptions as aF, useAllCollections as aG, type UseCollectionsOptions as aH, useCollections as aI, type UseBlogOptions as aJ, useBlog as aK, type UseAllBlogsOptions as aL, useAllBlogs as aM, type UseArticleOptions as aN, useArticle as aO, type UseArticlesOptions as aP, useArticles as aQ, type UseArticlesInBlogOptions as aR, useArticlesInBlog as aS, type SearchResultType as aT, type SearchResultItem as aU, type SearchResult as aV, type UseSearchOptions as aW, useSearch as aX, type SiteInfo as aY, type UseSiteOptions as aZ, useSite as a_, btoaID as aa, normalizeAddToCartLines as ab, createMockCartFromLines as ac, getMatchedMainProductSubTotal as ad, safeParse as ae, getDiscountEnvAttributeValue as af, checkAttributesUpdateNeeded as ag, preCheck as ah, formatScriptAutoFreeGift as ai, formatFunctionAutoFreeGift as aj, useSelectedOptions as ak, type SelectedOptionsResult as al, type UseProductOptions as am, useProduct as an, type UseAllProductsOptions as ao, useAllProducts as ap, type UseProductsByHandlesOptions as aq, useProductsByHandles as ar, type Options as as, useVariant as at, type UsePriceOptions as au, type UsePriceResult as av, usePrice as aw, useProductUrl as ax, useUpdateVariantQuery as ay, type ImageMedia as az, useUpdateCartLines as b, type PlusMemberContextValue as b0, PlusMemberContext as b1, usePlusMemberContext as b2, usePlusMonthlyProductVariant as b3, usePlusAnnualProductVariant as b4, type UseShippingMethodsOptions as b5, type UseShippingMethodsResult as b6, useShippingMethods as b7, useShippingMethodAvailableCheck as b8, useReplaceCartPlusMember as b9, type Image as bA, type Measurement as bB, type ExportSelectedOption as bC, type ExportProductVariant as bD, type ExportDiscountAllocations as bE, type ExportLineItem as bF, type ExportDiscounts as bG, type ExportCart as bH, usePlusMemberDeliveryCodes as ba, usePlusMemberItemCustomAttributes as bb, type CustomerOrder as bc, type Customer as bd, usePlusMemberCheckoutCustomAttributes as be, type UseAutoRemovePlusMemberInCartProps as bf, useAutoRemovePlusMemberInCart as bg, type UseHasPlusMemberInCartProps as bh, type HasPlusMemberInCartResult as bi, useHasPlusMemberInCart as bj, type UseAddPlusMemberProductsToCartProps as bk, useAddPlusMemberProductsToCart as bl, type PlusMemberProviderProps as bm, PlusMemberProvider as bn, type UseIntersectionOptions as bo, useIntersection as bp, type UseExposureOptions as bq, useExposure as br, type GeoLocationData as bs, type LocaleMapping as bt, type UseGeoLocationOptions as bu, useGeoLocation as bv, getCachedGeoLocation as bw, clearGeoLocationCache as bx, type Attribute as by, type Discount as bz, useRemoveCartLines as c, type ApplyCartCodesInput as d, useApplyCartCodes as e, type RemoveCartCodesInput as f, useRemoveCartCodes as g, useUpdateCartAttributes as h, type UseBuyNowOptions as i, useBuyNow as j, useCalcAutoFreeGift as k, type UseCalcGiftsFromLinesOptions as l, type UseCalcGiftsFromLinesResult as m, useCalcGiftsFromLines as n, useCalcOrderDiscount as o, getReferralAttributes as p, useCartAttributes as q, useCartItemQuantityLimit as r, type UseScriptAutoFreeGiftResult as s, useScriptAutoFreeGift as t, useCreateCart as u, useUpdateLineCodeAmountAttributes as v, type AutoFreeGift as w, type AutoFreeGiftMainProduct as x, type AutoFreeGiftConfig as y, type RuleCondition as z };
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { AttributeInput, CartContextValue, CartProvider, CartProviderProps, LoadingState, ShopifyContext, ShopifyContextValue, ShopifyProvider, ShopifyProviderProps, useCartContext, useShopify } from './provider/index.mjs';
2
2
  export { b as CartCookieAdapter, C as CookieAdapter, a as CookieOptions, R as RouterAdapter, U as UserContextAdapter } from './types-BLMoxbOk.mjs';
3
3
  export { browserCartCookieAdapter, browserCookieAdapter } from './adapters/index.mjs';
4
- export { A as AddCartLinesInput, d as ApplyCartCodesInput, br as Attribute, s as AutoFreeGift, v as AutoFreeGiftConfig, L as AutoFreeGiftItem, N as AutoFreeGiftList, t as AutoFreeGiftMainProduct, B as BuyNowInput, H as BuyRuleType, a2 as CODE_AMOUNT_KEY, a0 as CUSTOMER_ATTRIBUTE_KEY, a1 as CUSTOMER_SCRIPT_GIFT_KEY, K as CartLineInput, x as Config, C as CreateCartInput, b8 as Customer, b7 as CustomerOrder, bs as Discount, D as DiscountLabel, bA as ExportCart, bx as ExportDiscountAllocations, bz as ExportDiscounts, by as ExportLineItem, bw as ExportProductVariant, bv as ExportSelectedOption, J as FormattedGift, I as FunctionGiftResult, bl as GeoLocationData, G as GiftProduct, E as GiftProductItem, y as GiftTier, bd as HasPlusMemberInCartResult, bt as Image, au as ImageMedia, bm as LocaleMapping, a4 as MAIN_PRODUCT_CODE, M as MainProductInfo, bu as Measurement, an as Options, Q as OrderBasePriceType, W as OrderDiscountConfig, O as OrderDiscountResult, P as OrderDiscountType, aY as PlusMemberContext, aX as PlusMemberContextValue, bg as PlusMemberProvider, bf as PlusMemberProviderProps, Y as PriceBasePriceType, Z as PriceDiscountConfig, X as PriceDiscountType, f as RemoveCartCodesInput, R as RemoveCartLinesInput, z as RewardItem, w as RuleCondition, F as RuleType, a3 as SCRIPT_CODE_AMOUNT_KEY, aQ as SearchResult, aP as SearchResultItem, aO as SearchResultType, ag as SelectedOptionsResult, aW as ShippingMethodsContext, aT as SiteInfo, S as SpendMoneyType, T as TieredDiscount, U as UpdateCartAttributesInput, aG as UseAllBlogsOptions, aA as UseAllCollectionsOptions, aj as UseAllProductsOptions, aI as UseArticleOptions, aM as UseArticlesInBlogOptions, aK as UseArticlesOptions, ba as UseAutoRemovePlusMemberInCartProps, aE as UseBlogOptions, i as UseBuyNowOptions, ay as UseCollectionOptions, aC as UseCollectionsOptions, bj as UseExposureOptions, bn as UseGeoLocationOptions, bc as UseHasPlusMemberInCartProps, bh as UseIntersectionOptions, ap as UsePriceOptions, aq as UsePriceResult, ah as UseProductOptions, al as UseProductsByHandlesOptions, p as UseScriptAutoFreeGiftResult, aR as UseSearchOptions, b0 as UseShippingMethodsOptions, b1 as UseShippingMethodsResult, aU as UseSiteOptions, V as VariantItem, aw as VariantMedia, av as VideoMedia, a6 as atobID, a7 as btoaID, bq as clearGeoLocationCache, _ as currencyCodeMapping, $ as defaultSWRMutationConfiguration, ae as formatFunctionAutoFreeGift, ad as formatScriptAutoFreeGift, bp as getCachedGeoLocation, a9 as getDiscountEnvAttributeValue, a8 as getMatchedMainProductSubTotal, a5 as getQuery, m as getReferralAttributes, aa as isAttributesEqual, ac as preCheck, ab as safeParseJson, a as useAddCartLines, aH as useAllBlogs, aB as useAllCollections, ak as useAllProducts, e as useApplyCartCodes, aJ as useArticle, aL as useArticles, aN as useArticlesInBlog, bb as useAutoRemovePlusMemberInCart, aF as useBlog, j as useBuyNow, k as useCalcAutoFreeGift, l as useCalcOrderDiscount, n as useCartAttributes, o as useCartItemQuantityLimit, az as useCollection, aD as useCollections, u as useCreateCart, bk as useExposure, bo as useGeoLocation, be as useHasPlusMemberInCart, bi as useIntersection, a$ as usePlusAnnualProductVariant, b9 as usePlusMemberCheckoutCustomAttributes, aZ as usePlusMemberContext, b5 as usePlusMemberDeliveryCodes, b6 as usePlusMemberItemCustomAttributes, a_ as usePlusMonthlyProductVariant, ar as usePrice, ai as useProduct, as as useProductUrl, am as useProductsByHandles, g as useRemoveCartCodes, c as useRemoveCartLines, b4 as useReplaceCartPlusMember, q as useScriptAutoFreeGift, aS as useSearch, af as useSelectedOptions, b3 as useShippingMethodAvailableCheck, b2 as useShippingMethods, aV as useSite, h as useUpdateCartAttributes, b as useUpdateCartLines, r as useUpdateLineCodeAmountAttributes, at as useUpdateVariantQuery, ao as useVariant, ax as useVariantMedia } from './index-RevQokdZ.mjs';
4
+ export { A as AddCartLinesInput, d as ApplyCartCodesInput, by as Attribute, w as AutoFreeGift, y as AutoFreeGiftConfig, Q as AutoFreeGiftItem, T as AutoFreeGiftList, x as AutoFreeGiftMainProduct, B as BuyNowInput, K as BuyRuleType, a5 as CODE_AMOUNT_KEY, a3 as CUSTOMER_ATTRIBUTE_KEY, a4 as CUSTOMER_SCRIPT_GIFT_KEY, P as CartLineInput, E as Config, C as CreateCartInput, bd as Customer, bc as CustomerOrder, bz as Discount, D as DiscountLabel, bH as ExportCart, bE as ExportDiscountAllocations, bG as ExportDiscounts, bF as ExportLineItem, bD as ExportProductVariant, bC as ExportSelectedOption, N as FormattedGift, L as FunctionGiftResult, bs as GeoLocationData, G as GiftProduct, I as GiftProductItem, F as GiftTier, bi as HasPlusMemberInCartResult, bA as Image, az as ImageMedia, bt as LocaleMapping, a7 as MAIN_PRODUCT_CODE, M as MainProductInfo, bB as Measurement, as as Options, X as OrderBasePriceType, Z as OrderDiscountConfig, O as OrderDiscountResult, W as OrderDiscountType, b1 as PlusMemberContext, b0 as PlusMemberContextValue, bn as PlusMemberProvider, bm as PlusMemberProviderProps, $ as PriceBasePriceType, a0 as PriceDiscountConfig, _ as PriceDiscountType, f as RemoveCartCodesInput, R as RemoveCartLinesInput, H as RewardItem, z as RuleCondition, J as RuleType, a6 as SCRIPT_CODE_AMOUNT_KEY, aV as SearchResult, aU as SearchResultItem, aT as SearchResultType, al as SelectedOptionsResult, a$ as ShippingMethodsContext, aY as SiteInfo, S as SpendMoneyType, Y as TieredDiscount, U as UpdateCartAttributesInput, bk as UseAddPlusMemberProductsToCartProps, aL as UseAllBlogsOptions, aF as UseAllCollectionsOptions, ao as UseAllProductsOptions, aN as UseArticleOptions, aR as UseArticlesInBlogOptions, aP as UseArticlesOptions, bf as UseAutoRemovePlusMemberInCartProps, aJ as UseBlogOptions, i as UseBuyNowOptions, l as UseCalcGiftsFromLinesOptions, m as UseCalcGiftsFromLinesResult, aD as UseCollectionOptions, aH as UseCollectionsOptions, bq as UseExposureOptions, bu as UseGeoLocationOptions, bh as UseHasPlusMemberInCartProps, bo as UseIntersectionOptions, au as UsePriceOptions, av as UsePriceResult, am as UseProductOptions, aq as UseProductsByHandlesOptions, s as UseScriptAutoFreeGiftResult, aW as UseSearchOptions, b5 as UseShippingMethodsOptions, b6 as UseShippingMethodsResult, aZ as UseSiteOptions, V as VariantItem, aB as VariantMedia, aA as VideoMedia, a9 as atobID, aa as btoaID, ag as checkAttributesUpdateNeeded, bx as clearGeoLocationCache, ac as createMockCartFromLines, a1 as currencyCodeMapping, a2 as defaultSWRMutationConfiguration, aj as formatFunctionAutoFreeGift, ai as formatScriptAutoFreeGift, bw as getCachedGeoLocation, af as getDiscountEnvAttributeValue, ad as getMatchedMainProductSubTotal, a8 as getQuery, p as getReferralAttributes, ab as normalizeAddToCartLines, ah as preCheck, ae as safeParse, a as useAddCartLines, bl as useAddPlusMemberProductsToCart, aM as useAllBlogs, aG as useAllCollections, ap as useAllProducts, e as useApplyCartCodes, aO as useArticle, aQ as useArticles, aS as useArticlesInBlog, bg as useAutoRemovePlusMemberInCart, aK as useBlog, j as useBuyNow, k as useCalcAutoFreeGift, n as useCalcGiftsFromLines, o as useCalcOrderDiscount, q as useCartAttributes, r as useCartItemQuantityLimit, aE as useCollection, aI as useCollections, u as useCreateCart, br as useExposure, bv as useGeoLocation, bj as useHasPlusMemberInCart, bp as useIntersection, b4 as usePlusAnnualProductVariant, be as usePlusMemberCheckoutCustomAttributes, b2 as usePlusMemberContext, ba as usePlusMemberDeliveryCodes, bb as usePlusMemberItemCustomAttributes, b3 as usePlusMonthlyProductVariant, aw as usePrice, an as useProduct, ax as useProductUrl, ar as useProductsByHandles, g as useRemoveCartCodes, c as useRemoveCartLines, b9 as useReplaceCartPlusMember, t as useScriptAutoFreeGift, aX as useSearch, ak as useSelectedOptions, b8 as useShippingMethodAvailableCheck, b7 as useShippingMethods, a_ as useSite, h as useUpdateCartAttributes, b as useUpdateCartLines, v as useUpdateLineCodeAmountAttributes, ay as useUpdateVariantQuery, at as useVariant, aC as useVariantMedia } from './index-Utuz9i5x.mjs';
5
5
  export { a as AddToCartInput, A as AddToCartLineItem, B as BuyNowTrackConfig, h as DeliveryCustomData, i as DeliveryData, g as DeliveryOption, D as DeliveryPlusType, G as GtmParams, M as MailingAddress, P as PLUS_MEMBER_TYPE, b as PlusMemberMode, e as PlusMemberSettingsMetafields, d as PlusMemberShippingMethodConfig, c as PlusMemberShippingMethodMetafields, f as SelectedPlusMemberProduct, S as ShippingMethodMode, U as UseAddToCartOptions, j as gaTrack, m as trackAddToCartFBQ, t as trackAddToCartGA, k as trackBeginCheckoutGA, n as trackBuyNowFBQ, l as trackBuyNowGA, u as useAddToCart } from './types-CICUnw0v.mjs';
6
6
  export { ShopifyConfig, clearLocalStorage, createShopifyClient, getLocalStorage, removeLocalStorage, setLocalStorage } from '@anker-in/shopify-sdk';
7
7
  import 'react';