@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.mjs
CHANGED
@@ -133,9 +133,6 @@ var getRebuyConfig = async (rebuyKey, storeDomain) => {
|
|
133
133
|
|
134
134
|
// src/providers/RebuyHydrogenContextProvider.tsx
|
135
135
|
import { jsx } from "react/jsx-runtime";
|
136
|
-
var PUBLIC_PRIMARY_DOMAIN = import.meta.env.PUBLIC_PRIMARY_DOMAIN;
|
137
|
-
var PUBLIC_REBUY_API_KEY = import.meta.env.PUBLIC_REBUY_API_KEY;
|
138
|
-
var PUBLIC_STORE_DOMAIN = import.meta.env.PUBLIC_STORE_DOMAIN;
|
139
136
|
var RebuyHydrogenContext = ({
|
140
137
|
cartAttributes,
|
141
138
|
cartCost,
|
@@ -143,21 +140,24 @@ var RebuyHydrogenContext = ({
|
|
143
140
|
cartLines,
|
144
141
|
cartNote,
|
145
142
|
cartQuantity,
|
146
|
-
children
|
143
|
+
children,
|
144
|
+
shop,
|
145
|
+
apiKey,
|
146
|
+
publicStoreDomain
|
147
147
|
}) => {
|
148
148
|
const [rebuyConfig, setRebuyConfig] = useState(null);
|
149
149
|
const location = useLocation();
|
150
150
|
const queryObject = Utilities2.queryStringToObject(location.search);
|
151
|
-
const windowUrl = `${
|
151
|
+
const windowUrl = `${shop}${location.pathname}${location.search}`;
|
152
152
|
useEffect(() => {
|
153
153
|
const initConfig = async () => {
|
154
|
-
const config = await getRebuyConfig(
|
154
|
+
const config = await getRebuyConfig(apiKey, publicStoreDomain);
|
155
155
|
setRebuyConfig(config);
|
156
156
|
};
|
157
157
|
if (!rebuyConfig?.shop) {
|
158
158
|
initConfig();
|
159
159
|
}
|
160
|
-
}, [rebuyConfig
|
160
|
+
}, [rebuyConfig]);
|
161
161
|
const contextParameters = useMemo(
|
162
162
|
() => createContextParameters({
|
163
163
|
cacheKey: rebuyConfig?.shop?.cache_key,
|
@@ -181,7 +181,13 @@ var RebuyHydrogenContext = ({
|
|
181
181
|
);
|
182
182
|
return /* @__PURE__ */ jsx(RebuyContext.Provider, { value: contextValue, children });
|
183
183
|
};
|
184
|
-
var RebuyHydrogenContextProvider = ({
|
184
|
+
var RebuyHydrogenContextProvider = ({
|
185
|
+
cart,
|
186
|
+
children,
|
187
|
+
shop,
|
188
|
+
apiKey,
|
189
|
+
publicStoreDomain
|
190
|
+
}) => {
|
185
191
|
return /* @__PURE__ */ jsx(Await, { resolve: cart, children: (resolvedCart) => {
|
186
192
|
const cart2 = resolvedCart;
|
187
193
|
return /* @__PURE__ */ jsx(
|
@@ -193,6 +199,9 @@ var RebuyHydrogenContextProvider = ({ cart, children }) => {
|
|
193
199
|
cartLines: cart2?.lines?.nodes,
|
194
200
|
cartNote: cart2?.note,
|
195
201
|
cartQuantity: cart2?.totalQuantity,
|
202
|
+
shop,
|
203
|
+
apiKey,
|
204
|
+
publicStoreDomain,
|
196
205
|
children
|
197
206
|
}
|
198
207
|
);
|
@@ -668,26 +677,26 @@ var CART_FRAGMENT = `#graphql
|
|
668
677
|
|
669
678
|
// src/providers/RebuyHydrogenReactContextProvider.tsx
|
670
679
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
671
|
-
var
|
672
|
-
var
|
673
|
-
var
|
680
|
+
var PUBLIC_PRIMARY_DOMAIN = import.meta.env.PUBLIC_PRIMARY_DOMAIN;
|
681
|
+
var PUBLIC_REBUY_API_KEY = import.meta.env.PUBLIC_REBUY_API_KEY;
|
682
|
+
var PUBLIC_STORE_DOMAIN = import.meta.env.PUBLIC_STORE_DOMAIN;
|
674
683
|
var PUBLIC_STOREFRONT_ID = import.meta.env.PUBLIC_STOREFRONT_ID;
|
675
684
|
var PUBLIC_STOREFRONT_API_TOKEN = import.meta.env.PUBLIC_STOREFRONT_API_TOKEN || "";
|
676
685
|
var RebuyHydrogenReactContext = ({ children }) => {
|
677
686
|
const [rebuyConfig, setRebuyConfig] = useState2(null);
|
678
687
|
const location = useLocation2();
|
679
688
|
const queryObject = Utilities3.queryStringToObject(location.search);
|
680
|
-
const windowUrl = `${
|
689
|
+
const windowUrl = `${PUBLIC_PRIMARY_DOMAIN}${location.pathname}${location.search}`;
|
681
690
|
const cart = useCart();
|
682
691
|
useEffect2(() => {
|
683
692
|
const initConfig = async () => {
|
684
|
-
const config = await getRebuyConfig(
|
693
|
+
const config = await getRebuyConfig(PUBLIC_REBUY_API_KEY, PUBLIC_STORE_DOMAIN);
|
685
694
|
setRebuyConfig(config);
|
686
695
|
};
|
687
696
|
if (!rebuyConfig?.shop) {
|
688
697
|
initConfig();
|
689
698
|
}
|
690
|
-
}, [rebuyConfig,
|
699
|
+
}, [rebuyConfig, PUBLIC_REBUY_API_KEY, PUBLIC_STORE_DOMAIN]);
|
691
700
|
const contextParameters = useMemo2(
|
692
701
|
() => createContextParameters({
|
693
702
|
cacheKey: rebuyConfig?.shop?.cache_key,
|
@@ -759,7 +768,7 @@ var RebuyHydrogenReactContextProvider = ({
|
|
759
768
|
{
|
760
769
|
countryIsoCode,
|
761
770
|
languageIsoCode,
|
762
|
-
storeDomain:
|
771
|
+
storeDomain: PUBLIC_STORE_DOMAIN,
|
763
772
|
storefrontApiVersion,
|
764
773
|
storefrontId: PUBLIC_STOREFRONT_ID,
|
765
774
|
storefrontToken: PUBLIC_STOREFRONT_API_TOKEN,
|