@revenexx/cover 0.2.16 → 0.2.17
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/app/composables/useCartStore.ts +23 -12
- package/package.json +1 -1
|
@@ -45,22 +45,33 @@ export const useCartStore = defineStore("cart", () => {
|
|
|
45
45
|
// design. In live mode the carts app is the source of truth: the active
|
|
46
46
|
// cart syncs through /api/cart, the multi-cart list through /api/carts.
|
|
47
47
|
const devModeCookie = useCookie<string | null>("cover-dev-mode", { default: () => null, watch: true });
|
|
48
|
+
const appConfig = useAppConfig();
|
|
48
49
|
const liveCarts = computed(() => {
|
|
50
|
+
// The dev panel may force a mode / per-domain override via the cookie;
|
|
51
|
+
// otherwise follow the storefront's configured cart service (app.config),
|
|
52
|
+
// mirroring the server's service-key resolution. Without this, a real
|
|
53
|
+
// customer (no dev cookie) always resolved to mock — so the carts app was
|
|
54
|
+
// never the client-side source of truth and the cart never survived login.
|
|
49
55
|
const raw = devModeCookie.value;
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
if (raw) {
|
|
57
|
+
try {
|
|
58
|
+
const parsed = (typeof raw === "string" ? JSON.parse(raw) : raw) as { mode?: string; overrides?: Record<string, string> };
|
|
59
|
+
const override = parsed.overrides?.cartService;
|
|
60
|
+
if (override) {
|
|
61
|
+
return override === "api";
|
|
62
|
+
}
|
|
63
|
+
if (parsed.mode === "live") {
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
if (parsed.mode === "mock") {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
// malformed cookie → fall back to the app.config default below
|
|
58
72
|
}
|
|
59
|
-
return parsed.mode === "live";
|
|
60
|
-
}
|
|
61
|
-
catch {
|
|
62
|
-
return false;
|
|
63
73
|
}
|
|
74
|
+
return (appConfig.cartService as string | undefined) === "api";
|
|
64
75
|
});
|
|
65
76
|
const SERVER_CART_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
66
77
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revenexx/cover",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.17",
|
|
4
4
|
"description": "Cover \u2014 revenexx design system for Nuxt. Distributed as a Nuxt layer: generic UI components, theming tokens and stores shared by the demo shop, custom storefronts and the Blokkli theme.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./nuxt.config.ts",
|