@rebuy/rebuy-hydrogen 3.0.0-beta.7 → 3.0.0-beta.9

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.mjs CHANGED
@@ -134,6 +134,7 @@ var getRebuyConfig = async (rebuyKey, storeDomain) => {
134
134
  // src/providers/RebuyHydrogenContextProvider.tsx
135
135
  import { jsx } from "react/jsx-runtime";
136
136
  var RebuyHydrogenContext = ({
137
+ apiKey,
137
138
  cartAttributes,
138
139
  cartCost,
139
140
  cartId,
@@ -141,9 +142,8 @@ var RebuyHydrogenContext = ({
141
142
  cartNote,
142
143
  cartQuantity,
143
144
  children,
144
- shop,
145
- apiKey,
146
- publicStoreDomain
145
+ publicStoreDomain,
146
+ shop
147
147
  }) => {
148
148
  const [rebuyConfig, setRebuyConfig] = useState(null);
149
149
  const location = useLocation();
@@ -182,26 +182,26 @@ var RebuyHydrogenContext = ({
182
182
  return /* @__PURE__ */ jsx(RebuyContext.Provider, { value: contextValue, children });
183
183
  };
184
184
  var RebuyHydrogenContextProvider = ({
185
+ apiKey,
185
186
  cart,
186
187
  children,
187
- shop,
188
- apiKey,
189
- publicStoreDomain
188
+ publicStoreDomain,
189
+ shop
190
190
  }) => {
191
191
  return /* @__PURE__ */ jsx(Await, { resolve: cart, children: (resolvedCart) => {
192
192
  const cart2 = resolvedCart;
193
193
  return /* @__PURE__ */ jsx(
194
194
  RebuyHydrogenContext,
195
195
  {
196
+ apiKey,
196
197
  cartAttributes: cart2?.attributes,
197
198
  cartCost: cart2?.cost?.subtotalAmount?.amount,
198
199
  cartId: cart2?.id,
199
200
  cartLines: cart2?.lines?.nodes,
200
201
  cartNote: cart2?.note,
201
202
  cartQuantity: cart2?.totalQuantity,
202
- shop,
203
- apiKey,
204
203
  publicStoreDomain,
204
+ shop,
205
205
  children
206
206
  }
207
207
  );
@@ -810,7 +810,7 @@ import * as Utilities4 from "@rebuy/rebuy/utilities";
810
810
  import { flattenConnection } from "@shopify/hydrogen";
811
811
  import React, { useContext, useEffect as useEffect3, useMemo as useMemo3, useState as useState3 } from "react";
812
812
  var RebuyWidgetContainerBase = ({ children, ...props }) => {
813
- const { collection, collectionId, dataSource, limit, options, product, productId, variant, variantId } = props;
813
+ const { apiKey, collection, collectionId, dataSource, limit, options, product, productId, variant, variantId } = props;
814
814
  const contextParameters = useContext(RebuyContext);
815
815
  const [Rebuy, setRebuy] = useState3(null);
816
816
  const [initialized, setInitialized] = useState3(false);
@@ -819,10 +819,9 @@ var RebuyWidgetContainerBase = ({ children, ...props }) => {
819
819
  const shopifyCollectionId = collection?.id ?? collectionId ?? null;
820
820
  const [products, setProducts] = useState3([]);
821
821
  const [metadata, setMetadata] = useState3();
822
- const REBUY_API_KEY = import.meta.env.PUBLIC_REBUY_API_KEY;
823
822
  useEffect3(() => {
824
823
  if (!Rebuy) {
825
- const client = new RebuyClient2(REBUY_API_KEY);
824
+ const client = new RebuyClient2(apiKey);
826
825
  client.setContextParameters(
827
826
  contextParameters
828
827
  // TODO: fix this type when @rebuy/rebuy is moved to typescript
@@ -833,7 +832,7 @@ var RebuyWidgetContainerBase = ({ children, ...props }) => {
833
832
  setRebuy(client);
834
833
  setInitialized(true);
835
834
  }
836
- }, [REBUY_API_KEY, Rebuy, contextParameters, options]);
835
+ }, [apiKey, Rebuy, contextParameters, options]);
837
836
  useEffect3(() => {
838
837
  if (!Rebuy) return;
839
838
  Rebuy.setContextParameters(