@salla.sa/twilight-theme-engine 1.0.211 → 1.0.213
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-2S3HIEYO.js → AddToCartForm-N4MMD6VL.js} +3 -3
- package/dist/{AddToCartForm-2S3HIEYO.js.map → AddToCartForm-N4MMD6VL.js.map} +1 -1
- package/dist/{BlogAuthorPage-UIPJCWVQ.js → BlogAuthorPage-S2GUI5PU.js} +25 -25
- package/dist/{BlogAuthorPage-UIPJCWVQ.js.map → BlogAuthorPage-S2GUI5PU.js.map} +1 -1
- package/dist/{BlogCategoryPage-AFSGP5WT.js → BlogCategoryPage-HOKJ3QWU.js} +25 -25
- package/dist/{BlogCategoryPage-AFSGP5WT.js.map → BlogCategoryPage-HOKJ3QWU.js.map} +1 -1
- package/dist/{BlogPage-7NKZSUKO.js → BlogPage-UPC3QW3M.js} +23 -23
- package/dist/{BlogPage-7NKZSUKO.js.map → BlogPage-UPC3QW3M.js.map} +1 -1
- package/dist/{BlogSinglePage-UMHYPYNX.js → BlogSinglePage-TD33OMSO.js} +23 -23
- package/dist/{BlogSinglePage-UMHYPYNX.js.map → BlogSinglePage-TD33OMSO.js.map} +1 -1
- package/dist/{BlogTagPage-SQN4SXMC.js → BlogTagPage-LOBT2JFV.js} +25 -25
- package/dist/{BlogTagPage-SQN4SXMC.js.map → BlogTagPage-LOBT2JFV.js.map} +1 -1
- package/dist/{BrandsPage-TU2FQ3UB.js → BrandsPage-BC2AMBDU.js} +24 -24
- package/dist/{BrandsPage-TU2FQ3UB.js.map → BrandsPage-BC2AMBDU.js.map} +1 -1
- package/dist/{Breadcrumb-RNHCZA4F.js → Breadcrumb-S76SNC44.js} +23 -23
- package/dist/{Breadcrumb-RNHCZA4F.js.map → Breadcrumb-S76SNC44.js.map} +1 -1
- package/dist/{CanvasOverlay-236ZRVHI.js → CanvasOverlay-HIE2LF6E.js} +3 -3
- package/dist/{CanvasOverlay-236ZRVHI.js.map → CanvasOverlay-HIE2LF6E.js.map} +1 -1
- package/dist/{CartItem-GQH2YB75.js → CartItem-YH4EVIL5.js} +23 -23
- package/dist/{CartItem-GQH2YB75.js.map → CartItem-YH4EVIL5.js.map} +1 -1
- package/dist/{CartSummary-5HIIURD2.js → CartSummary-BXOBMFSP.js} +23 -23
- package/dist/{CartSummary-5HIIURD2.js.map → CartSummary-BXOBMFSP.js.map} +1 -1
- package/dist/{Copyright-N6FO47JO.js → Copyright-CDOSBXU2.js} +3 -3
- package/dist/{Copyright-N6FO47JO.js.map → Copyright-CDOSBXU2.js.map} +1 -1
- package/dist/{CustomerLayout-R6GLA6IE.js → CustomerLayout-H2EWMBZB.js} +23 -23
- package/dist/{CustomerLayout-R6GLA6IE.js.map → CustomerLayout-H2EWMBZB.js.map} +1 -1
- package/dist/{Footer-QIAQM4Q5.js → Footer-WJ7GSEUS.js} +3 -3
- package/dist/{Footer-QIAQM4Q5.js.map → Footer-WJ7GSEUS.js.map} +1 -1
- package/dist/GoogleTag-KZV3WKSO.js +15 -0
- package/dist/{GoogleTag-DFXQET34.js.map → GoogleTag-KZV3WKSO.js.map} +1 -1
- package/dist/{Header-TUR3EHNU.js → Header-5UZ6TNSC.js} +10 -10
- package/dist/{Header-TUR3EHNU.js.map → Header-5UZ6TNSC.js.map} +1 -1
- package/dist/{LatestProducts-2RB53H7S.js → LatestProducts-LQPDHIKA.js} +25 -25
- package/dist/{LatestProducts-2RB53H7S.js.map → LatestProducts-LQPDHIKA.js.map} +1 -1
- package/dist/{LoyaltyPage-UNF6NHZA.js → LoyaltyPage-LNIMYHR3.js} +23 -23
- package/dist/{LoyaltyPage-UNF6NHZA.js.map → LoyaltyPage-LNIMYHR3.js.map} +1 -1
- package/dist/{LoyaltyPointsPage-X45XSXB7.js → LoyaltyPointsPage-PHA3JHM2.js} +7 -7
- package/dist/{LoyaltyPointsPage-X45XSXB7.js.map → LoyaltyPointsPage-PHA3JHM2.js.map} +1 -1
- package/dist/{MainMenu-OUTLZSZK.js → MainMenu-PSN2ME5V.js} +6 -6
- package/dist/{MainMenu-OUTLZSZK.js.map → MainMenu-PSN2ME5V.js.map} +1 -1
- package/dist/{MasterLayout-32ZBX5TD.js → MasterLayout-LMG4AOWH.js} +23 -23
- package/dist/{MasterLayout-32ZBX5TD.js.map → MasterLayout-LMG4AOWH.js.map} +1 -1
- package/dist/{MobileMenu-DQYV7EGL.js → MobileMenu-TA4JGR2O.js} +24 -24
- package/dist/{MobileMenu-DQYV7EGL.js.map → MobileMenu-TA4JGR2O.js.map} +1 -1
- package/dist/{NotificationsPage-WVUGAYAG.js → NotificationsPage-XFCTNVP2.js} +23 -23
- package/dist/{NotificationsPage-WVUGAYAG.js.map → NotificationsPage-XFCTNVP2.js.map} +1 -1
- package/dist/{OrderSinglePage-KMA7PFNH.js → OrderSinglePage-HRS2SC4M.js} +26 -26
- package/dist/{OrderSinglePage-KMA7PFNH.js.map → OrderSinglePage-HRS2SC4M.js.map} +1 -1
- package/dist/{OrdersPage-DXTAFTYU.js → OrdersPage-I3OUPPDV.js} +23 -23
- package/dist/{OrdersPage-DXTAFTYU.js.map → OrdersPage-I3OUPPDV.js.map} +1 -1
- package/dist/{PageSingle-LXA5BRXS.js → PageSingle-3BSOPVBZ.js} +5 -5
- package/dist/{PageSingle-LXA5BRXS.js.map → PageSingle-3BSOPVBZ.js.map} +1 -1
- package/dist/{ProductDetails-S7TPPY3W.js → ProductDetails-F35CZZCU.js} +7 -7
- package/dist/{ProductDetails-S7TPPY3W.js.map → ProductDetails-F35CZZCU.js.map} +1 -1
- package/dist/{ProfilePage-KNPPEKY3.js → ProfilePage-BMCTP3CH.js} +23 -23
- package/dist/{ProfilePage-KNPPEKY3.js.map → ProfilePage-BMCTP3CH.js.map} +1 -1
- package/dist/{ReviewsPage-E2UMSJFS.js → ReviewsPage-R6HB3MH2.js} +3 -3
- package/dist/{ReviewsPage-E2UMSJFS.js.map → ReviewsPage-R6HB3MH2.js.map} +1 -1
- package/dist/{SeoCartWidget-PWVFEAEZ.js → SeoCartWidget-5ZDKLKMJ.js} +23 -23
- package/dist/{SeoCartWidget-PWVFEAEZ.js.map → SeoCartWidget-5ZDKLKMJ.js.map} +1 -1
- package/dist/{SettingsPage-5W2S64TK.js → SettingsPage-UYPJ6QO5.js} +23 -23
- package/dist/{SettingsPage-5W2S64TK.js.map → SettingsPage-UYPJ6QO5.js.map} +1 -1
- package/dist/{StoreClosedNotification-7PFADAJU.js → StoreClosedNotification-4CARFVOG.js} +24 -24
- package/dist/{StoreClosedNotification-7PFADAJU.js.map → StoreClosedNotification-4CARFVOG.js.map} +1 -1
- package/dist/{TestimonialsPage-K5UTZ2SS.js → TestimonialsPage-6PEBTBYZ.js} +5 -5
- package/dist/{TestimonialsPage-K5UTZ2SS.js.map → TestimonialsPage-6PEBTBYZ.js.map} +1 -1
- package/dist/{ThankYouPage-OUWYUEUD.js → ThankYouPage-OBYA7FZW.js} +23 -23
- package/dist/{ThankYouPage-OUWYUEUD.js.map → ThankYouPage-OBYA7FZW.js.map} +1 -1
- package/dist/{WalletPage-MM6VKKIZ.js → WalletPage-OQUQDIW3.js} +24 -24
- package/dist/{WalletPage-MM6VKKIZ.js.map → WalletPage-OQUQDIW3.js.map} +1 -1
- package/dist/{WebMcpTools-VLZH7CTG.js → WebMcpTools-PT36R4Z2.js} +7 -7
- package/dist/{WebMcpTools-VLZH7CTG.js.map → WebMcpTools-PT36R4Z2.js.map} +1 -1
- package/dist/{WishlistPage-MPCJXTRI.js → WishlistPage-VP3EUOJF.js} +25 -25
- package/dist/{WishlistPage-MPCJXTRI.js.map → WishlistPage-VP3EUOJF.js.map} +1 -1
- package/dist/api/advertisement.js +3 -3
- package/dist/api/apps.js +3 -3
- package/dist/api/blog.js +5 -5
- package/dist/api/brands.js +5 -5
- package/dist/api/cart.js +5 -5
- package/dist/api/category.js +5 -5
- package/dist/api/client.js +2 -2
- package/dist/api/custom-url.js +3 -3
- package/dist/api/home.js +3 -3
- package/dist/api/loyalty.js +5 -5
- package/dist/api/menu.js +3 -3
- package/dist/api/notification.js +3 -3
- package/dist/api/order.js +5 -5
- package/dist/api/page.js +5 -5
- package/dist/api/product.js +5 -5
- package/dist/api/profile.js +2 -2
- package/dist/api/store.js +3 -3
- package/dist/api/translations.js +3 -3
- package/dist/api/user.js +3 -3
- package/dist/api/wallet.js +3 -3
- package/dist/api/wishlist.js +6 -6
- package/dist/{chunk-IU43EVAG.js → chunk-22Z2HPHZ.js} +5 -5
- package/dist/{chunk-IU43EVAG.js.map → chunk-22Z2HPHZ.js.map} +1 -1
- package/dist/{chunk-DM427NHC.js → chunk-3OWXPBB3.js} +2 -2
- package/dist/{chunk-DM427NHC.js.map → chunk-3OWXPBB3.js.map} +1 -1
- package/dist/{chunk-SVNHENYH.js → chunk-5HOEY55Q.js} +3 -3
- package/dist/{chunk-SVNHENYH.js.map → chunk-5HOEY55Q.js.map} +1 -1
- package/dist/{chunk-BLXKFLIR.js → chunk-5KJBDPHE.js} +6 -6
- package/dist/{chunk-BLXKFLIR.js.map → chunk-5KJBDPHE.js.map} +1 -1
- package/dist/{chunk-UWHRIBOH.js → chunk-5UMVEBO5.js} +5 -5
- package/dist/{chunk-UWHRIBOH.js.map → chunk-5UMVEBO5.js.map} +1 -1
- package/dist/{chunk-CGLX3SHB.js → chunk-5ZT225WZ.js} +5 -5
- package/dist/{chunk-CGLX3SHB.js.map → chunk-5ZT225WZ.js.map} +1 -1
- package/dist/{chunk-LJJM2P6G.js → chunk-6VZTX5U3.js} +3 -3
- package/dist/{chunk-LJJM2P6G.js.map → chunk-6VZTX5U3.js.map} +1 -1
- package/dist/{chunk-ONP7ZHEA.js → chunk-74HPO4GY.js} +3 -3
- package/dist/{chunk-ONP7ZHEA.js.map → chunk-74HPO4GY.js.map} +1 -1
- package/dist/{chunk-JV7ZGSR6.js → chunk-AACB4TUN.js} +4 -4
- package/dist/{chunk-JV7ZGSR6.js.map → chunk-AACB4TUN.js.map} +1 -1
- package/dist/{chunk-DIGHZ2TF.js → chunk-AHMG3IFV.js} +5 -5
- package/dist/{chunk-DIGHZ2TF.js.map → chunk-AHMG3IFV.js.map} +1 -1
- package/dist/{chunk-VHP7NL3V.js → chunk-BIIQ4FZA.js} +3 -3
- package/dist/{chunk-VHP7NL3V.js.map → chunk-BIIQ4FZA.js.map} +1 -1
- package/dist/{chunk-BZ2QSBXM.js → chunk-BO4WTPCA.js} +3 -3
- package/dist/{chunk-BZ2QSBXM.js.map → chunk-BO4WTPCA.js.map} +1 -1
- package/dist/{chunk-X4VUTZ6G.js → chunk-BSFTK6UF.js} +5 -5
- package/dist/{chunk-X4VUTZ6G.js.map → chunk-BSFTK6UF.js.map} +1 -1
- package/dist/{chunk-S7X6KZWV.js → chunk-C53BH5CR.js} +4 -4
- package/dist/{chunk-S7X6KZWV.js.map → chunk-C53BH5CR.js.map} +1 -1
- package/dist/{chunk-TYR2U33O.js → chunk-CTRBXAY7.js} +4 -4
- package/dist/{chunk-TYR2U33O.js.map → chunk-CTRBXAY7.js.map} +1 -1
- package/dist/{chunk-NAAVZ2XI.js → chunk-DHGZXSNJ.js} +3 -3
- package/dist/{chunk-NAAVZ2XI.js.map → chunk-DHGZXSNJ.js.map} +1 -1
- package/dist/{chunk-LJD5ZGUC.js → chunk-DM2A2E43.js} +4 -4
- package/dist/{chunk-LJD5ZGUC.js.map → chunk-DM2A2E43.js.map} +1 -1
- package/dist/{chunk-DVJGKIFQ.js → chunk-DRSS7TJ3.js} +3 -3
- package/dist/{chunk-DVJGKIFQ.js.map → chunk-DRSS7TJ3.js.map} +1 -1
- package/dist/{chunk-3A3FYCFR.js → chunk-EDSZX3QE.js} +4 -4
- package/dist/{chunk-3A3FYCFR.js.map → chunk-EDSZX3QE.js.map} +1 -1
- package/dist/{chunk-MZPX4EPS.js → chunk-EX4VX4GK.js} +36 -3
- package/dist/chunk-EX4VX4GK.js.map +1 -0
- package/dist/{chunk-AA5B2KC3.js → chunk-F4D4PJ3T.js} +4 -4
- package/dist/{chunk-AA5B2KC3.js.map → chunk-F4D4PJ3T.js.map} +1 -1
- package/dist/{chunk-3BLXVAQR.js → chunk-F63K3HAG.js} +3 -3
- package/dist/{chunk-3BLXVAQR.js.map → chunk-F63K3HAG.js.map} +1 -1
- package/dist/{chunk-UY4VIWNH.js → chunk-FFHLTFHB.js} +3 -3
- package/dist/{chunk-UY4VIWNH.js.map → chunk-FFHLTFHB.js.map} +1 -1
- package/dist/{chunk-4TI4LBOQ.js → chunk-GNLXRPBC.js} +3 -3
- package/dist/{chunk-4TI4LBOQ.js.map → chunk-GNLXRPBC.js.map} +1 -1
- package/dist/{chunk-RXJL73PN.js → chunk-HCU5GODZ.js} +4 -4
- package/dist/{chunk-RXJL73PN.js.map → chunk-HCU5GODZ.js.map} +1 -1
- package/dist/{chunk-6LF7Z22K.js → chunk-HI7SDG3R.js} +4 -4
- package/dist/{chunk-6LF7Z22K.js.map → chunk-HI7SDG3R.js.map} +1 -1
- package/dist/{chunk-2OKUBHTT.js → chunk-IAGMA4A4.js} +5 -5
- package/dist/{chunk-2OKUBHTT.js.map → chunk-IAGMA4A4.js.map} +1 -1
- package/dist/{chunk-LLUE7YSQ.js → chunk-INQ7RGEJ.js} +3 -3
- package/dist/{chunk-LLUE7YSQ.js.map → chunk-INQ7RGEJ.js.map} +1 -1
- package/dist/{chunk-PSJP2HG3.js → chunk-IQMKVT2C.js} +5 -5
- package/dist/{chunk-PSJP2HG3.js.map → chunk-IQMKVT2C.js.map} +1 -1
- package/dist/{chunk-2QDPVKV3.js → chunk-ISEQMLS3.js} +3 -3
- package/dist/{chunk-2QDPVKV3.js.map → chunk-ISEQMLS3.js.map} +1 -1
- package/dist/{chunk-FICBW5IV.js → chunk-JMPVEH7U.js} +3 -3
- package/dist/{chunk-FICBW5IV.js.map → chunk-JMPVEH7U.js.map} +1 -1
- package/dist/{chunk-MNEYCPJK.js → chunk-KEB4BTPE.js} +4 -4
- package/dist/{chunk-MNEYCPJK.js.map → chunk-KEB4BTPE.js.map} +1 -1
- package/dist/{chunk-MVERA3YU.js → chunk-KQSI3TTP.js} +3 -3
- package/dist/{chunk-MVERA3YU.js.map → chunk-KQSI3TTP.js.map} +1 -1
- package/dist/{chunk-CA2UMD6A.js → chunk-L7UJ77YE.js} +5 -5
- package/dist/{chunk-CA2UMD6A.js.map → chunk-L7UJ77YE.js.map} +1 -1
- package/dist/{chunk-BG7NQSGI.js → chunk-LD7EYT7B.js} +3 -3
- package/dist/{chunk-BG7NQSGI.js.map → chunk-LD7EYT7B.js.map} +1 -1
- package/dist/{chunk-6DXMOGBI.js → chunk-LG3CUJ4V.js} +23 -22
- package/dist/chunk-LG3CUJ4V.js.map +1 -0
- package/dist/{chunk-QPZRI4JS.js → chunk-LM7Y7MG4.js} +6 -6
- package/dist/{chunk-QPZRI4JS.js.map → chunk-LM7Y7MG4.js.map} +1 -1
- package/dist/{chunk-GSAU34IP.js → chunk-MZU5ZEGL.js} +3 -3
- package/dist/{chunk-GSAU34IP.js.map → chunk-MZU5ZEGL.js.map} +1 -1
- package/dist/{chunk-NDOU3IPV.js → chunk-NFXCRFON.js} +5 -5
- package/dist/{chunk-NDOU3IPV.js.map → chunk-NFXCRFON.js.map} +1 -1
- package/dist/{chunk-43NJZKVP.js → chunk-ODBQRDUU.js} +4 -4
- package/dist/{chunk-43NJZKVP.js.map → chunk-ODBQRDUU.js.map} +1 -1
- package/dist/{chunk-AHYZEVQM.js → chunk-ORC5ETTR.js} +5 -24
- package/dist/chunk-ORC5ETTR.js.map +1 -0
- package/dist/{chunk-YWZPC3LE.js → chunk-PXVA4CFK.js} +7 -7
- package/dist/{chunk-YWZPC3LE.js.map → chunk-PXVA4CFK.js.map} +1 -1
- package/dist/{chunk-R3FQW5X3.js → chunk-RG6VTJ3F.js} +3 -3
- package/dist/{chunk-R3FQW5X3.js.map → chunk-RG6VTJ3F.js.map} +1 -1
- package/dist/{chunk-CU5VDU34.js → chunk-RWGRWXIQ.js} +3 -3
- package/dist/{chunk-CU5VDU34.js.map → chunk-RWGRWXIQ.js.map} +1 -1
- package/dist/{chunk-YVPYFGPQ.js → chunk-SV364K3U.js} +4 -4
- package/dist/{chunk-YVPYFGPQ.js.map → chunk-SV364K3U.js.map} +1 -1
- package/dist/{chunk-2KMILFUS.js → chunk-UGIPX4L3.js} +15 -15
- package/dist/{chunk-2KMILFUS.js.map → chunk-UGIPX4L3.js.map} +1 -1
- package/dist/{chunk-IIUBZEDA.js → chunk-UYOVE4ST.js} +4 -4
- package/dist/{chunk-IIUBZEDA.js.map → chunk-UYOVE4ST.js.map} +1 -1
- package/dist/{chunk-JEYIRTTV.js → chunk-VF4DW6KQ.js} +4 -4
- package/dist/{chunk-JEYIRTTV.js.map → chunk-VF4DW6KQ.js.map} +1 -1
- package/dist/{chunk-XGGV2M36.js → chunk-VNOMGCMO.js} +4 -4
- package/dist/{chunk-XGGV2M36.js.map → chunk-VNOMGCMO.js.map} +1 -1
- package/dist/{chunk-3FOYOKKX.js → chunk-W3EYJOD3.js} +4 -4
- package/dist/{chunk-3FOYOKKX.js.map → chunk-W3EYJOD3.js.map} +1 -1
- package/dist/{chunk-VJ4KJT5M.js → chunk-X7E2KD2F.js} +7 -7
- package/dist/{chunk-VJ4KJT5M.js.map → chunk-X7E2KD2F.js.map} +1 -1
- package/dist/{chunk-HU5YZCVR.js → chunk-YB356GAD.js} +8 -8
- package/dist/{chunk-HU5YZCVR.js.map → chunk-YB356GAD.js.map} +1 -1
- package/dist/{chunk-QHPB4RM4.js → chunk-YND257SH.js} +4 -4
- package/dist/{chunk-QHPB4RM4.js.map → chunk-YND257SH.js.map} +1 -1
- package/dist/{chunk-VNYDOP22.js → chunk-ZLSHNQSO.js} +3 -3
- package/dist/{chunk-VNYDOP22.js.map → chunk-ZLSHNQSO.js.map} +1 -1
- package/dist/{chunk-OH6NOZSB.js → chunk-ZOEW4C2C.js} +3 -3
- package/dist/{chunk-OH6NOZSB.js.map → chunk-ZOEW4C2C.js.map} +1 -1
- package/dist/{chunk-43RZLTNM.js → chunk-ZWPGS2V7.js} +4 -4
- package/dist/{chunk-43RZLTNM.js.map → chunk-ZWPGS2V7.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 +21 -21
- package/dist/components/home/index.js +26 -26
- package/dist/components/layout/index.js +5 -5
- package/dist/components/product/index.js +23 -23
- package/dist/components/store/index.js +22 -22
- package/dist/components/toast/index.js +3 -3
- package/dist/components/tracking/index.js +8 -8
- package/dist/{custom-urls-AOYDTTF4.js → custom-urls-7JFXAHVF.js} +9 -9
- package/dist/{custom-urls-AOYDTTF4.js.map → custom-urls-7JFXAHVF.js.map} +1 -1
- package/dist/dev/editor/index.js +1 -1
- package/dist/dev/index.js +1 -1
- package/dist/{document-class-WZISVNHG.js → document-class-DLQ7ZHXB.js} +19 -19
- package/dist/{document-class-WZISVNHG.js.map → document-class-DLQ7ZHXB.js.map} +1 -1
- package/dist/hooks/index.js +21 -21
- package/dist/hooks/useComments.js +2 -2
- package/dist/hooks/useGtm.js +21 -21
- package/dist/hooks/useMoney.js +21 -21
- package/dist/hooks/useProduct.js +2 -2
- package/dist/hooks/useStore.js +21 -21
- package/dist/hooks/useUser.js +4 -4
- package/dist/hooks/useWishlist.js +2 -2
- package/dist/index.js +21 -21
- package/dist/native-app/index.js +2 -2
- package/dist/{navigation-G6UMVNCJ.js → navigation-ILRUCZ3G.js} +7 -7
- package/dist/{navigation-G6UMVNCJ.js.map → navigation-ILRUCZ3G.js.map} +1 -1
- package/dist/{navigation-UG7TWUIO.js → navigation-ZZQKRNBG.js} +6 -6
- package/dist/{navigation-UG7TWUIO.js.map → navigation-ZZQKRNBG.js.map} +1 -1
- package/dist/{not-found-TMNGF4K6.js → not-found-47B2WAO5.js} +24 -24
- package/dist/{not-found-TMNGF4K6.js.map → not-found-47B2WAO5.js.map} +1 -1
- package/dist/providers/index.js +21 -21
- package/dist/providers/twilight-init.d.ts.map +1 -1
- package/dist/routes/account/orders.js +6 -6
- package/dist/routes/account.js +15 -15
- package/dist/routes/blog.js +10 -10
- package/dist/routes/brands.js +6 -6
- package/dist/routes/cart.js +31 -31
- package/dist/routes/home.js +27 -27
- package/dist/routes/index.js +10 -10
- package/dist/routes/loyalty.js +7 -7
- package/dist/routes/page.js +6 -6
- package/dist/routes/product-listing.js +31 -31
- package/dist/routes/product.js +30 -30
- package/dist/routes/seo-redirects.js +10 -10
- package/dist/routes/testimonials.js +2 -2
- package/dist/routes/thank-you.js +6 -6
- package/dist/skeleton.js +29 -29
- package/dist/{store-lookup-6B6PLTTG.js → store-lookup-5ULOU7TP.js} +10 -10
- package/dist/{store-lookup-6B6PLTTG.js.map → store-lookup-5ULOU7TP.js.map} +1 -1
- package/dist/tanstack.js +19 -19
- package/dist/types/salla-sdk.d.ts +11 -0
- package/dist/types/salla-sdk.d.ts.map +1 -1
- package/dist/utils/index.js +3 -3
- package/dist/utils/sdk-helpers.d.ts +10 -0
- package/dist/utils/sdk-helpers.d.ts.map +1 -1
- package/package.json +1 -1
- package/tailwind/routes/account/orders/single/OrderItemRow.tsx.txt +2 -2
- package/dist/GoogleTag-DFXQET34.js +0 -15
- package/dist/chunk-6DXMOGBI.js.map +0 -1
- package/dist/chunk-AHYZEVQM.js.map +0 -1
- package/dist/chunk-MZPX4EPS.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/native-app-headers.ts","../src/utils/theme-version.ts","../src/utils/sdk-helpers.ts"],"names":[],"mappings":";;;;AACO,IAAM,kBAAA,GAAqB;AAAA,EAChC,UAAA;AAAA,EACA,eAAA;AAAA,EACA,oBAAA;AAAA,EACA;AACF;AAMO,IAAM,0BAAA,GAA6B,CAAC,UAAA,EAAY,eAAe,CAAA;AAU/D,SAAS,qBAAqB,OAAA,EAAiD;AACpF,EAAA,MAAM,EAAA,GAAK,OAAA,CAAQ,GAAA,CAAI,UAAU,GAAG,WAAA,EAAY;AAChD,EAAA,IAAI,EAAA,KAAO,KAAA,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O,QAAA,EAAU,OAAA,EAAS,SAAS,IAAI,CAAA;AAC9D","file":"chunk-EX4VX4GK.js","sourcesContent":["/** The headers the Salla native app sends with every page it loads in its webview. */\nexport const NATIVE_APP_HEADERS = [\n 's-app-os',\n 's-app-version',\n 's-app-full-version',\n 's-app-os-version',\n];\n\n/**\n * How the app's webview names itself to the Store API. On a Twig theme Laravel hands these\n * to the SDK as request headers, which is how the API tells an app order from a website one.\n */\nexport const NATIVE_APP_REQUEST_HEADERS = ['s-source', 's-app-webview'];\n\n/**\n * The native app's own headers on this request, or null when it is not the app.\n *\n * On a Twig theme Laravel copies them into the settings' `jitsu.context.extra.headers`,\n * where the SDK reads the app's platform and version from (`salla.config.isMobileApp()`).\n * A React theme asks for its settings from the server, through the API, so the app's\n * headers never reach that call: the request is the only place they are.\n */\nexport function readNativeAppHeaders(headers: Headers): Record<string, string> | null {\n const os = headers.get('s-app-os')?.toLowerCase();\n if (os !== 'ios' && os !== 'android') return null;\n const found: Record<string, string> = {};\n for (const name of [...NATIVE_APP_HEADERS, ...NATIVE_APP_REQUEST_HEADERS]) {\n const value = headers.get(name);\n if (value) found[name] = value;\n }\n return found;\n}\n","/**\n * @fileoverview Which version of the theme's settings to render — the one answer,\n * in one place.\n *\n * A merchant's theme settings are versioned. An ordinary storefront visit names\n * no version and gets the live one; the API decides, and reports it back as\n * `theme.profile.id`. Two surfaces need a different one, and both address it in\n * the URL of an iframe:\n *\n * - the merchant's theme editor at `s.salla.sa/themes/editor/…`, which shows a\n * draft version beside the controls that are editing it;\n * - a partner running the theme locally, whose dev server is the iframe.\n *\n * Written as a module of its own rather than inline at the one call site,\n * because `store-identity.ts` exists for exactly this reason: the identifier a\n * request resolved and the identifier it sent were two different values for\n * days, in two files, and every test passed. A second implementation of this is\n * the bug, not a refactor away from one.\n */\nimport { getRequestStore, getTwilightContext } from '../twilight/context';\nimport type { StoreContext } from '../api/store';\nimport { getInjectedRuntimeEnv } from './runtime-env';\n\n/**\n * The version this request asked for, or null when it asked for none.\n *\n * Deliberately excludes the version the *settings* name. This is the answer to\n * \"what did the caller address?\", and it has to be available before any settings\n * exist — React Query keys are built from it, and a key that means one thing\n * during SSR and another after hydration is how a page refetches everything it\n * was just handed.\n *\n * 1. what the request named, seeded by `twilightMiddleware` on a host permitted\n * to name one;\n * 2. what SSR resolved and published into the head, which is all the browser has\n * once the dispatcher has stripped `?versionId=` from the URL.\n */\nexport function requestedThemeVersionId(): string | null {\n const { versionId } = getRequestStore();\n if (versionId) return versionId;\n\n return getInjectedRuntimeEnv().versionId || null;\n}\n\n/**\n * The prefix the Store names a draft theme by: core's `getDraftNameForId()` is\n * `draft-` followed by the Optimus-encoded draft id.\n */\nconst DRAFT_THEME_NAME_PREFIX = 'draft-';\n\n/**\n * The draft theme this request previews, as the name the Store knows it by —\n * what goes in `s-theme-name` — or null when it previews none.\n *\n * The version alone is not enough on a draft's preview. The theme editor shows a\n * draft against the store's one draft version, and that row names no theme\n * (`theme = '0'`), so the Store answered every call about it as the store's own\n * installed theme. It renders the draft's settings, but checks each component\n * against that other theme: a React draft's components are declared by the draft\n * alone, so `component/list` dropped every one and answered `[]` (TD-17779).\n *\n * `draft-<id>` is not a format invented here. It is the Store's own name for a\n * draft (`storeTheme()->getDraftNameForId()` in core), and the value a twig\n * draft's preview already puts on every API call through `api::setHeaders`. The\n * Store reads it only for its draft version, and only for a draft that allows\n * the store being asked about.\n *\n * Same two sources, in the same order and for the same reasons, as\n * {@link requestedThemeVersionId}, and no third: there are no settings that could\n * name a draft, and a build is never pinned to one. Both API clients — the\n * engine's own and the SDK's — ask this one function.\n */\nexport function requestedDraftThemeName(): string | null {\n const draftId = getRequestStore().draftId || getInjectedRuntimeEnv().draftId || null;\n return draftId ? `${DRAFT_THEME_NAME_PREFIX}${draftId}` : null;\n}\n\n/**\n * The version every Salla API call is answered with — what goes in `s-version-id`.\n *\n * The requested version outranks the settings, because a request that named one\n * is the only reason this is ever anything but the live version: falling back to\n * the settings there would let the first answer overwrite the question.\n *\n * The settings' own `theme.profile.id` stays as the fallback, unchanged. It is\n * what this header has always carried, and on an ordinary storefront it still\n * is — it keeps the rest of a page's calls pinned to the version the settings\n * call resolved, rather than letting a version go live mid-render.\n *\n * That pin is only good for the scope the settings were requested with. Each\n * market (scope) has its own version, and the API lets a named version outrank\n * the market's: once the shopper switches market, the loaded settings still\n * describe the previous one, and replaying their version — on the settings call\n * for the new market first of all — gets the previous market's theme back, for\n * good. So the version is replayed only while the active scope is the one the\n * settings were answered for (`store.scope`), which is not always the one they\n * were requested for (`requestedScopeId`): the API falls back to another scope\n * when it does not accept the requested one, and that scope's version must not\n * ride along on the next request for the requested one. With no active scope it\n * is replayed only for settings requested without one. Otherwise nothing is\n * sent and the API picks the version of the scope on the request.\n *\n * `activeScopeId` is passed in by the caller that already resolved the scope for\n * its `s-scope-*` headers.\n *\n * Reading the settings is guarded because `getTwilightContext().settings` throws\n * a `SettingsError` when they have not loaded — which is the normal state on the\n * very first call, the settings call itself.\n */\n/** Whether `settings` were answered for `activeScopeId` (see {@link resolveThemeVersionId}). */\nfunction answersScope(settings: StoreContext | null | undefined, activeScopeId: string | null) {\n const requestedScopeId = settings?.requestedScopeId ?? null;\n if (activeScopeId == null) return requestedScopeId == null;\n const answeredScopeId = settings?.store?.scope?.id;\n return (answeredScopeId != null ? String(answeredScopeId) : requestedScopeId) === activeScopeId;\n}\n\nexport function resolveThemeVersionId(activeScopeId: string | null = null): string | null {\n const requested = requestedThemeVersionId();\n if (requested) return requested;\n\n try {\n const settings = getTwilightContext().settings;\n if (!answersScope(settings, activeScopeId)) return null;\n\n const profileId = settings?.theme?.profile?.id;\n return profileId != null ? String(profileId) : null;\n } catch {\n return null;\n }\n}\n","export type { StoreContext } from '../api/store';\nimport type { StoreContext } from '../api/store';\nimport type { SallaSDK } from '../types/salla-sdk';\nimport { NATIVE_APP_HEADERS } from './native-app-headers';\nimport { resolveStoreIdentifier } from './store-identity';\nimport { requestedDraftThemeName, requestedThemeVersionId } from './theme-version';\n\nconst isBrowser = typeof window !== 'undefined';\n\n/**\n * Which store to ask the API about — see {@link resolveStoreIdentifier}.\n *\n * A delegation, not a second implementation. This name is the one on the wire\n * (`api/client.ts` sets the `store-identifier` header from it) and the one\n * themes import from `@salla.sa/twilight-theme-engine/utils`, so it stays; what\n * it must never do again is answer differently from the resolver everything\n * else asks. It had its own copy of the order once, missing the store the\n * request names and preferring the build-time `VITE_STORE_DOMAIN` that a\n * deployed worker does not have — so every published theme sent an empty\n * identifier and rendered \"Store Unavailable\".\n */\nexport function getStoreIdentifier(explicit?: string): string {\n return resolveStoreIdentifier(explicit);\n}\n\n/**\n * Get Salla SDK instance if available\n */\nexport function getSallaSDK(): typeof window.salla | undefined {\n if (!isBrowser) return undefined;\n return window.salla;\n}\n\n/** Dispatched on `window` by the SDK as the last step of loading (twilight `src/index.js`). */\nconst SDK_CREATED_EVENT = 'salla::created';\n\nconst noop = () => {};\n\n/**\n * Whether `window.salla` is the SDK, rather than the stub that stands in for it.\n *\n * ⚠️ `window.salla` exists from the first bytes of the page. The `twilight-init`\n * head script defines it with an `onReady`, so app snippets can queue work, and\n * the SDK — a deferred module — fills it in later. React can hydrate and run\n * effects in between, and there `window.salla?.event.on(…)` passes its `?.` and\n * throws `Cannot read properties of undefined (reading 'on')`.\n *\n * The SDK defines `init` and `event` in one synchronous module evaluation and the\n * stub has neither, so either one means it has loaded.\n */\nfunction isLoaded(sdk: typeof window.salla): sdk is SallaSDK {\n return typeof sdk?.init === 'function' || typeof sdk?.event?.on === 'function';\n}\n\n/** An SDK whose event bus can take a listener — what {@link onSallaEvent} needs. */\nfunction hasEventBus(sdk: typeof window.salla): sdk is SallaSDK {\n return typeof sdk?.event?.on === 'function';\n}\n\n/**\n * Run `callback` with the SDK as soon as it has loaded: now if it has, otherwise\n * when it announces itself.\n *\n * Returns a cancel for an effect's cleanup, so a component that unmounts first\n * never has the callback run. An effect that returned early when the SDK was not\n * there yet never ran again — on a cold load, where hydration beats the SDK, the\n * engine never initialised it at all.\n */\nexport function whenSallaLoaded(callback: (sdk: SallaSDK) => void): () => void {\n return whenSalla(isLoaded, callback);\n}\n\nfunction whenSalla(\n isUsable: (sdk: typeof window.salla) => sdk is SallaSDK,\n callback: (sdk: SallaSDK) => void\n): () => void {\n if (!isBrowser) return noop;\n\n if (isUsable(window.salla)) {\n callback(window.salla);\n return noop;\n }\n\n let settled = false;\n const onCreated = () => {\n const sdk = window.salla;\n if (settled || !isUsable(sdk)) return;\n settled = true;\n window.removeEventListener(SDK_CREATED_EVENT, onCreated);\n callback(sdk);\n };\n window.addEventListener(SDK_CREATED_EVENT, onCreated);\n\n return () => {\n settled = true;\n window.removeEventListener(SDK_CREATED_EVENT, onCreated);\n };\n}\n\n/**\n * Run `callback` once the SDK has loaded **and been initialised** — for work that\n * talks to the API, which needs the store config `init` sets.\n *\n * Loaded is not enough for that: `init` finishes asynchronously, so a cart lookup\n * made the moment the SDK announces itself goes out without a store identifier\n * and is answered `Store Identifier not found`. Returns a cancel, as\n * {@link whenSallaLoaded} does.\n *\n * A rejected `onReady` still runs `callback`, as `useTwilightInit` carries on past\n * one: it means a partial initialisation, and waiting on it would leave the caller\n * waiting for good.\n */\nexport function whenSallaReady(callback: (sdk: SallaSDK) => void): () => void {\n let cancelled = false;\n const cancel = whenSallaLoaded((sdk) => {\n void new Promise((resolve) => resolve(sdk.onReady?.())).catch(noop).then(() => {\n if (!cancelled) callback(sdk);\n });\n });\n return () => {\n cancelled = true;\n cancel();\n };\n}\n\n/**\n * `salla.event.on(name, listener)` once the SDK has loaded. Returns the matching\n * unsubscribe, which also cancels a subscription still waiting for the SDK.\n *\n * Removed from the emitter it was added to, not from whatever `window.salla` is\n * by the time the component unmounts.\n *\n * Waits for an event bus specifically, not for \"loaded\": an SDK is recognised by\n * `init` alone, and subscribing on one without a bus would throw.\n */\nexport function onSallaEvent(name: string, listener: (...args: unknown[]) => void): () => void {\n let bus: SallaSDK['event'] | undefined;\n const cancel = whenSalla(hasEventBus, (sdk) => {\n bus = sdk.event;\n bus.on(name, listener);\n });\n return () => {\n cancel();\n bus?.off?.(name, listener);\n };\n}\n\n/**\n * Push the active route locale onto the Salla SDK.\n *\n * Why this is needed (and why it must run on every navigation):\n * - The SDK seeds its locale from `navigator.language` — the theme sets no `s-lang`\n * cookie or `window.locale` — so an English browser starts the SDK in `en` even on\n * an `/ar` store.\n * - The SDK fixes its axios `accept-language` header ONCE, at init. `salla.lang.setLocale`\n * only swaps UI translations (it never touches the header), and `salla.init()` is a\n * no-op after `Salla.status === 'ready'`, so the header never refreshes on its own.\n * - `profile::info.fetched` (login / profile refresh on navigation) overrides the header\n * to the *account's* language.\n *\n * Net result without this: `salla.api.*` calls (cart/product details) return data in the\n * wrong locale — e.g. English cart item names on `/ar/cart` — intermittently, depending on\n * load order and whether a profile fetch ran. Re-asserting the URL locale here keeps the\n * header correct. No-op on the server and until the SDK exposes the methods.\n */\nexport function syncSdkLocale(locale: string): void {\n const sdk = getSallaSDK();\n if (!sdk || !locale) return;\n try {\n sdk.lang?.setLocale?.(locale);\n sdk.api?.setHeader?.('accept-language', locale);\n // The localization modal swaps `/${user.language_code}/` in the URL on submit;\n // the SDK never sets this locally, so without it the switch reloads the same page.\n sdk.config?.set?.('user.language_code', locale);\n } catch {\n // SDK partially loaded — the header is re-asserted on the next navigation.\n }\n}\n\n/**\n * The `s-version-id` the SDK sends: the version the request named, else the one\n * the settings report.\n *\n * The request outranks the settings here for the reason it does in\n * `resolveThemeVersionId`. `headers['s-version-id']` is the version the API\n * *answered with*, and for a version it cannot reach it reports the live one\n * while rendering defaults. Read alone, a preview's `salla.api.*` calls asked\n * about the live version while the engine's own asked about the previewed one,\n * so one page showed two versions.\n */\nfunction sdkThemeVersionId(headers: StoreContext['headers']): string | null {\n const versionId = requestedThemeVersionId() ?? headers?.['s-version-id'];\n return versionId != null ? String(versionId) : null;\n}\n\n/**\n * Settings as the SDK's `init` should copy them: with `headers` naming the\n * version {@link sdkThemeVersionId} picks, and the draft theme a preview renders.\n *\n * `init` spreads `headers` over its axios defaults, and on a first load nothing\n * re-asserts either afterwards: TanStack restores the root match's context\n * instead of re-running `rootBeforeLoad` in the browser, so\n * {@link syncSdkThemeVersion} first runs on a client navigation.\n *\n * The draft goes on as `s-theme-name`, the same header and value the engine's own\n * client sends (see `requestedDraftThemeName`). Without it every `salla.api.*`\n * call on a draft's preview would be answered as the store's own theme.\n */\nexport function withSdkThemeVersion<T extends Pick<StoreContext, 'headers'>>(settings: T): T {\n const versionId = requestedThemeVersionId();\n const draftThemeName = requestedDraftThemeName();\n if (!versionId && !draftThemeName) return settings;\n return {\n ...settings,\n headers: {\n ...settings.headers,\n ...(versionId ? { 's-version-id': versionId } : {}),\n ...(draftThemeName ? { 's-theme-name': draftThemeName } : {}),\n },\n };\n}\n\n/**\n * Push the theme version onto the Salla SDK: the requested one, else the one the\n * current settings name (see {@link sdkThemeVersionId}).\n *\n * The SDK copies `settings.headers` into its axios defaults ONCE, at init, and\n * `s-version-id` is one of them. Settings refetched on the client — the shopper\n * switched market, and each market has its own version — name a different one,\n * and without this every `salla.api.*` call keeps asking for the previous\n * market's version until a full page load. Settings that name no version take\n * the header off instead, so the SDK asks for the live one like the engine's own\n * client does. The draft a preview renders is re-asserted beside it, and taken\n * off the same way when nothing names one. No-op on the server and until the SDK\n * exposes its api.\n */\nexport function syncSdkThemeVersion(headers: StoreContext['headers']): void {\n const sdk = getSallaSDK();\n if (!sdk) return;\n try {\n syncSdkHeader(sdk, 's-version-id', sdkThemeVersionId(headers));\n syncSdkHeader(sdk, 's-theme-name', requestedDraftThemeName());\n } catch {\n // SDK partially loaded — the header is re-asserted on the next navigation.\n }\n}\n\n/**\n * Send the app's own headers (its platform and versions) on every call the SDK makes, with\n * the values the app's webview sent. Only inside the app's webview.\n *\n * Added to each request, not to the SDK's own headers: the SDK reads `s-app-version` and\n * `s-app-full-version` from its headers to decide whether the app can open its login and\n * its gallery, and falls back to the webview flag when they are absent. Held there, an app\n * older than those checks expect would lose both.\n */\nexport function sendNativeAppHeaders(\n sdk: SallaSDK,\n settings: Pick<StoreContext, 'headers' | 'jitsu'> | null | undefined\n): void {\n const headers = settings?.headers;\n if (headers?.['s-source'] !== 'mobile' || !headers['s-app-webview']) return;\n const sent = settings?.jitsu?.context?.extra?.headers;\n const app = NATIVE_APP_HEADERS.flatMap((name) => {\n const value = sent?.[name];\n return value ? [[name, value] as const] : [];\n });\n if (!app.length) return;\n sdk.api?.axios?.interceptors?.request?.use?.((config) => {\n for (const [name, value] of app) config.headers?.set?.(name, value);\n return config;\n });\n}\n\n/**\n * Set one of the SDK's default headers, or take it off when nothing names a value — so a\n * header left over from the previous page cannot answer for this one.\n */\nfunction syncSdkHeader(\n sdk: NonNullable<ReturnType<typeof getSallaSDK>>,\n name: string,\n value: string | null | undefined\n): void {\n if (value) sdk.api?.setHeader?.(name, value);\n else delete sdk.api?.axios?.defaults?.headers?.common?.[name];\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { orThrow } from './chunk-
|
|
2
|
-
import { getActiveScope, api } from './chunk-
|
|
1
|
+
import { orThrow } from './chunk-W3EYJOD3.js';
|
|
2
|
+
import { getActiveScope, api } from './chunk-EDSZX3QE.js';
|
|
3
3
|
import { getTwilightContext } from './chunk-MWUAHDQL.js';
|
|
4
4
|
import { defaultShouldDehydrateQuery, queryOptions } from '@tanstack/react-query';
|
|
5
5
|
|
|
@@ -234,5 +234,5 @@ var product = {
|
|
|
234
234
|
};
|
|
235
235
|
|
|
236
236
|
export { getProductPreview, isProductPreviewQuery, parseNextPageToken, product, productDetailQueryKey, productPreviewQueryKey, rememberProductPreview, shouldDehydrateQuery };
|
|
237
|
-
//# sourceMappingURL=chunk-
|
|
238
|
-
//# sourceMappingURL=chunk-
|
|
237
|
+
//# sourceMappingURL=chunk-F4D4PJ3T.js.map
|
|
238
|
+
//# sourceMappingURL=chunk-F4D4PJ3T.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/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,EAAS,CAAC,EAAE,MAAA,EAAO,KAAM,OAAA,CAAQ,IAAA,CAAK,EAAE,GAAG,MAAA,EAAQ,MAAA,EAAQ;AAAA,KAC5D;AAAA;AAEP","file":"chunk-AA5B2KC3.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\n/** What a product page shows, asked of `products/{id}/details` and `products/sku/{sku}/details`. */\nconst DETAILS_WITH =\n '?with[]=images&with[]=category&with[]=rating&with[]=notify_availability&with[]=tags&with[]=brand' +\n '&with[]=options&with[]=skus&with[]=skus_availability&with[]=included_products&with[]=bundle&with[]=sold_quantity';\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 { data } = await api\n .get(`products/${id}/details${DETAILS_WITH}`)\n .json<{ data: Product }>();\n return data;\n },\n\n findOrThrow: (id: string): Promise<Product> => orThrow(product.find(id)),\n\n /**\n * A product by its SKU, for a store on SKU links (`/{sku}-{name}`): the same details as `find`.\n * The API resolves the SKU as Twig's `showNewUrls` does (the product's own `sku`, in the store).\n */\n findBySku: async (sku: string): Promise<Product> => {\n const { data } = await api\n .get(`products/sku/${encodeURIComponent(sku)}/details${DETAILS_WITH}`)\n .json<{ data: Product }>();\n return data;\n },\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 bySku: (sku: string) =>\n queryOptions({\n // In the page's language: a preload asked in another must not answer for it.\n queryKey: [\n 'products',\n 'sku',\n sku,\n getTwilightContext().locale,\n { scope: getActiveScope() },\n ],\n queryFn: () => product.findBySku(sku),\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":";;;;;AAgGA,IAAM,YAAA,GACJ,kNAAA;AAGF,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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;AAAA,QACrB,EAAE,KAAA,EAAO,cAAA,EAAe;AAAE,OAC5B;AAAA,MACA,OAAA,EAAS,MAAM,OAAA,CAAQ,SAAA,CAAU,GAAG;AAAA,KACrC,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-F4D4PJ3T.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\n/** What a product page shows, asked of `products/{id}/details` and `products/sku/{sku}/details`. */\nconst DETAILS_WITH =\n '?with[]=images&with[]=category&with[]=rating&with[]=notify_availability&with[]=tags&with[]=brand' +\n '&with[]=options&with[]=skus&with[]=skus_availability&with[]=included_products&with[]=bundle&with[]=sold_quantity';\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 { data } = await api\n .get(`products/${id}/details${DETAILS_WITH}`)\n .json<{ data: Product }>();\n return data;\n },\n\n findOrThrow: (id: string): Promise<Product> => orThrow(product.find(id)),\n\n /**\n * A product by its SKU, for a store on SKU links (`/{sku}-{name}`): the same details as `find`.\n * The API resolves the SKU as Twig's `showNewUrls` does (the product's own `sku`, in the store).\n */\n findBySku: async (sku: string): Promise<Product> => {\n const { data } = await api\n .get(`products/sku/${encodeURIComponent(sku)}/details${DETAILS_WITH}`)\n .json<{ data: Product }>();\n return data;\n },\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 bySku: (sku: string) =>\n queryOptions({\n // In the page's language: a preload asked in another must not answer for it.\n queryKey: [\n 'products',\n 'sku',\n sku,\n getTwilightContext().locale,\n { scope: getActiveScope() },\n ],\n queryFn: () => product.findBySku(sku),\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 { api } from './chunk-
|
|
1
|
+
import { api } from './chunk-EDSZX3QE.js';
|
|
2
2
|
|
|
3
3
|
// src/api/wallet.ts
|
|
4
4
|
var wallet = {
|
|
@@ -20,5 +20,5 @@ var wallet = {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export { wallet };
|
|
23
|
-
//# sourceMappingURL=chunk-
|
|
24
|
-
//# sourceMappingURL=chunk-
|
|
23
|
+
//# sourceMappingURL=chunk-F63K3HAG.js.map
|
|
24
|
+
//# sourceMappingURL=chunk-F63K3HAG.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/wallet.ts"],"names":[],"mappings":";;;AAgCO,IAAM,MAAA,GAAS;AAAA,EACpB,IAAA,EAAM,OAAO,MAAA,GAA2B,EAAC,KAAiC;AACxE,IAAA,MAAM,EAAE,IAAA,GAAO,CAAA,EAAG,OAAA,GAAU,EAAA,EAAI,QAAO,GAAI,MAAA;AAE3C,IAAA,MAAM,YAAA,GAAe,IAAI,eAAA,EAAgB;AACzC,IAAA,YAAA,CAAa,GAAA,CAAI,MAAA,EAAQ,MAAA,CAAO,IAAI,CAAC,CAAA;AACrC,IAAA,YAAA,CAAa,GAAA,CAAI,UAAA,EAAY,MAAA,CAAO,OAAO,CAAC,CAAA;AAE5C,IAAA,MAAM,UAAmC,EAAC;AAC1C,IAAA,IAAI,MAAA,UAAgB,MAAA,GAAS,MAAA;AAE7B,IAAA,MAAM,QAAA,GAAW,MAAM,GAAA,CACpB,GAAA,CAAI,CAAA,eAAA,EAAkB,YAAA,CAAa,QAAA,EAAU,CAAA,CAAA,EAAI,OAAc,CAAA,CAC/D,IAAA,EAAsE;AAEzE,IAAA,MAAM,YAAA,GAAe,SAAS,IAAA,CAAK,YAAA;AAEnC,IAAA,OAAO;AAAA,MACL,KAAA,EAAO,YAAA,CAAa,IAAA,IAAQ,EAAC;AAAA,MAC7B,MAAM,YAAA,CAAa,aAAA;AAAA,MACnB,OAAA,EAAS,SAAS,IAAA,CAAK;AAAA,KACzB;AAAA,EACF;AACF","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/api/wallet.ts"],"names":[],"mappings":";;;AAgCO,IAAM,MAAA,GAAS;AAAA,EACpB,IAAA,EAAM,OAAO,MAAA,GAA2B,EAAC,KAAiC;AACxE,IAAA,MAAM,EAAE,IAAA,GAAO,CAAA,EAAG,OAAA,GAAU,EAAA,EAAI,QAAO,GAAI,MAAA;AAE3C,IAAA,MAAM,YAAA,GAAe,IAAI,eAAA,EAAgB;AACzC,IAAA,YAAA,CAAa,GAAA,CAAI,MAAA,EAAQ,MAAA,CAAO,IAAI,CAAC,CAAA;AACrC,IAAA,YAAA,CAAa,GAAA,CAAI,UAAA,EAAY,MAAA,CAAO,OAAO,CAAC,CAAA;AAE5C,IAAA,MAAM,UAAmC,EAAC;AAC1C,IAAA,IAAI,MAAA,UAAgB,MAAA,GAAS,MAAA;AAE7B,IAAA,MAAM,QAAA,GAAW,MAAM,GAAA,CACpB,GAAA,CAAI,CAAA,eAAA,EAAkB,YAAA,CAAa,QAAA,EAAU,CAAA,CAAA,EAAI,OAAc,CAAA,CAC/D,IAAA,EAAsE;AAEzE,IAAA,MAAM,YAAA,GAAe,SAAS,IAAA,CAAK,YAAA;AAEnC,IAAA,OAAO;AAAA,MACL,KAAA,EAAO,YAAA,CAAa,IAAA,IAAQ,EAAC;AAAA,MAC7B,MAAM,YAAA,CAAa,aAAA;AAAA,MACnB,OAAA,EAAS,SAAS,IAAA,CAAK;AAAA,KACzB;AAAA,EACF;AACF","file":"chunk-F63K3HAG.js","sourcesContent":["import { api } from './client';\n\nexport interface TransactionItem {\n id: number;\n order_id: number;\n transaction_type: string;\n action_type: string;\n type: string;\n title: string;\n description: string;\n amount: number;\n created_at: number;\n expired_at: number;\n}\n\nexport interface WalletListParams {\n page?: number;\n perPage?: number;\n signal?: AbortSignal;\n}\n\nexport interface WalletListResponse {\n data: TransactionItem[];\n next_page_url: string | null;\n}\n\nexport interface WalletListResult {\n items: TransactionItem[];\n next: string | null;\n balance: number;\n}\n\nexport const wallet = {\n list: async (params: WalletListParams = {}): Promise<WalletListResult> => {\n const { page = 1, perPage = 10, signal } = params;\n\n const searchParams = new URLSearchParams();\n searchParams.set('page', String(page));\n searchParams.set('per_page', String(perPage));\n\n const options: Record<string, unknown> = {};\n if (signal) options.signal = signal;\n\n const response = await api\n .get(`balance/wallet?${searchParams.toString()}`, options as any)\n .json<{ data: { transactions: WalletListResponse; balance: number } }>();\n\n const transactions = response.data.transactions;\n\n return {\n items: transactions.data ?? [],\n next: transactions.next_page_url,\n balance: response.data.balance,\n };\n },\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { onSallaEvent } from './chunk-
|
|
1
|
+
import { onSallaEvent } from './chunk-EX4VX4GK.js';
|
|
2
2
|
import { useRenderProbe } from './chunk-T43GL7UN.js';
|
|
3
3
|
import { useState, useCallback, useEffect } from 'react';
|
|
4
4
|
|
|
@@ -18,5 +18,5 @@ function useComments() {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export { useComments };
|
|
21
|
-
//# sourceMappingURL=chunk-
|
|
22
|
-
//# sourceMappingURL=chunk-
|
|
21
|
+
//# sourceMappingURL=chunk-FFHLTFHB.js.map
|
|
22
|
+
//# sourceMappingURL=chunk-FFHLTFHB.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/useComments.ts"],"names":[],"mappings":";;;;AAwCO,SAAS,WAAA,GAAiC;AAC/C,EAAA,cAAA,CAAe,aAAa,CAAA;AAC5B,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,SAAS,CAAC,CAAA;AAEhD,EAAA,MAAM,OAAA,GAAU,YAAY,MAAM;AAChC,IAAA,cAAA,CAAe,CAAC,IAAA,KAAS,IAAA,GAAO,CAAC,CAAA;AAAA,EACnC,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,qBAAqB,MAAM;AAC/B,MAAA,cAAA,CAAe,CAAC,IAAA,KAAS,IAAA,GAAO,CAAC,CAAA;AAAA,IACnC,CAAA;AAEA,IAAA,OAAO,YAAA,CAAa,kBAAkB,kBAAkB,CAAA;AAAA,EAC1D,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO,EAAE,aAAa,OAAA,EAAQ;AAChC","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useComments.ts"],"names":[],"mappings":";;;;AAwCO,SAAS,WAAA,GAAiC;AAC/C,EAAA,cAAA,CAAe,aAAa,CAAA;AAC5B,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,SAAS,CAAC,CAAA;AAEhD,EAAA,MAAM,OAAA,GAAU,YAAY,MAAM;AAChC,IAAA,cAAA,CAAe,CAAC,IAAA,KAAS,IAAA,GAAO,CAAC,CAAA;AAAA,EACnC,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,qBAAqB,MAAM;AAC/B,MAAA,cAAA,CAAe,CAAC,IAAA,KAAS,IAAA,GAAO,CAAC,CAAA;AAAA,IACnC,CAAA;AAEA,IAAA,OAAO,YAAA,CAAa,kBAAkB,kBAAkB,CAAA;AAAA,EAC1D,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO,EAAE,aAAa,OAAA,EAAQ;AAChC","file":"chunk-FFHLTFHB.js","sourcesContent":["import { useState, useEffect, useCallback } from 'react';\nimport { onSallaEvent } from '../utils/sdk-helpers';\nimport { useRenderProbe } from '../utils/render-probe';\n\n/**\n * UseCommentsResult - Return type for useComments hook\n *\n * @property commentsKey - Key to pass to salla-comments component for re-render\n * @property refresh - Function to manually trigger a comments refresh\n */\nexport interface UseCommentsResult {\n commentsKey: number;\n refresh: () => void;\n}\n\n/**\n * useComments - Hook for managing salla-comments web component re-renders\n *\n * Listens to the Salla SDK's comment added events and automatically\n * increments a re-render key for the salla-comments component. This\n * eliminates the need for full page reloads when comments are added.\n *\n * @returns Object with comments key for component re-rendering and manual refresh function\n *\n * @example\n * ```tsx\n * function ProductPage({ product }) {\n * const { commentsKey } = useComments();\n *\n * return (\n * <salla-comments\n * key={commentsKey}\n * item-id={product.id}\n * type=\"product\"\n * />\n * );\n * }\n * ```\n */\n\nexport function useComments(): UseCommentsResult {\n useRenderProbe('useComments');\n const [commentsKey, setCommentsKey] = useState(0);\n\n const refresh = useCallback(() => {\n setCommentsKey((prev) => prev + 1);\n }, []);\n\n useEffect(() => {\n const handleCommentAdded = () => {\n setCommentsKey((prev) => prev + 1);\n };\n\n return onSallaEvent('comment::added', handleCommentAdded);\n }, []);\n\n return { commentsKey, refresh };\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { api } from './chunk-
|
|
1
|
+
import { api } from './chunk-EDSZX3QE.js';
|
|
2
2
|
import { queryOptions } from '@tanstack/react-query';
|
|
3
3
|
|
|
4
4
|
var notification = {
|
|
@@ -24,5 +24,5 @@ var notification = {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
export { notification };
|
|
27
|
-
//# sourceMappingURL=chunk-
|
|
28
|
-
//# sourceMappingURL=chunk-
|
|
27
|
+
//# sourceMappingURL=chunk-GNLXRPBC.js.map
|
|
28
|
+
//# sourceMappingURL=chunk-GNLXRPBC.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/notification.ts"],"names":[],"mappings":";;;AAcO,IAAM,YAAA,GAAe;AAAA,EAC1B,MAAM,YAAgD;AACpD,IAAA,MAAM,WAAW,MAAM,GAAA,CACpB,GAAA,CAAI,eAAe,EACnB,IAAA,EAAmF;AACtF,IAAA,OAAO;AAAA,MACL,IAAA,EAAM,QAAA,CAAS,IAAA,IAAQ,EAAC;AAAA,MACxB,QAAQ,QAAA,CAAS;AAAA,KACnB;AAAA,EACF,CAAA;AAAA,EAEA,UAAA,EAAY,OAAO,EAAA,KAA8B;AAC/C,IAAA,MAAM,IAAI,GAAA,CAAI,CAAA,cAAA,EAAiB,EAAE,CAAA,KAAA,CAAO,EAAE,IAAA,EAAK;AAAA,EACjD,CAAA;AAAA,EAEA,eAAe,YAA2B;AACxC,IAAA,MAAM,GAAA,CAAI,GAAA,CAAI,wBAAwB,CAAA,CAAE,IAAA,EAAK;AAAA,EAC/C,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,IAAA,EAAM,MACJ,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,eAAA,EAAiB,MAAM,CAAA;AAAA,MAClC,OAAA,EAAS,MAAM,YAAA,CAAa,IAAA;AAAK,KAClC;AAAA;AAEP","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/api/notification.ts"],"names":[],"mappings":";;;AAcO,IAAM,YAAA,GAAe;AAAA,EAC1B,MAAM,YAAgD;AACpD,IAAA,MAAM,WAAW,MAAM,GAAA,CACpB,GAAA,CAAI,eAAe,EACnB,IAAA,EAAmF;AACtF,IAAA,OAAO;AAAA,MACL,IAAA,EAAM,QAAA,CAAS,IAAA,IAAQ,EAAC;AAAA,MACxB,QAAQ,QAAA,CAAS;AAAA,KACnB;AAAA,EACF,CAAA;AAAA,EAEA,UAAA,EAAY,OAAO,EAAA,KAA8B;AAC/C,IAAA,MAAM,IAAI,GAAA,CAAI,CAAA,cAAA,EAAiB,EAAE,CAAA,KAAA,CAAO,EAAE,IAAA,EAAK;AAAA,EACjD,CAAA;AAAA,EAEA,eAAe,YAA2B;AACxC,IAAA,MAAM,GAAA,CAAI,GAAA,CAAI,wBAAwB,CAAA,CAAE,IAAA,EAAK;AAAA,EAC/C,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,IAAA,EAAM,MACJ,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,eAAA,EAAiB,MAAM,CAAA;AAAA,MAClC,OAAA,EAAS,MAAM,YAAA,CAAa,IAAA;AAAK,KAClC;AAAA;AAEP","file":"chunk-GNLXRPBC.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\nimport type { Notification } from '../routes/account/notifications/types';\n\nexport interface NotificationsListResponse {\n data: Notification[];\n cursor: {\n current: number;\n previous: number | null;\n next: number | null;\n count: number;\n };\n}\n\nexport const notification = {\n list: async (): Promise<NotificationsListResponse> => {\n const response = await api\n .get('notifications')\n .json<{ data: Notification[] | null; cursor: NotificationsListResponse['cursor'] }>();\n return {\n data: response.data ?? [],\n cursor: response.cursor,\n };\n },\n\n markAsRead: async (id: number): Promise<void> => {\n await api.put(`notifications/${id}/read`).json();\n },\n\n markAllAsRead: async (): Promise<void> => {\n await api.put('notifications/read-all').json();\n },\n\n queries: {\n list: () =>\n queryOptions({\n queryKey: ['notifications', 'list'],\n queryFn: () => notification.list(),\n }),\n },\n};\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parseShortLinkPath } from './chunk-6T7N5FOL.js';
|
|
2
2
|
import { PRODUCT_SLUG_ROUTE_ID, CATEGORY_SLUG_ROUTE_ID } from './chunk-NV4PF3O3.js';
|
|
3
3
|
import { productKeyOfId } from './chunk-SDBR4X3K.js';
|
|
4
|
-
import { redirect, isMissingResource } from './chunk-
|
|
4
|
+
import { redirect, isMissingResource } from './chunk-W3EYJOD3.js';
|
|
5
5
|
import { clearAuthTokenCookie } from './chunk-4OZIBANF.js';
|
|
6
6
|
import { FALLBACK_LOCALE, isLocale } from './chunk-T72DAX7R.js';
|
|
7
7
|
import { useEffect } from 'react';
|
|
@@ -116,7 +116,7 @@ async function twigUrlRedirect(pathname, search, page, options = {}) {
|
|
|
116
116
|
throw redirect(`${locale ? `/${locale}` : ""}${target.path}${search}`, { statusCode: 301 });
|
|
117
117
|
}
|
|
118
118
|
if (!options.queryClient || twigPageUrl(pathname)) return;
|
|
119
|
-
const { customUrlRedirect } = await import('./custom-urls-
|
|
119
|
+
const { customUrlRedirect } = await import('./custom-urls-7JFXAHVF.js');
|
|
120
120
|
await customUrlRedirect(pathname, search, {
|
|
121
121
|
queryClient: options.queryClient,
|
|
122
122
|
targetLocale: options.targetLocale
|
|
@@ -131,5 +131,5 @@ function LogoutRedirect() {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
export { LogoutRedirect, accountRedirectLoader, orderRatingRedirectLoader, pendingOrdersRedirectLoader, productsSourceRedirectLoader, ratingRedirectLoader, slugBrandRedirectLoader, twigUrlRedirect };
|
|
134
|
-
//# sourceMappingURL=chunk-
|
|
135
|
-
//# sourceMappingURL=chunk-
|
|
134
|
+
//# sourceMappingURL=chunk-HCU5GODZ.js.map
|
|
135
|
+
//# sourceMappingURL=chunk-HCU5GODZ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/routes/seo-redirects.ts"],"names":["id"],"mappings":";;;;;;;;AAwBA,eAAsB,wBAAwB,GAAA,EAAkD;AAC9F,EAAA,MAAM,MAAA,GAAS,IAAI,MAAA,CAAO,MAAA,GAAS,IAAI,GAAA,CAAI,MAAA,CAAO,MAAM,CAAA,CAAA,GAAK,EAAA;AAC7D,EAAA,MAAM,QAAA,CAAS,CAAA,EAAG,MAAM,CAAA,QAAA,EAAW,GAAA,CAAI,MAAA,CAAO,EAAE,CAAA,CAAA,EAAI,EAAE,UAAA,EAAY,GAAA,EAAK,CAAA;AACzE;AAOA,eAAsB,4BACpB,GAAA,GAA+C,EAAE,MAAA,EAAQ,IAAG,EAC5C;AAChB,EAAA,MAAM,MAAA,GAAS,GAAA,CAAI,MAAA,CAAO,MAAA,IAAU,eAAA;AACpC,EAAA,MAAM,QAAA,CAAS,CAAA,CAAA,EAAI,MAAM,CAAA,8BAAA,CAAgC,CAAA;AAC3D;AAGA,eAAsB,qBACpB,GAAA,GAA+C,EAAE,MAAA,EAAQ,IAAG,EAC5C;AAChB,EAAA,MAAM,MAAA,GAAS,GAAA,CAAI,MAAA,CAAO,MAAA,IAAU,eAAA;AACpC,EAAA,MAAM,QAAA,CAAS,CAAA,CAAA,EAAI,MAAM,CAAA,eAAA,CAAiB,CAAA;AAC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,CAAA,EAAI,EAAE,UAAA,EAAY,KAAK,CAAA;AAAA,EAC5F;AACA,EAAA,IAAI,CAAC,OAAA,CAAQ,WAAA,IAAe,WAAA,CAAY,QAAQ,CAAA,EAAG;AACnD,EAAA,MAAM,EAAE,iBAAA,EAAkB,GAAI,MAAM,OAAO,2BAAe,CAAA;AAC1D,EAAA,MAAM,iBAAA,CAAkB,UAAU,MAAA,EAAQ;AAAA,IACxC,aAAa,OAAA,CAAQ,WAAA;AAAA,IACrB,cAAc,OAAA,CAAQ;AAAA,GACvB,CAAA;AACH;AAUO,SAAS,cAAA,GAAuB;AACrC,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,oBAAA,EAAqB;AAErB,IAAA,MAAA,CAAO,QAAA,CAAS,QAAQ,MAAA,CAAO,QAAA,CAAS,KAAK,OAAA,CAAQ,8BAAA,EAAgC,EAAE,CAAC,CAAA;AAAA,EAC1F,CAAA,EAAG,EAAE,CAAA;AACL,EAAA,OAAO,IAAA;AACT","file":"chunk-RXJL73PN.js","sourcesContent":["import { useEffect } from 'react';\nimport type { QueryClient } from '@tanstack/react-query';\nimport { isMissingResource, redirect } from '../providers/NavigationProvider';\nimport { FALLBACK_LOCALE, isLocale } from '../providers/locale-constants';\nimport { productKeyOfId } from '../router/product-key-urls';\nimport { CATEGORY_SLUG_ROUTE_ID, PRODUCT_SLUG_ROUTE_ID } from '../router/slug-routes';\nimport { clearAuthTokenCookie } from '../utils/cookies';\nimport { parseShortLinkPath } from './short-link-path';\n\nexport interface SlugBrandParams {\n /** SEO slug segment (ignored — only here to match the route pattern). */\n slug: string;\n /** Brand numeric ID to redirect to. */\n id: string;\n /** Active locale from the `/$locale` parent layout (e.g. `'ar'`, `'en'`). */\n locale?: string;\n}\n\n/**\n * Twig's brand address, `/{slug}/brand-{id}`, the one its pages link and search engines indexed,\n * moved for good to the engine's `/brands/{id}`: a 301, so the brand page keeps its ranking at the\n * new address (a 307 keeps the old one indexed). No locale in the URL stays without one: the\n * locale layout adds it only where the store has several, so a single-language store is one hop.\n */\nexport async function slugBrandRedirectLoader(ctx: { params: SlugBrandParams }): Promise<never> {\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n throw redirect(`${prefix}/brands/${ctx.params.id}`, { statusCode: 301 });\n}\n\nexport interface PendingOrdersRedirectParams {\n /** Active locale from the `/$locale` parent layout (e.g. `'ar'`, `'en'`). */\n locale?: string;\n}\n\nexport async function pendingOrdersRedirectLoader(\n ctx: { params: PendingOrdersRedirectParams } = { params: {} }\n): Promise<never> {\n const locale = ctx.params.locale || FALLBACK_LOCALE;\n throw redirect(`/${locale}/account/orders?status=pending`);\n}\n\n/** `/account/rating`: the loyalty \"rate your orders\" link. Twig Raed has no rating page and sends it to the orders list. */\nexport async function ratingRedirectLoader(\n ctx: { params: PendingOrdersRedirectParams } = { params: {} }\n): Promise<never> {\n const locale = ctx.params.locale || FALLBACK_LOCALE;\n throw redirect(`/${locale}/account/orders`);\n}\n\n/**\n * `/rating/{id}` and `/account/rating/{id}`: the rate-your-order link in the order email and SMS,\n * sent like Twig to the order with its rating popup. The id goes as it came: the orders API\n * decodes it the way Store's `rateOrder` does (optimus when numeric, else the hash).\n */\nexport async function orderRatingRedirectLoader(ctx: {\n params: PendingOrdersRedirectParams & { id: string };\n /** The incoming query string, `token` included: the SDK signs the visitor in with it. */\n search?: string;\n}): Promise<never> {\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n const query = new URLSearchParams(ctx.search);\n query.set('show-rating-popup', 'true');\n throw redirect(`${prefix}/account/orders/${encodeURIComponent(ctx.params.id)}?${query}`);\n}\n\n/** A Twig customer URL (`/profile`, `/orders`, …) kept working as its `/account/…` page. */\nexport async function accountRedirectLoader(ctx: {\n params: PendingOrdersRedirectParams;\n page: string;\n /** The incoming query string (`?status=pending`), kept on the account page. */\n search?: string;\n}): Promise<never> {\n // No locale in the URL stays without one: the locale layout adds it only where the store has several.\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n throw redirect(`${prefix}/account/${ctx.page}${ctx.search ?? ''}`, { statusCode: 301 });\n}\n\n/** `/latest-products`, `/most-sales-products` and `/offers` now live at `/products?source=`. */\nexport async function productsSourceRedirectLoader(ctx: {\n params: PendingOrdersRedirectParams;\n source: 'latest' | 'sales' | 'offers';\n search?: string;\n}): Promise<never> {\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n const query = new URLSearchParams(ctx.search);\n query.delete('source');\n const rest = query.toString();\n throw redirect(`${prefix}/products?source=${ctx.source}${rest ? `&${rest}` : ''}`, {\n statusCode: 301,\n });\n}\n\nexport { resolveProductKeyPage } from './product/key';\nexport { publicProductKeyPath } from '../router/product-key-urls';\n\n/** Routes a Twig URL lands on by accident: a locale bound as `$slug`, or an id that is no number. */\nconst SLUG_ROUTES = new Set([PRODUCT_SLUG_ROUTE_ID, CATEGORY_SLUG_ROUTE_ID]);\n\n/** `/p{id}` or `/p{id}-{name}`, with or without a leading segment; the id capped as in `./product/id`. */\nconst TWIG_PRODUCT_URL = /^(?:\\/([^/]+))?\\/p(\\d{1,18})(?:-[^/]*)?\\/?$/;\n/** `/category/{hash}`, with or without a leading segment. */\nconst TWIG_CATEGORY_URL = /^(?:\\/([^/]+))?\\/category\\/([A-Za-z0-9]+)\\/?$/;\n/**\n * `/p/{slug}`, with or without a leading segment: Twig's page address (`PageController@show`), the\n * one a store without SEO URLs lists in its sitemap. Twig renders it there, or 301s it to the page's\n * `/{slug}/page-{id}` on a store with SEO URLs.\n */\nconst TWIG_PAGE_URL = /^(?:\\/([^/]+))?\\/p\\/([^/]+)\\/?$/;\n\n/** The page the router matched, as the locale layout's `beforeLoad` sees it. */\nexport interface MatchedPage {\n routeId: string;\n params: Record<string, string | undefined>;\n}\n\nfunction rendersNoPage({ routeId, params }: MatchedPage): boolean {\n // A first segment that is no language binds as the locale, of the layout or of the home page.\n if (routeId === '/{-$locale}' || (params.locale && !isLocale(params.locale))) return true;\n if (!SLUG_ROUTES.has(routeId)) return false;\n // A SKU-link address the router's rewrite gave the product route (`router/product-key-urls`).\n if (productKeyOfId(params.id)) return false;\n return (!params.locale && isLocale(params.slug)) || !/^\\d+$/.test(params.id ?? '');\n}\n\nexport interface TwigUrlRedirectOptions {\n /**\n * The language segment the target takes, given the one the address had. The locale layout\n * knows how the store addresses its pages, so the redirect lands there in one hop: `/-/p1`\n * on a store with several languages was sent on again to `/ar/-/p1`, and that second request\n * also fetched the product, because the server starts every loader at once. Without it the\n * address's own segment is kept.\n */\n targetLocale?: (addressLocale: string | undefined) => Promise<string | undefined>;\n /**\n * The request's query client. The category lookup is then shared between a hover preload and\n * the click.\n */\n queryClient?: QueryClient;\n}\n\n/** The category's numeric id for its Twig hash, or `undefined` when the API has no such category. */\nasync function categoryIdOf(hash: string, queryClient?: QueryClient): Promise<string | undefined> {\n const { category } = await import('../api/category');\n try {\n const found = queryClient\n ? await queryClient.ensureQueryData(category.queries.detail(hash))\n : await category.find(hash);\n // Only the id is taken. The category is never filed under its id for the category page:\n // this lookup ran in the address's language (Arabic when it has none, the fallback), and\n // the page may be in another (`/en/-/c…` on an English-only store), while a category's\n // cache key carries no language.\n return String(found.id_ ?? found.id);\n } catch (error) {\n if (isMissingResource(error)) return undefined;\n throw error;\n }\n}\n\n/**\n * The product id behind a short link (`/KjQrpE`). A store without SEO URLs gives every product\n * that address, in its sitemap and in the API's `url`, and the API takes the code in place of\n * the id. Any failure counts as \"no such product\": a bare `/{code}` is also every scanner's\n * `/admin`, so an API error must not turn those into 500s. The not-found page's\n * `useProductShortLink` asks again from the browser, as it did before.\n */\nasync function shortLinkProductId(\n code: string,\n queryClient?: QueryClient\n): Promise<string | undefined> {\n const { product } = await import('../api/product');\n try {\n const found = queryClient\n ? await queryClient.ensureQueryData(product.queries.detail(code))\n : await product.find(code);\n return found?.id ? String(found.id) : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** A slug as Twig compares it: decoded, trimmed, case aside. */\nfunction comparableSlug(slug: string): string {\n let decoded = slug;\n try {\n decoded = decodeURIComponent(slug);\n } catch {\n // Not percent-encoded as a whole: compared as it came.\n }\n return decoded.trim().toLowerCase();\n}\n\n/**\n * The address of the page Twig calls `/p/{slug}`, found in the store's page list by its slug (the\n * page API takes only an id). Any failure counts as \"no such page\", as for a short link: the\n * address then stays the not-found page, after the merchant's custom URLs are asked.\n */\nasync function legacyPagePath(\n slug: string,\n queryClient?: QueryClient\n): Promise<string | undefined> {\n const { page } = await import('../api/page');\n try {\n const pages = queryClient\n ? await queryClient.ensureQueryData(page.queries.list())\n : await page.list();\n const wanted = comparableSlug(slug);\n const found = pages.find((listed) => listed.slug && comparableSlug(listed.slug) === wanted);\n return found ? `/${encodeURIComponent(found.slug.trim())}/page-${found.id}` : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** Where a Twig URL's page is now, and the language its address carried. */\n/**\n * A Twig product or category URL: `/p{id}…` or `/category/{hash}`, bare or under a language. Under\n * any other first segment it is no Twig route, so the Store's catch-all would have it.\n */\nfunction twigPageUrl(\n pathname: string\n): { kind: 'p' | 'c'; ref: string; locale?: string } | undefined {\n const productUrl = TWIG_PRODUCT_URL.exec(pathname);\n const match = productUrl ?? TWIG_CATEGORY_URL.exec(pathname);\n if (!match || (match[1] && !isLocale(match[1]))) return undefined;\n return { kind: productUrl ? 'p' : 'c', ref: match[2], locale: match[1] };\n}\n\nasync function twigTarget(\n pathname: string,\n queryClient?: QueryClient\n): Promise<{ path: string; locale?: string } | undefined> {\n const pageUrl = twigPageUrl(pathname);\n if (pageUrl) {\n if (pageUrl.kind === 'p') return { path: `/-/p${pageUrl.ref}`, locale: pageUrl.locale };\n const id = await categoryIdOf(pageUrl.ref, queryClient);\n return id ? { path: `/-/c${id}`, locale: pageUrl.locale } : undefined;\n }\n const legacyPage = TWIG_PAGE_URL.exec(pathname);\n if (legacyPage && (!legacyPage[1] || isLocale(legacyPage[1]))) {\n const path = await legacyPagePath(legacyPage[2], queryClient);\n return path ? { path, locale: legacyPage[1] } : undefined;\n }\n const shortLink = parseShortLinkPath(pathname);\n if (!shortLink) return undefined;\n const id = await shortLinkProductId(shortLink.code, queryClient);\n return id ? { path: `/-/p${id}`, locale: shortLink.locale } : undefined;\n}\n\n/**\n * Twig's product, category and page URLs, each with or without a locale, sent to the page that\n * has them now: `/p{id}`, `/p{id}-{name}`, `/category/{hash}`, the product short link `/{code}` and\n * a page's `/p/{slug}`.\n * Run by the locale layout's `beforeLoad`, only for an address no page answers: the router binds\n * `/ar/p1` to `$slug/p{$id}` (slug `ar`) and `/p1` to the locale.\n *\n * A product URL carries its id, so it is redirected without asking the API: a product that is\n * gone is the product page's not-found, one hop on. A category hash or a short code only the API\n * can turn into the id; one that is gone stays the not-found page at its address.\n *\n * Any other address no page answers, a short code that names no product included, may be one of\n * the merchant's custom URLs, which Twig's catch-all answers last (`./custom-urls`). A gone\n * category's Twig URL is not: Twig's category route answers it.\n */\nexport async function twigUrlRedirect(\n pathname: string,\n search: string,\n page: MatchedPage | undefined,\n options: TwigUrlRedirectOptions = {}\n): Promise<void> {\n if (!page || !rendersNoPage(page)) return;\n const target = await twigTarget(pathname, options.queryClient);\n if (target) {\n const locale = options.targetLocale ? await options.targetLocale(target.locale) : target.locale;\n throw redirect(`${locale ? `/${locale}` : ''}${target.path}${search}`, { statusCode: 301 });\n }\n if (!options.queryClient || twigPageUrl(pathname)) return;\n const { customUrlRedirect } = await import('./custom-urls');\n await customUrlRedirect(pathname, search, {\n queryClient: options.queryClient,\n targetLocale: options.targetLocale,\n });\n}\n\n/**\n * `/logout` — where the SDK sends the browser once `salla.auth.logout()` has run\n * (`salla.url.get('logout?from=…')`). The Twig storefront serves that URL server-side. Here\n * it renders nothing and, in the browser, removes the theme's own `token` cookie (the SDK's\n * `cookie.clearAll()` leaves it) and then does a full navigation home. It has to be a\n * component, not a loader redirect: a loader runs during server rendering, where the cookie\n * can't be cleared, so the redirect would leave the visitor signed in on the next request.\n */\nexport function LogoutRedirect(): null {\n useEffect(() => {\n clearAuthTokenCookie();\n // `/{store base}/{locale}/logout?from=…` → `/{store base}/{locale}`\n window.location.replace(window.location.href.replace(/\\/logout\\/?(\\?[^#]*)?(#.*)?$/, ''));\n }, []);\n return null;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/routes/seo-redirects.ts"],"names":["id"],"mappings":";;;;;;;;AAwBA,eAAsB,wBAAwB,GAAA,EAAkD;AAC9F,EAAA,MAAM,MAAA,GAAS,IAAI,MAAA,CAAO,MAAA,GAAS,IAAI,GAAA,CAAI,MAAA,CAAO,MAAM,CAAA,CAAA,GAAK,EAAA;AAC7D,EAAA,MAAM,QAAA,CAAS,CAAA,EAAG,MAAM,CAAA,QAAA,EAAW,GAAA,CAAI,MAAA,CAAO,EAAE,CAAA,CAAA,EAAI,EAAE,UAAA,EAAY,GAAA,EAAK,CAAA;AACzE;AAOA,eAAsB,4BACpB,GAAA,GAA+C,EAAE,MAAA,EAAQ,IAAG,EAC5C;AAChB,EAAA,MAAM,MAAA,GAAS,GAAA,CAAI,MAAA,CAAO,MAAA,IAAU,eAAA;AACpC,EAAA,MAAM,QAAA,CAAS,CAAA,CAAA,EAAI,MAAM,CAAA,8BAAA,CAAgC,CAAA;AAC3D;AAGA,eAAsB,qBACpB,GAAA,GAA+C,EAAE,MAAA,EAAQ,IAAG,EAC5C;AAChB,EAAA,MAAM,MAAA,GAAS,GAAA,CAAI,MAAA,CAAO,MAAA,IAAU,eAAA;AACpC,EAAA,MAAM,QAAA,CAAS,CAAA,CAAA,EAAI,MAAM,CAAA,eAAA,CAAiB,CAAA;AAC5C;AAOA,eAAsB,0BAA0B,GAAA,EAI7B;AACjB,EAAA,MAAM,MAAA,GAAS,IAAI,MAAA,CAAO,MAAA,GAAS,IAAI,GAAA,CAAI,MAAA,CAAO,MAAM,CAAA,CAAA,GAAK,EAAA;AAC7D,EAAA,MAAM,KAAA,GAAQ,IAAI,eAAA,CAAgB,GAAA,CAAI,MAAM,CAAA;AAC5C,EAAA,KAAA,CAAM,GAAA,CAAI,qBAAqB,MA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CAAQ,WAAA;AAAA,IACrB,cAAc,OAAA,CAAQ;AAAA,GACvB,CAAA;AACH;AAUO,SAAS,cAAA,GAAuB;AACrC,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,oBAAA,EAAqB;AAErB,IAAA,MAAA,CAAO,QAAA,CAAS,QAAQ,MAAA,CAAO,QAAA,CAAS,KAAK,OAAA,CAAQ,8BAAA,EAAgC,EAAE,CAAC,CAAA;AAAA,EAC1F,CAAA,EAAG,EAAE,CAAA;AACL,EAAA,OAAO,IAAA;AACT","file":"chunk-HCU5GODZ.js","sourcesContent":["import { useEffect } from 'react';\nimport type { QueryClient } from '@tanstack/react-query';\nimport { isMissingResource, redirect } from '../providers/NavigationProvider';\nimport { FALLBACK_LOCALE, isLocale } from '../providers/locale-constants';\nimport { productKeyOfId } from '../router/product-key-urls';\nimport { CATEGORY_SLUG_ROUTE_ID, PRODUCT_SLUG_ROUTE_ID } from '../router/slug-routes';\nimport { clearAuthTokenCookie } from '../utils/cookies';\nimport { parseShortLinkPath } from './short-link-path';\n\nexport interface SlugBrandParams {\n /** SEO slug segment (ignored — only here to match the route pattern). */\n slug: string;\n /** Brand numeric ID to redirect to. */\n id: string;\n /** Active locale from the `/$locale` parent layout (e.g. `'ar'`, `'en'`). */\n locale?: string;\n}\n\n/**\n * Twig's brand address, `/{slug}/brand-{id}`, the one its pages link and search engines indexed,\n * moved for good to the engine's `/brands/{id}`: a 301, so the brand page keeps its ranking at the\n * new address (a 307 keeps the old one indexed). No locale in the URL stays without one: the\n * locale layout adds it only where the store has several, so a single-language store is one hop.\n */\nexport async function slugBrandRedirectLoader(ctx: { params: SlugBrandParams }): Promise<never> {\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n throw redirect(`${prefix}/brands/${ctx.params.id}`, { statusCode: 301 });\n}\n\nexport interface PendingOrdersRedirectParams {\n /** Active locale from the `/$locale` parent layout (e.g. `'ar'`, `'en'`). */\n locale?: string;\n}\n\nexport async function pendingOrdersRedirectLoader(\n ctx: { params: PendingOrdersRedirectParams } = { params: {} }\n): Promise<never> {\n const locale = ctx.params.locale || FALLBACK_LOCALE;\n throw redirect(`/${locale}/account/orders?status=pending`);\n}\n\n/** `/account/rating`: the loyalty \"rate your orders\" link. Twig Raed has no rating page and sends it to the orders list. */\nexport async function ratingRedirectLoader(\n ctx: { params: PendingOrdersRedirectParams } = { params: {} }\n): Promise<never> {\n const locale = ctx.params.locale || FALLBACK_LOCALE;\n throw redirect(`/${locale}/account/orders`);\n}\n\n/**\n * `/rating/{id}` and `/account/rating/{id}`: the rate-your-order link in the order email and SMS,\n * sent like Twig to the order with its rating popup. The id goes as it came: the orders API\n * decodes it the way Store's `rateOrder` does (optimus when numeric, else the hash).\n */\nexport async function orderRatingRedirectLoader(ctx: {\n params: PendingOrdersRedirectParams & { id: string };\n /** The incoming query string, `token` included: the SDK signs the visitor in with it. */\n search?: string;\n}): Promise<never> {\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n const query = new URLSearchParams(ctx.search);\n query.set('show-rating-popup', 'true');\n throw redirect(`${prefix}/account/orders/${encodeURIComponent(ctx.params.id)}?${query}`);\n}\n\n/** A Twig customer URL (`/profile`, `/orders`, …) kept working as its `/account/…` page. */\nexport async function accountRedirectLoader(ctx: {\n params: PendingOrdersRedirectParams;\n page: string;\n /** The incoming query string (`?status=pending`), kept on the account page. */\n search?: string;\n}): Promise<never> {\n // No locale in the URL stays without one: the locale layout adds it only where the store has several.\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n throw redirect(`${prefix}/account/${ctx.page}${ctx.search ?? ''}`, { statusCode: 301 });\n}\n\n/** `/latest-products`, `/most-sales-products` and `/offers` now live at `/products?source=`. */\nexport async function productsSourceRedirectLoader(ctx: {\n params: PendingOrdersRedirectParams;\n source: 'latest' | 'sales' | 'offers';\n search?: string;\n}): Promise<never> {\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n const query = new URLSearchParams(ctx.search);\n query.delete('source');\n const rest = query.toString();\n throw redirect(`${prefix}/products?source=${ctx.source}${rest ? `&${rest}` : ''}`, {\n statusCode: 301,\n });\n}\n\nexport { resolveProductKeyPage } from './product/key';\nexport { publicProductKeyPath } from '../router/product-key-urls';\n\n/** Routes a Twig URL lands on by accident: a locale bound as `$slug`, or an id that is no number. */\nconst SLUG_ROUTES = new Set([PRODUCT_SLUG_ROUTE_ID, CATEGORY_SLUG_ROUTE_ID]);\n\n/** `/p{id}` or `/p{id}-{name}`, with or without a leading segment; the id capped as in `./product/id`. */\nconst TWIG_PRODUCT_URL = /^(?:\\/([^/]+))?\\/p(\\d{1,18})(?:-[^/]*)?\\/?$/;\n/** `/category/{hash}`, with or without a leading segment. */\nconst TWIG_CATEGORY_URL = /^(?:\\/([^/]+))?\\/category\\/([A-Za-z0-9]+)\\/?$/;\n/**\n * `/p/{slug}`, with or without a leading segment: Twig's page address (`PageController@show`), the\n * one a store without SEO URLs lists in its sitemap. Twig renders it there, or 301s it to the page's\n * `/{slug}/page-{id}` on a store with SEO URLs.\n */\nconst TWIG_PAGE_URL = /^(?:\\/([^/]+))?\\/p\\/([^/]+)\\/?$/;\n\n/** The page the router matched, as the locale layout's `beforeLoad` sees it. */\nexport interface MatchedPage {\n routeId: string;\n params: Record<string, string | undefined>;\n}\n\nfunction rendersNoPage({ routeId, params }: MatchedPage): boolean {\n // A first segment that is no language binds as the locale, of the layout or of the home page.\n if (routeId === '/{-$locale}' || (params.locale && !isLocale(params.locale))) return true;\n if (!SLUG_ROUTES.has(routeId)) return false;\n // A SKU-link address the router's rewrite gave the product route (`router/product-key-urls`).\n if (productKeyOfId(params.id)) return false;\n return (!params.locale && isLocale(params.slug)) || !/^\\d+$/.test(params.id ?? '');\n}\n\nexport interface TwigUrlRedirectOptions {\n /**\n * The language segment the target takes, given the one the address had. The locale layout\n * knows how the store addresses its pages, so the redirect lands there in one hop: `/-/p1`\n * on a store with several languages was sent on again to `/ar/-/p1`, and that second request\n * also fetched the product, because the server starts every loader at once. Without it the\n * address's own segment is kept.\n */\n targetLocale?: (addressLocale: string | undefined) => Promise<string | undefined>;\n /**\n * The request's query client. The category lookup is then shared between a hover preload and\n * the click.\n */\n queryClient?: QueryClient;\n}\n\n/** The category's numeric id for its Twig hash, or `undefined` when the API has no such category. */\nasync function categoryIdOf(hash: string, queryClient?: QueryClient): Promise<string | undefined> {\n const { category } = await import('../api/category');\n try {\n const found = queryClient\n ? await queryClient.ensureQueryData(category.queries.detail(hash))\n : await category.find(hash);\n // Only the id is taken. The category is never filed under its id for the category page:\n // this lookup ran in the address's language (Arabic when it has none, the fallback), and\n // the page may be in another (`/en/-/c…` on an English-only store), while a category's\n // cache key carries no language.\n return String(found.id_ ?? found.id);\n } catch (error) {\n if (isMissingResource(error)) return undefined;\n throw error;\n }\n}\n\n/**\n * The product id behind a short link (`/KjQrpE`). A store without SEO URLs gives every product\n * that address, in its sitemap and in the API's `url`, and the API takes the code in place of\n * the id. Any failure counts as \"no such product\": a bare `/{code}` is also every scanner's\n * `/admin`, so an API error must not turn those into 500s. The not-found page's\n * `useProductShortLink` asks again from the browser, as it did before.\n */\nasync function shortLinkProductId(\n code: string,\n queryClient?: QueryClient\n): Promise<string | undefined> {\n const { product } = await import('../api/product');\n try {\n const found = queryClient\n ? await queryClient.ensureQueryData(product.queries.detail(code))\n : await product.find(code);\n return found?.id ? String(found.id) : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** A slug as Twig compares it: decoded, trimmed, case aside. */\nfunction comparableSlug(slug: string): string {\n let decoded = slug;\n try {\n decoded = decodeURIComponent(slug);\n } catch {\n // Not percent-encoded as a whole: compared as it came.\n }\n return decoded.trim().toLowerCase();\n}\n\n/**\n * The address of the page Twig calls `/p/{slug}`, found in the store's page list by its slug (the\n * page API takes only an id). Any failure counts as \"no such page\", as for a short link: the\n * address then stays the not-found page, after the merchant's custom URLs are asked.\n */\nasync function legacyPagePath(\n slug: string,\n queryClient?: QueryClient\n): Promise<string | undefined> {\n const { page } = await import('../api/page');\n try {\n const pages = queryClient\n ? await queryClient.ensureQueryData(page.queries.list())\n : await page.list();\n const wanted = comparableSlug(slug);\n const found = pages.find((listed) => listed.slug && comparableSlug(listed.slug) === wanted);\n return found ? `/${encodeURIComponent(found.slug.trim())}/page-${found.id}` : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** Where a Twig URL's page is now, and the language its address carried. */\n/**\n * A Twig product or category URL: `/p{id}…` or `/category/{hash}`, bare or under a language. Under\n * any other first segment it is no Twig route, so the Store's catch-all would have it.\n */\nfunction twigPageUrl(\n pathname: string\n): { kind: 'p' | 'c'; ref: string; locale?: string } | undefined {\n const productUrl = TWIG_PRODUCT_URL.exec(pathname);\n const match = productUrl ?? TWIG_CATEGORY_URL.exec(pathname);\n if (!match || (match[1] && !isLocale(match[1]))) return undefined;\n return { kind: productUrl ? 'p' : 'c', ref: match[2], locale: match[1] };\n}\n\nasync function twigTarget(\n pathname: string,\n queryClient?: QueryClient\n): Promise<{ path: string; locale?: string } | undefined> {\n const pageUrl = twigPageUrl(pathname);\n if (pageUrl) {\n if (pageUrl.kind === 'p') return { path: `/-/p${pageUrl.ref}`, locale: pageUrl.locale };\n const id = await categoryIdOf(pageUrl.ref, queryClient);\n return id ? { path: `/-/c${id}`, locale: pageUrl.locale } : undefined;\n }\n const legacyPage = TWIG_PAGE_URL.exec(pathname);\n if (legacyPage && (!legacyPage[1] || isLocale(legacyPage[1]))) {\n const path = await legacyPagePath(legacyPage[2], queryClient);\n return path ? { path, locale: legacyPage[1] } : undefined;\n }\n const shortLink = parseShortLinkPath(pathname);\n if (!shortLink) return undefined;\n const id = await shortLinkProductId(shortLink.code, queryClient);\n return id ? { path: `/-/p${id}`, locale: shortLink.locale } : undefined;\n}\n\n/**\n * Twig's product, category and page URLs, each with or without a locale, sent to the page that\n * has them now: `/p{id}`, `/p{id}-{name}`, `/category/{hash}`, the product short link `/{code}` and\n * a page's `/p/{slug}`.\n * Run by the locale layout's `beforeLoad`, only for an address no page answers: the router binds\n * `/ar/p1` to `$slug/p{$id}` (slug `ar`) and `/p1` to the locale.\n *\n * A product URL carries its id, so it is redirected without asking the API: a product that is\n * gone is the product page's not-found, one hop on. A category hash or a short code only the API\n * can turn into the id; one that is gone stays the not-found page at its address.\n *\n * Any other address no page answers, a short code that names no product included, may be one of\n * the merchant's custom URLs, which Twig's catch-all answers last (`./custom-urls`). A gone\n * category's Twig URL is not: Twig's category route answers it.\n */\nexport async function twigUrlRedirect(\n pathname: string,\n search: string,\n page: MatchedPage | undefined,\n options: TwigUrlRedirectOptions = {}\n): Promise<void> {\n if (!page || !rendersNoPage(page)) return;\n const target = await twigTarget(pathname, options.queryClient);\n if (target) {\n const locale = options.targetLocale ? await options.targetLocale(target.locale) : target.locale;\n throw redirect(`${locale ? `/${locale}` : ''}${target.path}${search}`, { statusCode: 301 });\n }\n if (!options.queryClient || twigPageUrl(pathname)) return;\n const { customUrlRedirect } = await import('./custom-urls');\n await customUrlRedirect(pathname, search, {\n queryClient: options.queryClient,\n targetLocale: options.targetLocale,\n });\n}\n\n/**\n * `/logout` — where the SDK sends the browser once `salla.auth.logout()` has run\n * (`salla.url.get('logout?from=…')`). The Twig storefront serves that URL server-side. Here\n * it renders nothing and, in the browser, removes the theme's own `token` cookie (the SDK's\n * `cookie.clearAll()` leaves it) and then does a full navigation home. It has to be a\n * component, not a loader redirect: a loader runs during server rendering, where the cookie\n * can't be cleared, so the redirect would leave the visitor signed in on the next request.\n */\nexport function LogoutRedirect(): null {\n useEffect(() => {\n clearAuthTokenCookie();\n // `/{store base}/{locale}/logout?from=…` → `/{store base}/{locale}`\n window.location.replace(window.location.href.replace(/\\/logout\\/?(\\?[^#]*)?(#.*)?$/, ''));\n }, []);\n return null;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GTM_PAGE_DATA_WAIT_MS, whenGtmPageData } from './chunk-
|
|
2
|
-
import { DATA_LAYER_PROXY_SCRIPT } from './chunk-
|
|
1
|
+
import { GTM_PAGE_DATA_WAIT_MS, whenGtmPageData } from './chunk-LM7Y7MG4.js';
|
|
2
|
+
import { DATA_LAYER_PROXY_SCRIPT } from './chunk-LD7EYT7B.js';
|
|
3
3
|
import { useEffect } from 'react';
|
|
4
4
|
|
|
5
5
|
function containerScript(gtmId) {
|
|
@@ -63,5 +63,5 @@ function GoogleTagBody({ gtmIds }) {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
export { GTM_LOAD_DELAY_MS, GoogleTagBody };
|
|
66
|
-
//# sourceMappingURL=chunk-
|
|
67
|
-
//# sourceMappingURL=chunk-
|
|
66
|
+
//# sourceMappingURL=chunk-HI7SDG3R.js.map
|
|
67
|
+
//# sourceMappingURL=chunk-HI7SDG3R.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/tracking/GoogleTag.tsx"],"names":[],"mappings":";;;;AAUA,SAAS,gBAAgB,KAAA,EAAuB;AAC9C,EAAA,OAAO,CAAA;AAAA;AAAA;AAAA;AAAA,wCAAA,EAIiC,IAAA,CAAK,SAAA,CAAU,KAAK,CAAC,CAAA,EAAA,CAAA;AAC/D;AAGA,SAAS,UAAU,MAAA,EAAmC;AACpD,EAAA,OAAO,CAAC,yBAAyB,GAAG,MAAA,CAAO,IAAI,eAAe,CAAC,CAAA,CAAE,IAAA,CAAK,IAAI,CAAA;AAC5E;AAEA,IAAM,qBAAqB,CAAC,aAAA,EAAe,SAAA,EAAW,YAAA,EAAc,UAAU,OAAO,CAAA;AAG9E,IAAM,iBAAA,GAAoB;AAGjC,SAAS,aAAa,MAAA,EAAiD;AACrE,EAAA,OAAO,CAAC,GAAG,IAAI,GAAA,CAAA,CAAK,MAAA,IAAU,EAAC,EAAG,GAAA,CAAI,CAAC,EAAA,KAAO,IAAI,IAAA,EAAM,EAAE,MAAA,CAAO,OAAO,CAAC,CAAC,CAAA;AAC5E;AAMO,SAAS,aAAA,CAAc,EAAE,MAAA,EAAO,EAA6B;AAClE,EAAA,MAAM,GAAA,GA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AA,CAAW,MAAA,EAAQ,qBAAqB,CAAA;AAC/D,MAAA,KAAK,eAAA,EAAgB,CAAE,IAAA,CAAK,MAAM,CAAA;AAAA,IACpC;AACA,IAAA,SAAS,MAAA,GAAS;AAChB,MAAA,KAAA,GAAQ,MAAA,CAAO,UAAA,CAAW,MAAA,EAAQ,iBAAiB,CAAA;AAAA,IACrD;AAEA,IAAA,kBAAA,CAAmB,OAAA;AAAA,MAAQ,CAAC,IAAA,KAC1B,MAAA,CAAO,gBAAA,CAAiB,IAAA,EAAM,MAAA,EAAQ,EAAE,IAAA,EAAM,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM;AAAA,KACrE;AACA,IAAA,IAAI,QAAA,CAAS,UAAA,KAAe,UAAA,EAAY,MAAA,EAAO;AAAA,gBACnC,gBAAA,CAAiB,MAAA,EAAQ,QAAQ,EAAE,IAAA,EAAM,MAAM,CAAA;AAE3D,IAAA,OAAO,MAAM;AACX,MAAA,SAAA,GAAY,IAAA;AACZ,MAAA,WAAA,EAAY;AACZ,MAAA,MAAA,CAAO,aAAa,aAAa,CAAA;AACjC,MAAA,QAAA,CAAS,cAAA,CAAe,YAAY,CAAA,EAAG,MAAA,EAAO;AAAA,IAChD,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,MAAM,CAAC,CAAA;AAEX,EAAA,OAAO,IAAA;AACT","file":"chunk-HI7SDG3R.js","sourcesContent":["import { useEffect } from 'react';\nimport { DATA_LAYER_PROXY_SCRIPT } from '../../lib/analytics/gtm';\nimport { GTM_PAGE_DATA_WAIT_MS, whenGtmPageData } from '../../lib/analytics/gtm-page';\n\nexport interface GoogleTagBodyProps {\n /** GTM container IDs; every one is loaded, as on Twig. Empty or missing renders nothing. */\n gtmIds?: string[];\n}\n\n/** One container's loader, Google's snippet. */\nfunction containerScript(gtmId: string): string {\n return `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\nnew Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\nj=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);\n})(window,document,'script','dataLayer',${JSON.stringify(gtmId)});`;\n}\n\n/** Every container, in the settings' order: Salla's first, then the merchant's own. */\nfunction gtmScript(gtmIds: readonly string[]): string {\n return [DATA_LAYER_PROXY_SCRIPT, ...gtmIds.map(containerScript)].join('\\n');\n}\n\nconst INTERACTION_EVENTS = ['pointerdown', 'keydown', 'touchstart', 'scroll', 'wheel'] as const;\n\n/** How long after `load` GTM waits for a visitor who never interacts. */\nexport const GTM_LOAD_DELAY_MS = 4000;\n\n/** Distinct container ids, in order. */\nfunction containerIds(gtmIds: readonly string[] | undefined): string[] {\n return [...new Set((gtmIds ?? []).map((id) => id?.trim()).filter(Boolean))];\n}\n\n/**\n * Injects GTM on the first interaction or GTM_LOAD_DELAY_MS after `load`, off the page's load\n * path, once the first page's data is in the data layer (at most GTM_PAGE_DATA_WAIT_MS later).\n */\nexport function GoogleTagBody({ gtmIds }: GoogleTagBodyProps): null {\n const ids = containerIds(gtmIds);\n const idsKey = ids.join(',');\n\n useEffect(() => {\n const containers = idsKey ? idsKey.split(',') : [];\n if (!containers.length) return;\n\n let timer: number | undefined;\n let pageDataTimer: number | undefined;\n let cancelled = false;\n const stopWaiting = () => {\n window.clearTimeout(timer);\n window.removeEventListener('load', onLoad);\n INTERACTION_EVENTS.forEach((type) => window.removeEventListener(type, inject));\n };\n function append() {\n window.clearTimeout(pageDataTimer);\n if (cancelled || document.getElementById('gtm-script')) return;\n const script = document.createElement('script');\n script.id = 'gtm-script';\n script.textContent = gtmScript(containers);\n document.head.appendChild(script);\n }\n function inject() {\n stopWaiting();\n // A container's tags read the page's data when `gtm.js` fires, as on Twig.\n pageDataTimer = window.setTimeout(append, GTM_PAGE_DATA_WAIT_MS);\n void whenGtmPageData().then(append);\n }\n function onLoad() {\n timer = window.setTimeout(inject, GTM_LOAD_DELAY_MS);\n }\n\n INTERACTION_EVENTS.forEach((type) =>\n window.addEventListener(type, inject, { once: true, passive: true })\n );\n if (document.readyState === 'complete') onLoad();\n else window.addEventListener('load', onLoad, { once: true });\n\n return () => {\n cancelled = true;\n stopWaiting();\n window.clearTimeout(pageDataTimer);\n document.getElementById('gtm-script')?.remove();\n };\n }, [idsKey]);\n\n return null;\n}\n"]}
|
|
@@ -2,7 +2,7 @@ import { registry } from './chunk-Y32RHCOH.js';
|
|
|
2
2
|
import { useTranslation } from './chunk-TYNZ5B2B.js';
|
|
3
3
|
import { Image } from './chunk-IVO6YRRK.js';
|
|
4
4
|
import { LazyImageModal } from './chunk-TVL6UBN2.js';
|
|
5
|
-
import { isNativeApp } from './chunk-
|
|
5
|
+
import { isNativeApp } from './chunk-BO4WTPCA.js';
|
|
6
6
|
import { useTwilight } from './chunk-3VFOVWOE.js';
|
|
7
7
|
import { lazyComponent } from './chunk-TLHZBTPZ.js';
|
|
8
8
|
import { useRenderProbe } from './chunk-T43GL7UN.js';
|
|
@@ -12,10 +12,10 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
12
12
|
|
|
13
13
|
// src/components/product/lazy.ts
|
|
14
14
|
var LazyProductDetails = lazyComponent(
|
|
15
|
-
() => import('./ProductDetails-
|
|
15
|
+
() => import('./ProductDetails-F35CZZCU.js').then((m) => ({ default: m.ProductDetails }))
|
|
16
16
|
);
|
|
17
17
|
var LazyAddToCartForm = lazyComponent(
|
|
18
|
-
() => import('./AddToCartForm-
|
|
18
|
+
() => import('./AddToCartForm-N4MMD6VL.js').then((m) => ({ default: m.AddToCartForm }))
|
|
19
19
|
);
|
|
20
20
|
var PRODUCT_GALLERY_KEY = "product:gallery";
|
|
21
21
|
function legacyGalleryMedia(images) {
|
|
@@ -204,5 +204,5 @@ function ThumbSlide({ image, index }) {
|
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
export { LazyAddToCartForm, LazyProductDetails, ProductGallery };
|
|
207
|
-
//# sourceMappingURL=chunk-
|
|
208
|
-
//# sourceMappingURL=chunk-
|
|
207
|
+
//# sourceMappingURL=chunk-IAGMA4A4.js.map
|
|
208
|
+
//# sourceMappingURL=chunk-IAGMA4A4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/product/lazy.ts","../src/components/product/ProductGallery.tsx"],"names":[],"mappings":";;;;;;;;;;;;;AAEO,IAAM,kBAAA,GAAqB,aAAA;AAAA,EAAc,MAC9C,OAAO,8BAAkB,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,cAAA,EAAe,CAAE;AACxE;AAEO,IAAM,iBAAA,GAAoB,aAAA;AAAA,EAAc,MAC7C,OAAO,6BAAiB,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,aAAA,EAAc,CAAE;AACtE;ACGA,IAAM,mBAAA,GAAsB,iBAAA;AAc5B,SAAS,mBAAmB,MAAA,EAAwC;AAClE,EAAA,OAAO,MAAA,CAAO,OAAA,CAAsB,CAAC,KAAA,KAAU;AAC7C,IAAA,IAAI,KAAA,CAAM,iBAAA,EAAmB,OAAO,CAAC,EAAE,KAAK,KAAA,CAAM,iBAAA,EAAmB,IAAA,EAAM,UAAA,EAAY,CAAA;AACvF,IAAA,IAAI,KAAA,CAAM,SAAA,EAAW,OAAO,CAAC,EAAE,KAAK,KAAA,CAAM,SAAA,EAAW,IAAA,EAAM,OAAA,EAAS,CAAA;AACpE,IAAA,OAAO,KAAA,CAAM,GAAA,GAAM,CAAC,EAAE,GAAA,EAAK,KAAA,CAAM,GAAA,EAAK,IAAA,EAAM,OAAA,EAAS,CAAA,GAAI,EAAC;AAAA,EAC5D,CAAC,CAAA;AACH;AAEA,SAAS,qBAAA,CAAsB,EAAE,OAAA,EAAQ,EAAwB;AAC/D,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,cAAA,EAAe;AAC7B,EAAA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T,MAAA,EAAQ,MAAM,SAAA,CAAU,IAAI;AAAA;AAAA,OAC9B,EACF;AAAA;AAAA,GACF;AAEJ;AAEA,SAAS,UAAA,CAAW,EAAE,KAAA,EAAO,KAAA,EAAM,EAA2C;AAC5E,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAW,CAAA,kBAAA,EAAqB,KAAA,CAAM,SAAA,GAAY,aAAA,GAAgB,EAAE,CAAA,CAAA,EAAI,KAAA,CAAM,iBAAA,GAAoB,aAAA,GAAgB,EAAE,CAAA,CAAA;AAAA,MACpH,gBAAc,KAAA,CAAM,GAAA;AAAA,MAEpB,QAAA,kBAAA,GAAA;AAAA,QAAC,KAAA;AAAA,QAAA;AAAA,UACC,KAAK,KAAA,CAAM,GAAA;AAAA,UACX,GAAA,EAAK,MAAM,GAAA,IAAO,EAAA;AAAA,UAClB,SAAA,EAAU,mEAAA;AAAA,UACV,OAAO,KAAA,CAAM,GAAA;AAAA,UACb,UAAU,KAAA,GAAQ,CAAA;AAAA,UAClB,SAAA,EAAS;AAAA;AAAA;AACX;AAAA,GACF;AAEJ","file":"chunk-2OKUBHTT.js","sourcesContent":["import { lazyComponent } from '../../utils/lazy-component';\n\nexport const LazyProductDetails = lazyComponent(() =>\n import('./ProductDetails').then((m) => ({ default: m.ProductDetails }))\n);\n\nexport const LazyAddToCartForm = lazyComponent(() =>\n import('./AddToCartForm').then((m) => ({ default: m.AddToCartForm }))\n);\n","import { SallaSlider } from '@salla.sa/twilight-components-react/slider';\nimport { Suspense, useEffect, useMemo, useState } from 'react';\nimport { registry } from '../ComponentRegistry';\nimport { useTwilight } from '../../providers/TwilightProvider';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport type { Product, ProductImage } from '../../types';\nimport { Image } from '../common/Image';\nimport { ImageModal } from '../modal';\nimport { isNativeApp } from '../../native-app';\nimport { useRenderProbe } from '../../utils/render-probe';\n\nconst PRODUCT_GALLERY_KEY = 'product:gallery';\n\nexport interface ProductGalleryProps {\n product: Product;\n}\n\ntype ImagePreview = { src: string; alt: string };\ntype GalleryMedia = { url: string; type: 'image' | 'video' | '3d-image' };\n\n/**\n * The engine's own `mobile::gallery.open` payload from before `salla.mobile.openGallery`: a video's\n * link and a 3D model's file go in `url`, with no ids. Sent when the SDK has no `openGallery`\n * (Twilight before 2.14.569) or declines inside the app, so those stores keep the gallery they had.\n */\nfunction legacyGalleryMedia(images: ProductImage[]): GalleryMedia[] {\n return images.flatMap<GalleryMedia>((image) => {\n if (image.three_d_image_url) return [{ url: image.three_d_image_url, type: '3d-image' }];\n if (image.video_url) return [{ url: image.video_url, type: 'video' }];\n return image.url ? [{ url: image.url, type: 'image' }] : [];\n });\n}\n\nfunction ProductGalleryContent({ product }: ProductGalleryProps) {\n const { t } = useTranslation();\n const { theme } = useTwilight();\n const sliderId = `details-slider-${product.id}`;\n const objectFit = theme.settings.slider_background_size ?? 'cover';\n\n // Clicking an image opens an in-app lightbox instead of navigating to the CDN URL.\n const [preview, setPreview] = useState<ImagePreview | null>(null);\n\n useEffect(() => {\n const raf = requestAnimationFrame(() => {\n const el = document.getElementById(sliderId);\n if (!el?.parentElement) return;\n const { parentElement, nextSibling } = el;\n parentElement.removeChild(el);\n parentElement.insertBefore(el, nextSibling);\n });\n return () => cancelAnimationFrame(raf);\n }, [sliderId]);\n\n // The product-details API only returns `image` (singular).\n // Fall back so the main image always renders even without the full gallery array.\n const images: ProductImage[] =\n product.images && product.images.length > 0\n ? product.images\n : product.image?.url\n ? [product.image]\n : [];\n\n const hasManyImages = images.length > 1;\n const openNativeGallery = (selected: ProductImage) => {\n if (!isNativeApp()) return false;\n if (window.salla?.mobile?.openGallery?.(images, selected)) return true;\n window.salla?.event.dispatch('mobile::gallery.open', { images: legacyGalleryMedia(images) });\n return true;\n };\n\n return (\n <div className=\"sidebar md:sticky top-24 w-full md:!w-2/4 rtl:ml-8 ltr:mr-8 pb-8 md:pb-16 overflow-hidden shrink-0\">\n <SallaSlider\n id={sliderId}\n className=\"details-slider rounded-md image-slider\"\n type=\"thumbs\"\n loop={false}\n autoHeight\n listenToThumbnailsOption\n showThumbsControls={false}\n sliderConfig={{ watchOverflow: true, autoHeight: true }}\n >\n {product.promotion_title && (\n <div className=\"promotion-title\">{product.promotion_title}</div>\n )}\n\n {product.calories && (\n <div className=\"absolute z-[2] top-4 rtl:left-4 ltr:right-4 bg-white shadow-sm flex flex-col justify-center items-center rounded-full w-20 h-20 md:w-24 md:h-24\">\n <span className=\"text-red-500 text-xl leading-none font-bold\">{product.calories}</span>\n <span className=\"text-xs text-gray-500\">\n {t('pages.products.calories', 'Calories')}\n </span>\n </div>\n )}\n\n <div slot=\"items\">\n {images.map((image, index) => (\n <ImageSlide\n key={image.id ?? image.three_d_image_url ?? image.video_url ?? image.url}\n image={image}\n product={product}\n index={index}\n objectFit={objectFit}\n onPreview={setPreview}\n onNativeOpen={openNativeGallery}\n />\n ))}\n </div>\n\n {hasManyImages && (\n <div slot=\"thumbs\">\n {images.map((image, index) => (\n <ThumbSlide\n key={image.id ?? image.three_d_image_url ?? image.video_url ?? image.url}\n image={image}\n index={index}\n />\n ))}\n </div>\n )}\n </SallaSlider>\n\n <Suspense fallback={null}>\n <ImageModal\n isOpen={!!preview}\n onClose={() => setPreview(null)}\n src={preview?.src ?? ''}\n alt={preview?.alt}\n />\n </Suspense>\n </div>\n );\n}\n\nexport function ProductGallery(props: ProductGalleryProps) {\n useRenderProbe('ProductGallery');\n const Component = useMemo(() => {\n const resolved = registry.resolve<ProductGalleryProps>(PRODUCT_GALLERY_KEY);\n // A theme that seeds the key with this component (register + override) would\n // otherwise recurse into itself when it has not actually overridden anything.\n return resolved === ProductGallery ? null : resolved;\n }, []);\n\n if (Component) {\n return <Component {...props} />;\n }\n\n return <ProductGalleryContent {...props} />;\n}\n\nfunction ImageSlide({\n image,\n product,\n index,\n objectFit,\n onPreview,\n onNativeOpen,\n}: {\n image: ProductImage;\n product: Product;\n index: number;\n objectFit: 'cover' | 'contain';\n onPreview: (preview: ImagePreview) => void;\n onNativeOpen: (image: ProductImage) => boolean;\n}) {\n const [loaded, setLoaded] = useState(false);\n const isVideo = Boolean(image.video_url);\n\n if (image.three_d_image_url) {\n return (\n // biome-ignore lint/a11y/noStaticElementInteractions: model-viewer is an interactive web component.\n <model-viewer\n style={{ minHeight: '500px' }}\n className=\"swiper-slide model-entry w-full h-full\"\n loading=\"lazy\"\n camera-controls\n touch-action=\"pan-y\"\n auto-rotate\n poster={image.url || undefined}\n src={image.three_d_image_url}\n shadow-intensity=\"1\"\n alt={image.alt}\n onClick={() => onNativeOpen(image)}\n ></model-viewer>\n );\n }\n\n return (\n <a\n data-fslightbox={`product_${product.id}`}\n data-img-id={image.id}\n data-slid-index={index}\n {...(image.video_url ? { 'data-video-src': image.video_url } : {})}\n data-caption={image.alt}\n data-infinite=\"false\"\n data-type={image.video_url ? 'youtube' : 'image'}\n href={image.video_url || image.url}\n // FsLightbox isn't loaded in this React theme, so the bare href would leave the SPA.\n // Open images in an in-app lightbox; let videos open in a new tab.\n {...(isVideo ? { target: '_blank', rel: 'noopener noreferrer' } : {})}\n onClick={(event) => {\n if (onNativeOpen(image)) {\n event.preventDefault();\n return;\n }\n if (isVideo || !image.url) return;\n event.preventDefault();\n onPreview({ src: image.url, alt: image.alt || product.name });\n }}\n aria-label={product.name}\n className={`swiper-slide magnify-wrapper homeslider__slide ${image.video_url ? 'video-entry' : ''}`}\n >\n <div className={`w-full ${loaded ? '' : 'aspect-square bg-gray-100 animate-pulse'}`}>\n <Image\n id={String(image.id)}\n src={image.url}\n alt={image.alt || product.name}\n className={`h-full w-full object-${objectFit}`}\n aspectRatio=\"1/1\"\n priority={index === 0}\n noWrapper\n onLoad={() => setLoaded(true)}\n />\n </div>\n </a>\n );\n}\n\nfunction ThumbSlide({ image, index }: { image: ProductImage; index: number }) {\n return (\n <div\n className={`slide--one-fourth ${image.video_url ? 'video-entry' : ''} ${image.three_d_image_url ? 'model-entry' : ''}`}\n data-caption={image.alt}\n >\n <Image\n src={image.url}\n alt={image.alt || ''}\n className=\"object-cover w-full h-full bg-gray-100 rounded-md overflow-hidden\"\n title={image.alt}\n priority={index < 5}\n noWrapper\n />\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/product/lazy.ts","../src/components/product/ProductGallery.tsx"],"names":[],"mappings":";;;;;;;;;;;;;AAEO,IAAM,kBAAA,GAAqB,aAAA;AAAA,EAAc,MAC9C,OAAO,8BAAkB,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,cAAA,EAAe,CAAE;AACxE;AAEO,IAAM,iBAAA,GAAoB,aAAA;AAAA,EAAc,MAC7C,OAAO,6BAAiB,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,aAAA,EAAc,CAAE;AACtE;ACGA,IAAM,mBAAA,GAAsB,iBAAA;AAc5B,SAAS,mBAAmB,MAAA,EAAwC;AAClE,EAAA,OAAO,MAAA,CAAO,OAAA,CAAsB,CAAC,KAAA,KAAU;AAC7C,IAAA,IAAI,KAAA,CAAM,iBAAA,EAAmB,OAAO,CAAC,EAAE,KAAK,KAAA,CAAM,iBAAA,EAAmB,IAAA,EAAM,UAAA,EAAY,CAAA;AACvF,IAAA,IAAI,KAAA,CAAM,SAAA,EAAW,OAAO,CAAC,EAAE,KAAK,KAAA,CAAM,SAAA,EAAW,IAAA,EAAM,OAAA,EAAS,CAAA;AACpE,IAAA,OAAO,KAAA,CAAM,GAAA,GAAM,CAAC,EAAE,GAAA,EAAK,KAAA,CAAM,GAAA,EAAK,IAAA,EAAM,OAAA,EAAS,CAAA,GAAI,EAAC;AAAA,EAC5D,CAAC,CAAA;AACH;AAEA,SAAS,qBAAA,CAAsB,EAAE,OAAA,EAAQ,EAAwB;AAC/D,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,cAAA,EAAe;AAC7B,EAAA,MAAM,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,EAAQ,MAAM,SAAA,CAAU,IAAI;AAAA;AAAA,OAC9B,EACF;AAAA;AAAA,GACF;AAEJ;AAEA,SAAS,UAAA,CAAW,EAAE,KAAA,EAAO,KAAA,EAAM,EAA2C;AAC5E,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAW,CAAA,kBAAA,EAAqB,KAAA,CAAM,SAAA,GAAY,aAAA,GAAgB,EAAE,CAAA,CAAA,EAAI,KAAA,CAAM,iBAAA,GAAoB,aAAA,GAAgB,EAAE,CAAA,CAAA;AAAA,MACpH,gBAAc,KAAA,CAAM,GAAA;AAAA,MAEpB,QAAA,kBAAA,GAAA;AAAA,QAAC,KAAA;AAAA,QAAA;AAAA,UACC,KAAK,KAAA,CAAM,GAAA;AAAA,UACX,GAAA,EAAK,MAAM,GAAA,IAAO,EAAA;AAAA,UAClB,SAAA,EAAU,mEAAA;AAAA,UACV,OAAO,KAAA,CAAM,GAAA;AAAA,UACb,UAAU,KAAA,GAAQ,CAAA;AAAA,UAClB,SAAA,EAAS;AAAA;AAAA;AACX;AAAA,GACF;AAEJ","file":"chunk-IAGMA4A4.js","sourcesContent":["import { lazyComponent } from '../../utils/lazy-component';\n\nexport const LazyProductDetails = lazyComponent(() =>\n import('./ProductDetails').then((m) => ({ default: m.ProductDetails }))\n);\n\nexport const LazyAddToCartForm = lazyComponent(() =>\n import('./AddToCartForm').then((m) => ({ default: m.AddToCartForm }))\n);\n","import { SallaSlider } from '@salla.sa/twilight-components-react/slider';\nimport { Suspense, useEffect, useMemo, useState } from 'react';\nimport { registry } from '../ComponentRegistry';\nimport { useTwilight } from '../../providers/TwilightProvider';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport type { Product, ProductImage } from '../../types';\nimport { Image } from '../common/Image';\nimport { ImageModal } from '../modal';\nimport { isNativeApp } from '../../native-app';\nimport { useRenderProbe } from '../../utils/render-probe';\n\nconst PRODUCT_GALLERY_KEY = 'product:gallery';\n\nexport interface ProductGalleryProps {\n product: Product;\n}\n\ntype ImagePreview = { src: string; alt: string };\ntype GalleryMedia = { url: string; type: 'image' | 'video' | '3d-image' };\n\n/**\n * The engine's own `mobile::gallery.open` payload from before `salla.mobile.openGallery`: a video's\n * link and a 3D model's file go in `url`, with no ids. Sent when the SDK has no `openGallery`\n * (Twilight before 2.14.569) or declines inside the app, so those stores keep the gallery they had.\n */\nfunction legacyGalleryMedia(images: ProductImage[]): GalleryMedia[] {\n return images.flatMap<GalleryMedia>((image) => {\n if (image.three_d_image_url) return [{ url: image.three_d_image_url, type: '3d-image' }];\n if (image.video_url) return [{ url: image.video_url, type: 'video' }];\n return image.url ? [{ url: image.url, type: 'image' }] : [];\n });\n}\n\nfunction ProductGalleryContent({ product }: ProductGalleryProps) {\n const { t } = useTranslation();\n const { theme } = useTwilight();\n const sliderId = `details-slider-${product.id}`;\n const objectFit = theme.settings.slider_background_size ?? 'cover';\n\n // Clicking an image opens an in-app lightbox instead of navigating to the CDN URL.\n const [preview, setPreview] = useState<ImagePreview | null>(null);\n\n useEffect(() => {\n const raf = requestAnimationFrame(() => {\n const el = document.getElementById(sliderId);\n if (!el?.parentElement) return;\n const { parentElement, nextSibling } = el;\n parentElement.removeChild(el);\n parentElement.insertBefore(el, nextSibling);\n });\n return () => cancelAnimationFrame(raf);\n }, [sliderId]);\n\n // The product-details API only returns `image` (singular).\n // Fall back so the main image always renders even without the full gallery array.\n const images: ProductImage[] =\n product.images && product.images.length > 0\n ? product.images\n : product.image?.url\n ? [product.image]\n : [];\n\n const hasManyImages = images.length > 1;\n const openNativeGallery = (selected: ProductImage) => {\n if (!isNativeApp()) return false;\n if (window.salla?.mobile?.openGallery?.(images, selected)) return true;\n window.salla?.event.dispatch('mobile::gallery.open', { images: legacyGalleryMedia(images) });\n return true;\n };\n\n return (\n <div className=\"sidebar md:sticky top-24 w-full md:!w-2/4 rtl:ml-8 ltr:mr-8 pb-8 md:pb-16 overflow-hidden shrink-0\">\n <SallaSlider\n id={sliderId}\n className=\"details-slider rounded-md image-slider\"\n type=\"thumbs\"\n loop={false}\n autoHeight\n listenToThumbnailsOption\n showThumbsControls={false}\n sliderConfig={{ watchOverflow: true, autoHeight: true }}\n >\n {product.promotion_title && (\n <div className=\"promotion-title\">{product.promotion_title}</div>\n )}\n\n {product.calories && (\n <div className=\"absolute z-[2] top-4 rtl:left-4 ltr:right-4 bg-white shadow-sm flex flex-col justify-center items-center rounded-full w-20 h-20 md:w-24 md:h-24\">\n <span className=\"text-red-500 text-xl leading-none font-bold\">{product.calories}</span>\n <span className=\"text-xs text-gray-500\">\n {t('pages.products.calories', 'Calories')}\n </span>\n </div>\n )}\n\n <div slot=\"items\">\n {images.map((image, index) => (\n <ImageSlide\n key={image.id ?? image.three_d_image_url ?? image.video_url ?? image.url}\n image={image}\n product={product}\n index={index}\n objectFit={objectFit}\n onPreview={setPreview}\n onNativeOpen={openNativeGallery}\n />\n ))}\n </div>\n\n {hasManyImages && (\n <div slot=\"thumbs\">\n {images.map((image, index) => (\n <ThumbSlide\n key={image.id ?? image.three_d_image_url ?? image.video_url ?? image.url}\n image={image}\n index={index}\n />\n ))}\n </div>\n )}\n </SallaSlider>\n\n <Suspense fallback={null}>\n <ImageModal\n isOpen={!!preview}\n onClose={() => setPreview(null)}\n src={preview?.src ?? ''}\n alt={preview?.alt}\n />\n </Suspense>\n </div>\n );\n}\n\nexport function ProductGallery(props: ProductGalleryProps) {\n useRenderProbe('ProductGallery');\n const Component = useMemo(() => {\n const resolved = registry.resolve<ProductGalleryProps>(PRODUCT_GALLERY_KEY);\n // A theme that seeds the key with this component (register + override) would\n // otherwise recurse into itself when it has not actually overridden anything.\n return resolved === ProductGallery ? null : resolved;\n }, []);\n\n if (Component) {\n return <Component {...props} />;\n }\n\n return <ProductGalleryContent {...props} />;\n}\n\nfunction ImageSlide({\n image,\n product,\n index,\n objectFit,\n onPreview,\n onNativeOpen,\n}: {\n image: ProductImage;\n product: Product;\n index: number;\n objectFit: 'cover' | 'contain';\n onPreview: (preview: ImagePreview) => void;\n onNativeOpen: (image: ProductImage) => boolean;\n}) {\n const [loaded, setLoaded] = useState(false);\n const isVideo = Boolean(image.video_url);\n\n if (image.three_d_image_url) {\n return (\n // biome-ignore lint/a11y/noStaticElementInteractions: model-viewer is an interactive web component.\n <model-viewer\n style={{ minHeight: '500px' }}\n className=\"swiper-slide model-entry w-full h-full\"\n loading=\"lazy\"\n camera-controls\n touch-action=\"pan-y\"\n auto-rotate\n poster={image.url || undefined}\n src={image.three_d_image_url}\n shadow-intensity=\"1\"\n alt={image.alt}\n onClick={() => onNativeOpen(image)}\n ></model-viewer>\n );\n }\n\n return (\n <a\n data-fslightbox={`product_${product.id}`}\n data-img-id={image.id}\n data-slid-index={index}\n {...(image.video_url ? { 'data-video-src': image.video_url } : {})}\n data-caption={image.alt}\n data-infinite=\"false\"\n data-type={image.video_url ? 'youtube' : 'image'}\n href={image.video_url || image.url}\n // FsLightbox isn't loaded in this React theme, so the bare href would leave the SPA.\n // Open images in an in-app lightbox; let videos open in a new tab.\n {...(isVideo ? { target: '_blank', rel: 'noopener noreferrer' } : {})}\n onClick={(event) => {\n if (onNativeOpen(image)) {\n event.preventDefault();\n return;\n }\n if (isVideo || !image.url) return;\n event.preventDefault();\n onPreview({ src: image.url, alt: image.alt || product.name });\n }}\n aria-label={product.name}\n className={`swiper-slide magnify-wrapper homeslider__slide ${image.video_url ? 'video-entry' : ''}`}\n >\n <div className={`w-full ${loaded ? '' : 'aspect-square bg-gray-100 animate-pulse'}`}>\n <Image\n id={String(image.id)}\n src={image.url}\n alt={image.alt || product.name}\n className={`h-full w-full object-${objectFit}`}\n aspectRatio=\"1/1\"\n priority={index === 0}\n noWrapper\n onLoad={() => setLoaded(true)}\n />\n </div>\n </a>\n );\n}\n\nfunction ThumbSlide({ image, index }: { image: ProductImage; index: number }) {\n return (\n <div\n className={`slide--one-fourth ${image.video_url ? 'video-entry' : ''} ${image.three_d_image_url ? 'model-entry' : ''}`}\n data-caption={image.alt}\n >\n <Image\n src={image.url}\n alt={image.alt || ''}\n className=\"object-cover w-full h-full bg-gray-100 rounded-md overflow-hidden\"\n title={image.alt}\n priority={index < 5}\n noWrapper\n />\n </div>\n );\n}\n"]}
|