@shopkit/cart 0.1.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/CHANGELOG.md +58 -0
- package/README.md +216 -0
- package/dist/index.d.mts +730 -0
- package/dist/index.d.ts +730 -0
- package/dist/index.js +2 -0
- package/dist/index.mjs +2 -0
- package/package.json +60 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';var zustand=require('zustand'),react=require('react');var C=null;function b(t){C=t;}function l(){if(!C)throw new Error("Cart not configured. Call configureCart() first.");return C}function E(){return C!==null}var u=zustand.create((t,e)=>({items:[],isOpen:false,isLoading:false,error:null,cartId:null,totalAmount:void 0,isInitialized:false,initializeCart:async r=>{let{isInitialized:a}=e();if(a)return;let i=l(),{cartService:n,cartStorage:s}=i,c=r??i.merchantName;try{let d=s.getCartId();if(d)try{let o=await n.getCart(d);t({items:o.items||[],cartId:d,checkoutUrl:o.checkoutUrl,totalAmount:o.totalAmount,isInitialized:!0}),i.onCartEvent?.({type:"CART_INITIALIZED",cartId:d});}catch{s.removeCartId();let o=await n.createCart(c);s.setCartId(o.token),t({items:o.items||[],cartId:o.token,checkoutUrl:o.checkoutUrl,totalAmount:o.totalAmount,isInitialized:!0}),i.onCartEvent?.({type:"CART_INITIALIZED",cartId:o.token});}else {let o=await n.createCart(c);s.setCartId(o.token),t({items:o.items||[],cartId:o.token,checkoutUrl:o.checkoutUrl,totalAmount:o.totalAmount,isInitialized:!0}),i.onCartEvent?.({type:"CART_INITIALIZED",cartId:o.token});}}catch{t({error:"Failed to initialize cart",isInitialized:true}),i.onCartEvent?.({type:"CART_ERROR",action:"initializeCart",error:"Failed to initialize cart"});}},addItem:async r=>{let{cartId:a}=e();if(!a)return;let{cartService:i,onCartEvent:n}=l();try{t({isLoading:!0,error:null});let s=[{productId:r.productId||r.id,variantId:r.variantId||r.id,quantity:r.quantity}];await i.addToCart(a,s);let c=await i.getCart(a);t({items:c.items||[],checkoutUrl:c.checkoutUrl,totalAmount:c.totalAmount,isLoading:!1}),n?.({type:"ADD_TO_CART",item:r});}catch{t({error:"Failed to add item",isLoading:false}),n?.({type:"CART_ERROR",action:"addItem",error:"Failed to add item"});}},addItems:async r=>{let{cartId:a}=e();if(!a)return;let{cartService:i,onCartEvent:n}=l();try{t({isLoading:!0,error:null}),await i.addToCart(a,r);let s=await i.getCart(a);t({items:s.items||[],checkoutUrl:s.checkoutUrl,totalAmount:s.totalAmount,isLoading:!1});}catch{t({error:"Failed to add items",isLoading:false}),n?.({type:"CART_ERROR",action:"addItems",error:"Failed to add items"});}},removeItem:async(r,a)=>{let{cartId:i,items:n}=e();if(!i)return;let{cartService:s,onCartEvent:c}=l();try{t({isLoading:!0,error:null});let d=n.find(p=>a?p.id===r||p.productId===r&&p.variantId===a:p.id===r);if(!d){t({isLoading:!1});return}await s.removeFromCart(i,[d.id]);let o=await s.getCart(i);t({items:o.items||[],checkoutUrl:o.checkoutUrl,totalAmount:o.totalAmount,isLoading:!1}),c?.({type:"REMOVE_FROM_CART",item:d});}catch{t({error:"Failed to remove item",isLoading:false}),c?.({type:"CART_ERROR",action:"removeItem",error:"Failed to remove item"});}},updateItemQuantity:async(r,a,i)=>{let{cartId:n,items:s}=e();if(!n)return;if(a<=0)return e().removeItem(r,i);let{cartService:c,onCartEvent:d}=l();try{t({isLoading:!0,error:null});let o=s.find(m=>i?m.id===r||m.productId===r&&m.variantId===i:m.id===r);if(!o){t({isLoading:!1});return}let p=o.quantity,L=s.map(m=>({productId:m.productId,variantId:m.variantId||"",quantity:m.id===o.id?a:m.quantity}));await c.updateCart(n,L);let h=await c.getCart(n);t({items:h.items||[],checkoutUrl:h.checkoutUrl,totalAmount:h.totalAmount,isLoading:!1}),d?.({type:"UPDATE_QUANTITY",item:{...o,quantity:a},previousQuantity:p});}catch{t({error:"Failed to update quantity",isLoading:false}),d?.({type:"CART_ERROR",action:"updateItemQuantity",error:"Failed to update quantity"});}},clearCart:async()=>{let{cartId:r,items:a}=e();if(!r)return;let{cartService:i,onCartEvent:n}=l();try{t({isLoading:!0,error:null}),await i.updateCart(r,[]);let s=a.length;t({items:[],isLoading:!1}),n?.({type:"CLEAR_CART",itemCount:s});}catch{t({error:"Failed to clear cart",isLoading:false}),n?.({type:"CART_ERROR",action:"clearCart",error:"Failed to clear cart"});}},openCart:async()=>{let{cartId:r}=e(),{cartService:a,onCartEvent:i}=l();if(r)try{let n=await a.getCart(r);t({items:n.items||[],checkoutUrl:n.checkoutUrl,totalAmount:n.totalAmount,isOpen:!0});}catch{t({isOpen:true});}else t({isOpen:true});i?.({type:"CART_OPENED"});},closeCart:()=>{t({isOpen:false}),l().onCartEvent?.({type:"CART_CLOSED"});},toggleCart:async()=>{let{isOpen:r}=e();r?e().closeCart():await e().openCart();}}));var O=()=>u(t=>t.isInitialized?t.items.length:0),D=()=>u(t=>t.isInitialized?t.items.reduce((e,r)=>e+r.quantity,0):0),U=()=>u(t=>t.items),k=()=>u(t=>t.toggleCart),q=()=>u(t=>({isOpen:t.isOpen,isLoading:t.isLoading,error:t.error,cartId:t.cartId,isInitialized:t.isInitialized})),F=()=>u(t=>t.items.reduce((e,r)=>e+r.price.amount*r.quantity,0)),z=()=>u(t=>t.totalAmount),_=(t,e)=>u(r=>r.items.some(a=>e?a.productId===t&&a.variantId===e:a.productId===t)),N=(t,e)=>u(r=>r.items.find(a=>e?a.productId===t&&a.variantId===e:a.productId===t)),$=()=>u(t=>t.checkoutUrl);function f(t,e,r,a="USD"){let i=e?t.variants?.find(o=>o.id===e)||t.variants?.[0]:t.variants?.find(o=>o.available)||t.variants?.[0],n=i?.price||t.price,s=typeof n=="number"?{amount:n,currencyCode:a}:n,c=i?.compareAtPrice||t.compareAtPrice,d=c?typeof c=="number"?{amount:c,currencyCode:a}:c:void 0;return {id:`${t.id}-${e||i?.id||"default"}`,productId:t.id,variantId:e||i?.id,title:t.title,price:s,compareAtPrice:d,quantity:r||t.quantity||1,image:t.images?.[0]?.url||t.image,vendor:t.vendor}}function v(t){let[e,r]=react.useState({}),{addItem:a}=u();return {addToCart:async(s,c,d)=>{if(s){r(o=>({...o,[s.id]:true}));try{let o=f(s,c,d,t?.defaultCurrencyCode);await a(o),t?.onSuccess?.(o);}catch(o){let p=o instanceof Error?o:new Error("Failed to add product to cart");t?.onError?.(p);}finally{r(o=>({...o,[s.id]:false}));}}},loadingStates:e,isLoading:s=>e[s]??false}}var y=class{constructor(e="/api/v1/cart"){this.baseUrl=e;}async makeRequest(e,r){return fetch(e,{headers:{"Content-Type":"application/json",...r.headers},...r})}async handleResponse(e,r){if(!e.ok){let a=await e.text();throw new Error(`${r}: ${e.status} ${a}`)}return e.json()}async createCart(e){let r=await this.makeRequest(this.baseUrl,{method:"POST",body:JSON.stringify({merchantName:e})});return this.handleResponse(r,"Failed to create cart")}async getCart(e){let r=await this.makeRequest(`${this.baseUrl}/get`,{method:"POST",body:JSON.stringify({cartId:e})});return this.handleResponse(r,"Failed to get cart")}async addToCart(e,r){let a=await this.makeRequest(`${this.baseUrl}/add`,{method:"POST",body:JSON.stringify({cartId:e,items:r})});await this.handleResponse(a,"Failed to add item to cart");}async removeFromCart(e,r){let a=await this.makeRequest(`${this.baseUrl}/remove`,{method:"POST",body:JSON.stringify({cartId:e,itemIds:r})});await this.handleResponse(a,"Failed to remove item from cart");}async updateCart(e,r){let a=await this.makeRequest(`${this.baseUrl}/update`,{method:"POST",body:JSON.stringify({cartId:e,items:r})});await this.handleResponse(a,"Failed to update cart");}};var g=class{constructor(e="default"){this.merchantName=e;}getStorageKey(e){return `${this.merchantName?`merchant_${this.merchantName}`:"default"}_${e}`}get(e){if(typeof window>"u")return null;try{return localStorage.getItem(this.getStorageKey(e))}catch{return null}}set(e,r){if(!(typeof window>"u"))try{localStorage.setItem(this.getStorageKey(e),r);}catch{}}remove(e){if(!(typeof window>"u"))try{localStorage.removeItem(this.getStorageKey(e));}catch{}}getCartId(){return this.get("cartId")}setCartId(e){this.set("cartId",e);}removeCartId(){this.remove("cartId");}clear(){if(!(typeof window>"u"))try{let e=Object.keys(localStorage),r=this.getStorageKey("");e.forEach(a=>{a.startsWith(r)&&localStorage.removeItem(a);});}catch{}}};var I=class{constructor(e){this.client=e;}unwrapResponse(e){if(!e.success)throw new Error(e.message||"Cart operation failed");if(e.data===null)throw new Error("Cart data is null");return e.data}async createCart(e){let r=await this.client.createCart({merchantName:e});return this.unwrapResponse(r)}async getCart(e){let r=await this.client.getCart({id:e});return this.unwrapResponse(r)}async addToCart(e,r){let a=await this.client.addToCart({id:e,items:r});this.unwrapResponse(a);}async removeFromCart(e,r){let a=await this.client.removeFromCart({id:e,itemIds:r});this.unwrapResponse(a);}async updateCart(e,r){let a=await this.client.updateCart({id:e,items:r});this.unwrapResponse(a);}};function R(t){return t&&typeof t.getCart=="function"&&typeof t.createCart=="function"&&typeof t.addToCart=="function"}function T(t,e="USD",r){try{return new Intl.NumberFormat(r,{style:"currency",currency:e}).format(t)}catch{return `${e} ${t.toFixed(2)}`}}function A(t){return t.reduce((e,r)=>{let a=typeof r.price=="number"?r.price:r.price.amount;return e+a*r.quantity},0)}function S(t){return t.reduce((e,r)=>{if(!r.compareAtPrice)return e;let a=typeof r.price=="number"?r.price:r.price.amount,n=(typeof r.compareAtPrice=="number"?r.compareAtPrice:r.compareAtPrice.amount)-a;return e+Math.max(0,n)*r.quantity},0)}function x({merchantName:t}){let e=u(a=>a.initializeCart),r=u(a=>a.isOpen);return react.useEffect(()=>{e(t);},[t,e]),react.useEffect(()=>(document.body.style.overflow=r?"hidden":"",()=>{document.body.style.overflow="";}),[r]),null}exports.CartInitializer=x;exports.DataLayerCartService=I;exports.DefaultCartService=y;exports.DefaultCartStorage=g;exports.calculateCartTotal=A;exports.calculateSavings=S;exports.configureCart=b;exports.formatPrice=T;exports.getCartConfig=l;exports.isCartConfigured=E;exports.isDataLayerClient=R;exports.mapProductToCartItem=f;exports.useAddToCart=v;exports.useCartCount=O;exports.useCartItem=N;exports.useCartItems=U;exports.useCartStatus=q;exports.useCartStore=u;exports.useCartToggle=k;exports.useCartTotal=F;exports.useCartTotalAmount=z;exports.useCartTotalQuantity=D;exports.useCheckoutUrl=$;exports.useIsInCart=_;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {create}from'zustand';import {useState,useEffect}from'react';var C=null;function b(t){C=t;}function l(){if(!C)throw new Error("Cart not configured. Call configureCart() first.");return C}function E(){return C!==null}var u=create((t,e)=>({items:[],isOpen:false,isLoading:false,error:null,cartId:null,totalAmount:void 0,isInitialized:false,initializeCart:async r=>{let{isInitialized:a}=e();if(a)return;let i=l(),{cartService:n,cartStorage:s}=i,c=r??i.merchantName;try{let d=s.getCartId();if(d)try{let o=await n.getCart(d);t({items:o.items||[],cartId:d,checkoutUrl:o.checkoutUrl,totalAmount:o.totalAmount,isInitialized:!0}),i.onCartEvent?.({type:"CART_INITIALIZED",cartId:d});}catch{s.removeCartId();let o=await n.createCart(c);s.setCartId(o.token),t({items:o.items||[],cartId:o.token,checkoutUrl:o.checkoutUrl,totalAmount:o.totalAmount,isInitialized:!0}),i.onCartEvent?.({type:"CART_INITIALIZED",cartId:o.token});}else {let o=await n.createCart(c);s.setCartId(o.token),t({items:o.items||[],cartId:o.token,checkoutUrl:o.checkoutUrl,totalAmount:o.totalAmount,isInitialized:!0}),i.onCartEvent?.({type:"CART_INITIALIZED",cartId:o.token});}}catch{t({error:"Failed to initialize cart",isInitialized:true}),i.onCartEvent?.({type:"CART_ERROR",action:"initializeCart",error:"Failed to initialize cart"});}},addItem:async r=>{let{cartId:a}=e();if(!a)return;let{cartService:i,onCartEvent:n}=l();try{t({isLoading:!0,error:null});let s=[{productId:r.productId||r.id,variantId:r.variantId||r.id,quantity:r.quantity}];await i.addToCart(a,s);let c=await i.getCart(a);t({items:c.items||[],checkoutUrl:c.checkoutUrl,totalAmount:c.totalAmount,isLoading:!1}),n?.({type:"ADD_TO_CART",item:r});}catch{t({error:"Failed to add item",isLoading:false}),n?.({type:"CART_ERROR",action:"addItem",error:"Failed to add item"});}},addItems:async r=>{let{cartId:a}=e();if(!a)return;let{cartService:i,onCartEvent:n}=l();try{t({isLoading:!0,error:null}),await i.addToCart(a,r);let s=await i.getCart(a);t({items:s.items||[],checkoutUrl:s.checkoutUrl,totalAmount:s.totalAmount,isLoading:!1});}catch{t({error:"Failed to add items",isLoading:false}),n?.({type:"CART_ERROR",action:"addItems",error:"Failed to add items"});}},removeItem:async(r,a)=>{let{cartId:i,items:n}=e();if(!i)return;let{cartService:s,onCartEvent:c}=l();try{t({isLoading:!0,error:null});let d=n.find(p=>a?p.id===r||p.productId===r&&p.variantId===a:p.id===r);if(!d){t({isLoading:!1});return}await s.removeFromCart(i,[d.id]);let o=await s.getCart(i);t({items:o.items||[],checkoutUrl:o.checkoutUrl,totalAmount:o.totalAmount,isLoading:!1}),c?.({type:"REMOVE_FROM_CART",item:d});}catch{t({error:"Failed to remove item",isLoading:false}),c?.({type:"CART_ERROR",action:"removeItem",error:"Failed to remove item"});}},updateItemQuantity:async(r,a,i)=>{let{cartId:n,items:s}=e();if(!n)return;if(a<=0)return e().removeItem(r,i);let{cartService:c,onCartEvent:d}=l();try{t({isLoading:!0,error:null});let o=s.find(m=>i?m.id===r||m.productId===r&&m.variantId===i:m.id===r);if(!o){t({isLoading:!1});return}let p=o.quantity,L=s.map(m=>({productId:m.productId,variantId:m.variantId||"",quantity:m.id===o.id?a:m.quantity}));await c.updateCart(n,L);let h=await c.getCart(n);t({items:h.items||[],checkoutUrl:h.checkoutUrl,totalAmount:h.totalAmount,isLoading:!1}),d?.({type:"UPDATE_QUANTITY",item:{...o,quantity:a},previousQuantity:p});}catch{t({error:"Failed to update quantity",isLoading:false}),d?.({type:"CART_ERROR",action:"updateItemQuantity",error:"Failed to update quantity"});}},clearCart:async()=>{let{cartId:r,items:a}=e();if(!r)return;let{cartService:i,onCartEvent:n}=l();try{t({isLoading:!0,error:null}),await i.updateCart(r,[]);let s=a.length;t({items:[],isLoading:!1}),n?.({type:"CLEAR_CART",itemCount:s});}catch{t({error:"Failed to clear cart",isLoading:false}),n?.({type:"CART_ERROR",action:"clearCart",error:"Failed to clear cart"});}},openCart:async()=>{let{cartId:r}=e(),{cartService:a,onCartEvent:i}=l();if(r)try{let n=await a.getCart(r);t({items:n.items||[],checkoutUrl:n.checkoutUrl,totalAmount:n.totalAmount,isOpen:!0});}catch{t({isOpen:true});}else t({isOpen:true});i?.({type:"CART_OPENED"});},closeCart:()=>{t({isOpen:false}),l().onCartEvent?.({type:"CART_CLOSED"});},toggleCart:async()=>{let{isOpen:r}=e();r?e().closeCart():await e().openCart();}}));var O=()=>u(t=>t.isInitialized?t.items.length:0),D=()=>u(t=>t.isInitialized?t.items.reduce((e,r)=>e+r.quantity,0):0),U=()=>u(t=>t.items),k=()=>u(t=>t.toggleCart),q=()=>u(t=>({isOpen:t.isOpen,isLoading:t.isLoading,error:t.error,cartId:t.cartId,isInitialized:t.isInitialized})),F=()=>u(t=>t.items.reduce((e,r)=>e+r.price.amount*r.quantity,0)),z=()=>u(t=>t.totalAmount),_=(t,e)=>u(r=>r.items.some(a=>e?a.productId===t&&a.variantId===e:a.productId===t)),N=(t,e)=>u(r=>r.items.find(a=>e?a.productId===t&&a.variantId===e:a.productId===t)),$=()=>u(t=>t.checkoutUrl);function f(t,e,r,a="USD"){let i=e?t.variants?.find(o=>o.id===e)||t.variants?.[0]:t.variants?.find(o=>o.available)||t.variants?.[0],n=i?.price||t.price,s=typeof n=="number"?{amount:n,currencyCode:a}:n,c=i?.compareAtPrice||t.compareAtPrice,d=c?typeof c=="number"?{amount:c,currencyCode:a}:c:void 0;return {id:`${t.id}-${e||i?.id||"default"}`,productId:t.id,variantId:e||i?.id,title:t.title,price:s,compareAtPrice:d,quantity:r||t.quantity||1,image:t.images?.[0]?.url||t.image,vendor:t.vendor}}function v(t){let[e,r]=useState({}),{addItem:a}=u();return {addToCart:async(s,c,d)=>{if(s){r(o=>({...o,[s.id]:true}));try{let o=f(s,c,d,t?.defaultCurrencyCode);await a(o),t?.onSuccess?.(o);}catch(o){let p=o instanceof Error?o:new Error("Failed to add product to cart");t?.onError?.(p);}finally{r(o=>({...o,[s.id]:false}));}}},loadingStates:e,isLoading:s=>e[s]??false}}var y=class{constructor(e="/api/v1/cart"){this.baseUrl=e;}async makeRequest(e,r){return fetch(e,{headers:{"Content-Type":"application/json",...r.headers},...r})}async handleResponse(e,r){if(!e.ok){let a=await e.text();throw new Error(`${r}: ${e.status} ${a}`)}return e.json()}async createCart(e){let r=await this.makeRequest(this.baseUrl,{method:"POST",body:JSON.stringify({merchantName:e})});return this.handleResponse(r,"Failed to create cart")}async getCart(e){let r=await this.makeRequest(`${this.baseUrl}/get`,{method:"POST",body:JSON.stringify({cartId:e})});return this.handleResponse(r,"Failed to get cart")}async addToCart(e,r){let a=await this.makeRequest(`${this.baseUrl}/add`,{method:"POST",body:JSON.stringify({cartId:e,items:r})});await this.handleResponse(a,"Failed to add item to cart");}async removeFromCart(e,r){let a=await this.makeRequest(`${this.baseUrl}/remove`,{method:"POST",body:JSON.stringify({cartId:e,itemIds:r})});await this.handleResponse(a,"Failed to remove item from cart");}async updateCart(e,r){let a=await this.makeRequest(`${this.baseUrl}/update`,{method:"POST",body:JSON.stringify({cartId:e,items:r})});await this.handleResponse(a,"Failed to update cart");}};var g=class{constructor(e="default"){this.merchantName=e;}getStorageKey(e){return `${this.merchantName?`merchant_${this.merchantName}`:"default"}_${e}`}get(e){if(typeof window>"u")return null;try{return localStorage.getItem(this.getStorageKey(e))}catch{return null}}set(e,r){if(!(typeof window>"u"))try{localStorage.setItem(this.getStorageKey(e),r);}catch{}}remove(e){if(!(typeof window>"u"))try{localStorage.removeItem(this.getStorageKey(e));}catch{}}getCartId(){return this.get("cartId")}setCartId(e){this.set("cartId",e);}removeCartId(){this.remove("cartId");}clear(){if(!(typeof window>"u"))try{let e=Object.keys(localStorage),r=this.getStorageKey("");e.forEach(a=>{a.startsWith(r)&&localStorage.removeItem(a);});}catch{}}};var I=class{constructor(e){this.client=e;}unwrapResponse(e){if(!e.success)throw new Error(e.message||"Cart operation failed");if(e.data===null)throw new Error("Cart data is null");return e.data}async createCart(e){let r=await this.client.createCart({merchantName:e});return this.unwrapResponse(r)}async getCart(e){let r=await this.client.getCart({id:e});return this.unwrapResponse(r)}async addToCart(e,r){let a=await this.client.addToCart({id:e,items:r});this.unwrapResponse(a);}async removeFromCart(e,r){let a=await this.client.removeFromCart({id:e,itemIds:r});this.unwrapResponse(a);}async updateCart(e,r){let a=await this.client.updateCart({id:e,items:r});this.unwrapResponse(a);}};function R(t){return t&&typeof t.getCart=="function"&&typeof t.createCart=="function"&&typeof t.addToCart=="function"}function T(t,e="USD",r){try{return new Intl.NumberFormat(r,{style:"currency",currency:e}).format(t)}catch{return `${e} ${t.toFixed(2)}`}}function A(t){return t.reduce((e,r)=>{let a=typeof r.price=="number"?r.price:r.price.amount;return e+a*r.quantity},0)}function S(t){return t.reduce((e,r)=>{if(!r.compareAtPrice)return e;let a=typeof r.price=="number"?r.price:r.price.amount,n=(typeof r.compareAtPrice=="number"?r.compareAtPrice:r.compareAtPrice.amount)-a;return e+Math.max(0,n)*r.quantity},0)}function x({merchantName:t}){let e=u(a=>a.initializeCart),r=u(a=>a.isOpen);return useEffect(()=>{e(t);},[t,e]),useEffect(()=>(document.body.style.overflow=r?"hidden":"",()=>{document.body.style.overflow="";}),[r]),null}export{x as CartInitializer,I as DataLayerCartService,y as DefaultCartService,g as DefaultCartStorage,A as calculateCartTotal,S as calculateSavings,b as configureCart,T as formatPrice,l as getCartConfig,E as isCartConfigured,R as isDataLayerClient,f as mapProductToCartItem,v as useAddToCart,O as useCartCount,N as useCartItem,U as useCartItems,q as useCartStatus,u as useCartStore,k as useCartToggle,F as useCartTotal,z as useCartTotalAmount,D as useCartTotalQuantity,$ as useCheckoutUrl,_ as useIsInCart};
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@shopkit/cart",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Cart state management, hooks, and services for e-commerce storefronts",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"require": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md",
|
|
19
|
+
"CHANGELOG.md"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsup",
|
|
23
|
+
"dev": "tsup --watch",
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
25
|
+
"clean": "rm -rf dist",
|
|
26
|
+
"test": "vitest run",
|
|
27
|
+
"test:watch": "vitest",
|
|
28
|
+
"test:coverage": "vitest run --coverage",
|
|
29
|
+
"test:ui": "vitest --ui"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"react": "^18.0.0",
|
|
33
|
+
"zustand": "^4.4.0 || ^5.0.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@testing-library/react": "^14.0.0",
|
|
37
|
+
"@types/react": "^18.2.0",
|
|
38
|
+
"@vitest/coverage-v8": "^1.0.0",
|
|
39
|
+
"@vitest/ui": "^1.0.0",
|
|
40
|
+
"jsdom": "^23.0.0",
|
|
41
|
+
"react": "^18.2.0",
|
|
42
|
+
"react-dom": "^18.2.0",
|
|
43
|
+
"tsup": "^8.0.0",
|
|
44
|
+
"typescript": "^5.3.0",
|
|
45
|
+
"vitest": "^1.0.0",
|
|
46
|
+
"zustand": "^4.4.0"
|
|
47
|
+
},
|
|
48
|
+
"keywords": [
|
|
49
|
+
"cart",
|
|
50
|
+
"e-commerce",
|
|
51
|
+
"storefront",
|
|
52
|
+
"react",
|
|
53
|
+
"zustand",
|
|
54
|
+
"shopkit"
|
|
55
|
+
],
|
|
56
|
+
"license": "MIT",
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"access": "public"
|
|
59
|
+
}
|
|
60
|
+
}
|