@anker-in/shopify-react 0.1.1-beta.31 → 0.1.1-beta.33
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/adapters/index.d.mts +18 -3
- package/dist/adapters/index.d.ts +18 -3
- package/dist/adapters/index.js +15 -0
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/index.mjs +15 -1
- package/dist/adapters/index.mjs.map +1 -1
- package/dist/hooks/index.d.mts +3 -3
- package/dist/hooks/index.d.ts +3 -3
- package/dist/hooks/index.js +7 -6
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +7 -6
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +29 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -9
- package/dist/index.mjs.map +1 -1
- package/dist/provider/index.d.mts +4 -2
- package/dist/provider/index.d.ts +4 -2
- package/dist/provider/index.js +7 -5
- package/dist/provider/index.js.map +1 -1
- package/dist/provider/index.mjs +7 -5
- package/dist/provider/index.mjs.map +1 -1
- package/dist/{types-Dt0DUG00.d.mts → types-SKDHauqk.d.mts} +14 -1
- package/dist/{types-Dt0DUG00.d.ts → types-SKDHauqk.d.ts} +14 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -46,6 +46,20 @@ var browserCartCookieAdapter = {
|
|
|
46
46
|
Cookies5.remove(getCartCookieName(locale));
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
+
|
|
50
|
+
// src/adapters/browser-performance.ts
|
|
51
|
+
var BrowserPerformanceAdapter = class {
|
|
52
|
+
/**
|
|
53
|
+
* Start tracking a performance event
|
|
54
|
+
*/
|
|
55
|
+
addToCartStart() {
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* End tracking a performance event
|
|
59
|
+
*/
|
|
60
|
+
addToCartEnd() {
|
|
61
|
+
}
|
|
62
|
+
};
|
|
49
63
|
function ShopifyProvider({
|
|
50
64
|
config,
|
|
51
65
|
locale,
|
|
@@ -54,7 +68,8 @@ function ShopifyProvider({
|
|
|
54
68
|
cartCookieAdapter = browserCartCookieAdapter,
|
|
55
69
|
routerAdapter,
|
|
56
70
|
userAdapter,
|
|
57
|
-
children
|
|
71
|
+
children,
|
|
72
|
+
performanceAdapter
|
|
58
73
|
}) {
|
|
59
74
|
const client = useMemo(() => {
|
|
60
75
|
return createShopifyClient(config, locale);
|
|
@@ -68,7 +83,8 @@ function ShopifyProvider({
|
|
|
68
83
|
cookieAdapter,
|
|
69
84
|
cartCookieAdapter,
|
|
70
85
|
routerAdapter,
|
|
71
|
-
userAdapter
|
|
86
|
+
userAdapter,
|
|
87
|
+
performanceAdapter
|
|
72
88
|
};
|
|
73
89
|
}, [
|
|
74
90
|
client,
|
|
@@ -78,6 +94,7 @@ function ShopifyProvider({
|
|
|
78
94
|
cookieAdapter,
|
|
79
95
|
cartCookieAdapter,
|
|
80
96
|
routerAdapter,
|
|
97
|
+
performanceAdapter,
|
|
81
98
|
userAdapter
|
|
82
99
|
]);
|
|
83
100
|
return /* @__PURE__ */ jsx(ShopifyContext.Provider, { value, children });
|
|
@@ -438,7 +455,6 @@ var useCalcAutoFreeGift = (cart, autoFreeGiftConfig, customer, lines) => {
|
|
|
438
455
|
}
|
|
439
456
|
return cart;
|
|
440
457
|
}, [lines, cart]);
|
|
441
|
-
console.log("effectiveCart useCalcAutoFreeGift", effectiveCart);
|
|
442
458
|
const { activeCampaign, subtotal } = useMemo(() => {
|
|
443
459
|
for (const campaign of autoFreeGiftConfig) {
|
|
444
460
|
const { rule_conditions = [], rule_result } = campaign;
|
|
@@ -454,7 +470,6 @@ var useCalcAutoFreeGift = (cart, autoFreeGiftConfig, customer, lines) => {
|
|
|
454
470
|
all_store_variant: spend_get_reward.main_product?.all_store_variant || false
|
|
455
471
|
}
|
|
456
472
|
);
|
|
457
|
-
console.log("matchedSubtotal useCalcAutoFreeGift", matchedSubtotal);
|
|
458
473
|
if (matchedSubtotal > 0) {
|
|
459
474
|
return { activeCampaign: campaign, subtotal: matchedSubtotal };
|
|
460
475
|
}
|
|
@@ -1058,7 +1073,7 @@ var getLinesWithFunctionAttributes = (lineItems) => {
|
|
|
1058
1073
|
|
|
1059
1074
|
// src/hooks/cart/use-add-to-cart.ts
|
|
1060
1075
|
function useAddToCart({ withTrack = true } = {}, swrOptions) {
|
|
1061
|
-
const { client, config, locale, cartCookieAdapter, userAdapter } = useShopify();
|
|
1076
|
+
const { client, config, locale, cartCookieAdapter, userAdapter, performanceAdapter } = useShopify();
|
|
1062
1077
|
const { cart, addCustomAttributes } = useCartContext();
|
|
1063
1078
|
const { trigger: applyCartCodes } = useApplyCartCodes();
|
|
1064
1079
|
const { trigger: removeInvalidCodes } = useRemoveCartCodes();
|
|
@@ -1079,6 +1094,7 @@ function useAddToCart({ withTrack = true } = {}, swrOptions) {
|
|
|
1079
1094
|
if (!lineItems || lineItems.length === 0) {
|
|
1080
1095
|
return;
|
|
1081
1096
|
}
|
|
1097
|
+
performanceAdapter?.addToCartStart();
|
|
1082
1098
|
const linesWithAttributes = getLinesWithAttributes({
|
|
1083
1099
|
cart,
|
|
1084
1100
|
lineItems
|
|
@@ -1100,6 +1116,7 @@ function useAddToCart({ withTrack = true } = {}, swrOptions) {
|
|
|
1100
1116
|
buyerIdentity
|
|
1101
1117
|
});
|
|
1102
1118
|
if (!resultCart) {
|
|
1119
|
+
performanceAdapter?.addToCartEnd();
|
|
1103
1120
|
return void 0;
|
|
1104
1121
|
}
|
|
1105
1122
|
console.log("npm addCartLines resultCart", resultCart);
|
|
@@ -1134,9 +1151,10 @@ function useAddToCart({ withTrack = true } = {}, swrOptions) {
|
|
|
1134
1151
|
});
|
|
1135
1152
|
trackAddToCartFBQ({ lineItems });
|
|
1136
1153
|
}
|
|
1154
|
+
performanceAdapter?.addToCartEnd();
|
|
1137
1155
|
return resultCart;
|
|
1138
1156
|
},
|
|
1139
|
-
[client, locale, cartCookieAdapter, userAdapter, cart, withTrack]
|
|
1157
|
+
[client, locale, cartCookieAdapter, userAdapter, cart, withTrack, performanceAdapter]
|
|
1140
1158
|
);
|
|
1141
1159
|
return useSWRMutation("add-to-cart", addToCart, swrOptions);
|
|
1142
1160
|
}
|
|
@@ -2899,7 +2917,7 @@ function useAutoRemovePlusMemberInCart({
|
|
|
2899
2917
|
}
|
|
2900
2918
|
}, [cart, plus_annual_product, plus_monthly_product, profile, removeCartLines2]);
|
|
2901
2919
|
}
|
|
2902
|
-
function
|
|
2920
|
+
function usePlusMemberNeedAddToCart({
|
|
2903
2921
|
cart,
|
|
2904
2922
|
profile
|
|
2905
2923
|
}) {
|
|
@@ -3269,7 +3287,8 @@ function CartProvider({
|
|
|
3269
3287
|
cart,
|
|
3270
3288
|
mutateCart,
|
|
3271
3289
|
isCartLoading: isCartLoading || isCodeChanging,
|
|
3272
|
-
setLoadingState
|
|
3290
|
+
setLoadingState,
|
|
3291
|
+
metafieldIdentifiers
|
|
3273
3292
|
});
|
|
3274
3293
|
const removeCustomAttributes = useCallback(
|
|
3275
3294
|
(attributes2) => {
|
|
@@ -3418,6 +3437,6 @@ function useCartContext(options) {
|
|
|
3418
3437
|
return context;
|
|
3419
3438
|
}
|
|
3420
3439
|
|
|
3421
|
-
export { BuyRuleType, CODE_AMOUNT_KEY, CUSTOMER_ATTRIBUTE_KEY, CUSTOMER_SCRIPT_GIFT_KEY, CartProvider, DeliveryPlusType, MAIN_PRODUCT_CODE, OrderBasePriceType, OrderDiscountType, PLUS_MEMBER_TYPE, PlusMemberContext, PlusMemberMode, PlusMemberProvider, PriceBasePriceType, PriceDiscountType, RuleType, SCRIPT_CODE_AMOUNT_KEY, ShippingMethodMode, ShopifyContext, ShopifyProvider, SpendMoneyType, browserCartCookieAdapter, browserCookieAdapter, checkAttributesUpdateNeeded, clearGeoLocationCache, createMockCartFromLines, currencyCodeMapping, defaultSWRMutationConfiguration, formatFunctionAutoFreeGift, formatScriptAutoFreeGift, gaTrack, getCachedGeoLocation, getDiscountEnvAttributeValue, getMatchedMainProductSubTotal, getQuery, getReferralAttributes, normalizeAddToCartLines, preCheck, safeParse, trackAddToCartFBQ, trackAddToCartGA, trackBeginCheckoutGA, trackBuyNowFBQ, trackBuyNowGA, useAddCartLines,
|
|
3440
|
+
export { BrowserPerformanceAdapter, BuyRuleType, CODE_AMOUNT_KEY, CUSTOMER_ATTRIBUTE_KEY, CUSTOMER_SCRIPT_GIFT_KEY, CartProvider, DeliveryPlusType, MAIN_PRODUCT_CODE, OrderBasePriceType, OrderDiscountType, PLUS_MEMBER_TYPE, PlusMemberContext, PlusMemberMode, PlusMemberProvider, PriceBasePriceType, PriceDiscountType, RuleType, SCRIPT_CODE_AMOUNT_KEY, ShippingMethodMode, ShopifyContext, ShopifyProvider, SpendMoneyType, browserCartCookieAdapter, browserCookieAdapter, checkAttributesUpdateNeeded, clearGeoLocationCache, createMockCartFromLines, currencyCodeMapping, defaultSWRMutationConfiguration, formatFunctionAutoFreeGift, formatScriptAutoFreeGift, gaTrack, getCachedGeoLocation, getDiscountEnvAttributeValue, getMatchedMainProductSubTotal, getQuery, getReferralAttributes, normalizeAddToCartLines, preCheck, safeParse, trackAddToCartFBQ, trackAddToCartGA, trackBeginCheckoutGA, trackBuyNowFBQ, trackBuyNowGA, useAddCartLines, useAddToCart, useAllBlogs, useAllCollections, useAllProducts, useApplyCartCodes, useArticle, useArticles, useArticlesInBlog, useAutoRemovePlusMemberInCart, useBlog, useBuyNow, useCalcAutoFreeGift, useCalcGiftsFromLines, useCalcOrderDiscount, useCartAttributes, useCartContext, useCartItemQuantityLimit, useCollection, useCollections, useCreateCart, useExposure, useGeoLocation, useHasPlusMemberInCart, useIntersection, usePlusAnnualProductVariant, usePlusMemberCheckoutCustomAttributes, usePlusMemberContext, usePlusMemberDeliveryCodes, usePlusMemberItemCustomAttributes, usePlusMemberNeedAddToCart, usePlusMonthlyProductVariant, usePrice, useProduct, useProductUrl, useProductsByHandles, useRemoveCartCodes, useRemoveCartLines, useReplaceCartPlusMember, useScriptAutoFreeGift, useSearch, useSelectedOptions, useShippingMethodAvailableCheck, useShippingMethods, useShopify, useSite, useUpdateCartAttributes, useUpdateCartLines, useUpdateLineCodeAmountAttributes, useUpdatePlusMemberDeliveryOptions, useUpdateVariantQuery, useVariant, useVariantMedia };
|
|
3422
3441
|
//# sourceMappingURL=index.mjs.map
|
|
3423
3442
|
//# sourceMappingURL=index.mjs.map
|