@rebuy/rebuy-hydrogen 3.0.0-beta.6 → 3.0.0-beta.7
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.js +24 -15
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +24 -15
- package/dist/index.mjs.map +3 -3
- package/dist/providers/RebuyHydrogenContextProvider.d.ts +1 -1
- package/dist/providers/RebuyHydrogenContextProvider.d.ts.map +1 -1
- package/dist/providers/types.d.ts +6 -0
- package/dist/providers/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -175,9 +175,6 @@ var getRebuyConfig = async (rebuyKey, storeDomain) => {
|
|
175
175
|
|
176
176
|
// src/providers/RebuyHydrogenContextProvider.tsx
|
177
177
|
var import_jsx_runtime = require("react/jsx-runtime");
|
178
|
-
var PUBLIC_PRIMARY_DOMAIN = process.env.PUBLIC_PRIMARY_DOMAIN;
|
179
|
-
var PUBLIC_REBUY_API_KEY = process.env.PUBLIC_REBUY_API_KEY;
|
180
|
-
var PUBLIC_STORE_DOMAIN = process.env.PUBLIC_STORE_DOMAIN;
|
181
178
|
var RebuyHydrogenContext = ({
|
182
179
|
cartAttributes,
|
183
180
|
cartCost,
|
@@ -185,21 +182,24 @@ var RebuyHydrogenContext = ({
|
|
185
182
|
cartLines,
|
186
183
|
cartNote,
|
187
184
|
cartQuantity,
|
188
|
-
children
|
185
|
+
children,
|
186
|
+
shop,
|
187
|
+
apiKey,
|
188
|
+
publicStoreDomain
|
189
189
|
}) => {
|
190
190
|
const [rebuyConfig, setRebuyConfig] = (0, import_react3.useState)(null);
|
191
191
|
const location = (0, import_react2.useLocation)();
|
192
192
|
const queryObject = Utilities2.queryStringToObject(location.search);
|
193
|
-
const windowUrl = `${
|
193
|
+
const windowUrl = `${shop}${location.pathname}${location.search}`;
|
194
194
|
(0, import_react3.useEffect)(() => {
|
195
195
|
const initConfig = async () => {
|
196
|
-
const config = await getRebuyConfig(
|
196
|
+
const config = await getRebuyConfig(apiKey, publicStoreDomain);
|
197
197
|
setRebuyConfig(config);
|
198
198
|
};
|
199
199
|
if (!rebuyConfig?.shop) {
|
200
200
|
initConfig();
|
201
201
|
}
|
202
|
-
}, [rebuyConfig
|
202
|
+
}, [rebuyConfig]);
|
203
203
|
const contextParameters = (0, import_react3.useMemo)(
|
204
204
|
() => createContextParameters({
|
205
205
|
cacheKey: rebuyConfig?.shop?.cache_key,
|
@@ -223,7 +223,13 @@ var RebuyHydrogenContext = ({
|
|
223
223
|
);
|
224
224
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RebuyContext.Provider, { value: contextValue, children });
|
225
225
|
};
|
226
|
-
var RebuyHydrogenContextProvider = ({
|
226
|
+
var RebuyHydrogenContextProvider = ({
|
227
|
+
cart,
|
228
|
+
children,
|
229
|
+
shop,
|
230
|
+
apiKey,
|
231
|
+
publicStoreDomain
|
232
|
+
}) => {
|
227
233
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react2.Await, { resolve: cart, children: (resolvedCart) => {
|
228
234
|
const cart2 = resolvedCart;
|
229
235
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
@@ -235,6 +241,9 @@ var RebuyHydrogenContextProvider = ({ cart, children }) => {
|
|
235
241
|
cartLines: cart2?.lines?.nodes,
|
236
242
|
cartNote: cart2?.note,
|
237
243
|
cartQuantity: cart2?.totalQuantity,
|
244
|
+
shop,
|
245
|
+
apiKey,
|
246
|
+
publicStoreDomain,
|
238
247
|
children
|
239
248
|
}
|
240
249
|
);
|
@@ -710,26 +719,26 @@ var CART_FRAGMENT = `#graphql
|
|
710
719
|
|
711
720
|
// src/providers/RebuyHydrogenReactContextProvider.tsx
|
712
721
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
713
|
-
var
|
714
|
-
var
|
715
|
-
var
|
722
|
+
var PUBLIC_PRIMARY_DOMAIN = process.env.PUBLIC_PRIMARY_DOMAIN;
|
723
|
+
var PUBLIC_REBUY_API_KEY = process.env.PUBLIC_REBUY_API_KEY;
|
724
|
+
var PUBLIC_STORE_DOMAIN = process.env.PUBLIC_STORE_DOMAIN;
|
716
725
|
var PUBLIC_STOREFRONT_ID = process.env.PUBLIC_STOREFRONT_ID;
|
717
726
|
var PUBLIC_STOREFRONT_API_TOKEN = process.env.PUBLIC_STOREFRONT_API_TOKEN || "";
|
718
727
|
var RebuyHydrogenReactContext = ({ children }) => {
|
719
728
|
const [rebuyConfig, setRebuyConfig] = (0, import_react5.useState)(null);
|
720
729
|
const location = (0, import_react4.useLocation)();
|
721
730
|
const queryObject = Utilities3.queryStringToObject(location.search);
|
722
|
-
const windowUrl = `${
|
731
|
+
const windowUrl = `${PUBLIC_PRIMARY_DOMAIN}${location.pathname}${location.search}`;
|
723
732
|
const cart = (0, import_hydrogen_react.useCart)();
|
724
733
|
(0, import_react5.useEffect)(() => {
|
725
734
|
const initConfig = async () => {
|
726
|
-
const config = await getRebuyConfig(
|
735
|
+
const config = await getRebuyConfig(PUBLIC_REBUY_API_KEY, PUBLIC_STORE_DOMAIN);
|
727
736
|
setRebuyConfig(config);
|
728
737
|
};
|
729
738
|
if (!rebuyConfig?.shop) {
|
730
739
|
initConfig();
|
731
740
|
}
|
732
|
-
}, [rebuyConfig,
|
741
|
+
}, [rebuyConfig, PUBLIC_REBUY_API_KEY, PUBLIC_STORE_DOMAIN]);
|
733
742
|
const contextParameters = (0, import_react5.useMemo)(
|
734
743
|
() => createContextParameters({
|
735
744
|
cacheKey: rebuyConfig?.shop?.cache_key,
|
@@ -801,7 +810,7 @@ var RebuyHydrogenReactContextProvider = ({
|
|
801
810
|
{
|
802
811
|
countryIsoCode,
|
803
812
|
languageIsoCode,
|
804
|
-
storeDomain:
|
813
|
+
storeDomain: PUBLIC_STORE_DOMAIN,
|
805
814
|
storefrontApiVersion,
|
806
815
|
storefrontId: PUBLIC_STOREFRONT_ID,
|
807
816
|
storefrontToken: PUBLIC_STOREFRONT_API_TOKEN,
|