@rebuy/rebuy-hydrogen 3.0.0-beta.5 → 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 -33
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +24 -33
- 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/RebuyHydrogenReactContextProvider.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,30 +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
|
-
if (!PUBLIC_PRIMARY_DOMAIN) {
|
191
|
-
throw new Error("Missing required environment variable: PUBLIC_PRIMARY_DOMAIN");
|
192
|
-
}
|
193
|
-
if (!PUBLIC_REBUY_API_KEY) {
|
194
|
-
throw new Error("Missing required environment variable: PUBLIC_REBUY_API_KEY");
|
195
|
-
}
|
196
|
-
if (!PUBLIC_STORE_DOMAIN) {
|
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 = `${shop}${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(apiKey, publicStoreDomain);
|
206
197
|
setRebuyConfig(config);
|
207
198
|
};
|
208
199
|
if (!rebuyConfig?.shop) {
|
209
200
|
initConfig();
|
210
201
|
}
|
211
|
-
}, [rebuyConfig
|
202
|
+
}, [rebuyConfig]);
|
212
203
|
const contextParameters = (0, import_react3.useMemo)(
|
213
204
|
() => createContextParameters({
|
214
205
|
cacheKey: rebuyConfig?.shop?.cache_key,
|
@@ -232,7 +223,13 @@ var RebuyHydrogenContext = ({
|
|
232
223
|
);
|
233
224
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RebuyContext.Provider, { value: contextValue, children });
|
234
225
|
};
|
235
|
-
var RebuyHydrogenContextProvider = ({
|
226
|
+
var RebuyHydrogenContextProvider = ({
|
227
|
+
cart,
|
228
|
+
children,
|
229
|
+
shop,
|
230
|
+
apiKey,
|
231
|
+
publicStoreDomain
|
232
|
+
}) => {
|
236
233
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react2.Await, { resolve: cart, children: (resolvedCart) => {
|
237
234
|
const cart2 = resolvedCart;
|
238
235
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
@@ -244,6 +241,9 @@ var RebuyHydrogenContextProvider = ({ cart, children }) => {
|
|
244
241
|
cartLines: cart2?.lines?.nodes,
|
245
242
|
cartNote: cart2?.note,
|
246
243
|
cartQuantity: cart2?.totalQuantity,
|
244
|
+
shop,
|
245
|
+
apiKey,
|
246
|
+
publicStoreDomain,
|
247
247
|
children
|
248
248
|
}
|
249
249
|
);
|
@@ -719,35 +719,26 @@ var CART_FRAGMENT = `#graphql
|
|
719
719
|
|
720
720
|
// src/providers/RebuyHydrogenReactContextProvider.tsx
|
721
721
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
722
|
-
var
|
723
|
-
var
|
724
|
-
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;
|
725
725
|
var PUBLIC_STOREFRONT_ID = process.env.PUBLIC_STOREFRONT_ID;
|
726
726
|
var PUBLIC_STOREFRONT_API_TOKEN = process.env.PUBLIC_STOREFRONT_API_TOKEN || "";
|
727
727
|
var RebuyHydrogenReactContext = ({ children }) => {
|
728
|
-
if (!PUBLIC_PRIMARY_DOMAIN2) {
|
729
|
-
throw new Error("Missing required environment variable: PUBLIC_PRIMARY_DOMAIN");
|
730
|
-
}
|
731
|
-
if (!PUBLIC_REBUY_API_KEY2) {
|
732
|
-
throw new Error("Missing required environment variable: PUBLIC_REBUY_API_KEY");
|
733
|
-
}
|
734
|
-
if (!PUBLIC_STORE_DOMAIN2) {
|
735
|
-
throw new Error("Missing required environment variable: PUBLIC_STORE_DOMAIN");
|
736
|
-
}
|
737
728
|
const [rebuyConfig, setRebuyConfig] = (0, import_react5.useState)(null);
|
738
729
|
const location = (0, import_react4.useLocation)();
|
739
730
|
const queryObject = Utilities3.queryStringToObject(location.search);
|
740
|
-
const windowUrl = `${
|
731
|
+
const windowUrl = `${PUBLIC_PRIMARY_DOMAIN}${location.pathname}${location.search}`;
|
741
732
|
const cart = (0, import_hydrogen_react.useCart)();
|
742
733
|
(0, import_react5.useEffect)(() => {
|
743
734
|
const initConfig = async () => {
|
744
|
-
const config = await getRebuyConfig(
|
735
|
+
const config = await getRebuyConfig(PUBLIC_REBUY_API_KEY, PUBLIC_STORE_DOMAIN);
|
745
736
|
setRebuyConfig(config);
|
746
737
|
};
|
747
738
|
if (!rebuyConfig?.shop) {
|
748
739
|
initConfig();
|
749
740
|
}
|
750
|
-
}, [rebuyConfig,
|
741
|
+
}, [rebuyConfig, PUBLIC_REBUY_API_KEY, PUBLIC_STORE_DOMAIN]);
|
751
742
|
const contextParameters = (0, import_react5.useMemo)(
|
752
743
|
() => createContextParameters({
|
753
744
|
cacheKey: rebuyConfig?.shop?.cache_key,
|
@@ -819,7 +810,7 @@ var RebuyHydrogenReactContextProvider = ({
|
|
819
810
|
{
|
820
811
|
countryIsoCode,
|
821
812
|
languageIsoCode,
|
822
|
-
storeDomain:
|
813
|
+
storeDomain: PUBLIC_STORE_DOMAIN,
|
823
814
|
storefrontApiVersion,
|
824
815
|
storefrontId: PUBLIC_STOREFRONT_ID,
|
825
816
|
storefrontToken: PUBLIC_STOREFRONT_API_TOKEN,
|