@adminide-stack/yantra-mobile 12.0.95-alpha.0 â 12.0.95-alpha.1
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/lib/features/canvas/sessionIdentity.js +8 -1
- package/lib/features/canvas/sessionIdentity.js.map +1 -1
- package/lib/features/canvas/useCanvasSession.js +1 -0
- package/lib/features/canvas/useCanvasSession.js.map +1 -1
- package/lib/features/shopping/OrdersPanel.js +2 -2
- package/lib/features/shopping/OrdersPanel.js.map +1 -1
- package/lib/features/shopping/ProductCard.js +3 -3
- package/lib/features/shopping/ProductCard.js.map +1 -1
- package/lib/features/shopping/ProductDetailSheet.js +2 -2
- package/lib/features/shopping/ProductDetailSheet.js.map +1 -1
- package/lib/features/shopping/SavedPanel.js +2 -2
- package/lib/features/shopping/SavedPanel.js.map +1 -1
- package/lib/features/shopping/ShoppingExperience.js +46 -13
- package/lib/features/shopping/ShoppingExperience.js.map +1 -1
- package/lib/features/shopping/cartCloudSync.js +73 -0
- package/lib/features/shopping/cartCloudSync.js.map +1 -0
- package/lib/features/shopping/catalog.js +5 -1
- package/lib/features/shopping/catalog.js.map +1 -1
- package/lib/features/shopping/services/cartCloud.js +118 -0
- package/lib/features/shopping/services/cartCloud.js.map +1 -0
- package/lib/features/shopping/shoppingCart.js +17 -1
- package/lib/features/shopping/shoppingCart.js.map +1 -1
- package/lib/features/shopping/useCartCloudSync.js +33 -0
- package/lib/features/shopping/useCartCloudSync.js.map +1 -0
- package/lib/screens/ShoppingNative/index.js +2 -1
- package/lib/screens/ShoppingNative/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.js","sources":["../../../src/features/shopping/catalog.ts"],"sourcesContent":["/**\n * Storefront catalog types â native twin of `@yantra/shopping-surface` catalog.ts.\n */\n\nexport const PRODUCT_SOURCES = [\n 'catalog',\n 'amazon',\n 'walmart',\n 'bestbuy',\n 'ebay',\n 'target',\n 'shopify',\n 'costco',\n 'homedepot',\n 'lowes',\n 'newegg',\n 'google',\n 'yantra',\n] as const;\n\nexport type ProductSource = (typeof PRODUCT_SOURCES)[number];\n\nexport function isProductSource(value: string | undefined): value is ProductSource {\n return !!value && (PRODUCT_SOURCES as readonly string[]).includes(value);\n}\n\nexport interface Department {\n id: string;\n title: string;\n icon: string;\n tagline: string;\n accent: string;\n}\n\nexport interface Product {\n id: string;\n name: string;\n departmentId: string;\n price: number;\n rating: number;\n reviews: number;\n icon: string;\n accent: string;\n imageUrl?: string;\n url?: string;\n asin?: string;\n isPrime?: boolean;\n sponsored?: boolean;\n source?: ProductSource;\n originalPrice?: number;\n discountPercent?: number;\n currency?: string;\n inStock?: boolean;\n /** Live page check confirmed the product URL opens. */\n linkVerified?: boolean;\n /** Live page check confirmed the listed price. */\n priceVerified?: boolean;\n brand?: string;\n retailerId?: string;\n sku?: string;\n upc?: string;\n ean?: string;\n gtin?: string;\n mpn?: string;\n}\n\nexport const DEPARTMENTS: Department[] = [\n { id: 'high-tech', title: 'High-Tech', icon: 'ðŧ', tagline: 'Phones, laptops & audio', accent: '#6366F1' },\n { id: 'sports', title: 'Sports & leisure', icon: 'ðī', tagline: 'Gear for every season', accent: '#10B981' },\n { id: 'beauty', title: 'Beauty & wellness', icon: 'ð', tagline: 'Skincare, makeup & more', accent: '#EC4899' },\n { id: 'home-garden', title: 'Lawn & Garden', icon: 'ðŠī', tagline: 'Furniture, BBQ & lighting', accent: '#F59E0B' },\n { id: 'office', title: 'Offices', icon: 'ðĨïļ', tagline: 'Desks, tablets & supplies', accent: '#0EA5E9' },\n { id: 'toys', title: 'Toys & Games', icon: 'ð§ļ', tagline: 'Fun for all ages', accent: '#EF4444' },\n { id: 'fashion', title: 'Clothing & Shoes', icon: 'ð', tagline: 'Apparel, shoes & bags', accent: '#8B5CF6' },\n { id: 'grocery', title: 'Grocery & Household', icon: 'ð', tagline: 'Pantry, cleaning & paper', accent: '#14B8A6' },\n { id: 'auto', title: 'Auto & Tools', icon: 'ð§', tagline: 'Car care & power tools', accent: '#64748B' },\n { id: 'pets', title: 'Pet Supplies', icon: 'ðū', tagline: 'Food, toys & beds', accent: '#F97316' },\n {\n id: 'kitchen',\n title: 'Kitchen & Dining',\n icon: 'ðģ',\n tagline: 'Cookware, appliances & tableware',\n accent: '#E11D48',\n },\n {\n id: 'furniture',\n title: 'Furniture & Decor',\n icon: 'ðïļ',\n tagline: 'Sofas, storage & lighting',\n accent: '#A16207',\n },\n { id: 'baby', title: 'Baby & Kids', icon: 'ðž', tagline: 'Strollers, car seats & clothing', accent: '#F472B6' },\n {\n id: 'health',\n title: 'Health & Fitness',\n icon: 'ðŠ',\n tagline: 'Supplements, trackers & equipment',\n accent: '#22C55E',\n },\n { id: 'gaming', title: 'Gaming', icon: 'ðŪ', tagline: 'Consoles, PC parts & accessories', accent: '#7C3AED' },\n { id: 'books', title: 'Books & Media', icon: 'ð', tagline: 'Books, music & movies', accent: '#0891B2' },\n {\n id: 'jewelry',\n title: 'Jewelry & Watches',\n icon: 'â',\n tagline: 'Watches, rings & fine jewelry',\n accent: '#CA8A04',\n },\n {\n id: 'travel',\n title: 'Travel & Luggage',\n icon: 'ð§ģ',\n tagline: 'Suitcases, bags & accessories',\n accent: '#2563EB',\n },\n {\n id: 'music',\n title: 'Musical Instruments',\n icon: 'ðļ',\n tagline: 'Guitars, keyboards & audio gear',\n accent: '#DC2626',\n },\n { id: 'camera', title: 'Cameras & Photo', icon: 'ð·', tagline: 'Cameras, lenses & drones', accent: '#475569' },\n];\n\nexport const NEUTRAL_DEPARTMENT: Department = {\n id: '',\n title: 'All departments',\n icon: '\\u{1F6CD}',\n tagline: 'Everything the stores carry',\n accent: '#94A3B8',\n};\n\nexport function departmentBadge(departmentId?: string): Department {\n return (departmentId && DEPARTMENTS.find((d) => d.id === departmentId)) || NEUTRAL_DEPARTMENT;\n}\n\nexport function productIdentifier(\n product: Pick<Product, 'upc' | 'ean' | 'gtin' | 'asin'>,\n): { identifier: string; lookupType: 'upc' | 'ean' | 'gtin' | 'asin' } | null {\n if (product.upc) return { identifier: product.upc, lookupType: 'upc' };\n if (product.ean) return { identifier: product.ean, lookupType: 'ean' };\n if (product.gtin) return { identifier: product.gtin, lookupType: 'gtin' };\n if (product.asin) return { identifier: product.asin, lookupType: 'asin' };\n return null;\n}\n\nexport function formatPrice(value: number, currency = 'USD'): string {\n return new Intl.NumberFormat(undefined, { style: 'currency', currency }).format(value);\n}\n\nexport const SOURCE_ORDER: ProductSource[] = [...PRODUCT_SOURCES];\n\nexport const SOURCE_LABELS: Record<ProductSource, string> = {\n catalog: 'Catalog',\n amazon: 'Amazon',\n walmart: 'Walmart',\n bestbuy: 'Best Buy',\n ebay: 'eBay',\n target: 'Target',\n costco: 'Costco',\n homedepot: 'Home Depot',\n lowes: \"Lowe's\",\n newegg: 'Newegg',\n shopify: 'Shopify',\n google: 'Google Shopping',\n yantra: 'Yantra picks',\n};\n\nexport const SOURCE_SECTION: Record<ProductSource, { title: string; subtitle: string }> = {\n catalog: {\n title: 'Catalog matches',\n subtitle: 'Typed rows via LemmeBuyIt â list price, discount and identifiers',\n },\n amazon: { title: 'Amazon results', subtitle: 'Live Amazon SERP via yantra-shopping-search' },\n walmart: { title: 'Walmart results', subtitle: 'Live Walmart SERP via yantra-shopping-search' },\n bestbuy: { title: 'Best Buy results', subtitle: 'Live Best Buy listings via yantra-shopping-search' },\n ebay: { title: 'eBay results', subtitle: 'Live eBay SERP via yantra-shopping-search' },\n target: { title: 'Target results', subtitle: 'Live Target SERP via yantra-shopping-search' },\n costco: { title: 'Costco results', subtitle: 'Indexed and live retailer coverage' },\n homedepot: { title: 'Home Depot results', subtitle: 'Indexed and live retailer coverage' },\n lowes: { title: \"Lowe's results\", subtitle: 'Indexed and live retailer coverage' },\n newegg: { title: 'Newegg results', subtitle: 'Indexed and live retailer coverage' },\n shopify: { title: 'Shopify results', subtitle: 'Live Shopify SERP via yantra-shopping-search' },\n google: {\n title: 'Google Shopping results',\n subtitle: 'Shops with no section of their own â matched across the web',\n },\n yantra: { title: 'Yantra picks', subtitle: 'Curated research via yantra-shopping-search' },\n};\n\nexport function productSource(product: Product): ProductSource {\n return product.source && isProductSource(product.source) ? product.source : 'yantra';\n}\n\nexport function amazonImageUrlFromAsin(asin: string | undefined | null): string | undefined {\n const id = asin?.trim();\n if (!id || !/^[A-Z0-9]{10}$/i.test(id)) return undefined;\n return `https://m.media-amazon.com/images/P/${id.toUpperCase()}.01._SCLZZZZZZZ_SX250_.jpg`;\n}\n"],"names":[],"mappings":"AAIO,MAAM,eAAkB,GAAA,CAAC,SAAW,EAAA,QAAA,EAAU,WAAW,SAAW,EAAA,MAAA,EAAQ,QAAU,EAAA,SAAA,EAAW,QAAU,EAAA,WAAA,EAAa,OAAS,EAAA,QAAA,EAAU,UAAU,QAAQ;AAE7J,SAAS,gBAAgB,KAAmD,EAAA;AACjF,EAAA,OAAO,CAAC,CAAC,KAAU,IAAA,eAAA,CAAsC,SAAS,KAAK,CAAA;AACzE;AAuCO,MAAM,cAA4B,CAAC;AAAA,EACxC,EAAI,EAAA,WAAA;AAAA,EACJ,KAAO,EAAA,WAAA;AAAA,EACP,IAAM,EAAA,WAAA;AAAA,EACN,OAAS,EAAA,yBAAA;AAAA,EACT,MAAQ,EAAA;AACV,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,QAAA;AAAA,EACJ,KAAO,EAAA,kBAAA;AAAA,EACP,IAAM,EAAA,WAAA;AAAA,EACN,OAAS,EAAA,uBAAA;AAAA,EACT,MAAQ,EAAA;AACV,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,QAAA;AAAA,EACJ,KAAO,EAAA,mBAAA;AAAA,EACP,IAAM,EAAA,WAAA;AAAA,EACN,OAAS,EAAA,yBAAA;AAAA,EACT,MAAQ,EAAA;AACV,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,aAAA;AAAA,EACJ,KAAO,EAAA,eAAA;AAAA,EACP,IAAM,EAAA,WAAA;AAAA,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GACZ;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,KAAO,EAAA,gBAAA;AAAA,IACP,QAAU,EAAA;AAAA,GACZ;AAAA,EACA,OAAS,EAAA;AAAA,IACP,KAAO,EAAA,iBAAA;AAAA,IACP,QAAU,EAAA;AAAA,GACZ;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,KAAO,EAAA,yBAAA;AAAA,IACP,QAAU,EAAA;AAAA,GACZ;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,KAAO,EAAA,cAAA;AAAA,IACP,QAAU,EAAA;AAAA;AAEd;AACO,SAAS,cAAc,OAAiC,EAAA;AAC7D,EAAA,OAAO,QAAQ,MAAU,IAAA,eAAA,CAAgB,QAAQ,MAAM,CAAA,GAAI,QAAQ,MAAS,GAAA,QAAA;AAC9E;AACO,SAAS,uBAAuB,IAAqD,EAAA;AAC1F,EAAA,MAAM,KAAK,IAAM,IAAA,IAAA,GAAA,MAAA,GAAA,IAAA,CAAA,IAAA,EAAA;AACjB,EAAA,IAAI,CAAC,EAAM,IAAA,CAAC,kBAAkB,IAAK,CAAA,EAAE,GAAU,OAAA,MAAA;AAC/C,EAAO,OAAA,CAAA,oCAAA,EAAuC,EAAG,CAAA,WAAA,EAAa,CAAA,0BAAA,CAAA;AAChE"}
|
|
1
|
+
{"version":3,"file":"catalog.js","sources":["../../../src/features/shopping/catalog.ts"],"sourcesContent":["/**\n * Storefront catalog types â native twin of `@yantra/shopping-surface` catalog.ts.\n */\n\nexport const PRODUCT_SOURCES = [\n 'catalog',\n 'amazon',\n 'walmart',\n 'bestbuy',\n 'ebay',\n 'target',\n 'shopify',\n 'costco',\n 'homedepot',\n 'lowes',\n 'newegg',\n 'google',\n 'yantra',\n] as const;\n\nexport type ProductSource = (typeof PRODUCT_SOURCES)[number];\n\nexport function isProductSource(value: string | undefined): value is ProductSource {\n return !!value && (PRODUCT_SOURCES as readonly string[]).includes(value);\n}\n\nexport interface Department {\n id: string;\n title: string;\n icon: string;\n tagline: string;\n accent: string;\n}\n\nexport interface Product {\n id: string;\n name: string;\n departmentId: string;\n price: number;\n rating: number;\n reviews: number;\n icon: string;\n accent: string;\n imageUrl?: string;\n url?: string;\n asin?: string;\n isPrime?: boolean;\n sponsored?: boolean;\n source?: ProductSource;\n originalPrice?: number;\n discountPercent?: number;\n currency?: string;\n inStock?: boolean;\n /** Live page check confirmed the product URL opens. */\n linkVerified?: boolean;\n /** Live page check confirmed the listed price. */\n priceVerified?: boolean;\n brand?: string;\n retailerId?: string;\n sku?: string;\n upc?: string;\n ean?: string;\n gtin?: string;\n mpn?: string;\n}\n\nexport const DEPARTMENTS: Department[] = [\n { id: 'high-tech', title: 'High-Tech', icon: 'ðŧ', tagline: 'Phones, laptops & audio', accent: '#6366F1' },\n { id: 'sports', title: 'Sports & leisure', icon: 'ðī', tagline: 'Gear for every season', accent: '#10B981' },\n { id: 'beauty', title: 'Beauty & wellness', icon: 'ð', tagline: 'Skincare, makeup & more', accent: '#EC4899' },\n { id: 'home-garden', title: 'Lawn & Garden', icon: 'ðŠī', tagline: 'Furniture, BBQ & lighting', accent: '#F59E0B' },\n { id: 'office', title: 'Offices', icon: 'ðĨïļ', tagline: 'Desks, tablets & supplies', accent: '#0EA5E9' },\n { id: 'toys', title: 'Toys & Games', icon: 'ð§ļ', tagline: 'Fun for all ages', accent: '#EF4444' },\n { id: 'fashion', title: 'Clothing & Shoes', icon: 'ð', tagline: 'Apparel, shoes & bags', accent: '#8B5CF6' },\n { id: 'grocery', title: 'Grocery & Household', icon: 'ð', tagline: 'Pantry, cleaning & paper', accent: '#14B8A6' },\n { id: 'auto', title: 'Auto & Tools', icon: 'ð§', tagline: 'Car care & power tools', accent: '#64748B' },\n { id: 'pets', title: 'Pet Supplies', icon: 'ðū', tagline: 'Food, toys & beds', accent: '#F97316' },\n {\n id: 'kitchen',\n title: 'Kitchen & Dining',\n icon: 'ðģ',\n tagline: 'Cookware, appliances & tableware',\n accent: '#E11D48',\n },\n {\n id: 'furniture',\n title: 'Furniture & Decor',\n icon: 'ðïļ',\n tagline: 'Sofas, storage & lighting',\n accent: '#A16207',\n },\n { id: 'baby', title: 'Baby & Kids', icon: 'ðž', tagline: 'Strollers, car seats & clothing', accent: '#F472B6' },\n {\n id: 'health',\n title: 'Health & Fitness',\n icon: 'ðŠ',\n tagline: 'Supplements, trackers & equipment',\n accent: '#22C55E',\n },\n { id: 'gaming', title: 'Gaming', icon: 'ðŪ', tagline: 'Consoles, PC parts & accessories', accent: '#7C3AED' },\n { id: 'books', title: 'Books & Media', icon: 'ð', tagline: 'Books, music & movies', accent: '#0891B2' },\n {\n id: 'jewelry',\n title: 'Jewelry & Watches',\n icon: 'â',\n tagline: 'Watches, rings & fine jewelry',\n accent: '#CA8A04',\n },\n {\n id: 'travel',\n title: 'Travel & Luggage',\n icon: 'ð§ģ',\n tagline: 'Suitcases, bags & accessories',\n accent: '#2563EB',\n },\n {\n id: 'music',\n title: 'Musical Instruments',\n icon: 'ðļ',\n tagline: 'Guitars, keyboards & audio gear',\n accent: '#DC2626',\n },\n { id: 'camera', title: 'Cameras & Photo', icon: 'ð·', tagline: 'Cameras, lenses & drones', accent: '#475569' },\n];\n\nexport const NEUTRAL_DEPARTMENT: Department = {\n id: '',\n title: 'All departments',\n icon: '\\u{1F6CD}',\n tagline: 'Everything the stores carry',\n accent: '#94A3B8',\n};\n\nexport function departmentBadge(departmentId?: string): Department {\n return (departmentId && DEPARTMENTS.find((d) => d.id === departmentId)) || NEUTRAL_DEPARTMENT;\n}\n\nexport function productIdentifier(\n product: Pick<Product, 'upc' | 'ean' | 'gtin' | 'asin'>,\n): { identifier: string; lookupType: 'upc' | 'ean' | 'gtin' | 'asin' } | null {\n if (product.upc) return { identifier: product.upc, lookupType: 'upc' };\n if (product.ean) return { identifier: product.ean, lookupType: 'ean' };\n if (product.gtin) return { identifier: product.gtin, lookupType: 'gtin' };\n if (product.asin) return { identifier: product.asin, lookupType: 'asin' };\n return null;\n}\n\n/**\n * A product name as a shopper reads it. Names taken from a page title carry the\n * site in front (\"Amazon.com: 100Pcs Mochi Squishy Toy...\"), which repeats the\n * store badge and pushes the product words off a two-line card.\n */\nexport function productDisplayName(name: string): string {\n const cleaned = name\n .replace(/^\\s*(?:www\\.)?[a-z0-9-]+(?:\\.[a-z0-9-]+)*\\.(?:com|net|org|co\\.uk|ca|in)\\s*:\\s*/i, '')\n .trim();\n return cleaned || name.trim();\n}\n\nexport function formatPrice(value: number, currency = 'USD'): string {\n return new Intl.NumberFormat(undefined, { style: 'currency', currency }).format(value);\n}\n\nexport const SOURCE_ORDER: ProductSource[] = [...PRODUCT_SOURCES];\n\nexport const SOURCE_LABELS: Record<ProductSource, string> = {\n catalog: 'Catalog',\n amazon: 'Amazon',\n walmart: 'Walmart',\n bestbuy: 'Best Buy',\n ebay: 'eBay',\n target: 'Target',\n costco: 'Costco',\n homedepot: 'Home Depot',\n lowes: \"Lowe's\",\n newegg: 'Newegg',\n shopify: 'Shopify',\n google: 'Google Shopping',\n yantra: 'Yantra picks',\n};\n\nexport const SOURCE_SECTION: Record<ProductSource, { title: string; subtitle: string }> = {\n catalog: {\n title: 'Catalog matches',\n subtitle: 'Typed rows via LemmeBuyIt â list price, discount and identifiers',\n },\n amazon: { title: 'Amazon results', subtitle: 'Live Amazon SERP via yantra-shopping-search' },\n walmart: { title: 'Walmart results', subtitle: 'Live Walmart SERP via yantra-shopping-search' },\n bestbuy: { title: 'Best Buy results', subtitle: 'Live Best Buy listings via yantra-shopping-search' },\n ebay: { title: 'eBay results', subtitle: 'Live eBay SERP via yantra-shopping-search' },\n target: { title: 'Target results', subtitle: 'Live Target SERP via yantra-shopping-search' },\n costco: { title: 'Costco results', subtitle: 'Indexed and live retailer coverage' },\n homedepot: { title: 'Home Depot results', subtitle: 'Indexed and live retailer coverage' },\n lowes: { title: \"Lowe's results\", subtitle: 'Indexed and live retailer coverage' },\n newegg: { title: 'Newegg results', subtitle: 'Indexed and live retailer coverage' },\n shopify: { title: 'Shopify results', subtitle: 'Live Shopify SERP via yantra-shopping-search' },\n google: {\n title: 'Google Shopping results',\n subtitle: 'Shops with no section of their own â matched across the web',\n },\n yantra: { title: 'Yantra picks', subtitle: 'Curated research via yantra-shopping-search' },\n};\n\nexport function productSource(product: Product): ProductSource {\n return product.source && isProductSource(product.source) ? product.source : 'yantra';\n}\n\nexport function amazonImageUrlFromAsin(asin: string | undefined | null): string | undefined {\n const id = asin?.trim();\n if (!id || !/^[A-Z0-9]{10}$/i.test(id)) return undefined;\n return `https://m.media-amazon.com/images/P/${id.toUpperCase()}.01._SCLZZZZZZZ_SX250_.jpg`;\n}\n"],"names":[],"mappings":"AAIO,MAAM,eAAkB,GAAA,CAAC,SAAW,EAAA,QAAA,EAAU,WAAW,SAAW,EAAA,MAAA,EAAQ,QAAU,EAAA,SAAA,EAAW,QAAU,EAAA,WAAA,EAAa,OAAS,EAAA,QAAA,EAAU,UAAU,QAAQ;AAE7J,SAAS,gBAAgB,KAAmD,EAAA;AACjF,EAAA,OAAO,CAAC,CAAC,KAAU,IAAA,eAAA,CAAsC,SAAS,KAAK,CAAA;AACzE;AAuCO,MAAM,cAA4B,CAAC;AAAA,EACxC,EAAI,EAAA,WAAA;AAAA,EACJ,KAAO,EAAA,WAAA;AAAA,EACP,IAAM,EAAA,WAAA;AAAA,EACN,OAAS,EAAA,yBAAA;AAAA,EACT,MAAQ,EAAA;AACV,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,QAAA;AAAA,EACJ,KAAO,EAAA,kBAAA;AAAA,EACP,IAAM,EAAA,WAAA;AAAA,EACN,OAAS,EAAA,uBAAA;AAAA,EACT,MAAQ,EAAA;AACV,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,QAAA;AAAA,EACJ,KAAO,EAAA,mBAAA;AAAA,EACP,IAAM,EAAA,WAAA;AAAA,EACN,OAAS,EAAA,yBAAA;AAAA,EACT,MAAQ,EAAA;AACV,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,aAAA;AAAA,EACJ,KAAO,EA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AO,EAAA,gBAAA;AAAA,IACP,QAAU,EAAA;AAAA,GACZ;AAAA,EACA,SAAW,EAAA;AAAA,IACT,KAAO,EAAA,oBAAA;AAAA,IACP,QAAU,EAAA;AAAA,GACZ;AAAA,EACA,KAAO,EAAA;AAAA,IACL,KAAO,EAAA,gBAAA;AAAA,IACP,QAAU,EAAA;AAAA,GACZ;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,KAAO,EAAA,gBAAA;AAAA,IACP,QAAU,EAAA;AAAA,GACZ;AAAA,EACA,OAAS,EAAA;AAAA,IACP,KAAO,EAAA,iBAAA;AAAA,IACP,QAAU,EAAA;AAAA,GACZ;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,KAAO,EAAA,yBAAA;AAAA,IACP,QAAU,EAAA;AAAA,GACZ;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,KAAO,EAAA,cAAA;AAAA,IACP,QAAU,EAAA;AAAA;AAEd;AACO,SAAS,cAAc,OAAiC,EAAA;AAC7D,EAAA,OAAO,QAAQ,MAAU,IAAA,eAAA,CAAgB,QAAQ,MAAM,CAAA,GAAI,QAAQ,MAAS,GAAA,QAAA;AAC9E;AACO,SAAS,uBAAuB,IAAqD,EAAA;AAC1F,EAAA,MAAM,KAAK,IAAM,IAAA,IAAA,GAAA,MAAA,GAAA,IAAA,CAAA,IAAA,EAAA;AACjB,EAAA,IAAI,CAAC,EAAM,IAAA,CAAC,kBAAkB,IAAK,CAAA,EAAE,GAAU,OAAA,MAAA;AAC/C,EAAO,OAAA,CAAA,oCAAA,EAAuC,EAAG,CAAA,WAAA,EAAa,CAAA,0BAAA,CAAA;AAChE"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {tokenClaims}from'../../canvas/sessionIdentity.js';const CART_CONFIG_KEY = "account.shopping.cart";
|
|
2
|
+
const ORGANIZATION_TARGET = 4;
|
|
3
|
+
const REQUEST_TIMEOUT_MS = 15e3;
|
|
4
|
+
function cartResourceUri(token) {
|
|
5
|
+
var _a;
|
|
6
|
+
const claims = tokenClaims(token);
|
|
7
|
+
const raw = (_a = claims.cdecodeUri) != null ? _a : claims.cdecodeuri;
|
|
8
|
+
if (typeof raw === "string" && raw.trim()) {
|
|
9
|
+
const match = /^([a-z][\w+.-]*):\/\/([^/?#]*)([^?#]*)/i.exec(raw.trim());
|
|
10
|
+
if (match) {
|
|
11
|
+
const [, scheme, authority, rawPath] = match;
|
|
12
|
+
const segments = rawPath.split("/").filter(Boolean);
|
|
13
|
+
const path = scheme.toLowerCase() === "cdecode" && segments.length === 2 && segments[1] !== "projects" ? `/${segments[0]}/projects/${segments[1]}` : rawPath || "/";
|
|
14
|
+
return {
|
|
15
|
+
scheme,
|
|
16
|
+
authority: authority || "default",
|
|
17
|
+
path,
|
|
18
|
+
fragment: "settings"
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const org = claims.orgName;
|
|
23
|
+
if (typeof org === "string" && org.trim()) {
|
|
24
|
+
return {
|
|
25
|
+
scheme: "cdecode",
|
|
26
|
+
authority: "default",
|
|
27
|
+
path: `/${org.trim()}`,
|
|
28
|
+
fragment: "settings"
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
function backendBase(graphqlUrl) {
|
|
34
|
+
return graphqlUrl.trim().replace(/\/+$/, "").replace(/\/graphql$/i, "");
|
|
35
|
+
}
|
|
36
|
+
async function postJson(session, url, payload) {
|
|
37
|
+
const controller = new AbortController();
|
|
38
|
+
const timer = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
39
|
+
try {
|
|
40
|
+
const headers = {
|
|
41
|
+
"content-type": "application/json",
|
|
42
|
+
accept: "application/json",
|
|
43
|
+
authorization: `Bearer ${session.token}`
|
|
44
|
+
};
|
|
45
|
+
const {
|
|
46
|
+
cdecodeUri
|
|
47
|
+
} = tokenClaims(session.token);
|
|
48
|
+
if (typeof cdecodeUri === "string" && cdecodeUri) headers.cdecodeuri = cdecodeUri;
|
|
49
|
+
const res = await fetch(url, {
|
|
50
|
+
method: "POST",
|
|
51
|
+
headers,
|
|
52
|
+
body: JSON.stringify(payload),
|
|
53
|
+
signal: controller.signal
|
|
54
|
+
});
|
|
55
|
+
if (!res.ok) throw new Error(`cart sync: HTTP ${res.status}`);
|
|
56
|
+
return await res.json();
|
|
57
|
+
} finally {
|
|
58
|
+
clearTimeout(timer);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function isLine(value) {
|
|
62
|
+
const line = value;
|
|
63
|
+
return Boolean((line == null ? void 0 : line.product) && typeof line.product.id === "string" && line.product.id) && typeof (line == null ? void 0 : line.qty) === "number";
|
|
64
|
+
}
|
|
65
|
+
function extractCloudCart(settings) {
|
|
66
|
+
const root = settings && typeof settings === "object" ? settings : {};
|
|
67
|
+
let nested = root;
|
|
68
|
+
for (const segment of CART_CONFIG_KEY.split(".")) {
|
|
69
|
+
nested = nested && typeof nested === "object" ? nested[segment] : void 0;
|
|
70
|
+
}
|
|
71
|
+
for (const candidate of [root, root[CART_CONFIG_KEY], nested, root.cart]) {
|
|
72
|
+
const value = candidate;
|
|
73
|
+
if (value && Array.isArray(value.lines)) {
|
|
74
|
+
return {
|
|
75
|
+
lines: value.lines.filter(isLine),
|
|
76
|
+
updatedAt: typeof value.updatedAt === "number" ? value.updatedAt : 0
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
async function readCloudCart(session) {
|
|
83
|
+
const resourceUri = cartResourceUri(session.token);
|
|
84
|
+
if (!resourceUri) throw new Error("cart sync: the session token names no organization");
|
|
85
|
+
const page = await postJson(session, `${backendBase(session.graphqlUrl)}/v1/page-settings`, {
|
|
86
|
+
resourceUri,
|
|
87
|
+
options: {
|
|
88
|
+
configKey: CART_CONFIG_KEY,
|
|
89
|
+
target: ORGANIZATION_TARGET
|
|
90
|
+
},
|
|
91
|
+
noSidecar: true
|
|
92
|
+
});
|
|
93
|
+
return extractCloudCart(page == null ? void 0 : page.settings);
|
|
94
|
+
}
|
|
95
|
+
const CART_WRITE = `
|
|
96
|
+
mutation ShoppingCartSync($key: String!, $value: AnyObject!) {
|
|
97
|
+
updateConfigurationValue(key: $key, value: $value) {
|
|
98
|
+
__typename
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
`;
|
|
102
|
+
async function writeCloudCart(session, cart) {
|
|
103
|
+
var _a;
|
|
104
|
+
const body = await postJson(session, `${backendBase(session.graphqlUrl)}/graphql`, {
|
|
105
|
+
query: CART_WRITE,
|
|
106
|
+
variables: {
|
|
107
|
+
key: CART_CONFIG_KEY,
|
|
108
|
+
value: {
|
|
109
|
+
lines: cart.lines,
|
|
110
|
+
updatedAt: cart.updatedAt
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
if ((_a = body == null ? void 0 : body.errors) == null ? void 0 : _a.length) throw new Error(`cart sync: ${body.errors.map((e) => {
|
|
115
|
+
var _a2;
|
|
116
|
+
return (_a2 = e.message) != null ? _a2 : "error";
|
|
117
|
+
}).join("; ")}`);
|
|
118
|
+
}export{CART_CONFIG_KEY,cartResourceUri,extractCloudCart,readCloudCart,writeCloudCart};//# sourceMappingURL=cartCloud.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cartCloud.js","sources":["../../../../src/features/shopping/services/cartCloud.ts"],"sourcesContent":["/**\n * The account's copy of the basket - `account.shopping.cart`, the value the web\n * Shopping surface writes and the agent's cart actions\n * (`YANTRA_SHOPPING_SEARCH_CART` / `_CART_UPDATE`) read and edit.\n *\n * Same lane as those actions, with the same surface session token, so the\n * phone, the web and \"what's in my cart\" all address one basket:\n * - read: `POST /v1/page-settings` with `noSidecar`. The GraphQL `pageSettings`\n * query answers from a 24-hour response cache and the settings sidecar from a\n * 5-minute one, and neither is cleared by the cart's own write - a cached read\n * would hand back the basket from before the agent removed something, and the\n * next local edit would put it back.\n * - write: `updateConfigurationValue` with no target (the organization layer),\n * exactly as the web host writes it.\n */\nimport { tokenClaims } from '../../canvas/sessionIdentity';\nimport type { DurableCart } from '../shoppingCart';\n\nexport const CART_CONFIG_KEY = 'account.shopping.cart';\n\n/** ConfigurationTarget.ORGANIZATION - where a no-target `updateConfigurationValue` files the write. */\nconst ORGANIZATION_TARGET = 4;\nconst REQUEST_TIMEOUT_MS = 15_000;\n\nexport interface CartCloudSession {\n /** Surface session token (the account's system token) - not the Auth0 login token. */\n token: string;\n /** The backend that token was minted against (`.../graphql`). */\n graphqlUrl: string;\n}\n\ntype UriInput = { scheme: string; authority: string; path: string; fragment: string };\n\n/**\n * The settings file the token addresses: its `cdecodeUri` claim, else its org.\n * A legacy two-segment claim (`cdecode://default/<org>/<projectId>`) is rewritten\n * to the canonical `/<org>/projects/<projectId>` - the server rejects the short\n * form (\"resourceId is missing\"). Mirrors cli-tool `resolveResourceURI`.\n * Parsed by hand: React Native's URL does not take a custom scheme reliably.\n */\nexport function cartResourceUri(token: string): UriInput | null {\n const claims = tokenClaims(token);\n const raw = claims.cdecodeUri ?? claims.cdecodeuri;\n if (typeof raw === 'string' && raw.trim()) {\n const match = /^([a-z][\\w+.-]*):\\/\\/([^/?#]*)([^?#]*)/i.exec(raw.trim());\n if (match) {\n const [, scheme, authority, rawPath] = match;\n const segments = rawPath.split('/').filter(Boolean);\n const path =\n scheme.toLowerCase() === 'cdecode' && segments.length === 2 && segments[1] !== 'projects'\n ? `/${segments[0]}/projects/${segments[1]}`\n : rawPath || '/';\n return { scheme, authority: authority || 'default', path, fragment: 'settings' };\n }\n }\n const org = claims.orgName;\n if (typeof org === 'string' && org.trim()) {\n return { scheme: 'cdecode', authority: 'default', path: `/${org.trim()}`, fragment: 'settings' };\n }\n return null;\n}\n\nfunction backendBase(graphqlUrl: string): string {\n return graphqlUrl\n .trim()\n .replace(/\\/+$/, '')\n .replace(/\\/graphql$/i, '');\n}\n\nasync function postJson<T>(session: CartCloudSession, url: string, payload: unknown): Promise<T> {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);\n try {\n const headers: Record<string, string> = {\n 'content-type': 'application/json',\n accept: 'application/json',\n authorization: `Bearer ${session.token}`,\n };\n const { cdecodeUri } = tokenClaims(session.token);\n if (typeof cdecodeUri === 'string' && cdecodeUri) headers.cdecodeuri = cdecodeUri;\n const res = await fetch(url, {\n method: 'POST',\n headers,\n body: JSON.stringify(payload),\n signal: controller.signal,\n });\n if (!res.ok) throw new Error(`cart sync: HTTP ${res.status}`);\n return (await res.json()) as T;\n } finally {\n clearTimeout(timer);\n }\n}\n\nfunction isLine(value: unknown): boolean {\n const line = value as { product?: { id?: unknown }; qty?: unknown } | null;\n return (\n Boolean(line?.product && typeof line.product.id === 'string' && line.product.id) &&\n typeof line?.qty === 'number'\n );\n}\n\n/** The basket out of a settings payload: bare, under the full key, or nested along it. */\nexport function extractCloudCart(settings: unknown): DurableCart | null {\n const root = (settings && typeof settings === 'object' ? settings : {}) as Record<string, unknown>;\n let nested: unknown = root;\n for (const segment of CART_CONFIG_KEY.split('.')) {\n nested = nested && typeof nested === 'object' ? (nested as Record<string, unknown>)[segment] : undefined;\n }\n for (const candidate of [root, root[CART_CONFIG_KEY], nested, root.cart]) {\n const value = candidate as Partial<DurableCart> | null | undefined;\n if (value && Array.isArray(value.lines)) {\n return {\n lines: value.lines.filter(isLine) as DurableCart['lines'],\n updatedAt: typeof value.updatedAt === 'number' ? value.updatedAt : 0,\n };\n }\n }\n return null;\n}\n\n/** The account's basket, or null when it has never stored one. Throws on a failed read. */\nexport async function readCloudCart(session: CartCloudSession): Promise<DurableCart | null> {\n const resourceUri = cartResourceUri(session.token);\n if (!resourceUri) throw new Error('cart sync: the session token names no organization');\n const page = await postJson<{ settings?: unknown }>(\n session,\n `${backendBase(session.graphqlUrl)}/v1/page-settings`,\n {\n resourceUri,\n options: { configKey: CART_CONFIG_KEY, target: ORGANIZATION_TARGET },\n noSidecar: true,\n },\n );\n return extractCloudCart(page?.settings);\n}\n\nconst CART_WRITE = `\n mutation ShoppingCartSync($key: String!, $value: AnyObject!) {\n updateConfigurationValue(key: $key, value: $value) {\n __typename\n }\n }\n`;\n\nexport async function writeCloudCart(session: CartCloudSession, cart: DurableCart): Promise<void> {\n const body = await postJson<{ errors?: Array<{ message?: string }> }>(\n session,\n `${backendBase(session.graphqlUrl)}/graphql`,\n {\n query: CART_WRITE,\n variables: { key: CART_CONFIG_KEY, value: { lines: cart.lines, updatedAt: cart.updatedAt } },\n },\n );\n if (body?.errors?.length) throw new Error(`cart sync: ${body.errors.map((e) => e.message ?? 'error').join('; ')}`);\n}\n"],"names":["_a"],"mappings":"0DAiBO,MAAM,eAAkB,GAAA;AAG/B,MAAM,mBAAsB,GAAA,CAAA;AAC5B,MAAM,kBAAqB,GAAA,IAAA;AAqBpB,SAAS,gBAAgB,KAAgC,EAAA;AA1ChE,EAAA,IAAA,EAAA;AA2CE,EAAM,MAAA,MAAA,GAAS,YAAY,KAAK,CAAA;AAChC,EAAA,MAAM,GAAM,GAAA,CAAA,EAAA,GAAA,MAAA,CAAO,UAAP,KAAA,IAAA,GAAA,EAAA,GAAqB,MAAO,CAAA,UAAA;AACxC,EAAA,IAAI,OAAO,GAAA,KAAQ,QAAY,IAAA,GAAA,CAAI,MAAQ,EAAA;AACzC,IAAA,MAAM,KAAQ,GAAA,yCAAA,CAA0C,IAAK,CAAA,GAAA,CAAI,MAAM,CAAA;AACvE,IAAA,IAAI,KAAO,EAAA;AACT,MAAA,MAAM,GAAG,MAAQ,EAAA,SAAA,EAAW,OAAO,CAAI,GAAA,KAAA;AACvC,MAAA,MAAM,WAAW,OAAQ,CAAA,KAAA,CAAM,GAAG,CAAA,CAAE,OAAO,OAAO,CAAA;AAClD,MAAM,MAAA,IAAA,GAAO,OAAO,WAAY,EAAA,KAAM,aAAa,QAAS,CAAA,MAAA,KAAW,KAAK,QAAS,CAAA,CAAC,MAAM,UAAa,GAAA,CAAA,C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AO,EAAA;AAAA,QACL,OAAO,IAAK,CAAA,KAAA;AAAA,QACZ,WAAW,IAAK,CAAA;AAAA;AAClB;AACF,GACD,CAAA;AACD,EAAI,IAAA,CAAA,EAAA,GAAA,IAAA,IAAA,IAAA,GAAA,MAAA,GAAA,IAAA,CAAM,MAAN,KAAA,IAAA,GAAA,MAAA,GAAA,EAAA,CAAc,MAAQ,EAAA,MAAM,IAAI,KAAA,CAAM,CAAc,WAAA,EAAA,IAAA,CAAK,MAAO,CAAA,GAAA,CAAI,CAAE,CAAA,KAAA;AArK5E,IAAAA,IAAAA,GAAAA;AAqK+E,IAAA,OAAA,CAAAA,GAAA,GAAA,CAAA,CAAE,OAAF,KAAA,IAAA,GAAAA,GAAa,GAAA,OAAA;AAAA,GAAO,CAAE,CAAA,IAAA,CAAK,IAAI,CAAC,CAAE,CAAA,CAAA;AACjH"}
|
|
@@ -61,6 +61,22 @@ function subscribe(listener) {
|
|
|
61
61
|
_listeners.add(listener);
|
|
62
62
|
return () => _listeners.delete(listener);
|
|
63
63
|
}
|
|
64
|
+
const subscribeCart = subscribe;
|
|
65
|
+
function getDurableCart() {
|
|
66
|
+
return _durable;
|
|
67
|
+
}
|
|
68
|
+
function mergeDurableCart(cloud) {
|
|
69
|
+
if (!cloud || !Array.isArray(cloud.lines)) return false;
|
|
70
|
+
const stamp = typeof cloud.updatedAt === "number" ? cloud.updatedAt : 0;
|
|
71
|
+
if (stamp <= _updatedAt) return false;
|
|
72
|
+
_lines = cloud.lines.filter((l) => {
|
|
73
|
+
var _a2;
|
|
74
|
+
return Boolean((_a2 = l == null ? void 0 : l.product) == null ? void 0 : _a2.id) && typeof l.qty === "number";
|
|
75
|
+
});
|
|
76
|
+
_updatedAt = stamp;
|
|
77
|
+
emit(false);
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
64
80
|
function addToCart(product, qty = 1) {
|
|
65
81
|
const existing = _lines.find((l) => l.product.id === product.id);
|
|
66
82
|
if (existing) existing.qty += qty;
|
|
@@ -113,4 +129,4 @@ function useCart() {
|
|
|
113
129
|
}
|
|
114
130
|
function useCartQty(productId) {
|
|
115
131
|
return useSyncExternalStore(subscribe, () => cartQtyOf(productId), () => 0);
|
|
116
|
-
}export{addToCart,cartQtyOf,clearCart,getCartTotals,hydrateCart,removeFromCart,setQty,useCart,useCartQty};//# sourceMappingURL=shoppingCart.js.map
|
|
132
|
+
}export{addToCart,cartQtyOf,clearCart,getCartTotals,getDurableCart,hydrateCart,mergeDurableCart,removeFromCart,setQty,subscribeCart,useCart,useCartQty};//# sourceMappingURL=shoppingCart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shoppingCart.js","sources":["../../../src/features/shopping/shoppingCart.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react';\nimport type { Product } from './catalog';\nimport { recordCartEvent } from './shoppingHistoryStore';\n\nexport interface CartLine {\n product: Product;\n qty: number;\n}\n\nexport interface DurableCart {\n lines: CartLine[];\n updatedAt: number;\n}\n\nexport interface CartTotals {\n lines: CartLine[];\n count: number;\n subtotal: number;\n}\n\nconst STORAGE_KEY = 'yantra.shopping.cart';\nconst MAX_LINES = 60;\n\ntype StorageLike = { getItem(key: string): Promise<string | null>; setItem(key: string, value: string): Promise<void> };\nlet AsyncStorage: StorageLike | null = null;\ntry {\n // eslint-disable-next-line @typescript-eslint/no-require-imports, global-require\n AsyncStorage = require('@react-native-async-storage/async-storage').default ?? null;\n} catch {\n AsyncStorage = null;\n}\n\nlet _lines: CartLine[] = [];\nlet _updatedAt = 0;\nlet _durable: DurableCart = { lines: _lines, updatedAt: _updatedAt };\nconst _listeners = new Set<() => void>();\n\nfunction emit(touched = true): void {\n _lines = _lines.slice(0, MAX_LINES);\n if (touched) _updatedAt = Date.now();\n _durable = { lines: _lines, updatedAt: _updatedAt };\n persist(_durable);\n _listeners.forEach((l) => l());\n}\n\nfunction persist(cart: DurableCart): void {\n try {\n void AsyncStorage?.setItem(STORAGE_KEY, JSON.stringify(cart));\n } catch {\n /* best-effort */\n }\n}\n\nfunction parseCart(raw: string | null): DurableCart | null {\n if (!raw) return null;\n try {\n const parsed = JSON.parse(raw) as Partial<DurableCart>;\n if (!Array.isArray(parsed?.lines)) return null;\n return {\n lines: parsed.lines.filter((l): l is CartLine => Boolean(l?.product?.id) && typeof l.qty === 'number'),\n updatedAt: typeof parsed.updatedAt === 'number' ? parsed.updatedAt : 0,\n };\n } catch {\n return null;\n }\n}\n\nexport async function hydrateCart(): Promise<void> {\n if (!AsyncStorage) return;\n try {\n const parsed = parseCart(await AsyncStorage.getItem(STORAGE_KEY));\n if (!parsed || parsed.updatedAt <= _updatedAt) return;\n _lines = parsed.lines;\n _updatedAt = parsed.updatedAt;\n emit(false);\n } catch {\n /* memory-only */\n }\n}\n\nfunction subscribe(listener: () => void): () => void {\n _listeners.add(listener);\n return () => _listeners.delete(listener);\n}\n\nexport function addToCart(product: Product, qty = 1): void {\n const existing = _lines.find((l) => l.product.id === product.id);\n if (existing) existing.qty += qty;\n else _lines.push({ product, qty });\n emit();\n recordCartEvent('add', product, existing ? existing.qty : qty);\n}\n\nexport function setQty(productId: string, qty: number): void {\n if (qty <= 0) {\n removeFromCart(productId);\n return;\n }\n const line = _lines.find((l) => l.product.id === productId);\n if (!line) return;\n line.qty = qty;\n emit();\n recordCartEvent('qty', line.product, qty);\n}\n\nexport function removeFromCart(productId: string): void {\n const removed = _lines.find((l) => l.product.id === productId);\n if (!removed) return;\n _lines = _lines.filter((l) => l.product.id !== productId);\n emit();\n recordCartEvent('remove', removed.product, removed.qty);\n}\n\nexport function clearCart(): void {\n if (_lines.length === 0) return;\n _lines = [];\n emit();\n recordCartEvent('clear');\n}\n\nexport function getCartTotals(lines: CartLine[] = _lines): CartTotals {\n return {\n lines,\n count: lines.reduce((n, l) => n + l.qty, 0),\n subtotal: lines.reduce((sum, l) => sum + l.product.price * l.qty, 0),\n };\n}\n\nexport function cartQtyOf(productId: string): number {\n return _lines.find((line) => line.product.id === productId)?.qty ?? 0;\n}\n\nconst EMPTY_LINES: CartLine[] = [];\n\nexport function useCart(): CartTotals {\n const lines = useSyncExternalStore(\n subscribe,\n () => _lines,\n () => EMPTY_LINES,\n );\n return getCartTotals(lines);\n}\n\nexport function useCartQty(productId: string): number {\n return useSyncExternalStore(\n subscribe,\n () => cartQtyOf(productId),\n () => 0,\n );\n}\n\nexport function __resetCart(): void {\n _lines = [];\n _updatedAt = 0;\n _durable = { lines: _lines, updatedAt: 0 };\n persist(_durable);\n _listeners.forEach((l) => l());\n}\n"],"names":["_a"],"mappings":"iGAAA,IAAA,EAAA;AAgBA,MAAM,WAAc,GAAA,sBAAA;AACpB,MAAM,SAAY,GAAA,EAAA;AAKlB,IAAI,YAAmC,GAAA,IAAA;AACvC,IAAI;AAEF,EAAA,YAAA,GAAA,CAAe,EAAQ,GAAA,OAAA,CAAA,2CAA2C,CAAE,CAAA,OAAA,KAArD,IAAgE,GAAA,EAAA,GAAA,IAAA;AACjF,CAAQ,CAAA,OAAA,CAAA,EAAA;AACN,EAAe,YAAA,GAAA,IAAA;AACjB;AACA,IAAI,SAAqB,EAAC;AAC1B,IAAI,UAAa,GAAA,CAAA;AACjB,IAAI,QAAwB,GAAA;AAAA,EAC1B,KAAO,EAAA,MAAA;AAAA,EACP,SAAW,EAAA;AACb,CAAA;AACA,MAAM,UAAA,uBAAiB,GAAgB,EAAA;AACvC,SAAS,IAAA,CAAK,UAAU,IAAY,EAAA;AAClC,EAAS,MAAA,GAAA,MAAA,CAAO,KAAM,CAAA,CAAA,EAAG,SAAS,CAAA;AAClC,EAAI,IAAA,OAAA,EAAsB,UAAA,GAAA,IAAA,CAAK,GAAI,EAAA;AACnC,EAAW,QAAA,GAAA;AAAA,IACT,KAAO,EAAA,MAAA;AAAA,IACP,SAAW,EAAA;AAAA,GACb;AACA,EAAA,OAAA,CAAQ,QAAQ,CAAA;AAChB,EAAW,UAAA,CAAA,OAAA,CAAQ,CAAK,CAAA,KAAA,CAAA,EAAG,CAAA;AAC7B;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,CAAA,SAAA,EAAW,MAAM,MAAA,EAAQ,MAAM,WAAW,CAAA;AAC7E,EAAA,OAAO,cAAc,KAAK,CAAA;AAC5B;AACO,SAAS,WAAW,SAA2B,EAAA;AACpD,EAAA,OAAO,qBAAqB,SAAW,EAAA,MAAM,UAAU,SAAS,CAAA,EAAG,MAAM,CAAC,CAAA;AAC5E"}
|
|
1
|
+
{"version":3,"file":"shoppingCart.js","sources":["../../../src/features/shopping/shoppingCart.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react';\nimport type { Product } from './catalog';\nimport { recordCartEvent } from './shoppingHistoryStore';\n\n/**\n * The basket, on two layers: AsyncStorage so a relaunch keeps it, and - through\n * {@link ./useCartCloudSync} - the account's `account.shopping.cart` config,\n * the same value the web Shopping surface keeps and the agent reads, so the\n * cart the person filled here is the cart \"what's in my cart\" answers about.\n * Reconciliation is last-write-wins on the whole basket ({@link mergeDurableCart}),\n * like the web: removing a line is as much a decision as adding one.\n */\n\nexport interface CartLine {\n product: Product;\n qty: number;\n}\n\nexport interface DurableCart {\n lines: CartLine[];\n updatedAt: number;\n}\n\nexport interface CartTotals {\n lines: CartLine[];\n count: number;\n subtotal: number;\n}\n\nconst STORAGE_KEY = 'yantra.shopping.cart';\nconst MAX_LINES = 60;\n\ntype StorageLike = { getItem(key: string): Promise<string | null>; setItem(key: string, value: string): Promise<void> };\nlet AsyncStorage: StorageLike | null = null;\ntry {\n // eslint-disable-next-line @typescript-eslint/no-require-imports, global-require\n AsyncStorage = require('@react-native-async-storage/async-storage').default ?? null;\n} catch {\n AsyncStorage = null;\n}\n\nlet _lines: CartLine[] = [];\nlet _updatedAt = 0;\nlet _durable: DurableCart = { lines: _lines, updatedAt: _updatedAt };\nconst _listeners = new Set<() => void>();\n\nfunction emit(touched = true): void {\n _lines = _lines.slice(0, MAX_LINES);\n if (touched) _updatedAt = Date.now();\n _durable = { lines: _lines, updatedAt: _updatedAt };\n persist(_durable);\n _listeners.forEach((l) => l());\n}\n\nfunction persist(cart: DurableCart): void {\n try {\n void AsyncStorage?.setItem(STORAGE_KEY, JSON.stringify(cart));\n } catch {\n /* best-effort */\n }\n}\n\nfunction parseCart(raw: string | null): DurableCart | null {\n if (!raw) return null;\n try {\n const parsed = JSON.parse(raw) as Partial<DurableCart>;\n if (!Array.isArray(parsed?.lines)) return null;\n return {\n lines: parsed.lines.filter((l): l is CartLine => Boolean(l?.product?.id) && typeof l.qty === 'number'),\n updatedAt: typeof parsed.updatedAt === 'number' ? parsed.updatedAt : 0,\n };\n } catch {\n return null;\n }\n}\n\nexport async function hydrateCart(): Promise<void> {\n if (!AsyncStorage) return;\n try {\n const parsed = parseCart(await AsyncStorage.getItem(STORAGE_KEY));\n if (!parsed || parsed.updatedAt <= _updatedAt) return;\n _lines = parsed.lines;\n _updatedAt = parsed.updatedAt;\n emit(false);\n } catch {\n /* memory-only */\n }\n}\n\nfunction subscribe(listener: () => void): () => void {\n _listeners.add(listener);\n return () => _listeners.delete(listener);\n}\n\n/** Subscribe to the cart from outside React (the cloud sync does). */\nexport const subscribeCart = subscribe;\n\n/** The basket plus its stamp - what the cloud sync compares and writes. */\nexport function getDurableCart(): DurableCart {\n return _durable;\n}\n\n/**\n * Adopt a basket from the account when it is strictly newer than this phone's.\n * Its stamp comes from the device (or agent) that made the edit, so it is kept\n * as is - re-stamping would make this phone look like the newest writer and\n * send the value straight back. Returns true when the local cart changed.\n */\nexport function mergeDurableCart(cloud: DurableCart | null | undefined): boolean {\n if (!cloud || !Array.isArray(cloud.lines)) return false;\n const stamp = typeof cloud.updatedAt === 'number' ? cloud.updatedAt : 0;\n if (stamp <= _updatedAt) return false;\n _lines = cloud.lines.filter((l): l is CartLine => Boolean(l?.product?.id) && typeof l.qty === 'number');\n _updatedAt = stamp;\n emit(false);\n return true;\n}\n\nexport function addToCart(product: Product, qty = 1): void {\n const existing = _lines.find((l) => l.product.id === product.id);\n if (existing) existing.qty += qty;\n else _lines.push({ product, qty });\n emit();\n recordCartEvent('add', product, existing ? existing.qty : qty);\n}\n\nexport function setQty(productId: string, qty: number): void {\n if (qty <= 0) {\n removeFromCart(productId);\n return;\n }\n const line = _lines.find((l) => l.product.id === productId);\n if (!line) return;\n line.qty = qty;\n emit();\n recordCartEvent('qty', line.product, qty);\n}\n\nexport function removeFromCart(productId: string): void {\n const removed = _lines.find((l) => l.product.id === productId);\n if (!removed) return;\n _lines = _lines.filter((l) => l.product.id !== productId);\n emit();\n recordCartEvent('remove', removed.product, removed.qty);\n}\n\nexport function clearCart(): void {\n if (_lines.length === 0) return;\n _lines = [];\n emit();\n recordCartEvent('clear');\n}\n\nexport function getCartTotals(lines: CartLine[] = _lines): CartTotals {\n return {\n lines,\n count: lines.reduce((n, l) => n + l.qty, 0),\n subtotal: lines.reduce((sum, l) => sum + l.product.price * l.qty, 0),\n };\n}\n\nexport function cartQtyOf(productId: string): number {\n return _lines.find((line) => line.product.id === productId)?.qty ?? 0;\n}\n\nconst EMPTY_LINES: CartLine[] = [];\n\nexport function useCart(): CartTotals {\n const lines = useSyncExternalStore(\n subscribe,\n () => _lines,\n () => EMPTY_LINES,\n );\n return getCartTotals(lines);\n}\n\nexport function useCartQty(productId: string): number {\n return useSyncExternalStore(\n subscribe,\n () => cartQtyOf(productId),\n () => 0,\n );\n}\n\nexport function __resetCart(): void {\n _lines = [];\n _updatedAt = 0;\n _durable = { lines: _lines, updatedAt: 0 };\n persist(_durable);\n _listeners.forEach((l) => l());\n}\n"],"names":["_a"],"mappings":"iGAAA,IAAA,EAAA;AA0BA,MAAM,WAAc,GAAA,sBAAA;AACpB,MAAM,SAAY,GAAA,EAAA;AAKlB,IAAI,YAAmC,GAAA,IAAA;AACvC,IAAI;AAEF,EAAA,YAAA,GAAA,CAAe,EAAQ,GAAA,OAAA,CAAA,2CAA2C,CAAE,CAAA,OAAA,KAArD,IAAgE,GAAA,EAAA,GAAA,IAAA;AACjF,CAAQ,CAAA,OAAA,CAAA,EAAA;AACN,EAAe,YAAA,GAAA,IAAA;AACjB;AACA,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,EAAC;AAC1B,SAAS,OAAsB,GAAA;AACpC,EAAA,MAAM,QAAQ,oBAAqB,CAAA,SAAA,EAAW,MAAM,MAAA,EAAQ,MAAM,WAAW,CAAA;AAC7E,EAAA,OAAO,cAAc,KAAK,CAAA;AAC5B;AACO,SAAS,WAAW,SAA2B,EAAA;AACpD,EAAA,OAAO,qBAAqB,SAAW,EAAA,MAAM,UAAU,SAAS,CAAA,EAAG,MAAM,CAAC,CAAA;AAC5E"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {useRef,useEffect,useCallback}from'react';import {AppState}from'react-native';import {createCartCloudSync}from'./cartCloudSync.js';import {writeCloudCart,readCloudCart}from'./services/cartCloud.js';import {hydrateCart,subscribeCart,mergeDurableCart,getDurableCart}from'./shoppingCart.js';function useCartCloudSync(token, graphqlUrl) {
|
|
2
|
+
const syncRef = useRef(null);
|
|
3
|
+
useEffect(() => {
|
|
4
|
+
if (!token || !graphqlUrl) return void 0;
|
|
5
|
+
const session = {
|
|
6
|
+
token,
|
|
7
|
+
graphqlUrl
|
|
8
|
+
};
|
|
9
|
+
const sync = createCartCloudSync({
|
|
10
|
+
read: () => readCloudCart(session),
|
|
11
|
+
write: (cart) => writeCloudCart(session, cart),
|
|
12
|
+
local: getDurableCart,
|
|
13
|
+
adopt: mergeDurableCart,
|
|
14
|
+
subscribe: subscribeCart,
|
|
15
|
+
hydrate: hydrateCart
|
|
16
|
+
});
|
|
17
|
+
syncRef.current = sync;
|
|
18
|
+
void sync.reconcile();
|
|
19
|
+
const appState = AppState.addEventListener("change", (state) => {
|
|
20
|
+
if (state === "active") void sync.reconcile();
|
|
21
|
+
else void sync.flush();
|
|
22
|
+
});
|
|
23
|
+
return () => {
|
|
24
|
+
appState.remove();
|
|
25
|
+
sync.dispose();
|
|
26
|
+
if (syncRef.current === sync) syncRef.current = null;
|
|
27
|
+
};
|
|
28
|
+
}, [token, graphqlUrl]);
|
|
29
|
+
return useCallback(() => {
|
|
30
|
+
var _a;
|
|
31
|
+
void ((_a = syncRef.current) == null ? void 0 : _a.reconcile());
|
|
32
|
+
}, []);
|
|
33
|
+
}export{useCartCloudSync};//# sourceMappingURL=useCartCloudSync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCartCloudSync.js","sources":["../../../src/features/shopping/useCartCloudSync.ts"],"sourcesContent":["/**\n * Mounts {@link createCartCloudSync} for the shopping screen: one sync per\n * session, reconciled on mount and whenever the app comes back to the\n * foreground, flushed when it leaves. Returns `reconcile` so the screen can\n * refresh right before showing the cart. No session (signed out, token not\n * minted yet) = the phone's cart stays local, as before.\n */\nimport { useCallback, useEffect, useRef } from 'react';\nimport { AppState } from 'react-native';\nimport { createCartCloudSync, type CartCloudSync } from './cartCloudSync';\nimport { readCloudCart, writeCloudCart, type CartCloudSession } from './services/cartCloud';\nimport { getDurableCart, hydrateCart, mergeDurableCart, subscribeCart } from './shoppingCart';\n\nexport function useCartCloudSync(token: string | null | undefined, graphqlUrl: string | null | undefined): () => void {\n const syncRef = useRef<CartCloudSync | null>(null);\n\n useEffect(() => {\n if (!token || !graphqlUrl) return undefined;\n const session: CartCloudSession = { token, graphqlUrl };\n const sync = createCartCloudSync({\n read: () => readCloudCart(session),\n write: (cart) => writeCloudCart(session, cart),\n local: getDurableCart,\n adopt: mergeDurableCart,\n subscribe: subscribeCart,\n hydrate: hydrateCart,\n });\n syncRef.current = sync;\n void sync.reconcile();\n const appState = AppState.addEventListener('change', (state) => {\n if (state === 'active') void sync.reconcile();\n else void sync.flush();\n });\n return () => {\n appState.remove();\n sync.dispose();\n if (syncRef.current === sync) syncRef.current = null;\n };\n }, [token, graphqlUrl]);\n\n return useCallback(() => {\n void syncRef.current?.reconcile();\n }, []);\n}\n"],"names":[],"mappings":"uSAYgB,SAAA,gBAAA,CAAiB,OAAkC,UAAmD,EAAA;AACpH,EAAM,MAAA,OAAA,GAAU,OAA6B,IAAI,CAAA;AACjD,EAAA,SAAA,CAAU,MAAM;AACd,I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Memo,useCallback}from'react'
|
|
|
7
7
|
const {
|
|
8
8
|
token,
|
|
9
9
|
indexUrl,
|
|
10
|
+
graphqlUrl,
|
|
10
11
|
error,
|
|
11
12
|
ready
|
|
12
13
|
} = useCanvasSession();
|
|
@@ -34,7 +35,7 @@ import {jsx,jsxs}from'react/jsx-runtime';import {useMemo,useCallback}from'react'
|
|
|
34
35
|
/* @__PURE__ */ jsx(Text, { style: [styles.detail, isDark && styles.textMuted], children: "This build does not carry the federation host runtime." })
|
|
35
36
|
] }) });
|
|
36
37
|
}
|
|
37
|
-
return /* @__PURE__ */ jsx(SafeAreaView, { style: [styles.fill, isDark && styles.fillDark], edges: ["left", "right"], children: /* @__PURE__ */ jsx(Experience, { token, indexUrl, sessionError: ready ? error : null, hostChat, onAgentVisibleChange, initialAgentSeed: seed }) });
|
|
38
|
+
return /* @__PURE__ */ jsx(SafeAreaView, { style: [styles.fill, isDark && styles.fillDark], edges: ["left", "right"], children: /* @__PURE__ */ jsx(Experience, { token, indexUrl, backendGraphqlUrl: graphqlUrl, sessionError: ready ? error : null, hostChat, onAgentVisibleChange, initialAgentSeed: seed }) });
|
|
38
39
|
}
|
|
39
40
|
const styles = StyleSheet.create({
|
|
40
41
|
fill: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/screens/ShoppingNative/index.tsx"],"sourcesContent":["/**\n * Native Shop screen â host route for the federated shopping storefront.\n *\n * Same delivery contract as CanvasBoard: the App registers the federated\n * component; this screen only reads the registry and hands over a token the\n * shopping connector accepts plus the surface-index endpoint for this\n * environment. Opening it fetches `shopping_native/Shop` from the shopping\n * native surface; that code is not in the app binary.\n *\n * Host chat (images / vision) is created here and passed in as props so the\n * remote never imports Apollo or cdecli.\n */\nimport React, { useCallback, useMemo } from 'react';\nimport { StyleSheet, Text, View, useColorScheme } from 'react-native';\nimport { SafeAreaView } from 'react-native-safe-area-context';\nimport { useNavigation, useRoute } from '@react-navigation/native';\nimport { getNativeShoppingExperience } from '../../features/shopping/nativeShoppingRegistry';\nimport { useCanvasSession } from '../../features/canvas/useCanvasSession';\nimport { useShoppingHostChat } from './useShoppingHostChat';\n\nexport default function ShoppingNativeScreen() {\n const isDark = useColorScheme() === 'dark';\n const navigation = useNavigation<any>();\n const route = useRoute<any>();\n const Experience = getNativeShoppingExperience();\n const { token, indexUrl, error, ready } = useCanvasSession();\n const hostChat = useShoppingHostChat();\n const seed = useMemo(() => {\n const query = typeof route.params?.initialAgentQuery === 'string' ? route.params.initialAgentQuery.trim() : '';\n const files = Array.isArray(route.params?.initialAgentAttachments)\n ? route.params.initialAgentAttachments\n : undefined;\n if (!query && !files?.length) return null;\n return { text: query, files };\n }, [route.params?.initialAgentQuery, route.params?.initialAgentAttachments]);\n\n const onAgentVisibleChange = useCallback(\n (open: boolean) => {\n if (!navigation.isFocused?.()) return;\n navigation.setParams({ hideNavigationHeader: open || undefined });\n },\n [navigation],\n );\n\n if (!Experience) {\n return (\n <SafeAreaView style={[styles.fill, isDark && styles.fillDark]}>\n <View style={styles.center}>\n <Text style={[styles.title, isDark && styles.textLight]}>Native shop unavailable</Text>\n <Text style={[styles.detail, isDark && styles.textMuted]}>\n This build does not carry the federation host runtime.\n </Text>\n </View>\n </SafeAreaView>\n );\n }\n\n return (\n <SafeAreaView style={[styles.fill, isDark && styles.fillDark]} edges={['left', 'right']}>\n <Experience\n token={token}\n indexUrl={indexUrl}\n sessionError={ready ? error : null}\n hostChat={hostChat}\n onAgentVisibleChange={onAgentVisibleChange}\n initialAgentSeed={seed}\n />\n </SafeAreaView>\n );\n}\n\nconst styles = StyleSheet.create({\n fill: { flex: 1, backgroundColor: '#f8fafc' },\n fillDark: { backgroundColor: '#0f172a' },\n center: { flex: 1, alignItems: 'center', justifyContent: 'center', padding: 24 },\n title: { fontSize: 15, fontWeight: '600', color: '#0f172a', marginBottom: 6 },\n detail: { fontSize: 13, color: '#64748b', textAlign: 'center' },\n textLight: { color: '#f8fafc' },\n textMuted: { color: '#94a3b8' },\n});\n"],"names":["_a","_b"],"mappings":"weAmBA,SAAwB,oBAAuB,GAAA;AAnB/C,EAAA,IAAA,EAAA,EAAA,EAAA;AAoBE,EAAM,MAAA,MAAA,GAAS,gBAAqB,KAAA,MAAA;AACpC,EAAA,MAAM,aAAa,aAAmB,EAAA;AACtC,EAAA,MAAM,QAAQ,QAAc,EAAA;AAC5B,EAAA,MAAM,aAAa,2BAA4B,EAAA;AAC/C,EAAM,MAAA;AAAA,IACJ,KAAA;AAAA,IACA,QAAA;AAAA,IACA,KAAA;AAAA,IACA;AAAA,MACE,gBAAiB,EAAA;AACrB,EAAA,MAAM,WAAW,mBAAoB,EAAA;AACrC,EAAM,MAAA,IAAA,GAAO,QAAQ,MAAM;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/screens/ShoppingNative/index.tsx"],"sourcesContent":["/**\n * Native Shop screen â host route for the federated shopping storefront.\n *\n * Same delivery contract as CanvasBoard: the App registers the federated\n * component; this screen only reads the registry and hands over a token the\n * shopping connector accepts plus the surface-index endpoint for this\n * environment. Opening it fetches `shopping_native/Shop` from the shopping\n * native surface; that code is not in the app binary.\n *\n * Host chat (images / vision) is created here and passed in as props so the\n * remote never imports Apollo or cdecli.\n */\nimport React, { useCallback, useMemo } from 'react';\nimport { StyleSheet, Text, View, useColorScheme } from 'react-native';\nimport { SafeAreaView } from 'react-native-safe-area-context';\nimport { useNavigation, useRoute } from '@react-navigation/native';\nimport { getNativeShoppingExperience } from '../../features/shopping/nativeShoppingRegistry';\nimport { useCanvasSession } from '../../features/canvas/useCanvasSession';\nimport { useShoppingHostChat } from './useShoppingHostChat';\n\nexport default function ShoppingNativeScreen() {\n const isDark = useColorScheme() === 'dark';\n const navigation = useNavigation<any>();\n const route = useRoute<any>();\n const Experience = getNativeShoppingExperience();\n const { token, indexUrl, graphqlUrl, error, ready } = useCanvasSession();\n const hostChat = useShoppingHostChat();\n const seed = useMemo(() => {\n const query = typeof route.params?.initialAgentQuery === 'string' ? route.params.initialAgentQuery.trim() : '';\n const files = Array.isArray(route.params?.initialAgentAttachments)\n ? route.params.initialAgentAttachments\n : undefined;\n if (!query && !files?.length) return null;\n return { text: query, files };\n }, [route.params?.initialAgentQuery, route.params?.initialAgentAttachments]);\n\n const onAgentVisibleChange = useCallback(\n (open: boolean) => {\n if (!navigation.isFocused?.()) return;\n navigation.setParams({ hideNavigationHeader: open || undefined });\n },\n [navigation],\n );\n\n if (!Experience) {\n return (\n <SafeAreaView style={[styles.fill, isDark && styles.fillDark]}>\n <View style={styles.center}>\n <Text style={[styles.title, isDark && styles.textLight]}>Native shop unavailable</Text>\n <Text style={[styles.detail, isDark && styles.textMuted]}>\n This build does not carry the federation host runtime.\n </Text>\n </View>\n </SafeAreaView>\n );\n }\n\n return (\n <SafeAreaView style={[styles.fill, isDark && styles.fillDark]} edges={['left', 'right']}>\n <Experience\n token={token}\n indexUrl={indexUrl}\n backendGraphqlUrl={graphqlUrl}\n sessionError={ready ? error : null}\n hostChat={hostChat}\n onAgentVisibleChange={onAgentVisibleChange}\n initialAgentSeed={seed}\n />\n </SafeAreaView>\n );\n}\n\nconst styles = StyleSheet.create({\n fill: { flex: 1, backgroundColor: '#f8fafc' },\n fillDark: { backgroundColor: '#0f172a' },\n center: { flex: 1, alignItems: 'center', justifyContent: 'center', padding: 24 },\n title: { fontSize: 15, fontWeight: '600', color: '#0f172a', marginBottom: 6 },\n detail: { fontSize: 13, color: '#64748b', textAlign: 'center' },\n textLight: { color: '#f8fafc' },\n textMuted: { color: '#94a3b8' },\n});\n"],"names":["_a","_b"],"mappings":"weAmBA,SAAwB,oBAAuB,GAAA;AAnB/C,EAAA,IAAA,EAAA,EAAA,EAAA;AAoBE,EAAM,MAAA,MAAA,GAAS,gBAAqB,KAAA,MAAA;AACpC,EAAA,MAAM,aAAa,aAAmB,EAAA;AACtC,EAAA,MAAM,QAAQ,QAAc,EAAA;AAC5B,EAAA,MAAM,aAAa,2BAA4B,EAAA;AAC/C,EAAM,MAA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AAA,CAAA;AAAA,IACN,eAAiB,EAAA;AAAA,GACnB;AAAA,EACA,QAAU,EAAA;AAAA,IACR,eAAiB,EAAA;AAAA,GACnB;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,IAAM,EAAA,CAAA;AAAA,IACN,UAAY,EAAA,QAAA;AAAA,IACZ,cAAgB,EAAA,QAAA;AAAA,IAChB,OAAS,EAAA;AAAA,GACX;AAAA,EACA,KAAO,EAAA;AAAA,IACL,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA,KAAA;AAAA,IACZ,KAAO,EAAA,SAAA;AAAA,IACP,YAAc,EAAA;AAAA,GAChB;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,QAAU,EAAA,EAAA;AAAA,IACV,KAAO,EAAA,SAAA;AAAA,IACP,SAAW,EAAA;AAAA,GACb;AAAA,EACA,SAAW,EAAA;AAAA,IACT,KAAO,EAAA;AAAA,GACT;AAAA,EACA,SAAW,EAAA;AAAA,IACT,KAAO,EAAA;AAAA;AAEX,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adminide-stack/yantra-mobile",
|
|
3
|
-
"version": "12.0.95-alpha.
|
|
3
|
+
"version": "12.0.95-alpha.1",
|
|
4
4
|
"description": "Sample core for higher packages to depend on",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "CDMBase LLC",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"uuid": "^9.0.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"common": "12.0.95-alpha.
|
|
30
|
+
"common": "12.0.95-alpha.1",
|
|
31
31
|
"libphonenumber-js": "^1.13.3"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@messenger-box/platform-mobile": "*",
|
|
46
46
|
"@react-native-async-storage/async-storage": "*",
|
|
47
47
|
"@react-navigation/native": "*",
|
|
48
|
-
"common": "12.0.
|
|
48
|
+
"common": "12.0.95-alpha.0",
|
|
49
49
|
"expo-constants": "*",
|
|
50
50
|
"expo-secure-store": "*",
|
|
51
51
|
"expo-web-browser": "*",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"typescript": {
|
|
65
65
|
"definition": "lib/index.d.ts"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "74ac0dc7b6826015f54a3ccde6a6c96a4031cf1f"
|
|
68
68
|
}
|