@forgecart/cli 2.202607122305.0 → 2.202607150804.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forgecart/cli",
3
- "version": "2.202607122305.0",
3
+ "version": "2.202607150804.0",
4
4
  "type": "module",
5
5
  "description": "CLI for scaffolding and operating ForgeCart channel storefronts",
6
6
  "bin": {
@@ -68,9 +68,17 @@ async function persistSession(client: ForgeCartShopClient): Promise<void> {
68
68
  * cart immediately instead of driving the client into a doomed fetch. The
69
69
  * layout renders on every route, so this read must never stall an unconfigured
70
70
  * scaffold.
71
+ *
72
+ * No session cookie ⇒ no cart, WITHOUT calling the API. The shop's activeOrder
73
+ * read auto-creates an order for the session — and a Server Component can't
74
+ * persist a session cookie — so an eager read used to MINT an anonymous
75
+ * session plus an orphan order on every cookie-less page view. The order (and
76
+ * the cookie, via persistSession) is created lazily by the first addToCart.
71
77
  */
72
78
  export async function getCart(): Promise<Order | null> {
73
79
  if (!SHOP_API_URL || !CHANNEL_TOKEN) return null;
80
+ const store = await cookies();
81
+ if (!store.get(SESSION_COOKIE)?.value) return null;
74
82
  const client = await getCartClient();
75
83
  const { activeOrder } = await client.order.activeOrder();
76
84
  return activeOrder ?? null;