@salla.sa/twilight-theme-engine 1.0.150 → 1.0.152
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-P5Q4P763.js → AddToCartForm-HOBSTMWX.js} +3 -3
- package/dist/{AddToCartForm-P5Q4P763.js.map → AddToCartForm-HOBSTMWX.js.map} +1 -1
- package/dist/{BlogAuthorPage-Z3R6AETN.js → BlogAuthorPage-56OY5GCN.js} +27 -27
- package/dist/{BlogAuthorPage-Z3R6AETN.js.map → BlogAuthorPage-56OY5GCN.js.map} +1 -1
- package/dist/{BlogCategoryPage-7VROFBGI.js → BlogCategoryPage-HW7A6RNL.js} +27 -27
- package/dist/{BlogCategoryPage-7VROFBGI.js.map → BlogCategoryPage-HW7A6RNL.js.map} +1 -1
- package/dist/{BlogPage-Q2NN4WTB.js → BlogPage-RRHKP3GP.js} +25 -25
- package/dist/{BlogPage-Q2NN4WTB.js.map → BlogPage-RRHKP3GP.js.map} +1 -1
- package/dist/{BlogSinglePage-ZPCSNBIX.js → BlogSinglePage-STNMFQHX.js} +25 -25
- package/dist/{BlogSinglePage-ZPCSNBIX.js.map → BlogSinglePage-STNMFQHX.js.map} +1 -1
- package/dist/{BlogTagPage-IGG2VEMR.js → BlogTagPage-YD3EPTQY.js} +27 -27
- package/dist/{BlogTagPage-IGG2VEMR.js.map → BlogTagPage-YD3EPTQY.js.map} +1 -1
- package/dist/{BrandsPage-ZAJT6RGM.js → BrandsPage-KJFB4QBN.js} +26 -26
- package/dist/{BrandsPage-ZAJT6RGM.js.map → BrandsPage-KJFB4QBN.js.map} +1 -1
- package/dist/{Breadcrumb-KE4EWH7L.js → Breadcrumb-QKHYTTFB.js} +25 -25
- package/dist/{Breadcrumb-KE4EWH7L.js.map → Breadcrumb-QKHYTTFB.js.map} +1 -1
- package/dist/{CartItem-RMCXCGHT.js → CartItem-DCCYGMRI.js} +25 -25
- package/dist/{CartItem-RMCXCGHT.js.map → CartItem-DCCYGMRI.js.map} +1 -1
- package/dist/{CartSummary-NLEAHKWF.js → CartSummary-DAAYDRFS.js} +25 -25
- package/dist/{CartSummary-NLEAHKWF.js.map → CartSummary-DAAYDRFS.js.map} +1 -1
- package/dist/{Copyright-EIBPTE3B.js → Copyright-GL5Q4FTN.js} +3 -3
- package/dist/{Copyright-EIBPTE3B.js.map → Copyright-GL5Q4FTN.js.map} +1 -1
- package/dist/{CustomerLayout-POGWFN6R.js → CustomerLayout-D7HC4G7V.js} +25 -25
- package/dist/{CustomerLayout-POGWFN6R.js.map → CustomerLayout-D7HC4G7V.js.map} +1 -1
- package/dist/{Footer-LGIUINGS.js → Footer-3NQWLPAA.js} +4 -4
- package/dist/{Footer-LGIUINGS.js.map → Footer-3NQWLPAA.js.map} +1 -1
- package/dist/{Header-4TGYO6E4.js → Header-SCR46P4B.js} +11 -11
- package/dist/{Header-4TGYO6E4.js.map → Header-SCR46P4B.js.map} +1 -1
- package/dist/{LatestProducts-YYKQNL5N.js → LatestProducts-4UML6BNG.js} +27 -27
- package/dist/{LatestProducts-YYKQNL5N.js.map → LatestProducts-4UML6BNG.js.map} +1 -1
- package/dist/{LoyaltyPage-MROFMZXV.js → LoyaltyPage-CQIUT7MD.js} +25 -25
- package/dist/{LoyaltyPage-MROFMZXV.js.map → LoyaltyPage-CQIUT7MD.js.map} +1 -1
- package/dist/{LoyaltyPointsPage-DVHJOAKP.js → LoyaltyPointsPage-ZOZFDRZT.js} +8 -8
- package/dist/{LoyaltyPointsPage-DVHJOAKP.js.map → LoyaltyPointsPage-ZOZFDRZT.js.map} +1 -1
- package/dist/{MainMenu-GQO5KOTU.js → MainMenu-YLCB4MT7.js} +7 -7
- package/dist/{MainMenu-GQO5KOTU.js.map → MainMenu-YLCB4MT7.js.map} +1 -1
- package/dist/{MasterLayout-ZJBJ7EHM.js → MasterLayout-BDDKPLS6.js} +25 -25
- package/dist/{MasterLayout-ZJBJ7EHM.js.map → MasterLayout-BDDKPLS6.js.map} +1 -1
- package/dist/{MobileMenu-TZSFYHPW.js → MobileMenu-S5LB622I.js} +26 -26
- package/dist/{MobileMenu-TZSFYHPW.js.map → MobileMenu-S5LB622I.js.map} +1 -1
- package/dist/{NotificationsPage-BX6OSIDY.js → NotificationsPage-FPF7UU3Q.js} +25 -25
- package/dist/{NotificationsPage-BX6OSIDY.js.map → NotificationsPage-FPF7UU3Q.js.map} +1 -1
- package/dist/{OrderSinglePage-3RQ5TJDB.js → OrderSinglePage-M37ROUBX.js} +26 -26
- package/dist/{OrderSinglePage-3RQ5TJDB.js.map → OrderSinglePage-M37ROUBX.js.map} +1 -1
- package/dist/{OrdersPage-S4ECYNGI.js → OrdersPage-GIZFTPQ7.js} +25 -25
- package/dist/{OrdersPage-S4ECYNGI.js.map → OrdersPage-GIZFTPQ7.js.map} +1 -1
- package/dist/{PageSingle-BZGDC4VE.js → PageSingle-EQD5Y3L5.js} +6 -6
- package/dist/{PageSingle-BZGDC4VE.js.map → PageSingle-EQD5Y3L5.js.map} +1 -1
- package/dist/{ProductDetails-ZPRWPSVK.js → ProductDetails-53BXVF37.js} +7 -7
- package/dist/{ProductDetails-ZPRWPSVK.js.map → ProductDetails-53BXVF37.js.map} +1 -1
- package/dist/{ProfilePage-SKAS6LFQ.js → ProfilePage-6GJXTBFN.js} +25 -25
- package/dist/{ProfilePage-SKAS6LFQ.js.map → ProfilePage-6GJXTBFN.js.map} +1 -1
- package/dist/{ReviewsPage-NAZWXVXT.js → ReviewsPage-SCHVMKXV.js} +3 -3
- package/dist/{ReviewsPage-NAZWXVXT.js.map → ReviewsPage-SCHVMKXV.js.map} +1 -1
- package/dist/{SeoCartWidget-6NB6LT2Z.js → SeoCartWidget-IUXLYOTC.js} +25 -25
- package/dist/{SeoCartWidget-6NB6LT2Z.js.map → SeoCartWidget-IUXLYOTC.js.map} +1 -1
- package/dist/{SettingsPage-GZ2NJIUR.js → SettingsPage-2TKL2COF.js} +25 -25
- package/dist/{SettingsPage-GZ2NJIUR.js.map → SettingsPage-2TKL2COF.js.map} +1 -1
- package/dist/{StoreClosedNotification-V72F7HE5.js → StoreClosedNotification-HHOQXT6N.js} +26 -26
- package/dist/{StoreClosedNotification-V72F7HE5.js.map → StoreClosedNotification-HHOQXT6N.js.map} +1 -1
- package/dist/{TestimonialsPage-L6VBZFLT.js → TestimonialsPage-GJJT7F5G.js} +6 -6
- package/dist/{TestimonialsPage-L6VBZFLT.js.map → TestimonialsPage-GJJT7F5G.js.map} +1 -1
- package/dist/{ThankYouPage-O5U3V6J4.js → ThankYouPage-ZAEZWSUK.js} +25 -25
- package/dist/{ThankYouPage-O5U3V6J4.js.map → ThankYouPage-ZAEZWSUK.js.map} +1 -1
- package/dist/{WalletPage-NJBBZIMM.js → WalletPage-74LAUONG.js} +26 -26
- package/dist/{WalletPage-NJBBZIMM.js.map → WalletPage-74LAUONG.js.map} +1 -1
- package/dist/{WebMcpTools-VAZH3S5G.js → WebMcpTools-J6HCO5B6.js} +9 -9
- package/dist/{WebMcpTools-VAZH3S5G.js.map → WebMcpTools-J6HCO5B6.js.map} +1 -1
- package/dist/{WishlistPage-UKOGNFKB.js → WishlistPage-SV55V5CP.js} +27 -27
- package/dist/{WishlistPage-UKOGNFKB.js.map → WishlistPage-SV55V5CP.js.map} +1 -1
- package/dist/api/advertisement.js +4 -4
- package/dist/api/apps.js +4 -4
- package/dist/api/blog.js +6 -6
- package/dist/api/brands.js +6 -6
- package/dist/api/cart.js +6 -6
- package/dist/api/category.js +6 -6
- package/dist/api/client.js +3 -3
- package/dist/api/home.js +4 -4
- package/dist/api/loyalty.js +6 -6
- package/dist/api/menu.js +4 -4
- package/dist/api/notification.js +4 -4
- package/dist/api/order.js +6 -6
- package/dist/api/page.js +6 -6
- package/dist/api/product.js +6 -6
- package/dist/api/profile.js +3 -3
- package/dist/api/store.js +5 -5
- package/dist/api/translations.js +4 -4
- package/dist/api/user.js +4 -4
- package/dist/api/wallet.js +4 -4
- package/dist/api/wishlist.js +7 -7
- package/dist/{chunk-FL3OK7AQ.js → chunk-4SZNUX4K.js} +16 -16
- package/dist/{chunk-FL3OK7AQ.js.map → chunk-4SZNUX4K.js.map} +1 -1
- package/dist/{chunk-JSAWLWUN.js → chunk-5VTVPQQB.js} +4 -4
- package/dist/{chunk-JSAWLWUN.js.map → chunk-5VTVPQQB.js.map} +1 -1
- package/dist/{chunk-PVOJJ2BV.js → chunk-64RDACOS.js} +5 -5
- package/dist/{chunk-PVOJJ2BV.js.map → chunk-64RDACOS.js.map} +1 -1
- package/dist/{chunk-PYXAPLNB.js → chunk-677OXNGV.js} +3 -3
- package/dist/{chunk-PYXAPLNB.js.map → chunk-677OXNGV.js.map} +1 -1
- package/dist/{chunk-7XAGU6CT.js → chunk-7IVHY4OR.js} +3 -3
- package/dist/{chunk-7XAGU6CT.js.map → chunk-7IVHY4OR.js.map} +1 -1
- package/dist/{chunk-6H6BVZBV.js → chunk-A2SS3TNE.js} +3 -3
- package/dist/{chunk-6H6BVZBV.js.map → chunk-A2SS3TNE.js.map} +1 -1
- package/dist/{chunk-TXYLHBUH.js → chunk-AFFBCOH6.js} +3 -3
- package/dist/{chunk-TXYLHBUH.js.map → chunk-AFFBCOH6.js.map} +1 -1
- package/dist/{chunk-LBZNLTBM.js → chunk-AU2XMLTH.js} +3 -3
- package/dist/{chunk-LBZNLTBM.js.map → chunk-AU2XMLTH.js.map} +1 -1
- package/dist/{chunk-5NUCGUTE.js → chunk-BIVBSVWR.js} +4 -4
- package/dist/{chunk-5NUCGUTE.js.map → chunk-BIVBSVWR.js.map} +1 -1
- package/dist/{chunk-6YEE3VHL.js → chunk-BRIRWS2Q.js} +3 -3
- package/dist/{chunk-6YEE3VHL.js.map → chunk-BRIRWS2Q.js.map} +1 -1
- package/dist/{chunk-ZUVBDALM.js → chunk-BWKHA4ZD.js} +4 -4
- package/dist/{chunk-ZUVBDALM.js.map → chunk-BWKHA4ZD.js.map} +1 -1
- package/dist/{chunk-EMAAVDEK.js → chunk-BY4DQTOG.js} +7 -7
- package/dist/{chunk-EMAAVDEK.js.map → chunk-BY4DQTOG.js.map} +1 -1
- package/dist/{chunk-TEAYGNHT.js → chunk-CIJVNUNZ.js} +3 -3
- package/dist/{chunk-TEAYGNHT.js.map → chunk-CIJVNUNZ.js.map} +1 -1
- package/dist/{chunk-5RBXCPG6.js → chunk-CV32FSEL.js} +3 -3
- package/dist/{chunk-5RBXCPG6.js.map → chunk-CV32FSEL.js.map} +1 -1
- package/dist/{chunk-FCCGJ4DI.js → chunk-EAQAPYYU.js} +7 -7
- package/dist/{chunk-FCCGJ4DI.js.map → chunk-EAQAPYYU.js.map} +1 -1
- package/dist/{chunk-4E6FD5W7.js → chunk-EEL6OYAQ.js} +7 -3
- package/dist/chunk-EEL6OYAQ.js.map +1 -0
- package/dist/{chunk-W7CYFPGY.js → chunk-EFKVEYML.js} +6 -6
- package/dist/{chunk-W7CYFPGY.js.map → chunk-EFKVEYML.js.map} +1 -1
- package/dist/{chunk-O63WBEAC.js → chunk-F5RU2UCE.js} +22 -22
- package/dist/{chunk-O63WBEAC.js.map → chunk-F5RU2UCE.js.map} +1 -1
- package/dist/{chunk-RB7RHMKJ.js → chunk-FCFIG4M3.js} +5 -5
- package/dist/{chunk-RB7RHMKJ.js.map → chunk-FCFIG4M3.js.map} +1 -1
- package/dist/{chunk-B57KIBQL.js → chunk-GGQA6QBB.js} +3 -3
- package/dist/{chunk-B57KIBQL.js.map → chunk-GGQA6QBB.js.map} +1 -1
- package/dist/{chunk-WAKCWE6P.js → chunk-GMXNVBCD.js} +5 -5
- package/dist/{chunk-WAKCWE6P.js.map → chunk-GMXNVBCD.js.map} +1 -1
- package/dist/{chunk-PHPOMWQ4.js → chunk-HSJCVD3P.js} +4 -4
- package/dist/{chunk-PHPOMWQ4.js.map → chunk-HSJCVD3P.js.map} +1 -1
- package/dist/{chunk-5LI536P6.js → chunk-I3KAWUPG.js} +5 -5
- package/dist/{chunk-5LI536P6.js.map → chunk-I3KAWUPG.js.map} +1 -1
- package/dist/{chunk-34L65JGK.js → chunk-I5GFTVR2.js} +4 -4
- package/dist/{chunk-34L65JGK.js.map → chunk-I5GFTVR2.js.map} +1 -1
- package/dist/{chunk-QKKEBQ57.js → chunk-IO4CVUL5.js} +6 -6
- package/dist/{chunk-QKKEBQ57.js.map → chunk-IO4CVUL5.js.map} +1 -1
- package/dist/{chunk-ULF4LPVA.js → chunk-IURXJAIK.js} +3 -3
- package/dist/{chunk-ULF4LPVA.js.map → chunk-IURXJAIK.js.map} +1 -1
- package/dist/{chunk-2CILV5ME.js → chunk-JWYZLXJZ.js} +5 -5
- package/dist/{chunk-2CILV5ME.js.map → chunk-JWYZLXJZ.js.map} +1 -1
- package/dist/{chunk-PZP3372I.js → chunk-KNY2ZZ5M.js} +4 -4
- package/dist/{chunk-PZP3372I.js.map → chunk-KNY2ZZ5M.js.map} +1 -1
- package/dist/{chunk-UUHLRFXB.js → chunk-LAO3MSKN.js} +8 -8
- package/dist/{chunk-UUHLRFXB.js.map → chunk-LAO3MSKN.js.map} +1 -1
- package/dist/{chunk-5EAISVPV.js → chunk-LFMCUQQ3.js} +3 -3
- package/dist/{chunk-5EAISVPV.js.map → chunk-LFMCUQQ3.js.map} +1 -1
- package/dist/{chunk-Q7Z76F7N.js → chunk-LJXWCGBH.js} +8 -8
- package/dist/{chunk-Q7Z76F7N.js.map → chunk-LJXWCGBH.js.map} +1 -1
- package/dist/{chunk-6QIF6WJH.js → chunk-LPF6YURL.js} +3 -3
- package/dist/{chunk-6QIF6WJH.js.map → chunk-LPF6YURL.js.map} +1 -1
- package/dist/{chunk-P2PPBXHD.js → chunk-M2MJKUQF.js} +3 -3
- package/dist/{chunk-P2PPBXHD.js.map → chunk-M2MJKUQF.js.map} +1 -1
- package/dist/{chunk-IEKP3HYS.js → chunk-MJQ3HFLJ.js} +4 -4
- package/dist/{chunk-IEKP3HYS.js.map → chunk-MJQ3HFLJ.js.map} +1 -1
- package/dist/{chunk-VJA4DVVT.js → chunk-N2RAPPQ3.js} +4 -4
- package/dist/{chunk-VJA4DVVT.js.map → chunk-N2RAPPQ3.js.map} +1 -1
- package/dist/{chunk-OOZQVX7C.js → chunk-O76H6TDP.js} +6 -6
- package/dist/{chunk-OOZQVX7C.js.map → chunk-O76H6TDP.js.map} +1 -1
- package/dist/{chunk-GLSRVHYJ.js → chunk-OZRGUVHQ.js} +4 -4
- package/dist/{chunk-GLSRVHYJ.js.map → chunk-OZRGUVHQ.js.map} +1 -1
- package/dist/{chunk-JK45RUVV.js → chunk-PPUV27YN.js} +3 -3
- package/dist/{chunk-JK45RUVV.js.map → chunk-PPUV27YN.js.map} +1 -1
- package/dist/{chunk-RY6VPXG6.js → chunk-R4LA6IMS.js} +3 -3
- package/dist/{chunk-RY6VPXG6.js.map → chunk-R4LA6IMS.js.map} +1 -1
- package/dist/{chunk-R7QCNL62.js → chunk-REBJQRQF.js} +3 -3
- package/dist/{chunk-R7QCNL62.js.map → chunk-REBJQRQF.js.map} +1 -1
- package/dist/{chunk-5M2AK5KE.js → chunk-S5KE6KPV.js} +4 -4
- package/dist/{chunk-5M2AK5KE.js.map → chunk-S5KE6KPV.js.map} +1 -1
- package/dist/{chunk-LWAJNEIM.js → chunk-SIYINCXL.js} +4 -4
- package/dist/{chunk-LWAJNEIM.js.map → chunk-SIYINCXL.js.map} +1 -1
- package/dist/{chunk-KJ7NG3ZH.js → chunk-SXJEZEGN.js} +3 -3
- package/dist/{chunk-KJ7NG3ZH.js.map → chunk-SXJEZEGN.js.map} +1 -1
- package/dist/{chunk-I2LK4IC2.js → chunk-UBRG55VM.js} +4 -4
- package/dist/{chunk-I2LK4IC2.js.map → chunk-UBRG55VM.js.map} +1 -1
- package/dist/{chunk-2HCODIC6.js → chunk-UG44HSCN.js} +4 -4
- package/dist/{chunk-2HCODIC6.js.map → chunk-UG44HSCN.js.map} +1 -1
- package/dist/{chunk-BYGVKW3M.js → chunk-UL2DRYH3.js} +4 -4
- package/dist/{chunk-BYGVKW3M.js.map → chunk-UL2DRYH3.js.map} +1 -1
- package/dist/{chunk-PPFD456V.js → chunk-URBOD4MX.js} +3 -3
- package/dist/{chunk-PPFD456V.js.map → chunk-URBOD4MX.js.map} +1 -1
- package/dist/{chunk-5T4MJAUN.js → chunk-VBAFSMNX.js} +3 -3
- package/dist/{chunk-5T4MJAUN.js.map → chunk-VBAFSMNX.js.map} +1 -1
- package/dist/{chunk-DPQIVZ4T.js → chunk-VDPMCOHX.js} +3 -3
- package/dist/{chunk-DPQIVZ4T.js.map → chunk-VDPMCOHX.js.map} +1 -1
- package/dist/{chunk-2ZC5YGMI.js → chunk-XEHOZTER.js} +3 -3
- package/dist/{chunk-2ZC5YGMI.js.map → chunk-XEHOZTER.js.map} +1 -1
- package/dist/{chunk-AOQZHLZZ.js → chunk-XTBFIIAR.js} +5 -5
- package/dist/{chunk-AOQZHLZZ.js.map → chunk-XTBFIIAR.js.map} +1 -1
- package/dist/{chunk-O3XMYDNC.js → chunk-ZBGMIDDO.js} +5 -5
- package/dist/{chunk-O3XMYDNC.js.map → chunk-ZBGMIDDO.js.map} +1 -1
- package/dist/{chunk-CAULDK3N.js → chunk-ZC4O472R.js} +6 -6
- package/dist/{chunk-CAULDK3N.js.map → chunk-ZC4O472R.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 +23 -23
- package/dist/components/home/index.js +28 -28
- package/dist/components/layout/index.js +6 -6
- package/dist/components/product/index.js +25 -25
- package/dist/components/store/index.js +24 -24
- package/dist/components/toast/index.js +4 -4
- package/dist/dev/editor/index.js +2 -2
- package/dist/dev/index.js +2 -2
- package/dist/document-class-XYBFXCE7.js +33 -0
- package/dist/{document-class-N7WF3WXG.js.map → document-class-XYBFXCE7.js.map} +1 -1
- package/dist/hooks/index.js +23 -23
- package/dist/hooks/useComments.js +3 -3
- package/dist/hooks/useGtm.js +23 -23
- package/dist/hooks/useMoney.js +23 -23
- package/dist/hooks/useProduct.js +3 -3
- package/dist/hooks/useStore.js +23 -23
- package/dist/hooks/useUser.js +5 -5
- package/dist/hooks/useWishlist.js +3 -3
- package/dist/index.js +23 -23
- package/dist/native-app/index.js +3 -3
- package/dist/{navigation-FRKMKNLK.js → navigation-QDTYXINL.js} +7 -7
- package/dist/{navigation-FRKMKNLK.js.map → navigation-QDTYXINL.js.map} +1 -1
- package/dist/{navigation-5DPDZQUU.js → navigation-SHFUWYCA.js} +8 -8
- package/dist/{navigation-5DPDZQUU.js.map → navigation-SHFUWYCA.js.map} +1 -1
- package/dist/{not-found-4U2TRCLF.js → not-found-IFD562WC.js} +26 -26
- package/dist/{not-found-4U2TRCLF.js.map → not-found-IFD562WC.js.map} +1 -1
- package/dist/providers/index.js +23 -23
- package/dist/routes/account/orders.js +8 -8
- package/dist/routes/account.js +17 -17
- package/dist/routes/blog.js +12 -12
- package/dist/routes/brands.js +8 -8
- package/dist/routes/cart.js +32 -32
- package/dist/routes/home.js +29 -29
- package/dist/routes/index.js +6 -6
- package/dist/routes/loyalty.js +9 -9
- package/dist/routes/page/loader.d.ts.map +1 -1
- package/dist/routes/page.js +9 -8
- package/dist/routes/page.js.map +1 -1
- package/dist/routes/product/loader.d.ts.map +1 -1
- package/dist/routes/product-listing.js +33 -33
- package/dist/routes/product.js +29 -28
- package/dist/routes/product.js.map +1 -1
- package/dist/routes/seo-redirects.js +6 -6
- package/dist/routes/testimonials.js +4 -4
- package/dist/routes/thank-you.js +8 -8
- package/dist/skeleton.js +29 -29
- package/dist/{store-lookup-S6JUSKNH.js → store-lookup-AJT3ZHTS.js} +11 -11
- package/dist/{store-lookup-S6JUSKNH.js.map → store-lookup-AJT3ZHTS.js.map} +1 -1
- package/dist/tanstack/templates/locale-wrapper.d.ts +3 -1
- package/dist/tanstack/templates/locale-wrapper.d.ts.map +1 -1
- package/dist/tanstack.js +20 -20
- package/dist/utils/baseHead.js +2 -2
- package/dist/utils/cookies.d.ts +6 -0
- package/dist/utils/cookies.d.ts.map +1 -1
- package/dist/utils/index.js +6 -6
- package/dist/vite/index.js +32 -14
- package/dist/vite/index.js.map +1 -1
- package/package.json +1 -1
- package/tailwind/routes/page/loader.ts.txt +4 -0
- package/tailwind/routes/product/loader.ts.txt +5 -0
- package/dist/chunk-4E6FD5W7.js.map +0 -1
- package/dist/document-class-N7WF3WXG.js +0 -33
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/product/ProductCard.tsx"],"names":["ProductCardContent","ProductCard"],"mappings":";;;;;;;;;;;;;AAcA,IAAM,gBAAA,GAAmB,cAAA;AAEzB,IAAM,2BAAA,GAA8B,CAAC,GAAA,EAAK,GAAA,EAAK,KAAK,GAAG,CAAA;AAEvD,IAAM,mBAAA,GAAsB,+BAAA;AAE5B,IAAM,wBAAA,GAA2B,iCAAA;AAoCjC,IAAM,kBAAA,GAAqB,IAAA,CAAK,SAASA,mBAAAA,CAAmB;AAAA,EAC1D,OAAA;AAAA,EACA,MAAA,GAAS,UAAA;AAAA,EACT,SAAA,GAAY,EAAA;AAAA,EACZ,UAAA,GAAa,KAAA;AAAA,EACb,YAAA,GAAe,KAAA;AAAA,EACf,gBAAA,GAAmB,KAAA;AAAA,EACnB,KAAA,GAAQ,CAAA;AAAA,EACR,aAAA,GAAgB,KAAA;AAAA,EAChB;AACF,CAAA,EAAqB;AACnB,EAAA,MAAM,EAAE,MAAA,EAAO,GAAI,QAAA,EAAS;AAC5B,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,cAAA,EAAe;AAC7B,EAAA,MAAM,EAAE,KAAA,EAAO,KAAA,EAAM,GAAI,WAAA,EAAY;AACrC,EAAA,MAAM,WAAW,WAAA,EAAY;AAC7B,EAAA,MAAM,EAAE,aAAA,EAAc,GAAI,QAAA,EAAS;AACnC,EAAA,MAAM,EAAE,MAAA,EAAQ,YAAA,EAAa,GAAI,SAAA,EAAU;AAI3C,EAAA,MAAM,YAAA,GAAe,KAAA,EAAO,QAAA,EAAU,6BAAA,KAAkC,KAAA;AACxE,EAAA,MAAM,eAAA,GACJ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AA,EAC/B;AAEA,EAAA,uBAAO,GAAA,CAAC,kBAAA,EAAA,EAAoB,GAAG,KAAA,EAAO,CAAA;AACxC,CAAC","file":"chunk-PVOJJ2BV.js","sourcesContent":["import { memo, useCallback, useMemo } from 'react';\nimport { SallaAddProductButton } from '@salla.sa/twilight-components-react/add-product-button';\nimport { SallaButton } from '@salla.sa/twilight-components-react/button';\nimport { useHostAttributes } from '@salla.sa/twilight-theme-engine/hooks/useHostAttributes';\nimport { useMoney } from '../../hooks/useMoney';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport { useTwilight } from '../../providers/TwilightProvider';\nimport { useWishlist } from '../../hooks/useWishlist';\nimport { useAsset } from '../../hooks/useAsset';\nimport { useNumber } from '../../hooks/useNumber';\nimport { registry } from '../ComponentRegistry';\nimport { Image } from '../common';\nimport type { Product } from '../../types';\n\nconst PRODUCT_CARD_KEY = 'product:card';\n\nconst PRODUCT_IMAGE_SRCSET_WIDTHS = [150, 300, 450, 600] as const;\n/** Matches `.s-products-list-vertical-cards`: 2-col below 768px, 4-col above. */\nconst PRODUCT_IMAGE_SIZES = '(min-width: 768px) 25vw, 50vw';\n/** fullImage / minimal slots in FeaturedProductsStyle3 (`lg:grid-cols-2`). */\nconst PRODUCT_WIDE_IMAGE_SIZES = '(min-width: 1024px) 50vw, 100vw';\n\n/** Product card layout variants - mutually exclusive */\nexport type ProductCardLayout = 'vertical' | 'horizontal' | 'fullImage' | 'minimal' | 'special';\n\nexport interface ProductCardProps {\n product: Product;\n layout?: ProductCardLayout;\n className?: string;\n withShadow?: boolean;\n withQuantity?: boolean;\n withoutAddButton?: boolean;\n index?: number;\n imagePriority?: boolean;\n /** Overrides the layout-based image `sizes` hint. */\n sizes?: string;\n}\n\n/**\n * ProductCard - Displays a product in various layouts\n *\n * Layouts:\n * - vertical: Default card with image top, content bottom\n * - horizontal: Side-by-side image and content\n * - fullImage: Full bleed image with overlay content\n * - minimal: Compact version with reduced info\n * - special: Featured card with quantity pie chart\n *\n * Features:\n * - Native lazy loading for images\n * - Product badges (promotion, preorder, quantity, out of stock)\n * - Wishlist toggle button\n * - Price display (sale, starting, regular)\n * - Rating display\n * - Add to cart button via SallaAddProductButton (handles labels internally)\n */\nconst ProductCardContent = memo(function ProductCardContent({\n product,\n layout = 'vertical',\n className = '',\n withShadow = false,\n withQuantity = false,\n withoutAddButton = false,\n index = 0,\n imagePriority = false,\n sizes,\n}: ProductCardProps) {\n const { format } = useMoney();\n const { t } = useTranslation();\n const { store, theme } = useTwilight();\n const wishlist = useWishlist();\n const { isPlaceholder } = useAsset();\n const { format: formatNumber } = useNumber();\n\n // Out-of-stock cards offer \"notify me when available\" instead of a dead button, unless\n // the merchant switched `notify_when_available_in_card` off (Twig theme-raed parity).\n const notifyInCard = theme?.settings?.notify_when_available_in_card !== false;\n const addButtonStatus =\n notifyInCard &&\n product.is_out_of_stock &&\n product.type !== 'donating' &&\n product.type !== 'financial_support'\n ? 'out-and-notify'\n : product.status;\n\n const addButtonRef = useHostAttributes({ fill: 'outline', width: 'wide' });\n\n // Layout flags\n const isVertical = layout === 'vertical';\n const isHorizontal = layout === 'horizontal';\n const isFullImage = layout === 'fullImage';\n const isMinimal = layout === 'minimal';\n const isSpecial = layout === 'special';\n\n // Wishlist status\n const productInWishlist = wishlist.has(Number(product.id));\n const handleWishlistToggle = useCallback(() => {\n wishlist.toggle(Number(product.id));\n }, [wishlist, product.id]);\n\n // Get image fit type from store settings\n const fitImageHeight = store?.settings?.product?.fit_type;\n\n // Product badge component\n const getProductBadge = () => {\n if (product?.preorder?.label && typeof product.preorder.label === 'string') {\n return <div className=\"s-product-card-promotion-title\">{product.preorder.label}</div>;\n }\n if (product.promotion_title) {\n return <div className=\"s-product-card-promotion-title\">{product.promotion_title}</div>;\n }\n if (withQuantity && product?.quantity) {\n const formattedQty = formatNumber(product.quantity);\n return (\n <div className=\"s-product-card-quantity\">\n {t('pages.products.remained', 'Remained')} {formattedQty}\n </div>\n );\n }\n if (withQuantity && product?.is_out_of_stock) {\n return (\n <div className=\"s-product-card-out-badge\">\n {t('pages.products.out_of_stock', 'Out of Stock')}\n </div>\n );\n }\n return null;\n };\n\n // Price display component\n const getProductPrice = () => {\n if (product.is_on_sale && product.sale_price) {\n return (\n <div className=\"s-product-card-sale-price\">\n <h4>{format(product.sale_price)}</h4>\n {product.regular_price && <span>{format(product.regular_price)}</span>}\n </div>\n );\n }\n if (product.starting_price) {\n return (\n <div className=\"s-product-card-starting-price\">\n <p>{t('pages.products.starting_price', 'Starting from')}</p>\n <h4>{format(product.starting_price)}</h4>\n </div>\n );\n }\n return <h4 className=\"s-product-card-price\">{format(product.price)}</h4>;\n };\n\n // Build card class names\n const cardClassName = [\n 's-product-card',\n 's-product-card-entry',\n isVertical ? 's-product-card-vertical' : '',\n isHorizontal ? 's-product-card-horizontal' : '',\n // As Twig's card: the store's unified image height sizes horizontal cards too.\n fitImageHeight && (isVertical || isHorizontal) ? `s-product-card-fit-height` : '',\n isSpecial ? 's-product-card-special' : '',\n isFullImage ? 's-product-card-full-image' : '',\n isMinimal ? 's-product-card-minimal' : '',\n product?.donation ? 's-product-card-donation' : '',\n withShadow ? 's-product-card-shadow' : '',\n product?.is_out_of_stock ? 's-product-card-out-of-stock' : '',\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n // Image fit class\n const isProductPlaceholder = isPlaceholder(product.image?.url);\n const imageFitClass = isProductPlaceholder ? 'contain' : fitImageHeight || 'cover';\n\n return (\n <div\n id={`product-card-${product.id}`}\n className={cardClassName}\n data-product-id={product.id}\n style={{\n animationDelay: `${index * 100}ms`,\n }}\n >\n <div className={isFullImage ? 's-product-card-image-full' : 's-product-card-image'}>\n <a href={product.url} aria-label={product.image?.alt || product.name}>\n <Image\n className={`s-product-card-image-${imageFitClass}`}\n src={product.image?.url}\n alt={product.image?.alt ?? product.name}\n width={300}\n height={300}\n sizes={\n sizes ?? (isFullImage || isMinimal ? PRODUCT_WIDE_IMAGE_SIZES : PRODUCT_IMAGE_SIZES)\n }\n srcSetWidths={PRODUCT_IMAGE_SRCSET_WIDTHS}\n aspectRatio=\"1/1\"\n priority={imagePriority}\n />\n {!isFullImage && !isMinimal && getProductBadge()}\n </a>\n {isFullImage && (\n <a href={product.url} aria-label={product.name} className=\"s-product-card-overlay\" />\n )}\n {!isHorizontal && !isFullImage && (\n <SallaButton\n shape=\"icon\"\n fill=\"outline\"\n color=\"light\"\n ariaLabel={t('pages.wishlist.toggle', 'Add or remove to wishlist')}\n className={`s-product-card-wishlist-btn animated ${productInWishlist ? 's-product-card-wishlist-added pulse-anime' : 'not-added un-favorited'}`}\n onClick={handleWishlistToggle}\n data-id={product.id}\n >\n <i className=\"sicon-heart\" />\n </SallaButton>\n )}\n </div>\n <div className=\"s-product-card-content\">\n {/* Special card: quantity pie */}\n {isSpecial && product?.quantity && (\n <div className=\"s-product-card-content-pie\">\n <span>\n <b>{formatNumber(product.quantity)}</b>\n {t('pages.products.remained', 'Remained')}\n </span>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"-2 -1 36 34\"\n className=\"s-product-card-content-pie-svg\"\n >\n <circle cx=\"16\" cy=\"16\" r=\"15.9155\" className=\"s-product-card-content-pie-svg-base\" />\n <circle cx=\"16\" cy=\"16\" r=\"15.9155\" className=\"s-product-card-content-pie-svg-bar\" />\n </svg>\n </div>\n )}\n\n <div\n className={`s-product-card-content-main ${isSpecial ? 's-product-card-content-extra-padding' : ''}`}\n >\n <h3 className=\"s-product-card-content-title\">\n <a href={product.url}>{product.name}</a>\n </h3>\n {product.subtitle && !isMinimal && (\n <p className=\"s-product-card-content-subtitle opacity-80\">{product.subtitle}</p>\n )}\n </div>\n\n <div\n className={`s-product-card-content-sub ${isSpecial ? 's-product-card-content-extra-padding' : ''}`}\n >\n {!product?.donation?.can_donate && getProductPrice()}\n {product.rating?.stars && (\n <div className=\"s-product-card-rating\">\n <i className=\"sicon-star2 text-orange-300\" />\n <span>{product.rating.stars}</span>\n </div>\n )}\n </div>\n\n {!withoutAddButton && (\n <div className=\"s-product-card-content-footer gap-2\">\n <SallaAddProductButton\n ref={addButtonRef}\n fill=\"outline\"\n width=\"wide\"\n productId={product.id}\n productStatus={addButtonStatus}\n productType={product.type}\n hasPreOrder={product.has_preorder_campaign}\n />\n {(isHorizontal || isFullImage) && (\n <SallaButton\n shape=\"icon\"\n fill=\"outline\"\n color=\"light\"\n ariaLabel={t('pages.wishlist.toggle', 'Add or remove to wishlist')}\n className={`s-product-card-wishlist-btn animated ${productInWishlist ? 's-product-card-wishlist-added pulse-anime' : 'not-added un-favorited'}`}\n onClick={handleWishlistToggle}\n data-id={product.id}\n >\n <i className=\"sicon-heart\" />\n </SallaButton>\n )}\n </div>\n )}\n </div>\n </div>\n );\n});\n\nexport const ProductCard = memo(function ProductCard(props: ProductCardProps) {\n const Component = useMemo(() => {\n const hasOverride = registry.getOriginal<ProductCardProps>(PRODUCT_CARD_KEY) !== null;\n if (hasOverride) {\n return registry.resolve<ProductCardProps>(PRODUCT_CARD_KEY);\n }\n return null;\n }, []);\n\n if (Component) {\n return <Component {...props} />;\n }\n\n return <ProductCardContent {...props} />;\n});\n\nexport default ProductCard;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/product/ProductCard.tsx"],"names":["ProductCardContent","ProductCard"],"mappings":";;;;;;;;;;;;;AAcA,IAAM,gBAAA,GAAmB,cAAA;AAEzB,IAAM,2BAAA,GAA8B,CAAC,GAAA,EAAK,GAAA,EAAK,KAAK,GAAG,CAAA;AAEvD,IAAM,mBAAA,GAAsB,+BAAA;AAE5B,IAAM,wBAAA,GAA2B,iCAAA;AAoCjC,IAAM,kBAAA,GAAqB,IAAA,CAAK,SAASA,mBAAAA,CAAmB;AAAA,EAC1D,OAAA;AAAA,EACA,MAAA,GAAS,UAAA;AAAA,EACT,SAAA,GAAY,EAAA;AAAA,EACZ,UAAA,GAAa,KAAA;AAAA,EACb,YAAA,GAAe,KAAA;AAAA,EACf,gBAAA,GAAmB,KAAA;AAAA,EACnB,KA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;AAAA,SAAA,EAEJ;AAAA;AAAA;AAAA,GACF;AAEJ,CAAC,CAAA;AAEM,IAAM,WAAA,GAAc,IAAA,CAAK,SAASC,YAAAA,CAAY,KAAA,EAAyB;AAC5E,EAAA,MAAM,SAAA,GAAY,QAAQ,MAAM;AAC9B,IAAA,MAAM,WAAA,GAAc,QAAA,CAAS,WAAA,CAA8B,gBAAgB,CAAA,KAAM,IAAA;AACjF,IAAA,IAAI,WAAA,EAAa;AACf,MAAA,OAAO,QAAA,CAAS,QAA0B,gBAAgB,CAAA;AAAA,IAC5D;AACA,IAAA,OAAO,IAAA;AAAA,EACT,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,IAAI,SAAA,EAAW;AACb,IAAA,uBAAO,GAAA,CAAC,SAAA,EAAA,EAAW,GAAG,KAAA,EAAO,CAAA;AAAA,EAC/B;AAEA,EAAA,uBAAO,GAAA,CAAC,kBAAA,EAAA,EAAoB,GAAG,KAAA,EAAO,CAAA;AACxC,CAAC","file":"chunk-64RDACOS.js","sourcesContent":["import { memo, useCallback, useMemo } from 'react';\nimport { SallaAddProductButton } from '@salla.sa/twilight-components-react/add-product-button';\nimport { SallaButton } from '@salla.sa/twilight-components-react/button';\nimport { useHostAttributes } from '@salla.sa/twilight-theme-engine/hooks/useHostAttributes';\nimport { useMoney } from '../../hooks/useMoney';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport { useTwilight } from '../../providers/TwilightProvider';\nimport { useWishlist } from '../../hooks/useWishlist';\nimport { useAsset } from '../../hooks/useAsset';\nimport { useNumber } from '../../hooks/useNumber';\nimport { registry } from '../ComponentRegistry';\nimport { Image } from '../common';\nimport type { Product } from '../../types';\n\nconst PRODUCT_CARD_KEY = 'product:card';\n\nconst PRODUCT_IMAGE_SRCSET_WIDTHS = [150, 300, 450, 600] as const;\n/** Matches `.s-products-list-vertical-cards`: 2-col below 768px, 4-col above. */\nconst PRODUCT_IMAGE_SIZES = '(min-width: 768px) 25vw, 50vw';\n/** fullImage / minimal slots in FeaturedProductsStyle3 (`lg:grid-cols-2`). */\nconst PRODUCT_WIDE_IMAGE_SIZES = '(min-width: 1024px) 50vw, 100vw';\n\n/** Product card layout variants - mutually exclusive */\nexport type ProductCardLayout = 'vertical' | 'horizontal' | 'fullImage' | 'minimal' | 'special';\n\nexport interface ProductCardProps {\n product: Product;\n layout?: ProductCardLayout;\n className?: string;\n withShadow?: boolean;\n withQuantity?: boolean;\n withoutAddButton?: boolean;\n index?: number;\n imagePriority?: boolean;\n /** Overrides the layout-based image `sizes` hint. */\n sizes?: string;\n}\n\n/**\n * ProductCard - Displays a product in various layouts\n *\n * Layouts:\n * - vertical: Default card with image top, content bottom\n * - horizontal: Side-by-side image and content\n * - fullImage: Full bleed image with overlay content\n * - minimal: Compact version with reduced info\n * - special: Featured card with quantity pie chart\n *\n * Features:\n * - Native lazy loading for images\n * - Product badges (promotion, preorder, quantity, out of stock)\n * - Wishlist toggle button\n * - Price display (sale, starting, regular)\n * - Rating display\n * - Add to cart button via SallaAddProductButton (handles labels internally)\n */\nconst ProductCardContent = memo(function ProductCardContent({\n product,\n layout = 'vertical',\n className = '',\n withShadow = false,\n withQuantity = false,\n withoutAddButton = false,\n index = 0,\n imagePriority = false,\n sizes,\n}: ProductCardProps) {\n const { format } = useMoney();\n const { t } = useTranslation();\n const { store, theme } = useTwilight();\n const wishlist = useWishlist();\n const { isPlaceholder } = useAsset();\n const { format: formatNumber } = useNumber();\n\n // Out-of-stock cards offer \"notify me when available\" instead of a dead button, unless\n // the merchant switched `notify_when_available_in_card` off (Twig theme-raed parity).\n const notifyInCard = theme?.settings?.notify_when_available_in_card !== false;\n const addButtonStatus =\n notifyInCard &&\n product.is_out_of_stock &&\n product.type !== 'donating' &&\n product.type !== 'financial_support'\n ? 'out-and-notify'\n : product.status;\n\n const addButtonRef = useHostAttributes({ fill: 'outline', width: 'wide' });\n\n // Layout flags\n const isVertical = layout === 'vertical';\n const isHorizontal = layout === 'horizontal';\n const isFullImage = layout === 'fullImage';\n const isMinimal = layout === 'minimal';\n const isSpecial = layout === 'special';\n\n // Wishlist status\n const productInWishlist = wishlist.has(Number(product.id));\n const handleWishlistToggle = useCallback(() => {\n wishlist.toggle(Number(product.id));\n }, [wishlist, product.id]);\n\n // Get image fit type from store settings\n const fitImageHeight = store?.settings?.product?.fit_type;\n\n // Product badge component\n const getProductBadge = () => {\n if (product?.preorder?.label && typeof product.preorder.label === 'string') {\n return <div className=\"s-product-card-promotion-title\">{product.preorder.label}</div>;\n }\n if (product.promotion_title) {\n return <div className=\"s-product-card-promotion-title\">{product.promotion_title}</div>;\n }\n if (withQuantity && product?.quantity) {\n const formattedQty = formatNumber(product.quantity);\n return (\n <div className=\"s-product-card-quantity\">\n {t('pages.products.remained', 'Remained')} {formattedQty}\n </div>\n );\n }\n if (withQuantity && product?.is_out_of_stock) {\n return (\n <div className=\"s-product-card-out-badge\">\n {t('pages.products.out_of_stock', 'Out of Stock')}\n </div>\n );\n }\n return null;\n };\n\n // Price display component\n const getProductPrice = () => {\n if (product.is_on_sale && product.sale_price) {\n return (\n <div className=\"s-product-card-sale-price\">\n <h4>{format(product.sale_price)}</h4>\n {product.regular_price && <span>{format(product.regular_price)}</span>}\n </div>\n );\n }\n if (product.starting_price) {\n return (\n <div className=\"s-product-card-starting-price\">\n <p>{t('pages.products.starting_price', 'Starting from')}</p>\n <h4>{format(product.starting_price)}</h4>\n </div>\n );\n }\n return <h4 className=\"s-product-card-price\">{format(product.price)}</h4>;\n };\n\n // Build card class names\n const cardClassName = [\n 's-product-card',\n 's-product-card-entry',\n isVertical ? 's-product-card-vertical' : '',\n isHorizontal ? 's-product-card-horizontal' : '',\n // As Twig's card: the store's unified image height sizes horizontal cards too.\n fitImageHeight && (isVertical || isHorizontal) ? `s-product-card-fit-height` : '',\n isSpecial ? 's-product-card-special' : '',\n isFullImage ? 's-product-card-full-image' : '',\n isMinimal ? 's-product-card-minimal' : '',\n product?.donation ? 's-product-card-donation' : '',\n withShadow ? 's-product-card-shadow' : '',\n product?.is_out_of_stock ? 's-product-card-out-of-stock' : '',\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n // Image fit class\n const isProductPlaceholder = isPlaceholder(product.image?.url);\n const imageFitClass = isProductPlaceholder ? 'contain' : fitImageHeight || 'cover';\n\n return (\n <div\n id={`product-card-${product.id}`}\n className={cardClassName}\n data-product-id={product.id}\n style={{\n animationDelay: `${index * 100}ms`,\n }}\n >\n <div className={isFullImage ? 's-product-card-image-full' : 's-product-card-image'}>\n <a href={product.url} aria-label={product.image?.alt || product.name}>\n <Image\n className={`s-product-card-image-${imageFitClass}`}\n src={product.image?.url}\n alt={product.image?.alt ?? product.name}\n width={300}\n height={300}\n sizes={\n sizes ?? (isFullImage || isMinimal ? PRODUCT_WIDE_IMAGE_SIZES : PRODUCT_IMAGE_SIZES)\n }\n srcSetWidths={PRODUCT_IMAGE_SRCSET_WIDTHS}\n aspectRatio=\"1/1\"\n priority={imagePriority}\n />\n {!isFullImage && !isMinimal && getProductBadge()}\n </a>\n {isFullImage && (\n <a href={product.url} aria-label={product.name} className=\"s-product-card-overlay\" />\n )}\n {!isHorizontal && !isFullImage && (\n <SallaButton\n shape=\"icon\"\n fill=\"outline\"\n color=\"light\"\n ariaLabel={t('pages.wishlist.toggle', 'Add or remove to wishlist')}\n className={`s-product-card-wishlist-btn animated ${productInWishlist ? 's-product-card-wishlist-added pulse-anime' : 'not-added un-favorited'}`}\n onClick={handleWishlistToggle}\n data-id={product.id}\n >\n <i className=\"sicon-heart\" />\n </SallaButton>\n )}\n </div>\n <div className=\"s-product-card-content\">\n {/* Special card: quantity pie */}\n {isSpecial && product?.quantity && (\n <div className=\"s-product-card-content-pie\">\n <span>\n <b>{formatNumber(product.quantity)}</b>\n {t('pages.products.remained', 'Remained')}\n </span>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"-2 -1 36 34\"\n className=\"s-product-card-content-pie-svg\"\n >\n <circle cx=\"16\" cy=\"16\" r=\"15.9155\" className=\"s-product-card-content-pie-svg-base\" />\n <circle cx=\"16\" cy=\"16\" r=\"15.9155\" className=\"s-product-card-content-pie-svg-bar\" />\n </svg>\n </div>\n )}\n\n <div\n className={`s-product-card-content-main ${isSpecial ? 's-product-card-content-extra-padding' : ''}`}\n >\n <h3 className=\"s-product-card-content-title\">\n <a href={product.url}>{product.name}</a>\n </h3>\n {product.subtitle && !isMinimal && (\n <p className=\"s-product-card-content-subtitle opacity-80\">{product.subtitle}</p>\n )}\n </div>\n\n <div\n className={`s-product-card-content-sub ${isSpecial ? 's-product-card-content-extra-padding' : ''}`}\n >\n {!product?.donation?.can_donate && getProductPrice()}\n {product.rating?.stars && (\n <div className=\"s-product-card-rating\">\n <i className=\"sicon-star2 text-orange-300\" />\n <span>{product.rating.stars}</span>\n </div>\n )}\n </div>\n\n {!withoutAddButton && (\n <div className=\"s-product-card-content-footer gap-2\">\n <SallaAddProductButton\n ref={addButtonRef}\n fill=\"outline\"\n width=\"wide\"\n productId={product.id}\n productStatus={addButtonStatus}\n productType={product.type}\n hasPreOrder={product.has_preorder_campaign}\n />\n {(isHorizontal || isFullImage) && (\n <SallaButton\n shape=\"icon\"\n fill=\"outline\"\n color=\"light\"\n ariaLabel={t('pages.wishlist.toggle', 'Add or remove to wishlist')}\n className={`s-product-card-wishlist-btn animated ${productInWishlist ? 's-product-card-wishlist-added pulse-anime' : 'not-added un-favorited'}`}\n onClick={handleWishlistToggle}\n data-id={product.id}\n >\n <i className=\"sicon-heart\" />\n </SallaButton>\n )}\n </div>\n )}\n </div>\n </div>\n );\n});\n\nexport const ProductCard = memo(function ProductCard(props: ProductCardProps) {\n const Component = useMemo(() => {\n const hasOverride = registry.getOriginal<ProductCardProps>(PRODUCT_CARD_KEY) !== null;\n if (hasOverride) {\n return registry.resolve<ProductCardProps>(PRODUCT_CARD_KEY);\n }\n return null;\n }, []);\n\n if (Component) {\n return <Component {...props} />;\n }\n\n return <ProductCardContent {...props} />;\n});\n\nexport default ProductCard;\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { api } from './chunk-
|
|
1
|
+
import { api } from './chunk-FCFIG4M3.js';
|
|
2
2
|
import { queryOptions } from '@tanstack/react-query';
|
|
3
3
|
|
|
4
4
|
var user = {
|
|
@@ -19,5 +19,5 @@ var user = {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
export { user };
|
|
22
|
-
//# sourceMappingURL=chunk-
|
|
23
|
-
//# sourceMappingURL=chunk-
|
|
22
|
+
//# sourceMappingURL=chunk-677OXNGV.js.map
|
|
23
|
+
//# sourceMappingURL=chunk-677OXNGV.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/user.ts"],"names":[],"mappings":";;;AAIO,IAAM,IAAA,GAAO;AAAA,EAClB,KAAK,YAAkC;AACrC,IAAA,IAAI;AACF,MAAA,OAAO,MAAM,GAAA,CACV,GAAA,CAAI,WAAW,CAAA,CACf,MAAmC,CACnC,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,GAAG,CAAA,CAAE,IAAA,EAAM,IAAA,EAAM,QAAgB,CAAE,CAAA;AAAA,IACvD,SAAS,KAAA,EAAO;AACd,MAAA,OAAA,CAAQ,KAAA,CAAM,sBAAsB,KAAK,CAAA;AACzC,MAAA,OAAO,IAAA;AAAA,IACT;AAAA,EACF,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,OAAA,EAAS,MACP,YAAA,CAA0B;AAAA,MACxB,QAAA,EAAU,CAAC,MAAA,EAAQ,SAAS,CAAA;AAAA,MAC5B,SAAS,IAAA,CAAK;AAAA,KACf;AAAA;AAEP","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/api/user.ts"],"names":[],"mappings":";;;AAIO,IAAM,IAAA,GAAO;AAAA,EAClB,KAAK,YAAkC;AACrC,IAAA,IAAI;AACF,MAAA,OAAO,MAAM,GAAA,CACV,GAAA,CAAI,WAAW,CAAA,CACf,MAAmC,CACnC,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,GAAG,CAAA,CAAE,IAAA,EAAM,IAAA,EAAM,QAAgB,CAAE,CAAA;AAAA,IACvD,SAAS,KAAA,EAAO;AACd,MAAA,OAAA,CAAQ,KAAA,CAAM,sBAAsB,KAAK,CAAA;AACzC,MAAA,OAAO,IAAA;AAAA,IACT;AAAA,EACF,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,OAAA,EAAS,MACP,YAAA,CAA0B;AAAA,MACxB,QAAA,EAAU,CAAC,MAAA,EAAQ,SAAS,CAAA;AAAA,MAC5B,SAAS,IAAA,CAAK;AAAA,KACf;AAAA;AAEP","file":"chunk-677OXNGV.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\nimport type { User } from '../types';\n\nexport const user = {\n get: async (): Promise<User | null> => {\n try {\n return await api\n .get('auth/user')\n .json<{ data: Omit<User, 'type'> }>()\n .then((r) => ({ ...r.data, type: 'user' as const }));\n } catch (error) {\n console.debug('[user.get] Failed:', error);\n return null;\n }\n },\n\n queries: {\n current: () =>\n queryOptions<User | null>({\n queryKey: ['user', 'current'],\n queryFn: user.get,\n }),\n },\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getInjectedRuntimeEnv, resolveStoreIdentifier } from './chunk-
|
|
1
|
+
import { getInjectedRuntimeEnv, resolveStoreIdentifier } from './chunk-EEL6OYAQ.js';
|
|
2
2
|
import { getRequestStore, getTwilightContext } from './chunk-6K34BCUP.js';
|
|
3
3
|
|
|
4
4
|
// src/utils/theme-version.ts
|
|
@@ -121,5 +121,5 @@ function syncSdkThemeVersion(headers) {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
export { getSallaSDK, getStoreIdentifier, onSallaEvent, requestedThemeVersionId, resolveThemeVersionId, syncSdkLocale, syncSdkThemeVersion, whenSallaLoaded, whenSallaReady, withSdkThemeVersion };
|
|
124
|
-
//# sourceMappingURL=chunk-
|
|
125
|
-
//# sourceMappingURL=chunk-
|
|
124
|
+
//# sourceMappingURL=chunk-7IVHY4OR.js.map
|
|
125
|
+
//# sourceMappingURL=chunk-7IVHY4OR.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/theme-version.ts","../src/utils/sdk-helpers.ts"],"names":[],"mappings":";;;;AAqCO,SAAS,uBAAA,GAAyC;AACvD,EAAA,MAAM,EAAE,SAAA,EAAU,GAAI,eAAA,EAAgB;AACtC,EAAA,IAAI,WAAW,OAAO,SAAA;AAEtB,EAAA,OAAO,qBAAA,GAAwB,SAAA,IAAa,IAAA;AAC9C;AAmCA,SAAS,YAAA,CAAa,UAA2C,aAAA,EAA8B;AAC7F,EAAA,MAAM,gBAAA,GAAmB,UAAU,gBAAA,IAAoB,IAAA;AACvD,EAAA,IAAI,aAAA,IAAiB,IAAA,EAAM,OAAO,gBAAA,IAAoB,IAAA;AACtD,EAAA,MAAM,eAAA,GAAkB,QAAA,EAAU,KAAA,EAAO,KAAA,EAAO,EAAA;AAChD,EAAA,OAAA,CAAQ,eAAA,IAAmB,IAAA,GAAO,MAAA,CAAO,eAAe,IAAI,gBAAA,MAAsB,aAAA;AACpF;AAEO,SAAS,qBAAA,CAAsB,gBAA+B,IAAA,EAAqB;AACxF,EAAA,MAAM,YAAY,uBAAA,EAAwB;AAC1C,EAAA,IAAI,WAAW,OAAO,SAAA;AAEtB,EAAA,IAAI;AACF,IAAA,MAAM,QAAA,GAAW,oBAAmB,CAAE,QAAA;AACtC,IAAA,IAAI,CAAC,YAAA,CAAa,QAAA,EAAU,aAAa,GAAG,OAAO,IAAA;AAEnD,IAAA,MAAM,SAAA,GAAY,QAAA,EAAU,KAAA,EAAO,OAAA,EAAS,EAAA;AAC5C,IAAA,OAAO,SAAA,IAAa,IAAA,GAAO,MAAA,CAAO,SAAS,CAAA,GAAI,IAAA;AAAA,EACjD,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;;;AC3FA,IAAM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SAAA,GAAY,iBAAA,EAAmB,MAAM,CAAA;AAG9C,IAAA,GAAA,CAAI,MAAA,EAAQ,GAAA,GAAM,oBAAA,EAAsB,MAAM,CAAA;AAAA,EAChD,CAAA,CAAA,MAAQ;AAAA,EAER;AACF;AAaA,SAAS,kBAAkB,OAAA,EAAiD;AAC1E,EAAA,MAAM,SAAA,GAAY,uBAAA,EAAwB,IAAK,OAAA,GAAU,cAAc,CAAA;AACvE,EAAA,OAAO,SAAA,IAAa,IAAA,GAAO,MAAA,CAAO,SAAS,CAAA,GAAI,IAAA;AACjD;AAWO,SAAS,oBAA6D,QAAA,EAAgB;AAC3F,EAAA,MAAM,YAAY,uBAAA,EAAwB;AAC1C,EAAA,IAAI,CAAC,WAAW,OAAO,QAAA;AACvB,EAAA,OAAO,EAAE,GAAG,QAAA,EAAU,OAAA,EAAS,EAAE,GAAG,QAAA,CAAS,OAAA,EAAS,cAAA,EAAgB,SAAA,EAAU,EAAE;AACpF;AAcO,SAAS,oBAAoB,OAAA,EAAwC;AAC1E,EAAA,MAAM,MAAM,WAAA,EAAY;AACxB,EAAA,IAAI,CAAC,GAAA,EAAK;AACV,EAAA,MAAM,SAAA,GAAY,kBAAkB,OAAO,CAAA;AAC3C,EAAA,IAAI;AACF,IAAA,IAAI,aAAa,IAAA,EAAM,GAAA,CAAI,GAAA,EAAK,SAAA,GAAY,gBAAgB,SAAS,CAAA;AAAA,gBACzD,GAAA,CAAI,GAAA,EAAK,OAAO,QAAA,EAAU,OAAA,EAAS,SAAS,cAAc,CAAA;AAAA,EACxE,CAAA,CAAA,MAAQ;AAAA,EAER;AACF","file":"chunk-7XAGU6CT.js","sourcesContent":["/**\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 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 { resolveStoreIdentifier } from './store-identity';\nimport { 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.\n *\n * `init` spreads `headers` over its axios defaults, and on a first load nothing\n * re-asserts the version 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 */\nexport function withSdkThemeVersion<T extends Pick<StoreContext, 'headers'>>(settings: T): T {\n const versionId = requestedThemeVersionId();\n if (!versionId) return settings;\n return { ...settings, headers: { ...settings.headers, 's-version-id': versionId } };\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. No-op on the server and until the SDK exposes its api.\n */\nexport function syncSdkThemeVersion(headers: StoreContext['headers']): void {\n const sdk = getSallaSDK();\n if (!sdk) return;\n const versionId = sdkThemeVersionId(headers);\n try {\n if (versionId != null) sdk.api?.setHeader?.('s-version-id', versionId);\n else delete sdk.api?.axios?.defaults?.headers?.common?.['s-version-id'];\n } catch {\n // SDK partially loaded — the header is re-asserted on the next navigation.\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/theme-version.ts","../src/utils/sdk-helpers.ts"],"names":[],"mappings":";;;;AAqCO,SAAS,uBAAA,GAAyC;AACvD,EAAA,MAAM,EAAE,SAAA,EAAU,GAAI,eAAA,EAAgB;AACtC,EAAA,IAAI,WAAW,OAAO,SAAA;AAEtB,EAAA,OAAO,qBAAA,GAAwB,SAAA,IAAa,IAAA;AAC9C;AAmCA,SAAS,YAAA,CAAa,UAA2C,aAAA,EAA8B;AAC7F,EAAA,MAAM,gBAAA,GAAmB,UAAU,gBAAA,IAAoB,IAAA;AACvD,EAAA,IAAI,aAAA,IAAiB,IAAA,EAAM,OAAO,gBAAA,IAAoB,IAAA;AACtD,EAAA,MAAM,eAAA,GAAkB,QAAA,EAAU,KAAA,EAAO,KAAA,EAAO,EAAA;AAChD,EAAA,OAAA,CAAQ,eAAA,IAAmB,IAAA,GAAO,MAAA,CAAO,eAAe,IAAI,gBAAA,MAAsB,aAAA;AACpF;AAEO,SAAS,qBAAA,CAAsB,gBAA+B,IAAA,EAAqB;AACxF,EAAA,MAAM,YAAY,uBAAA,EAAwB;AAC1C,EAAA,IAAI,WAAW,OAAO,SAAA;AAEtB,EAAA,IAAI;AACF,IAAA,MAAM,QAAA,GAAW,oBAAmB,CAAE,QAAA;AACtC,IAAA,IAAI,CAAC,YAAA,CAAa,QAAA,EAAU,aAAa,GAAG,OAAO,IAAA;AAEnD,IAAA,MAAM,SAAA,GAAY,QAAA,EAAU,KAAA,EAAO,OAAA,EAAS,EAAA;AAC5C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EAAA,IAAI,CAAC,GAAA,IAAO,CAAC,MAAA,EAAQ;AACrB,EAAA,IAAI;AACF,IAAA,GAAA,CAAI,IAAA,EAAM,YAAY,MAAM,CAAA;AAC5B,IAAA,GAAA,CAAI,GAAA,EAAK,SAAA,GAAY,iBAAA,EAAmB,MAAM,CAAA;AAG9C,IAAA,GAAA,CAAI,MAAA,EAAQ,GAAA,GAAM,oBAAA,EAAsB,MAAM,CAAA;AAAA,EAChD,CAAA,CAAA,MAAQ;AAAA,EAER;AACF;AAaA,SAAS,kBAAkB,OAAA,EAAiD;AAC1E,EAAA,MAAM,SAAA,GAAY,uBAAA,EAAwB,IAAK,OAAA,GAAU,cAAc,CAAA;AACvE,EAAA,OAAO,SAAA,IAAa,IAAA,GAAO,MAAA,CAAO,SAAS,CAAA,GAAI,IAAA;AACjD;AAWO,SAAS,oBAA6D,QAAA,EAAgB;AAC3F,EAAA,MAAM,YAAY,uBAAA,EAAwB;AAC1C,EAAA,IAAI,CAAC,WAAW,OAAO,QAAA;AACvB,EAAA,OAAO,EAAE,GAAG,QAAA,EAAU,OAAA,EAAS,EAAE,GAAG,QAAA,CAAS,OAAA,EAAS,cAAA,EAAgB,SAAA,EAAU,EAAE;AACpF;AAcO,SAAS,oBAAoB,OAAA,EAAwC;AAC1E,EAAA,MAAM,MAAM,WAAA,EAAY;AACxB,EAAA,IAAI,CAAC,GAAA,EAAK;AACV,EAAA,MAAM,SAAA,GAAY,kBAAkB,OAAO,CAAA;AAC3C,EAAA,IAAI;AACF,IAAA,IAAI,aAAa,IAAA,EAAM,GAAA,CAAI,GAAA,EAAK,SAAA,GAAY,gBAAgB,SAAS,CAAA;AAAA,gBACzD,GAAA,CAAI,GAAA,EAAK,OAAO,QAAA,EAAU,OAAA,EAAS,SAAS,cAAc,CAAA;AAAA,EACxE,CAAA,CAAA,MAAQ;AAAA,EAER;AACF","file":"chunk-7IVHY4OR.js","sourcesContent":["/**\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 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 { resolveStoreIdentifier } from './store-identity';\nimport { 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.\n *\n * `init` spreads `headers` over its axios defaults, and on a first load nothing\n * re-asserts the version 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 */\nexport function withSdkThemeVersion<T extends Pick<StoreContext, 'headers'>>(settings: T): T {\n const versionId = requestedThemeVersionId();\n if (!versionId) return settings;\n return { ...settings, headers: { ...settings.headers, 's-version-id': versionId } };\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. No-op on the server and until the SDK exposes its api.\n */\nexport function syncSdkThemeVersion(headers: StoreContext['headers']): void {\n const sdk = getSallaSDK();\n if (!sdk) return;\n const versionId = sdkThemeVersionId(headers);\n try {\n if (versionId != null) sdk.api?.setHeader?.('s-version-id', versionId);\n else delete sdk.api?.axios?.defaults?.headers?.common?.['s-version-id'];\n } catch {\n // SDK partially loaded — the header is re-asserted on the next navigation.\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { api } from './chunk-
|
|
1
|
+
import { api } from './chunk-FCFIG4M3.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-A2SS3TNE.js.map
|
|
28
|
+
//# sourceMappingURL=chunk-A2SS3TNE.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,I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ent":["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,4 +1,4 @@
|
|
|
1
|
-
import { getActiveScope, api } from './chunk-
|
|
1
|
+
import { getActiveScope, api } from './chunk-FCFIG4M3.js';
|
|
2
2
|
import { queryOptions } from '@tanstack/react-query';
|
|
3
3
|
|
|
4
4
|
async function list(params) {
|
|
@@ -45,5 +45,5 @@ var home = {
|
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
export { home };
|
|
48
|
-
//# sourceMappingURL=chunk-
|
|
49
|
-
//# sourceMappingURL=chunk-
|
|
48
|
+
//# sourceMappingURL=chunk-AFFBCOH6.js.map
|
|
49
|
+
//# sourceMappingURL=chunk-AFFBCOH6.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/home.ts"],"names":[],"mappings":";;;AAQA,eAAe,KAAK,MAAA,EAA+D;AACjF,EAAA,MAAM,KAAA,GAAQ,SAAS,CAAA,CAAA,EAAI,IAAI,gBAAgB,MAAM,CAAA,CAAE,QAAA,EAAU,CAAA,CAAA,GAAK,EAAA;AACtE,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CAAI,IAAI,CAAA,cAAA,EAAiB,KAAK,CAA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AC,CAAC;AAAA,KAC5D;AACA,IAAA,MAAM,MAAA,GAAS,MAAM,IAAA,CAAK,EAAE,OAAO,IAAA,EAAM,GAAG,aAAa,CAAA;AACzD,IAAA,OAAO,MAAA,CAAO,GAAA,CAAI,CAAC,KAAA,MAAW,EAAE,GAAG,KAAA,EAAO,IAAA,EAAM,KAAA,CAAM,IAAA,CAAK,OAAA,CAAQ,OAAA,EAAS,EAAE,GAAE,CAAE,CAAA;AAAA,EACpF,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,UAAA,EAAY,MACV,YAAA,CAAa;AAAA;AAAA,MAEX,QAAA,EAAU,CAAC,MAAA,EAAQ,YAAA,EAAc,EAAE,KAAA,EAAO,cAAA,IAAkB,CAAA;AAAA,MAC5D,OAAA,EAAS,MAAM,IAAA,CAAK,UAAA;AAAW,KAChC,CAAA;AAAA,IAEH,MAAA,EAAQ,CAAC,IAAA,EAAc,KAAA,KACrB,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,MAAA,EAAQ,QAAA,EAAU,MAAM,KAAK,CAAA;AAAA,MACxC,OAAA,EAAS,MAAM,IAAA,CAAK,MAAA,CAAO,MAAM,KAAK;AAAA,KACvC;AAAA;AAEP","file":"chunk-AFFBCOH6.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api, getActiveScope } from './client';\nimport type { HomeComponentData } from '../types';\n\n/** The page a hook's blocks render on; blocks can target specific products, categories or pages. */\nexport type BlockScope =\n { product_id: number | string } | { category_id: number | string } | { page_id: number | string };\n\nasync function list(params?: Record<string, string>): Promise<HomeComponentData[]> {\n const query = params ? `?${new URLSearchParams(params).toString()}` : '';\n const { data } = await api.get(`component/list${query}`).json<{ data: HomeComponentData[] }>();\n return data ?? [];\n}\n\n/** `blocks` minus each of `excluded`, matched by content: the API sends no id or order to match on. */\nfunction without(blocks: HomeComponentData[], excluded: HomeComponentData[]): HomeComponentData[] {\n if (!excluded.length) return blocks;\n const paths = new Set(excluded.map((block) => block.path));\n const left = excluded.map((block) => JSON.stringify(block));\n return blocks.filter((block) => {\n if (!paths.has(block.path)) return true;\n const index = left.indexOf(JSON.stringify(block));\n if (index === -1) return true;\n left.splice(index, 1);\n return false;\n });\n}\n\nexport const home = {\n components: async (): Promise<HomeComponentData[]> => {\n // The unfiltered list also has the product, category and page blocks, which the home leaves out.\n const [blocks, pageBlocks] = await Promise.all([list(), list({ show_in: 'pages' })]);\n return without(blocks, pageBlocks);\n },\n\n /** The blocks the merchant placed at `hook` on a product, category or page. */\n blocks: async (hook: string, scope: BlockScope): Promise<HomeComponentData[]> => {\n const scopeParams = Object.fromEntries(\n Object.entries(scope).map(([key, id]) => [key, String(id)])\n );\n const blocks = await list({ hooks: hook, ...scopeParams });\n return blocks.map((block) => ({ ...block, path: block.path.replace('home.', '') }));\n },\n\n queries: {\n components: () =>\n queryOptions({\n // Each market (scope) has its own theme version, and its own home page with it.\n queryKey: ['home', 'components', { scope: getActiveScope() }],\n queryFn: () => home.components(),\n }),\n\n blocks: (hook: string, scope: BlockScope) =>\n queryOptions({\n queryKey: ['home', 'blocks', hook, scope],\n queryFn: () => home.blocks(hook, scope),\n }),\n },\n};\n"]}
|
|
@@ -6,7 +6,7 @@ export { BlogSkeleton, BreadcrumbSkeleton, CustomerLayoutSkeleton, CustomerPageS
|
|
|
6
6
|
|
|
7
7
|
// src/components/common/lazy.ts
|
|
8
8
|
var LazyBreadcrumb = lazyComponent(
|
|
9
|
-
() => import('./Breadcrumb-
|
|
9
|
+
() => import('./Breadcrumb-QKHYTTFB.js').then((m) => ({ default: m.Breadcrumb }))
|
|
10
10
|
);
|
|
11
11
|
var LazyNoContent = lazyComponent(
|
|
12
12
|
() => import('./NoContent-7A7OR2NZ.js').then((m) => ({ default: m.NoContent }))
|
|
@@ -155,5 +155,5 @@ function DeferredData({ promise, fallback, children }) {
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
export { DeferredData, Image, LazyBreadcrumb, LazyCurrencySymbol, LazyErrorPage, LazyNoContent, LazyRenderWhenVisible, resolveDeferred };
|
|
158
|
-
//# sourceMappingURL=chunk-
|
|
159
|
-
//# sourceMappingURL=chunk-
|
|
158
|
+
//# sourceMappingURL=chunk-AU2XMLTH.js.map
|
|
159
|
+
//# sourceMappingURL=chunk-AU2XMLTH.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/common/lazy.ts","../src/components/common/Image.tsx","../src/components/common/DeferredData.tsx"],"names":["Image","memo","DeferredRenderer","jsx"],"mappings":";;;;;;;AASO,IAAM,cAAA,GAAiB,aAAA;AAAA,EAAc,MAC1C,OAAO,0BAAc,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,UAAA,EAAW,CAAE;AAChE;AAEO,IAAM,aAAA,GAAgB,aAAA;AAAA,EAAc,MACzC,OAAO,yBAAa,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,SAAA,EAAU,CAAE;AAC9D;AAEO,IAAM,qBAAA,GAAwB,aAAA;AAAA,EAAc,MACjD,OAAO,iCAAqB,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,iBAAA,EAAkB,CAAE;AAC9E;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,aAAA,GAAgB,aAAA;AAAA,EAAc,MACzC,OAAO,yBAAa,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,SAAA,EAAU,CAAE;AAC9D;ACSO,IAAM,KAAA,GAAQ,IAAA,CAAK,SAASA,MAAAA,CAAM;AAAA,EACvC,GAAA;AAAA,EACA,G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A,MAGF,QAAA,kBAAAA,GAAAA,CAAC,gBAAA,EAAA,EAAiB,OAAA,EAAS,UAAW,QAAA,EAAS;AAAA;AAAA,GACjD;AAEJ","file":"chunk-LBZNLTBM.js","sourcesContent":["import { lazyComponent } from '../../utils/lazy-component';\n\n/**\n * Lazy-loaded common components\n * Use these for code-splitting non-critical components\n *\n * NOTE: Skeleton components are sourced from @salla.sa/twilight-components-react\n * because they must render instantly during route transitions.\n */\nexport const LazyBreadcrumb = lazyComponent(() =>\n import('./Breadcrumb').then((m) => ({ default: m.Breadcrumb }))\n);\n\nexport const LazyNoContent = lazyComponent(() =>\n import('./NoContent').then((m) => ({ default: m.NoContent }))\n);\n\nexport const LazyRenderWhenVisible = lazyComponent(() =>\n import('./RenderWhenVisible').then((m) => ({ default: m.RenderWhenVisible }))\n);\n\nexport const LazyCurrencySymbol = lazyComponent(() =>\n import('./CurrencySymbol').then((m) => ({ default: m.CurrencySymbol }))\n);\n\nexport const LazyErrorPage = lazyComponent(() =>\n import('./ErrorPage').then((m) => ({ default: m.ErrorPage }))\n);\n","import { memo } from 'react';\nimport { getCdnImageSrcSet, getCdnImageUrl } from '../../utils/cdn-image';\n\nexport interface ImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {\n /** Image source URL */\n src?: string;\n /** Alt text for accessibility */\n alt: string;\n /** Whether this image is above the fold / LCP candidate */\n priority?: boolean;\n /** Aspect ratio for CLS prevention (e.g. \"16/9\", \"1/1\", \"4/3\") */\n aspectRatio?: string;\n /** Object fit mode */\n objectFit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';\n /** Mobile image source for <picture> element */\n mobileSrc?: string;\n /** Mobile breakpoint for <source> media query (default: 768px) */\n mobileBreakpoint?: number;\n /** Skip the wrapper div */\n noWrapper?: boolean;\n /**\n * CDN widths for a density `srcset`. Pass `sizes` so the browser picks a\n * candidate close to the displayed CSS size.\n */\n srcSetWidths?: readonly number[];\n}\n\n/**\n * Optimized Image component with native browser lazy loading.\n *\n * - Uses `loading=\"lazy\"` + `decoding=\"async\"` by default for below-the-fold images.\n * - Uses `loading=\"eager\"` + `fetchPriority=\"high\"` for priority (above-the-fold / LCP) images.\n * - Supports responsive `<picture>` with mobile source.\n * - Provides `aspectRatio` for CLS prevention.\n * - When `srcSetWidths` + `sizes` are set, emits a sized CDN `srcset`.\n */\nexport const Image = memo(function Image({\n src,\n alt,\n priority = false,\n aspectRatio,\n objectFit = 'cover',\n mobileSrc,\n mobileBreakpoint = 768,\n noWrapper = false,\n className = '',\n style,\n width,\n height,\n sizes,\n srcSet: srcSetProp,\n srcSetWidths,\n ...rest\n}: ImageProps) {\n if (!src) return null;\n\n const generatedSrcSet =\n srcSetProp || (srcSetWidths?.length ? getCdnImageSrcSet(src, srcSetWidths) : undefined);\n const generatedMobileSrcSet =\n srcSetWidths?.length && mobileSrc ? getCdnImageSrcSet(mobileSrc, srcSetWidths) : undefined;\n const cdnWidth = srcSetWidths?.length\n ? width != null && srcSetWidths.includes(Number(width))\n ? Number(width)\n : srcSetWidths[0]\n : width;\n // Width-only CDN URLs so `src` matches a srcset candidate for preload.\n const cdnOptions = generatedSrcSet ? { width: cdnWidth } : { width: cdnWidth, height };\n\n const optimizedSrc = getCdnImageUrl(src, cdnOptions);\n const optimizedMobileSrc = getCdnImageUrl(mobileSrc, cdnOptions);\n\n const objectFitClass = `object-${objectFit}`;\n const imgClasses = [className, objectFitClass].filter(Boolean).join(' ');\n\n const loadingProps: React.ImgHTMLAttributes<HTMLImageElement> = priority\n ? { loading: 'eager' as const, fetchPriority: 'high' as const, decoding: 'sync' as const }\n : { loading: 'lazy' as const, decoding: 'async' as const };\n\n const hasWrapper = !noWrapper && !!aspectRatio;\n\n const img = (\n <img\n src={optimizedSrc}\n alt={alt}\n className={imgClasses}\n width={width}\n height={height}\n sizes={sizes}\n srcSet={generatedSrcSet}\n // With a wrapper, `style` goes to the wrapper; otherwise it must land on the <img>.\n style={hasWrapper ? undefined : style}\n {...loadingProps}\n {...rest}\n />\n );\n\n const imgElement = optimizedMobileSrc ? (\n <picture>\n <source\n media={`(max-width: ${mobileBreakpoint}px)`}\n srcSet={generatedMobileSrcSet || optimizedMobileSrc}\n sizes={generatedMobileSrcSet ? sizes : undefined}\n />\n {img}\n </picture>\n ) : (\n img\n );\n\n if (!hasWrapper) {\n return imgElement;\n }\n\n return (\n <div className=\"relative overflow-hidden\" style={{ aspectRatio, ...style }}>\n {imgElement}\n </div>\n );\n});\n","import { Suspense, memo, use, type ReactNode } from 'react';\n\nexport interface DeferredDataProps<T> {\n promise: Promise<T> | T;\n fallback: ReactNode;\n children: (data: T) => ReactNode;\n}\n\nconst DEFERRED_KEY = Symbol.for('twilight.deferred');\n\ninterface DeferredState<T> {\n status: 'pending' | 'success' | 'error';\n value?: T;\n error?: unknown;\n}\n\nexport interface DeferredPromise<T> extends Promise<T> {\n [DEFERRED_KEY]?: DeferredState<T>;\n}\n\nconst seenPromises = typeof WeakSet !== 'undefined' ? new WeakSet() : null;\n\nfunction defer<T>(promise: Promise<T>): DeferredPromise<T> {\n const existing = (promise as DeferredPromise<T>)[DEFERRED_KEY];\n if (existing) return promise as DeferredPromise<T>;\n\n const state: DeferredState<T> = { status: 'pending' };\n\n const deferred = promise as DeferredPromise<T>;\n deferred[DEFERRED_KEY] = state;\n\n promise.then(\n (value) => {\n state.status = 'success';\n state.value = value;\n },\n (error) => {\n state.status = 'error';\n state.error = error;\n }\n );\n\n return deferred;\n}\n\nconst DeferredRenderer = memo(function DeferredRenderer<T>({\n promise,\n children,\n}: {\n promise: DeferredPromise<T>;\n children: (data: T) => ReactNode;\n}) {\n const state = promise[DEFERRED_KEY];\n\n if (state?.status === 'success') {\n return children(state.value!);\n }\n\n if (state?.status === 'error') {\n throw state.error;\n }\n\n const data = use(promise);\n return children(data);\n}) as <T>(props: { promise: DeferredPromise<T>; children: (data: T) => ReactNode }) => ReactNode;\n\nfunction DeferredFallback<T>({\n promise,\n fallback,\n children,\n}: {\n promise: DeferredPromise<T>;\n fallback: ReactNode;\n children: (data: T) => ReactNode;\n}) {\n const state = promise[DEFERRED_KEY];\n if (state?.status === 'success') {\n return children(state.value!);\n }\n return <>{fallback}</>;\n}\n\nexport function resolveDeferred<T>(\n promiseOrValue: Promise<T> | T | undefined\n): T | Promise<T> | undefined {\n if (promiseOrValue == null || !(promiseOrValue instanceof Promise)) return promiseOrValue;\n const deferred = defer(promiseOrValue);\n const state = deferred[DEFERRED_KEY];\n if (state?.status === 'success') return state.value as T;\n return promiseOrValue;\n}\n\nexport function DeferredData<T>({ promise, fallback, children }: DeferredDataProps<T>) {\n if (!(promise instanceof Promise)) {\n return children(promise);\n }\n\n if (seenPromises && promise instanceof Promise) seenPromises.add(promise);\n\n const deferred = defer(promise);\n const state = deferred[DEFERRED_KEY];\n\n if (state?.status === 'success') {\n return children(state.value!);\n }\n\n if (state?.status === 'error') {\n throw state.error;\n }\n\n return (\n <Suspense\n fallback={\n <DeferredFallback promise={deferred} fallback={fallback}>\n {children}\n </DeferredFallback>\n }\n >\n <DeferredRenderer promise={deferred}>{children}</DeferredRenderer>\n </Suspense>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/common/lazy.ts","../src/components/common/Image.tsx","../src/components/common/DeferredData.tsx"],"names":["Image","memo","DeferredRenderer","jsx"],"mappings":";;;;;;;AASO,IAAM,cAAA,GAAiB,aAAA;AAAA,EAAc,MAC1C,OAAO,0BAAc,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,UAAA,EAAW,CAAE;AAChE;AAEO,IAAM,aAAA,GAAgB,aAAA;AAAA,EAAc,MACzC,OAAO,yBAAa,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,SAAA,EAAU,CAAE;AAC9D;AAEO,IAAM,qBAAA,GAAwB,aAAA;AAAA,EAAc,MACjD,OAAO,iCAAqB,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,M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IAAI,OAAO,CAAA;AAExE,EAAA,MAAM,QAAA,GAAW,MAAM,OAAO,CAAA;AAC9B,EAAA,MAAM,KAAA,GAAQ,SAAS,YAAY,CAAA;AAEnC,EAAA,IAAI,KAAA,EAAO,WAAW,SAAA,EAAW;AAC/B,IAAA,OAAO,QAAA,CAAS,MAAM,KAAM,CAAA;AAAA,EAC9B;AAEA,EAAA,IAAI,KAAA,EAAO,WAAW,OAAA,EAAS;AAC7B,IAAA,MAAM,KAAA,CAAM,KAAA;AAAA,EACd;AAEA,EAAA,uBACEA,GAAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,0BACEA,GAAAA,CAAC,oBAAiB,OAAA,EAAS,QAAA,EAAU,UAClC,QAAA,EACH,CAAA;AAAA,MAGF,QAAA,kBAAAA,GAAAA,CAAC,gBAAA,EAAA,EAAiB,OAAA,EAAS,UAAW,QAAA,EAAS;AAAA;AAAA,GACjD;AAEJ","file":"chunk-AU2XMLTH.js","sourcesContent":["import { lazyComponent } from '../../utils/lazy-component';\n\n/**\n * Lazy-loaded common components\n * Use these for code-splitting non-critical components\n *\n * NOTE: Skeleton components are sourced from @salla.sa/twilight-components-react\n * because they must render instantly during route transitions.\n */\nexport const LazyBreadcrumb = lazyComponent(() =>\n import('./Breadcrumb').then((m) => ({ default: m.Breadcrumb }))\n);\n\nexport const LazyNoContent = lazyComponent(() =>\n import('./NoContent').then((m) => ({ default: m.NoContent }))\n);\n\nexport const LazyRenderWhenVisible = lazyComponent(() =>\n import('./RenderWhenVisible').then((m) => ({ default: m.RenderWhenVisible }))\n);\n\nexport const LazyCurrencySymbol = lazyComponent(() =>\n import('./CurrencySymbol').then((m) => ({ default: m.CurrencySymbol }))\n);\n\nexport const LazyErrorPage = lazyComponent(() =>\n import('./ErrorPage').then((m) => ({ default: m.ErrorPage }))\n);\n","import { memo } from 'react';\nimport { getCdnImageSrcSet, getCdnImageUrl } from '../../utils/cdn-image';\n\nexport interface ImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {\n /** Image source URL */\n src?: string;\n /** Alt text for accessibility */\n alt: string;\n /** Whether this image is above the fold / LCP candidate */\n priority?: boolean;\n /** Aspect ratio for CLS prevention (e.g. \"16/9\", \"1/1\", \"4/3\") */\n aspectRatio?: string;\n /** Object fit mode */\n objectFit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';\n /** Mobile image source for <picture> element */\n mobileSrc?: string;\n /** Mobile breakpoint for <source> media query (default: 768px) */\n mobileBreakpoint?: number;\n /** Skip the wrapper div */\n noWrapper?: boolean;\n /**\n * CDN widths for a density `srcset`. Pass `sizes` so the browser picks a\n * candidate close to the displayed CSS size.\n */\n srcSetWidths?: readonly number[];\n}\n\n/**\n * Optimized Image component with native browser lazy loading.\n *\n * - Uses `loading=\"lazy\"` + `decoding=\"async\"` by default for below-the-fold images.\n * - Uses `loading=\"eager\"` + `fetchPriority=\"high\"` for priority (above-the-fold / LCP) images.\n * - Supports responsive `<picture>` with mobile source.\n * - Provides `aspectRatio` for CLS prevention.\n * - When `srcSetWidths` + `sizes` are set, emits a sized CDN `srcset`.\n */\nexport const Image = memo(function Image({\n src,\n alt,\n priority = false,\n aspectRatio,\n objectFit = 'cover',\n mobileSrc,\n mobileBreakpoint = 768,\n noWrapper = false,\n className = '',\n style,\n width,\n height,\n sizes,\n srcSet: srcSetProp,\n srcSetWidths,\n ...rest\n}: ImageProps) {\n if (!src) return null;\n\n const generatedSrcSet =\n srcSetProp || (srcSetWidths?.length ? getCdnImageSrcSet(src, srcSetWidths) : undefined);\n const generatedMobileSrcSet =\n srcSetWidths?.length && mobileSrc ? getCdnImageSrcSet(mobileSrc, srcSetWidths) : undefined;\n const cdnWidth = srcSetWidths?.length\n ? width != null && srcSetWidths.includes(Number(width))\n ? Number(width)\n : srcSetWidths[0]\n : width;\n // Width-only CDN URLs so `src` matches a srcset candidate for preload.\n const cdnOptions = generatedSrcSet ? { width: cdnWidth } : { width: cdnWidth, height };\n\n const optimizedSrc = getCdnImageUrl(src, cdnOptions);\n const optimizedMobileSrc = getCdnImageUrl(mobileSrc, cdnOptions);\n\n const objectFitClass = `object-${objectFit}`;\n const imgClasses = [className, objectFitClass].filter(Boolean).join(' ');\n\n const loadingProps: React.ImgHTMLAttributes<HTMLImageElement> = priority\n ? { loading: 'eager' as const, fetchPriority: 'high' as const, decoding: 'sync' as const }\n : { loading: 'lazy' as const, decoding: 'async' as const };\n\n const hasWrapper = !noWrapper && !!aspectRatio;\n\n const img = (\n <img\n src={optimizedSrc}\n alt={alt}\n className={imgClasses}\n width={width}\n height={height}\n sizes={sizes}\n srcSet={generatedSrcSet}\n // With a wrapper, `style` goes to the wrapper; otherwise it must land on the <img>.\n style={hasWrapper ? undefined : style}\n {...loadingProps}\n {...rest}\n />\n );\n\n const imgElement = optimizedMobileSrc ? (\n <picture>\n <source\n media={`(max-width: ${mobileBreakpoint}px)`}\n srcSet={generatedMobileSrcSet || optimizedMobileSrc}\n sizes={generatedMobileSrcSet ? sizes : undefined}\n />\n {img}\n </picture>\n ) : (\n img\n );\n\n if (!hasWrapper) {\n return imgElement;\n }\n\n return (\n <div className=\"relative overflow-hidden\" style={{ aspectRatio, ...style }}>\n {imgElement}\n </div>\n );\n});\n","import { Suspense, memo, use, type ReactNode } from 'react';\n\nexport interface DeferredDataProps<T> {\n promise: Promise<T> | T;\n fallback: ReactNode;\n children: (data: T) => ReactNode;\n}\n\nconst DEFERRED_KEY = Symbol.for('twilight.deferred');\n\ninterface DeferredState<T> {\n status: 'pending' | 'success' | 'error';\n value?: T;\n error?: unknown;\n}\n\nexport interface DeferredPromise<T> extends Promise<T> {\n [DEFERRED_KEY]?: DeferredState<T>;\n}\n\nconst seenPromises = typeof WeakSet !== 'undefined' ? new WeakSet() : null;\n\nfunction defer<T>(promise: Promise<T>): DeferredPromise<T> {\n const existing = (promise as DeferredPromise<T>)[DEFERRED_KEY];\n if (existing) return promise as DeferredPromise<T>;\n\n const state: DeferredState<T> = { status: 'pending' };\n\n const deferred = promise as DeferredPromise<T>;\n deferred[DEFERRED_KEY] = state;\n\n promise.then(\n (value) => {\n state.status = 'success';\n state.value = value;\n },\n (error) => {\n state.status = 'error';\n state.error = error;\n }\n );\n\n return deferred;\n}\n\nconst DeferredRenderer = memo(function DeferredRenderer<T>({\n promise,\n children,\n}: {\n promise: DeferredPromise<T>;\n children: (data: T) => ReactNode;\n}) {\n const state = promise[DEFERRED_KEY];\n\n if (state?.status === 'success') {\n return children(state.value!);\n }\n\n if (state?.status === 'error') {\n throw state.error;\n }\n\n const data = use(promise);\n return children(data);\n}) as <T>(props: { promise: DeferredPromise<T>; children: (data: T) => ReactNode }) => ReactNode;\n\nfunction DeferredFallback<T>({\n promise,\n fallback,\n children,\n}: {\n promise: DeferredPromise<T>;\n fallback: ReactNode;\n children: (data: T) => ReactNode;\n}) {\n const state = promise[DEFERRED_KEY];\n if (state?.status === 'success') {\n return children(state.value!);\n }\n return <>{fallback}</>;\n}\n\nexport function resolveDeferred<T>(\n promiseOrValue: Promise<T> | T | undefined\n): T | Promise<T> | undefined {\n if (promiseOrValue == null || !(promiseOrValue instanceof Promise)) return promiseOrValue;\n const deferred = defer(promiseOrValue);\n const state = deferred[DEFERRED_KEY];\n if (state?.status === 'success') return state.value as T;\n return promiseOrValue;\n}\n\nexport function DeferredData<T>({ promise, fallback, children }: DeferredDataProps<T>) {\n if (!(promise instanceof Promise)) {\n return children(promise);\n }\n\n if (seenPromises && promise instanceof Promise) seenPromises.add(promise);\n\n const deferred = defer(promise);\n const state = deferred[DEFERRED_KEY];\n\n if (state?.status === 'success') {\n return children(state.value!);\n }\n\n if (state?.status === 'error') {\n throw state.error;\n }\n\n return (\n <Suspense\n fallback={\n <DeferredFallback promise={deferred} fallback={fallback}>\n {children}\n </DeferredFallback>\n }\n >\n <DeferredRenderer promise={deferred}>{children}</DeferredRenderer>\n </Suspense>\n );\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { orThrow } from './chunk-
|
|
2
|
-
import { getActiveScope, api } from './chunk-
|
|
1
|
+
import { orThrow } from './chunk-ZBGMIDDO.js';
|
|
2
|
+
import { getActiveScope, api } from './chunk-FCFIG4M3.js';
|
|
3
3
|
import { queryOptions } from '@tanstack/react-query';
|
|
4
4
|
|
|
5
5
|
var category = {
|
|
@@ -26,5 +26,5 @@ var category = {
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
export { category };
|
|
29
|
-
//# sourceMappingURL=chunk-
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
29
|
+
//# sourceMappingURL=chunk-BIVBSVWR.js.map
|
|
30
|
+
//# sourceMappingURL=chunk-BIVBSVWR.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/category.ts"],"names":[],"mappings":";;;;AAKO,IAAM,QAAA,GAAW;AAAA,EACtB,IAAA,EAAM,OAAO,EAAA,KAAkC;AAC7C,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CAAI,IAAI,CAAA,WAAA,EAAc,EAAE,CAAA,CAAE,CAAA,CAAE,IAAA,EAAyB;AAC5E,IAAA,OAAO,IAAA;AAAA,EACT,CAAA;AAAA,EAEA,aAAa,CAAC,EAAA,KAAkC,QAAQ,QAAA,CAAS,IAAA,CAAK,EAAE,CAAC,CAAA;AAAA,EAEzE,MAAM,YAAiC;AACrC,IAAA,MAAM,EAAE,MAAK,GAAI,MAAM,IAAI,GAAA,CAAI,YAAY,EAAE,IAAA,EAA2B;AACxE,IAAA,OAAO,QAAQ,EAAC;AAAA,EAClB,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,MAAA,EAAQ,CAAC,EAAA,KACP,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,YAAA,EAAc,QAAA,EAAU,EAAE,CAAA;AAAA,MACrC,OAAA,EAAS,MAAM,QAAA,CAAS,IAAA,CAAK,EAAE;AAAA,KAChC,CAAA;AAAA,IAEH,IAAA,EAAM,MACJ,YAAA,CAAa;AAAA;AAAA,MAEX,QAAA,EAAU,CAAC,YAAA,EAAc,MAAA,EAAQ,EAAE,KAAA,EAAO,cAAA,IAAkB,CAAA;AAAA,MAC5D,OAAA,EAAS,MAAM,QAAA,CAAS,IAAA;AAAK,KAC9B;AAAA;AAEP","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/api/category.ts"],"names":[],"mappings":";;;;AAKO,IAAM,QAAA,GAAW;AAAA,EACtB,IAAA,EAAM,OAAO,EAAA,KAAkC;AAC7C,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CAAI,IAAI,CAAA,WAAA,EAAc,EAAE,CAAA,CAAE,CAAA,CAAE,IAAA,EAAyB;AAC5E,IAAA,OAAO,IAAA;AAAA,EACT,CAAA;AAAA,EAEA,aAAa,CAAC,EAAA,KAAkC,QAAQ,QAAA,CAAS,IAAA,CAAK,EAAE,CAAC,CAAA;AAAA,EAEzE,MAAM,YAAiC;AACrC,IAAA,MAAM,EAAE,MAAK,GAAI,MAAM,IAAI,GAAA,CAAI,YAAY,EAAE,IAAA,EAA2B;AACxE,IAAA,OAAO,QAAQ,EAAC;AAAA,EAClB,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,MAAA,EAAQ,CAAC,EAAA,KACP,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,YAAA,EAAc,QAAA,EAAU,EAAE,CAAA;AAAA,MACrC,OAAA,EAAS,MAAM,QAAA,CAAS,IAAA,CAAK,EAAE;AAAA,KAChC,CAAA;AAAA,IAEH,IAAA,EAAM,MACJ,YAAA,CAAa;AAAA;AAAA,MAEX,QAAA,EAAU,CAAC,YAAA,EAAc,MAAA,EAAQ,EAAE,KAAA,EAAO,cAAA,IAAkB,CAAA;AAAA,MAC5D,OAAA,EAAS,MAAM,QAAA,CAAS,IAAA;AAAK,KAC9B;AAAA;AAEP","file":"chunk-BIVBSVWR.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api, getActiveScope } from './client';\nimport type { Category } from '../types';\nimport { orThrow } from '../providers/NavigationProvider';\n\nexport const category = {\n find: async (id: string): Promise<Category> => {\n const { data } = await api.get(`categories/${id}`).json<{ data: Category }>();\n return data;\n },\n\n findOrThrow: (id: string): Promise<Category> => orThrow(category.find(id)),\n\n list: async (): Promise<Category[]> => {\n const { data } = await api.get('categories').json<{ data: Category[] }>();\n return data ?? [];\n },\n\n queries: {\n detail: (id: string) =>\n queryOptions({\n queryKey: ['categories', 'detail', id],\n queryFn: () => category.find(id),\n }),\n\n list: () =>\n queryOptions({\n // Scope (branch) varies the API response — key must include it.\n queryKey: ['categories', 'list', { scope: getActiveScope() }],\n queryFn: () => category.list(),\n }),\n },\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { extractTokenFromCookies, isPreviewHost } from './chunk-
|
|
1
|
+
import { extractTokenFromCookies, isPreviewHost } from './chunk-EEL6OYAQ.js';
|
|
2
2
|
|
|
3
3
|
// src/utils/maintenance.ts
|
|
4
4
|
var VIEW_AS_OWNER_COOKIE_NAME = "salla_view_as";
|
|
@@ -73,5 +73,5 @@ function withOwnerMaintenanceButton(settings, buttonTitle) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
export { MAINTENANCE_EVIDENCE_HEADER, VIEW_AS_OWNER_COOKIE_NAME, isNotLaunchedNotice, maintenanceEvidence, maintenanceEvidenceHeader, ownerCookieMatches, ownerLinkMatches, showsMaintenancePage, withOwnerMaintenanceButton, withoutMaintenanceOnPreviewHost };
|
|
76
|
-
//# sourceMappingURL=chunk-
|
|
77
|
-
//# sourceMappingURL=chunk-
|
|
76
|
+
//# sourceMappingURL=chunk-BRIRWS2Q.js.map
|
|
77
|
+
//# sourceMappingURL=chunk-BRIRWS2Q.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/maintenance.ts"],"names":[],"mappings":";;;AAgBO,IAAM,yBAAA,GAA4B;AAEzC,IAAM,aAAA,GAAgB,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AQ,QAAQ,CAAA,CAC3B,IAAI,CAAC,CAAC,KAAK,KAAK,CAAA,KAAM,GAAG,GAAG,CAAA,CAAA,EAAI,MAAM,OAAA,CAAQ,eAAA,EAAiB,EAAE,CAAC,CAAA,CAAE,CAAA,CACpE,IAAA,CAAK,IAAI,CAAA;AACd;AAKA,IAAM,aAAA,GAAgB,oBAAA;AAGf,IAAM,wBAAA,GAA2B,GAAG,aAAa,CAAA,2CAAA,CAAA;AAcjD,SAAS,oBAAoB,OAAA,EAAyD;AAC3F,EAAA,OAAO,OAAA,EAAS,UAAA,EAAY,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAA,KAAM,aAAA;AACtD;AAYO,SAAS,0BAAA,CAEd,UAAa,WAAA,EAAwB;AACrC,EAAA,MAAM,UAAU,QAAA,CAAS,mBAAA;AACzB,EAAA,IAAI,QAAA,CAAS,WAAA,KAAgB,IAAA,IAAQ,OAAA,EAAS,cAAc,OAAO,QAAA;AACnE,EAAA,OAAO;AAAA,IACL,GAAG,QAAA;AAAA,IACH,mBAAA,EAAqB;AAAA,MACnB,GAAG,OAAA;AAAA,MACH,YAAA,EAAc,WAAA;AAAA,MACd,iBAAA,EAAmB,WAAA;AAAA,MACnB,UAAA,EAAY;AAAA;AACd,GACF;AACF","file":"chunk-6YEE3VHL.js","sourcesContent":["import type { StoreContext } from '../api/store';\nimport type { MaintenanceDetails } from '../types';\nimport { extractTokenFromCookies, isPreviewHost } from './cookies';\n\n/**\n * Remembers that this browser is the merchant looking at their own closed store.\n *\n * The dashboard's \"view store\" link carries `?utm_source=dashboard&identifier=<store id>`\n * (`portal` for the partners portal). Twig's backend checks that once, keeps\n * `view-as: owner` in the PHP session and lets every later request through; this\n * cookie is that session entry. No `max-age`: a session cookie, as the PHP session\n * was, so closing the browser ends the owner view.\n *\n * The value is the store id the bypass was granted for, checked against the store\n * the settings answer about, so one store's cookie opens no other store.\n */\nexport const VIEW_AS_OWNER_COOKIE_NAME = 'salla_view_as';\n\nconst OWNER_SOURCES = ['dashboard', 'portal'];\n\n/** The id as the URL and the cookie spell it, or null when the settings name none. */\nfunction storeIdOf(settings: StoreContext | null | undefined): string | null {\n const id = settings?.store?.id;\n return id == null ? null : String(id);\n}\n\n/**\n * Whether `href` is the dashboard's link into the merchant's own store:\n * `utm_source` is `dashboard` or `portal`, and `identifier` is this store's id.\n * The backend's own rule, translated.\n */\nexport function ownerLinkMatches(href: string, settings: StoreContext | null | undefined): boolean {\n const storeId = storeIdOf(settings);\n if (!storeId) return false;\n let params: URLSearchParams;\n try {\n params = new URL(href, 'http://localhost').searchParams;\n } catch {\n return false;\n }\n const source = params.get('utm_source');\n return source != null && OWNER_SOURCES.includes(source) && params.get('identifier') === storeId;\n}\n\n/** Whether the cookie remembers an owner view of this store. */\nexport function ownerCookieMatches(\n cookieHeader: string | null,\n settings: StoreContext | null | undefined\n): boolean {\n const storeId = storeIdOf(settings);\n return !!storeId && extractTokenFromCookies(cookieHeader, VIEW_AS_OWNER_COOKIE_NAME) === storeId;\n}\n\n/**\n * Whether this visitor gets the maintenance page instead of the store.\n *\n * True only when the settings say the store is closed and nothing lets the visitor\n * through: neither an owner view (the link or the cookie), nor a session the\n * backend marks `theme.mode === 'preview'`, nor the hosted preview host.\n *\n * The host is what lets the dashboard's theme editor through. The editor frames\n * this storefront on the preview host, and that request has none of the other\n * three: its URL carries no owner link, the owner cookie is `SameSite=Lax` and a\n * cross-site frame neither stores nor sends it, and `theme.mode` is only ever\n * `preview` from a PHP session, which the worker's sessionless API call has not got.\n * The Twig storefront exempts its preview hosts the same way (`CheckStoreStatus`\n * skips `hasCustomDomain()`), and for the same reasons: a merchant customising a\n * store that is closed, or not launched yet, still has to see what they are\n * customising. A merchant's own domain is never a preview host, so a customer of a\n * closed store still gets the page.\n *\n * Loopback is not exempt: on a dev server a closed store shows the maintenance page\n * on purpose, so a theme author can see and test it (see `MaintenanceDevBar`).\n *\n * @param host - the host the request arrived on; see {@link isPreviewHost}. Required\n * rather than optional: a caller that forgot it would quietly bring the editor bug back.\n */\nexport function showsMaintenancePage(\n settings: StoreContext | null | undefined,\n viewAsOwner: boolean,\n host: string | null | undefined\n): boolean {\n return (\n settings?.maintenance === true &&\n !viewAsOwner &&\n settings.theme?.mode !== 'preview' &&\n !isPreviewHost(host)\n );\n}\n\n/**\n * The settings the Salla SDK is initialised with, told the store is open when the\n * page is on the preview host.\n *\n * {@link showsMaintenancePage} lets the preview host render a closed store, but the\n * settings still say `maintenance: true`, and the SDK reads that to draw its\n * merchant maintenance bar. In the theme editor that bar would sit over the very\n * page being customised, offering a \"turn off maintenance\" button to everyone who\n * looks at the preview, a reviewer included. Twig's editor shows no bar either:\n * `CheckStoreStatus` returns before it adds one. The bar is all the SDK uses the flag\n * for, and the maintenance page is decided elsewhere, so nothing else changes.\n */\nexport function withoutMaintenanceOnPreviewHost<T extends Pick<StoreContext, 'maintenance'>>(\n settings: T,\n host: string | null | undefined\n): T {\n if (settings.maintenance !== true || !isPreviewHost(host)) return settings;\n return { ...settings, maintenance: false };\n}\n\n/**\n * The response header a maintenance 503 carries saying which settings decided it.\n *\n * Theme workers write no logs, and the dispatcher's line for a 5xx records the\n * answer's own `x-trace-id` and this header, so the evidence travels on the answer.\n * The backend sets `maintenance` from store-wide state alone (closed, not launched,\n * or the market in maintenance), so `request-id` and `trace` find the settings\n * request it logged, and `cache`/`age` say whether this was a cached copy of one.\n */\nexport const MAINTENANCE_EVIDENCE_HEADER = 'x-twilight-maintenance';\n\n/**\n * What the maintenance decision rested on, as `key=value` pairs. Ids and the API's\n * own header values only: nothing a visitor typed, nothing that identifies them.\n */\nexport function maintenanceEvidence(\n settings: StoreContext | null | undefined\n): Record<string, string> {\n const evidence: Record<string, string> = {};\n if (!settings) return evidence;\n for (const [key, read] of EVIDENCE) {\n const value = read(settings);\n if (value != null && value !== '') evidence[key] = String(value);\n }\n return evidence;\n}\n\nconst EVIDENCE: [string, (settings: StoreContext) => unknown][] = [\n ['store', (s) => s.store?.id],\n ['scope', (s) => s.store?.scope?.id],\n ['requested-scope', (s) => s.requestedScopeId],\n ['mode', (s) => s.theme?.mode],\n ['request-id', (s) => s.answer?.requestId],\n ['trace', (s) => s.answer?.traceId],\n ['cache', (s) => s.answer?.cacheStatus],\n ['age', (s) => s.answer?.age],\n];\n\n/** {@link maintenanceEvidence} as one header value: `store=1; scope=2; cache=HIT`. */\nexport function maintenanceEvidenceHeader(evidence: Record<string, string>): string {\n return Object.entries(evidence)\n .map(([key, value]) => `${key}=${value.replace(/[^\\x21-\\x7e]/g, '')}`)\n .join('; ');\n}\n\n// todo:: drop both once the backend sends `dashboard_url` (or the filled `button_*`) in the\n// settings; until then this mirrors `config('salla.app.dashboard_url')` and the path Twig's\n// `StoreStatusAlertWidget` appends for the owner.\nconst DASHBOARD_URL = 'https://s.salla.sa';\n\n/** The dashboard page where the merchant turns maintenance mode off, as the backend links it. */\nexport const MAINTENANCE_SETTINGS_URL = `${DASHBOARD_URL}/channel/settings?legacy=0#maintenance-mode`;\n\n/**\n * Whether the notice is the one the backend sends for a store that has not launched yet.\n *\n * The settings carry no `launched` flag: a store whose `store::launched` setting is `0`\n * gets `maintenance: true` and `StoreStatusAlertWidget::getData(true)`, the merchant's\n * \"finish launching\" notice, whose button goes to the dashboard's root, and it goes\n * there for every visitor. A closed store's notice links nowhere for a customer and to\n * {@link MAINTENANCE_SETTINGS_URL} for the owner, so the bare dashboard URL tells them\n * apart, as Twig's `CheckStoreStatus` does by rendering `construction` instead of\n * `maintenance`.\n */\n// todo:: read the backend's own flag once the settings send one.\nexport function isNotLaunchedNotice(details: MaintenanceDetails | null | undefined): boolean {\n return details?.button_url?.replace(/\\/+$/, '') === DASHBOARD_URL;\n}\n\n/**\n * The button on the SDK's merchant maintenance bar. The API fills the `button_*`\n * fields only inside Twig's owner session, which the engine's settings request has\n * none of, so the SDK, handed the settings as they are, draws an empty button. The\n * SDK renders only in the store view, so `maintenance: true` there means the owner\n * (or a session the backend marks `theme.mode === 'preview'`, where the SDK mounts\n * no bar; the preview host never gets here, see {@link withoutMaintenanceOnPreviewHost}):\n * the three fields get what Twig's owner branch gives them. The merchant's own title\n * and message stay as they are.\n */\nexport function withOwnerMaintenanceButton<\n T extends Pick<StoreContext, 'maintenance' | 'maintenance_details'>,\n>(settings: T, buttonTitle: string): T {\n const details = settings.maintenance_details;\n if (settings.maintenance !== true || details?.button_title) return settings;\n return {\n ...settings,\n maintenance_details: {\n ...details,\n button_title: buttonTitle,\n button_full_title: buttonTitle,\n button_url: MAINTENANCE_SETTINGS_URL,\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/maintenance.ts"],"names":[],"mappings":";;;AAgBO,IAAM,yBAAA,GAA4B;AAEzC,IAAM,aAAA,GAAgB,CAAC,WAAA,EAAa,QAAQ,CAAA;AAG5C,SAAS,UAAU,QAAA,EAA0D;AAC3E,EAAA,MAAM,EAAA,GAAK,UAAU,KAAA,EAAO,EAAA;AAC5B,EAAA,OAAO,EAAA,IAAM,IAAA,GAAO,IAAA,GAAO,MAAA,CAAO,EAAE,CAAA;AACtC;AAOO,SAAS,gBAAA,CAAiB,MAAc,QAAA,EAAoD;AACjG,EAAA,MAAM,OAAA,GAAU,UAAU,QAAQ,CAAA;AAClC,EAAA,IAAI,CAAC,SAAS,OAAO,KAAA;AACrB,EAAA,IAAI,MAAA;AACJ,EAAA,IAAI;AACF,IAAA,MAAA,GAAS,IAAI,GAAA,CAAI,IAAA,EAAM,kBAAkB,CAAA,CAAE,YAAA;AAAA,EAC7C,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,MAAM,MAAA,GAAS,MAAA,CAAO,GAAA,CAAI,YAAY,CAAA;AACtC,EAAA,OAAO,MAAA,IAAU,QAAQ,aAAA,CAAc,QAAA,CAAS,MAAM,CAAA,IAAK,MAAA,CAAO,GAAA,CAAI,YAAY,CAAA,KAAM,OAAA;AAC1F;AAGO,SAAS,kBAAA,CACd,cACA,QAAA,EACS;AACT,EA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ACd,GACF;AACF","file":"chunk-BRIRWS2Q.js","sourcesContent":["import type { StoreContext } from '../api/store';\nimport type { MaintenanceDetails } from '../types';\nimport { extractTokenFromCookies, isPreviewHost } from './cookies';\n\n/**\n * Remembers that this browser is the merchant looking at their own closed store.\n *\n * The dashboard's \"view store\" link carries `?utm_source=dashboard&identifier=<store id>`\n * (`portal` for the partners portal). Twig's backend checks that once, keeps\n * `view-as: owner` in the PHP session and lets every later request through; this\n * cookie is that session entry. No `max-age`: a session cookie, as the PHP session\n * was, so closing the browser ends the owner view.\n *\n * The value is the store id the bypass was granted for, checked against the store\n * the settings answer about, so one store's cookie opens no other store.\n */\nexport const VIEW_AS_OWNER_COOKIE_NAME = 'salla_view_as';\n\nconst OWNER_SOURCES = ['dashboard', 'portal'];\n\n/** The id as the URL and the cookie spell it, or null when the settings name none. */\nfunction storeIdOf(settings: StoreContext | null | undefined): string | null {\n const id = settings?.store?.id;\n return id == null ? null : String(id);\n}\n\n/**\n * Whether `href` is the dashboard's link into the merchant's own store:\n * `utm_source` is `dashboard` or `portal`, and `identifier` is this store's id.\n * The backend's own rule, translated.\n */\nexport function ownerLinkMatches(href: string, settings: StoreContext | null | undefined): boolean {\n const storeId = storeIdOf(settings);\n if (!storeId) return false;\n let params: URLSearchParams;\n try {\n params = new URL(href, 'http://localhost').searchParams;\n } catch {\n return false;\n }\n const source = params.get('utm_source');\n return source != null && OWNER_SOURCES.includes(source) && params.get('identifier') === storeId;\n}\n\n/** Whether the cookie remembers an owner view of this store. */\nexport function ownerCookieMatches(\n cookieHeader: string | null,\n settings: StoreContext | null | undefined\n): boolean {\n const storeId = storeIdOf(settings);\n return !!storeId && extractTokenFromCookies(cookieHeader, VIEW_AS_OWNER_COOKIE_NAME) === storeId;\n}\n\n/**\n * Whether this visitor gets the maintenance page instead of the store.\n *\n * True only when the settings say the store is closed and nothing lets the visitor\n * through: neither an owner view (the link or the cookie), nor a session the\n * backend marks `theme.mode === 'preview'`, nor the hosted preview host.\n *\n * The host is what lets the dashboard's theme editor through. The editor frames\n * this storefront on the preview host, and that request has none of the other\n * three: its URL carries no owner link, the owner cookie is `SameSite=Lax` and a\n * cross-site frame neither stores nor sends it, and `theme.mode` is only ever\n * `preview` from a PHP session, which the worker's sessionless API call has not got.\n * The Twig storefront exempts its preview hosts the same way (`CheckStoreStatus`\n * skips `hasCustomDomain()`), and for the same reasons: a merchant customising a\n * store that is closed, or not launched yet, still has to see what they are\n * customising. A merchant's own domain is never a preview host, so a customer of a\n * closed store still gets the page.\n *\n * Loopback is not exempt: on a dev server a closed store shows the maintenance page\n * on purpose, so a theme author can see and test it (see `MaintenanceDevBar`).\n *\n * @param host - the host the request arrived on; see {@link isPreviewHost}. Required\n * rather than optional: a caller that forgot it would quietly bring the editor bug back.\n */\nexport function showsMaintenancePage(\n settings: StoreContext | null | undefined,\n viewAsOwner: boolean,\n host: string | null | undefined\n): boolean {\n return (\n settings?.maintenance === true &&\n !viewAsOwner &&\n settings.theme?.mode !== 'preview' &&\n !isPreviewHost(host)\n );\n}\n\n/**\n * The settings the Salla SDK is initialised with, told the store is open when the\n * page is on the preview host.\n *\n * {@link showsMaintenancePage} lets the preview host render a closed store, but the\n * settings still say `maintenance: true`, and the SDK reads that to draw its\n * merchant maintenance bar. In the theme editor that bar would sit over the very\n * page being customised, offering a \"turn off maintenance\" button to everyone who\n * looks at the preview, a reviewer included. Twig's editor shows no bar either:\n * `CheckStoreStatus` returns before it adds one. The bar is all the SDK uses the flag\n * for, and the maintenance page is decided elsewhere, so nothing else changes.\n */\nexport function withoutMaintenanceOnPreviewHost<T extends Pick<StoreContext, 'maintenance'>>(\n settings: T,\n host: string | null | undefined\n): T {\n if (settings.maintenance !== true || !isPreviewHost(host)) return settings;\n return { ...settings, maintenance: false };\n}\n\n/**\n * The response header a maintenance 503 carries saying which settings decided it.\n *\n * Theme workers write no logs, and the dispatcher's line for a 5xx records the\n * answer's own `x-trace-id` and this header, so the evidence travels on the answer.\n * The backend sets `maintenance` from store-wide state alone (closed, not launched,\n * or the market in maintenance), so `request-id` and `trace` find the settings\n * request it logged, and `cache`/`age` say whether this was a cached copy of one.\n */\nexport const MAINTENANCE_EVIDENCE_HEADER = 'x-twilight-maintenance';\n\n/**\n * What the maintenance decision rested on, as `key=value` pairs. Ids and the API's\n * own header values only: nothing a visitor typed, nothing that identifies them.\n */\nexport function maintenanceEvidence(\n settings: StoreContext | null | undefined\n): Record<string, string> {\n const evidence: Record<string, string> = {};\n if (!settings) return evidence;\n for (const [key, read] of EVIDENCE) {\n const value = read(settings);\n if (value != null && value !== '') evidence[key] = String(value);\n }\n return evidence;\n}\n\nconst EVIDENCE: [string, (settings: StoreContext) => unknown][] = [\n ['store', (s) => s.store?.id],\n ['scope', (s) => s.store?.scope?.id],\n ['requested-scope', (s) => s.requestedScopeId],\n ['mode', (s) => s.theme?.mode],\n ['request-id', (s) => s.answer?.requestId],\n ['trace', (s) => s.answer?.traceId],\n ['cache', (s) => s.answer?.cacheStatus],\n ['age', (s) => s.answer?.age],\n];\n\n/** {@link maintenanceEvidence} as one header value: `store=1; scope=2; cache=HIT`. */\nexport function maintenanceEvidenceHeader(evidence: Record<string, string>): string {\n return Object.entries(evidence)\n .map(([key, value]) => `${key}=${value.replace(/[^\\x21-\\x7e]/g, '')}`)\n .join('; ');\n}\n\n// todo:: drop both once the backend sends `dashboard_url` (or the filled `button_*`) in the\n// settings; until then this mirrors `config('salla.app.dashboard_url')` and the path Twig's\n// `StoreStatusAlertWidget` appends for the owner.\nconst DASHBOARD_URL = 'https://s.salla.sa';\n\n/** The dashboard page where the merchant turns maintenance mode off, as the backend links it. */\nexport const MAINTENANCE_SETTINGS_URL = `${DASHBOARD_URL}/channel/settings?legacy=0#maintenance-mode`;\n\n/**\n * Whether the notice is the one the backend sends for a store that has not launched yet.\n *\n * The settings carry no `launched` flag: a store whose `store::launched` setting is `0`\n * gets `maintenance: true` and `StoreStatusAlertWidget::getData(true)`, the merchant's\n * \"finish launching\" notice, whose button goes to the dashboard's root, and it goes\n * there for every visitor. A closed store's notice links nowhere for a customer and to\n * {@link MAINTENANCE_SETTINGS_URL} for the owner, so the bare dashboard URL tells them\n * apart, as Twig's `CheckStoreStatus` does by rendering `construction` instead of\n * `maintenance`.\n */\n// todo:: read the backend's own flag once the settings send one.\nexport function isNotLaunchedNotice(details: MaintenanceDetails | null | undefined): boolean {\n return details?.button_url?.replace(/\\/+$/, '') === DASHBOARD_URL;\n}\n\n/**\n * The button on the SDK's merchant maintenance bar. The API fills the `button_*`\n * fields only inside Twig's owner session, which the engine's settings request has\n * none of, so the SDK, handed the settings as they are, draws an empty button. The\n * SDK renders only in the store view, so `maintenance: true` there means the owner\n * (or a session the backend marks `theme.mode === 'preview'`, where the SDK mounts\n * no bar; the preview host never gets here, see {@link withoutMaintenanceOnPreviewHost}):\n * the three fields get what Twig's owner branch gives them. The merchant's own title\n * and message stay as they are.\n */\nexport function withOwnerMaintenanceButton<\n T extends Pick<StoreContext, 'maintenance' | 'maintenance_details'>,\n>(settings: T, buttonTitle: string): T {\n const details = settings.maintenance_details;\n if (settings.maintenance !== true || details?.button_title) return settings;\n return {\n ...settings,\n maintenance_details: {\n ...details,\n button_title: buttonTitle,\n button_full_title: buttonTitle,\n button_url: MAINTENANCE_SETTINGS_URL,\n },\n };\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { orThrow } from './chunk-
|
|
2
|
-
import { getActiveScope, api } from './chunk-
|
|
1
|
+
import { orThrow } from './chunk-ZBGMIDDO.js';
|
|
2
|
+
import { getActiveScope, api } from './chunk-FCFIG4M3.js';
|
|
3
3
|
import { getTwilightContext } from './chunk-6K34BCUP.js';
|
|
4
4
|
import { defaultShouldDehydrateQuery, queryOptions } from '@tanstack/react-query';
|
|
5
5
|
|
|
@@ -215,5 +215,5 @@ var product = {
|
|
|
215
215
|
};
|
|
216
216
|
|
|
217
217
|
export { getProductPreview, isProductPreviewQuery, parseNextPageToken, product, productDetailQueryKey, productPreviewQueryKey, rememberProductPreview, shouldDehydrateQuery };
|
|
218
|
-
//# sourceMappingURL=chunk-
|
|
219
|
-
//# sourceMappingURL=chunk-
|
|
218
|
+
//# sourceMappingURL=chunk-BWKHA4ZD.js.map
|
|
219
|
+
//# sourceMappingURL=chunk-BWKHA4ZD.js.map
|