@replohq/sdk 1.13.4 → 1.13.6-beta.pr-27483-proof.8.1.gfe0053a
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/replo-utils/lib/misc.d.ts +4 -0
- package/_vendor/replo-utils/lib/misc.mjs +1 -1
- package/_vendor/schemas/money.mjs +1 -1
- package/_vendor/schemas/routing/locale.mjs +1 -1
- package/_vendor/schemas/routing/rules.mjs +1 -1
- package/cart/buy-now-action.js +2 -1
- package/cart/cart-loader.d.ts +3 -4
- package/cart/cart-loader.js +1 -8
- package/cart/cart-provider.js +34 -12
- package/{chunk-ZKAX2FW3.mjs → chunk-HFKL4ZR5.mjs} +21 -1
- 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/package.json +4 -4
|
@@ -142,4 +142,8 @@ export declare function coerceNumberToString(value: string | number | null): str
|
|
|
142
142
|
*/
|
|
143
143
|
export declare function formatFileSize(byteCount: number, decimalPlaces?: number): string;
|
|
144
144
|
export declare const sleep: (ms: number) => Promise<unknown>;
|
|
145
|
+
export declare function sleepWithSignal({ delayMs, signal, }: {
|
|
146
|
+
delayMs: number;
|
|
147
|
+
signal: AbortSignal | null;
|
|
148
|
+
}): Promise<unknown>;
|
|
145
149
|
export declare function errorMessage(error: unknown): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { coerceNumberToString, deepCloneAndMergeReplacingArrays, errorMessage, exhaustiveSwitch, formatFileSize, getFromRecordOrNull, hasOwnProperty, invariant, isEmpty, isNotNullish, isNullish, isPrimitive, mergeReplacingArrays, mergeReplacingObjects, noop, preventDefault, sleep, warning } from '../../../chunk-
|
|
1
|
+
export { coerceNumberToString, deepCloneAndMergeReplacingArrays, errorMessage, exhaustiveSwitch, formatFileSize, getFromRecordOrNull, hasOwnProperty, invariant, isEmpty, isNotNullish, isNullish, isPrimitive, mergeReplacingArrays, mergeReplacingObjects, noop, preventDefault, sleep, sleepWithSignal, warning } from '../../../chunk-HFKL4ZR5.mjs';
|
|
2
2
|
export { isNumber_default as isNumber, isString_default as isString } from '../../../chunk-EUIVDITZ.mjs';
|
|
3
3
|
export { isFunction_default as isFunction } from '../../../chunk-SSBIMQES.mjs';
|
|
4
4
|
import '../../../chunk-UJCSKKID.mjs';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getParamSegment, getRouteParams, hasRouteParam, matchSource } from '../../../chunk-VPEVERWE.mjs';
|
|
2
2
|
import { ReploError } from '../../../chunk-Y3AYABMK.mjs';
|
|
3
|
-
import '../../../chunk-
|
|
3
|
+
import '../../../chunk-HFKL4ZR5.mjs';
|
|
4
4
|
import '../../../chunk-EUIVDITZ.mjs';
|
|
5
5
|
import '../../../chunk-SSBIMQES.mjs';
|
|
6
6
|
import '../../../chunk-UJCSKKID.mjs';
|
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-loader.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { StorefrontCountryCode } from "../loaders/markets";
|
|
2
2
|
/**
|
|
3
|
-
* Server component that
|
|
4
|
-
*
|
|
5
|
-
* cart loading to avoid cookie issues during development.
|
|
3
|
+
* Server component that provides the cart context to child components. The
|
|
4
|
+
* provider loads any persisted cart in the browser after hydration.
|
|
6
5
|
*
|
|
7
6
|
* @param children - Child components that will have access to the cart
|
|
8
|
-
* @returns A CartProvider component wrapping the children
|
|
7
|
+
* @returns A CartProvider component wrapping the children
|
|
9
8
|
*/
|
|
10
9
|
export declare function CartLoader({ children, country, shouldReconcileSuppliedCart, }: React.PropsWithChildren<{
|
|
11
10
|
country?: StorefrontCountryCode;
|
package/cart/cart-loader.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { unstable_rethrow } from "next/navigation";
|
|
3
|
-
import { getCartAction } from "./cart-actions";
|
|
4
2
|
import { CartProvider } from "./cart-provider";
|
|
5
3
|
import { SuppliedCartReconciliationBoundary } from "./supplied-cart-reconciliation";
|
|
6
4
|
async function CartLoader({
|
|
@@ -8,12 +6,7 @@ async function CartLoader({
|
|
|
8
6
|
country,
|
|
9
7
|
shouldReconcileSuppliedCart
|
|
10
8
|
}) {
|
|
11
|
-
|
|
12
|
-
unstable_rethrow(error);
|
|
13
|
-
console.warn("[Replo] Failed to load cart:", error);
|
|
14
|
-
return null;
|
|
15
|
-
});
|
|
16
|
-
return /* @__PURE__ */ jsx(SuppliedCartReconciliationBoundary, { enabled: shouldReconcileSuppliedCart, children: /* @__PURE__ */ jsx(CartProvider, { cart, country, children }) });
|
|
9
|
+
return /* @__PURE__ */ jsx(SuppliedCartReconciliationBoundary, { enabled: shouldReconcileSuppliedCart, children: /* @__PURE__ */ jsx(CartProvider, { cart: null, country, children }) });
|
|
17
10
|
}
|
|
18
11
|
export {
|
|
19
12
|
CartLoader
|
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();
|
|
@@ -689,6 +689,26 @@ function formatFileSize(byteCount, decimalPlaces = 0) {
|
|
|
689
689
|
var sleep = async (ms) => {
|
|
690
690
|
return await new Promise((resolve) => setTimeout(resolve, ms));
|
|
691
691
|
};
|
|
692
|
+
function sleepWithSignal({
|
|
693
|
+
delayMs,
|
|
694
|
+
signal
|
|
695
|
+
}) {
|
|
696
|
+
if (signal === null) {
|
|
697
|
+
return sleep(delayMs);
|
|
698
|
+
}
|
|
699
|
+
signal.throwIfAborted();
|
|
700
|
+
return new Promise((resolve, reject) => {
|
|
701
|
+
const onAbort = () => {
|
|
702
|
+
clearTimeout(timeoutId);
|
|
703
|
+
reject(signal.reason);
|
|
704
|
+
};
|
|
705
|
+
const timeoutId = setTimeout(() => {
|
|
706
|
+
signal.removeEventListener("abort", onAbort);
|
|
707
|
+
resolve();
|
|
708
|
+
}, delayMs);
|
|
709
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
710
|
+
});
|
|
711
|
+
}
|
|
692
712
|
function errorMessage(error) {
|
|
693
713
|
if (error instanceof Error) {
|
|
694
714
|
return error.message;
|
|
@@ -700,4 +720,4 @@ function errorMessage(error) {
|
|
|
700
720
|
return String(error);
|
|
701
721
|
}
|
|
702
722
|
|
|
703
|
-
export { coerceNumberToString, deepCloneAndMergeReplacingArrays, errorMessage, exhaustiveSwitch, formatFileSize, getFromRecordOrNull, hasOwnProperty4 as hasOwnProperty, invariant, isEmpty2 as isEmpty, isNotNullish, isNullish, isPrimitive, mergeReplacingArrays, mergeReplacingObjects, noop, preventDefault, sleep, warning };
|
|
723
|
+
export { coerceNumberToString, deepCloneAndMergeReplacingArrays, errorMessage, exhaustiveSwitch, formatFileSize, getFromRecordOrNull, hasOwnProperty4 as hasOwnProperty, invariant, isEmpty2 as isEmpty, isNotNullish, isNullish, isPrimitive, mergeReplacingArrays, mergeReplacingObjects, noop, preventDefault, sleep, sleepWithSignal, warning };
|
|
@@ -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.6",
|
|
4
4
|
"branch": "HEAD",
|
|
5
|
-
"commit": "
|
|
6
|
-
"builtAt": "2026-
|
|
5
|
+
"commit": "fe0053a00bb3468932593a9cd60f637a58a55491",
|
|
6
|
+
"builtAt": "2026-10-02T15:54:20.457Z"
|
|
7
7
|
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@replohq/sdk",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.6-beta.pr-27483-proof.8.1.gfe0053a",
|
|
4
4
|
"reploBuild": {
|
|
5
5
|
"packageName": "@replohq/sdk",
|
|
6
|
-
"version": "1.13.
|
|
6
|
+
"version": "1.13.6",
|
|
7
7
|
"branch": "HEAD",
|
|
8
|
-
"commit": "
|
|
9
|
-
"builtAt": "2026-
|
|
8
|
+
"commit": "fe0053a00bb3468932593a9cd60f637a58a55491",
|
|
9
|
+
"builtAt": "2026-10-02T15:54:20.457Z"
|
|
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",
|