@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.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,30 +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
|
-
if (!PUBLIC_PRIMARY_DOMAIN) {
|
149
|
-
throw new Error("Missing required environment variable: PUBLIC_PRIMARY_DOMAIN");
|
150
|
-
}
|
151
|
-
if (!PUBLIC_REBUY_API_KEY) {
|
152
|
-
throw new Error("Missing required environment variable: PUBLIC_REBUY_API_KEY");
|
153
|
-
}
|
154
|
-
if (!PUBLIC_STORE_DOMAIN) {
|
155
|
-
throw new Error("Missing required environment variable: PUBLIC_STORE_DOMAIN");
|
156
|
-
}
|
157
148
|
const [rebuyConfig, setRebuyConfig] = useState(null);
|
158
149
|
const location = useLocation();
|
159
150
|
const queryObject = Utilities2.queryStringToObject(location.search);
|
160
|
-
const windowUrl = `${
|
151
|
+
const windowUrl = `${shop}${location.pathname}${location.search}`;
|
161
152
|
useEffect(() => {
|
162
153
|
const initConfig = async () => {
|
163
|
-
const config = await getRebuyConfig(
|
154
|
+
const config = await getRebuyConfig(apiKey, publicStoreDomain);
|
164
155
|
setRebuyConfig(config);
|
165
156
|
};
|
166
157
|
if (!rebuyConfig?.shop) {
|
167
158
|
initConfig();
|
168
159
|
}
|
169
|
-
}, [rebuyConfig
|
160
|
+
}, [rebuyConfig]);
|
170
161
|
const contextParameters = useMemo(
|
171
162
|
() => createContextParameters({
|
172
163
|
cacheKey: rebuyConfig?.shop?.cache_key,
|
@@ -190,7 +181,13 @@ var RebuyHydrogenContext = ({
|
|
190
181
|
);
|
191
182
|
return /* @__PURE__ */ jsx(RebuyContext.Provider, { value: contextValue, children });
|
192
183
|
};
|
193
|
-
var RebuyHydrogenContextProvider = ({
|
184
|
+
var RebuyHydrogenContextProvider = ({
|
185
|
+
cart,
|
186
|
+
children,
|
187
|
+
shop,
|
188
|
+
apiKey,
|
189
|
+
publicStoreDomain
|
190
|
+
}) => {
|
194
191
|
return /* @__PURE__ */ jsx(Await, { resolve: cart, children: (resolvedCart) => {
|
195
192
|
const cart2 = resolvedCart;
|
196
193
|
return /* @__PURE__ */ jsx(
|
@@ -202,6 +199,9 @@ var RebuyHydrogenContextProvider = ({ cart, children }) => {
|
|
202
199
|
cartLines: cart2?.lines?.nodes,
|
203
200
|
cartNote: cart2?.note,
|
204
201
|
cartQuantity: cart2?.totalQuantity,
|
202
|
+
shop,
|
203
|
+
apiKey,
|
204
|
+
publicStoreDomain,
|
205
205
|
children
|
206
206
|
}
|
207
207
|
);
|
@@ -677,35 +677,26 @@ var CART_FRAGMENT = `#graphql
|
|
677
677
|
|
678
678
|
// src/providers/RebuyHydrogenReactContextProvider.tsx
|
679
679
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
680
|
-
var
|
681
|
-
var
|
682
|
-
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;
|
683
683
|
var PUBLIC_STOREFRONT_ID = import.meta.env.PUBLIC_STOREFRONT_ID;
|
684
684
|
var PUBLIC_STOREFRONT_API_TOKEN = import.meta.env.PUBLIC_STOREFRONT_API_TOKEN || "";
|
685
685
|
var RebuyHydrogenReactContext = ({ children }) => {
|
686
|
-
if (!PUBLIC_PRIMARY_DOMAIN2) {
|
687
|
-
throw new Error("Missing required environment variable: PUBLIC_PRIMARY_DOMAIN");
|
688
|
-
}
|
689
|
-
if (!PUBLIC_REBUY_API_KEY2) {
|
690
|
-
throw new Error("Missing required environment variable: PUBLIC_REBUY_API_KEY");
|
691
|
-
}
|
692
|
-
if (!PUBLIC_STORE_DOMAIN2) {
|
693
|
-
throw new Error("Missing required environment variable: PUBLIC_STORE_DOMAIN");
|
694
|
-
}
|
695
686
|
const [rebuyConfig, setRebuyConfig] = useState2(null);
|
696
687
|
const location = useLocation2();
|
697
688
|
const queryObject = Utilities3.queryStringToObject(location.search);
|
698
|
-
const windowUrl = `${
|
689
|
+
const windowUrl = `${PUBLIC_PRIMARY_DOMAIN}${location.pathname}${location.search}`;
|
699
690
|
const cart = useCart();
|
700
691
|
useEffect2(() => {
|
701
692
|
const initConfig = async () => {
|
702
|
-
const config = await getRebuyConfig(
|
693
|
+
const config = await getRebuyConfig(PUBLIC_REBUY_API_KEY, PUBLIC_STORE_DOMAIN);
|
703
694
|
setRebuyConfig(config);
|
704
695
|
};
|
705
696
|
if (!rebuyConfig?.shop) {
|
706
697
|
initConfig();
|
707
698
|
}
|
708
|
-
}, [rebuyConfig,
|
699
|
+
}, [rebuyConfig, PUBLIC_REBUY_API_KEY, PUBLIC_STORE_DOMAIN]);
|
709
700
|
const contextParameters = useMemo2(
|
710
701
|
() => createContextParameters({
|
711
702
|
cacheKey: rebuyConfig?.shop?.cache_key,
|
@@ -777,7 +768,7 @@ var RebuyHydrogenReactContextProvider = ({
|
|
777
768
|
{
|
778
769
|
countryIsoCode,
|
779
770
|
languageIsoCode,
|
780
|
-
storeDomain:
|
771
|
+
storeDomain: PUBLIC_STORE_DOMAIN,
|
781
772
|
storefrontApiVersion,
|
782
773
|
storefrontId: PUBLIC_STOREFRONT_ID,
|
783
774
|
storefrontToken: PUBLIC_STOREFRONT_API_TOKEN,
|