@replohq/sdk 1.13.3 → 1.13.5
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/_vendor/schemas/errors.d.ts +1 -0
- package/cart/buy-now-action.js +2 -1
- package/cart/cart-provider.js +34 -12
- package/hooks/browser-locale.d.ts +1 -0
- package/hooks/browser-locale.js +10 -0
- package/hooks/use-formatted-price.js +2 -1
- package/lib/buildMetadata.js +3 -3
- package/next/image-loader.js +10 -0
- package/package.json +4 -4
|
@@ -59,6 +59,7 @@ export type ReploAuthenticationErrorConfig = {
|
|
|
59
59
|
type: AuthErrorType;
|
|
60
60
|
userFacingDetails?: ErrorUserFacingDetailsWithMessage;
|
|
61
61
|
additionalData?: ReploErrorConfig["additionalData"];
|
|
62
|
+
cause?: ReploErrorConfig["cause"];
|
|
62
63
|
};
|
|
63
64
|
export declare class ReploAuthenticationError extends ReploError {
|
|
64
65
|
type: AuthErrorType;
|
package/cart/buy-now-action.js
CHANGED
|
@@ -80,11 +80,12 @@ async function buyNowWithRecoveryAction(input) {
|
|
|
80
80
|
retry: z.literal("newAttempt"),
|
|
81
81
|
message: z.string().min(1)
|
|
82
82
|
}).safeParse(await response.json());
|
|
83
|
-
if (terminalAttempt.success)
|
|
83
|
+
if (terminalAttempt.success) {
|
|
84
84
|
return {
|
|
85
85
|
result: "restartCheckout",
|
|
86
86
|
message: terminalAttempt.data.message
|
|
87
87
|
};
|
|
88
|
+
}
|
|
88
89
|
}
|
|
89
90
|
throw new BuyNowCartCreationError({
|
|
90
91
|
message: "Failed to create Stripe checkout session for buy now",
|
package/cart/cart-provider.js
CHANGED
|
@@ -38,10 +38,14 @@ function getSharedReconciledCart(country) {
|
|
|
38
38
|
}
|
|
39
39
|
const previousLoad = cartLoadPromise;
|
|
40
40
|
const load = (async () => {
|
|
41
|
-
if (previousLoad)
|
|
41
|
+
if (previousLoad) {
|
|
42
|
+
await previousLoad.catch(() => null);
|
|
43
|
+
}
|
|
42
44
|
return await reconcileCartAction({ country });
|
|
43
45
|
})().finally(() => {
|
|
44
|
-
if (cartLoadPromise === load)
|
|
46
|
+
if (cartLoadPromise === load) {
|
|
47
|
+
cartLoadPromise = null;
|
|
48
|
+
}
|
|
45
49
|
});
|
|
46
50
|
cartLoadCountry = country;
|
|
47
51
|
cartLoadPromise = load;
|
|
@@ -53,7 +57,9 @@ function getOrCreateSharedCart(country) {
|
|
|
53
57
|
}
|
|
54
58
|
const previousCreation = cartCreationPromise;
|
|
55
59
|
const creation = (async () => {
|
|
56
|
-
if (previousCreation)
|
|
60
|
+
if (previousCreation) {
|
|
61
|
+
await previousCreation.catch(() => null);
|
|
62
|
+
}
|
|
57
63
|
const cart = await getOrCreateCartAction({ country });
|
|
58
64
|
if (!cart) {
|
|
59
65
|
throw new CartContextError({
|
|
@@ -62,7 +68,9 @@ function getOrCreateSharedCart(country) {
|
|
|
62
68
|
}
|
|
63
69
|
return cart;
|
|
64
70
|
})().finally(() => {
|
|
65
|
-
if (cartCreationPromise === creation)
|
|
71
|
+
if (cartCreationPromise === creation) {
|
|
72
|
+
cartCreationPromise = null;
|
|
73
|
+
}
|
|
66
74
|
});
|
|
67
75
|
cartCreationCountry = country;
|
|
68
76
|
cartCreationPromise = creation;
|
|
@@ -209,10 +217,11 @@ function CartProvider({
|
|
|
209
217
|
await cartCreationPromise?.catch(() => null);
|
|
210
218
|
if (needsRefresh.current) {
|
|
211
219
|
const restoredCart = await getCartAction();
|
|
212
|
-
if (!restoredCart)
|
|
220
|
+
if (!restoredCart) {
|
|
213
221
|
throw new CartContextError({
|
|
214
222
|
message: "Your cart could not be refreshed. Please reload before changing it."
|
|
215
223
|
});
|
|
224
|
+
}
|
|
216
225
|
serverCart.current = restoredCart;
|
|
217
226
|
needsRefresh.current = false;
|
|
218
227
|
}
|
|
@@ -223,15 +232,18 @@ function CartProvider({
|
|
|
223
232
|
}
|
|
224
233
|
try {
|
|
225
234
|
const savedCart = await save(serverCart.current);
|
|
226
|
-
if (!savedCart)
|
|
235
|
+
if (!savedCart) {
|
|
227
236
|
throw new CartContextError({
|
|
228
237
|
message: "Your cart could not be saved. Please try again."
|
|
229
238
|
});
|
|
239
|
+
}
|
|
230
240
|
serverCart.current = savedCart;
|
|
231
241
|
} catch (error2) {
|
|
232
242
|
const restoredCart = await getCartAction().catch(() => null);
|
|
233
243
|
needsRefresh.current = !restoredCart;
|
|
234
|
-
if (restoredCart)
|
|
244
|
+
if (restoredCart) {
|
|
245
|
+
serverCart.current = restoredCart;
|
|
246
|
+
}
|
|
235
247
|
throw error2;
|
|
236
248
|
}
|
|
237
249
|
});
|
|
@@ -255,7 +267,9 @@ function CartProvider({
|
|
|
255
267
|
originalLine
|
|
256
268
|
}) => {
|
|
257
269
|
const existingLine = currentCart.lines.find((line) => line.id === lineId);
|
|
258
|
-
if (existingLine)
|
|
270
|
+
if (existingLine) {
|
|
271
|
+
return existingLine;
|
|
272
|
+
}
|
|
259
273
|
const optimisticLine = optimisticLines.current.get(lineId);
|
|
260
274
|
const merchandiseId = optimisticLine?.id ?? originalLine?.merchandise?.id;
|
|
261
275
|
const sellingPlanId = optimisticLine?.sellingPlanId ?? originalLine?.sellingPlanAllocation?.sellingPlan.id ?? null;
|
|
@@ -280,7 +294,9 @@ function CartProvider({
|
|
|
280
294
|
);
|
|
281
295
|
}
|
|
282
296
|
serverCart.current = loadedCart;
|
|
283
|
-
if (pendingMutations.current === 0)
|
|
297
|
+
if (pendingMutations.current === 0) {
|
|
298
|
+
updateCartData(loadedCart);
|
|
299
|
+
}
|
|
284
300
|
return loadedCart;
|
|
285
301
|
})();
|
|
286
302
|
cartInitialization.current = { country, promise: initialization };
|
|
@@ -293,14 +309,18 @@ function CartProvider({
|
|
|
293
309
|
}, [country, updateCartData]);
|
|
294
310
|
const getOrCreateCartForMutation = React.useCallback(async () => {
|
|
295
311
|
const loadedCart = await reconcilePersistedCart();
|
|
296
|
-
if (loadedCart)
|
|
312
|
+
if (loadedCart) {
|
|
313
|
+
return loadedCart;
|
|
314
|
+
}
|
|
297
315
|
const selection = marketSelection.current;
|
|
298
316
|
const createdCart = await getOrCreateSharedCart(country);
|
|
299
317
|
if (!isMounted.current || marketSelection.current !== selection) {
|
|
300
318
|
throw new DOMException("Cart creation was superseded", "AbortError");
|
|
301
319
|
}
|
|
302
320
|
serverCart.current = createdCart;
|
|
303
|
-
if (pendingMutations.current === 0)
|
|
321
|
+
if (pendingMutations.current === 0) {
|
|
322
|
+
updateCartData(createdCart);
|
|
323
|
+
}
|
|
304
324
|
return createdCart;
|
|
305
325
|
}, [country, reconcilePersistedCart, updateCartData]);
|
|
306
326
|
React.useEffect(() => {
|
|
@@ -358,7 +378,9 @@ function CartProvider({
|
|
|
358
378
|
(lines, openCartAfterAdd = true) => {
|
|
359
379
|
return runWithErrorState("add", async () => {
|
|
360
380
|
const readyCart = cartData ?? serverCart.current ?? await getOrCreateCartForMutation().catch((caught) => {
|
|
361
|
-
if (openCartAfterAdd)
|
|
381
|
+
if (openCartAfterAdd) {
|
|
382
|
+
setIsCartOpen(true);
|
|
383
|
+
}
|
|
362
384
|
throw caught;
|
|
363
385
|
});
|
|
364
386
|
reportedLineQuantities.current.clear();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getValidBrowserLocale(browserLanguage: string): string;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { formatAmount } from "../_vendor/schemas/money.mjs";
|
|
2
|
+
import { getValidBrowserLocale } from "./browser-locale";
|
|
2
3
|
import { useClientValue } from "./use-client-value";
|
|
3
4
|
const useFormattedPrice = (price, currency) => {
|
|
4
5
|
const navigatorLanguage = useClientValue(
|
|
5
|
-
() => window.navigator.language,
|
|
6
|
+
() => getValidBrowserLocale(window.navigator.language),
|
|
6
7
|
"en-US"
|
|
7
8
|
);
|
|
8
9
|
if (price === null) {
|
package/lib/buildMetadata.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const BUILD_METADATA = {
|
|
2
2
|
"packageName": "@replohq/sdk",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.5",
|
|
4
4
|
"branch": "HEAD",
|
|
5
|
-
"commit": "
|
|
6
|
-
"builtAt": "2026-09-
|
|
5
|
+
"commit": "478717af374584697f8e305ab76117c4aa95f444",
|
|
6
|
+
"builtAt": "2026-09-25T08:34:14.026Z"
|
|
7
7
|
};
|
package/next/image-loader.js
CHANGED
|
@@ -2,6 +2,13 @@ const REPLO_IMAGE_CDN = "https://assets.replocdn.com";
|
|
|
2
2
|
function isContentfulImagesCdn(hostname) {
|
|
3
3
|
return /^images(?:\.[a-z]+)?\.ctfassets\.net$/i.test(hostname);
|
|
4
4
|
}
|
|
5
|
+
function isAvifSource(src) {
|
|
6
|
+
try {
|
|
7
|
+
return new URL(src, REPLO_IMAGE_CDN).pathname.toLowerCase().endsWith(".avif");
|
|
8
|
+
} catch {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
5
12
|
function contentfulImagesApiUrl({
|
|
6
13
|
src,
|
|
7
14
|
width,
|
|
@@ -20,6 +27,9 @@ function cloudflareLoader({
|
|
|
20
27
|
width,
|
|
21
28
|
quality
|
|
22
29
|
}) {
|
|
30
|
+
if (isAvifSource(src)) {
|
|
31
|
+
return src;
|
|
32
|
+
}
|
|
23
33
|
const isDevelopment = process.env.NODE_ENV === "development";
|
|
24
34
|
const params = [`width=${width}`, `quality=${quality ?? 75}`, "format=auto"];
|
|
25
35
|
if (/^https:\/\//i.test(src)) {
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@replohq/sdk",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.5",
|
|
4
4
|
"reploBuild": {
|
|
5
5
|
"packageName": "@replohq/sdk",
|
|
6
|
-
"version": "1.13.
|
|
6
|
+
"version": "1.13.5",
|
|
7
7
|
"branch": "HEAD",
|
|
8
|
-
"commit": "
|
|
9
|
-
"builtAt": "2026-09-
|
|
8
|
+
"commit": "478717af374584697f8e305ab76117c4aa95f444",
|
|
9
|
+
"builtAt": "2026-09-25T08:34:14.026Z"
|
|
10
10
|
},
|
|
11
11
|
"description": "Replo SDK — cart, analytics, and data loaders for agent-built Next.js sites.",
|
|
12
12
|
"license": "SEE LICENSE IN LICENSE",
|