@anker-in/shopify-react 0.1.1-beta.4 → 0.1.1-beta.41

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,11 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import React__default from 'react';
3
- import { ShopifyClient, ShopifyConfig, CartCookieAdapter as CartCookieAdapter$1, NormalizedCart, HasMetafieldsIdentifier } from '@anker-in/shopify-sdk';
4
- import { C as CookieAdapter, b as CartCookieAdapter, R as RouterAdapter, U as UserContextAdapter } from '../types-BLMoxbOk.mjs';
3
+ import { ShopifyClient, ShopifyConfig, CartCookieAdapter, NormalizedCart, AttributeInput, HasMetafieldsIdentifier } from '@anker-in/shopify-sdk';
4
+ import { C as CookieAdapter, R as RouterAdapter, U as UserContextAdapter, P as PerformanceAdapter } from '../types-SKDHauqk.mjs';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import { SWRConfiguration } from 'swr';
7
- import { e as PlusMemberSettingsMetafields } from '../types-CICUnw0v.mjs';
8
- import 'swr/mutation';
7
+ import { e as PlusMemberSettingsMetafields } from '../types-y1Wa95P3.mjs';
9
8
 
10
9
  interface ShopifyContextValue {
11
10
  client: ShopifyClient;
@@ -16,6 +15,7 @@ interface ShopifyContextValue {
16
15
  cartCookieAdapter: CartCookieAdapter;
17
16
  routerAdapter?: RouterAdapter;
18
17
  userAdapter?: UserContextAdapter;
18
+ performanceAdapter?: PerformanceAdapter;
19
19
  }
20
20
  declare const ShopifyContext: React.Context<ShopifyContextValue | null>;
21
21
 
@@ -24,16 +24,17 @@ interface ShopifyProviderProps {
24
24
  locale: string;
25
25
  locales?: string[];
26
26
  cookieAdapter?: CookieAdapter;
27
- cartCookieAdapter?: CartCookieAdapter$1;
27
+ cartCookieAdapter?: CartCookieAdapter;
28
28
  routerAdapter?: RouterAdapter;
29
29
  userAdapter?: UserContextAdapter;
30
30
  children: React__default.ReactNode;
31
+ performanceAdapter?: PerformanceAdapter;
31
32
  }
32
33
  /**
33
34
  * Shopify Provider Component
34
35
  * Provides Shopify context to all child components
35
36
  */
36
- declare function ShopifyProvider({ config, locale, locales, cookieAdapter, cartCookieAdapter, routerAdapter, userAdapter, children, }: ShopifyProviderProps): react_jsx_runtime.JSX.Element;
37
+ declare function ShopifyProvider({ config, locale, locales, cookieAdapter, cartCookieAdapter, routerAdapter, userAdapter, children, performanceAdapter, }: ShopifyProviderProps): react_jsx_runtime.JSX.Element;
37
38
 
38
39
  /**
39
40
  * Hook to access Shopify context
@@ -41,10 +42,6 @@ declare function ShopifyProvider({ config, locale, locales, cookieAdapter, cartC
41
42
  */
42
43
  declare function useShopify(): ShopifyContextValue;
43
44
 
44
- type AttributeInput = {
45
- key: string;
46
- value: string;
47
- };
48
45
  type LoadingState = {
49
46
  editLineQuantityLoading: boolean;
50
47
  editLineCodeAmountLoading: boolean;
@@ -54,6 +51,8 @@ type LoadingState = {
54
51
  interface CartContextValue {
55
52
  /** Current cart data */
56
53
  cart: NormalizedCart | undefined;
54
+ /** Total quantity of items in cart */
55
+ totalQuantity: number;
57
56
  /** Whether cart is loading */
58
57
  isCartLoading: boolean;
59
58
  /** Manually trigger cart fetch */
@@ -151,14 +150,25 @@ declare function CartProvider({ children, autoFreeGiftConfig, gradientGiftsConfi
151
150
  /**
152
151
  * Hook to access cart context
153
152
  *
154
- * @throws Error if used outside CartProvider
155
- * @returns Cart context value
153
+ * @param options - Optional configuration
154
+ * @param options.optional - If true, returns undefined instead of throwing error when used outside provider
155
+ * @throws Error if used outside CartProvider (unless optional is true)
156
+ * @returns Cart context value (or undefined if optional is true and no provider exists)
156
157
  *
157
158
  * @example
158
159
  * ```tsx
159
160
  * const { cart, mutateCart, isCartLoading, loadingState } = useCartContext()
161
+ *
162
+ * // Optional usage (safe for SSR)
163
+ * const cartContext = useCartContext({ optional: true })
164
+ * if (cartContext) {
165
+ * const { cart } = cartContext
166
+ * }
160
167
  * ```
161
168
  */
162
169
  declare function useCartContext(): CartContextValue;
170
+ declare function useCartContext(options: {
171
+ optional: true;
172
+ }): CartContextValue | null;
163
173
 
164
- export { type AttributeInput, type CartContextValue, CartProvider, type CartProviderProps, type LoadingState, ShopifyContext, type ShopifyContextValue, ShopifyProvider, type ShopifyProviderProps, useCartContext, useShopify };
174
+ export { type CartContextValue, CartProvider, type CartProviderProps, type LoadingState, ShopifyContext, type ShopifyContextValue, ShopifyProvider, type ShopifyProviderProps, useCartContext, useShopify };
@@ -1,11 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import React__default from 'react';
3
- import { ShopifyClient, ShopifyConfig, CartCookieAdapter as CartCookieAdapter$1, NormalizedCart, HasMetafieldsIdentifier } from '@anker-in/shopify-sdk';
4
- import { C as CookieAdapter, b as CartCookieAdapter, R as RouterAdapter, U as UserContextAdapter } from '../types-BLMoxbOk.js';
3
+ import { ShopifyClient, ShopifyConfig, CartCookieAdapter, NormalizedCart, AttributeInput, HasMetafieldsIdentifier } from '@anker-in/shopify-sdk';
4
+ import { C as CookieAdapter, R as RouterAdapter, U as UserContextAdapter, P as PerformanceAdapter } from '../types-SKDHauqk.js';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import { SWRConfiguration } from 'swr';
7
- import { e as PlusMemberSettingsMetafields } from '../types-CICUnw0v.js';
8
- import 'swr/mutation';
7
+ import { e as PlusMemberSettingsMetafields } from '../types-y1Wa95P3.js';
9
8
 
10
9
  interface ShopifyContextValue {
11
10
  client: ShopifyClient;
@@ -16,6 +15,7 @@ interface ShopifyContextValue {
16
15
  cartCookieAdapter: CartCookieAdapter;
17
16
  routerAdapter?: RouterAdapter;
18
17
  userAdapter?: UserContextAdapter;
18
+ performanceAdapter?: PerformanceAdapter;
19
19
  }
20
20
  declare const ShopifyContext: React.Context<ShopifyContextValue | null>;
21
21
 
@@ -24,16 +24,17 @@ interface ShopifyProviderProps {
24
24
  locale: string;
25
25
  locales?: string[];
26
26
  cookieAdapter?: CookieAdapter;
27
- cartCookieAdapter?: CartCookieAdapter$1;
27
+ cartCookieAdapter?: CartCookieAdapter;
28
28
  routerAdapter?: RouterAdapter;
29
29
  userAdapter?: UserContextAdapter;
30
30
  children: React__default.ReactNode;
31
+ performanceAdapter?: PerformanceAdapter;
31
32
  }
32
33
  /**
33
34
  * Shopify Provider Component
34
35
  * Provides Shopify context to all child components
35
36
  */
36
- declare function ShopifyProvider({ config, locale, locales, cookieAdapter, cartCookieAdapter, routerAdapter, userAdapter, children, }: ShopifyProviderProps): react_jsx_runtime.JSX.Element;
37
+ declare function ShopifyProvider({ config, locale, locales, cookieAdapter, cartCookieAdapter, routerAdapter, userAdapter, children, performanceAdapter, }: ShopifyProviderProps): react_jsx_runtime.JSX.Element;
37
38
 
38
39
  /**
39
40
  * Hook to access Shopify context
@@ -41,10 +42,6 @@ declare function ShopifyProvider({ config, locale, locales, cookieAdapter, cartC
41
42
  */
42
43
  declare function useShopify(): ShopifyContextValue;
43
44
 
44
- type AttributeInput = {
45
- key: string;
46
- value: string;
47
- };
48
45
  type LoadingState = {
49
46
  editLineQuantityLoading: boolean;
50
47
  editLineCodeAmountLoading: boolean;
@@ -54,6 +51,8 @@ type LoadingState = {
54
51
  interface CartContextValue {
55
52
  /** Current cart data */
56
53
  cart: NormalizedCart | undefined;
54
+ /** Total quantity of items in cart */
55
+ totalQuantity: number;
57
56
  /** Whether cart is loading */
58
57
  isCartLoading: boolean;
59
58
  /** Manually trigger cart fetch */
@@ -151,14 +150,25 @@ declare function CartProvider({ children, autoFreeGiftConfig, gradientGiftsConfi
151
150
  /**
152
151
  * Hook to access cart context
153
152
  *
154
- * @throws Error if used outside CartProvider
155
- * @returns Cart context value
153
+ * @param options - Optional configuration
154
+ * @param options.optional - If true, returns undefined instead of throwing error when used outside provider
155
+ * @throws Error if used outside CartProvider (unless optional is true)
156
+ * @returns Cart context value (or undefined if optional is true and no provider exists)
156
157
  *
157
158
  * @example
158
159
  * ```tsx
159
160
  * const { cart, mutateCart, isCartLoading, loadingState } = useCartContext()
161
+ *
162
+ * // Optional usage (safe for SSR)
163
+ * const cartContext = useCartContext({ optional: true })
164
+ * if (cartContext) {
165
+ * const { cart } = cartContext
166
+ * }
160
167
  * ```
161
168
  */
162
169
  declare function useCartContext(): CartContextValue;
170
+ declare function useCartContext(options: {
171
+ optional: true;
172
+ }): CartContextValue | null;
163
173
 
164
- export { type AttributeInput, type CartContextValue, CartProvider, type CartProviderProps, type LoadingState, ShopifyContext, type ShopifyContextValue, ShopifyProvider, type ShopifyProviderProps, useCartContext, useShopify };
174
+ export { type CartContextValue, CartProvider, type CartProviderProps, type LoadingState, ShopifyContext, type ShopifyContextValue, ShopifyProvider, type ShopifyProviderProps, useCartContext, useShopify };