@salla.sa/twilight-theme-engine 1.0.144 → 1.0.146
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-LWT2QINY.js → AddToCartForm-ZZMT3ZRO.js} +3 -3
- package/dist/{AddToCartForm-LWT2QINY.js.map → AddToCartForm-ZZMT3ZRO.js.map} +1 -1
- package/dist/{BlogAuthorPage-52C2OHXW.js → BlogAuthorPage-LVRGWFOC.js} +27 -27
- package/dist/{BlogAuthorPage-52C2OHXW.js.map → BlogAuthorPage-LVRGWFOC.js.map} +1 -1
- package/dist/{BlogCategoryPage-LBLIAN6Q.js → BlogCategoryPage-CONL6QSN.js} +27 -27
- package/dist/{BlogCategoryPage-LBLIAN6Q.js.map → BlogCategoryPage-CONL6QSN.js.map} +1 -1
- package/dist/{BlogPage-U56CLHI4.js → BlogPage-6ZA474IU.js} +25 -25
- package/dist/{BlogPage-U56CLHI4.js.map → BlogPage-6ZA474IU.js.map} +1 -1
- package/dist/{BlogSinglePage-NQJDYUFB.js → BlogSinglePage-W7WYKP7W.js} +25 -25
- package/dist/{BlogSinglePage-NQJDYUFB.js.map → BlogSinglePage-W7WYKP7W.js.map} +1 -1
- package/dist/{BlogTagPage-XP3XGVCO.js → BlogTagPage-G5JX7FSN.js} +27 -27
- package/dist/{BlogTagPage-XP3XGVCO.js.map → BlogTagPage-G5JX7FSN.js.map} +1 -1
- package/dist/{BrandsPage-22AET7DW.js → BrandsPage-TB5NDSGL.js} +26 -26
- package/dist/{BrandsPage-22AET7DW.js.map → BrandsPage-TB5NDSGL.js.map} +1 -1
- package/dist/{Breadcrumb-YTYXSTKO.js → Breadcrumb-EVZDJG7H.js} +25 -25
- package/dist/{Breadcrumb-YTYXSTKO.js.map → Breadcrumb-EVZDJG7H.js.map} +1 -1
- package/dist/{CartItem-UTU4GLDN.js → CartItem-D2LJIFGL.js} +25 -25
- package/dist/{CartItem-UTU4GLDN.js.map → CartItem-D2LJIFGL.js.map} +1 -1
- package/dist/{CartSummary-4UGWZ3B3.js → CartSummary-V4HYUEPB.js} +25 -25
- package/dist/{CartSummary-4UGWZ3B3.js.map → CartSummary-V4HYUEPB.js.map} +1 -1
- package/dist/{Copyright-B2GYPZBZ.js → Copyright-JLIFLENS.js} +3 -3
- package/dist/{Copyright-B2GYPZBZ.js.map → Copyright-JLIFLENS.js.map} +1 -1
- package/dist/{CustomerLayout-I4XFBCOH.js → CustomerLayout-JSIYPWY4.js} +25 -25
- package/dist/{CustomerLayout-I4XFBCOH.js.map → CustomerLayout-JSIYPWY4.js.map} +1 -1
- package/dist/{Footer-OWOF2AGC.js → Footer-BNIVXKRM.js} +4 -4
- package/dist/{Footer-OWOF2AGC.js.map → Footer-BNIVXKRM.js.map} +1 -1
- package/dist/{Header-KDJL4YRP.js → Header-DI3OK5TC.js} +11 -11
- package/dist/{Header-KDJL4YRP.js.map → Header-DI3OK5TC.js.map} +1 -1
- package/dist/{LatestProducts-YBFHXG5V.js → LatestProducts-PEIN355E.js} +27 -27
- package/dist/{LatestProducts-YBFHXG5V.js.map → LatestProducts-PEIN355E.js.map} +1 -1
- package/dist/{LoyaltyPage-GFWTFQA7.js → LoyaltyPage-GV6WMYVE.js} +25 -25
- package/dist/{LoyaltyPage-GFWTFQA7.js.map → LoyaltyPage-GV6WMYVE.js.map} +1 -1
- package/dist/{LoyaltyPointsPage-WJDZL6G4.js → LoyaltyPointsPage-QNOVSCKB.js} +8 -8
- package/dist/{LoyaltyPointsPage-WJDZL6G4.js.map → LoyaltyPointsPage-QNOVSCKB.js.map} +1 -1
- package/dist/{MainMenu-AWSLHAEE.js → MainMenu-IN5HUX3U.js} +7 -7
- package/dist/{MainMenu-AWSLHAEE.js.map → MainMenu-IN5HUX3U.js.map} +1 -1
- package/dist/{MasterLayout-ZMHHLGYL.js → MasterLayout-GHAXKYOR.js} +25 -25
- package/dist/{MasterLayout-ZMHHLGYL.js.map → MasterLayout-GHAXKYOR.js.map} +1 -1
- package/dist/{MobileMenu-56MF2EAS.js → MobileMenu-XU45EZMG.js} +26 -26
- package/dist/{MobileMenu-56MF2EAS.js.map → MobileMenu-XU45EZMG.js.map} +1 -1
- package/dist/{NotificationsPage-7QC66446.js → NotificationsPage-AMY7TARF.js} +25 -25
- package/dist/{NotificationsPage-7QC66446.js.map → NotificationsPage-AMY7TARF.js.map} +1 -1
- package/dist/{OrderSinglePage-WXJHUJ6C.js → OrderSinglePage-L2E6YH3Z.js} +26 -26
- package/dist/{OrderSinglePage-WXJHUJ6C.js.map → OrderSinglePage-L2E6YH3Z.js.map} +1 -1
- package/dist/{OrdersPage-ZNM4YGXR.js → OrdersPage-76ORWMJY.js} +25 -25
- package/dist/{OrdersPage-ZNM4YGXR.js.map → OrdersPage-76ORWMJY.js.map} +1 -1
- package/dist/{PageSingle-NQZM6O5A.js → PageSingle-D7I6EHBF.js} +6 -6
- package/dist/{PageSingle-NQZM6O5A.js.map → PageSingle-D7I6EHBF.js.map} +1 -1
- package/dist/{ProductDetails-N4KYBKBG.js → ProductDetails-BZVRXSCD.js} +7 -7
- package/dist/{ProductDetails-N4KYBKBG.js.map → ProductDetails-BZVRXSCD.js.map} +1 -1
- package/dist/{ProfilePage-XOGVATHX.js → ProfilePage-65NYRBON.js} +25 -25
- package/dist/{ProfilePage-XOGVATHX.js.map → ProfilePage-65NYRBON.js.map} +1 -1
- package/dist/{ReviewsPage-WOLLCLAY.js → ReviewsPage-C7NSCMBE.js} +3 -3
- package/dist/{ReviewsPage-WOLLCLAY.js.map → ReviewsPage-C7NSCMBE.js.map} +1 -1
- package/dist/{SeoCartWidget-EVJOTXPO.js → SeoCartWidget-GK3KC2M3.js} +25 -25
- package/dist/{SeoCartWidget-EVJOTXPO.js.map → SeoCartWidget-GK3KC2M3.js.map} +1 -1
- package/dist/{SettingsPage-LYDZFUF3.js → SettingsPage-7VGJBA5K.js} +25 -25
- package/dist/{SettingsPage-LYDZFUF3.js.map → SettingsPage-7VGJBA5K.js.map} +1 -1
- package/dist/{StoreClosedNotification-62SFSGRH.js → StoreClosedNotification-44JN2FZV.js} +26 -26
- package/dist/{StoreClosedNotification-62SFSGRH.js.map → StoreClosedNotification-44JN2FZV.js.map} +1 -1
- package/dist/{TestimonialsPage-WPZBQQO2.js → TestimonialsPage-KGCGTUJQ.js} +6 -6
- package/dist/{TestimonialsPage-WPZBQQO2.js.map → TestimonialsPage-KGCGTUJQ.js.map} +1 -1
- package/dist/{ThankYouPage-44VMBXGI.js → ThankYouPage-XWB4X236.js} +25 -25
- package/dist/{ThankYouPage-44VMBXGI.js.map → ThankYouPage-XWB4X236.js.map} +1 -1
- package/dist/{WalletPage-YVSIECSM.js → WalletPage-J3CX6MLS.js} +26 -26
- package/dist/{WalletPage-YVSIECSM.js.map → WalletPage-J3CX6MLS.js.map} +1 -1
- package/dist/{WebMcpTools-VA2A62E3.js → WebMcpTools-3MV53OMT.js} +9 -9
- package/dist/{WebMcpTools-VA2A62E3.js.map → WebMcpTools-3MV53OMT.js.map} +1 -1
- package/dist/{WishlistPage-IGWDG4HC.js → WishlistPage-HHX3OVOF.js} +27 -27
- package/dist/{WishlistPage-IGWDG4HC.js.map → WishlistPage-HHX3OVOF.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-G3NCSKQ3.js → chunk-2DUN6DZK.js} +5 -5
- package/dist/{chunk-G3NCSKQ3.js.map → chunk-2DUN6DZK.js.map} +1 -1
- package/dist/{chunk-S4KV6QGP.js → chunk-3G4YCXOR.js} +27 -20
- package/dist/chunk-3G4YCXOR.js.map +1 -0
- package/dist/{chunk-IVZNTLAA.js → chunk-3O6BB7SI.js} +3 -3
- package/dist/{chunk-IVZNTLAA.js.map → chunk-3O6BB7SI.js.map} +1 -1
- package/dist/{chunk-5XWGYFZ2.js → chunk-3QOALQQJ.js} +4 -4
- package/dist/{chunk-5XWGYFZ2.js.map → chunk-3QOALQQJ.js.map} +1 -1
- package/dist/{chunk-7IQFONJR.js → chunk-5EN3XZ32.js} +3 -3
- package/dist/{chunk-7IQFONJR.js.map → chunk-5EN3XZ32.js.map} +1 -1
- package/dist/{chunk-N6ZE6HUX.js → chunk-5V4W3GBI.js} +5 -5
- package/dist/{chunk-N6ZE6HUX.js.map → chunk-5V4W3GBI.js.map} +1 -1
- package/dist/{chunk-3E3ABCPC.js → chunk-6TFM3UTF.js} +3 -3
- package/dist/{chunk-3E3ABCPC.js.map → chunk-6TFM3UTF.js.map} +1 -1
- package/dist/{chunk-WATFGHFK.js → chunk-7PPNAVBF.js} +4 -4
- package/dist/{chunk-WATFGHFK.js.map → chunk-7PPNAVBF.js.map} +1 -1
- package/dist/{chunk-GCXFTIHV.js → chunk-7ZTSYUCJ.js} +4 -4
- package/dist/{chunk-GCXFTIHV.js.map → chunk-7ZTSYUCJ.js.map} +1 -1
- package/dist/{chunk-BBQATCYN.js → chunk-A4Y5BVJN.js} +3 -3
- package/dist/{chunk-BBQATCYN.js.map → chunk-A4Y5BVJN.js.map} +1 -1
- package/dist/{chunk-IAM44RPN.js → chunk-AECYX56P.js} +4 -4
- package/dist/{chunk-IAM44RPN.js.map → chunk-AECYX56P.js.map} +1 -1
- package/dist/{chunk-AT6YLLT4.js → chunk-B36NISD2.js} +4 -4
- package/dist/{chunk-AT6YLLT4.js.map → chunk-B36NISD2.js.map} +1 -1
- package/dist/{chunk-BXMU3ARO.js → chunk-BEYWTFOR.js} +4 -4
- package/dist/{chunk-BXMU3ARO.js.map → chunk-BEYWTFOR.js.map} +1 -1
- package/dist/{chunk-AXTVBTO4.js → chunk-BKSVKSAW.js} +22 -22
- package/dist/{chunk-AXTVBTO4.js.map → chunk-BKSVKSAW.js.map} +1 -1
- package/dist/{chunk-KVBWIXXG.js → chunk-C5P2C2NR.js} +3 -3
- package/dist/{chunk-KVBWIXXG.js.map → chunk-C5P2C2NR.js.map} +1 -1
- package/dist/{chunk-PYUTATUY.js → chunk-C6PNF2OT.js} +3 -3
- package/dist/{chunk-PYUTATUY.js.map → chunk-C6PNF2OT.js.map} +1 -1
- package/dist/{chunk-VNEMV6IC.js → chunk-CFG6PGUZ.js} +4 -4
- package/dist/{chunk-VNEMV6IC.js.map → chunk-CFG6PGUZ.js.map} +1 -1
- package/dist/{chunk-GN7V2QHO.js → chunk-DHKZCR6U.js} +6 -6
- package/dist/{chunk-GN7V2QHO.js.map → chunk-DHKZCR6U.js.map} +1 -1
- package/dist/{chunk-WU5Z4JGX.js → chunk-DMGSEY7F.js} +3 -3
- package/dist/{chunk-WU5Z4JGX.js.map → chunk-DMGSEY7F.js.map} +1 -1
- package/dist/{chunk-VV7MDVGS.js → chunk-EF3PLLLA.js} +8 -8
- package/dist/{chunk-VV7MDVGS.js.map → chunk-EF3PLLLA.js.map} +1 -1
- package/dist/{chunk-WQPG22DY.js → chunk-EGI7F57E.js} +3 -3
- package/dist/{chunk-WQPG22DY.js.map → chunk-EGI7F57E.js.map} +1 -1
- package/dist/{chunk-W6KPVZZR.js → chunk-F7S2QA3D.js} +7 -7
- package/dist/{chunk-W6KPVZZR.js.map → chunk-F7S2QA3D.js.map} +1 -1
- package/dist/{chunk-P3WHN7JA.js → chunk-FTH3XLIN.js} +3 -3
- package/dist/{chunk-P3WHN7JA.js.map → chunk-FTH3XLIN.js.map} +1 -1
- package/dist/{chunk-CRO7DXS3.js → chunk-FXW6H6J3.js} +3 -3
- package/dist/{chunk-CRO7DXS3.js.map → chunk-FXW6H6J3.js.map} +1 -1
- package/dist/{chunk-TF6HFXTW.js → chunk-H7LRGY7U.js} +3 -3
- package/dist/{chunk-TF6HFXTW.js.map → chunk-H7LRGY7U.js.map} +1 -1
- package/dist/{chunk-RWAOBMAK.js → chunk-HZWTDQVJ.js} +6 -6
- package/dist/{chunk-RWAOBMAK.js.map → chunk-HZWTDQVJ.js.map} +1 -1
- package/dist/{chunk-HOJ5E2PG.js → chunk-IHOUADLX.js} +3 -3
- package/dist/{chunk-HOJ5E2PG.js.map → chunk-IHOUADLX.js.map} +1 -1
- package/dist/{chunk-GUODUINX.js → chunk-JOHFXU4C.js} +5 -5
- package/dist/{chunk-GUODUINX.js.map → chunk-JOHFXU4C.js.map} +1 -1
- package/dist/{chunk-MZ4LTJQD.js → chunk-K4YRFOFA.js} +7 -7
- package/dist/{chunk-MZ4LTJQD.js.map → chunk-K4YRFOFA.js.map} +1 -1
- package/dist/{chunk-LFHYQ6AN.js → chunk-M5WTY3EH.js} +3 -3
- package/dist/{chunk-LFHYQ6AN.js.map → chunk-M5WTY3EH.js.map} +1 -1
- package/dist/{chunk-RYGEIQWO.js → chunk-MGG4XAJ5.js} +3 -3
- package/dist/{chunk-RYGEIQWO.js.map → chunk-MGG4XAJ5.js.map} +1 -1
- package/dist/{chunk-O7OFWC34.js → chunk-O6RZ6AWT.js} +4 -4
- package/dist/{chunk-O7OFWC34.js.map → chunk-O6RZ6AWT.js.map} +1 -1
- package/dist/{chunk-LVUH4FOB.js → chunk-PBT52UWY.js} +5 -5
- package/dist/{chunk-LVUH4FOB.js.map → chunk-PBT52UWY.js.map} +1 -1
- package/dist/{chunk-C6WYORKW.js → chunk-PCYZMJUC.js} +3 -3
- package/dist/{chunk-C6WYORKW.js.map → chunk-PCYZMJUC.js.map} +1 -1
- package/dist/{chunk-ODP2N7CD.js → chunk-QBVXQHVJ.js} +4 -4
- package/dist/{chunk-ODP2N7CD.js.map → chunk-QBVXQHVJ.js.map} +1 -1
- package/dist/{chunk-MWYKP7CI.js → chunk-QMWP2ZP6.js} +3 -3
- package/dist/{chunk-MWYKP7CI.js.map → chunk-QMWP2ZP6.js.map} +1 -1
- package/dist/{chunk-LNTLWEYI.js → chunk-QXWCIK6D.js} +4 -4
- package/dist/{chunk-LNTLWEYI.js.map → chunk-QXWCIK6D.js.map} +1 -1
- package/dist/{chunk-5UWRPWK2.js → chunk-R7VWIXFX.js} +3 -3
- package/dist/{chunk-5UWRPWK2.js.map → chunk-R7VWIXFX.js.map} +1 -1
- package/dist/{chunk-Q7E4TNN7.js → chunk-SLBO4SEE.js} +3 -3
- package/dist/{chunk-Q7E4TNN7.js.map → chunk-SLBO4SEE.js.map} +1 -1
- package/dist/{chunk-FXVII733.js → chunk-T2752RH7.js} +27 -3
- package/dist/chunk-T2752RH7.js.map +1 -0
- package/dist/{chunk-4L5RHZHJ.js → chunk-T2O2IQJQ.js} +4 -4
- package/dist/{chunk-4L5RHZHJ.js.map → chunk-T2O2IQJQ.js.map} +1 -1
- package/dist/{chunk-YVQXIZY7.js → chunk-TQQN5AE2.js} +6 -6
- package/dist/{chunk-YVQXIZY7.js.map → chunk-TQQN5AE2.js.map} +1 -1
- package/dist/{chunk-3KTDODC5.js → chunk-VDY3VY7S.js} +3 -3
- package/dist/{chunk-3KTDODC5.js.map → chunk-VDY3VY7S.js.map} +1 -1
- package/dist/{chunk-2ZR562TA.js → chunk-VEVFVWF3.js} +5 -5
- package/dist/{chunk-2ZR562TA.js.map → chunk-VEVFVWF3.js.map} +1 -1
- package/dist/{chunk-W5LVGFHX.js → chunk-VNHYMLGK.js} +6 -6
- package/dist/{chunk-W5LVGFHX.js.map → chunk-VNHYMLGK.js.map} +1 -1
- package/dist/{chunk-MDU7ERR3.js → chunk-VQO4TTPE.js} +4 -4
- package/dist/{chunk-MDU7ERR3.js.map → chunk-VQO4TTPE.js.map} +1 -1
- package/dist/{chunk-JYPIPQ3V.js → chunk-X6WDFQYL.js} +3 -3
- package/dist/{chunk-JYPIPQ3V.js.map → chunk-X6WDFQYL.js.map} +1 -1
- package/dist/{chunk-NHA4SBKG.js → chunk-XMRNYUQY.js} +3 -3
- package/dist/{chunk-NHA4SBKG.js.map → chunk-XMRNYUQY.js.map} +1 -1
- package/dist/{chunk-6JH4QYKT.js → chunk-YDRURQ2W.js} +4 -4
- package/dist/{chunk-6JH4QYKT.js.map → chunk-YDRURQ2W.js.map} +1 -1
- package/dist/{chunk-AD4QPYNG.js → chunk-YEBA44IV.js} +4 -4
- package/dist/{chunk-AD4QPYNG.js.map → chunk-YEBA44IV.js.map} +1 -1
- package/dist/{chunk-V46O3Z7J.js → chunk-Z4EQHB26.js} +5 -5
- package/dist/{chunk-V46O3Z7J.js.map → chunk-Z4EQHB26.js.map} +1 -1
- package/dist/{chunk-TAVF4E7T.js → chunk-ZSEECSDV.js} +8 -8
- package/dist/{chunk-TAVF4E7T.js.map → chunk-ZSEECSDV.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-SWL4NCC6.js +32 -0
- package/dist/{document-class-TRLFCQHJ.js.map → document-class-SWL4NCC6.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-HWFEKUG6.js → navigation-7V4CSVG5.js} +8 -8
- package/dist/{navigation-HWFEKUG6.js.map → navigation-7V4CSVG5.js.map} +1 -1
- package/dist/{navigation-E75N4EU3.js → navigation-VMR4V27L.js} +7 -7
- package/dist/{navigation-E75N4EU3.js.map → navigation-VMR4V27L.js.map} +1 -1
- package/dist/{not-found-7SZU5K7G.js → not-found-S33EUV2Q.js} +26 -26
- package/dist/{not-found-7SZU5K7G.js.map → not-found-S33EUV2Q.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/loader.d.ts.map +1 -1
- package/dist/routes/blog.js +27 -19
- package/dist/routes/blog.js.map +1 -1
- 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.js +8 -8
- package/dist/routes/product-listing.js +30 -30
- package/dist/routes/product.js +28 -28
- package/dist/routes/root/beforeLoad.d.ts.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-LGYGZ4PU.js → store-lookup-D5C2LNXK.js} +11 -11
- package/dist/{store-lookup-LGYGZ4PU.js.map → store-lookup-D5C2LNXK.js.map} +1 -1
- package/dist/tanstack.js +19 -19
- package/dist/types/index.d.ts +5 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/baseHead.js +2 -2
- package/dist/utils/index.js +6 -6
- package/dist/utils/store-base.d.ts +30 -0
- package/dist/utils/store-base.d.ts.map +1 -1
- package/dist/utils/store-identity.d.ts +8 -0
- package/dist/utils/store-identity.d.ts.map +1 -1
- package/dist/vite/index.js +3 -3
- package/package.json +1 -1
- package/tailwind/routes/blog/loader.ts.txt +26 -8
- package/tailwind/routes/root/beforeLoad.ts.txt +27 -9
- package/dist/chunk-FXVII733.js.map +0 -1
- package/dist/ch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KAAM,CAAA,CAAE,QAAQ,WAAW,CAAA;AAAA,EACtC,CAAC,KAAA,EAAO,CAAC,CAAA,KAAM,CAAA,CAAE,QAAQ,GAAG;AAC9B,CAAA;AAGO,SAAS,0BAA0B,QAAA,EAA0C;AAClF,EAAA,OAAO,MAAA,CAAO,QAAQ,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-Q7E4TNN7.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,YA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AO,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-SLBO4SEE.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"]}
|
|
@@ -401,6 +401,21 @@ function storeBaseRedirectHref(args) {
|
|
|
401
401
|
url.searchParams.delete(STORE_ID_PARAM);
|
|
402
402
|
return `${prefixStoreBase(url.pathname, username)}${url.search}${url.hash}`;
|
|
403
403
|
}
|
|
404
|
+
var BASIC_PLAN_RAY = 0;
|
|
405
|
+
function stoppedDomainRedirectHref(args) {
|
|
406
|
+
const { host, named, ray, storeUrl, username } = args;
|
|
407
|
+
if (ray !== BASIC_PLAN_RAY || named || !host || allowsRequestStoreId(host)) return null;
|
|
408
|
+
if (!storeUrl || !username) return null;
|
|
409
|
+
let address;
|
|
410
|
+
try {
|
|
411
|
+
address = new URL(storeUrl);
|
|
412
|
+
} catch {
|
|
413
|
+
return null;
|
|
414
|
+
}
|
|
415
|
+
const { first } = splitLeadingSegment(address.pathname);
|
|
416
|
+
if (!first || first.toLowerCase() !== encodeURIComponent(username).toLowerCase()) return null;
|
|
417
|
+
return `${address.origin}/${first}/redirect`;
|
|
418
|
+
}
|
|
404
419
|
function loginRedirectHref(args) {
|
|
405
420
|
const { pathname, searchStr, origin, base, baseFollowsLocale = false } = args;
|
|
406
421
|
const first = pathname.split("/")[1];
|
|
@@ -452,7 +467,16 @@ function resolveStoreBaseRedirect(username, href) {
|
|
|
452
467
|
href
|
|
453
468
|
});
|
|
454
469
|
}
|
|
470
|
+
function resolveStoppedDomainRedirect(store) {
|
|
471
|
+
return stoppedDomainRedirectHref({
|
|
472
|
+
host: currentHost(),
|
|
473
|
+
named: Boolean(getRequestStore().storeId || resolveStoreBase()),
|
|
474
|
+
ray: store?.ray,
|
|
475
|
+
storeUrl: store?.url,
|
|
476
|
+
username: store?.username
|
|
477
|
+
});
|
|
478
|
+
}
|
|
455
479
|
|
|
456
|
-
export { AUTH_TOKEN_COOKIE_NAME, CURRENCY_COOKIE_NAME, LANGUAGE_COOKIE_MAX_AGE, LANGUAGE_COOKIE_NAME, SCOPE_COOKIE_MAX_AGE, SCOPE_COOKIE_NAME, STORE_BASE_HEADER, clearAuthTokenCookie, currentHost, decideSharedHostLanguage, escapeForInlineScript, extractCurrencyFromCookies, extractScopeFromCookies, extractScopeFromUrl, extractTokenFromCookies, getInjectedRuntimeEnv, hasLanguageParam, hasStoreUrlBase, isLoopback, isPreviewHost, legacyLocaleRedirectHref, loginRedirectHref, parseStoreId, prefixStoreBase, readEnv, readSdkScope, rememberDevStoreId, renderRuntimeEnvScript, resolveAddressedStore, resolveRequestScope, resolveRequestVersionId, resolveStoreBase, resolveStoreBaseFollowsLocale, resolveStoreBaseRedirect, resolveStoreIdentifier, sameScope, splitLeadingSegment, stripStoreBase, syncScopeCookie, toCurrencyCode, virtualLocale, withLanguageParam, withoutStoreUrlBase };
|
|
457
|
-
//# sourceMappingURL=chunk-
|
|
458
|
-
//# sourceMappingURL=chunk-
|
|
480
|
+
export { AUTH_TOKEN_COOKIE_NAME, CURRENCY_COOKIE_NAME, LANGUAGE_COOKIE_MAX_AGE, LANGUAGE_COOKIE_NAME, SCOPE_COOKIE_MAX_AGE, SCOPE_COOKIE_NAME, STORE_BASE_HEADER, clearAuthTokenCookie, currentHost, decideSharedHostLanguage, escapeForInlineScript, extractCurrencyFromCookies, extractScopeFromCookies, extractScopeFromUrl, extractTokenFromCookies, getInjectedRuntimeEnv, hasLanguageParam, hasStoreUrlBase, isLoopback, isPreviewHost, legacyLocaleRedirectHref, loginRedirectHref, parseStoreId, prefixStoreBase, readEnv, readSdkScope, rememberDevStoreId, renderRuntimeEnvScript, resolveAddressedStore, resolveRequestScope, resolveRequestVersionId, resolveStoppedDomainRedirect, resolveStoreBase, resolveStoreBaseFollowsLocale, resolveStoreBaseRedirect, resolveStoreIdentifier, sameScope, splitLeadingSegment, stripStoreBase, syncScopeCookie, toCurrencyCode, virtualLocale, withLanguageParam, withoutStoreUrlBase };
|
|
481
|
+
//# sourceMappingURL=chunk-T2752RH7.js.map
|
|
482
|
+
//# sourceMappingURL=chunk-T2752RH7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/cookies.ts","../src/utils/inline-script.ts","../src/utils/runtime-env.ts","../src/utils/shared-host-language.ts","../src/utils/store-base.ts","../src/utils/store-identity.ts"],"names":[],"mappings":";;;;AAEO,IAAM,sBAAA,GAAyB;AAC/B,IAAM,iBAAA,GAAoB;AAC1B,IAAM,oBAAA,GAAuB;AAE7B,IAAM,oBAAA,GAA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ACZ,UAAU,KAAA,EAAO,GAAA;AAAA,IACjB,UAAU,KAAA,EAAO;AAAA,GAClB,CAAA;AACH","file":"chunk-T2752RH7.js","sourcesContent":["import { isLocale } from '../providers/locale-constants';\n\nexport const AUTH_TOKEN_COOKIE_NAME = 'token';\nexport const SCOPE_COOKIE_NAME = 'scope';\nexport const CURRENCY_COOKIE_NAME = 's-curr';\n/** The language the SDK's localization modal remembers; host-wide, so shared by every store on a shared host. */\nexport const LANGUAGE_COOKIE_NAME = 's-lang';\n/** Query parameter the localization modal navigates with to ask for a language. */\nexport const LANGUAGE_PARAM = 'lang';\n/** How long a language choice is remembered: one year, like the `scope` cookie. */\nexport const LANGUAGE_COOKIE_MAX_AGE = 60 * 60 * 24 * 365;\n\n/**\n * Which store this request is for, when the hostname does not say.\n *\n * A live storefront is reached at its own domain, so the hostname identifies it\n * and nothing else is needed. A preview is not: every theme under review is\n * served from the one preview hostname, so the store has to be named some other\n * way — the dispatcher takes it from `?storeId=` and puts it here, the same way\n * it remembers which theme to serve.\n *\n * Written by the dispatcher rather than the theme, and set on the *forwarded\n * request* as well as the response, because the response cookie only arrives in\n * time for the second page load and the first one has to render too.\n *\n * The literal is a contract with `STORE_COOKIE` in store-front-dispacher\n * (`src/dispatch/preview.ts`), and **nothing checks the two agree**. Drift does\n * not fail loudly — it renders somebody else's shop. Grep both repos before\n * changing it.\n */\nexport const STORE_ID_COOKIE_NAME = 'salla_sid';\n\n/** Query parameter naming the store, on a host that serves more than one. */\nexport const STORE_ID_PARAM = 'storeId';\n\n/**\n * Which version of the theme's settings to render.\n *\n * A merchant's theme settings are versioned, and the storefront normally shows\n * whichever version is live — the API answers with it, and names it back as\n * `theme.profile.id`. Two places need a different one: the merchant's own theme\n * editor, which previews a draft version before it is published, and a partner\n * running a theme locally against a store whose settings they are editing. Both\n * open the theme inside an iframe, and the version travels in that URL.\n *\n * Named `versionId` rather than the `version_id` the Dashboard uses internally,\n * because it sits beside `?storeId=` and one URL should not spell two ids two\n * ways. The value is the same one either way: the Optimus-encoded version id,\n * which is exactly what `s-version-id` has always carried.\n *\n * The literal is a contract with `VERSION_COOKIE` in store-front-dispacher\n * (`src/dispatch/preview.ts`), on the same terms as {@link STORE_ID_COOKIE_NAME}:\n * nothing checks the two agree, and drift shows a merchant the wrong version of\n * their own settings rather than failing.\n */\nexport const VERSION_ID_COOKIE_NAME = 'salla_vid';\n\n/** Query parameter naming the theme-settings version, where one may be named. */\nexport const VERSION_ID_PARAM = 'versionId';\n\n/**\n * An id named by a request is an integer, and anything else is not one.\n *\n * Validated rather than passed through because these values end up in an upstream\n * API path and header. Leading zeroes, signs, decimals and whitespace are all\n * rejected: the point is a single canonical form, not the widest set of things\n * that could be coerced into a number.\n *\n * One function for both ids on purpose. They arrive the same way, from the same\n * untrusted place, and are spent the same way; two copies of this rule would be\n * two chances for one of them to be relaxed on its own.\n */\nfunction parseRequestId(raw: string | null | undefined): string | null {\n if (!raw) return null;\n return /^[1-9][0-9]{0,18}$/.test(raw) ? raw : null;\n}\n\n/** A store id in its canonical form, or null when it is not one. */\nexport function parseStoreId(raw: string | null | undefined): string | null {\n return parseRequestId(raw);\n}\n\n/** A theme-settings version id in its canonical form, or null when it is not one. */\nexport function parseVersionId(raw: string | null | undefined): string | null {\n return parseRequestId(raw);\n}\n\n/** The store id the dispatcher left in the cookie, or null when absent or malformed. */\nexport function extractStoreIdFromCookies(cookieHeader: string | null): string | null {\n return parseStoreId(extractTokenFromCookies(cookieHeader, STORE_ID_COOKIE_NAME));\n}\n\n/** The version id the dispatcher left in the cookie, or null when absent or malformed. */\nexport function extractVersionIdFromCookies(cookieHeader: string | null): string | null {\n return parseVersionId(extractTokenFromCookies(cookieHeader, VERSION_ID_COOKIE_NAME));\n}\n\n/**\n * The only hosts on which a request may name its own store.\n *\n * **This is a security boundary, not a convenience.** On a merchant's own domain\n * the hostname *is* the store, and it is the only thing that may decide. A theme\n * that also honoured `?storeId=` there would let anyone open\n * `https://reefperfumes.com/?storeId=<someone else>` and be served a different\n * merchant's shop from the domain its owner controls — their branding, their\n * customers' address bar, somebody else's catalogue — and the cookie would keep\n * serving it for the rest of that browser's session. Salla points SaaS domains\n * at this dispatcher, so those hostnames are real and reachable.\n *\n * The override exists for one situation: a host that serves many stores and so\n * cannot identify one from its name. That is the preview host, where every theme\n * under review answers on the same address, and local development.\n *\n * Adding an entry grants that host the ability to render any store on request,\n * **and** stops that host showing a closed or not-yet-launched store's maintenance\n * page to anyone (see {@link isPreviewHost}): the preview host is where the theme\n * editor frames a theme, and it has to render whatever it is customising. A host\n * that serves many stores is not enough reason to add one here. If a merchant's\n * customers can reach it, a closed store would stop showing them the page.\n * Add nothing that a merchant's traffic reaches.\n */\nexport const STORE_ID_HOSTS: readonly string[] = ['preview.salla.design'];\n\n/** The hostname alone — a port never distinguishes one host's authority from another's. */\nfunction hostnameOf(host: string): string {\n const trimmed = host.trim().toLowerCase();\n // IPv6 literals are bracketed, and the colons inside them are not a port.\n if (trimmed.startsWith('[')) return trimmed.slice(0, trimmed.indexOf(']') + 1) || trimmed;\n const colon = trimmed.indexOf(':');\n return colon === -1 ? trimmed : trimmed.slice(0, colon);\n}\n\nexport function isLoopback(hostname: string): boolean {\n return (\n hostname === 'localhost' ||\n hostname === '127.0.0.1' ||\n hostname === '[::1]' ||\n hostname.endsWith('.localhost')\n );\n}\n\n/**\n * Whether this host is the hosted preview host: the one address the dashboard's\n * theme editor and every theme under review answer on. Loopback is not it.\n *\n * Reads {@link STORE_ID_HOSTS} rather than keeping a second list, for the reason\n * {@link allowsRequestStoreId} gives: two lists of \"the preview host\" is how they\n * come to disagree. Exact hostnames only, so no suffix can admit another host.\n */\nexport function isPreviewHost(host: string | null | undefined): boolean {\n if (!host) return false;\n return STORE_ID_HOSTS.includes(hostnameOf(host));\n}\n\n/**\n * Whether this host is allowed to let the request choose a store.\n *\n * Deliberately an allowlist of exact hostnames plus loopback. No suffix matching:\n * a rule like \"anything ending in salla.design\" is one wildcard DNS record away\n * from admitting a host nobody meant to admit, and the list of hosts that serve\n * more than one store is short and known.\n *\n * It gates {@link resolveRequestVersionId} as well, and the name has been left\n * alone rather than generalised because one predicate that both call is the\n * property worth keeping — a second, subtly different list is how a host ends up\n * permitted to name one thing and not the other. A version is worth gating for\n * the same reason a store is: on a merchant's own domain, honouring\n * `?versionId=` would publish whatever draft settings they are still working on\n * to anyone who guessed the URL.\n */\nexport function allowsRequestStoreId(host: string | null | undefined): boolean {\n if (!host) return false;\n return isPreviewHost(host) || isLoopback(hostnameOf(host));\n}\n\n/**\n * Whether this host *is* a store, so its name can be used as the identifier.\n *\n * The exact inverse of {@link allowsRequestStoreId}, and deliberately written as\n * one so the two can never disagree: a host that may name its store is a host\n * that serves more than one, and a host that serves more than one cannot be the\n * answer to \"which store is this?\". `preview.salla.design` and `localhost:5188`\n * are not shops; asking the API about them earns a 422 and a page that reads as\n * a broken theme.\n */\nexport function hostIdentifiesStore(host: string | null | undefined): boolean {\n return Boolean(host) && !allowsRequestStoreId(host);\n}\n\n/**\n * The store this request names, on a host permitted to name one.\n *\n * The host check is inside the resolution rather than at a call site, because a\n * call site is a thing someone can add without reading this comment. There is no\n * way to ask \"what store did the request name?\" without also asking \"is this a\n * host that may say?\" — get it wrong and the answer is a security bug that looks\n * like a feature.\n *\n * Between the two permitted sources the URL wins, the same precedence the\n * dispatcher uses for the theme and for the same reason: a link is how someone\n * switches, and a cookie they cannot see should never beat the address they\n * just typed.\n */\nexport function resolveRequestStoreId(\n url: string,\n cookieHeader: string | null,\n host: string | null | undefined\n): string | null {\n return resolveRequestId(url, cookieHeader, host, STORE_ID_PARAM, STORE_ID_COOKIE_NAME);\n}\n\n/**\n * A store username as it can appear as the first segment of a path.\n *\n * Starts with a letter or digit, so nothing the platform mounts at the root of a\n * host — `/_serverFn/`, `/.well-known/` — is ever read as a store. Dots are allowed\n * (`zyros.sa`), but a root file (`/favicon.ico`, `/robots.txt`) is not a store.\n * The value is sent upstream as the `store-identifier` header, so the set is kept\n * narrow on purpose: a username outside it cannot be addressed by path, and\n * `?storeId=` still can.\n */\nconst STORE_BASE_SEGMENT = /^[a-z0-9][a-z0-9._-]{0,62}$/i;\nconst ROOT_FILE =\n /\\.(ico|txt|xml|json|webmanifest|html?|js|mjs|css|map|png|jpe?g|gif|svg|webp|avif|woff2?|ttf|otf|eot|pdf|mp4|webm|wasm)$/i;\n\n/**\n * Whether this could be a store's username in the first segment of a path.\n *\n * A supported locale code never is, in any case: `/ar` and `/EN` are languages,\n * so `preview.salla.design/en/cart` is the English cart of the store the cookie\n * names. That makes a store whose username is a locale code (`ar` is one)\n * unreachable by path; `?storeId=` still reaches it.\n *\n * The same predicate decides whether a username may become a path's root\n * (`storeBaseRedirectHref`). That is what stops the redirect from looping: a\n * store called `ar`, sent to `/ar/…`, would find no store there and be sent again.\n */\nexport function isStoreBaseSegment(value: string | null | undefined): value is string {\n return (\n typeof value === 'string' &&\n STORE_BASE_SEGMENT.test(value) &&\n !ROOT_FILE.test(value) &&\n !isLocale(value.toLowerCase())\n );\n}\n\n/**\n * The store the first segment of this request's path names, on a host permitted\n * to name one.\n *\n * On such a host the first segment **is** the store. It is the root of the\n * application there, so `https://preview.salla.design/mtgr-alaatr-2/cart` is the\n * cart of the store whose username is `mtgr-alaatr-2`. This is a rule rather than\n * a guess, and it has to be: `cart`, `offers` and `search` are all real store\n * usernames, so a store cannot be told from a page by looking at the segment.\n * `/cart` on these hosts is the store called `cart`.\n *\n * The one segment that is not a store is a supported locale code (see\n * {@link isStoreBaseSegment}). `/ar/cart` names a language, and the store comes\n * from the cookie or `VITE_STORE_DOMAIN`, as it would at `/`.\n *\n * A URL that carries `storeId` is not read this way at all, whatever its value.\n * That is how `salla theme dev` names a store (`/ar?storeId=…`), on a path that\n * begins with a page; the root loader then redirects to the store's own address.\n * Checking for a *valid* id instead would let a malformed one hand the page's\n * first segment the store's job. (On the preview host the dispatcher removes the\n * parameter and sends a cookie; the editor opens that host at `/`, where there is\n * no segment to read.)\n *\n * Same gate as {@link resolveRequestStoreId}, for the same reason: on a merchant's\n * own domain the hostname is the store and the path is only ever a page.\n */\nexport function resolveRequestStoreBase(\n url: string,\n host: string | null | undefined\n): string | null {\n if (!allowsRequestStoreId(host)) return null;\n\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return null;\n }\n if (parsed.searchParams.has(STORE_ID_PARAM)) return null;\n\n const first = parsed.pathname.split('/')[1];\n return isStoreBaseSegment(first) ? first : null;\n}\n\n/** Which store a request addressed, and how. At most one of the two is set. */\nexport interface RequestStore {\n /** Named by `?storeId=`, or by the cookie remembering it. */\n storeId: string | null;\n /** Named by the first segment of the path. */\n storeBase: string | null;\n}\n\n/**\n * The store this request addressed: the query, then the path, then the cookie.\n *\n * The path outranks the cookie because it is the address the visitor can see.\n * The cookie is one value for the whole preview host, so with two stores open in\n * two tabs it names whichever was opened last; the path names the one in front\n * of them.\n */\nexport function resolveRequestStore(\n url: string,\n cookieHeader: string | null,\n host: string | null | undefined\n): RequestStore {\n const storeBase = resolveRequestStoreBase(url, host);\n return {\n storeBase,\n storeId: storeBase ? null : resolveRequestStoreId(url, cookieHeader, host),\n };\n}\n\n/**\n * The header the storefront dispatcher names the store in, on a Salla shared host\n * that routes by username: `demostore.salla.sa/ar/dev-x/cart` is store `dev-x`.\n *\n * There the hostname belongs to every store, so the API cannot be asked about it\n * (it answers 422 and the page reads \"Store Unavailable\"), and only the dispatcher\n * has already read the username out of the path to choose this theme.\n *\n * Trusted because nothing else can set it. A theme worker is reached only through\n * the dispatcher, which hands it the headers on its own allowlist and then this one;\n * a visitor's copy never arrives. On a merchant's own domain the dispatcher does\n * not send it, so the hostname stays the store there.\n */\nexport const STORE_BASE_HEADER = 'x-salla-store-base';\n\n/** {@link RequestStore}, plus where the store segment sits in the path. */\nexport interface AddressedStore extends RequestStore {\n /**\n * True when the store segment follows the locale (`/ar/dev-x/cart`), as on a\n * Salla shared host; false when it is the root (`/mtgr-alaatr-2/ar/cart`), as on\n * the preview host and a dev server.\n */\n storeBaseFollowsLocale: boolean;\n}\n\n/**\n * The store this request addressed, counting the one the dispatcher named.\n *\n * The dispatcher's answer comes first and replaces the others: on a shared host it\n * is the address the visitor typed, read by the service that routed it here. Any\n * other request is resolved as {@link resolveRequestStore} always has, with the\n * segment at the root.\n */\nexport function resolveAddressedStore(\n url: string,\n cookieHeader: string | null,\n host: string | null | undefined,\n dispatchedStoreBase: string | null | undefined\n): AddressedStore {\n if (isStoreBaseSegment(dispatchedStoreBase)) {\n return { storeBase: dispatchedStoreBase, storeId: null, storeBaseFollowsLocale: true };\n }\n return { ...resolveRequestStore(url, cookieHeader, host), storeBaseFollowsLocale: false };\n}\n\n/**\n * The theme-settings version this request names, on a host permitted to name one.\n *\n * Same shape and the same host gate as {@link resolveRequestStoreId}, deliberately:\n * both answer \"what did this request ask to be shown?\", both are reached only on\n * a host that serves more than one thing, and a version that could be named where\n * a store could not would be a second rule to keep in step with the first.\n *\n * Null is the ordinary answer, and it is not a failure — it means nothing\n * addressed a version, so the store's own live one is what gets rendered.\n */\nexport function resolveRequestVersionId(\n url: string,\n cookieHeader: string | null,\n host: string | null | undefined\n): string | null {\n return resolveRequestId(url, cookieHeader, host, VERSION_ID_PARAM, VERSION_ID_COOKIE_NAME);\n}\n\n/**\n * The id this request names, from the query first and the cookie after.\n *\n * The host check lives here rather than at either call site, for the reason the\n * two wrappers above are wrappers at all: there must be no way to ask what a\n * request named without also asking whether this host may say.\n */\nfunction resolveRequestId(\n url: string,\n cookieHeader: string | null,\n host: string | null | undefined,\n param: string,\n cookieName: string\n): string | null {\n if (!allowsRequestStoreId(host)) return null;\n\n let fromQuery: string | null = null;\n try {\n fromQuery = parseRequestId(new URL(url).searchParams.get(param));\n } catch {\n /* a relative or malformed URL simply names nothing */\n }\n return fromQuery ?? parseRequestId(extractTokenFromCookies(cookieHeader, cookieName));\n}\n\n/**\n * Deletes the auth `token` cookie. This cookie is written client-side by the theme\n * (TwilightProvider), not by the SDK — `salla.cookie.clearAll()` only clears its own\n * allowlist and leaves `token` behind — so logout must clear it here. Client-only.\n */\n/**\n * On a dev server, remembers the store the page is showing, so a later URL that\n * names no store keeps it instead of falling back to `VITE_STORE_DOMAIN`.\n * Loopback only: on the preview host this cookie belongs to the dispatcher. Client-only.\n */\nexport function rememberDevStoreId(id: string | number | null | undefined): void {\n if (typeof document === 'undefined' || !isLoopback(window.location.hostname)) return;\n const storeId = parseStoreId(id == null ? null : String(id));\n if (storeId) document.cookie = `${STORE_ID_COOKIE_NAME}=${storeId}; path=/; SameSite=Lax`;\n}\n\nexport function clearAuthTokenCookie(): void {\n if (typeof document === 'undefined') return;\n document.cookie = `${AUTH_TOKEN_COOKIE_NAME}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;\n}\n\nexport function extractTokenFromCookies(\n cookieHeader: string | null,\n cookieName: string\n): string | null {\n if (!cookieHeader) return null;\n\n const prefix = `${cookieName}=`;\n let start = 0;\n\n while (start < cookieHeader.length) {\n const idx = cookieHeader.indexOf(prefix, start);\n if (idx === -1) return null;\n\n const prevChar = idx > 0 ? cookieHeader[idx - 1] : '';\n if (prevChar === '' || prevChar === ';' || prevChar === ' ') {\n let end = cookieHeader.indexOf(';', idx);\n if (end === -1) end = cookieHeader.length;\n\n const value = cookieHeader.slice(idx + prefix.length, end).trim();\n try {\n return decodeURIComponent(value) || null;\n } catch {\n return value || null;\n }\n }\n\n start = idx + prefix.length;\n }\n\n return null;\n}\n\n/**\n * The scope the Salla SDK persists as `scope`: the market (`id`/`type`) plus, once\n * bullet delivery confirms an address or branch, the allocation. The SDK sends all\n * four as request headers (`s-scope-id`, `s-scope-type`, `s-scope-allocation-type`,\n * `s-scope-allocation-id`) and the API resolves stock per allocation — a scope sent\n * without its allocation is a different question, answered from a different branch.\n */\nexport interface ActiveScope {\n id: string;\n type?: string;\n allocation_type?: string;\n allocation_id?: string;\n}\n\n/** The SDK stores the scope either as its full object or as a bare id. */\nfunction normalizeScope(raw: unknown): ActiveScope | null {\n if (raw == null) return null;\n if (typeof raw !== 'object') return { id: String(raw) };\n const s = raw as Record<string, unknown>;\n if (s.id == null) return null;\n const scope: ActiveScope = { id: String(s.id) };\n if (s.type != null) scope.type = String(s.type);\n if (s.allocation_type != null) scope.allocation_type = String(s.allocation_type);\n if (s.allocation_id != null) scope.allocation_id = String(s.allocation_id);\n return scope;\n}\n\n/**\n * Reads the active scope from the `scope` cookie, which Salla persists as a JSON\n * object (e.g. `{\"id\":123,\"type\":\"scope\",\"allocation_type\":\"branch\",\"allocation_id\":\"9\"}`).\n * Returns null when the cookie is missing or unparseable. Used server-side, where\n * `salla.storage` is absent.\n */\nexport function extractScopeFromCookies(cookieHeader: string | null): ActiveScope | null {\n const raw = extractTokenFromCookies(cookieHeader, SCOPE_COOKIE_NAME);\n if (!raw) return null;\n try {\n return normalizeScope(JSON.parse(raw));\n } catch {\n return null;\n }\n}\n\n/** `value` when it is a currency code, else null: the cookie's value goes into a request header. */\nexport function toCurrencyCode(value: string | null | undefined): string | null {\n return value && /^[A-Z]{3}$/.test(value) ? value : null;\n}\n\n/** The currency the visitor chose (`s-curr`, written by the SDK), or null for the store's own. */\nexport function extractCurrencyFromCookies(cookieHeader: string | null): string | null {\n return toCurrencyCode(extractTokenFromCookies(cookieHeader, CURRENCY_COOKIE_NAME));\n}\n\n/** {@link extractScopeFromCookies} reduced to the id. */\nexport function extractScopeIdFromCookies(cookieHeader: string | null): string | null {\n return extractScopeFromCookies(cookieHeader)?.id ?? null;\n}\n\n/**\n * The scope the Salla SDK persisted in its storage (`salla.storage.get('scope')`).\n *\n * Returns `undefined` when the SDK storage API isn't ready yet — deliberately\n * distinct from `null` (\"no branch selected\"), so callers can't mistake a\n * not-yet-hydrated SDK for a cleared selection. Client-only.\n *\n * Storage the SDK has loaded but not yet initialised counts as not ready: it is\n * what the previous visit left, and `init` replaces it with the scope the page\n * was rendered for and the one `?scope=` names. Read before that, it would\n * outvote the `scope` cookie the server wrote for this page.\n */\nexport function readSdkScope(): ActiveScope | null | undefined {\n const sdk = typeof window !== 'undefined' ? window.salla : undefined;\n const storage = sdk?.storage;\n if (typeof storage?.get !== 'function') return undefined;\n const status = (sdk as { status?: unknown } | undefined)?.status;\n if (status !== undefined && status !== 'ready') return undefined;\n return normalizeScope(storage.get(SCOPE_COOKIE_NAME));\n}\n\n/** The type of a multi-market (Country Scopes) store's scopes, which `s-scope-type` must name. */\nconst MARKET_SCOPE_TYPE = 'scope';\n\nconst ALLOCATION_TYPES = ['address', 'branch'];\n\n/** An encoded branch id, or the `msa_` token several branches are packed into. */\nconst ALLOCATION_ID = /^(?:[1-9][0-9]{0,18}|msa_[A-Za-z0-9+/=_-]{1,2048})$/;\n\n/**\n * The scope a page URL names, the way Twig storefronts switch market: the SDK's\n * scopes modal reloads the page with `?scope=<id>`, and a branch picked for it\n * travels as `allocation_type` / `allocation_id`. Null when the URL names none\n * or names it malformed; an allocation is kept only when both halves are valid.\n */\nexport function extractScopeFromUrl(url: string): ActiveScope | null {\n let params: URLSearchParams;\n try {\n params = new URL(url).searchParams;\n } catch {\n return null;\n }\n const id = parseRequestId(params.get('scope'));\n if (!id) return null;\n\n const scope: ActiveScope = { id };\n const allocationType = params.get('allocation_type');\n const allocationId = params.get('allocation_id');\n if (\n allocationType &&\n ALLOCATION_TYPES.includes(allocationType) &&\n allocationId &&\n ALLOCATION_ID.test(allocationId)\n ) {\n scope.allocation_type = allocationType;\n scope.allocation_id = allocationId;\n }\n return scope;\n}\n\n/**\n * The scope a request is for: the one its URL names, else the `scope` cookie.\n *\n * The URL wins because it is the newer choice: it is how a market is switched,\n * and the cookie still holds the one switched from. Merged with that cookie only\n * when both name the same scope; a different scope does not inherit the previous\n * one's branch. The type is store-wide, so it comes from the cookie, or is the\n * multi-market one when there is no cookie yet — the settings answer corrects it\n * for a store that browses by branch or city (see `rootBeforeLoad`).\n */\nexport function resolveRequestScope(url: string, cookieHeader: string | null): ActiveScope | null {\n const fromCookie = extractScopeFromCookies(cookieHeader);\n const fromUrl = extractScopeFromUrl(url);\n if (!fromUrl) return fromCookie;\n if (fromCookie?.id === fromUrl.id) return { ...fromCookie, ...fromUrl };\n return { ...fromUrl, type: fromCookie?.type ?? MARKET_SCOPE_TYPE };\n}\n\n/** {@link readSdkScope} reduced to the id; keeps the not-ready/none distinction. */\nexport function readSdkScopeId(): string | null | undefined {\n const scope = readSdkScope();\n return scope === undefined ? undefined : (scope?.id ?? null);\n}\n\n/** One year — the SDK keeps the selected branch in localStorage indefinitely. */\nexport const SCOPE_COOKIE_MAX_AGE = 60 * 60 * 24 * 365;\n\nexport const sameScope = (a: ActiveScope | null, b: ActiveScope | null): boolean =>\n JSON.stringify(a) === JSON.stringify(b);\n\n/**\n * Mirrors the scope the Salla SDK selected into the `scope` cookie so the SERVER\n * can see it. The SDK persists the selection in localStorage ONLY and writes no\n * cookie, so without this the server computes scope=null for every visitor who\n * picked a branch while the client computes the branch id — the dehydrated settings\n * query key never matches and the client refetches store settings on every page\n * load (SAL-122).\n *\n * Written in the SDK's own JSON shape so {@link extractScopeFromCookies} parses it,\n * allocation included: the bullet-delivery component writes the same cookie with the\n * full object, and rewriting it with the id alone would drop the branch the server\n * needs. Returns true when the cookie was (re)written. Client-only; no-op on the server.\n */\nexport function writeScopeCookie(scope: ActiveScope | null): boolean {\n if (typeof document === 'undefined') return false;\n if (sameScope(extractScopeFromCookies(document.cookie), scope)) return false;\n\n if (scope == null) {\n document.cookie = `${SCOPE_COOKIE_NAME}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;\n return true;\n }\n\n const value = encodeURIComponent(JSON.stringify(scope));\n document.cookie = `${SCOPE_COOKIE_NAME}=${value}; path=/; max-age=${SCOPE_COOKIE_MAX_AGE}; samesite=lax`;\n return true;\n}\n\n/**\n * Keeps the `scope` cookie in step with the SDK's selected branch. Call on every\n * client navigation; it no-ops while the SDK storage API is still hydrating so a\n * late-loading SDK can't wipe a valid cookie.\n */\nexport function syncScopeCookie(): boolean {\n const scope = readSdkScope();\n return scope === undefined ? false : writeScopeCookie(scope);\n}\n","/**\n * Escape a JSON-stringified value for safe embedding inside an inline `<script>` body.\n *\n * The head injects script bodies raw, so a `</script>` inside partner-set data would break out\n * of the tag; U+2028/U+2029 are line terminators in JS but not in JSON, so they must go too.\n */\nexport function escapeForInlineScript(value: string): string {\n return value\n .replace(/</g, '\\\\u003c')\n .replace(/>/g, '\\\\u003e')\n .replace(/&/g, '\\\\u0026')\n .replace(/\\u2028/g, '\\\\u2028')\n .replace(/\\u2029/g, '\\\\u2029');\n}\n","import { escapeForInlineScript } from './inline-script';\nimport { getRequestStore } from '../twilight/context';\nimport { hostIdentifiesStore } from './cookies';\n\n/** Where `rootHead` publishes the SSR-resolved env for the browser bundle to read. */\nconst RUNTIME_ENV_KEY = '__SALLA_RUNTIME_ENV__';\n\n/** The env values that must agree between the SSR render and the hydrated client. */\nexport interface RuntimeEnv {\n /** Store API base — `VITE_API_URL`. */\n apiBase?: string;\n /** Store identifier — `VITE_STORE_DOMAIN`. */\n storeIdentifier?: string;\n /**\n * The theme-settings version the request named, if any.\n *\n * Published for the same reason `storeIdentifier` is: the dispatcher strips\n * `?versionId=` on the way in, so by the time the browser has the page its own\n * URL no longer says which version it is showing. Without this the hydrated\n * client would ask the API about the store's live version and quietly replace\n * the draft it was handed.\n *\n * Absent — not empty — when nothing named one, so it drops out of the inline\n * script entirely rather than publishing a value that means \"live\".\n */\n versionId?: string;\n /**\n * The store segment at the root of this page's paths, when the store is\n * addressed that way — see `resolveStoreBase`.\n *\n * Published because the browser's address is not always the URL the server\n * read: the dispatcher removes `?storeId=` from the request it forwards but not\n * from the address bar, and a URL carrying it is never read for a segment. The\n * client builds its router from this, and a router that disagreed with the\n * server about the root would hydrate a different page.\n */\n storeBase?: string;\n /**\n * True when {@link storeBase} sits behind the locale (`/ar/dev-x/cart`), as on a\n * Salla shared host. Published with it: a client router that put the segment in\n * the other place would build every link to a page the dispatcher cannot route.\n * Absent when false, like the other flags here.\n */\n storeBaseFollowsLocale?: boolean;\n}\n\n/**\n * A build-time `import.meta.env` var, falling back to the worker's runtime `process.env`\n * (wrangler `vars`, exposed via the `nodejs_compat_populate_process_env` flag).\n */\nexport function readEnv(key: string): string | undefined {\n try {\n const vite = (import.meta as unknown as { env?: Record<string, string | undefined> }).env?.[\n key\n ];\n if (vite) return vite;\n } catch {\n /* import.meta.env not available in all environments */\n }\n return typeof process !== 'undefined' ? process.env?.[key] : undefined;\n}\n\n/**\n * What this runtime resolves from its own env — server-side that includes the worker vars.\n * Prefers what the server already published, so re-rendering the head during hydration yields\n * the same script instead of dropping it.\n */\nexport function resolveRuntimeEnv(): RuntimeEnv {\n const injected = getInjectedRuntimeEnv();\n const { storeId, storeBase, storeBaseFollowsLocale, versionId, requestHost } = getRequestStore();\n return {\n apiBase: injected.apiBase || readEnv('VITE_API_URL'),\n // The request outranks the build-time var here for the same reason it does\n // in `resolveStoreIdentifier`, and this is the copy that reaches the\n // browser: publish the store SSR actually rendered, or hydration resolves\n // again from a URL whose `?storeId=` the dispatcher has already stripped and\n // queries a different store than the markup it is hydrating.\n storeIdentifier:\n injected.storeIdentifier ||\n storeId ||\n storeBase ||\n (hostIdentifiesStore(requestHost) ? requestHost : null) ||\n readEnv('VITE_STORE_DOMAIN'),\n // Absent rather than empty when the path named no store, so it drops out of\n // the inline script, like `versionId`.\n storeBase: injected.storeBase || storeBase || undefined,\n storeBaseFollowsLocale:\n injected.storeBaseFollowsLocale || (storeBase ? storeBaseFollowsLocale : false) || undefined,\n // No env fallback on purpose. A store identifier has one because a build can\n // legitimately be pinned to a store; a version is something a request asks\n // for, and a build-time default would make every visitor of every store see\n // whichever draft was current when the theme was compiled.\n versionId: injected.versionId || versionId || undefined,\n };\n}\n\n/**\n * The env the SSR worker resolved, as handed to the browser by `rootHead`. Empty on the server\n * and on a client whose head carried nothing.\n *\n * Worker `vars` are *runtime* env: they live in `process.env` on the server only, while\n * `import.meta.env` is substituted at build time. A bundle built without those vars therefore\n * sees `undefined` in the browser and silently falls back to the production defaults — SSR\n * would render off the configured backend while every post-hydration fetch hits another one.\n */\nexport function getInjectedRuntimeEnv(): RuntimeEnv {\n const holder = globalThis as typeof globalThis & { [RUNTIME_ENV_KEY]?: RuntimeEnv };\n return holder[RUNTIME_ENV_KEY] ?? {};\n}\n\n/**\n * Inline head `<script>` body publishing the server-resolved env, or null when there is nothing\n * to publish (no overrides configured — the defaults already agree on both sides).\n */\nexport function renderRuntimeEnvScript(env: RuntimeEnv = resolveRuntimeEnv()): string | null {\n const set = Object.entries(env).filter(([, value]) => Boolean(value));\n if (!set.length) return null;\n const json = escapeForInlineScript(JSON.stringify(Object.fromEntries(set)));\n return `window.${RUNTIME_ENV_KEY}=${json};`;\n}\n","/**\n * @fileoverview The language of a page on a Salla shared host, where the URL does not carry it.\n *\n * On `demostore.salla.sa` and `salla.sa` a store is addressed `/dev-x/cart`. The route tree\n * still has a `/{-$locale}` segment, so the router puts a *virtual* locale in front of the\n * path on the way in and takes it off on the way out (`tanstack/store-base.ts`). This file\n * decides which one, and what to do when the choice is not one the store offers. See\n * `docs/store-base-path.md`.\n *\n * Pure: no request, no cookies written. The callers read and write those.\n */\nimport type { StoreContext } from '../api/store';\nimport { FALLBACK_LOCALE, isLocale } from '../providers/locale-constants';\nimport { extractTokenFromCookies, LANGUAGE_COOKIE_NAME, LANGUAGE_PARAM } from './cookies';\n\n/** A language code from a request, if it is one the engine knows. Case is not significant. */\nfunction knownLocale(value: string | null | undefined): string | null {\n const code = value?.toLowerCase();\n return isLocale(code) ? code : null;\n}\n\nfunction safeDecode(value: string): string {\n try {\n return decodeURIComponent(value);\n } catch {\n return value;\n }\n}\n\n/** The value of `?lang=` in a query string (with or without the `?`), or null when absent. */\nfunction langParam(search: string): string | null {\n for (const part of search.replace(/^\\?/, '').split('&')) {\n const [key, value = ''] = part.split('=');\n if (safeDecode(key) === LANGUAGE_PARAM) return safeDecode(value);\n }\n return null;\n}\n\n/** Whether a query string (with or without the `?`) carries `lang`, whatever its value. */\nexport function hasLanguageParam(search: string): boolean {\n return langParam(search) !== null;\n}\n\n/** The language the `s-lang` cookie remembers, if it is a known one. */\nexport function languageFromCookies(cookieHeader: string | null): string | null {\n return knownLocale(extractTokenFromCookies(cookieHeader, LANGUAGE_COOKIE_NAME));\n}\n\n/**\n * The language a request on a shared host is for, before the store's settings are known:\n * `?lang=`, then the `s-lang` cookie, then {@link FALLBACK_LOCALE}. Each must be a language\n * the engine knows; whether the store offers it is {@link decideSharedHostLanguage}'s\n * question.\n */\nexport function virtualLocale(search: string, cookieHeader: string | null): string {\n return knownLocale(langParam(search)) ?? languageFromCookies(cookieHeader) ?? FALLBACK_LOCALE;\n}\n\n/** The ISO codes (lower case) a store lists, or null when its settings did not say. */\nfunction listedLocales(settings: StoreContext): string[] | null {\n const codes = (settings.languages ?? [])\n .map((language) => (language.iso_code ?? language.code)?.toLowerCase())\n .filter((code): code is string => Boolean(code));\n return codes.length ? codes : null;\n}\n\n/**\n * Whether the store has more than one language to choose between.\n *\n * Both signals count: the merchant's `is_multilingual` switch, and the number of languages\n * the settings list. Either one saying \"single\" makes the store single-language. The count\n * is only used when the settings carry the list at all.\n */\nexport function isMultilingualStore(settings: StoreContext | null | undefined): boolean {\n if (settings?.store?.settings?.is_multilingual === false) return false;\n return settings?.languages == null || settings.languages.length >= 2;\n}\n\n/** The store's default language: the one marked, else the engine's fallback, else the first listed. */\nexport function defaultLanguage(settings: StoreContext): string | null {\n const listed = listedLocales(settings);\n if (!listed) return null;\n const marked = settings.languages?.find((language) => Boolean(language.is_default));\n const markedCode = (marked?.iso_code ?? marked?.code)?.toLowerCase();\n if (markedCode) return markedCode;\n return listed.includes(FALLBACK_LOCALE) ? FALLBACK_LOCALE : listed[0];\n}\n\n/**\n * The languages this store can be shown in, or null when its settings did not list any\n * (nothing to check against). A store that is not multilingual shows its default only.\n */\nexport function offeredLanguages(settings: StoreContext): string[] | null {\n const listed = listedLocales(settings);\n if (!listed) return null;\n if (isMultilingualStore(settings)) return listed;\n const only = defaultLanguage(settings);\n return only ? [only] : listed;\n}\n\n/** `search` (a query string, with or without `?`) without `lang`, and then `lang=<code>` if given. */\nexport function withLanguageParam(search: string, code?: string): string {\n const kept = search\n .replace(/^\\?/, '')\n .split('&')\n .filter((part) => part && safeDecode(part.split('=')[0]) !== LANGUAGE_PARAM);\n if (code) kept.push(`${LANGUAGE_PARAM}=${encodeURIComponent(code)}`);\n return kept.length ? `?${kept.join('&')}` : '';\n}\n\nexport interface SharedHostLanguage {\n /** A language to remember in the `s-lang` cookie, or null to leave the cookie alone. */\n cookie: string | null;\n /** Where to send the visitor (path, query and hash, in the address the browser uses), or null to render. */\n redirectTo: string | null;\n}\n\n/**\n * What to do with the language of a page on a shared host, once the store's settings are in.\n *\n * - `?lang=` asking for a language the store offers is remembered in the cookie. It is taken\n * off the URL with a redirect when that cannot change what the next request renders: the\n * cookie already says it, or it is the fallback a cookieless request gets anyway. Otherwise\n * it stays, so a visitor whose browser drops the cookie is not sent round in circles.\n * - `?lang=` asking for one the store does not offer is dropped, and nothing is remembered.\n * - No `?lang=`, and the language the request resolved to is not offered (a stale cookie\n * from another store on this host, or the fallback of a store that does not offer it):\n * sent to `?lang=<the store's default>`.\n *\n * Every redirect either removes `?lang=` or adds one for an offered language, so none\n * returns the request to itself.\n *\n * @param href - the browser's address for this page: path (with the store segment, without\n * a language), query and hash.\n * @param locale - the language the request resolved to ({@link virtualLocale}).\n */\nexport function decideSharedHostLanguage(args: {\n settings: StoreContext;\n locale: string;\n href: string;\n cookieHeader: string | null;\n}): SharedHostLanguage {\n const { settings, locale, href, cookieHeader } = args;\n const offered = offeredLanguages(settings);\n const url = new URL(href, 'http://shared-host.invalid');\n const withSearch = (search: string) => `${url.pathname}${search}${url.hash}`;\n\n const asked = langParam(url.search);\n if (asked !== null) {\n const wanted = knownLocale(asked);\n if (!wanted || (offered && !offered.includes(wanted))) {\n return { cookie: null, redirectTo: withSearch(withLanguageParam(url.search)) };\n }\n const remembered = languageFromCookies(cookieHeader);\n const clean = remembered === wanted || wanted === FALLBACK_LOCALE;\n return {\n cookie: remembered === wanted ? null : wanted,\n redirectTo: clean ? withSearch(withLanguageParam(url.search)) : null,\n };\n }\n\n if (offered && !offered.includes(locale)) {\n const fallback = defaultLanguage(settings) as string;\n return { cookie: null, redirectTo: withSearch(withLanguageParam(url.search, fallback)) };\n }\n return { cookie: null, redirectTo: null };\n}\n","/**\n * @fileoverview Paths on a host where the store is part of every address.\n *\n * On `preview.salla.design` and a dev server a store is addressed by the first\n * segment of the path — `/mtgr-alaatr-2/cart` — and that segment is the root of\n * the application. No route knows about it: the router takes it off every URL on\n * the way in and puts it back on every URL on the way out\n * (`tanstack/store-base.ts`), so pages, links and loaders all see `/cart`.\n *\n * On a Salla shared host (`demostore.salla.sa`, `salla.sa`) the store is the\n * root too — `/dev-x/cart`, with no language in the address — and the storefront\n * dispatcher names it (`resolveAddressedStore`). The old shape, `/ar/dev-x/cart`,\n * is still read, and redirected once by `twilightMiddleware`. The same two\n * functions move the segment, told which host it is.\n *\n * Which segment it is, and on which hosts, is decided once, in `utils/cookies.ts`.\n * This file only moves it on and off a path. See `docs/store-base-path.md`.\n */\nimport { allowsRequestStoreId, isStoreBaseSegment, STORE_ID_PARAM } from './cookies';\nimport { isLocale } from '../providers/locale-constants';\nimport { withLanguageParam } from './shared-host-language';\n\n/**\n * An application pathname, without the store segment in front.\n *\n * Only a whole segment is removed, so `/mtgr-alaatr-2x/cart` is left alone, and a\n * pathname that does not start with the segment comes back unchanged.\n *\n * With `followsLocale` the segment is also taken from behind a leading locale,\n * where Salla's shared hosts used to put it (`/ar/dev-x/cart` → `/ar/cart`). It is\n * looked for there first, then at the root, which is where it is now\n * (`/dev-x/cart`).\n */\nexport function stripStoreBase(pathname: string, base: string, followsLocale = false): string {\n if (followsLocale) {\n const segments = pathname.split('/');\n if (isLocale(segments[1]) && segments[2] === base) {\n segments.splice(2, 1);\n return segments.join('/');\n }\n }\n\n const prefix = `/${base}`;\n if (pathname === prefix) return '/';\n return pathname.startsWith(`${prefix}/`) ? pathname.slice(prefix.length) : pathname;\n}\n\n/**\n * A rooted path split into its first segment and what follows it (a path, a query, a hash, or\n * nothing). The segment ends at the first `/`, `?` or `#`. Plain string work, no pattern.\n */\nexport function splitLeadingSegment(rooted: string): { first: string; rest: string } {\n if (!rooted.startsWith('/')) return { first: '', rest: '' };\n let end = 1;\n while (end < rooted.length && rooted[end] !== '/' && rooted[end] !== '?' && rooted[end] !== '#') {\n end += 1;\n }\n return { first: rooted.slice(1, end), rest: rooted.slice(end) };\n}\n\n/**\n * An application path as the browser addresses it, with the store segment in front.\n *\n * It never checks whether the segment is already there, because that cannot be\n * told apart from a page of the same name: a store called `cart` keeps its cart at\n * `/cart/cart`. Callers pass application paths only.\n *\n * With `followsLocale` (a Salla shared host) the address has no language in it at\n * all: a leading locale is dropped (`/ar/cart` → `/dev-x/cart`). The language comes\n * back from `?lang=` or the `s-lang` cookie on the way in (`tanstack/store-base.ts`).\n */\nexport function prefixStoreBase(path: string, base: string, followsLocale = false): string {\n let rooted = path.startsWith('/') ? path : `/${path}`;\n\n if (followsLocale) {\n const { first, rest } = splitLeadingSegment(rooted);\n // What follows the locale is a path (`/cart`), a query or a hash, or nothing: the root.\n if (isLocale(first)) rooted = rest.startsWith('/') ? rest : `/${rest}`;\n }\n\n // The store's root is `/<base>`, not `/<base>/`, with or without a query or hash.\n const atRoot = rooted === '/' || rooted[1] === '?' || rooted[1] === '#';\n return `/${base}${atRoot ? rooted.slice(1) : rooted}`;\n}\n\n/**\n * Where to send a request that still uses the old shared-host address, or null when it\n * does not.\n *\n * Shared hosts used to put the language in front of the store (`/ar/dev-x/cart`) and now\n * leave it out (`/dev-x/cart`). A link in the old shape is sent once to the new one,\n * carrying its language as `?lang=` so the visitor keeps it; the page then remembers it\n * and the language stays out of the address (`rootBeforeLoad`).\n *\n * Only a path that *starts* with a locale and then names this store as a whole segment\n * matches, so a page whose slug is a locale code, or that is spelled like the store, is\n * never redirected. The result is a relative path: it cannot leave the host.\n */\nexport function legacyLocaleRedirectHref(url: string, base: string): string | null {\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return null;\n }\n\n const segments = parsed.pathname.split('/');\n if (!isLocale(segments[1]) || segments[2] !== base) return null;\n\n const pathname = ['', base, ...segments.slice(3)].join('/');\n // An explicit `?lang=` outranks the old path's language, as it did when it was rewritten\n // into the path.\n const search = parsed.searchParams.has('lang')\n ? parsed.search\n : withLanguageParam(parsed.search, segments[1]);\n return `${pathname}${search}`;\n}\n\n/**\n * A pathname from a link the Salla API handed out, without the store's username in it.\n *\n * A store with no domain of its own is served under its username on a shared host,\n * and every URL the API returns for it carries that segment. Its `store.url` is\n * `/{lang}/{username}/` when the store is multilingual and `/{username}/` when it is\n * not: `https://demostore.salla.sa/ar/dev-vgckq3fssfhjewwi/`, `https://salla.sa/cart/`.\n * The segment there belongs to Salla's host, not to the application. Left in, it\n * lands where a page slug is expected and matches no route.\n *\n * The username is the last segment of `store.url`, but only when it equals the\n * store's username. Neither its position nor its spelling says so on its own: `/ar/`\n * is the locale of `https://3tir.com/ar/`, a store on its own domain whose links carry\n * no username, and it is also the whole address of the store called `ar`,\n * `https://salla.sa/ar/`. Without a username to compare against, a last segment\n * spelled like a locale is taken to be one, which is wrong only for a store whose\n * username is a locale code.\n *\n * The locale stays wherever the link put it.\n */\nexport function withoutStoreUrlBase(\n pathname: string,\n storeUrlPathname: string,\n username?: string | null\n): string {\n const own = storeUrlSegment(storeUrlPathname, username);\n if (!own) return pathname;\n\n const segments = pathname.split('/');\n // Salla puts the locale first (`/ar/dev-x/…`); a store that is not multilingual has\n // none (`/dev-x/…`). Checked in that order, `/ar/ar/…` for a store called `ar` keeps\n // its locale.\n let at = -1;\n if (isLocale(segments[1]) && segments[2] === own) at = 2;\n else if (segments[1] === own) at = 1;\n if (at === -1) return pathname;\n\n segments.splice(at, 1);\n return segments.join('/') || '/';\n}\n\n/**\n * Whether a pathname on the store's host is this store's.\n *\n * On a shared host the origin belongs to every store there, and a link names its store\n * by the username in its path, where {@link withoutStoreUrlBase} looks for it. One\n * without it is another store's page, or the host's own. A store on its own domain has\n * no such segment, and every path on its host is its own.\n */\nexport function hasStoreUrlBase(\n pathname: string,\n storeUrlPathname: string,\n username?: string | null\n): boolean {\n const own = storeUrlSegment(storeUrlPathname, username);\n if (!own) return true;\n\n const segments = pathname.split('/');\n return segments[1] === own || (isLocale(segments[1]) && segments[2] === own);\n}\n\n/** The segment `store.url` serves the store under, or null when it has none. */\nfunction storeUrlSegment(storeUrlPathname: string, username?: string | null): string | null {\n const last = storeUrlPathname.split('/').filter(Boolean).pop();\n if (!last) return null;\n if (username) return last === username ? last : null;\n return isLocale(last) ? null : last;\n}\n\n/**\n * Where to send a page whose store was not named by its own first segment, or null\n * when it already was.\n *\n * On a host where the store is the root, every page has one address,\n * `/<username>/…`. A request that found its store some other way (`?storeId=`, the\n * preview cookie, `VITE_STORE_DOMAIN`, or a first segment that named the store by\n * another spelling, such as its numeric id) is sent there once the store's settings\n * say what its username is.\n *\n * `storeId` is dropped from the query on the way. It has to be: a URL carrying it\n * is never read for a store segment, so keeping it would redirect to an address\n * that redirects again, forever. For the same reason a username that could not be\n * read back out of a path produces no redirect at all.\n *\n * `href` is the application's own href (path, query and hash, already without any\n * store segment), which the router keeps percent-encoded, so the result is safe to\n * put in a `Location` header.\n */\nexport function storeBaseRedirectHref(args: {\n host: string | null | undefined;\n base: string | null;\n username: string | null | undefined;\n href: string;\n}): string | null {\n const { host, base, username, href } = args;\n if (!allowsRequestStoreId(host) || !isStoreBaseSegment(username) || username === base) {\n return null;\n }\n\n const url = new URL(href, 'http://store-base.invalid');\n url.searchParams.delete(STORE_ID_PARAM);\n return `${prefixStoreBase(url.pathname, username)}${url.search}${url.hash}`;\n}\n\n/**\n * The `ray` a basic-plan store's settings carry: Core's `Plan::getRayScore()`, which scores the\n * plans basic 0, plus 25, team 50 and special 100. A store with no plan scores 0 too, and a test\n * store always scores 50.\n */\nexport const BASIC_PLAN_RAY = 0;\n\n/**\n * Where a basic-plan store's own domain sends a shopper, as Twig's `checkUsername` does: a\n * 302 to the Store's \"this domain is stopped\" page, `https://salla.sa/<username>/redirect`\n * (`store.redirect-to-normal-url`), keeping neither the path nor the query. Null for any\n * other request.\n *\n * The plan is the settings' `ray` ({@link BASIC_PLAN_RAY}). The page is at the store's address,\n * which Core builds without the custom domain for a basic-plan store (`isUrlWithoutDomain`):\n * `https://salla.sa/<username>/`. Both are required. A store with no plan also has a `ray` of\n * 0, but its address is its own domain (`/` or `/<language>/`, no username), and the Store\n * serves it there.\n *\n * Only on a host that is the store. A request that named its store has nothing to stop: on\n * salla.sa the dispatcher names it, and the preview host and localhost serve many stores.\n * Unlike Twig, a basic-plan test store is served, because its `ray` is a team plan's.\n */\nexport function stoppedDomainRedirectHref(args: {\n host: string | null | undefined;\n /** Whether the request named its store (`?storeId=`, its cookie, a path segment). */\n named: boolean;\n ray: number | null | undefined;\n storeUrl: string | null | undefined;\n username: string | null | undefined;\n}): string | null {\n const { host, named, ray, storeUrl, username } = args;\n if (ray !== BASIC_PLAN_RAY || named || !host || allowsRequestStoreId(host)) return null;\n if (!storeUrl || !username) return null;\n\n let address: URL;\n try {\n address = new URL(storeUrl);\n } catch {\n return null;\n }\n\n const { first } = splitLeadingSegment(address.pathname);\n if (!first || first.toLowerCase() !== encodeURIComponent(username).toLowerCase()) return null;\n\n return `${address.origin}/${first}/redirect`;\n}\n\n/**\n * Where to send a guest who opened a customer-only page: the locale's home with\n * `intended_to`, which the SDK reads to open the login modal and come back after.\n * Null when already there, so the redirect cannot loop.\n */\nexport function loginRedirectHref(args: {\n pathname: string;\n searchStr: string;\n origin: string;\n base: string | null;\n baseFollowsLocale?: boolean;\n}): string | null {\n const { pathname, searchStr, origin, base, baseFollowsLocale = false } = args;\n const first = pathname.split('/')[1];\n const home = isLocale(first) ? `/${first}` : '/';\n if ((pathname.replace(/\\/$/, '') || '/') === home) return null;\n\n const browserPath = (path: string) =>\n base ? prefixStoreBase(path, base, baseFollowsLocale) : path;\n const intended = `${origin}${browserPath(pathname)}${searchStr}`;\n return `${browserPath(home)}?intended_to=${encodeURIComponent(intended)}`;\n}\n","/**\n * @fileoverview Which store to ask about — the one answer, in one place.\n *\n * This lived in two places once. `api/store.ts` learned to read the store a\n * request names, and `utils/sdk-helpers.ts` — the copy `api/client.ts` actually\n * sets the `store-identifier` header from — did not. So the resolver that had\n * been taught the answer was consulted for a null check and thrown away, every\n * outgoing request carried an empty identifier, the API answered\n * `422 Store Identifier not found`, and every published theme rendered\n * \"Store Unavailable\" while its tests passed: the client's suite mocked the\n * resolver, and the resolver's suite never went near a request.\n *\n * Hence one module, imported by both. If a third place ever needs a store\n * identifier, it imports this — a second implementation is the bug, not a\n * refactor away from it.\n *\n * See `docs/store-identity.md` for the full picture, including the security\n * boundary on who may name a store.\n */\nimport { getRequestStore } from '../twilight/context';\nimport { hostIdentifiesStore, resolveRequestStoreBase } from './cookies';\nimport { getInjectedRuntimeEnv, readEnv } from './runtime-env';\nimport { stoppedDomainRedirectHref, storeBaseRedirectHref } from './store-base';\nimport type { Store } from '../types';\n\n/**\n * Which store to ask about, in the order the answers can be trusted.\n *\n * A deployed theme worker is published with **no vars and no bindings** — the\n * script metadata carries `main_module`, compatibility settings, assets and tags\n * and nothing else — so `VITE_STORE_DOMAIN` exists only where a build baked it\n * in, which is local development. In production this function used to reach the\n * end of that chain and return the empty string, `store.settings` refused to\n * call with no identifier, and the root loader threw \"Store Unavailable\" — a\n * theme that renders its own failure page for every visitor of every store.\n *\n * The order:\n *\n * 1. what the caller passed, which is always deliberate;\n * 2. the store this request names — the `?storeId=` a preview was opened with,\n * then the cookie remembering it — seeded by `twilightMiddleware`, and only\n * on a host permitted to name one;\n * 3. the store the first segment of the path names, on those same hosts — its\n * username, which the API accepts as an identifier as readily as an id (see\n * {@link resolveStoreBase});\n * 4. what SSR already resolved and published, so the hydrated client asks about\n * the same store the server rendered instead of resolving again from a URL\n * that no longer names it;\n * 5. the request's own host, which *is* the identity of a live storefront —\n * but only when that host is a storefront. `preview.salla.design` and\n * `localhost` serve many stores, so their names identify none;\n * 6. `VITE_STORE_DOMAIN`, last, because a build-time constant is a development\n * convenience and must never outrank what the request actually said.\n *\n * Steps 2 and 3 never both answer: a path that names a store takes the place of\n * the cookie, and a URL carrying `?storeId=` is not read for a path segment.\n */\nexport function resolveStoreIdentifier(explicit?: string): string {\n if (explicit) return explicit;\n\n const { storeId, requestHost } = getRequestStore();\n if (storeId) return storeId;\n\n const storeBase = resolveStoreBase();\n if (storeBase) return storeBase;\n\n const injected = getInjectedRuntimeEnv().storeIdentifier;\n if (injected) return injected;\n\n if (hostIdentifiesStore(requestHost)) return requestHost as string;\n\n // The browser's own address, for a client render that reached neither of the\n // above — a live storefront, where the host is the store.\n const browserHost = typeof window !== 'undefined' ? window.location.host : null;\n if (hostIdentifiesStore(browserHost)) return browserHost as string;\n\n return readEnv('VITE_STORE_DOMAIN') || readEnv('STORE_DOMAIN') || '';\n}\n\n/**\n * The store segment at the root of this page's paths, or null when the store is\n * not addressed that way.\n *\n * On the server it is what `twilightMiddleware` read off the request. In the\n * browser it is what SSR published, because the address bar is not always the\n * URL the server rendered: on the preview host the dispatcher removes\n * `?storeId=` from the request it forwards and leaves it in the browser's, and a\n * URL carrying `storeId` is never read for a segment. Re-reading\n * `window.location` would, for `/ar?storeId=…`, route the page under a different\n * store than the one it was rendered for.\n *\n * The address bar is read only when SSR published nothing at all: a page the dev\n * server answered with its client shell instead of a render, where there is no\n * server decision to agree with.\n */\nexport function resolveStoreBase(): string | null {\n const { storeBase } = getRequestStore();\n if (storeBase) return storeBase;\n if (typeof window === 'undefined') return null;\n\n const published = getInjectedRuntimeEnv();\n if (published.storeBase) return published.storeBase;\n if (Object.keys(published).length > 0) return null;\n\n return resolveRequestStoreBase(window.location.href, window.location.host);\n}\n\n/**\n * Whether {@link resolveStoreBase}'s segment sits behind the locale\n * (`/ar/dev-x/cart`) rather than at the root of the path.\n *\n * True only on a Salla shared host, where the dispatcher named the store. Read\n * from the same place as the segment, so the two always describe one address: the\n * request on the server, what SSR published in the browser.\n */\nexport function resolveStoreBaseFollowsLocale(): boolean {\n const { storeBase, storeBaseFollowsLocale } = getRequestStore();\n if (storeBase) return storeBaseFollowsLocale;\n if (typeof window === 'undefined') return false;\n\n const published = getInjectedRuntimeEnv();\n return Boolean(published.storeBase && published.storeBaseFollowsLocale);\n}\n\n/**\n * The host this page was asked for: the request's on the server, the browser's own in\n * the browser.\n *\n * The middleware captures `requestHost` from the request and nothing sets it in the\n * browser, so the browser reads `window.location.host`. Both sides then name the same\n * host for the same page, which is what keeps a decision made from it (the store base,\n * the maintenance page) from flipping between the server render and hydration.\n */\nexport function currentHost(): string | null {\n return (\n getRequestStore().requestHost ?? (typeof window !== 'undefined' ? window.location.host : null)\n );\n}\n\n/**\n * The address this page should be loaded from instead, when the store is the root\n * of every URL on this host and this request did not use it; null otherwise.\n *\n * @param username - the store's username, from the settings the request loaded\n * @param href - the router's own href for the page, without any store segment\n *\n * See `storeBaseRedirectHref` for the rules. The host is the request's on the\n * server and the browser's own in the browser, so the decision is gated the same\n * way on both sides.\n */\nexport function resolveStoreBaseRedirect(\n username: string | null | undefined,\n href: string\n): string | null {\n return storeBaseRedirectHref({\n host: currentHost(),\n base: resolveStoreBase(),\n username,\n href,\n });\n}\n\n/**\n * The Store's \"this domain is stopped\" page, when this request came on a basic-plan\n * store's own domain; null otherwise. See `stoppedDomainRedirectHref` for the rules.\n *\n * @param store - the store the settings were answered for\n */\nexport function resolveStoppedDomainRedirect(store: Store | null | undefined): string | null {\n return stoppedDomainRedirectHref({\n host: currentHost(),\n named: Boolean(getRequestStore().storeId || resolveStoreBase()),\n ray: store?.ray,\n storeUrl: store?.url,\n username: store?.username,\n });\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { orThrow, orUnauthorized } from './chunk-
|
|
2
|
-
import { api } from './chunk-
|
|
1
|
+
import { orThrow, orUnauthorized } from './chunk-VEVFVWF3.js';
|
|
2
|
+
import { api } from './chunk-2DUN6DZK.js';
|
|
3
3
|
import { queryOptions } from '@tanstack/react-query';
|
|
4
4
|
|
|
5
5
|
var order = {
|
|
@@ -78,5 +78,5 @@ var order = {
|
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
export { order };
|
|
81
|
-
//# sourceMappingURL=chunk-
|
|
82
|
-
//# sourceMappingURL=chunk-
|
|
81
|
+
//# sourceMappingURL=chunk-T2O2IQJQ.js.map
|
|
82
|
+
//# sourceMappingURL=chunk-T2O2IQJQ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/order.ts"],"names":[],"mappings":";;;;AAoDO,IAAM,KAAA,GAAQ;AAAA,EACnB,IAAA,EAAM,OAAO,MAAA,KAA2D;AACtE,IAAA,MAAM;AAAA,MACJ,IAAA;AAAA,MACA,MAAA;AAAA,MACA,MAAA;AAAA,MACA,eAAA,EAAiB,cAAA;AAAA,MACjB,UAAA,EAAY,SAAA;AAAA,MACZ;AAAA,KACF,GAAI,UAAU,EAAC;AAEf,IAAA,MAAM,YAAA,GAAe,IAAI,eAAA,EAAgB;AACzC,IAAA,IAAI,SAAS,MAAA,EAAW,YAAA,CAAa,IAAI,MAAA,EAAQ,MAAA,CAAO,IAAI,CAAC,CAAA;AAC7D,IAAA,IAAI,MAAA,EAAQ,YAAA,CAAa,GAAA,CAAI,QAAA,EAAU,MAAM,CAAA;AAC7C,IAAA,IAAI,MAAA,EAAQ,YAAA,CAAa,GAAA,CAAI,QAAA,EAAU,MAAM,CAAA;AAC7C,IAAA,IAAI,cAAA,EAAgB,YAAA,CAAa,GAAA,CAAI,iBAAA,EAAmB,cAAc,CAAA;AACtE,IAAA,IAAI,SAAA,EAAW,YAAA,CAAa,GAAA,CAAI,YAAA,EAAc,GAAG,CAAA;AAEjD,IAAA,MAAM,UAAmC,EAAC;AAC1C,IAAA,IAAI,MAAA,UAAgB,MAAA,GAAS,MAAA;AAE7B,IAAA,MAAM,QAAA,GAAW,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A,CAAM,OAAA,CAAQ,OAAO;AAAA,KACrC,CAAA;AAAA,IACH,QAAA,EAAU,CAAC,OAAA,KACT,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,QAAA,EAAU,UAAA,EAAY,OAAO,CAAA;AAAA,MACxC,OAAA,EAAS,MAAM,KAAA,CAAM,QAAA,CAAS,OAAO;AAAA,KACtC;AAAA;AAEP","file":"chunk-T2O2IQJQ.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\nimport type {\n Order,\n OrderListItem,\n OrderShipmentItem,\n OrderRatingItem,\n} from '../routes/account/types';\nimport type { Pagination } from './types';\nimport { orThrow, orUnauthorized } from '../providers/NavigationProvider';\n\nexport interface OrderDetailResponse {\n order: Order;\n}\n\n/**\n * The order in the shape the Twilight web components read (`salla-order-details`,\n * `salla-order-totals-card`) and the Twig themes render: the API answers `orders/{id}` this\n * way when the request does not say it comes from a React theme (`s-theme-type`).\n */\nexport interface TwilightOrder {\n items: Array<{\n name: string;\n quantity: number;\n product?: { id: number; url?: string; type?: string; image?: { url?: string } };\n options?: unknown[];\n }>;\n [key: string]: unknown;\n}\n\nexport interface CheckoutThankYouData {\n thank_you_title?: string;\n messages?: string[];\n share_message?: string;\n short_share_message?: string;\n}\n\nexport interface OrdersListResponse {\n data: OrderListItem[];\n cursor?: Pagination;\n}\n\nexport interface OrdersListParams {\n page?: number;\n cursor?: string | null;\n status?: string;\n feedback_status?: string;\n /** When set, the list payload includes each order's `items[]` (`with_items=1`). */\n with_items?: boolean | number;\n signal?: AbortSignal;\n}\n\nexport const order = {\n list: async (params?: OrdersListParams): Promise<OrdersListResponse> => {\n const {\n page,\n cursor,\n status,\n feedback_status: feedbackStatus,\n with_items: withItems,\n signal,\n } = params ?? {};\n\n const searchParams = new URLSearchParams();\n if (page !== undefined) searchParams.set('page', String(page));\n if (cursor) searchParams.set('cursor', cursor);\n if (status) searchParams.set('status', status);\n if (feedbackStatus) searchParams.set('feedback_status', feedbackStatus);\n if (withItems) searchParams.set('with_items', '1');\n\n const options: Record<string, unknown> = {};\n if (signal) options.signal = signal;\n\n const response = await api\n .get(`orders?${searchParams.toString()}`, options as any)\n .json<{ data: OrderListItem[] | null; cursor?: Pagination }>();\n\n return {\n data: response.data ?? [],\n cursor: response.cursor,\n };\n },\n\n find: async (id: string): Promise<OrderDetailResponse> => {\n const response = await api.get(`orders/${id}`).json<{ data: Order }>();\n\n return { order: response.data };\n },\n\n findForComponents: async (id: string): Promise<TwilightOrder> => {\n const response = await api\n .get(`orders/${id}`, {\n hooks: {\n // Runs after the client's own hook, which marks every request as from a React theme.\n beforeRequest: [({ request }) => request.headers.delete('s-theme-type')],\n },\n })\n .json<{ data: TwilightOrder }>();\n return response.data;\n },\n\n shipments: async (orderId: string): Promise<OrderShipmentItem[]> => {\n const response = await api\n .get(`orders/${orderId}/shipments`)\n .json<{ data: OrderShipmentItem[] }>();\n return response.data ?? [];\n },\n\n ratings: async (orderId: string): Promise<OrderRatingItem[]> => {\n const response = await api.get(`orders/${orderId}/ratings`).json<{ data: OrderRatingItem[] }>();\n return response.data ?? [];\n },\n\n findOrThrow: (id: string): Promise<OrderDetailResponse> =>\n orThrow(orUnauthorized(order.find(id))),\n\n thankYou: async (orderId: string): Promise<CheckoutThankYouData> => {\n const { data } = await api\n .get(`checkout/thank-you/${orderId}`)\n .json<{ data: CheckoutThankYouData }>();\n return data;\n },\n\n thankYouOrThrow: (orderId: string): Promise<CheckoutThankYouData> =>\n orThrow(order.thankYou(orderId)),\n\n queries: {\n list: (params?: Omit<OrdersListParams, 'signal'>) =>\n queryOptions({\n queryKey: ['orders', 'list', params],\n queryFn: ({ signal }) => order.list({ ...params, signal }),\n }),\n find: (id: string) =>\n queryOptions({\n queryKey: ['orders', 'detail', id],\n queryFn: () => order.find(id),\n }),\n shipments: (orderId: string) =>\n queryOptions({\n queryKey: ['orders', 'shipments', orderId],\n queryFn: () => order.shipments(orderId),\n }),\n ratings: (orderId: string) =>\n queryOptions({\n queryKey: ['orders', 'ratings', orderId],\n queryFn: () => order.ratings(orderId),\n }),\n thankYou: (orderId: string) =>\n queryOptions({\n queryKey: ['orders', 'thankYou', orderId],\n queryFn: () => order.thankYou(orderId),\n }),\n },\n};\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { isNotLaunchedNotice } from './chunk-
|
|
2
|
-
import { getActiveScope, api, STORE_IDENTIFIER_HEADER, devSettingsFetchedAt } from './chunk-
|
|
3
|
-
import { requestedThemeVersionId } from './chunk-
|
|
4
|
-
import { LANGUAGE_COOKIE_NAME, LANGUAGE_COOKIE_MAX_AGE, resolveStoreIdentifier, extractScopeFromUrl, parseStoreId } from './chunk-
|
|
1
|
+
import { isNotLaunchedNotice } from './chunk-SLBO4SEE.js';
|
|
2
|
+
import { getActiveScope, api, STORE_IDENTIFIER_HEADER, devSettingsFetchedAt } from './chunk-2DUN6DZK.js';
|
|
3
|
+
import { requestedThemeVersionId } from './chunk-XMRNYUQY.js';
|
|
4
|
+
import { LANGUAGE_COOKIE_NAME, LANGUAGE_COOKIE_MAX_AGE, resolveStoreIdentifier, extractScopeFromUrl, parseStoreId } from './chunk-T2752RH7.js';
|
|
5
5
|
import { getTwilightContext, SettingsError } from './chunk-6K34BCUP.js';
|
|
6
6
|
import { queryOptions } from '@tanstack/react-query';
|
|
7
7
|
import { isTimeoutError, isHTTPError, isNetworkError } from 'ky';
|
|
@@ -250,5 +250,5 @@ var store = {
|
|
|
250
250
|
};
|
|
251
251
|
|
|
252
252
|
export { persistLanguageCookie, readCookieHeader, readNativeAppHeaders, readPageSearch, store };
|
|
253
|
-
//# sourceMappingURL=chunk-
|
|
254
|
-
//# sourceMappingURL=chunk-
|
|
253
|
+
//# sourceMappingURL=chunk-TQQN5AE2.js.map
|
|
254
|
+
//# sourceMappingURL=chunk-TQQN5AE2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/language-cookie.ts","../src/utils/native-app-headers.ts","../src/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AAAA,QACrB,cAAA,EAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAQf,uBAAA;AAAwB,OAC1B;AAAA;AAAA,MAEA,OAAA,EAAS,MAAM,aAAA,CAAc,eAAe,CAAA;AAAA;AAAA;AAAA,MAG5C,KAAA,EAAO;AAAA,KACR;AAAA;AAEP","file":"chunk-YVQXIZY7.js","sourcesContent":["/**\n * @fileoverview Reading and writing the `s-lang` cookie, on the server and in the browser.\n *\n * The server reads it from the request the framework is handling and writes it to that\n * request's response. The server-only import is stripped from the client bundle by\n * `createIsomorphicFn`, as in `routes/root/beforeLoad.ts`. The browser uses `document.cookie`.\n * Either side outside a request (a prerender, a test) has nothing to read or write and says so\n * quietly.\n */\nimport { createIsomorphicFn } from '@tanstack/react-start';\nimport { getRequestHeader, getRequestUrl, setCookie } from '@tanstack/react-start/server';\nimport { LANGUAGE_COOKIE_MAX_AGE, LANGUAGE_COOKIE_NAME } from './cookies';\n\nconst readServerCookieHeader = createIsomorphicFn()\n .server((): string | null => {\n try {\n return getRequestHeader('cookie') ?? null;\n } catch {\n return null;\n }\n })\n .client((): string | null => null);\n\nconst writeServerLanguageCookie = createIsomorphicFn()\n .server((code: string): void => {\n try {\n setCookie(LANGUAGE_COOKIE_NAME, code, {\n path: '/',\n maxAge: LANGUAGE_COOKIE_MAX_AGE,\n sameSite: 'lax',\n });\n } catch {\n // Outside a request: there is no response to write to.\n }\n })\n .client((): void => {});\n\nconst readServerSearch = createIsomorphicFn()\n .server((): string => {\n try {\n return getRequestUrl().search;\n } catch {\n return '';\n }\n })\n .client((): string => '');\n\n/**\n * The query string of the page being rendered (`?lang=en`, or `''`): the request's on the\n * server, the address bar's in the browser, so both sides read the same one.\n */\nexport function readPageSearch(): string {\n return readServerSearch() || (typeof window !== 'undefined' ? window.location.search : '');\n}\n\n/** The `Cookie` header of the request being handled, or `document.cookie` in the browser. */\nexport function readCookieHeader(): string | null {\n return readServerCookieHeader() ?? (typeof document !== 'undefined' ? document.cookie : null);\n}\n\n/** Remembers `code` as the visitor's language for every store on this host. */\nexport function persistLanguageCookie(code: string): void {\n writeServerLanguageCookie(code);\n if (typeof document !== 'undefined') {\n document.cookie = `${LANGUAGE_COOKIE_NAME}=${encodeURIComponent(code)}; path=/; max-age=${LANGUAGE_COOKIE_MAX_AGE}; SameSite=Lax`;\n }\n}\n","/** The headers the Salla native app sends with every page it loads in its webview. */\nexport const NATIVE_APP_HEADERS = [\n 's-app-os',\n 's-app-version',\n 's-app-full-version',\n 's-app-os-version',\n];\n\n/**\n * The native app's own headers on this request, or null when it is not the app.\n *\n * On a Twig theme Laravel copies them into the settings' `jitsu.context.extra.headers`,\n * where the SDK reads the app's platform and version from (`salla.config.isMobileApp()`).\n * A React theme asks for its settings from the server, through the API, so the app's\n * headers never reach that call: the request is the only place they are.\n */\nexport function readNativeAppHeaders(headers: Headers): Record<string, string> | null {\n const os = headers.get('s-app-os')?.toLowerCase();\n if (os !== 'ios' && os !== 'android') return null;\n const found: Record<string, string> = {};\n for (const name of NATIVE_APP_HEADERS) {\n const value = headers.get(name);\n if (value) found[name] = value;\n }\n return found;\n}\n","import { queryOptions } from '@tanstack/react-query';\nimport { isHTTPError, isNetworkError, isTimeoutError } from 'ky';\nimport { api, getActiveScope, STORE_IDENTIFIER_HEADER } from './client';\nimport { devSettingsFetchedAt } from './dev-settings-cache';\nimport { SettingsError } from '../utils/errors';\nimport type { Store, Theme, Language, JitsuConfig, MaintenanceDetails } from '../types';\nimport { getTwilightContext } from '../twilight/context';\nimport { resolveStoreIdentifier } from '../utils/store-identity';\nimport { extractScopeFromUrl, parseStoreId } from '../utils/cookies';\nimport { readPageSearch } from '../utils/language-cookie';\nimport { requestedThemeVersionId } from '../utils/theme-version';\nimport { NATIVE_APP_HEADERS } from '../utils/native-app-headers';\nimport { isNotLaunchedNotice } from '../utils/maintenance';\n\nexport { resolveStoreIdentifier };\n\nconst DEFAULT_INCLUDE_ITEMS = [\n 'store',\n 'settings',\n 'theme',\n 'theme_settings',\n 'external_services',\n 'currencies',\n 'languages',\n 'payments',\n 'product_widgets',\n 'rating',\n 'ratings',\n 'user',\n];\n\n/** Twig's `salla.init({ user })` object; the endpoint ignores the token, so always the guest. */\nexport interface SettingsUser {\n type: 'guest' | 'user';\n id?: number | string | null;\n language_code?: string;\n currency_code?: string;\n country_code?: string;\n [key: string]: unknown;\n}\n\n/**\n * Raw API response for settings endpoint.\n * Languages come as object: { \"AR\": { code, name, ... }, \"EN\": {...} }\n */\ninterface SettingsApiResponse {\n store?: Store;\n theme?: Theme;\n languages?: Record<string, Language>;\n currencies?: Record<\n string,\n { code: string; name: string; symbol: string; amount: number; country_code: string }\n >;\n external_services?: Record<string, unknown>;\n headers?: Record<string, unknown>;\n login?: { url: string; turnstile_site_key: string };\n affiliate?: { utm_url: string; cta_enabled: boolean };\n debug?: boolean;\n trace_console?: boolean;\n policy_url?: string;\n user?: SettingsUser;\n swoole?: string[];\n jitsu?: JitsuConfig;\n maintenance?: boolean;\n maintenance_details?: MaintenanceDetails;\n}\n\n/**\n * Central settings context - single source of truth for all API data.\n * Contains everything from the settings endpoint response after processing.\n */\nexport interface StoreContext {\n store?: Store;\n theme?: Theme;\n /** Languages as array after conversion from API object format */\n languages?: Language[];\n currencies?: Record<\n string,\n { code: string; name: string; symbol: string; amount: number; country_code: string }\n >;\n external_services?: Record<string, unknown>;\n headers?: Record<string, unknown>;\n login?: { url: string; turnstile_site_key: string };\n affiliate?: { utm_url: string; cta_enabled: boolean };\n debug?: boolean;\n trace_console?: boolean; // todo:: remove it\n policy_url?: string;\n user?: SettingsUser;\n /** API paths the SDK sends with `s-store-api-version: swoole` */\n swoole?: string[];\n /** Where the SDK's analytics send events, and which ones; without it the SDK tracks nothing. */\n jitsu?: JitsuConfig;\n /**\n * The store is closed: by the merchant from the dashboard, by the platform, or\n * for the selected market only. The engine then renders the maintenance page\n * to everyone but the merchant; see `rootBeforeLoad`.\n */\n maintenance?: boolean;\n /** What the maintenance page says; sent beside `maintenance`. */\n maintenance_details?: MaintenanceDetails;\n /**\n * `false` while the store has not launched yet: `maintenance` is then `true` and the\n * engine's maintenance page says the store is launching soon. Absent otherwise. Not\n * from the API: read off `maintenance_details` by `store.settings`, since the\n * backend sends the merchant's \"finish launching\" notice there for every visitor,\n * which is not for a customer's eyes.\n */\n launched?: false;\n /**\n * The scope these settings were requested with; absent when none was. Not from\n * the API: stamped by `store.settings`, so `resolveThemeVersionId` can tell\n * whether the version they name still answers the scope that is active now.\n */\n requestedScopeId?: string;\n /** Which answer of the API these settings are; see {@link SettingsAnswer}. */\n answer?: SettingsAnswer;\n /**\n * When the dev server fetched these settings from the API (epoch ms). It reuses\n * them for a while (see `dev-settings-cache.ts`) and the theme editor says how old\n * they are. Only on a dev server render; absent everywhere else.\n */\n devFetchedAt?: number;\n}\n\n/**\n * Which answer of the settings API a set of settings came from, read off the\n * response rather than the body: the API's request id, the Store's trace, and\n * whether Cloudflare served it from its cache and how old it was. A decision the\n * settings drive for every visitor alike (the maintenance page) can then be\n * traced to the exact request the backend logged, or to a cached copy of it.\n */\nexport interface SettingsAnswer {\n requestId?: string;\n traceId?: string;\n cacheStatus?: string;\n age?: string;\n}\n\nconst ANSWER_HEADERS: Record<keyof SettingsAnswer, string> = {\n requestId: 's-request-id',\n traceId: 'x-trace-id',\n cacheStatus: 'cf-cache-status',\n age: 'age',\n};\n\nfunction settingsAnswerOf(headers: Headers | undefined): SettingsAnswer | undefined {\n if (!headers) return undefined;\n const answer: SettingsAnswer = {};\n for (const [field, name] of Object.entries(ANSWER_HEADERS) as [keyof SettingsAnswer, string][]) {\n const value = headers.get(name);\n if (value) answer[field] = value;\n }\n return Object.keys(answer).length ? answer : undefined;\n}\n\n/**\n * Converts languages object from API to array format.\n * API returns: { \"AR\": { code, name, ... }, \"EN\": { ... } }\n * We need: [{ code, name, ... }, { code, name, ... }]\n * todo:: return the languages as object from the APIs to avoid this\n */\nfunction languagesToArray(languages?: Record<string, Language>): Language[] | undefined {\n if (!languages) return undefined;\n // The SDK's localization modal reads `lang.iso_code` (not `code`) when a language is\n // selected — without it the switch navigates to `/undefined/...`.\n return Object.values(languages).map((lang) => ({ iso_code: lang.code, ...lang }));\n}\n\n/**\n * The settings' analytics context with the native app's headers in it, as Laravel\n * writes it for a Twig theme: the SDK reads the app's platform and version from there.\n * The API answers a server-side call with the engine's own headers, never the app's.\n */\nfunction withNativeAppHeaders(jitsu?: JitsuConfig): JitsuConfig | undefined {\n if (!jitsu || typeof window !== 'undefined') return jitsu;\n let appHeaders: Record<string, string> | null = null;\n try {\n appHeaders = getTwilightContext().nativeAppHeaders;\n } catch {\n return jitsu;\n }\n if (!appHeaders) return jitsu;\n const extra = jitsu.context?.extra;\n // The engine's own app headers go, so an app that sends no version doesn't get the engine's.\n const headers = { ...extra?.headers };\n for (const name of NATIVE_APP_HEADERS) delete headers[name];\n return {\n ...jitsu,\n context: {\n ...jitsu.context,\n extra: { ...extra, headers: { ...headers, ...appHeaders } },\n },\n };\n}\n\nconst SETTINGS_TIMEOUT_MS = 5000;\n\n/**\n * Whether the page's own address switches market (`?scope=`).\n *\n * Only then does the settings request name the scope in its query string. The API\n * reads `?scope=` as a switch and lets it override the market a market's own domain\n * is pinned to, which the `s-scope-id` header never does. Sent on every request, a\n * market remembered from another visit would win over the host the shopper is on: the\n * settings, and the SDK seeded from them, would answer for that market while every\n * call without the parameter (the cart, among them) answers for the host's, and a\n * guest's cart created in one is refused by the other (TD-17588).\n */\nfunction pageSwitchesScope(): boolean {\n return extractScopeFromUrl(`http://page.invalid/${readPageSearch()}`) !== null;\n}\n\nasync function requestSettings(identifier: string): Promise<StoreContext> {\n const includeParams = DEFAULT_INCLUDE_ITEMS.map((i) => `include[]=${i}`).join('&');\n const scope = getActiveScope();\n const params =\n scope != null && pageSwitchesScope() ? `${includeParams}&scope=${scope.id}` : includeParams;\n\n const request = api\n // Sent explicitly rather than left to the client's own resolution, so\n // the identifier this function checked is the identifier that travels.\n // They agree today; a caller passing one and being answered about\n // another is the failure this makes impossible rather than unlikely.\n .get(`store/settings?${params}`, {\n timeout: SETTINGS_TIMEOUT_MS,\n headers: { [STORE_IDENTIFIER_HEADER]: identifier },\n });\n const json = await request.json<{ data?: SettingsApiResponse }>();\n // The same response, already settled; only its headers are read.\n const headers = (await request)?.headers;\n const answer = settingsAnswerOf(headers);\n const devFetchedAt = devSettingsFetchedAt(headers);\n\n const data = json?.data;\n if (!data) {\n throw new SettingsError(\n `The Salla API answered the settings request for store \"${identifier}\" without settings.`,\n { reason: 'empty' }\n );\n }\n\n // Convert languages from object to array\n const languages = languagesToArray(data.languages);\n\n return {\n store: data.store,\n theme: data.theme,\n languages,\n currencies: data.currencies,\n external_services: data.external_services,\n headers: data.headers,\n login: data.login,\n affiliate: data.affiliate,\n policy_url: data.policy_url,\n user: data.user,\n swoole: data.swoole,\n jitsu: withNativeAppHeaders(data.jitsu),\n maintenance: data.maintenance,\n maintenance_details: data.maintenance_details,\n ...(data.maintenance === true &&\n isNotLaunchedNotice(data.maintenance_details) && { launched: false as const }),\n ...(scope && { requestedScopeId: scope.id }),\n ...(answer && { answer }),\n ...(devFetchedAt && { devFetchedAt }),\n };\n}\n\n/** The message the API put in an error body, `{ error: { message } }`, when it sent one. */\nfunction apiErrorMessage(data: unknown): string | undefined {\n const message = (data as { error?: { message?: unknown } } | undefined)?.error?.message;\n return typeof message === 'string' && message.length > 0 && message.length <= 200\n ? message\n : undefined;\n}\n\n/**\n * What core's `CurrentStoreMiddleware` answers, with a 422, when no store has the\n * username or domain it was given (or the store's status is `deleted`). The lookup is\n * `loadUseUsernameOrDomain`, the same one Twig's `checkUsername` turns into its 410.\n * The literal is not translated: it reads the same whatever language was asked for.\n */\nconst STORE_NOT_FOUND_MESSAGE = 'المتجر غير موجود';\n\n/**\n * Whether the API answered that no store has this identifier. A numeric identifier\n * is looked up with `findOrFail`, which Store's exception handler answers with a 410;\n * a username or domain gets {@link STORE_NOT_FOUND_MESSAGE}. A 410 for a username is\n * not read as one: nothing on that path answers it, and a store that does exist must\n * never be told it does not.\n */\nfunction isStoreNotFound(identifier: string, status: number, said: string | undefined): boolean {\n if (status === 410) return parseStoreId(identifier) !== null;\n return status === 422 && said === STORE_NOT_FOUND_MESSAGE;\n}\n\n/**\n * Names what went wrong, because the page, the server log and Sentry all carry\n * this message. Every failure used to read \"Make sure VITE_STORE_DOMAIN is set\",\n * a local-development variable no deployed theme has, so a slow API looked like\n * a misconfigured theme.\n */\nfunction describeSettingsFailure(identifier: string, error: unknown): SettingsError {\n if (error instanceof SettingsError) return error;\n const request = `the settings request for store \"${identifier}\"`;\n if (isTimeoutError(error)) {\n return new SettingsError(\n `The Salla API did not answer ${request} within ${SETTINGS_TIMEOUT_MS} ms.`,\n { reason: 'timeout' }\n );\n }\n if (isHTTPError(error)) {\n const { status } = error.response;\n const said = apiErrorMessage(error.data);\n return new SettingsError(\n `The Salla API answered ${request} with HTTP ${status}${said ? `: ${said}` : ''}.`,\n { reason: isStoreNotFound(identifier, status, said) ? 'not-found' : 'http', status }\n );\n }\n if (isNetworkError(error)) {\n return new SettingsError(`The Salla API could not be reached for ${request}.`, {\n reason: 'network',\n });\n }\n const detail = error instanceof Error ? `: ${error.message}` : '';\n return new SettingsError(`The settings request for store \"${identifier}\" failed${detail}.`);\n}\n\n/**\n * The settings, or a {@link SettingsError} that says why there are none. The\n * query throws it so the root route can say why the store did not load;\n * `store.settings` keeps answering `null` for its own callers.\n */\nasync function fetchSettings(storeIdentifier?: string): Promise<StoreContext> {\n const identifier = storeIdentifier ?? resolveStoreIdentifier();\n\n if (!identifier) {\n const error = new SettingsError(\n 'No store is named for this request: add `?storeId=` on the preview host, or set VITE_STORE_DOMAIN in local development.',\n { reason: 'no-store' }\n );\n console.warn('[store.settings]', error.message);\n throw error;\n }\n\n try {\n return await requestSettings(identifier);\n } catch (cause) {\n const error = describeSettingsFailure(identifier, cause);\n console.error('[store.settings]', error.message, ...(cause === error ? [] : [cause]));\n throw error;\n }\n}\n\nexport const store = {\n settings: async (storeIdentifier?: string): Promise<StoreContext | null> => {\n try {\n return await fetchSettings(storeIdentifier);\n } catch {\n // Already logged, with the reason.\n return null;\n }\n },\n\n queries: {\n settings: (storeIdentifier?: string) =>\n queryOptions<StoreContext | null>({\n queryKey: [\n 'store',\n 'settings',\n storeIdentifier,\n getTwilightContext().locale,\n getActiveScope(),\n // Two versions of one store's settings are two different answers, and\n // this is the query whose answer decides what every other call is\n // pinned to. `requestedThemeVersionId` rather than the resolved one:\n // the resolved value falls back to what these settings report, so it\n // is not knowable until after this query has run — the key would be\n // one thing on the server and another on the client, and the hydrated\n // page would refetch the settings it was just handed.\n requestedThemeVersionId(),\n ],\n // Throws rather than resolving `null`, so the failure keeps its reason.\n queryFn: () => fetchSettings(storeIdentifier),\n // A null never retried, and the root route waits on this: the router's\n // default `retry: 1` would sit through the timeout twice.\n retry: 0,\n }),\n },\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/language-cookie.ts","../src/utils/native-app-headers.ts","../src/api/store.ts"],"names":[],"mappings":";;;;;;;;;;AAaA,IAAM,sBAAA,GAAyB,kBAAA,EAAmB,CAC/C,MAAA,CAAO,MAAqB;AAC3B,EAAA,IAAI;AACF,IAAA,OAAO,gBAAA,CAAiB,QAAQ,CAAA,IAAK,IAAA;AAAA,EACvC,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF,CAAC,CAAA,CACA,MAAA,CAAO,MAAqB,IAAI,CAAA;AAEnC,IAAM,yBAAA,GAA4B,kBAAA,EAAmB,CAClD,MAAA,CAAO,CAAC,IAAA,KAAuB;AAC9B,EAAA,IAAI;AACF,IAAA,SAAA,CAAU,sBAAsB,IAAA,EAAM;AAAA,MACpC,IAAA,EAAM,GAAA;AAAA,MACN,MAAA,EAAQ,uBAAA;AAAA,MACR,QAAA,EAAU;AAAA,KACX,CAAA;AAAA,EACH,CAAA,CAAA,MAAQ;AAAA,EAER;AACF,CAAC,CAAA,CACA,OAAO,MAAY;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,uBAAA,CAAwB,UAAA,EAAY,KAAK,CAAA;AACvD,IAAA,OAAA,CAAQ,KAAA,CAAM,kBAAA,EAAoB,KAAA,CAAM,OAAA,EAAS,GAAI,KAAA,KAAU,KAAA,GAAQ,EAAC,GAAI,CAAC,KAAK,CAAE,CAAA;AACpF,IAAA,MAAM,KAAA;AAAA,EACR;AACF;AAEO,IAAM,KAAA,GAAQ;AAAA,EACnB,QAAA,EAAU,OAAO,eAAA,KAA2D;AAC1E,IAAA,IAAI;AACF,MAAA,OAAO,MAAM,cAAc,eAAe,CAAA;AAAA,IAC5C,CAAA,CAAA,MAAQ;AAEN,MAAA,OAAO,IAAA;AAAA,IACT;AAAA,EACF,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,QAAA,EAAU,CAAC,eAAA,KACT,YAAA,CAAkC;AAAA,MAChC,QAAA,EAAU;AAAA,QACR,OAAA;AAAA,QACA,UAAA;AAAA,QACA,eAAA;AAAA,QACA,oBAAmB,CAAE,MAAA;AAAA,QACrB,cAAA,EAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAQf,uBAAA;AAAwB,OAC1B;AAAA;AAAA,MAEA,OAAA,EAAS,MAAM,aAAA,CAAc,eAAe,CAAA;AAAA;AAAA;AAAA,MAG5C,KAAA,EAAO;AAAA,KACR;AAAA;AAEP","file":"chunk-TQQN5AE2.js","sourcesContent":["/**\n * @fileoverview Reading and writing the `s-lang` cookie, on the server and in the browser.\n *\n * The server reads it from the request the framework is handling and writes it to that\n * request's response. The server-only import is stripped from the client bundle by\n * `createIsomorphicFn`, as in `routes/root/beforeLoad.ts`. The browser uses `document.cookie`.\n * Either side outside a request (a prerender, a test) has nothing to read or write and says so\n * quietly.\n */\nimport { createIsomorphicFn } from '@tanstack/react-start';\nimport { getRequestHeader, getRequestUrl, setCookie } from '@tanstack/react-start/server';\nimport { LANGUAGE_COOKIE_MAX_AGE, LANGUAGE_COOKIE_NAME } from './cookies';\n\nconst readServerCookieHeader = createIsomorphicFn()\n .server((): string | null => {\n try {\n return getRequestHeader('cookie') ?? null;\n } catch {\n return null;\n }\n })\n .client((): string | null => null);\n\nconst writeServerLanguageCookie = createIsomorphicFn()\n .server((code: string): void => {\n try {\n setCookie(LANGUAGE_COOKIE_NAME, code, {\n path: '/',\n maxAge: LANGUAGE_COOKIE_MAX_AGE,\n sameSite: 'lax',\n });\n } catch {\n // Outside a request: there is no response to write to.\n }\n })\n .client((): void => {});\n\nconst readServerSearch = createIsomorphicFn()\n .server((): string => {\n try {\n return getRequestUrl().search;\n } catch {\n return '';\n }\n })\n .client((): string => '');\n\n/**\n * The query string of the page being rendered (`?lang=en`, or `''`): the request's on the\n * server, the address bar's in the browser, so both sides read the same one.\n */\nexport function readPageSearch(): string {\n return readServerSearch() || (typeof window !== 'undefined' ? window.location.search : '');\n}\n\n/** The `Cookie` header of the request being handled, or `document.cookie` in the browser. */\nexport function readCookieHeader(): string | null {\n return readServerCookieHeader() ?? (typeof document !== 'undefined' ? document.cookie : null);\n}\n\n/** Remembers `code` as the visitor's language for every store on this host. */\nexport function persistLanguageCookie(code: string): void {\n writeServerLanguageCookie(code);\n if (typeof document !== 'undefined') {\n document.cookie = `${LANGUAGE_COOKIE_NAME}=${encodeURIComponent(code)}; path=/; max-age=${LANGUAGE_COOKIE_MAX_AGE}; SameSite=Lax`;\n }\n}\n","/** The headers the Salla native app sends with every page it loads in its webview. */\nexport const NATIVE_APP_HEADERS = [\n 's-app-os',\n 's-app-version',\n 's-app-full-version',\n 's-app-os-version',\n];\n\n/**\n * The native app's own headers on this request, or null when it is not the app.\n *\n * On a Twig theme Laravel copies them into the settings' `jitsu.context.extra.headers`,\n * where the SDK reads the app's platform and version from (`salla.config.isMobileApp()`).\n * A React theme asks for its settings from the server, through the API, so the app's\n * headers never reach that call: the request is the only place they are.\n */\nexport function readNativeAppHeaders(headers: Headers): Record<string, string> | null {\n const os = headers.get('s-app-os')?.toLowerCase();\n if (os !== 'ios' && os !== 'android') return null;\n const found: Record<string, string> = {};\n for (const name of NATIVE_APP_HEADERS) {\n const value = headers.get(name);\n if (value) found[name] = value;\n }\n return found;\n}\n","import { queryOptions } from '@tanstack/react-query';\nimport { isHTTPError, isNetworkError, isTimeoutError } from 'ky';\nimport { api, getActiveScope, STORE_IDENTIFIER_HEADER } from './client';\nimport { devSettingsFetchedAt } from './dev-settings-cache';\nimport { SettingsError } from '../utils/errors';\nimport type { Store, Theme, Language, JitsuConfig, MaintenanceDetails } from '../types';\nimport { getTwilightContext } from '../twilight/context';\nimport { resolveStoreIdentifier } from '../utils/store-identity';\nimport { extractScopeFromUrl, parseStoreId } from '../utils/cookies';\nimport { readPageSearch } from '../utils/language-cookie';\nimport { requestedThemeVersionId } from '../utils/theme-version';\nimport { NATIVE_APP_HEADERS } from '../utils/native-app-headers';\nimport { isNotLaunchedNotice } from '../utils/maintenance';\n\nexport { resolveStoreIdentifier };\n\nconst DEFAULT_INCLUDE_ITEMS = [\n 'store',\n 'settings',\n 'theme',\n 'theme_settings',\n 'external_services',\n 'currencies',\n 'languages',\n 'payments',\n 'product_widgets',\n 'rating',\n 'ratings',\n 'user',\n];\n\n/** Twig's `salla.init({ user })` object; the endpoint ignores the token, so always the guest. */\nexport interface SettingsUser {\n type: 'guest' | 'user';\n id?: number | string | null;\n language_code?: string;\n currency_code?: string;\n country_code?: string;\n [key: string]: unknown;\n}\n\n/**\n * Raw API response for settings endpoint.\n * Languages come as object: { \"AR\": { code, name, ... }, \"EN\": {...} }\n */\ninterface SettingsApiResponse {\n store?: Store;\n theme?: Theme;\n languages?: Record<string, Language>;\n currencies?: Record<\n string,\n { code: string; name: string; symbol: string; amount: number; country_code: string }\n >;\n external_services?: Record<string, unknown>;\n headers?: Record<string, unknown>;\n login?: { url: string; turnstile_site_key: string };\n affiliate?: { utm_url: string; cta_enabled: boolean };\n debug?: boolean;\n trace_console?: boolean;\n policy_url?: string;\n user?: SettingsUser;\n swoole?: string[];\n jitsu?: JitsuConfig;\n maintenance?: boolean;\n maintenance_details?: MaintenanceDetails;\n}\n\n/**\n * Central settings context - single source of truth for all API data.\n * Contains everything from the settings endpoint response after processing.\n */\nexport interface StoreContext {\n store?: Store;\n theme?: Theme;\n /** Languages as array after conversion from API object format */\n languages?: Language[];\n currencies?: Record<\n string,\n { code: string; name: string; symbol: string; amount: number; country_code: string }\n >;\n external_services?: Record<string, unknown>;\n headers?: Record<string, unknown>;\n login?: { url: string; turnstile_site_key: string };\n affiliate?: { utm_url: string; cta_enabled: boolean };\n debug?: boolean;\n trace_console?: boolean; // todo:: remove it\n policy_url?: string;\n user?: SettingsUser;\n /** API paths the SDK sends with `s-store-api-version: swoole` */\n swoole?: string[];\n /** Where the SDK's analytics send events, and which ones; without it the SDK tracks nothing. */\n jitsu?: JitsuConfig;\n /**\n * The store is closed: by the merchant from the dashboard, by the platform, or\n * for the selected market only. The engine then renders the maintenance page\n * to everyone but the merchant; see `rootBeforeLoad`.\n */\n maintenance?: boolean;\n /** What the maintenance page says; sent beside `maintenance`. */\n maintenance_details?: MaintenanceDetails;\n /**\n * `false` while the store has not launched yet: `maintenance` is then `true` and the\n * engine's maintenance page says the store is launching soon. Absent otherwise. Not\n * from the API: read off `maintenance_details` by `store.settings`, since the\n * backend sends the merchant's \"finish launching\" notice there for every visitor,\n * which is not for a customer's eyes.\n */\n launched?: false;\n /**\n * The scope these settings were requested with; absent when none was. Not from\n * the API: stamped by `store.settings`, so `resolveThemeVersionId` can tell\n * whether the version they name still answers the scope that is active now.\n */\n requestedScopeId?: string;\n /** Which answer of the API these settings are; see {@link SettingsAnswer}. */\n answer?: SettingsAnswer;\n /**\n * When the dev server fetched these settings from the API (epoch ms). It reuses\n * them for a while (see `dev-settings-cache.ts`) and the theme editor says how old\n * they are. Only on a dev server render; absent everywhere else.\n */\n devFetchedAt?: number;\n}\n\n/**\n * Which answer of the settings API a set of settings came from, read off the\n * response rather than the body: the API's request id, the Store's trace, and\n * whether Cloudflare served it from its cache and how old it was. A decision the\n * settings drive for every visitor alike (the maintenance page) can then be\n * traced to the exact request the backend logged, or to a cached copy of it.\n */\nexport interface SettingsAnswer {\n requestId?: string;\n traceId?: string;\n cacheStatus?: string;\n age?: string;\n}\n\nconst ANSWER_HEADERS: Record<keyof SettingsAnswer, string> = {\n requestId: 's-request-id',\n traceId: 'x-trace-id',\n cacheStatus: 'cf-cache-status',\n age: 'age',\n};\n\nfunction settingsAnswerOf(headers: Headers | undefined): SettingsAnswer | undefined {\n if (!headers) return undefined;\n const answer: SettingsAnswer = {};\n for (const [field, name] of Object.entries(ANSWER_HEADERS) as [keyof SettingsAnswer, string][]) {\n const value = headers.get(name);\n if (value) answer[field] = value;\n }\n return Object.keys(answer).length ? answer : undefined;\n}\n\n/**\n * Converts languages object from API to array format.\n * API returns: { \"AR\": { code, name, ... }, \"EN\": { ... } }\n * We need: [{ code, name, ... }, { code, name, ... }]\n * todo:: return the languages as object from the APIs to avoid this\n */\nfunction languagesToArray(languages?: Record<string, Language>): Language[] | undefined {\n if (!languages) return undefined;\n // The SDK's localization modal reads `lang.iso_code` (not `code`) when a language is\n // selected — without it the switch navigates to `/undefined/...`.\n return Object.values(languages).map((lang) => ({ iso_code: lang.code, ...lang }));\n}\n\n/**\n * The settings' analytics context with the native app's headers in it, as Laravel\n * writes it for a Twig theme: the SDK reads the app's platform and version from there.\n * The API answers a server-side call with the engine's own headers, never the app's.\n */\nfunction withNativeAppHeaders(jitsu?: JitsuConfig): JitsuConfig | undefined {\n if (!jitsu || typeof window !== 'undefined') return jitsu;\n let appHeaders: Record<string, string> | null = null;\n try {\n appHeaders = getTwilightContext().nativeAppHeaders;\n } catch {\n return jitsu;\n }\n if (!appHeaders) return jitsu;\n const extra = jitsu.context?.extra;\n // The engine's own app headers go, so an app that sends no version doesn't get the engine's.\n const headers = { ...extra?.headers };\n for (const name of NATIVE_APP_HEADERS) delete headers[name];\n return {\n ...jitsu,\n context: {\n ...jitsu.context,\n extra: { ...extra, headers: { ...headers, ...appHeaders } },\n },\n };\n}\n\nconst SETTINGS_TIMEOUT_MS = 5000;\n\n/**\n * Whether the page's own address switches market (`?scope=`).\n *\n * Only then does the settings request name the scope in its query string. The API\n * reads `?scope=` as a switch and lets it override the market a market's own domain\n * is pinned to, which the `s-scope-id` header never does. Sent on every request, a\n * market remembered from another visit would win over the host the shopper is on: the\n * settings, and the SDK seeded from them, would answer for that market while every\n * call without the parameter (the cart, among them) answers for the host's, and a\n * guest's cart created in one is refused by the other (TD-17588).\n */\nfunction pageSwitchesScope(): boolean {\n return extractScopeFromUrl(`http://page.invalid/${readPageSearch()}`) !== null;\n}\n\nasync function requestSettings(identifier: string): Promise<StoreContext> {\n const includeParams = DEFAULT_INCLUDE_ITEMS.map((i) => `include[]=${i}`).join('&');\n const scope = getActiveScope();\n const params =\n scope != null && pageSwitchesScope() ? `${includeParams}&scope=${scope.id}` : includeParams;\n\n const request = api\n // Sent explicitly rather than left to the client's own resolution, so\n // the identifier this function checked is the identifier that travels.\n // They agree today; a caller passing one and being answered about\n // another is the failure this makes impossible rather than unlikely.\n .get(`store/settings?${params}`, {\n timeout: SETTINGS_TIMEOUT_MS,\n headers: { [STORE_IDENTIFIER_HEADER]: identifier },\n });\n const json = await request.json<{ data?: SettingsApiResponse }>();\n // The same response, already settled; only its headers are read.\n const headers = (await request)?.headers;\n const answer = settingsAnswerOf(headers);\n const devFetchedAt = devSettingsFetchedAt(headers);\n\n const data = json?.data;\n if (!data) {\n throw new SettingsError(\n `The Salla API answered the settings request for store \"${identifier}\" without settings.`,\n { reason: 'empty' }\n );\n }\n\n // Convert languages from object to array\n const languages = languagesToArray(data.languages);\n\n return {\n store: data.store,\n theme: data.theme,\n languages,\n currencies: data.currencies,\n external_services: data.external_services,\n headers: data.headers,\n login: data.login,\n affiliate: data.affiliate,\n policy_url: data.policy_url,\n user: data.user,\n swoole: data.swoole,\n jitsu: withNativeAppHeaders(data.jitsu),\n maintenance: data.maintenance,\n maintenance_details: data.maintenance_details,\n ...(data.maintenance === true &&\n isNotLaunchedNotice(data.maintenance_details) && { launched: false as const }),\n ...(scope && { requestedScopeId: scope.id }),\n ...(answer && { answer }),\n ...(devFetchedAt && { devFetchedAt }),\n };\n}\n\n/** The message the API put in an error body, `{ error: { message } }`, when it sent one. */\nfunction apiErrorMessage(data: unknown): string | undefined {\n const message = (data as { error?: { message?: unknown } } | undefined)?.error?.message;\n return typeof message === 'string' && message.length > 0 && message.length <= 200\n ? message\n : undefined;\n}\n\n/**\n * What core's `CurrentStoreMiddleware` answers, with a 422, when no store has the\n * username or domain it was given (or the store's status is `deleted`). The lookup is\n * `loadUseUsernameOrDomain`, the same one Twig's `checkUsername` turns into its 410.\n * The literal is not translated: it reads the same whatever language was asked for.\n */\nconst STORE_NOT_FOUND_MESSAGE = 'المتجر غير موجود';\n\n/**\n * Whether the API answered that no store has this identifier. A numeric identifier\n * is looked up with `findOrFail`, which Store's exception handler answers with a 410;\n * a username or domain gets {@link STORE_NOT_FOUND_MESSAGE}. A 410 for a username is\n * not read as one: nothing on that path answers it, and a store that does exist must\n * never be told it does not.\n */\nfunction isStoreNotFound(identifier: string, status: number, said: string | undefined): boolean {\n if (status === 410) return parseStoreId(identifier) !== null;\n return status === 422 && said === STORE_NOT_FOUND_MESSAGE;\n}\n\n/**\n * Names what went wrong, because the page, the server log and Sentry all carry\n * this message. Every failure used to read \"Make sure VITE_STORE_DOMAIN is set\",\n * a local-development variable no deployed theme has, so a slow API looked like\n * a misconfigured theme.\n */\nfunction describeSettingsFailure(identifier: string, error: unknown): SettingsError {\n if (error instanceof SettingsError) return error;\n const request = `the settings request for store \"${identifier}\"`;\n if (isTimeoutError(error)) {\n return new SettingsError(\n `The Salla API did not answer ${request} within ${SETTINGS_TIMEOUT_MS} ms.`,\n { reason: 'timeout' }\n );\n }\n if (isHTTPError(error)) {\n const { status } = error.response;\n const said = apiErrorMessage(error.data);\n return new SettingsError(\n `The Salla API answered ${request} with HTTP ${status}${said ? `: ${said}` : ''}.`,\n { reason: isStoreNotFound(identifier, status, said) ? 'not-found' : 'http', status }\n );\n }\n if (isNetworkError(error)) {\n return new SettingsError(`The Salla API could not be reached for ${request}.`, {\n reason: 'network',\n });\n }\n const detail = error instanceof Error ? `: ${error.message}` : '';\n return new SettingsError(`The settings request for store \"${identifier}\" failed${detail}.`);\n}\n\n/**\n * The settings, or a {@link SettingsError} that says why there are none. The\n * query throws it so the root route can say why the store did not load;\n * `store.settings` keeps answering `null` for its own callers.\n */\nasync function fetchSettings(storeIdentifier?: string): Promise<StoreContext> {\n const identifier = storeIdentifier ?? resolveStoreIdentifier();\n\n if (!identifier) {\n const error = new SettingsError(\n 'No store is named for this request: add `?storeId=` on the preview host, or set VITE_STORE_DOMAIN in local development.',\n { reason: 'no-store' }\n );\n console.warn('[store.settings]', error.message);\n throw error;\n }\n\n try {\n return await requestSettings(identifier);\n } catch (cause) {\n const error = describeSettingsFailure(identifier, cause);\n console.error('[store.settings]', error.message, ...(cause === error ? [] : [cause]));\n throw error;\n }\n}\n\nexport const store = {\n settings: async (storeIdentifier?: string): Promise<StoreContext | null> => {\n try {\n return await fetchSettings(storeIdentifier);\n } catch {\n // Already logged, with the reason.\n return null;\n }\n },\n\n queries: {\n settings: (storeIdentifier?: string) =>\n queryOptions<StoreContext | null>({\n queryKey: [\n 'store',\n 'settings',\n storeIdentifier,\n getTwilightContext().locale,\n getActiveScope(),\n // Two versions of one store's settings are two different answers, and\n // this is the query whose answer decides what every other call is\n // pinned to. `requestedThemeVersionId` rather than the resolved one:\n // the resolved value falls back to what these settings report, so it\n // is not knowable until after this query has run — the key would be\n // one thing on the server and another on the client, and the hydrated\n // page would refetch the settings it was just handed.\n requestedThemeVersionId(),\n ],\n // Throws rather than resolving `null`, so the failure keeps its reason.\n queryFn: () => fetchSettings(storeIdentifier),\n // A null never retried, and the root route waits on this: the router's\n // default `retry: 1` would sit through the timeout twice.\n retry: 0,\n }),\n },\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getActiveScope, api } from './chunk-
|
|
1
|
+
import { getActiveScope, api } from './chunk-2DUN6DZK.js';
|
|
2
2
|
import { getTwilightContext } from './chunk-6K34BCUP.js';
|
|
3
3
|
import { queryOptions } from '@tanstack/react-query';
|
|
4
4
|
|
|
@@ -25,5 +25,5 @@ var advertisement = {
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
export { advertisement, advertisementsFor };
|
|
28
|
-
//# sourceMappingURL=chunk-
|
|
29
|
-
//# sourceMappingURL=chunk-
|
|
28
|
+
//# sourceMappingURL=chunk-VDY3VY7S.js.map
|
|
29
|
+
//# sourceMappingURL=chunk-VDY3VY7S.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/advertisement.ts"],"names":[],"mappings":";;;;AAkBO,SAAS,iBAAA,CACd,KACA,QAAA,EACiB;AACjB,EAAA,OAAO,GAAA,CAAI,MAAA;AAAA,IACT,CAAC,EAAA,KACC,KAAA,CAAM,QAAQ,EAAA,CAAG,KAAK,MACrB,EAAA,CAAG,KAAA,CAAM,QAAA,CAAS,KAAK,KAAM,CAAC,CAAC,YAAY,EAAA,CAAG,KAAA,CAAM,SAAS,QAAQ,CAAA;AAAA,GAC1E;AACF;AAEO,IAAM,aAAA,GAAgB;AAAA;AAAA,EAE3B,MAAM,YAAsC;AAE1C,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CACpB,GAAA,CAAI,gBAAA,EAAkB,EAAE,OAAA,EAAS,GAAA,EAAM,CAAA,CACvC,IAAA,EAAiC;AACpC,IAAA,OAAO,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,GAAI,OAAO,EAAC;AAAA,EACvC,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,IAAA,EAAM,MACJ,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,gBAAA,EAAkB,kBAAA,EAAmB,CAAE,QAAQ,EAAE,KAAA,EAAO,cAAA,EAAe,EAAG,CAAA;AAAA,MACrF,OAAA,EAAS,MAAM,aAAA,CAAc,IAAA,EAAK;AAAA,MAClC,SAAA,EAAW,QAAA;AAAA;AAAA,MAEX,KAAA,EAAO;AAAA,KACR;AAAA;AAEP","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/api/advertisement.ts"],"names":[],"mappings":";;;;AAkBO,SAAS,iBAAA,CACd,KACA,QAAA,EACiB;AACjB,EAAA,OAAO,GAAA,CAAI,MAAA;AAAA,IACT,CAAC,EAAA,KACC,KAAA,CAAM,QAAQ,EAAA,CAAG,KAAK,MACrB,EAAA,CAAG,KAAA,CAAM,QAAA,CAAS,KAAK,KAAM,CAAC,CAAC,YAAY,EAAA,CAAG,KAAA,CAAM,SAAS,QAAQ,CAAA;AAAA,GAC1E;AACF;AAEO,IAAM,aAAA,GAAgB;AAAA;AAAA,EAE3B,MAAM,YAAsC;AAE1C,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CACpB,GAAA,CAAI,gBAAA,EAAkB,EAAE,OAAA,EAAS,GAAA,EAAM,CAAA,CACvC,IAAA,EAAiC;AACpC,IAAA,OAAO,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,GAAI,OAAO,EAAC;AAAA,EACvC,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,IAAA,EAAM,MACJ,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,gBAAA,EAAkB,kBAAA,EAAmB,CAAE,QAAQ,EAAE,KAAA,EAAO,cAAA,EAAe,EAAG,CAAA;AAAA,MACrF,OAAA,EAAS,MAAM,aAAA,CAAc,IAAA,EAAK;AAAA,MAClC,SAAA,EAAW,QAAA;AAAA;AAAA,MAEX,KAAA,EAAO;AAAA,KACR;AAAA;AAEP","file":"chunk-VDY3VY7S.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api, getActiveScope } from './client';\nimport { getTwilightContext } from '../twilight/context';\n\n/** A merchant's announcement bar, as `GET advertisements` returns it. */\nexport interface Advertisement {\n id: number;\n title?: string;\n description?: string;\n icon?: string | null;\n url?: string | null;\n target?: string | null;\n colors?: { bg?: string; text?: string };\n /** Page slugs the ad shows on (`salla.config` `page.slug`), or `all`. */\n pages?: string[];\n}\n\n/** The ads a page shows: the rule the API applies to `?page=`, run on the full list. */\nexport function advertisementsFor(\n ads: readonly Advertisement[],\n pageSlug: string | null | undefined\n): Advertisement[] {\n return ads.filter(\n (ad) =>\n Array.isArray(ad.pages) &&\n (ad.pages.includes('all') || (!!pageSlug && ad.pages.includes(pageSlug)))\n );\n}\n\nexport const advertisement = {\n /** Every active ad, unfiltered: one request serves all pages, filtered with `advertisementsFor`. */\n list: async (): Promise<Advertisement[]> => {\n // Short timeout: it is fetched with the store settings on every server render.\n const { data } = await api\n .get('advertisements', { timeout: 3000 })\n .json<{ data?: Advertisement[] }>();\n return Array.isArray(data) ? data : [];\n },\n\n queries: {\n list: () =>\n queryOptions({\n queryKey: ['advertisements', getTwilightContext().locale, { scope: getActiveScope() }],\n queryFn: () => advertisement.list(),\n staleTime: Infinity,\n // Awaited in rootBeforeLoad: a retry would double the 3s budget. `PageAdvertisements` retries.\n retry: 0,\n }),\n },\n};\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RouteId } from './chunk-OUW6WESU.js';
|
|
2
|
-
import { getActiveScope } from './chunk-
|
|
3
|
-
import { openNativeBrowser } from './chunk-
|
|
4
|
-
import { withoutStoreUrlBase, extractScopeFromUrl } from './chunk-
|
|
2
|
+
import { getActiveScope } from './chunk-2DUN6DZK.js';
|
|
3
|
+
import { openNativeBrowser } from './chunk-6TFM3UTF.js';
|
|
4
|
+
import { withoutStoreUrlBase, extractScopeFromUrl } from './chunk-T2752RH7.js';
|
|
5
5
|
import { subscribeTwilight, getTwilightContext } from './chunk-6K34BCUP.js';
|
|
6
6
|
import { SUPPORTED_LOCALES } from './chunk-T72DAX7R.js';
|
|
7
7
|
import { useTwilight } from './chunk-DF6FBKDN.js';
|
|
@@ -330,5 +330,5 @@ function useNavigationInterceptor(navigate, storeUrl, username) {
|
|
|
330
330
|
}
|
|
331
331
|
|
|
332
332
|
export { NavigationInterceptor, NavigationProvider, NotFoundError, RedirectError, UnauthorizedError, configureNavigation, defaultNavigate, isMissingResource, notFound, orThrow, orUnauthorized, redirect, resolveRelativePath, responseStatusOf, unauthorized, useIsBlog, useIsBrands, useIsCart, useIsCustomer, useIsHome, useIsProduct, useIsSearch, useLocation, useNavigate, useRouteId };
|
|
333
|
-
//# sourceMappingURL=chunk-
|
|
334
|
-
//# sourceMappingURL=chunk-
|
|
333
|
+
//# sourceMappingURL=chunk-VEVFVWF3.js.map
|
|
334
|
+
//# sourceMappingURL=chunk-VEVFVWF3.js.map
|