@salla.sa/twilight-theme-engine 1.0.138 → 1.0.140
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/dist/{AddToCartForm-P3IXCYO7.js → AddToCartForm-EPTN5O3X.js} +3 -3
- package/dist/{AddToCartForm-P3IXCYO7.js.map → AddToCartForm-EPTN5O3X.js.map} +1 -1
- package/dist/{BlogAuthorPage-UJYMW4ZL.js → BlogAuthorPage-PGFINJSP.js} +16 -16
- package/dist/{BlogAuthorPage-UJYMW4ZL.js.map → BlogAuthorPage-PGFINJSP.js.map} +1 -1
- package/dist/{BlogCategoryPage-3XO42UFX.js → BlogCategoryPage-ZVRRHTKJ.js} +16 -16
- package/dist/{BlogCategoryPage-3XO42UFX.js.map → BlogCategoryPage-ZVRRHTKJ.js.map} +1 -1
- package/dist/{BlogPage-5SQNDQ7L.js → BlogPage-5SRGR7NK.js} +14 -14
- package/dist/{BlogPage-5SQNDQ7L.js.map → BlogPage-5SRGR7NK.js.map} +1 -1
- package/dist/{BlogSinglePage-XSRKZYUI.js → BlogSinglePage-6A5J2BKK.js} +14 -14
- package/dist/{BlogSinglePage-XSRKZYUI.js.map → BlogSinglePage-6A5J2BKK.js.map} +1 -1
- package/dist/{BlogTagPage-CFXWHUJR.js → BlogTagPage-DAA3ZO76.js} +16 -16
- package/dist/{BlogTagPage-CFXWHUJR.js.map → BlogTagPage-DAA3ZO76.js.map} +1 -1
- package/dist/{BrandsPage-APYVP4M2.js → BrandsPage-JABKRWP2.js} +15 -15
- package/dist/{BrandsPage-APYVP4M2.js.map → BrandsPage-JABKRWP2.js.map} +1 -1
- package/dist/{Breadcrumb-M4DBOMXW.js → Breadcrumb-SCJZW4RO.js} +14 -14
- package/dist/{Breadcrumb-M4DBOMXW.js.map → Breadcrumb-SCJZW4RO.js.map} +1 -1
- package/dist/{CartItem-BXZDBDLA.js → CartItem-3KFTPQVF.js} +14 -14
- package/dist/{CartItem-BXZDBDLA.js.map → CartItem-3KFTPQVF.js.map} +1 -1
- package/dist/{CartSummary-NT7N6ERQ.js → CartSummary-I64SD4QX.js} +14 -14
- package/dist/{CartSummary-NT7N6ERQ.js.map → CartSummary-I64SD4QX.js.map} +1 -1
- package/dist/{Copyright-IJDVQWOS.js → Copyright-3TREUCAK.js} +3 -3
- package/dist/{Copyright-IJDVQWOS.js.map → Copyright-3TREUCAK.js.map} +1 -1
- package/dist/{CustomerLayout-UNEDHUO2.js → CustomerLayout-BH74QWRI.js} +14 -14
- package/dist/{CustomerLayout-UNEDHUO2.js.map → CustomerLayout-BH74QWRI.js.map} +1 -1
- package/dist/{Footer-QX5BCDUK.js → Footer-DSSOB3ZW.js} +4 -4
- package/dist/{Footer-QX5BCDUK.js.map → Footer-DSSOB3ZW.js.map} +1 -1
- package/dist/{Header-EAOIXJNS.js → Header-UWUS34D6.js} +8 -8
- package/dist/{Header-EAOIXJNS.js.map → Header-UWUS34D6.js.map} +1 -1
- package/dist/LatestProducts-VLSTOKEB.js +107 -0
- package/dist/LatestProducts-VLSTOKEB.js.map +1 -0
- package/dist/{LoyaltyPage-3VOLW5OQ.js → LoyaltyPage-3FAD5MJ6.js} +14 -14
- package/dist/{LoyaltyPage-3VOLW5OQ.js.map → LoyaltyPage-3FAD5MJ6.js.map} +1 -1
- package/dist/{LoyaltyPointsPage-IMHJHCZV.js → LoyaltyPointsPage-A4CTI55P.js} +6 -6
- package/dist/{LoyaltyPointsPage-IMHJHCZV.js.map → LoyaltyPointsPage-A4CTI55P.js.map} +1 -1
- package/dist/{MainMenu-ML6OQT53.js → MainMenu-C7TWXVL5.js} +6 -6
- package/dist/MainMenu-C7TWXVL5.js.map +1 -0
- package/dist/{MasterLayout-UCQA73I3.js → MasterLayout-MZY44RTA.js} +14 -14
- package/dist/{MasterLayout-UCQA73I3.js.map → MasterLayout-MZY44RTA.js.map} +1 -1
- package/dist/{MobileMenu-5JHOT4DP.js → MobileMenu-KNDN34HO.js} +15 -15
- package/dist/{MobileMenu-5JHOT4DP.js.map → MobileMenu-KNDN34HO.js.map} +1 -1
- package/dist/NoContent-7A7OR2NZ.js +6 -0
- package/dist/NoContent-7A7OR2NZ.js.map +1 -0
- package/dist/{NotificationsPage-C373Z2KC.js → NotificationsPage-LKUTYWPR.js} +14 -14
- package/dist/{NotificationsPage-C373Z2KC.js.map → NotificationsPage-LKUTYWPR.js.map} +1 -1
- package/dist/{OrderSinglePage-YYTU72JY.js → OrderSinglePage-VDALCKJL.js} +15 -15
- package/dist/{OrderSinglePage-YYTU72JY.js.map → OrderSinglePage-VDALCKJL.js.map} +1 -1
- package/dist/{OrdersPage-2F43AA76.js → OrdersPage-TOSCY6ML.js} +14 -14
- package/dist/{OrdersPage-2F43AA76.js.map → OrdersPage-TOSCY6ML.js.map} +1 -1
- package/dist/{PageSingle-2FIESLYJ.js → PageSingle-56SRDA4Q.js} +3 -3
- package/dist/{PageSingle-2FIESLYJ.js.map → PageSingle-56SRDA4Q.js.map} +1 -1
- package/dist/{ProductDetails-TNULRGXM.js → ProductDetails-YYU7TJSU.js} +4 -4
- package/dist/{ProductDetails-TNULRGXM.js.map → ProductDetails-YYU7TJSU.js.map} +1 -1
- package/dist/{ProfilePage-4VSU6H3S.js → ProfilePage-CTGBAD2A.js} +14 -14
- package/dist/{ProfilePage-4VSU6H3S.js.map → ProfilePage-CTGBAD2A.js.map} +1 -1
- package/dist/{ReviewsPage-65CYIATI.js → ReviewsPage-RJ5VQVB2.js} +3 -3
- package/dist/{ReviewsPage-65CYIATI.js.map → ReviewsPage-RJ5VQVB2.js.map} +1 -1
- package/dist/{SeoCartWidget-UHJJLLCU.js → SeoCartWidget-VL5TD2FU.js} +14 -14
- package/dist/{SeoCartWidget-UHJJLLCU.js.map → SeoCartWidget-VL5TD2FU.js.map} +1 -1
- package/dist/{SettingsPage-2JHRIGFS.js → SettingsPage-ZHDB3YZS.js} +14 -14
- package/dist/{SettingsPage-2JHRIGFS.js.map → SettingsPage-ZHDB3YZS.js.map} +1 -1
- package/dist/{StoreClosedNotification-ADSYNO7O.js → StoreClosedNotification-VP2ACWD6.js} +15 -15
- package/dist/{StoreClosedNotification-ADSYNO7O.js.map → StoreClosedNotification-VP2ACWD6.js.map} +1 -1
- package/dist/{TestimonialsPage-PYFKXCQP.js → TestimonialsPage-V2RWUVZD.js} +3 -3
- package/dist/{TestimonialsPage-PYFKXCQP.js.map → TestimonialsPage-V2RWUVZD.js.map} +1 -1
- package/dist/{ThankYouPage-VHUAKQF7.js → ThankYouPage-NJKASZ2R.js} +14 -14
- package/dist/{ThankYouPage-VHUAKQF7.js.map → ThankYouPage-NJKASZ2R.js.map} +1 -1
- package/dist/{WalletPage-NG2DJAUE.js → WalletPage-N4FDKDK3.js} +15 -15
- package/dist/{WalletPage-NG2DJAUE.js.map → WalletPage-N4FDKDK3.js.map} +1 -1
- package/dist/{WishlistPage-GFOKEWL3.js → WishlistPage-JCOG3KOV.js} +16 -16
- package/dist/{WishlistPage-GFOKEWL3.js.map → WishlistPage-JCOG3KOV.js.map} +1 -1
- package/dist/api/advertisement.js +2 -2
- package/dist/api/apps.js +2 -2
- package/dist/api/blog.js +3 -3
- package/dist/api/brands.js +3 -3
- package/dist/api/cart.js +3 -3
- package/dist/api/category.js +3 -3
- package/dist/api/client.js +1 -1
- package/dist/api/home.js +2 -2
- package/dist/api/loyalty.js +3 -3
- package/dist/api/menu.js +2 -2
- package/dist/api/notification.js +2 -2
- package/dist/api/order.js +3 -3
- package/dist/api/page.js +3 -3
- package/dist/api/product.js +3 -3
- package/dist/api/profile.js +1 -1
- package/dist/api/store.js +2 -2
- package/dist/api/translations.js +2 -2
- package/dist/api/user.js +2 -2
- package/dist/api/wallet.js +2 -2
- package/dist/api/wishlist.js +4 -4
- package/dist/{chunk-MWAXFBGG.js → chunk-2AS6KREO.js} +3 -3
- package/dist/{chunk-MWAXFBGG.js.map → chunk-2AS6KREO.js.map} +1 -1
- package/dist/{NoContent-63TMCPGY.js → chunk-33FWLJXY.js} +2 -4
- package/dist/chunk-33FWLJXY.js.map +1 -0
- package/dist/{chunk-35D6CKKX.js → chunk-33R2PXOK.js} +4 -4
- package/dist/{chunk-35D6CKKX.js.map → chunk-33R2PXOK.js.map} +1 -1
- package/dist/{chunk-OSYUGCRG.js → chunk-3CKMMFUF.js} +4 -4
- package/dist/{chunk-OSYUGCRG.js.map → chunk-3CKMMFUF.js.map} +1 -1
- package/dist/{chunk-SAYYMA6E.js → chunk-444GCMTZ.js} +21 -9
- package/dist/chunk-444GCMTZ.js.map +1 -0
- package/dist/{chunk-PBFLXHKM.js → chunk-5NTD7WXX.js} +3 -3
- package/dist/{chunk-PBFLXHKM.js.map → chunk-5NTD7WXX.js.map} +1 -1
- package/dist/{chunk-FVHAKOEH.js → chunk-7DRXAR76.js} +3 -3
- package/dist/{chunk-FVHAKOEH.js.map → chunk-7DRXAR76.js.map} +1 -1
- package/dist/{chunk-U6EB7GM3.js → chunk-7PFJOTZS.js} +4 -4
- package/dist/{chunk-U6EB7GM3.js.map → chunk-7PFJOTZS.js.map} +1 -1
- package/dist/{chunk-P43VADN7.js → chunk-ABVHWJPY.js} +10 -3
- package/dist/chunk-ABVHWJPY.js.map +1 -0
- package/dist/{chunk-S7FNMT24.js → chunk-AEM5UEH6.js} +3 -3
- package/dist/{chunk-S7FNMT24.js.map → chunk-AEM5UEH6.js.map} +1 -1
- package/dist/{chunk-HG75MP47.js → chunk-ATL7CYF2.js} +3 -3
- package/dist/{chunk-HG75MP47.js.map → chunk-ATL7CYF2.js.map} +1 -1
- package/dist/{chunk-KLVEKLFL.js → chunk-AZT4TALZ.js} +5 -5
- package/dist/{chunk-KLVEKLFL.js.map → chunk-AZT4TALZ.js.map} +1 -1
- package/dist/{chunk-S5ZKI3TY.js → chunk-BPM6LSOV.js} +4 -4
- package/dist/{chunk-S5ZKI3TY.js.map → chunk-BPM6LSOV.js.map} +1 -1
- package/dist/{chunk-JXLZTGQN.js → chunk-CU2DV3Z4.js} +3 -3
- package/dist/{chunk-JXLZTGQN.js.map → chunk-CU2DV3Z4.js.map} +1 -1
- package/dist/chunk-F3SXHQU4.js +206 -0
- package/dist/chunk-F3SXHQU4.js.map +1 -0
- package/dist/{chunk-WC2ZDV4J.js → chunk-GIYRCRS6.js} +3 -3
- package/dist/{chunk-WC2ZDV4J.js.map → chunk-GIYRCRS6.js.map} +1 -1
- package/dist/{chunk-5FEFYFTS.js → chunk-IK7CQSEA.js} +3 -3
- package/dist/{chunk-5FEFYFTS.js.map → chunk-IK7CQSEA.js.map} +1 -1
- package/dist/{chunk-UXS3QCHM.js → chunk-J4EFCWMM.js} +14 -14
- package/dist/{chunk-UXS3QCHM.js.map → chunk-J4EFCWMM.js.map} +1 -1
- package/dist/{chunk-TK6A4UON.js → chunk-LB4U7GI3.js} +4 -4
- package/dist/{chunk-TK6A4UON.js.map → chunk-LB4U7GI3.js.map} +1 -1
- package/dist/{chunk-LMMDVLAB.js → chunk-LCRHHSBP.js} +7 -5
- package/dist/chunk-LCRHHSBP.js.map +1 -0
- package/dist/{chunk-EGJ2SV6O.js → chunk-LGXEXLX3.js} +12 -12
- package/dist/chunk-LGXEXLX3.js.map +1 -0
- package/dist/{chunk-GJFK3SU5.js → chunk-MBU4LSRZ.js} +4 -4
- package/dist/{chunk-GJFK3SU5.js.map → chunk-MBU4LSRZ.js.map} +1 -1
- package/dist/{chunk-EJ66I5SH.js → chunk-MJ3DLAC3.js} +4 -4
- package/dist/{chunk-EJ66I5SH.js.map → chunk-MJ3DLAC3.js.map} +1 -1
- package/dist/{chunk-DMS6PZXN.js → chunk-MOAMYULW.js} +4 -4
- package/dist/{chunk-DMS6PZXN.js.map → chunk-MOAMYULW.js.map} +1 -1
- package/dist/{chunk-3QR6T7KW.js → chunk-N36TVQP2.js} +6 -201
- package/dist/chunk-N36TVQP2.js.map +1 -0
- package/dist/{chunk-VFQNVPFH.js → chunk-NRPYHHRQ.js} +7 -7
- package/dist/{chunk-VFQNVPFH.js.map → chunk-NRPYHHRQ.js.map} +1 -1
- package/dist/{chunk-6KZUGNCS.js → chunk-NUTURBAK.js} +3 -3
- package/dist/{chunk-6KZUGNCS.js.map → chunk-NUTURBAK.js.map} +1 -1
- package/dist/{chunk-EOQPV6KS.js → chunk-O2RXB3P3.js} +7 -7
- package/dist/{chunk-EOQPV6KS.js.map → chunk-O2RXB3P3.js.map} +1 -1
- package/dist/{chunk-HEWFF3KI.js → chunk-OEM2SFJE.js} +3 -3
- package/dist/{chunk-HEWFF3KI.js.map → chunk-OEM2SFJE.js.map} +1 -1
- package/dist/{chunk-A7KXUBPT.js → chunk-OJMG3NAF.js} +3 -3
- package/dist/{chunk-A7KXUBPT.js.map → chunk-OJMG3NAF.js.map} +1 -1
- package/dist/{chunk-TVAXTMMQ.js → chunk-QQWJNRSI.js} +3 -3
- package/dist/{chunk-TVAXTMMQ.js.map → chunk-QQWJNRSI.js.map} +1 -1
- package/dist/{chunk-6EOAIIHL.js → chunk-RUUQ5OVU.js} +3 -3
- package/dist/{chunk-6EOAIIHL.js.map → chunk-RUUQ5OVU.js.map} +1 -1
- package/dist/{chunk-R73HXW5D.js → chunk-SCBSKIBA.js} +4 -4
- package/dist/{chunk-R73HXW5D.js.map → chunk-SCBSKIBA.js.map} +1 -1
- package/dist/{chunk-ITZ543CK.js → chunk-SOLUKKTW.js} +3 -3
- package/dist/{chunk-ITZ543CK.js.map → chunk-SOLUKKTW.js.map} +1 -1
- package/dist/{chunk-TWLJ2RII.js → chunk-TDIENKPW.js} +4 -4
- package/dist/{chunk-TWLJ2RII.js.map → chunk-TDIENKPW.js.map} +1 -1
- package/dist/{chunk-5MNGLNIJ.js → chunk-UXJAZ5JP.js} +3 -3
- package/dist/{chunk-5MNGLNIJ.js.map → chunk-UXJAZ5JP.js.map} +1 -1
- package/dist/{chunk-JFKHKDSK.js → chunk-VNZ6VI2O.js} +3 -3
- package/dist/{chunk-JFKHKDSK.js.map → chunk-VNZ6VI2O.js.map} +1 -1
- package/dist/{chunk-OXBMZSKL.js → chunk-VXMWMGBQ.js} +4 -4
- package/dist/{chunk-OXBMZSKL.js.map → chunk-VXMWMGBQ.js.map} +1 -1
- package/dist/{chunk-YPRSS27D.js → chunk-XMSZSSTZ.js} +4 -4
- package/dist/{chunk-YPRSS27D.js.map → chunk-XMSZSSTZ.js.map} +1 -1
- package/dist/{chunk-R4BPODDJ.js → chunk-YRIMECFU.js} +3 -3
- package/dist/{chunk-R4BPODDJ.js.map → chunk-YRIMECFU.js.map} +1 -1
- package/dist/{chunk-CJZ3MJ3Y.js → chunk-ZNA3SWRP.js} +7 -7
- package/dist/{chunk-CJZ3MJ3Y.js.map → chunk-ZNA3SWRP.js.map} +1 -1
- package/dist/components/cart/index.js +1 -1
- package/dist/components/common/index.js +1 -1
- package/dist/components/drawer/index.js +12 -12
- package/dist/components/home/HomePageRenderer.d.ts +3 -1
- package/dist/components/home/HomePageRenderer.d.ts.map +1 -1
- package/dist/components/home/LatestProducts.d.ts +13 -0
- package/dist/components/home/LatestProducts.d.ts.map +1 -0
- package/dist/components/home/index.js +17 -16
- package/dist/components/home/lazy.d.ts +1 -0
- package/dist/components/home/lazy.d.ts.map +1 -1
- package/dist/components/home/register.d.ts.map +1 -1
- package/dist/components/layout/index.js +4 -4
- package/dist/components/navigation/MainMenu.d.ts.map +1 -1
- package/dist/components/product/index.js +14 -13
- package/dist/components/store/index.js +13 -13
- package/dist/dev/editor/index.js +1 -1
- package/dist/dev/index.js +1 -1
- package/dist/{document-class-IGGYSGCU.js → document-class-B4WBGWSA.js} +11 -11
- package/dist/{document-class-IGGYSGCU.js.map → document-class-B4WBGWSA.js.map} +1 -1
- package/dist/hooks/index.js +12 -12
- package/dist/hooks/useGtm.js +12 -12
- package/dist/hooks/useMoney.js +12 -12
- package/dist/hooks/useStore.js +12 -12
- package/dist/hooks/useUser.js +3 -3
- package/dist/index.js +12 -12
- package/dist/{navigation-MJYWGH7A.js → navigation-MBQKDV5V.js} +5 -5
- package/dist/{navigation-MJYWGH7A.js.map → navigation-MBQKDV5V.js.map} +1 -1
- package/dist/{navigation-FUHRDRAN.js → navigation-VPRCR725.js} +4 -4
- package/dist/{navigation-FUHRDRAN.js.map → navigation-VPRCR725.js.map} +1 -1
- package/dist/{not-found-VVI6BXAZ.js → not-found-OIZGDR7G.js} +15 -15
- package/dist/{not-found-VVI6BXAZ.js.map → not-found-OIZGDR7G.js.map} +1 -1
- package/dist/providers/index.js +12 -12
- package/dist/routes/account/orders.js +4 -4
- package/dist/routes/account.js +13 -13
- package/dist/routes/blog.js +8 -8
- package/dist/routes/brands.js +4 -4
- package/dist/routes/cart.js +21 -20
- package/dist/routes/cart.js.map +1 -1
- package/dist/routes/home/HomePage.d.ts.map +1 -1
- package/dist/routes/home.js +18 -17
- package/dist/routes/index.js +3 -3
- package/dist/routes/loyalty.js +5 -5
- package/dist/routes/page.js +4 -4
- package/dist/routes/product-listing.js +19 -18
- package/dist/routes/product-listing.js.map +1 -1
- package/dist/routes/product.js +17 -16
- package/dist/routes/product.js.map +1 -1
- package/dist/routes/root/beforeLoad.d.ts.map +1 -1
- package/dist/routes/seo-redirects.js +3 -3
- package/dist/routes/testimonials.js +2 -2
- package/dist/routes/thank-you.js +4 -4
- package/dist/skeleton.js +18 -17
- package/dist/{store-lookup-2P7PQVXE.js → store-lookup-HMU7QMSC.js} +8 -8
- package/dist/{store-lookup-2P7PQVXE.js.map → store-lookup-HMU7QMSC.js.map} +1 -1
- package/dist/tanstack/link.d.ts.map +1 -1
- package/dist/tanstack.js +11 -11
- package/dist/utils/index.js +2 -2
- package/package.json +1 -1
- package/tailwind/components/home/HomePageRenderer.tsx.txt +14 -3
- package/tailwind/components/home/LatestProducts.tsx.txt +63 -0
- package/tailwind/components/home/lazy.ts.txt +4 -0
- package/tailwind/components/home/register.ts.txt +2 -0
- package/tailwind/components/navigation/MainMenu.tsx.txt +2 -1
- package/tailwind/routes/home/HomePage.tsx.txt +6 -0
- package/tailwind/routes/root/beforeLoad.ts.txt +4 -2
- package/dist/MainMenu-ML6OQT53.js.map +0 -1
- package/dist/NoContent-63TMCPGY.js.map +0 -1
- package/dist/chunk-3QR6T7KW.js.map +0 -1
- package/dist/chunk-EGJ2SV6O.js.map +0 -1
- package/dist/chunk-LMMDVLAB.js.map +0 -1
- package/dist/chunk-P43VADN7.js.map +0 -1
- package/dist/chunk-SAYYMA6E.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/layout/PageAdvertisements.tsx"],"names":[],"mappings":";;;;;;;;AAOA,IAAM,eAAA,GAAkB,MAAM,kBAAA,EAAmB,CAAE,IAAA,EAAM,IAAA;AAGzD,IAAM,YAAA,GAAe,CAAC,EAAA,KAAe,CAAA,SAAA,EAAY,EAAE,CAAA,CAAA;AAGnD,IAAM,SAA0B,EAAC;AAGjC,IAAM,qBAAA,GACJ,uPAAA;AAEF,SAAS,YAAY,EAAA,EAAqB;AACxC,EAAA,IAAI;AACF,IAAA,OAAO,QAAQ,MAAA,CAAO,YAAA,CAAa,QAAQ,YAAA,CAAa,EAAE,CAAC,CAAC,CAAA;AAAA,EAC9D,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF;AAEA,SAAS,QAAQ,EAAA,EAAkB;AACjC,EAAA,MAAM,OAAA,GAAU,OAAO,KAAA,EAAO,OAAA;AAC9B,EAAA,IAAI,OAAO,SAAS,GAAA,KAAQ,UAAA,UAAoB,GAAA,CAAI,YAAA,CAAa,EAAE,CAAA,EAAG,WAAW,CAAA;AAAA,OAC5E;AACH,IAAA,IAAI;AACF,MAAA,MAAA,CAAO,YAAA,CAAa,QAAQ,YAAA,CAAa,EAAE,GAAG,IAAA,CAAK,SAAA,CAAU,WAAW,CAAC,CAAA;AAAA,IAC3E,CAAA,CAAA,MAAQ;AAAA,IAER;AAAA,EACF;AACF;AAeO,SAAS,kBAAA,GAAqB;AACnC,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,cAAA,EAAe;AAE7B,EAAA,MAAM,QAAA,GAAW,oBAAA,CAAq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,QAAA,EAAA,EAAO,wBAAA,EAAwB,IAAA,EAAE,QAAA,EAAA,qBAAA,EAAsB;AAAA,GAAA,EAC1D,CAAA;AAEJ","file":"chunk-5NTD7WXX.js","sourcesContent":["import { useEffect, useState, useSyncExternalStore } from 'react';\nimport { useQuery } from '@tanstack/react-query';\nimport { advertisement, advertisementsFor, type Advertisement } from '../../api/advertisement';\nimport { whenSallaReady } from '../../utils/sdk-helpers';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport { getTwilightContext, subscribeTwilight } from '../../twilight/context';\n\nconst currentPageSlug = () => getTwilightContext().page?.slug;\n\n/** The key `<salla-advertisement>` marks a closed ad with, through `salla.storage` (store.js, JSON). */\nconst dismissedKey = (id: number) => `statusAd-${id}`;\n\n/** Stable while the query has no data, so the effect below doesn't rerun on every render. */\nconst NO_ADS: Advertisement[] = [];\n\n/** Hides the ads this visitor closed before the first paint; the effect then drops them. */\nconst HIDE_DISMISSED_SCRIPT =\n \"(function(){try{if(window.self!==window.top)return;document.currentScript.parentNode.querySelectorAll('.s-advertisement[data-id]').forEach(function(e){if(localStorage.getItem('statusAd-'+e.getAttribute('data-id')))e.hidden=true})}catch(e){}})();\";\n\nfunction isDismissed(id: number): boolean {\n try {\n return Boolean(window.localStorage.getItem(dismissedKey(id)));\n } catch {\n return false;\n }\n}\n\nfunction dismiss(id: number): void {\n const storage = window.salla?.storage;\n if (typeof storage?.set === 'function') storage.set(dismissedKey(id), 'dismissed');\n else {\n try {\n window.localStorage.setItem(dismissedKey(id), JSON.stringify('dismissed'));\n } catch {\n // Storage disabled: the ad hides for this page view only.\n }\n }\n}\n\ninterface ClientView {\n /** The theme editor's iframe, or the SDK's debug flag: every ad shows, closed or not. */\n preview: boolean;\n /** Inside the Salla mobile app, which shows no ads. */\n inApp: boolean;\n dismissed: Set<number>;\n}\n\n/**\n * The merchant's announcement bars, in place of `<salla-advertisement>`. Same data, rules and\n * markup, but rendered on the server (the ads are prefetched in the root `beforeLoad`), so the\n * bar is in the first paint instead of pushing the page down when the web component fetches it.\n */\nexport function PageAdvertisements() {\n const { t } = useTranslation();\n // The deepest route loader's `page`, the page `salla.config` reports.\n const pageSlug = useSyncExternalStore(subscribeTwilight, currentPageSlug, currentPageSlug);\n // The query's `retry: 0` only bounds the server wait; the browser may retry.\n const { data: ads = NO_ADS } = useQuery({ ...advertisement.queries.list(), retry: 2 });\n const [view, setView] = useState<ClientView | null>(null);\n\n useEffect(() => {\n const dismissed = new Set(ads.filter((ad) => isDismissed(ad.id)).map((ad) => ad.id));\n setView({ preview: window.self !== window.top, inApp: false, dismissed });\n return whenSallaReady((sdk) => {\n const config = sdk.config as { isMobileApp?: () => boolean; isDebug?: () => boolean };\n const inApp = Boolean(config?.isMobileApp?.());\n const debug = Boolean(config?.isDebug?.());\n if (inApp || debug) {\n setView((current) =>\n current ? { ...current, inApp, preview: current.preview || debug } : current\n );\n }\n });\n }, [ads]);\n\n if (view?.inApp) return null;\n const shown = view?.preview\n ? ads\n : advertisementsFor(ads, pageSlug).filter((ad) => !view?.dismissed.has(ad.id));\n if (!shown.length) return null;\n\n const close = (id: number) => {\n dismiss(id);\n setView((current) =>\n current ? { ...current, dismissed: new Set(current.dismissed).add(id) } : current\n );\n };\n\n return (\n <>\n {shown.map((ad) => (\n <div\n key={ad.id}\n className=\"s-advertisement\"\n data-id={ad.id}\n style={{ backgroundColor: ad.colors?.bg, color: ad.colors?.text }}\n >\n <div className=\"s-advertisement-content container flex justify-between items-center py-2.5\">\n <span className=\"s-advertisement-content-main flex-1 font-bold text-center text-sm\">\n {/* Rendered without an icon too, as the SDK does: its margin is part of the layout. */}\n <i\n className={`s-advertisement-content-icon inline-block align-middle me-2 text-base ${ad.icon ?? ''}`}\n />\n {ad.url ? (\n <a\n href={ad.url}\n target={ad.target ?? undefined}\n rel={ad.target === '_blank' ? 'noopener' : undefined}\n >\n {ad.description}\n </a>\n ) : (\n ad.description\n )}\n </span>\n <button\n type=\"button\"\n className=\"s-advertisement-action px-1\"\n aria-label={t('common.buttons.close', 'Close')}\n onClick={() => close(ad.id)}\n >\n {/* `inline-block`: before the icon CSS loads, an empty inline `<i>` leaves the button 0px tall. */}\n <i className=\"sicon-cancel inline-block\" />\n </button>\n </div>\n </div>\n ))}\n <script suppressHydrationWarning>{HIDE_DISMISSED_SCRIPT}</script>\n </>\n );\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { filesCdn, cdn } from './chunk-
|
|
1
|
+
import { filesCdn, cdn } from './chunk-UXJAZ5JP.js';
|
|
2
2
|
import { storeTranslationsQueryKey, translationsQueryKey, composeMessages, isPlainObject } from './chunk-6K34BCUP.js';
|
|
3
3
|
import { queryOptions } from '@tanstack/react-query';
|
|
4
4
|
|
|
@@ -126,5 +126,5 @@ var translations = {
|
|
|
126
126
|
};
|
|
127
127
|
|
|
128
128
|
export { commonTranslationsPath, storeTranslationsPath, translations };
|
|
129
|
-
//# sourceMappingURL=chunk-
|
|
130
|
-
//# sourceMappingURL=chunk-
|
|
129
|
+
//# sourceMappingURL=chunk-7DRXAR76.js.map
|
|
130
|
+
//# sourceMappingURL=chunk-7DRXAR76.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/translations.ts"],"names":[],"mappings":";;;;AAiEA,IAAM,kBAAA,GAAqB,sBAAA;AAGpB,SAAS,uBAAuB,MAAA,EAAwB;AAC7D,EAAA,OAAO,uBAAuB,MAAM,CAAA,KAAA,CAAA;AACtC;AAWO,SAAS,qBAAA,CAAsB,SAA0B,MAAA,EAAwB;AACtF,EAAA,OAAO,CAAA,aAAA,EAAgB,OAAO,CAAA,CAAA,EAAI,MAAM,CAAA,KAAA,CAAA;AAC1C;AAUA,eAAe,eACb,IAAA,EACA,EAAE,aAAa,KAAA,EAAM,GAA8B,EAAC,EAC1B;AAE1B,EAAA,MAAM,UAAA,GAAa,CAAC,MAAA,EAAgB,KAAA,KAA0B;AAC5D,IAAA,IAAI,UAAA,EAAY,MAAM,IAAI,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AAA,MACX,QAAA,EAAU,qBAAqB,MAAM,CAAA;AAAA,MACrC,OAAA,EAAS,MAAM,YAAA,CAAa,GAAA,CAAI,MAAM;AAAA,KACvC,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWH,OAAA,EAAS,CAAC,OAAA,EAA0B,MAAA,KAClC,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,yBAAA,CAA0B,OAAA,EAAS,MAAM,CAAA;AAAA,MACnD,OAAA,EAAS,MAAM,YAAA,CAAa,QAAA,CAAS,SAAS,MAAM;AAAA,KACrD;AAAA;AAEP","file":"chunk-FVHAKOEH.js","sourcesContent":["/**\n * @fileoverview Where a storefront's words come from.\n *\n * Two files, merged: the platform's copy for this language, and the merchant's\n * own edits for this language and this store. Both are plain JSON objects on\n * the uploader's CDN, one per language.\n *\n * ```\n * https://cdn.files.salla.network/translations/common/<locale>.json the platform's\n * https://cdn.files.salla.network/translations/<storeId>/<locale>.json the merchant's\n * ```\n *\n * **What this replaces, and why.** Until now the engine read a single global\n * file, `cdn.salla.network/js/translations.json`, holding every language keyed\n * `\"<locale>.trans\"`. Nothing publishes that file: it is an object last written\n * on 2026-03-26, carrying only `ar` and `en` where the platform has 39 locales,\n * 405 keys behind `Languages-Module` and 959 English strings textually\n * different from it. So every React storefront has been serving copy from\n * March, and a key added since has never reached one. It also carried no\n * merchant overrides at all — a merchant editing their theme's wording in the\n * Dashboard changed nothing on a React theme.\n *\n * **Merchant overrides are read, and only when there are any.** Getting here\n * took two corrections worth keeping.\n *\n * The first is the address. A merchant's own wording lives at\n * `translations/<storeId>/<locale>.json`, keyed by `store()->getRouteKey()` —\n * the Optimus-encoded numeric id. An early version addressed it with\n * `resolveStoreIdentifier()`, on the claim that the two are the same string.\n * That is true of the `store-identifier` *header*, which accepts a host, a\n * username or an id, and false of the R2 key: on a custom domain the resolver\n * returns `reefperfumes.com` and on a shared host a username like\n * `mtgr-alaatr-2`. Both 404, both then read as \"this store has no overrides\",\n * and the merchant's wording silently never appears — so the feature would have\n * worked under `?storeId=` alone, which is preview and localhost. It is\n * `settings.store.id` now, which is known only after the settings query.\n *\n * The second is when to ask at all. Most stores have never customised a word,\n * and a miss is an uncached round trip (`cf-cache-status: DYNAMIC` on the 404)\n * on the critical path of every SSR render. So the request is made only when\n * `settings.languages[<ISO>].has_custom_translations` says there is something\n * to get — a flag `Languages-Module` writes when a merchant saves a\n * translation. A store without overrides pays nothing, which is what made this\n * shippable at all.\n *\n * ⚠️ The flag is written on save, so a store whose wording predates it reads as\n * `false` until someone edits a translation or the backfill runs. That is a\n * store keeping today's behaviour, not a regression — React themes have never\n * read merchant overrides — but it does mean the feature is only as complete as\n * the backfill.\n *\n * **Rollout is by fallback, not by flag.** `translations/common/` is written by\n * a sync in the theme build service that may not have run yet, and a hard switch\n * would leave every storefront with no platform strings at all. A missing common\n * file therefore falls back to the old global one, which is exactly today's\n * behaviour — so this is safe to ship before the bucket is populated, and stops\n * using the fallback on its own once it is.\n */\nimport { queryOptions } from '@tanstack/react-query';\nimport { cdn, filesCdn } from './client';\nimport { storeTranslationsQueryKey, translationsQueryKey } from './translations-key';\nimport { composeMessages, isPlainObject, type Messages } from './messages';\nimport type { TranslationMessages } from '../providers/I18nProvider';\n\n/** The global file this used to be the only reader of. See the file comment. */\nconst LEGACY_GLOBAL_FILE = 'js/translations.json';\n\n/** One language of platform copy, shared by every store. */\nexport function commonTranslationsPath(locale: string): string {\n return `translations/common/${locale}.json`;\n}\n\n/**\n * One language of a single merchant's own wording.\n *\n * `storeId` is `settings.store.id`, which is the value `Languages-Module` names\n * the object with (`store()->getRouteKey()`, the Optimus-encoded numeric id).\n * It is **not** `resolveStoreIdentifier()`: that returns a hostname on a custom\n * domain and a username on a shared host, both of which 404 here and would read\n * as \"this merchant has no overrides\" — silently, on every store but a preview.\n */\nexport function storeTranslationsPath(storeId: string | number, locale: string): string {\n return `translations/${storeId}/${locale}.json`;\n}\n\n/**\n * Reads one language file, or `null` when there is nothing to read.\n *\n * A 404 is the ordinary answer, not a failure: most stores have never had a\n * word customised, so their file does not exist. Distinguishing it from a real\n * error matters only for the log — both end in `null` — but a warning on every\n * page load of every uncustomised store is a warning nobody will read.\n */\nasync function readLocaleFile(\n path: string,\n { failLoudly = false }: { failLoudly?: boolean } = {}\n): Promise<Messages | null> {\n /** A 404 always means \"absent\"; everything else is a failure to read. */\n const unreadable = (reason: string, cause?: unknown): null => {\n if (failLoudly) throw new Error(`[translations] ${path}: ${reason}`, { cause });\n console.warn('[translations]', reason, path, cause ?? '');\n return null;\n };\n\n try {\n const response = await filesCdn.get(path, { throwHttpErrors: false, timeout: 5000 });\n if (response.status === 404) return null;\n\n if (!response.ok) {\n return unreadable(`answered ${response.status}`);\n }\n\n const data: unknown = await response.json();\n if (!isPlainObject(data)) {\n return unreadable('is not a JSON object');\n }\n\n return data;\n } catch (error) {\n if (error instanceof Error && error.message.startsWith('[translations]')) throw error;\n return unreadable('could not be read', error);\n }\n}\n\n/**\n * The pre-CDN global file, sliced to one language.\n *\n * Only reached when `translations/common/<locale>.json` is missing, which is\n * the state of the bucket until the sync has run once.\n */\nasync function readLegacyGlobal(locale: string): Promise<Messages | null> {\n try {\n const data = await cdn.get(LEGACY_GLOBAL_FILE, { timeout: 5000 }).json<TranslationMessages>();\n const forLocale = data?.[`${locale}.trans`];\n return isPlainObject(forLocale) ? forLocale : null;\n } catch {\n console.warn('[translations] the legacy global file could not be read either');\n return null;\n }\n}\n\nexport const translations = {\n /**\n * The platform's copy for `locale`.\n *\n * One file, so one request. See the file comment for why the merchant's own\n * wording is not merged in here yet and what it is waiting on.\n */\n get: async (locale: string): Promise<TranslationMessages | null> => {\n const common = await readLocaleFile(commonTranslationsPath(locale));\n const base = common ?? (await readLegacyGlobal(locale));\n if (!base) return null;\n\n // Still wrapped in the `<locale>.trans` shape the rest of the engine reads.\n // `createI18nInstance` slices by that key and so does the SDK bridge in\n // `I18nProvider`; changing the envelope here would be a second change for\n // no gain, since one language is all any of them ever take out of it.\n return { [`${locale}.trans`]: base as Record<string, string> };\n },\n\n /**\n * This merchant's own wording for `locale`, or `null` if they have none.\n *\n * Only worth calling when `settings.languages[<ISO>].has_custom_translations`\n * says there is something to get. Most stores have never customised a word,\n * and a miss here is an uncached round trip — `cf-cache-status: DYNAMIC` on a\n * 404 — on the critical path of an SSR render. The flag is what makes this\n * free for everyone who does not use it.\n *\n * Returned unwrapped, unlike {@link translations.get}: this is merged into\n * that one's messages rather than handed to i18next on its own.\n */\n forStore: async (storeId: string | number, locale: string): Promise<Messages | null> =>\n // `failLoudly`, unlike the platform file: this is only ever called because\n // the settings said overrides exist, so a 500, a timeout or a body that is\n // not JSON is a failure to read them — not a store that has none. Returning\n // `null` there would cache \"no overrides\" as a success, skip the query's\n // retry, and serve Salla's wording in place of the merchant's until the\n // entry expired. A 404 still means absent, and `rootBeforeLoad` catches the\n // throw and keeps the platform copy, so the worst case is unchanged.\n readLocaleFile(storeTranslationsPath(storeId, locale), { failLoudly: true }),\n\n /**\n * The platform's copy for `locale` with this merchant's wording laid over it.\n *\n * Takes the two as values rather than fetching them, so the caller decides\n * whether the second request happens at all and both stay separately cached.\n */\n /**\n * The platform's copy for `locale` with this merchant's wording over it.\n *\n * Delegates to `composeMessages`, which every other reader of these two\n * entries also uses — see `api/messages.ts` for why there is exactly one.\n */\n merge: (\n common: TranslationMessages | null,\n overrides: Messages | null,\n locale: string\n ): TranslationMessages | null => composeMessages(common, overrides, locale) ?? null,\n\n queries: {\n /**\n * @param locale taken as an argument rather than read from the twilight\n * context, and that is load-bearing. This key is built on the server, on\n * hydration, and again lazily from the context accessor; if any of the\n * three read a locale the others had not been given yet, the hydrated page\n * would miss the dehydrated entry and refetch both files it was just\n * handed. Every caller already has the locale in hand.\n *\n * The store is deliberately **not** in the key. One document serves one\n * store — a request that names a different one is redirected with\n * `reloadDocument`, so the client never changes store under a live cache —\n * and adding a value that resolves from the request on the server and from\n * the injected env on the client is how a key stops matching across\n * hydration.\n */\n byLocale: (locale: string) =>\n queryOptions({\n queryKey: translationsQueryKey(locale),\n queryFn: () => translations.get(locale),\n }),\n\n /**\n * This merchant's overrides, cached apart from the platform's copy.\n *\n * Its own entry rather than a wider `byLocale` key, so the common file is\n * fetched and dehydrated once per language whatever the store does, and a\n * store with no overrides never has an entry at all. Both sides compute the\n * key from the settings payload, so the hydrated page finds what the server\n * dehydrated instead of refetching it.\n */\n byStore: (storeId: string | number, locale: string) =>\n queryOptions({\n queryKey: storeTranslationsQueryKey(storeId, locale),\n queryFn: () => translations.forStore(storeId, locale),\n }),\n },\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/api/translations.ts"],"names":[],"mappings":";;;;AAiEA,IAAM,kBAAA,GAAqB,sBAAA;AAGpB,SAAS,uBAAuB,MAAA,EAAwB;AAC7D,EAAA,OAAO,uBAAuB,MAAM,CAAA,KAAA,CAAA;AACtC;AAWO,SAAS,qBAAA,CAAsB,SAA0B,MAAA,EAAwB;AACtF,EAAA,OAAO,CAAA,aAAA,EAAgB,OAAO,CAAA,CAAA,EAAI,MAAM,CAAA,KAAA,CAAA;AAC1C;AAUA,eAAe,eACb,IAAA,EACA,EAAE,aAAa,KAAA,EAAM,GAA8B,EAAC,EAC1B;AAE1B,EAAA,MAAM,UAAA,GAAa,CAAC,MAAA,EAAgB,KAAA,KAA0B;AAC5D,IAAA,IAAI,UAAA,EAAY,MAAM,IAAI,KAAA,CAAM,CAAA,eAAA,EAAkB,IAAI,CAAA,EAAA,EAAK,MAAM,CAAA,CAAA,EAAI,EAAE,KAAA,EAAO,CAAA;AAC9E,IAAA,OAAA,CAAQ,IAAA,CAAK,gBAAA,EAAkB,MAAA,EAAQ,IAAA,EAAM,SAAS,EAAE,CAAA;AACxD,IAAA,OAAO,IAAA;AAAA,EACT,CAAA;AAEA,EAAA,IAAI;AACF,IAAA,MAAM,QAAA,GAAW,MAAM,QAAA,CAAS,GAAA,CAAI,IAAA,EAAM,EAAE,eAAA,EAAiB,KAAA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AS,SAAS,MAAM;AAAA,KACrD;AAAA;AAEP","file":"chunk-7DRXAR76.js","sourcesContent":["/**\n * @fileoverview Where a storefront's words come from.\n *\n * Two files, merged: the platform's copy for this language, and the merchant's\n * own edits for this language and this store. Both are plain JSON objects on\n * the uploader's CDN, one per language.\n *\n * ```\n * https://cdn.files.salla.network/translations/common/<locale>.json the platform's\n * https://cdn.files.salla.network/translations/<storeId>/<locale>.json the merchant's\n * ```\n *\n * **What this replaces, and why.** Until now the engine read a single global\n * file, `cdn.salla.network/js/translations.json`, holding every language keyed\n * `\"<locale>.trans\"`. Nothing publishes that file: it is an object last written\n * on 2026-03-26, carrying only `ar` and `en` where the platform has 39 locales,\n * 405 keys behind `Languages-Module` and 959 English strings textually\n * different from it. So every React storefront has been serving copy from\n * March, and a key added since has never reached one. It also carried no\n * merchant overrides at all — a merchant editing their theme's wording in the\n * Dashboard changed nothing on a React theme.\n *\n * **Merchant overrides are read, and only when there are any.** Getting here\n * took two corrections worth keeping.\n *\n * The first is the address. A merchant's own wording lives at\n * `translations/<storeId>/<locale>.json`, keyed by `store()->getRouteKey()` —\n * the Optimus-encoded numeric id. An early version addressed it with\n * `resolveStoreIdentifier()`, on the claim that the two are the same string.\n * That is true of the `store-identifier` *header*, which accepts a host, a\n * username or an id, and false of the R2 key: on a custom domain the resolver\n * returns `reefperfumes.com` and on a shared host a username like\n * `mtgr-alaatr-2`. Both 404, both then read as \"this store has no overrides\",\n * and the merchant's wording silently never appears — so the feature would have\n * worked under `?storeId=` alone, which is preview and localhost. It is\n * `settings.store.id` now, which is known only after the settings query.\n *\n * The second is when to ask at all. Most stores have never customised a word,\n * and a miss is an uncached round trip (`cf-cache-status: DYNAMIC` on the 404)\n * on the critical path of every SSR render. So the request is made only when\n * `settings.languages[<ISO>].has_custom_translations` says there is something\n * to get — a flag `Languages-Module` writes when a merchant saves a\n * translation. A store without overrides pays nothing, which is what made this\n * shippable at all.\n *\n * ⚠️ The flag is written on save, so a store whose wording predates it reads as\n * `false` until someone edits a translation or the backfill runs. That is a\n * store keeping today's behaviour, not a regression — React themes have never\n * read merchant overrides — but it does mean the feature is only as complete as\n * the backfill.\n *\n * **Rollout is by fallback, not by flag.** `translations/common/` is written by\n * a sync in the theme build service that may not have run yet, and a hard switch\n * would leave every storefront with no platform strings at all. A missing common\n * file therefore falls back to the old global one, which is exactly today's\n * behaviour — so this is safe to ship before the bucket is populated, and stops\n * using the fallback on its own once it is.\n */\nimport { queryOptions } from '@tanstack/react-query';\nimport { cdn, filesCdn } from './client';\nimport { storeTranslationsQueryKey, translationsQueryKey } from './translations-key';\nimport { composeMessages, isPlainObject, type Messages } from './messages';\nimport type { TranslationMessages } from '../providers/I18nProvider';\n\n/** The global file this used to be the only reader of. See the file comment. */\nconst LEGACY_GLOBAL_FILE = 'js/translations.json';\n\n/** One language of platform copy, shared by every store. */\nexport function commonTranslationsPath(locale: string): string {\n return `translations/common/${locale}.json`;\n}\n\n/**\n * One language of a single merchant's own wording.\n *\n * `storeId` is `settings.store.id`, which is the value `Languages-Module` names\n * the object with (`store()->getRouteKey()`, the Optimus-encoded numeric id).\n * It is **not** `resolveStoreIdentifier()`: that returns a hostname on a custom\n * domain and a username on a shared host, both of which 404 here and would read\n * as \"this merchant has no overrides\" — silently, on every store but a preview.\n */\nexport function storeTranslationsPath(storeId: string | number, locale: string): string {\n return `translations/${storeId}/${locale}.json`;\n}\n\n/**\n * Reads one language file, or `null` when there is nothing to read.\n *\n * A 404 is the ordinary answer, not a failure: most stores have never had a\n * word customised, so their file does not exist. Distinguishing it from a real\n * error matters only for the log — both end in `null` — but a warning on every\n * page load of every uncustomised store is a warning nobody will read.\n */\nasync function readLocaleFile(\n path: string,\n { failLoudly = false }: { failLoudly?: boolean } = {}\n): Promise<Messages | null> {\n /** A 404 always means \"absent\"; everything else is a failure to read. */\n const unreadable = (reason: string, cause?: unknown): null => {\n if (failLoudly) throw new Error(`[translations] ${path}: ${reason}`, { cause });\n console.warn('[translations]', reason, path, cause ?? '');\n return null;\n };\n\n try {\n const response = await filesCdn.get(path, { throwHttpErrors: false, timeout: 5000 });\n if (response.status === 404) return null;\n\n if (!response.ok) {\n return unreadable(`answered ${response.status}`);\n }\n\n const data: unknown = await response.json();\n if (!isPlainObject(data)) {\n return unreadable('is not a JSON object');\n }\n\n return data;\n } catch (error) {\n if (error instanceof Error && error.message.startsWith('[translations]')) throw error;\n return unreadable('could not be read', error);\n }\n}\n\n/**\n * The pre-CDN global file, sliced to one language.\n *\n * Only reached when `translations/common/<locale>.json` is missing, which is\n * the state of the bucket until the sync has run once.\n */\nasync function readLegacyGlobal(locale: string): Promise<Messages | null> {\n try {\n const data = await cdn.get(LEGACY_GLOBAL_FILE, { timeout: 5000 }).json<TranslationMessages>();\n const forLocale = data?.[`${locale}.trans`];\n return isPlainObject(forLocale) ? forLocale : null;\n } catch {\n console.warn('[translations] the legacy global file could not be read either');\n return null;\n }\n}\n\nexport const translations = {\n /**\n * The platform's copy for `locale`.\n *\n * One file, so one request. See the file comment for why the merchant's own\n * wording is not merged in here yet and what it is waiting on.\n */\n get: async (locale: string): Promise<TranslationMessages | null> => {\n const common = await readLocaleFile(commonTranslationsPath(locale));\n const base = common ?? (await readLegacyGlobal(locale));\n if (!base) return null;\n\n // Still wrapped in the `<locale>.trans` shape the rest of the engine reads.\n // `createI18nInstance` slices by that key and so does the SDK bridge in\n // `I18nProvider`; changing the envelope here would be a second change for\n // no gain, since one language is all any of them ever take out of it.\n return { [`${locale}.trans`]: base as Record<string, string> };\n },\n\n /**\n * This merchant's own wording for `locale`, or `null` if they have none.\n *\n * Only worth calling when `settings.languages[<ISO>].has_custom_translations`\n * says there is something to get. Most stores have never customised a word,\n * and a miss here is an uncached round trip — `cf-cache-status: DYNAMIC` on a\n * 404 — on the critical path of an SSR render. The flag is what makes this\n * free for everyone who does not use it.\n *\n * Returned unwrapped, unlike {@link translations.get}: this is merged into\n * that one's messages rather than handed to i18next on its own.\n */\n forStore: async (storeId: string | number, locale: string): Promise<Messages | null> =>\n // `failLoudly`, unlike the platform file: this is only ever called because\n // the settings said overrides exist, so a 500, a timeout or a body that is\n // not JSON is a failure to read them — not a store that has none. Returning\n // `null` there would cache \"no overrides\" as a success, skip the query's\n // retry, and serve Salla's wording in place of the merchant's until the\n // entry expired. A 404 still means absent, and `rootBeforeLoad` catches the\n // throw and keeps the platform copy, so the worst case is unchanged.\n readLocaleFile(storeTranslationsPath(storeId, locale), { failLoudly: true }),\n\n /**\n * The platform's copy for `locale` with this merchant's wording laid over it.\n *\n * Takes the two as values rather than fetching them, so the caller decides\n * whether the second request happens at all and both stay separately cached.\n */\n /**\n * The platform's copy for `locale` with this merchant's wording over it.\n *\n * Delegates to `composeMessages`, which every other reader of these two\n * entries also uses — see `api/messages.ts` for why there is exactly one.\n */\n merge: (\n common: TranslationMessages | null,\n overrides: Messages | null,\n locale: string\n ): TranslationMessages | null => composeMessages(common, overrides, locale) ?? null,\n\n queries: {\n /**\n * @param locale taken as an argument rather than read from the twilight\n * context, and that is load-bearing. This key is built on the server, on\n * hydration, and again lazily from the context accessor; if any of the\n * three read a locale the others had not been given yet, the hydrated page\n * would miss the dehydrated entry and refetch both files it was just\n * handed. Every caller already has the locale in hand.\n *\n * The store is deliberately **not** in the key. One document serves one\n * store — a request that names a different one is redirected with\n * `reloadDocument`, so the client never changes store under a live cache —\n * and adding a value that resolves from the request on the server and from\n * the injected env on the client is how a key stops matching across\n * hydration.\n */\n byLocale: (locale: string) =>\n queryOptions({\n queryKey: translationsQueryKey(locale),\n queryFn: () => translations.get(locale),\n }),\n\n /**\n * This merchant's overrides, cached apart from the platform's copy.\n *\n * Its own entry rather than a wider `byLocale` key, so the common file is\n * fetched and dehydrated once per language whatever the store does, and a\n * store with no overrides never has an entry at all. Both sides compute the\n * key from the settings payload, so the hydrated page finds what the server\n * dehydrated instead of refetching it.\n */\n byStore: (storeId: string | number, locale: string) =>\n queryOptions({\n queryKey: storeTranslationsQueryKey(storeId, locale),\n queryFn: () => translations.forStore(storeId, locale),\n }),\n },\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { orThrow } from './chunk-
|
|
2
|
-
import { getActiveScope, api } from './chunk-
|
|
1
|
+
import { orThrow } from './chunk-SOLUKKTW.js';
|
|
2
|
+
import { getActiveScope, api } from './chunk-UXJAZ5JP.js';
|
|
3
3
|
import { getTwilightContext } from './chunk-6K34BCUP.js';
|
|
4
4
|
import { defaultShouldDehydrateQuery, queryOptions } from '@tanstack/react-query';
|
|
5
5
|
|
|
@@ -215,5 +215,5 @@ var product = {
|
|
|
215
215
|
};
|
|
216
216
|
|
|
217
217
|
export { getProductPreview, isProductPreviewQuery, parseNextPageToken, product, productDetailQueryKey, productPreviewQueryKey, rememberProductPreview, shouldDehydrateQuery };
|
|
218
|
-
//# sourceMappingURL=chunk-
|
|
219
|
-
//# sourceMappingURL=chunk-
|
|
218
|
+
//# sourceMappingURL=chunk-7PFJOTZS.js.map
|
|
219
|
+
//# sourceMappingURL=chunk-7PFJOTZS.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/product.ts"],"names":["product"],"mappings":";;;;;AA+FA,SAAS,iBAAA,GAAoB;AAC3B,EAAA,IAAI;AACF,IAAA,MAAM,WAAA,GAAc,oBAAmB,CAAE,WAAA;AACzC,IAAA,OAAO,WAAA,IAAe,OAAO,WAAA,CAAY,YAAA,KAAiB,aAAa,WAAA,GAAc,IAAA;AAAA,EACvF,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAEO,SAAS,uBAAuB,EAAA,EAAY;AACjD,EAAA,OAAO,CAAC,UAAA,EAAY,SAAA,EAAW,MAAA,CAAO,EAAE,GAAG,EAAE,KAAA,EAAO,cAAA,EAAe,EAAG,CAAA;AACxE;AAEO,SAAS,sBAAsB,EAAA,EAAY;AAChD,EAAA,OAAO,CAAC,YAAY,QAAA,EAAU,EAAA,EAAI,EAAE,KAAA,EAAO,cAAA,IAAkB,CAA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,MAAA,EAAQ,kBAAA,GAAqB,MAAA;AAAO,OACjE;AAAA,MACA,OAAA,EAAS,CAAC,EAAE,MAAA,EAAO,KAAM,OAAA,CAAQ,IAAA,CAAK,EAAE,GAAG,MAAA,EAAQ,MAAA,EAAQ;AAAA,KAC5D;AAAA;AAEP","file":"chunk-U6EB7GM3.js","sourcesContent":["import { queryOptions, defaultShouldDehydrateQuery } from '@tanstack/react-query';\nimport { api, getActiveScope } from './client';\nimport type { Product } from '../types';\nimport type { Pagination, PaginatedResult } from './types';\nimport { orThrow } from '../providers/NavigationProvider';\nimport { getTwilightContext } from '../twilight/context';\nimport type { ActiveScope } from '../utils/cookies';\n\n// ===== Filter Types =====\n\nexport interface FilterValue {\n key?: string;\n count?: number;\n value?: string;\n from?: number | '*';\n to?: number | '*';\n}\n\nexport interface Filter {\n key?: string;\n label?: string;\n type?: string;\n values?: FilterValue[];\n max?: number;\n min?: number;\n}\n\n// ===== Product List Types =====\n\nexport type ProductsListSource =\n | 'brands'\n | 'categories'\n | 'json'\n | 'landing-page'\n | 'latest'\n | 'offers'\n | 'recently'\n | 'related'\n | 'selected'\n | 'tags'\n | 'top-rated'\n | 'wishlist'\n | 'search'\n | 'sales'\n | 'reorder'\n | 'best_selling';\n\nexport interface ProductsListParams {\n /** Source type (wishlist, latest, brands, etc.) */\n source: ProductsListSource;\n /**\n * The ids the source reads, as an array: category, brand, tag or product ids\n * (`sourceValue: [708738657]`). Sent as `source_value[]`.\n */\n sourceValue?: string | number | number[] | null;\n /** The search words when `source` is `'search'`. Sent as `keyword`; other sources ignore it. */\n keyword?: string;\n /** Page number for offset-based pagination */\n page?: number;\n /** Cursor for cursor-based pagination (from previous response) */\n cursor?: string | null;\n /** Items per page (default: 15) */\n perPage?: number;\n /** Sort option */\n sort?: string;\n /** Enable filters on the response */\n filterable?: boolean;\n /** Applied `<salla-filters>` selection (the `salla-filters::changed` payload). */\n filters?: ProductListFilters;\n /** Abort signal for cancellation */\n signal?: AbortSignal;\n}\n\n/** One `<salla-filters>` value: a scalar, a list, or a nested `{ sub-key: value }` (variants). */\nexport type ProductListFilterValue =\n string | number | Array<string | number> | { [key: string]: ProductListFilterValue };\n\n/** A `<salla-filters>` selection, i.e. the `salla-filters::changed` payload. */\nexport type ProductListFilters = Record<string, ProductListFilterValue>;\n\nexport type ProductsListResult = PaginatedResult<Product> & {\n filters?: Filter[];\n};\n\nexport interface ProductsListResponse {\n data: Product[];\n cursor?: Pagination;\n filters?: Filter[];\n}\n\n// ===== List-card preview cache =====\n// List payloads are a subset of details (one `image`, no `options` / `images[]`).\n// They live on a separate query key so they can paint a sheet/quick-view without\n// being treated as a successful `products/{id}/details` fetch.\n\nfunction queryClientOrNull() {\n try {\n const queryClient = getTwilightContext().queryClient;\n return queryClient && typeof queryClient.setQueryData === 'function' ? queryClient : null;\n } catch {\n return null;\n }\n}\n\nexport function productPreviewQueryKey(id: string) {\n return ['products', 'preview', String(id), { scope: getActiveScope() }] as const;\n}\n\nexport function productDetailQueryKey(id: string) {\n return ['products', 'detail', id, { scope: getActiveScope() }] as const;\n}\n\n/** True when this query is a list-card stand-in — skip it when dehydrating SSR. */\nexport function isProductPreviewQuery(query: { queryKey: readonly unknown[] }): boolean {\n return query.queryKey[0] === 'products' && query.queryKey[1] === 'preview';\n}\n\n/**\n * Default dehydrate policy (success) plus pending SSR-stream queries, minus\n * list-card stand-ins. Replacing the default wholesale would ship error states.\n */\nexport function shouldDehydrateQuery(\n query: Parameters<typeof defaultShouldDehydrateQuery>[0]\n): boolean {\n return (\n !isProductPreviewQuery(query) &&\n (defaultShouldDehydrateQuery(query) || query.state.status === 'pending')\n );\n}\n\n/**\n * Remember a list/card product so `product.queries.detail(id)` can use it as\n * `placeholderData` while details load. No-op if details for this id are already\n * cached. Themes that fetch products outside `product.list` should call this.\n */\nexport function rememberProductPreview(product: Product): void {\n const queryClient = queryClientOrNull();\n if (!queryClient || product?.id == null) return;\n const id = String(product.id);\n if (queryClient.getQueryState(productDetailQueryKey(id))?.status === 'success') return;\n queryClient.setQueryData(productPreviewQueryKey(id), product);\n}\n\nfunction scopeFromQueryKey(queryKey: readonly unknown[]): ActiveScope | null | undefined {\n const last = queryKey[queryKey.length - 1];\n if (last == null || typeof last !== 'object' || !('scope' in last)) return undefined;\n return (last as { scope: ActiveScope | null }).scope;\n}\n\nfunction isSameScope(a: ActiveScope | null | undefined, b: ActiveScope | null): boolean {\n if (a === undefined) return false;\n if (a === b) return true;\n if (a == null || b == null) return a == null && b == null;\n return (\n a.id === b.id &&\n a.type === b.type &&\n a.allocation_id === b.allocation_id &&\n a.allocation_type === b.allocation_type\n );\n}\n\nconst LIST_QUERY_PREFIXES = [\n ['products', 'list'],\n ['wishlist', 'list'],\n] as const;\n\n/**\n * Rebuild the scoped preview index from hydrated list/wishlist queries (SSR\n * dehydrate drops preview keys). Subsequent lookups hit `productPreviewQueryKey`.\n */\nfunction findProductInScopedLists(\n queryClient: NonNullable<ReturnType<typeof queryClientOrNull>>,\n id: string\n): Product | undefined {\n const scope = getActiveScope();\n let found: Product | undefined;\n for (const prefix of LIST_QUERY_PREFIXES) {\n for (const [queryKey, data] of queryClient.getQueriesData<ProductsListResult>({\n queryKey: prefix,\n })) {\n if (!isSameScope(scopeFromQueryKey(queryKey), scope)) continue;\n for (const item of data?.items ?? []) {\n if (item?.id == null) continue;\n rememberProductPreview(item);\n if (!found && String(item.id) === id) found = item;\n }\n }\n }\n return found;\n}\n\n/**\n * List-card product for `placeholderData`. Prefers the preview key; if that was\n * dropped on SSR dehydrate, rebuilds it from the current-scope list/wishlist.\n */\nexport function getProductPreview(id: string): Product | undefined {\n const queryClient = queryClientOrNull();\n if (!queryClient) return undefined;\n const key = String(id);\n return (\n queryClient.getQueryData(productPreviewQueryKey(key)) ??\n findProductInScopedLists(queryClient, key)\n );\n}\n\nfunction rememberProductPreviews(items: Product[]): void {\n for (const item of items) rememberProductPreview(item);\n}\n\n/**\n * Search sends its words as `keyword` (a `sourceValue` string is still read there, as before);\n * every other source sends its ids as `source_value[]`, which the API requires as an array.\n */\nfunction appendSourceParams(\n searchParams: URLSearchParams,\n { source, sourceValue, keyword }: Pick<ProductsListParams, 'source' | 'sourceValue' | 'keyword'>\n): void {\n if (source === 'search') {\n const words = keyword ?? sourceValue;\n if (words !== undefined) searchParams.set('keyword', String(words));\n } else if (Array.isArray(sourceValue)) {\n sourceValue.forEach((val) => searchParams.append('source_value[]', String(val)));\n } else if (sourceValue !== undefined) {\n searchParams.append('source_value[]', String(sourceValue));\n }\n}\n\n/**\n * Sends an applied filter selection the way the SDK's `<salla-products-list>` does:\n * `filters[key]=v`, `filters[key][]=v` or `filters[key][sub]=v`.\n */\nfunction appendFilterParams(\n searchParams: URLSearchParams,\n filters?: Record<string, ProductListFilterValue>,\n parentKey = 'filters'\n): void {\n if (!filters) return;\n for (const [key, value] of Object.entries(filters)) {\n const fullKey = `${parentKey}[${key}]`;\n if (Array.isArray(value)) {\n value.forEach((item) => searchParams.append(`${fullKey}[]`, String(item)));\n } else if (value !== null && typeof value === 'object') {\n appendFilterParams(searchParams, value, fullKey);\n } else if (value !== undefined && value !== null) {\n searchParams.append(fullKey, String(value));\n }\n }\n}\n\n/** A `category_id` filter replaces the page's category as the list source (as in the SDK). */\n// The API sends these four filter titles in Arabic whatever the language (the values are\n// translated). Twig's `<salla-filters>` swaps them for its own translations when the list\n// reaches it through `filters::fetched`; a list handed over as data, the loader's or a\n// theme's own query, is swapped here instead, with the keys the component uses.\nconst FILTER_TITLES: Record<string, [key: string, fallback: string]> = {\n category_id: ['common.titles.categories', 'Categories'],\n brand_id: ['common.titles.brands', 'Brands'],\n price: ['pages.categories.filter_price', 'Price'],\n rating: ['pages.categories.filter_rating', 'Rating'],\n};\n\nfunction titledFilters(filters?: Filter[]): Filter[] | undefined {\n const t = getTwilightContext().i18n?.t;\n if (!filters || !t) return filters;\n return filters.map((filter) => {\n const title = filter.key && FILTER_TITLES[filter.key];\n return title ? { ...filter, label: t(title[0], title[1]) } : filter;\n });\n}\n\nfunction categoryFilterIds(filters?: ProductListFilters): number[] | null {\n const raw = filters?.category_id;\n if (raw === undefined || raw === null) return null;\n const ids = Array.isArray(raw) ? raw : typeof raw === 'object' ? Object.values(raw) : [raw];\n return ids.map(Number);\n}\n\n// ===== Pagination =====\n\n/**\n * The API's own `cursor.next` (the previous page's response) is usually a\n * bare opaque cursor token, but for sources that don't support true\n * cursor-based pagination (observed: `source=offers`) it's instead a full\n * next-page URL carrying its own `page=N` — and no `cursor=` param at all.\n *\n * Passing that whole URL straight through as `list()`'s own `cursor` used to\n * smuggle its embedded `source` / `per_page` / `sort` into the request on\n * top of the ones `list()` already sets unconditionally, producing a\n * doubled query string (`source=offers&source=offers&...`) the API can't\n * paginate from correctly — every subsequent scroll re-fetched the exact\n * same first page instead of advancing. Pulling just the `page` number back\n * out here, the same way an actual `cursor=` is already pulled out, keeps\n * `list()`'s request to the one copy of each param it's supposed to have.\n */\nexport function parseNextPageToken(nextUrl: string | null | undefined): {\n cursor?: string;\n page?: number;\n} {\n if (!nextUrl) return {};\n\n const cursorMatch = nextUrl.match(/[?&]cursor=([^&]+)/);\n if (cursorMatch) return { cursor: decodeURIComponent(cursorMatch[1]) };\n\n const pageMatch = nextUrl.match(/[?&]page=([^&]+)/);\n if (pageMatch) {\n const page = Number(decodeURIComponent(pageMatch[1]));\n if (Number.isFinite(page)) return { page };\n }\n\n // Neither pattern matched: not a URL at all, just the bare opaque token itself.\n return { cursor: nextUrl };\n}\n\n// ===== API Functions =====\n\nexport const product = {\n find: async (id: string): Promise<Product> => {\n const endpoint = `products/${id}/details?with[]=images&with[]=category&with[]=rating&with[]=notify_availability&with[]=tags&with[]=brand&with[]=options&with[]=skus&with[]=skus_availability&with[]=included_products&with[]=bundle&with[]=sold_quantity`;\n const { data } = await api.get(endpoint).json<{ data: Product }>();\n return data;\n },\n\n findOrThrow: (id: string): Promise<Product> => orThrow(product.find(id)),\n\n /** A tag's name. The list endpoint returns every product for an unknown tag; this one answers 410. */\n tag: async (id: string): Promise<{ id: number; name: string }> => {\n const { tag } = await api\n .get(`products/tags/${id}`)\n .json<{ tag: { id: number; name: string } }>();\n return tag;\n },\n\n /**\n * Fetch products list with pagination support\n * Used by native ProductsList component for SSR loaders\n *\n * API pattern: GET /products?source=wishlist&page=1\n */\n list: async (params: ProductsListParams): Promise<ProductsListResult> => {\n const {\n source,\n sourceValue,\n keyword,\n page,\n cursor,\n perPage = 16,\n sort,\n filterable,\n filters,\n signal,\n } = params;\n\n // Build URL with query parameters\n const searchParams = new URLSearchParams();\n searchParams.set('source', source);\n // Only send page when explicitly provided — cursor-based callers omit it entirely\n if (page !== undefined) searchParams.set('page', String(page));\n searchParams.set('per_page', String(perPage));\n\n appendSourceParams(searchParams, {\n source,\n sourceValue: (source === 'categories' && categoryFilterIds(filters)) || sourceValue,\n keyword,\n });\n appendFilterParams(searchParams, filters);\n\n // Add filterable parameter\n if (filterable !== undefined) {\n searchParams.set('filterable', filterable ? '1' : '0');\n }\n\n // Add sort parameter\n if (sort) {\n searchParams.set('sort', sort);\n }\n\n // Add cursor for cursor-based pagination\n if (cursor) {\n searchParams.set('cursor', cursor);\n }\n\n // Make the request\n const options: Record<string, unknown> = {};\n if (signal) options.signal = signal;\n\n const response = await api\n .get(`products?${searchParams.toString()}`, options as any)\n .json<ProductsListResponse>();\n\n const items = response.data ?? [];\n rememberProductPreviews(items);\n\n return {\n items,\n next: response.cursor?.next ?? null,\n filters: titledFilters(response.filters),\n };\n },\n\n queries: {\n detail: (id: string) =>\n queryOptions({\n // Stock and availability are resolved per branch allocation — same as the list.\n queryKey: productDetailQueryKey(id),\n queryFn: () => product.find(id),\n // List-card product, if one was remembered. Not written as the detail\n // cache entry — `queryFn` still hits products/{id}/details.\n placeholderData: () => getProductPreview(id),\n }),\n tag: (id: string) =>\n queryOptions({\n queryKey: ['products', 'tag', id],\n queryFn: () => product.tag(id),\n }),\n list: (params: Omit<ProductsListParams, 'signal'>) =>\n queryOptions({\n // Scope (branch) varies product availability, and the locale the names and the\n // filter titles (a same-store link can switch language without a page load) — the\n // key must include both.\n queryKey: [\n 'products',\n 'list',\n params,\n { scope: getActiveScope(), locale: getTwilightContext().locale },\n ],\n queryFn: ({ signal }) => product.list({ ...params, signal }),\n }),\n },\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/api/product.ts"],"names":["product"],"mappings":";;;;;AA+FA,SAAS,iBAAA,GAAoB;AAC3B,EAAA,IAAI;AACF,IAAA,MAAM,WAAA,GAAc,oBAAmB,CAAE,WAAA;AACzC,IAAA,OAAO,WAAA,IAAe,OAAO,WAAA,CAAY,YAAA,KAAiB,aAAa,WAAA,GAAc,IAAA;AAAA,EACvF,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAEO,SAAS,uBAAuB,EAAA,EAAY;AACjD,EAAA,OAAO,CAAC,UAAA,EAAY,SAAA,EAAW,MAAA,CAAO,EAAE,GAAG,EAAE,KAAA,EAAO,cAAA,EAAe,EAAG,CAAA;AACxE;AAEO,SAAS,sBAAsB,EAAA,EAAY;AAChD,EAAA,OAAO,CAAC,YAAY,QAAA,EAAU,EAAA,EAAI,EAAE,KAAA,EAAO,cAAA,IAAkB,CAAA;AAC/D;AAGO,SAAS,sBAAsB,KAAA,EAAkD;AACtF,EAAA,OAAO,KAAA,CAAM,SAAS,CAAC,CAAA,KAAM,cAAc,KAAA,CAAM,QAAA,CAAS,CAAC,CAAA,KAAM,SAAA;AACnE;AAMO,SAAS,qBACd,KAAA,EACS;AACT,EAAA,OACE,CAAC,sBAAsB,KAAK,CAAA,KAC3B,4BAA4B,KAAK,CAAA,IAAK,KAAA,CAAM,KAAA,CAAM,MAAA,KAAW,SAAA,CAAA;AAElE;AAOO,SAAS,uBAAuBA,QAAAA,EAAwB;AAC7D,EAAA,MAAM,cAAc,iBAAA,EAAkB;AACtC,EAAA,IAAI,CAAC,WAAA,IAAeA,QAAAA,EAAS,EAAA,IAAM,IAAA,EAAM;AACzC,EAAA,MAAM,E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AAA,MAC/B,OAAA,EAAS,aAAA,CAAc,QAAA,CAAS,OAAO;AAAA,KACzC;AAAA,EACF,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,MAAA,EAAQ,CAAC,EAAA,KACP,YAAA,CAAa;AAAA;AAAA,MAEX,QAAA,EAAU,sBAAsB,EAAE,CAAA;AAAA,MAClC,OAAA,EAAS,MAAM,OAAA,CAAQ,IAAA,CAAK,EAAE,CAAA;AAAA;AAAA;AAAA,MAG9B,eAAA,EAAiB,MAAM,iBAAA,CAAkB,EAAE;AAAA,KAC5C,CAAA;AAAA,IACH,GAAA,EAAK,CAAC,EAAA,KACJ,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,UAAA,EAAY,KAAA,EAAO,EAAE,CAAA;AAAA,MAChC,OAAA,EAAS,MAAM,OAAA,CAAQ,GAAA,CAAI,EAAE;AAAA,KAC9B,CAAA;AAAA,IACH,IAAA,EAAM,CAAC,MAAA,KACL,YAAA,CAAa;AAAA;AAAA;AAAA;AAAA,MAIX,QAAA,EAAU;AAAA,QACR,UAAA;AAAA,QACA,MAAA;AAAA,QACA,MAAA;AAAA,QACA,EAAE,KAAA,EAAO,cAAA,IAAkB,MAAA,EAAQ,kBAAA,GAAqB,MAAA;AAAO,OACjE;AAAA,MACA,OAAA,EAAS,CAAC,EAAE,MAAA,EAAO,KAAM,OAAA,CAAQ,IAAA,CAAK,EAAE,GAAG,MAAA,EAAQ,MAAA,EAAQ;AAAA,KAC5D;AAAA;AAEP","file":"chunk-7PFJOTZS.js","sourcesContent":["import { queryOptions, defaultShouldDehydrateQuery } from '@tanstack/react-query';\nimport { api, getActiveScope } from './client';\nimport type { Product } from '../types';\nimport type { Pagination, PaginatedResult } from './types';\nimport { orThrow } from '../providers/NavigationProvider';\nimport { getTwilightContext } from '../twilight/context';\nimport type { ActiveScope } from '../utils/cookies';\n\n// ===== Filter Types =====\n\nexport interface FilterValue {\n key?: string;\n count?: number;\n value?: string;\n from?: number | '*';\n to?: number | '*';\n}\n\nexport interface Filter {\n key?: string;\n label?: string;\n type?: string;\n values?: FilterValue[];\n max?: number;\n min?: number;\n}\n\n// ===== Product List Types =====\n\nexport type ProductsListSource =\n | 'brands'\n | 'categories'\n | 'json'\n | 'landing-page'\n | 'latest'\n | 'offers'\n | 'recently'\n | 'related'\n | 'selected'\n | 'tags'\n | 'top-rated'\n | 'wishlist'\n | 'search'\n | 'sales'\n | 'reorder'\n | 'best_selling';\n\nexport interface ProductsListParams {\n /** Source type (wishlist, latest, brands, etc.) */\n source: ProductsListSource;\n /**\n * The ids the source reads, as an array: category, brand, tag or product ids\n * (`sourceValue: [708738657]`). Sent as `source_value[]`.\n */\n sourceValue?: string | number | number[] | null;\n /** The search words when `source` is `'search'`. Sent as `keyword`; other sources ignore it. */\n keyword?: string;\n /** Page number for offset-based pagination */\n page?: number;\n /** Cursor for cursor-based pagination (from previous response) */\n cursor?: string | null;\n /** Items per page (default: 15) */\n perPage?: number;\n /** Sort option */\n sort?: string;\n /** Enable filters on the response */\n filterable?: boolean;\n /** Applied `<salla-filters>` selection (the `salla-filters::changed` payload). */\n filters?: ProductListFilters;\n /** Abort signal for cancellation */\n signal?: AbortSignal;\n}\n\n/** One `<salla-filters>` value: a scalar, a list, or a nested `{ sub-key: value }` (variants). */\nexport type ProductListFilterValue =\n string | number | Array<string | number> | { [key: string]: ProductListFilterValue };\n\n/** A `<salla-filters>` selection, i.e. the `salla-filters::changed` payload. */\nexport type ProductListFilters = Record<string, ProductListFilterValue>;\n\nexport type ProductsListResult = PaginatedResult<Product> & {\n filters?: Filter[];\n};\n\nexport interface ProductsListResponse {\n data: Product[];\n cursor?: Pagination;\n filters?: Filter[];\n}\n\n// ===== List-card preview cache =====\n// List payloads are a subset of details (one `image`, no `options` / `images[]`).\n// They live on a separate query key so they can paint a sheet/quick-view without\n// being treated as a successful `products/{id}/details` fetch.\n\nfunction queryClientOrNull() {\n try {\n const queryClient = getTwilightContext().queryClient;\n return queryClient && typeof queryClient.setQueryData === 'function' ? queryClient : null;\n } catch {\n return null;\n }\n}\n\nexport function productPreviewQueryKey(id: string) {\n return ['products', 'preview', String(id), { scope: getActiveScope() }] as const;\n}\n\nexport function productDetailQueryKey(id: string) {\n return ['products', 'detail', id, { scope: getActiveScope() }] as const;\n}\n\n/** True when this query is a list-card stand-in — skip it when dehydrating SSR. */\nexport function isProductPreviewQuery(query: { queryKey: readonly unknown[] }): boolean {\n return query.queryKey[0] === 'products' && query.queryKey[1] === 'preview';\n}\n\n/**\n * Default dehydrate policy (success) plus pending SSR-stream queries, minus\n * list-card stand-ins. Replacing the default wholesale would ship error states.\n */\nexport function shouldDehydrateQuery(\n query: Parameters<typeof defaultShouldDehydrateQuery>[0]\n): boolean {\n return (\n !isProductPreviewQuery(query) &&\n (defaultShouldDehydrateQuery(query) || query.state.status === 'pending')\n );\n}\n\n/**\n * Remember a list/card product so `product.queries.detail(id)` can use it as\n * `placeholderData` while details load. No-op if details for this id are already\n * cached. Themes that fetch products outside `product.list` should call this.\n */\nexport function rememberProductPreview(product: Product): void {\n const queryClient = queryClientOrNull();\n if (!queryClient || product?.id == null) return;\n const id = String(product.id);\n if (queryClient.getQueryState(productDetailQueryKey(id))?.status === 'success') return;\n queryClient.setQueryData(productPreviewQueryKey(id), product);\n}\n\nfunction scopeFromQueryKey(queryKey: readonly unknown[]): ActiveScope | null | undefined {\n const last = queryKey[queryKey.length - 1];\n if (last == null || typeof last !== 'object' || !('scope' in last)) return undefined;\n return (last as { scope: ActiveScope | null }).scope;\n}\n\nfunction isSameScope(a: ActiveScope | null | undefined, b: ActiveScope | null): boolean {\n if (a === undefined) return false;\n if (a === b) return true;\n if (a == null || b == null) return a == null && b == null;\n return (\n a.id === b.id &&\n a.type === b.type &&\n a.allocation_id === b.allocation_id &&\n a.allocation_type === b.allocation_type\n );\n}\n\nconst LIST_QUERY_PREFIXES = [\n ['products', 'list'],\n ['wishlist', 'list'],\n] as const;\n\n/**\n * Rebuild the scoped preview index from hydrated list/wishlist queries (SSR\n * dehydrate drops preview keys). Subsequent lookups hit `productPreviewQueryKey`.\n */\nfunction findProductInScopedLists(\n queryClient: NonNullable<ReturnType<typeof queryClientOrNull>>,\n id: string\n): Product | undefined {\n const scope = getActiveScope();\n let found: Product | undefined;\n for (const prefix of LIST_QUERY_PREFIXES) {\n for (const [queryKey, data] of queryClient.getQueriesData<ProductsListResult>({\n queryKey: prefix,\n })) {\n if (!isSameScope(scopeFromQueryKey(queryKey), scope)) continue;\n for (const item of data?.items ?? []) {\n if (item?.id == null) continue;\n rememberProductPreview(item);\n if (!found && String(item.id) === id) found = item;\n }\n }\n }\n return found;\n}\n\n/**\n * List-card product for `placeholderData`. Prefers the preview key; if that was\n * dropped on SSR dehydrate, rebuilds it from the current-scope list/wishlist.\n */\nexport function getProductPreview(id: string): Product | undefined {\n const queryClient = queryClientOrNull();\n if (!queryClient) return undefined;\n const key = String(id);\n return (\n queryClient.getQueryData(productPreviewQueryKey(key)) ??\n findProductInScopedLists(queryClient, key)\n );\n}\n\nfunction rememberProductPreviews(items: Product[]): void {\n for (const item of items) rememberProductPreview(item);\n}\n\n/**\n * Search sends its words as `keyword` (a `sourceValue` string is still read there, as before);\n * every other source sends its ids as `source_value[]`, which the API requires as an array.\n */\nfunction appendSourceParams(\n searchParams: URLSearchParams,\n { source, sourceValue, keyword }: Pick<ProductsListParams, 'source' | 'sourceValue' | 'keyword'>\n): void {\n if (source === 'search') {\n const words = keyword ?? sourceValue;\n if (words !== undefined) searchParams.set('keyword', String(words));\n } else if (Array.isArray(sourceValue)) {\n sourceValue.forEach((val) => searchParams.append('source_value[]', String(val)));\n } else if (sourceValue !== undefined) {\n searchParams.append('source_value[]', String(sourceValue));\n }\n}\n\n/**\n * Sends an applied filter selection the way the SDK's `<salla-products-list>` does:\n * `filters[key]=v`, `filters[key][]=v` or `filters[key][sub]=v`.\n */\nfunction appendFilterParams(\n searchParams: URLSearchParams,\n filters?: Record<string, ProductListFilterValue>,\n parentKey = 'filters'\n): void {\n if (!filters) return;\n for (const [key, value] of Object.entries(filters)) {\n const fullKey = `${parentKey}[${key}]`;\n if (Array.isArray(value)) {\n value.forEach((item) => searchParams.append(`${fullKey}[]`, String(item)));\n } else if (value !== null && typeof value === 'object') {\n appendFilterParams(searchParams, value, fullKey);\n } else if (value !== undefined && value !== null) {\n searchParams.append(fullKey, String(value));\n }\n }\n}\n\n/** A `category_id` filter replaces the page's category as the list source (as in the SDK). */\n// The API sends these four filter titles in Arabic whatever the language (the values are\n// translated). Twig's `<salla-filters>` swaps them for its own translations when the list\n// reaches it through `filters::fetched`; a list handed over as data, the loader's or a\n// theme's own query, is swapped here instead, with the keys the component uses.\nconst FILTER_TITLES: Record<string, [key: string, fallback: string]> = {\n category_id: ['common.titles.categories', 'Categories'],\n brand_id: ['common.titles.brands', 'Brands'],\n price: ['pages.categories.filter_price', 'Price'],\n rating: ['pages.categories.filter_rating', 'Rating'],\n};\n\nfunction titledFilters(filters?: Filter[]): Filter[] | undefined {\n const t = getTwilightContext().i18n?.t;\n if (!filters || !t) return filters;\n return filters.map((filter) => {\n const title = filter.key && FILTER_TITLES[filter.key];\n return title ? { ...filter, label: t(title[0], title[1]) } : filter;\n });\n}\n\nfunction categoryFilterIds(filters?: ProductListFilters): number[] | null {\n const raw = filters?.category_id;\n if (raw === undefined || raw === null) return null;\n const ids = Array.isArray(raw) ? raw : typeof raw === 'object' ? Object.values(raw) : [raw];\n return ids.map(Number);\n}\n\n// ===== Pagination =====\n\n/**\n * The API's own `cursor.next` (the previous page's response) is usually a\n * bare opaque cursor token, but for sources that don't support true\n * cursor-based pagination (observed: `source=offers`) it's instead a full\n * next-page URL carrying its own `page=N` — and no `cursor=` param at all.\n *\n * Passing that whole URL straight through as `list()`'s own `cursor` used to\n * smuggle its embedded `source` / `per_page` / `sort` into the request on\n * top of the ones `list()` already sets unconditionally, producing a\n * doubled query string (`source=offers&source=offers&...`) the API can't\n * paginate from correctly — every subsequent scroll re-fetched the exact\n * same first page instead of advancing. Pulling just the `page` number back\n * out here, the same way an actual `cursor=` is already pulled out, keeps\n * `list()`'s request to the one copy of each param it's supposed to have.\n */\nexport function parseNextPageToken(nextUrl: string | null | undefined): {\n cursor?: string;\n page?: number;\n} {\n if (!nextUrl) return {};\n\n const cursorMatch = nextUrl.match(/[?&]cursor=([^&]+)/);\n if (cursorMatch) return { cursor: decodeURIComponent(cursorMatch[1]) };\n\n const pageMatch = nextUrl.match(/[?&]page=([^&]+)/);\n if (pageMatch) {\n const page = Number(decodeURIComponent(pageMatch[1]));\n if (Number.isFinite(page)) return { page };\n }\n\n // Neither pattern matched: not a URL at all, just the bare opaque token itself.\n return { cursor: nextUrl };\n}\n\n// ===== API Functions =====\n\nexport const product = {\n find: async (id: string): Promise<Product> => {\n const endpoint = `products/${id}/details?with[]=images&with[]=category&with[]=rating&with[]=notify_availability&with[]=tags&with[]=brand&with[]=options&with[]=skus&with[]=skus_availability&with[]=included_products&with[]=bundle&with[]=sold_quantity`;\n const { data } = await api.get(endpoint).json<{ data: Product }>();\n return data;\n },\n\n findOrThrow: (id: string): Promise<Product> => orThrow(product.find(id)),\n\n /** A tag's name. The list endpoint returns every product for an unknown tag; this one answers 410. */\n tag: async (id: string): Promise<{ id: number; name: string }> => {\n const { tag } = await api\n .get(`products/tags/${id}`)\n .json<{ tag: { id: number; name: string } }>();\n return tag;\n },\n\n /**\n * Fetch products list with pagination support\n * Used by native ProductsList component for SSR loaders\n *\n * API pattern: GET /products?source=wishlist&page=1\n */\n list: async (params: ProductsListParams): Promise<ProductsListResult> => {\n const {\n source,\n sourceValue,\n keyword,\n page,\n cursor,\n perPage = 16,\n sort,\n filterable,\n filters,\n signal,\n } = params;\n\n // Build URL with query parameters\n const searchParams = new URLSearchParams();\n searchParams.set('source', source);\n // Only send page when explicitly provided — cursor-based callers omit it entirely\n if (page !== undefined) searchParams.set('page', String(page));\n searchParams.set('per_page', String(perPage));\n\n appendSourceParams(searchParams, {\n source,\n sourceValue: (source === 'categories' && categoryFilterIds(filters)) || sourceValue,\n keyword,\n });\n appendFilterParams(searchParams, filters);\n\n // Add filterable parameter\n if (filterable !== undefined) {\n searchParams.set('filterable', filterable ? '1' : '0');\n }\n\n // Add sort parameter\n if (sort) {\n searchParams.set('sort', sort);\n }\n\n // Add cursor for cursor-based pagination\n if (cursor) {\n searchParams.set('cursor', cursor);\n }\n\n // Make the request\n const options: Record<string, unknown> = {};\n if (signal) options.signal = signal;\n\n const response = await api\n .get(`products?${searchParams.toString()}`, options as any)\n .json<ProductsListResponse>();\n\n const items = response.data ?? [];\n rememberProductPreviews(items);\n\n return {\n items,\n next: response.cursor?.next ?? null,\n filters: titledFilters(response.filters),\n };\n },\n\n queries: {\n detail: (id: string) =>\n queryOptions({\n // Stock and availability are resolved per branch allocation — same as the list.\n queryKey: productDetailQueryKey(id),\n queryFn: () => product.find(id),\n // List-card product, if one was remembered. Not written as the detail\n // cache entry — `queryFn` still hits products/{id}/details.\n placeholderData: () => getProductPreview(id),\n }),\n tag: (id: string) =>\n queryOptions({\n queryKey: ['products', 'tag', id],\n queryFn: () => product.tag(id),\n }),\n list: (params: Omit<ProductsListParams, 'signal'>) =>\n queryOptions({\n // Scope (branch) varies product availability, and the locale the names and the\n // filter titles (a same-store link can switch language without a page load) — the\n // key must include both.\n queryKey: [\n 'products',\n 'list',\n params,\n { scope: getActiveScope(), locale: getTwilightContext().locale },\n ],\n queryFn: ({ signal }) => product.list({ ...params, signal }),\n }),\n },\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { configureNavigation, UnauthorizedError, NavigationProvider, resolveRelativePath } from './chunk-
|
|
1
|
+
import { configureNavigation, UnauthorizedError, NavigationProvider, resolveRelativePath } from './chunk-SOLUKKTW.js';
|
|
2
2
|
import { LinkProvider } from './chunk-BYMOPN2S.js';
|
|
3
3
|
import { useIsNativeApp } from './chunk-3E3ABCPC.js';
|
|
4
4
|
import { onSallaEvent } from './chunk-NHA4SBKG.js';
|
|
@@ -34,6 +34,13 @@ var TanStackLinkAdapter = forwardRef(
|
|
|
34
34
|
}, ref) => {
|
|
35
35
|
const { locale } = useParams({ strict: false });
|
|
36
36
|
const destination = localizeDestination(to ?? href ?? "/", locale);
|
|
37
|
+
if (destination === "#") {
|
|
38
|
+
return createElement(
|
|
39
|
+
"a",
|
|
40
|
+
{ ref, className, style, title, onClick, "aria-label": ariaLabel, ...rest },
|
|
41
|
+
children
|
|
42
|
+
);
|
|
43
|
+
}
|
|
37
44
|
return createElement(
|
|
38
45
|
Link,
|
|
39
46
|
{
|
|
@@ -188,5 +195,5 @@ function TanStackNavigationProvider({ children }) {
|
|
|
188
195
|
}
|
|
189
196
|
|
|
190
197
|
export { NavigationSetup, TanStackLinkAdapter, TanStackNavigationProvider, createTanStackLinkAdapter, requestHostOf };
|
|
191
|
-
//# sourceMappingURL=chunk-
|
|
192
|
-
//# sourceMappingURL=chunk-
|
|
198
|
+
//# sourceMappingURL=chunk-ABVHWJPY.js.map
|
|
199
|
+
//# sourceMappingURL=chunk-ABVHWJPY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/tanstack/link.tsx","../src/tanstack/native-app-events.tsx","../src/utils/request-host.ts","../src/tanstack/navigation.tsx"],"names":["TanStackLink","tanstackNotFound","tanstackRedirect","useParams","jsx"],"mappings":";;;;;;;;;;;;AAWO,SAAS,mBAAA,CAAoB,aAAqB,MAAA,EAAiB;AACxE,EAAA,IAAI,CAAC,MAAA,IAAU,CAAC,WAAA,CAAY,UAAA,CAAW,GAAG,CAAA,IAAK,WAAA,CAAY,UAAA,CAAW,IAAI,CAAA,EAAG,OAAO,WAAA;AACpF,EAAA,MAAM,YAAA,GAAe,WAAA,CAAY,KAAA,CAAM,GAAG,CAAA,CAAE,CAAC,CAAA,EAAG,KAAA,CAAM,MAAM,CAAA,CAAE,CAAC,CAAA;AAC/D,EAAA,IAAI,QAAA,CAAS,YAAY,CAAA,EAAG,OAAO,WAAA;AACnC,EAAA,OAAO,WAAA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D;AAEJ","file":"chunk-ABVHWJPY.js","sourcesContent":["import { forwardRef, createElement } from 'react';\nimport { Link as TanStackLink, useParams } from '@tanstack/react-router';\nimport { isLocale } from '../providers/locale-constants';\nimport type { BaseLinkProps } from '../components/common/Link.types';\n\n/**\n * Routes live under an optional `/{-$locale}` param, so a bare `to=\"/brands\"`\n * resolves with the locale omitted and the $locale loader bounces the user to\n * the fallback locale. Prefix the current locale onto internal paths that\n * don't already carry one.\n */\nexport function localizeDestination(destination: string, locale?: string) {\n if (!locale || !destination.startsWith('/') || destination.startsWith('//')) return destination;\n const firstSegment = destination.split('/')[1]?.split(/[?#]/)[0];\n if (isLocale(firstSegment)) return destination;\n return destination === '/' ? `/${locale}` : `/${locale}${destination}`;\n}\n\n/**\n * TanStack Router Link adapter.\n * Translates framework-agnostic props to TanStack Router Link props.\n */\nexport const TanStackLinkAdapter = forwardRef<HTMLAnchorElement, BaseLinkProps>(\n (\n {\n to,\n href,\n children,\n className,\n style,\n title,\n target,\n rel,\n onClick,\n preload,\n replace,\n 'aria-label': ariaLabel,\n ...rest\n },\n ref\n ) => {\n const { locale } = useParams({ strict: false }) as { locale?: string };\n const destination = localizeDestination(to ?? href ?? '/', locale);\n\n // `#` is how a block says it has nowhere to go, such as a banner with no URL. An anchor with\n // no href keeps the theme's `a` styles, and the router can neither preload nor follow it.\n if (destination === '#') {\n return createElement(\n 'a',\n { ref, className, style, title, onClick, 'aria-label': ariaLabel, ...rest },\n children\n );\n }\n\n return createElement(\n TanStackLink,\n {\n ref,\n to: destination,\n className,\n style,\n title,\n target,\n rel,\n onClick,\n preload: preload === 'intent' || preload === false ? preload : undefined,\n replace,\n 'aria-label': ariaLabel,\n ...(rest as Record<string, unknown>),\n },\n children\n );\n }\n);\n\nTanStackLinkAdapter.displayName = 'TanStackLinkAdapter';\n\n/**\n * Create a TanStack Router Link adapter component.\n */\nexport function createTanStackLinkAdapter() {\n return TanStackLinkAdapter;\n}\n","import { useEffect } from 'react';\nimport { useRouter } from '@tanstack/react-router';\nimport { resolveRelativePath } from '../providers/NavigationProvider';\nimport { useTwilight } from '../providers/twilight-context';\nimport { isLocale } from '../providers/locale-constants';\nimport { getTwilightContext } from '../twilight/context';\nimport { useIsNativeApp } from '../native-app';\nimport { onSallaEvent } from '../utils/sdk-helpers';\nimport { hasStoreUrlBase } from '../utils/store-base';\nimport { localizeDestination } from './link';\n\nconst UI_UPDATE_EVENT = 'mobile::ui.update';\nconst OPEN_ORDER_EVENT = 'mobile::open.order';\nconst NAVIGATE_TO_EVENT = 'mobile::navigate.to';\n\n/**\n * Events the native app sends into its webview. `NavigationSetup` mounts this once, so a\n * theme adds no listener of its own:\n *\n * - `mobile::ui.update` re-runs the route loaders and refetches what is on screen.\n * - `mobile::open.order` `{ id }` opens that order, with a fresh cart.\n * - `mobile::navigate.to` `{ url }` opens a notification deep link in-app. Only a link to\n * this store is followed (`deepLinkPath`), so `javascript:`, off-site and other stores'\n * URLs are dropped.\n *\n * Nothing is mounted outside the app (`useIsNativeApp()`), so a browser runs none of it.\n */\nexport function NativeAppEvents({ locale }: { locale?: string }) {\n return useIsNativeApp() ? <Listeners locale={locale} /> : null;\n}\n\nfunction Listeners({ locale }: { locale?: string }) {\n useNativeAppEvents(locale);\n return null;\n}\n\n/** The listeners themselves. `NativeAppEvents` mounts them inside the app only. */\nexport function useNativeAppEvents(locale?: string): void {\n const router = useRouter();\n const { store } = useTwilight();\n const storeUrl = store?.url;\n const username = store?.username;\n\n useEffect(() => {\n // `href`, not `to`: the router parses the query and the hash out of it.\n const open = (path: string) =>\n void router.navigate({ href: localizeDestination(path, locale) });\n\n const refresh = () => {\n void Promise.allSettled([\n router.invalidate(),\n getTwilightContext().queryClient?.refetchQueries({ type: 'active' }),\n ]);\n };\n const openOrder = (data?: unknown) => {\n const rawId = (data as { id?: unknown } | undefined)?.id;\n if (typeof rawId !== 'string' && typeof rawId !== 'number') return;\n\n const id = String(rawId).trim();\n if (!id) return;\n\n void getTwilightContext().queryClient?.invalidateQueries({ queryKey: ['cart'] });\n open(`/account/orders/${encodeURIComponent(id)}`);\n };\n const navigateTo = (data?: unknown) => {\n const url = (data as { url?: unknown } | undefined)?.url;\n if (typeof url !== 'string' || !url.trim() || !storeUrl) return;\n\n const path = deepLinkPath(url.trim(), storeUrl, username);\n if (path) void router.navigate({ href: inLocale(path, locale) });\n };\n\n const offs = [\n onSallaEvent(UI_UPDATE_EVENT, refresh),\n onSallaEvent(OPEN_ORDER_EVENT, openOrder),\n onSallaEvent(NAVIGATE_TO_EVENT, navigateTo),\n ];\n return () => offs.forEach((off) => off());\n }, [router, locale, storeUrl, username]);\n}\n\n/** A URL that names its host: `https://…` or `//…`. Anything else is a path of this app. */\nfunction isAbsoluteUrl(url: string): boolean {\n if (url.startsWith('//')) return true;\n try {\n // Without a base, only a URL with its own scheme parses.\n new URL(url);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * The application path of a deep link to this store, or null for any other link.\n *\n * It passes the test a tapped link does (`resolveRelativePath`: the store's origin, the\n * username taken off), and one more. On a shared host that origin is every store's, so\n * an absolute link has to carry this store's username: without it, another store's\n * `/ar/offers` would open this store's offers.\n */\nfunction deepLinkPath(url: string, storeUrl: string, username?: string): string | null {\n const path = resolveRelativePath(url, storeUrl, username);\n if (!path || !isAbsoluteUrl(url)) return path;\n\n // Both parse: `resolveRelativePath` returns null when either does not.\n const { pathname } = new URL(url, window.location.href);\n return hasStoreUrlBase(pathname, new URL(storeUrl).pathname, username) ? path : null;\n}\n\n/**\n * A deep link in the locale the visitor is browsing in. A notification is written in one\n * language and opened in whichever is on screen, so the link's own locale gives way.\n *\n * The prefix is written here, not by `localizeDestination`: that one leaves a path alone\n * when it already starts with a locale, and would take the slug of `/ar/en/p456` for one.\n */\nfunction inLocale(path: string, locale?: string): string {\n const first = path.split('/')[1]?.split(/[?#]/)[0];\n const own = isLocale(first) ? path.slice(first.length + 1) : path;\n const rest = own.startsWith('/') ? own : `/${own}`;\n\n if (!locale) return rest;\n return rest === '/' ? `/${locale}` : `/${locale}${rest}`;\n}\n","/**\n * What the request itself is enough to describe: its host.\n *\n * Small, and deliberately its own module rather than a helper inside the\n * middleware. This value decides two things — which store a live storefront is,\n * and whether the request is allowed to name a store at all — so it is worth\n * testing directly instead of only through the wiring that calls it.\n */\nimport { isLoopback } from './cookies';\n\n/** The part of a `Request` this needs, so a test does not have to build a whole one. */\nexport interface HostSource {\n url: string;\n headers: { get(name: string): string | null };\n}\n\n/**\n * The host this request arrived on, with its port when it has one.\n *\n * Taken from the request URL, which in a Worker is the address the platform\n * actually routed on, and from the `Host` header only when that fails.\n *\n * **`X-Forwarded-Host` is deliberately not consulted.** A client can set it, and\n * this value gates `allowsRequestStoreId` — so honouring it would be a way to\n * talk a merchant's own domain into behaving like the preview host, and from\n * there into serving a stranger's shop. The dispatcher strips that header today;\n * a theme must not be one edit to another repository's allowlist away from a\n * spoofable identity.\n */\nexport function requestHostOf(request: HostSource): string | null {\n try {\n const fromUrl = new URL(request.url).host;\n if (fromUrl) return fromUrl;\n } catch {\n /* an unparseable URL falls through to the header */\n }\n\n return request.headers.get('Host')?.trim() || null;\n}\n\n/** The origin a browser reached this host on: `http` for a dev server, `https` otherwise. */\nexport function requestOriginOf(host: string): string {\n return `${isLoopback(host.replace(/:\\d+$/, '')) ? 'http' : 'https'}://${host}`;\n}\n","import {\n useNavigate,\n useParams,\n redirect as tanstackRedirect,\n notFound as tanstackNotFound,\n} from '@tanstack/react-router';\nimport {\n NavigationProvider,\n configureNavigation,\n type NavigateOptions,\n} from '../providers/NavigationProvider';\nimport { LinkProvider } from '../providers/LinkProvider';\nimport { TanStackLinkAdapter, localizeDestination } from './link';\nimport { NativeAppEvents } from './native-app-events';\nimport { useCallback, type ReactNode } from 'react';\nimport { UnauthorizedError, type RedirectOptions } from '../providers/NavigationProvider';\nimport { getRequestStore, getTwilightContext } from '../twilight/context';\nimport { resolveStoreBase, resolveStoreBaseFollowsLocale } from '../utils/store-identity';\nimport { loginRedirectHref } from '../utils/store-base';\nimport { requestOriginOf } from '../utils/request-host';\n\nfunction currentOrigin(): string | null {\n if (typeof window !== 'undefined') return window.location.origin;\n const host = getRequestStore().requestHost;\n return host ? requestOriginOf(host) : null;\n}\n\nconfigureNavigation({\n notFound: (message?: string) => {\n throw tanstackNotFound({ data: message });\n },\n redirect: (path: string, opts?: RedirectOptions) => {\n throw tanstackRedirect({ to: path, replace: opts?.replace, statusCode: opts?.statusCode });\n },\n unauthorized: (message?: string) => {\n const origin = currentOrigin();\n const { pathname, searchStr } = getTwilightContext().location;\n const href =\n origin &&\n loginRedirectHref({\n pathname,\n searchStr,\n origin,\n base: resolveStoreBase(),\n baseFollowsLocale: resolveStoreBaseFollowsLocale(),\n });\n // A full load, because the SDK only reads `intended_to` when a page starts.\n if (href) throw tanstackRedirect({ href, reloadDocument: true, replace: true });\n throw new UnauthorizedError(message);\n },\n});\n\n/**\n * TanStack navigation setup - wraps children with NavigationProvider and LinkProvider.\n * Called by TwilightProvider when client.framework === 'tanstack'.\n */\nexport function NavigationSetup({ children }: { children: ReactNode }) {\n const navigate = useNavigate();\n const { locale } = useParams({ strict: false }) as { locale?: string };\n const navigateFn = useCallback(\n (to: string, opts?: NavigateOptions) =>\n navigate({ to: localizeDestination(to, locale), replace: opts?.replace }),\n [navigate, locale]\n );\n\n return (\n <NavigationProvider navigate={navigateFn}>\n <NativeAppEvents locale={locale} />\n <LinkProvider adapter={TanStackLinkAdapter}>{children}</LinkProvider>\n </NavigationProvider>\n );\n}\n\n/** @deprecated Use NavigationSetup instead */\nexport function TanStackNavigationProvider({ children }: { children: ReactNode }) {\n const navigate = useNavigate();\n return (\n <NavigationProvider\n navigate={(to: string, opts?: NavigateOptions) => navigate({ to, replace: opts?.replace })}\n >\n <LinkProvider adapter={TanStackLinkAdapter}>{children}</LinkProvider>\n </NavigationProvider>\n );\n}\n"]}
|
|
@@ -147,7 +147,7 @@ function takeFrameReport(message) {
|
|
|
147
147
|
async function answerLookup(message) {
|
|
148
148
|
const { requestId, source, query } = message;
|
|
149
149
|
try {
|
|
150
|
-
const { lookupInStore } = await import('./store-lookup-
|
|
150
|
+
const { lookupInStore } = await import('./store-lookup-HMU7QMSC.js');
|
|
151
151
|
sendToEditor({ kind: "lookup-result", requestId, items: await lookupInStore(source, query) });
|
|
152
152
|
} catch (error) {
|
|
153
153
|
sendToEditor({
|
|
@@ -495,5 +495,5 @@ function useDevLayoutBlocks(components) {
|
|
|
495
495
|
var useDevHomeBlocks = import.meta.env.DEV ? useDevLayoutBlocks : (components) => components;
|
|
496
496
|
|
|
497
497
|
export { blockPath, devSettingsStore, useDevEditorMeta, useDevHomeBlocks, useDevReportSettingsFetchedAt, useDevSettingsOverrides, useDevSettingsState };
|
|
498
|
-
//# sourceMappingURL=chunk-
|
|
499
|
-
//# sourceMappingURL=chunk-
|
|
498
|
+
//# sourceMappingURL=chunk-AEM5UEH6.js.map
|
|
499
|
+
//# sourceMappingURL=chunk-AEM5UEH6.js.map
|