@rebuy/rebuy-hydrogen 3.0.0-beta.4 → 3.0.0-beta.6
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
CHANGED
@@ -175,6 +175,9 @@ 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;
|
178
181
|
var RebuyHydrogenContext = ({
|
179
182
|
cartAttributes,
|
180
183
|
cartCost,
|
@@ -184,31 +187,19 @@ var RebuyHydrogenContext = ({
|
|
184
187
|
cartQuantity,
|
185
188
|
children
|
186
189
|
}) => {
|
187
|
-
const primaryDomain = process.env.PRIMARY_DOMAIN;
|
188
|
-
const rebuyKey = process.env.PUBLIC_REBUY_API_KEY;
|
189
|
-
const storeDomain = process.env.PUBLIC_STORE_DOMAIN;
|
190
|
-
if (!primaryDomain) {
|
191
|
-
throw new Error("Missing required environment variable: PRIMARY_DOMAIN");
|
192
|
-
}
|
193
|
-
if (!rebuyKey) {
|
194
|
-
throw new Error("Missing required environment variable: PUBLIC_REBUY_API_KEY");
|
195
|
-
}
|
196
|
-
if (!storeDomain) {
|
197
|
-
throw new Error("Missing required environment variable: PUBLIC_STORE_DOMAIN");
|
198
|
-
}
|
199
190
|
const [rebuyConfig, setRebuyConfig] = (0, import_react3.useState)(null);
|
200
191
|
const location = (0, import_react2.useLocation)();
|
201
192
|
const queryObject = Utilities2.queryStringToObject(location.search);
|
202
|
-
const windowUrl = `${
|
193
|
+
const windowUrl = `${PUBLIC_PRIMARY_DOMAIN}${location.pathname}${location.search}`;
|
203
194
|
(0, import_react3.useEffect)(() => {
|
204
195
|
const initConfig = async () => {
|
205
|
-
const config = await getRebuyConfig(
|
196
|
+
const config = await getRebuyConfig(PUBLIC_REBUY_API_KEY, PUBLIC_STORE_DOMAIN);
|
206
197
|
setRebuyConfig(config);
|
207
198
|
};
|
208
199
|
if (!rebuyConfig?.shop) {
|
209
200
|
initConfig();
|
210
201
|
}
|
211
|
-
}, [rebuyConfig,
|
202
|
+
}, [rebuyConfig, PUBLIC_REBUY_API_KEY, PUBLIC_STORE_DOMAIN]);
|
212
203
|
const contextParameters = (0, import_react3.useMemo)(
|
213
204
|
() => createContextParameters({
|
214
205
|
cacheKey: rebuyConfig?.shop?.cache_key,
|
@@ -719,33 +710,26 @@ var CART_FRAGMENT = `#graphql
|
|
719
710
|
|
720
711
|
// src/providers/RebuyHydrogenReactContextProvider.tsx
|
721
712
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
713
|
+
var PUBLIC_PRIMARY_DOMAIN2 = process.env.PUBLIC_PRIMARY_DOMAIN;
|
714
|
+
var PUBLIC_REBUY_API_KEY2 = process.env.PUBLIC_REBUY_API_KEY;
|
715
|
+
var PUBLIC_STORE_DOMAIN2 = process.env.PUBLIC_STORE_DOMAIN;
|
716
|
+
var PUBLIC_STOREFRONT_ID = process.env.PUBLIC_STOREFRONT_ID;
|
717
|
+
var PUBLIC_STOREFRONT_API_TOKEN = process.env.PUBLIC_STOREFRONT_API_TOKEN || "";
|
722
718
|
var RebuyHydrogenReactContext = ({ children }) => {
|
723
|
-
const primaryDomain = process.env.PRIMARY_DOMAIN;
|
724
|
-
const rebuyKey = process.env.PUBLIC_REBUY_API_KEY;
|
725
|
-
const storeDomain = process.env.PUBLIC_STORE_DOMAIN;
|
726
|
-
if (!primaryDomain) {
|
727
|
-
throw new Error("Missing required environment variable: PRIMARY_DOMAIN");
|
728
|
-
}
|
729
|
-
if (!rebuyKey) {
|
730
|
-
throw new Error("Missing required environment variable: PUBLIC_REBUY_API_KEY");
|
731
|
-
}
|
732
|
-
if (!storeDomain) {
|
733
|
-
throw new Error("Missing required environment variable: PUBLIC_STORE_DOMAIN");
|
734
|
-
}
|
735
719
|
const [rebuyConfig, setRebuyConfig] = (0, import_react5.useState)(null);
|
736
720
|
const location = (0, import_react4.useLocation)();
|
737
721
|
const queryObject = Utilities3.queryStringToObject(location.search);
|
738
|
-
const windowUrl = `${
|
722
|
+
const windowUrl = `${PUBLIC_PRIMARY_DOMAIN2}${location.pathname}${location.search}`;
|
739
723
|
const cart = (0, import_hydrogen_react.useCart)();
|
740
724
|
(0, import_react5.useEffect)(() => {
|
741
725
|
const initConfig = async () => {
|
742
|
-
const config = await getRebuyConfig(
|
726
|
+
const config = await getRebuyConfig(PUBLIC_REBUY_API_KEY2, PUBLIC_STORE_DOMAIN2);
|
743
727
|
setRebuyConfig(config);
|
744
728
|
};
|
745
729
|
if (!rebuyConfig?.shop) {
|
746
730
|
initConfig();
|
747
731
|
}
|
748
|
-
}, [rebuyConfig,
|
732
|
+
}, [rebuyConfig, PUBLIC_REBUY_API_KEY2, PUBLIC_STORE_DOMAIN2]);
|
749
733
|
const contextParameters = (0, import_react5.useMemo)(
|
750
734
|
() => createContextParameters({
|
751
735
|
cacheKey: rebuyConfig?.shop?.cache_key,
|
@@ -794,9 +778,6 @@ var RebuyHydrogenReactContextProvider = ({
|
|
794
778
|
onNoteUpdateComplete,
|
795
779
|
storefrontApiVersion = "2025-01"
|
796
780
|
}) => {
|
797
|
-
const publicStoreDomain = process.env.PUBLIC_STORE_DOMAIN;
|
798
|
-
const storefrontId = process.env.PUBLIC_STOREFRONT_ID;
|
799
|
-
const storefrontToken = process.env.PUBLIC_STOREFRONT_API_TOKEN || "";
|
800
781
|
const adapted = {
|
801
782
|
onAttributesUpdate: onAttributesUpdate ? () => onAttributesUpdate() : void 0,
|
802
783
|
onAttributesUpdateComplete: onAttributesUpdateComplete ? () => onAttributesUpdateComplete() : void 0,
|
@@ -820,10 +801,10 @@ var RebuyHydrogenReactContextProvider = ({
|
|
820
801
|
{
|
821
802
|
countryIsoCode,
|
822
803
|
languageIsoCode,
|
823
|
-
storeDomain:
|
804
|
+
storeDomain: PUBLIC_STORE_DOMAIN2,
|
824
805
|
storefrontApiVersion,
|
825
|
-
storefrontId,
|
826
|
-
storefrontToken,
|
806
|
+
storefrontId: PUBLIC_STOREFRONT_ID,
|
807
|
+
storefrontToken: PUBLIC_STOREFRONT_API_TOKEN,
|
827
808
|
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
828
809
|
import_hydrogen_react.CartProvider,
|
829
810
|
{
|