@anker-in/shopify-react 0.1.1-beta.32 → 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 -4
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +7 -4
- 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 +27 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -6
- 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 +5 -2
- package/dist/provider/index.js.map +1 -1
- package/dist/provider/index.mjs +5 -2
- 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 +1 -1
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 });
|
|
@@ -1056,7 +1073,7 @@ var getLinesWithFunctionAttributes = (lineItems) => {
|
|
|
1056
1073
|
|
|
1057
1074
|
// src/hooks/cart/use-add-to-cart.ts
|
|
1058
1075
|
function useAddToCart({ withTrack = true } = {}, swrOptions) {
|
|
1059
|
-
const { client, config, locale, cartCookieAdapter, userAdapter } = useShopify();
|
|
1076
|
+
const { client, config, locale, cartCookieAdapter, userAdapter, performanceAdapter } = useShopify();
|
|
1060
1077
|
const { cart, addCustomAttributes } = useCartContext();
|
|
1061
1078
|
const { trigger: applyCartCodes } = useApplyCartCodes();
|
|
1062
1079
|
const { trigger: removeInvalidCodes } = useRemoveCartCodes();
|
|
@@ -1077,6 +1094,7 @@ function useAddToCart({ withTrack = true } = {}, swrOptions) {
|
|
|
1077
1094
|
if (!lineItems || lineItems.length === 0) {
|
|
1078
1095
|
return;
|
|
1079
1096
|
}
|
|
1097
|
+
performanceAdapter?.addToCartStart();
|
|
1080
1098
|
const linesWithAttributes = getLinesWithAttributes({
|
|
1081
1099
|
cart,
|
|
1082
1100
|
lineItems
|
|
@@ -1098,6 +1116,7 @@ function useAddToCart({ withTrack = true } = {}, swrOptions) {
|
|
|
1098
1116
|
buyerIdentity
|
|
1099
1117
|
});
|
|
1100
1118
|
if (!resultCart) {
|
|
1119
|
+
performanceAdapter?.addToCartEnd();
|
|
1101
1120
|
return void 0;
|
|
1102
1121
|
}
|
|
1103
1122
|
console.log("npm addCartLines resultCart", resultCart);
|
|
@@ -1132,9 +1151,10 @@ function useAddToCart({ withTrack = true } = {}, swrOptions) {
|
|
|
1132
1151
|
});
|
|
1133
1152
|
trackAddToCartFBQ({ lineItems });
|
|
1134
1153
|
}
|
|
1154
|
+
performanceAdapter?.addToCartEnd();
|
|
1135
1155
|
return resultCart;
|
|
1136
1156
|
},
|
|
1137
|
-
[client, locale, cartCookieAdapter, userAdapter, cart, withTrack]
|
|
1157
|
+
[client, locale, cartCookieAdapter, userAdapter, cart, withTrack, performanceAdapter]
|
|
1138
1158
|
);
|
|
1139
1159
|
return useSWRMutation("add-to-cart", addToCart, swrOptions);
|
|
1140
1160
|
}
|
|
@@ -2897,7 +2917,7 @@ function useAutoRemovePlusMemberInCart({
|
|
|
2897
2917
|
}
|
|
2898
2918
|
}, [cart, plus_annual_product, plus_monthly_product, profile, removeCartLines2]);
|
|
2899
2919
|
}
|
|
2900
|
-
function
|
|
2920
|
+
function usePlusMemberNeedAddToCart({
|
|
2901
2921
|
cart,
|
|
2902
2922
|
profile
|
|
2903
2923
|
}) {
|
|
@@ -3417,6 +3437,6 @@ function useCartContext(options) {
|
|
|
3417
3437
|
return context;
|
|
3418
3438
|
}
|
|
3419
3439
|
|
|
3420
|
-
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 };
|
|
3421
3441
|
//# sourceMappingURL=index.mjs.map
|
|
3422
3442
|
//# sourceMappingURL=index.mjs.map
|