@salla.sa/twilight-theme-engine 1.0.59 → 1.0.61
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-IFK5P6XK.js → AddToCartForm-RAQX7VHU.js} +3 -3
- package/dist/{AddToCartForm-IFK5P6XK.js.map → AddToCartForm-RAQX7VHU.js.map} +1 -1
- package/dist/{BlogAuthorPage-KA3EWFJC.js → BlogAuthorPage-HV6JUJNL.js} +17 -16
- package/dist/BlogAuthorPage-HV6JUJNL.js.map +1 -0
- package/dist/{BlogCategoryPage-EWFNGPTS.js → BlogCategoryPage-ATPIVUAL.js} +17 -16
- package/dist/BlogCategoryPage-ATPIVUAL.js.map +1 -0
- package/dist/{BlogPage-E3CN2WJL.js → BlogPage-6IIOSB45.js} +15 -14
- package/dist/BlogPage-6IIOSB45.js.map +1 -0
- package/dist/{BlogSinglePage-Z4GIRBWI.js → BlogSinglePage-DV3XYB26.js} +15 -14
- package/dist/BlogSinglePage-DV3XYB26.js.map +1 -0
- package/dist/{BlogTagPage-4D6GMTHN.js → BlogTagPage-RVJIXERD.js} +17 -16
- package/dist/BlogTagPage-RVJIXERD.js.map +1 -0
- package/dist/BrandsPage-RQXP67LV.js +187 -0
- package/dist/BrandsPage-RQXP67LV.js.map +1 -0
- package/dist/{Breadcrumb-HZVWJZC4.js → Breadcrumb-NXXVZJJD.js} +15 -14
- package/dist/Breadcrumb-NXXVZJJD.js.map +1 -0
- package/dist/{CartItem-OBF3TBDK.js → CartItem-XRWTSJB5.js} +15 -14
- package/dist/CartItem-XRWTSJB5.js.map +1 -0
- package/dist/{CartSummary-GHMZ5LAL.js → CartSummary-F6BY5APF.js} +15 -14
- package/dist/CartSummary-F6BY5APF.js.map +1 -0
- package/dist/{Copyright-XLIZFWVM.js → Copyright-TEDF6HMC.js} +3 -3
- package/dist/{Copyright-XLIZFWVM.js.map → Copyright-TEDF6HMC.js.map} +1 -1
- package/dist/{CustomerLayout-JG4GOVSO.js → CustomerLayout-T5BSTU6T.js} +15 -14
- package/dist/CustomerLayout-T5BSTU6T.js.map +1 -0
- package/dist/{Footer-FV7ZXLY4.js → Footer-IRX2WAEF.js} +15 -14
- package/dist/{Footer-FV7ZXLY4.js.map → Footer-IRX2WAEF.js.map} +1 -1
- package/dist/{Header-WQ675B65.js → Header-HQKDTZSI.js} +7 -7
- package/dist/{Header-WQ675B65.js.map → Header-HQKDTZSI.js.map} +1 -1
- package/dist/{LoyaltyPage-SJUUOW3V.js → LoyaltyPage-AIUDZLT7.js} +16 -15
- package/dist/LoyaltyPage-AIUDZLT7.js.map +1 -0
- package/dist/{MainMenu-SH3YM2CA.js → MainMenu-4ZPVIJCN.js} +9 -8
- package/dist/MainMenu-4ZPVIJCN.js.map +1 -0
- package/dist/{MasterLayout-VJQDAL7N.js → MasterLayout-G3MVZLYZ.js} +15 -14
- package/dist/{MasterLayout-VJQDAL7N.js.map → MasterLayout-G3MVZLYZ.js.map} +1 -1
- package/dist/{MobileMenu-JGO33EPX.js → MobileMenu-A5DBTPS7.js} +16 -15
- package/dist/MobileMenu-A5DBTPS7.js.map +1 -0
- package/dist/{NotificationsPage-DBXZUQW6.js → NotificationsPage-T2O67MLD.js} +15 -14
- package/dist/NotificationsPage-T2O67MLD.js.map +1 -0
- package/dist/{OrderSinglePage-2ME6HVFH.js → OrderSinglePage-4W4JZX7I.js} +16 -15
- package/dist/OrderSinglePage-4W4JZX7I.js.map +1 -0
- package/dist/{OrdersPage-6XMYJQAB.js → OrdersPage-DYKFBMRC.js} +16 -15
- package/dist/OrdersPage-DYKFBMRC.js.map +1 -0
- package/dist/{PageSingle-ATWHQBS7.js → PageSingle-6U6GPMXJ.js} +3 -3
- package/dist/{PageSingle-ATWHQBS7.js.map → PageSingle-6U6GPMXJ.js.map} +1 -1
- package/dist/{ProductDetails-DH2MRJQ2.js → ProductDetails-OWSIL357.js} +3 -3
- package/dist/{ProductDetails-DH2MRJQ2.js.map → ProductDetails-OWSIL357.js.map} +1 -1
- package/dist/{ProfilePage-FGJHE5AD.js → ProfilePage-LLCIJHAI.js} +15 -14
- package/dist/ProfilePage-LLCIJHAI.js.map +1 -0
- package/dist/{SeoCartWidget-ALMYKXRG.js → SeoCartWidget-ZL3FTBWK.js} +15 -14
- package/dist/SeoCartWidget-ZL3FTBWK.js.map +1 -0
- package/dist/{SettingsPage-K5EM4BLS.js → SettingsPage-2XU5IF4A.js} +15 -14
- package/dist/SettingsPage-2XU5IF4A.js.map +1 -0
- package/dist/{StoreClosedNotification-3NKLFBKL.js → StoreClosedNotification-CNJI2Q26.js} +16 -15
- package/dist/{StoreClosedNotification-3NKLFBKL.js.map → StoreClosedNotification-CNJI2Q26.js.map} +1 -1
- package/dist/{TestimonialsPage-UBRVYDQW.js → TestimonialsPage-QYPLMNWL.js} +3 -3
- package/dist/{TestimonialsPage-UBRVYDQW.js.map → TestimonialsPage-QYPLMNWL.js.map} +1 -1
- package/dist/{ThankYouPage-WPR576XD.js → ThankYouPage-WG3CM5JP.js} +15 -14
- package/dist/ThankYouPage-WG3CM5JP.js.map +1 -0
- package/dist/{WalletPage-ZMTV7GVF.js → WalletPage-J7CH22JM.js} +16 -15
- package/dist/WalletPage-J7CH22JM.js.map +1 -0
- package/dist/{WishlistPage-BRB7RZEF.js → WishlistPage-ZXWYB56R.js} +17 -16
- package/dist/WishlistPage-ZXWYB56R.js.map +1 -0
- package/dist/api/apps.js +6 -5
- package/dist/api/brands.d.ts +6 -5
- package/dist/api/brands.d.ts.map +1 -1
- package/dist/api/brands.js +7 -6
- package/dist/api/cart.js +7 -6
- package/dist/api/category.js +7 -6
- package/dist/api/client.js +5 -4
- package/dist/api/home.js +6 -5
- package/dist/api/loyalty.js +7 -6
- package/dist/api/menu.js +6 -5
- package/dist/api/messages.d.ts +58 -0
- package/dist/api/messages.d.ts.map +1 -0
- package/dist/api/notification.js +6 -5
- package/dist/api/order.js +7 -6
- package/dist/api/page.js +7 -6
- package/dist/api/product.js +7 -6
- package/dist/api/profile.js +5 -4
- package/dist/api/profile.js.map +1 -1
- package/dist/api/store.js +6 -5
- package/dist/api/translations.d.ts +7 -2
- package/dist/api/translations.d.ts.map +1 -1
- package/dist/api/translations.js +6 -5
- package/dist/api/user.js +6 -5
- package/dist/api/wishlist.js +8 -7
- package/dist/{chunk-B3Z7WNO5.js → chunk-2U3PUO3V.js} +18 -16
- package/dist/chunk-2U3PUO3V.js.map +1 -0
- package/dist/{chunk-POATRFUM.js → chunk-2XGQSJKH.js} +3 -3
- package/dist/{chunk-POATRFUM.js.map → chunk-2XGQSJKH.js.map} +1 -1
- package/dist/{chunk-ODNUSQLR.js → chunk-3ITQB3PY.js} +4 -4
- package/dist/{chunk-ODNUSQLR.js.map → chunk-3ITQB3PY.js.map} +1 -1
- package/dist/{chunk-G2UPOKZZ.js → chunk-3YVAYIM4.js} +6 -6
- package/dist/{chunk-G2UPOKZZ.js.map → chunk-3YVAYIM4.js.map} +1 -1
- package/dist/{chunk-RA6FYDRQ.js → chunk-4DHLIY6V.js} +4 -4
- package/dist/{chunk-RA6FYDRQ.js.map → chunk-4DHLIY6V.js.map} +1 -1
- package/dist/{chunk-WD7HOPT5.js → chunk-5X2UFNKY.js} +3 -3
- package/dist/{chunk-WD7HOPT5.js.map → chunk-5X2UFNKY.js.map} +1 -1
- package/dist/{chunk-GJXCHLKY.js → chunk-5ZR2HKZ7.js} +3 -3
- package/dist/{chunk-GJXCHLKY.js.map → chunk-5ZR2HKZ7.js.map} +1 -1
- package/dist/{chunk-5EPR726Z.js → chunk-6IDCWH5K.js} +10 -7
- package/dist/chunk-6IDCWH5K.js.map +1 -0
- package/dist/{chunk-JR2NYBZS.js → chunk-7OIP65ER.js} +5 -5
- package/dist/{chunk-JR2NYBZS.js.map → chunk-7OIP65ER.js.map} +1 -1
- package/dist/{chunk-IUZ2IZFK.js → chunk-EAZGFREP.js} +3 -3
- package/dist/{chunk-IUZ2IZFK.js.map → chunk-EAZGFREP.js.map} +1 -1
- package/dist/{chunk-MFL6R2WL.js → chunk-FUIPNVQY.js} +6 -6
- package/dist/{chunk-MFL6R2WL.js.map → chunk-FUIPNVQY.js.map} +1 -1
- package/dist/{chunk-K3WTFB6A.js → chunk-GUGZ4CEG.js} +4 -4
- package/dist/{chunk-K3WTFB6A.js.map → chunk-GUGZ4CEG.js.map} +1 -1
- package/dist/{chunk-SDXKGWMC.js → chunk-IZFZLJHD.js} +5 -5
- package/dist/{chunk-SDXKGWMC.js.map → chunk-IZFZLJHD.js.map} +1 -1
- package/dist/{chunk-UIC4FUJM.js → chunk-JVGZDLFP.js} +4 -4
- package/dist/{chunk-UIC4FUJM.js.map → chunk-JVGZDLFP.js.map} +1 -1
- package/dist/{chunk-JNCLDK5D.js → chunk-LCJW7JKZ.js} +5 -5
- package/dist/{chunk-JNCLDK5D.js.map → chunk-LCJW7JKZ.js.map} +1 -1
- package/dist/{chunk-YDU4K4M7.js → chunk-N2S25NXP.js} +76 -12
- package/dist/chunk-N2S25NXP.js.map +1 -0
- package/dist/{chunk-55NGYH3V.js → chunk-N4THXNXA.js} +29 -23
- package/dist/chunk-N4THXNXA.js.map +1 -0
- package/dist/{chunk-WOFJ3WBJ.js → chunk-NFTOMTTI.js} +4 -4
- package/dist/{chunk-WOFJ3WBJ.js.map → chunk-NFTOMTTI.js.map} +1 -1
- package/dist/{chunk-PU6G2UIX.js → chunk-NHKP5XIG.js} +4 -4
- package/dist/{chunk-PU6G2UIX.js.map → chunk-NHKP5XIG.js.map} +1 -1
- package/dist/{chunk-JNB2WC5Z.js → chunk-NQVJ7NJ6.js} +3 -3
- package/dist/{chunk-JNB2WC5Z.js.map → chunk-NQVJ7NJ6.js.map} +1 -1
- package/dist/{chunk-AEQ6NRTE.js → chunk-OET4G4XC.js} +3 -3
- package/dist/{chunk-AEQ6NRTE.js.map → chunk-OET4G4XC.js.map} +1 -1
- package/dist/{chunk-POLSCD5O.js → chunk-P3OPJL6I.js} +6 -5
- package/dist/chunk-P3OPJL6I.js.map +1 -0
- package/dist/{chunk-B3EFOE57.js → chunk-PK7EU5TM.js} +2 -2
- package/dist/chunk-PK7EU5TM.js.map +1 -0
- package/dist/{chunk-SHHF6XXL.js → chunk-Q3COPV5Z.js} +31 -34
- package/dist/chunk-Q3COPV5Z.js.map +1 -0
- package/dist/{chunk-RL4VZU3P.js → chunk-RJAVZBUK.js} +3 -3
- package/dist/{chunk-RL4VZU3P.js.map → chunk-RJAVZBUK.js.map} +1 -1
- package/dist/{chunk-XTMHHLNK.js → chunk-SR4OTLTJ.js} +23 -5
- package/dist/chunk-SR4OTLTJ.js.map +1 -0
- package/dist/{chunk-JVKDYZMW.js → chunk-TDZSHACC.js} +30 -5
- package/dist/chunk-TDZSHACC.js.map +1 -0
- package/dist/{chunk-JMBO6VHQ.js → chunk-TLAEW7TB.js} +3 -3
- package/dist/{chunk-JMBO6VHQ.js.map → chunk-TLAEW7TB.js.map} +1 -1
- package/dist/{chunk-XJDQHKV6.js → chunk-TLO2M5TJ.js} +5 -5
- package/dist/{chunk-XJDQHKV6.js.map → chunk-TLO2M5TJ.js.map} +1 -1
- package/dist/{chunk-UFOSIY3P.js → chunk-TTMYT3RB.js} +4 -4
- package/dist/{chunk-UFOSIY3P.js.map → chunk-TTMYT3RB.js.map} +1 -1
- package/dist/{chunk-RLNBEDA4.js → chunk-TYLKNVQA.js} +5 -25
- package/dist/chunk-TYLKNVQA.js.map +1 -0
- package/dist/{chunk-MJGW6YZQ.js → chunk-UIOLSYKV.js} +3 -3
- package/dist/{chunk-MJGW6YZQ.js.map → chunk-UIOLSYKV.js.map} +1 -1
- package/dist/{chunk-G5ZVKWD7.js → chunk-UZKTK6YV.js} +4 -4
- package/dist/{chunk-G5ZVKWD7.js.map → chunk-UZKTK6YV.js.map} +1 -1
- package/dist/{chunk-232SREMP.js → chunk-VJHDE6UT.js} +4 -4
- package/dist/{chunk-232SREMP.js.map → chunk-VJHDE6UT.js.map} +1 -1
- package/dist/{chunk-35B7ACNO.js → chunk-VSJLPWFI.js} +4 -4
- package/dist/{chunk-35B7ACNO.js.map → chunk-VSJLPWFI.js.map} +1 -1
- package/dist/{chunk-NXJJ3IP3.js → chunk-W2B5P54C.js} +4 -4
- package/dist/{chunk-NXJJ3IP3.js.map → chunk-W2B5P54C.js.map} +1 -1
- package/dist/{chunk-FLAJQXOM.js → chunk-WH225GEC.js} +26 -11
- package/dist/chunk-WH225GEC.js.map +1 -0
- package/dist/chunk-WY4IYO3G.js +25 -0
- package/dist/chunk-WY4IYO3G.js.map +1 -0
- package/dist/{chunk-RQOCJRHY.js → chunk-YH4O3H4R.js} +4 -4
- package/dist/{chunk-RQOCJRHY.js.map → chunk-YH4O3H4R.js.map} +1 -1
- package/dist/chunk-ZPRZQTYM.js +14 -0
- package/dist/{chunk-MU4ACHQU.js.map → chunk-ZPRZQTYM.js.map} +1 -1
- package/dist/chunk-ZQGMVUPE.js +29 -0
- package/dist/chunk-ZQGMVUPE.js.map +1 -0
- package/dist/components/cart/index.js +1 -1
- package/dist/components/common/index.js +1 -1
- package/dist/components/drawer/index.js +13 -12
- package/dist/components/home/index.js +16 -15
- package/dist/components/layout/index.js +5 -5
- package/dist/components/product/index.js +14 -13
- package/dist/components/store/index.js +15 -14
- package/dist/components/store/index.js.map +1 -1
- package/dist/document-class-7KPUN2DK.js +26 -0
- package/dist/{document-class-QLK3MMHA.js.map → document-class-7KPUN2DK.js.map} +1 -1
- package/dist/hooks/index.js +13 -12
- package/dist/hooks/useGtm.js +13 -12
- package/dist/hooks/useMoney.js +13 -12
- package/dist/hooks/useStore.js +13 -12
- package/dist/hooks/useUser.js +7 -6
- package/dist/index.js +13 -12
- package/dist/index.js.map +1 -1
- package/dist/navigation-QMBOIYJI.js +12 -0
- package/dist/{navigation-7ZIYPM45.js.map → navigation-QMBOIYJI.js.map} +1 -1
- package/dist/{navigation-ZRCCK54S.js → navigation-XZJCQXY3.js} +5 -5
- package/dist/{navigation-ZRCCK54S.js.map → navigation-XZJCQXY3.js.map} +1 -1
- package/dist/{not-found-M6PIZHJW.js → not-found-UE5XOV5C.js} +16 -15
- package/dist/not-found-UE5XOV5C.js.map +1 -0
- package/dist/providers/NavigationProvider.d.ts +5 -5
- package/dist/providers/NavigationProvider.d.ts.map +1 -1
- package/dist/providers/TwilightProvider.d.ts.map +1 -1
- package/dist/providers/index.js +13 -12
- package/dist/routes/account/notifications/loader.d.ts.map +1 -1
- package/dist/routes/account/orders/loader.d.ts.map +1 -1
- package/dist/routes/account/orders.js +8 -7
- package/dist/routes/account/profile/loader.d.ts.map +1 -1
- package/dist/routes/account/settings/loader.d.ts.map +1 -1
- package/dist/routes/account/wallet/loader.d.ts.map +1 -1
- package/dist/routes/account/wishlist/loader.d.ts.map +1 -1
- package/dist/routes/account.js +24 -20
- package/dist/routes/account.js.map +1 -1
- package/dist/routes/blog.js +12 -11
- package/dist/routes/blog.js.map +1 -1
- package/dist/routes/brands/BrandsPage.d.ts +1 -1
- package/dist/routes/brands/BrandsPage.d.ts.map +1 -1
- package/dist/routes/brands/index.d.ts +2 -2
- package/dist/routes/brands/index.d.ts.map +1 -1
- package/dist/routes/brands/loader.d.ts.map +1 -1
- package/dist/routes/brands/types.d.ts +4 -1
- package/dist/routes/brands/types.d.ts.map +1 -1
- package/dist/routes/brands.js +12 -22
- package/dist/routes/brands.js.map +1 -1
- package/dist/routes/cart.js +21 -20
- package/dist/routes/cart.js.map +1 -1
- package/dist/routes/home.js +18 -17
- package/dist/routes/index.js +4 -4
- package/dist/routes/lazy.d.ts +1 -1
- package/dist/routes/lazy.d.ts.map +1 -1
- package/dist/routes/loyalty/index.d.ts +1 -1
- package/dist/routes/loyalty/index.d.ts.map +1 -1
- package/dist/routes/loyalty/loader.d.ts +1 -1
- package/dist/routes/loyalty/loader.d.ts.map +1 -1
- package/dist/routes/loyalty.js +21 -12
- package/dist/routes/loyalty.js.map +1 -1
- package/dist/routes/page.js +8 -7
- package/dist/routes/page.js.map +1 -1
- package/dist/routes/product-listing.js +18 -17
- package/dist/routes/product-listing.js.map +1 -1
- package/dist/routes/product.js +16 -15
- package/dist/routes/product.js.map +1 -1
- package/dist/routes/seo-redirects.js +4 -4
- package/dist/routes/testimonials.js +2 -2
- package/dist/routes/thank-you.js +8 -7
- package/dist/routes/thank-you.js.map +1 -1
- package/dist/skeleton.js +18 -17
- package/dist/tanstack/navigation.d.ts.map +1 -1
- package/dist/tanstack/router.d.ts.map +1 -1
- package/dist/tanstack.js +19 -28
- package/dist/tanstack.js.map +1 -1
- package/dist/twilight/context.d.ts.map +1 -1
- package/dist/utils/cookies.d.ts +7 -0
- package/dist/utils/cookies.d.ts.map +1 -1
- package/dist/utils/head.d.ts +3 -0
- package/dist/utils/head.d.ts.map +1 -1
- package/dist/utils/head.js +1 -1
- package/dist/utils/index.js +7 -6
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/request-host.d.ts +2 -8
- package/dist/utils/request-host.d.ts.map +1 -1
- package/dist/utils/store-base.d.ts +11 -0
- package/dist/utils/store-base.d.ts.map +1 -1
- package/dist/vite/index.js +3 -3
- package/package.json +1 -1
- package/dist/BlogAuthorPage-KA3EWFJC.js.map +0 -1
- package/dist/BlogCategoryPage-EWFNGPTS.js.map +0 -1
- package/dist/BlogPage-E3CN2WJL.js.map +0 -1
- package/dist/BlogSinglePage-Z4GIRBWI.js.map +0 -1
- package/dist/BlogTagPage-4D6GMTHN.js.map +0 -1
- package/dist/BrandsPage-C6EZVXQC.js +0 -132
- package/dist/BrandsPage-C6EZVXQC.js.map +0 -1
- package/dist/Breadcrumb-HZVWJZC4.js.map +0 -1
- package/dist/CartItem-OBF3TBDK.js.map +0 -1
- package/dist/CartSummary-GHMZ5LAL.js.map +0 -1
- package/dist/CustomerLayout-JG4GOVSO.js.map +0 -1
- package/dist/LoyaltyPage-SJUUOW3V.js.map +0 -1
- package/dist/MainMenu-SH3YM2CA.js.map +0 -1
- package/dist/MobileMenu-JGO33EPX.js.map +0 -1
- package/dist/NotificationsPage-DBXZUQW6.js.map +0 -1
- package/dist/OrderSinglePage-2ME6HVFH.js.map +0 -1
- package/dist/OrdersPage-6XMYJQAB.js.map +0 -1
- package/dist/ProfilePage-FGJHE5AD.js.map +0 -1
- package/dist/SeoCartWidget-ALMYKXRG.js.map +0 -1
- package/dist/SettingsPage-K5EM4BLS.js.map +0 -1
- package/dist/ThankYouPage-WPR576XD.js.map +0 -1
- package/dist/WalletPage-ZMTV7GVF.js.map +0 -1
- package/dist/WishlistPage-BRB7RZEF.js.map +0 -1
- package/dist/chunk-55NGYH3V.js.map +0 -1
- package/dist/chunk-5EPR726Z.js.map +0 -1
- package/dist/chunk-B3EFOE57.js.map +0 -1
- package/dist/chunk-B3Z7WNO5.js.map +0 -1
- package/dist/chunk-FLAJQXOM.js.map +0 -1
- package/dist/chunk-JVKDYZMW.js.map +0 -1
- package/dist/chunk-MU4ACHQU.js +0 -14
- package/dist/chunk-NQHOKDDF.js +0 -29
- package/dist/chunk-NQHOKDDF.js.map +0 -1
- package/dist/chunk-POLSCD5O.js.map +0 -1
- package/dist/chunk-RLNBEDA4.js.map +0 -1
- package/dist/chunk-SHHF6XXL.js.map +0 -1
- package/dist/chunk-XTMHHLNK.js.map +0 -1
- package/dist/chunk-YDU4K4M7.js.map +0 -1
- package/dist/document-class-QLK3MMHA.js +0 -25
- package/dist/navigation-7ZIYPM45.js +0 -11
- package/dist/not-found-M6PIZHJW.js.map +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { getStoreIdentifier
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { getStoreIdentifier } from './chunk-WY4IYO3G.js';
|
|
2
|
+
import { getInjectedRuntimeEnv } from './chunk-TYLKNVQA.js';
|
|
3
|
+
import { AUTH_TOKEN_COOKIE_NAME, extractTokenFromCookies, readSdkScope, extractScopeFromCookies } from './chunk-SR4OTLTJ.js';
|
|
4
|
+
import { getTwilightContext, getRequestStore } from './chunk-N2S25NXP.js';
|
|
4
5
|
import ky from 'ky';
|
|
5
6
|
import { createIsomorphicFn } from '@tanstack/react-start';
|
|
6
7
|
import { getCookie } from '@tanstack/react-start/server';
|
|
@@ -131,5 +132,5 @@ var filesCdn = ky.extend({
|
|
|
131
132
|
});
|
|
132
133
|
|
|
133
134
|
export { STORE_IDENTIFIER_HEADER, api, cdn, filesCdn, getActiveScope, getActiveScopeId, getAuthToken, requestedThemeVersionId };
|
|
134
|
-
//# sourceMappingURL=chunk-
|
|
135
|
-
//# sourceMappingURL=chunk-
|
|
135
|
+
//# sourceMappingURL=chunk-P3OPJL6I.js.map
|
|
136
|
+
//# sourceMappingURL=chunk-P3OPJL6I.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/theme-version.ts","../src/api/client.ts"],"names":[],"mappings":";;;;;;;;;AAoCO,SAAS,uBAAA,GAAyC;AACvD,EAAA,MAAM,EAAE,SAAA,EAAU,GAAI,eAAA,EAAgB;AACtC,EAAA,IAAI,WAAW,OAAO,SAAA;AAEtB,EAAA,OAAO,qBAAA,GAAwB,SAAA,IAAa,IAAA;AAC9C;AAkBO,SAAS,qBAAA,GAAuC;AACrD,EAAA,MAAM,YAAY,uBAAA,EAAwB;AAC1C,EAAA,IAAI,WAAW,OAAO,SAAA;AAEtB,EAAA,IAAI;AACF,IAAA,MAAM,SAAA,GAAY,kBAAA,EAAmB,CAAE,QAAA,EAAU,OAAO,OAAA,EAAS,EAAA;AACjE,IAAA,OAAO,SAAA,IAAa,IAAA,GAAO,MAAA,CAAO,SAAS,CAAA,GAAI,IAAA;AAAA,EACjD,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;;;AC9CA,IAAM,iBAAA,GAAoB,kBAAA,EAAmB,CAC1C,MAAA,CAAO,MAAqB;AAC3B,EAAA,IAAI;AACF,IAAA,OAAO,SAAA,CAAU,sBAAsB,CAAA,IAAK,IAAA;AAAA,EAC9C,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF,CAAC,CAAA,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I,KAAA,CAAM,eAAA;AACR,YAAA,OAAA,CAAQ,OAAA,CAAQ,GAAA,CAAI,WAAA,CAAY,qBAAA,EAAuB,MAAM,eAAe,CAAA;AAC9E,UAAA,IAAI,KAAA,CAAM,aAAA;AACR,YAAA,OAAA,CAAQ,OAAA,CAAQ,GAAA,CAAI,WAAA,CAAY,mBAAA,EAAqB,MAAM,aAAa,CAAA;AAAA,QAC5E;AAAA,MACF;AAAA;AACF;AAEJ,CAAC;AAEM,IAAM,GAAA,GAAM,GAAG,MAAA,CAAO;AAAA,EAC3B,MAAA,EAAQ,2BAAA;AAAA,EACR,OAAA,EAAS;AACX,CAAC;AAUM,IAAM,QAAA,GAAW,GAAG,MAAA,CAAO;AAAA,EAChC,MAAA,EAAQ,iCAAA;AAAA,EACR,OAAA,EAAS;AACX,CAAC","file":"chunk-P3OPJL6I.js","sourcesContent":["/**\n * @fileoverview Which version of the theme's settings to render — the one answer,\n * in one place.\n *\n * A merchant's theme settings are versioned. An ordinary storefront visit names\n * no version and gets the live one; the API decides, and reports it back as\n * `theme.profile.id`. Two surfaces need a different one, and both address it in\n * the URL of an iframe:\n *\n * - the merchant's theme editor at `s.salla.sa/themes/editor/…`, which shows a\n * draft version beside the controls that are editing it;\n * - a partner running the theme locally, whose dev server is the iframe.\n *\n * Written as a module of its own rather than inline at the one call site,\n * because `store-identity.ts` exists for exactly this reason: the identifier a\n * request resolved and the identifier it sent were two different values for\n * days, in two files, and every test passed. A second implementation of this is\n * the bug, not a refactor away from one.\n */\nimport { getRequestStore, getTwilightContext } from '../twilight/context';\nimport { getInjectedRuntimeEnv } from './runtime-env';\n\n/**\n * The version this request asked for, or null when it asked for none.\n *\n * Deliberately excludes the version the *settings* name. This is the answer to\n * \"what did the caller address?\", and it has to be available before any settings\n * exist — React Query keys are built from it, and a key that means one thing\n * during SSR and another after hydration is how a page refetches everything it\n * was just handed.\n *\n * 1. what the request named, seeded by `twilightMiddleware` on a host permitted\n * to name one;\n * 2. what SSR resolved and published into the head, which is all the browser has\n * once the dispatcher has stripped `?versionId=` from the URL.\n */\nexport function requestedThemeVersionId(): string | null {\n const { versionId } = getRequestStore();\n if (versionId) return versionId;\n\n return getInjectedRuntimeEnv().versionId || null;\n}\n\n/**\n * The version every Salla API call is answered with — what goes in `s-version-id`.\n *\n * The requested version outranks the settings, because a request that named one\n * is the only reason this is ever anything but the live version: falling back to\n * the settings there would let the first answer overwrite the question.\n *\n * The settings' own `theme.profile.id` stays as the fallback, unchanged. It is\n * what this header has always carried, and on an ordinary storefront it still\n * is — it keeps the rest of a page's calls pinned to the version the settings\n * call resolved, rather than letting a version go live mid-render.\n *\n * Reading the settings is guarded because `getTwilightContext().settings` throws\n * a `SettingsError` when they have not loaded — which is the normal state on the\n * very first call, the settings call itself.\n */\nexport function resolveThemeVersionId(): string | null {\n const requested = requestedThemeVersionId();\n if (requested) return requested;\n\n try {\n const profileId = getTwilightContext().settings?.theme?.profile?.id;\n return profileId != null ? String(profileId) : null;\n } catch {\n return null;\n }\n}\n","import ky from 'ky';\nimport { createIsomorphicFn } from '@tanstack/react-start';\nimport { getCookie } from '@tanstack/react-start/server';\nimport { getStoreIdentifier } from '../utils/sdk-helpers';\nimport { resolveThemeVersionId } from '../utils/theme-version';\n// import { getInjectedRuntimeEnv, readEnv } from '../utils/runtime-env';\nimport { getTwilightContext } from '../twilight/context';\nimport {\n AUTH_TOKEN_COOKIE_NAME,\n extractScopeFromCookies,\n extractTokenFromCookies,\n readSdkScope,\n type ActiveScope,\n} from '../utils/cookies';\n\n// The twilight module store doesn't reliably carry authToken into every scope: on the\n// SERVER workerd has no AsyncLocalStorage, and on BOTH sides this api client can live in a\n// different module instance than the one rootBeforeLoad populates (engine subpath import vs\n// engine-internal relative import). So `getTwilightContext().authToken` is often null even\n// for logged-in users → API calls (orders/customer/…) return `token_not_provided` (400).\n// Read the token directly from the request cookie (server) or document.cookie / salla.storage\n// (client) as a fallback. The server-only import is stripped from the client bundle by\n// createIsomorphicFn.\nconst readFallbackToken = createIsomorphicFn()\n .server((): string | null => {\n try {\n return getCookie(AUTH_TOKEN_COOKIE_NAME) ?? null;\n } catch {\n return null;\n }\n })\n .client((): string | null => {\n const fromCookie =\n typeof document !== 'undefined'\n ? extractTokenFromCookies(document.cookie, AUTH_TOKEN_COOKIE_NAME)\n : null;\n if (fromCookie) return fromCookie;\n const storage = typeof window !== 'undefined' ? window.salla?.storage : undefined;\n const fromStorage =\n typeof storage?.get === 'function' ? storage.get(AUTH_TOKEN_COOKIE_NAME) : null;\n if (typeof fromStorage === 'string' && fromStorage) return fromStorage;\n // `?token=` webview injection lands only on the SDK's axios instance\n const fromSdkApi = typeof window !== 'undefined' ? window.salla?.api?.token : undefined;\n return typeof fromSdkApi === 'string' && fromSdkApi ? fromSdkApi : null;\n });\n\n/**\n * The auth token as the api client sees it: twilight context first, cookie/storage fallback.\n * Use this (not `getTwilightContext().authToken`, which is often null for logged-in users —\n * see the note above) to decide whether an authenticated-only query should run.\n */\nexport const getAuthToken = (): string | null =>\n getTwilightContext().authToken ?? readFallbackToken();\n\nconst API_HEADERS = {\n ACCEPT: 'accept',\n ACCEPT_LANGUAGE: 'accept-language',\n APP_OS: 's-app-os',\n APP_VERSION: 's-app-version',\n RAY: 's-ray',\n SOURCE: 's-source',\n THEME_TYPE: 's-theme-type',\n STORE_API_VERSION: 's-store-api-version',\n REQUESTED_WITH: 'x-requested-with',\n CF_PROXY_WHITELIST: 's-cf-proxy-whitelist-id',\n STORE_IDENTIFIER: 'store-identifier',\n AUTHORIZATION: 'Authorization',\n VERSION_ID: 's-version-id',\n SCOPE_ID: 's-scope-id',\n SCOPE_TYPE: 's-scope-type',\n SCOPE_ALLOCATION_TYPE: 's-scope-allocation-type',\n SCOPE_ALLOCATION_ID: 's-scope-allocation-id',\n} as const;\n\n/**\n * The header every Salla API call is answered by store.\n *\n * Exported because a caller that already knows which store it is asking about\n * must be able to say so on the request itself — see `store.settings`. Without\n * it the only way to name a store is the ambient resolver, and \"the identifier\n * I checked\" and \"the identifier that was sent\" become two different things.\n */\nexport const STORE_IDENTIFIER_HEADER = API_HEADERS.STORE_IDENTIFIER;\n\n/**\n * Active scope: the market plus its branch allocation, as the SDK stores it. On the\n * client it comes from `salla.storage.get('scope')`; before the SDK hydrates storage\n * it falls back to the `scope` cookie the theme mirrors that selection into (see\n * writeScopeCookie), then to the scope twilightMiddleware seeded from the same\n * cookie on the server. Requests vary by the `s-scope-*` headers, so React Query\n * keys must include this to avoid serving another branch's cached categories/products.\n *\n * The cookie step matters for hydration: the SDK is not guaranteed to have\n * populated `salla.storage` by the time the client rebuilds a dehydrated query\n * key, and without it the client would compute null against a scoped SSR key.\n */\nexport const getActiveScope = (): ActiveScope | null => {\n // `!== undefined`, not `!= null`: a null here is the SDK authoritatively saying \"no branch\n // selected\", which must beat a cookie left over from the previous selection. Only a\n // not-yet-ready storage API (undefined) falls through to the cookie.\n const fromStorage = readSdkScope();\n if (fromStorage !== undefined) return fromStorage;\n\n if (typeof document !== 'undefined') {\n const fromCookie = extractScopeFromCookies(document.cookie);\n if (fromCookie != null) return fromCookie;\n }\n\n try {\n return getTwilightContext().scope;\n } catch {\n return null;\n }\n};\n\n/** {@link getActiveScope} reduced to the market id. */\nexport const getActiveScopeId = (): string | null => getActiveScope()?.id ?? null;\n\nconst sharedHeaders = (locale: string) => ({\n [API_HEADERS.ACCEPT]: 'application/json' as const,\n [API_HEADERS.ACCEPT_LANGUAGE]: locale,\n [API_HEADERS.APP_OS]: 'browser',\n [API_HEADERS.APP_VERSION]: '2.14.363',\n [API_HEADERS.RAY]: '50',\n [API_HEADERS.SOURCE]: 'twilight',\n [API_HEADERS.THEME_TYPE]: 'react',\n [API_HEADERS.STORE_API_VERSION]: 'swoole',\n [API_HEADERS.REQUESTED_WITH]: 'XMLHttpRequest',\n [API_HEADERS.CF_PROXY_WHITELIST]: '019a2f78-a64c-7edb-proxy-whitelist-id-9a3a-17afda90f03a',\n});\n\n/**\n * Store API base. `VITE_API_URL` override points a preview at a branch backend; unset → prod\n * `api.salla.dev`. Resolution order matters: the value the SSR worker resolved (published into\n * the head, since worker `vars` are server-only `process.env` and never reach the browser\n * bundle) wins, so the hydrated client keeps talking to the backend that rendered the page.\n */\n\n// const STORE_API_BASE = getInjectedRuntimeEnv().apiBase || readEnv('VITE_API_URL') || 'https://api.salla.dev/store/v1';\n\nexport const api = ky.extend({\n prefix: 'https://api.salla.dev/store/v1', // TODO: check env\n timeout: 8000,\n hooks: {\n beforeRequest: [\n ({ request }) => {\n const { locale, authToken } = getTwilightContext();\n const headers = sharedHeaders(locale);\n for (const [key, value] of Object.entries(headers)) {\n request.headers.set(key, value);\n }\n // Only when the caller did not say. `headers.set` here would otherwise\n // overwrite a per-request identifier with the ambient one, which is a\n // silent way to answer a question about one store with another's data.\n if (!request.headers.get(API_HEADERS.STORE_IDENTIFIER)) {\n request.headers.set(API_HEADERS.STORE_IDENTIFIER, getStoreIdentifier());\n }\n\n // The version the request asked for, else the one the settings named.\n // Absent means \"whatever is live\", which is what an ordinary storefront\n // visit wants — so a null is left off rather than sent empty.\n const versionId = resolveThemeVersionId();\n if (versionId) {\n request.headers.set(API_HEADERS.VERSION_ID, versionId);\n }\n\n const token = authToken ?? readFallbackToken();\n if (token) {\n request.headers.set(API_HEADERS.AUTHORIZATION, `Bearer ${token}`);\n }\n\n // The same four the SDK's own client sends. The API resolves stock per\n // allocation: id alone asks about the market, not the branch the shopper chose.\n const scope = getActiveScope();\n if (scope) {\n request.headers.set(API_HEADERS.SCOPE_ID, scope.id);\n if (scope.type) request.headers.set(API_HEADERS.SCOPE_TYPE, scope.type);\n if (scope.allocation_type)\n request.headers.set(API_HEADERS.SCOPE_ALLOCATION_TYPE, scope.allocation_type);\n if (scope.allocation_id)\n request.headers.set(API_HEADERS.SCOPE_ALLOCATION_ID, scope.allocation_id);\n }\n },\n ],\n },\n});\n\nexport const cdn = ky.extend({\n prefix: 'https://cdn.salla.network',\n timeout: 5000,\n});\n\n/**\n * The merchant uploader's public bucket, `admin-uploader-prod`.\n *\n * A different host from {@link cdn} and a different thing behind it: this one\n * is an R2 custom domain, so a read never passes through a worker. Storefront\n * translations live here, per language, under `translations/` — see\n * `api/translations.ts`.\n */\nexport const filesCdn = ky.extend({\n prefix: 'https://cdn.files.salla.network',\n timeout: 5000,\n});\n"]}
|
|
@@ -28,5 +28,5 @@ function resolveHead(descriptor) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export { mergeHead, resolveHead, setHeadAdapter };
|
|
31
|
-
//# sourceMappingURL=chunk-
|
|
32
|
-
//# sourceMappingURL=chunk-
|
|
31
|
+
//# sourceMappingURL=chunk-PK7EU5TM.js.map
|
|
32
|
+
//# sourceMappingURL=chunk-PK7EU5TM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/head.ts"],"names":[],"mappings":";AAqGO,SAAS,SAAA,CACd,MACA,SAAA,EACgB;AAChB,EAAA,MAAM,MAAA,GAAyB;AAAA,IAC7B,GAAG,IAAA;AAAA,IACH,GAAG,SAAA;AAAA,IACH,IAAA,EAAM,CAAC,GAAI,IAAA,CAAK,IAAA,IAAQ,EAAC,EAAI,GAAI,SAAA,CAAU,IAAA,IAAQ,EAAG,CAAA;AAAA,IACtD,KAAA,EAAO,CAAC,GAAI,IAAA,CAAK,KAAA,IAAS,EAAC,EAAI,GAAI,SAAA,CAAU,KAAA,IAAS,EAAG,CAAA;AAAA,IACzD,MAAA,EAAQ,CAAC,GAAI,IAAA,CAAK,MAAA,IAAU,EAAC,EAAI,GAAI,SAAA,CAAU,MAAA,IAAU,EAAG,CAAA;AAAA,IAC5D,OAAA,EAAS,CAAC,GAAI,IAAA,CAAK,OAAA,IAAW,EAAC,EAAI,GAAI,SAAA,CAAU,OAAA,IAAW,EAAG,CAAA;AAAA,IAC/D,SAAA,EAAW,CAAC,GAAI,IAAA,CAAK,SAAA,IAAa,EAAC,EAAI,GAAI,SAAA,CAAU,SAAA,IAAa,EAAG,CAAA;AAAA,IACrE,kBAAA,EAAoB,SAAA,CAAU,kBAAA,IAAsB,IAAA,CAAK,kBAAA;AAAA,IACzD,MAAA,EAAQ,SAAA,CAAU,MAAA,IAAU,IAAA,CAAK;AAAA,GACnC;AAEA,EAAA,IAAI,IAAA,CAAK,SAAA,IAAa,SAAA,CAAU,SAAA,EAAW;AACzC,IAAA,MAAA,CAAO,YAAY,EAAE,GAAG,KAAK,SAAA,EAAW,GAAG,UAAU,SAAA,EAAU;AAAA,EACjE;AACA,EAAA,IAAI,IAAA,CAAK,OAAA,IAAW,SAAA,CAAU,OAAA,EAAS;AACrC,IAAA,MAAA,CAAO,UAAU,EAAE,GAAG,KAAK,OAAA,EAAS,GAAG,UAAU,OAAA,EAAQ;AAAA,EAC3D;AAEA,EAAA,OAAO,MAAA;AACT;AAIA,IAAI,aAAA,GAA6B,CAAC,CAAA,KAAM,CAAA;AAEjC,SAAS,eAAe,OAAA,EAA4B;AACzD,EAAA,aAAA,GAAgB,OAAA;AAClB;AAEO,SAAS,YAAY,UAAA,EAAwC;AAClE,EAAA,OAAO,cAAc,UAAU,CAAA;AACjC","file":"chunk-PK7EU5TM.js","sourcesContent":["export interface OpenGraphImage {\n url: string;\n width?: number;\n height?: number;\n alt?: string;\n}\n\n/** Typed `<link>` descriptor — covers SEO, preload, prefetch, and resource hints. */\nexport interface LinkDescriptor {\n rel: string;\n href: string;\n id?: string;\n type?: string;\n /** For preload/prefetch: specifies the type of resource (e.g. \"font\", \"script\", \"image\"). */\n as?: string;\n hreflang?: string;\n media?: string;\n sizes?: string;\n crossOrigin?: 'anonymous' | 'use-credentials';\n integrity?: string;\n fetchPriority?: 'high' | 'low' | 'auto';\n [key: string]: string | undefined;\n}\n\n/** Typed `<style>` descriptor — for injecting inline CSS into the document head. */\nexport interface StyleDescriptor {\n /** Used to deduplicate styles across route tree. */\n id?: string;\n /** Applies the style only to specific media (e.g. \"print\", \"screen\"). */\n media?: string;\n /** The CSS content to inject. */\n children: string;\n /** With `precedence`, makes React 19 hoist the style and match it by `href` rather than by position. */\n href?: string;\n precedence?: string;\n}\n\n/** Typed `<script>` descriptor — for injecting scripts into the document head. */\nexport interface ScriptDescriptor {\n id?: string;\n type?: string;\n src?: string;\n async?: boolean;\n defer?: boolean;\n nonce?: string;\n crossOrigin?: 'anonymous' | 'use-credentials';\n /** Inline script content. */\n children?: string;\n [key: string]: unknown;\n}\n\nexport interface HeadDescriptor {\n title?: string;\n description?: string;\n keywords?: string | string[];\n canonical?: string;\n robots?: string;\n\n openGraph?: {\n type?: string;\n siteName?: string;\n title?: string;\n description?: string;\n url?: string;\n locale?: string;\n alternateLocale?: string[];\n images?: string | OpenGraphImage | Array<string | OpenGraphImage>;\n publishedTime?: string;\n modifiedTime?: string;\n };\n\n twitter?: {\n card?: string;\n title?: string;\n description?: string;\n images?: string | string[];\n site?: string;\n creator?: string;\n url?: string;\n };\n\n // Multilingual alternates (hreflang)\n alternateLanguages?: Array<{ hreflang: string; href: string }>;\n\n // JSON-LD structured data (convenience shorthand — rendered as a head script)\n jsonLd?: Record<string, unknown> | Array<Record<string, unknown>>;\n\n // Import map for module resolution\n importMap?: Array<{ imports: Record<string, string> }>;\n\n // Escape hatches / extras\n /** Arbitrary `<meta>` tags. Supports name, property, and http-equiv variants. */\n meta?: Array<{ name?: string; property?: string; httpEquiv?: string; content: string }>;\n /** Typed `<link>` tags — use for canonical, alternates, preload, prefetch, icons, etc. */\n links?: LinkDescriptor[];\n /** Inline `<style>` blocks injected into the document head. */\n styles?: StyleDescriptor[];\n /** Arbitrary `<script>` tags injected into the document head. */\n scripts?: ScriptDescriptor[];\n}\n\nexport function mergeHead(\n base: HeadDescriptor,\n extension: Partial<HeadDescriptor>\n): HeadDescriptor {\n const merged: HeadDescriptor = {\n ...base,\n ...extension,\n meta: [...(base.meta ?? []), ...(extension.meta ?? [])],\n links: [...(base.links ?? []), ...(extension.links ?? [])],\n styles: [...(base.styles ?? []), ...(extension.styles ?? [])],\n scripts: [...(base.scripts ?? []), ...(extension.scripts ?? [])],\n importMap: [...(base.importMap ?? []), ...(extension.importMap ?? [])],\n alternateLanguages: extension.alternateLanguages ?? base.alternateLanguages,\n jsonLd: extension.jsonLd ?? base.jsonLd,\n };\n\n if (base.openGraph || extension.openGraph) {\n merged.openGraph = { ...base.openGraph, ...extension.openGraph };\n }\n if (base.twitter || extension.twitter) {\n merged.twitter = { ...base.twitter, ...extension.twitter };\n }\n\n return merged;\n}\n\nexport type HeadResult = Record<string, unknown>;\ntype HeadAdapter = (descriptor: HeadDescriptor) => HeadResult;\nlet activeAdapter: HeadAdapter = (d) => d as HeadResult;\n\nexport function setHeadAdapter(adapter: HeadAdapter): void {\n activeAdapter = adapter;\n}\n\nexport function resolveHead(descriptor: HeadDescriptor): HeadResult {\n return activeAdapter(descriptor);\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { filesCdn, cdn } from './chunk-
|
|
2
|
-
import { storeTranslationsQueryKey, translationsQueryKey } from './chunk-
|
|
1
|
+
import { filesCdn, cdn } from './chunk-P3OPJL6I.js';
|
|
2
|
+
import { storeTranslationsQueryKey, translationsQueryKey, composeMessages, isPlainObject } from './chunk-N2S25NXP.js';
|
|
3
3
|
import { queryOptions } from '@tanstack/react-query';
|
|
4
4
|
|
|
5
5
|
var LEGACY_GLOBAL_FILE = "js/translations.json";
|
|
@@ -9,30 +9,26 @@ function commonTranslationsPath(locale) {
|
|
|
9
9
|
function storeTranslationsPath(storeId, locale) {
|
|
10
10
|
return `translations/${storeId}/${locale}.json`;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
12
|
+
async function readLocaleFile(path, { failLoudly = false } = {}) {
|
|
13
|
+
const unreadable = (reason, cause) => {
|
|
14
|
+
if (failLoudly) throw new Error(`[translations] ${path}: ${reason}`, { cause });
|
|
15
|
+
console.warn("[translations]", reason, path, cause ?? "");
|
|
16
|
+
return null;
|
|
17
|
+
};
|
|
16
18
|
try {
|
|
17
19
|
const response = await filesCdn.get(path, { throwHttpErrors: false, timeout: 5e3 });
|
|
18
20
|
if (response.status === 404) return null;
|
|
19
21
|
if (!response.ok) {
|
|
20
|
-
|
|
21
|
-
"[translations] a language file answered an error status",
|
|
22
|
-
path,
|
|
23
|
-
response.status
|
|
24
|
-
);
|
|
25
|
-
return null;
|
|
22
|
+
return unreadable(`answered ${response.status}`);
|
|
26
23
|
}
|
|
27
24
|
const data = await response.json();
|
|
28
25
|
if (!isPlainObject(data)) {
|
|
29
|
-
|
|
30
|
-
return null;
|
|
26
|
+
return unreadable("is not a JSON object");
|
|
31
27
|
}
|
|
32
28
|
return data;
|
|
33
29
|
} catch (error) {
|
|
34
|
-
|
|
35
|
-
return
|
|
30
|
+
if (error instanceof Error && error.message.startsWith("[translations]")) throw error;
|
|
31
|
+
return unreadable("could not be read", error);
|
|
36
32
|
}
|
|
37
33
|
}
|
|
38
34
|
async function readLegacyGlobal(locale) {
|
|
@@ -45,14 +41,6 @@ async function readLegacyGlobal(locale) {
|
|
|
45
41
|
return null;
|
|
46
42
|
}
|
|
47
43
|
}
|
|
48
|
-
function mergeMessages(base, overrides) {
|
|
49
|
-
const merged = { ...base };
|
|
50
|
-
for (const [key, value] of Object.entries(overrides)) {
|
|
51
|
-
const existing = merged[key];
|
|
52
|
-
merged[key] = isPlainObject(existing) && isPlainObject(value) ? mergeMessages(existing, value) : value;
|
|
53
|
-
}
|
|
54
|
-
return merged;
|
|
55
|
-
}
|
|
56
44
|
var translations = {
|
|
57
45
|
/**
|
|
58
46
|
* The platform's copy for `locale`.
|
|
@@ -78,20 +66,29 @@ var translations = {
|
|
|
78
66
|
* Returned unwrapped, unlike {@link translations.get}: this is merged into
|
|
79
67
|
* that one's messages rather than handed to i18next on its own.
|
|
80
68
|
*/
|
|
81
|
-
forStore: async (storeId, locale) =>
|
|
69
|
+
forStore: async (storeId, locale) => (
|
|
70
|
+
// `failLoudly`, unlike the platform file: this is only ever called because
|
|
71
|
+
// the settings said overrides exist, so a 500, a timeout or a body that is
|
|
72
|
+
// not JSON is a failure to read them — not a store that has none. Returning
|
|
73
|
+
// `null` there would cache "no overrides" as a success, skip the query's
|
|
74
|
+
// retry, and serve Salla's wording in place of the merchant's until the
|
|
75
|
+
// entry expired. A 404 still means absent, and `rootBeforeLoad` catches the
|
|
76
|
+
// throw and keeps the platform copy, so the worst case is unchanged.
|
|
77
|
+
readLocaleFile(storeTranslationsPath(storeId, locale), { failLoudly: true })
|
|
78
|
+
),
|
|
82
79
|
/**
|
|
83
80
|
* The platform's copy for `locale` with this merchant's wording laid over it.
|
|
84
81
|
*
|
|
85
82
|
* Takes the two as values rather than fetching them, so the caller decides
|
|
86
83
|
* whether the second request happens at all and both stay separately cached.
|
|
87
84
|
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
85
|
+
/**
|
|
86
|
+
* The platform's copy for `locale` with this merchant's wording over it.
|
|
87
|
+
*
|
|
88
|
+
* Delegates to `composeMessages`, which every other reader of these two
|
|
89
|
+
* entries also uses — see `api/messages.ts` for why there is exactly one.
|
|
90
|
+
*/
|
|
91
|
+
merge: (common, overrides, locale) => composeMessages(common, overrides, locale) ?? null,
|
|
95
92
|
queries: {
|
|
96
93
|
/**
|
|
97
94
|
* @param locale taken as an argument rather than read from the twilight
|
|
@@ -129,5 +126,5 @@ var translations = {
|
|
|
129
126
|
};
|
|
130
127
|
|
|
131
128
|
export { commonTranslationsPath, storeTranslationsPath, translations };
|
|
132
|
-
//# sourceMappingURL=chunk-
|
|
133
|
-
//# sourceMappingURL=chunk-
|
|
129
|
+
//# sourceMappingURL=chunk-Q3COPV5Z.js.map
|
|
130
|
+
//# sourceMappingURL=chunk-Q3COPV5Z.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/api/translations.ts"],"names":[],"mappings":";;;;AAiEA,IAAM,kBAAA,GAAqB,sBAAA;AAGp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GAAG,EAAE,UAAA,EAAY,MAAM;AAAA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAc7E,KAAA,EAAO,CACL,MAAA,EACA,SAAA,EACA,WAC+B,eAAA,CAAgB,MAAA,EAAQ,SAAA,EAAW,MAAM,CAAA,IAAK,IAAA;AAAA,EAE/E,OAAA,EAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAgBP,QAAA,EAAU,CAAC,MAAA,KACT,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,qBAAqB,MAAM,CAAA;AAAA,MACrC,OAAA,EAAS,MAAM,YAAA,CAAa,GAAA,CAAI,MAAM;AAAA,KACvC,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWH,OAAA,EAAS,CAAC,OAAA,EAA0B,MAAA,KAClC,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,yBAAA,CAA0B,OAAA,EAAS,MAAM,CAAA;AAAA,MACnD,OAAA,EAAS,MAAM,YAAA,CAAa,QAAA,CAAS,SAAS,MAAM;AAAA,KACrD;AAAA;AAEP","file":"chunk-Q3COPV5Z.js","sourcesContent":["/**\n * @fileoverview Where a storefront's words come from.\n *\n * Two files, merged: the platform's copy for this language, and the merchant's\n * own edits for this language and this store. Both are plain JSON objects on\n * the uploader's CDN, one per language.\n *\n * ```\n * https://cdn.files.salla.network/translations/common/<locale>.json the platform's\n * https://cdn.files.salla.network/translations/<storeId>/<locale>.json the merchant's\n * ```\n *\n * **What this replaces, and why.** Until now the engine read a single global\n * file, `cdn.salla.network/js/translations.json`, holding every language keyed\n * `\"<locale>.trans\"`. Nothing publishes that file: it is an object last written\n * on 2026-03-26, carrying only `ar` and `en` where the platform has 39 locales,\n * 405 keys behind `Languages-Module` and 959 English strings textually\n * different from it. So every React storefront has been serving copy from\n * March, and a key added since has never reached one. It also carried no\n * merchant overrides at all — a merchant editing their theme's wording in the\n * Dashboard changed nothing on a React theme.\n *\n * **Merchant overrides are read, and only when there are any.** Getting here\n * took two corrections worth keeping.\n *\n * The first is the address. A merchant's own wording lives at\n * `translations/<storeId>/<locale>.json`, keyed by `store()->getRouteKey()` —\n * the Optimus-encoded numeric id. An early version addressed it with\n * `resolveStoreIdentifier()`, on the claim that the two are the same string.\n * That is true of the `store-identifier` *header*, which accepts a host, a\n * username or an id, and false of the R2 key: on a custom domain the resolver\n * returns `reefperfumes.com` and on a shared host a username like\n * `mtgr-alaatr-2`. Both 404, both then read as \"this store has no overrides\",\n * and the merchant's wording silently never appears — so the feature would have\n * worked under `?storeId=` alone, which is preview and localhost. It is\n * `settings.store.id` now, which is known only after the settings query.\n *\n * The second is when to ask at all. Most stores have never customised a word,\n * and a miss is an uncached round trip (`cf-cache-status: DYNAMIC` on the 404)\n * on the critical path of every SSR render. So the request is made only when\n * `settings.languages[<ISO>].has_custom_translations` says there is something\n * to get — a flag `Languages-Module` writes when a merchant saves a\n * translation. A store without overrides pays nothing, which is what made this\n * shippable at all.\n *\n * ⚠️ The flag is written on save, so a store whose wording predates it reads as\n * `false` until someone edits a translation or the backfill runs. That is a\n * store keeping today's behaviour, not a regression — React themes have never\n * read merchant overrides — but it does mean the feature is only as complete as\n * the backfill.\n *\n * **Rollout is by fallback, not by flag.** `translations/common/` is written by\n * a sync in the theme build service that may not have run yet, and a hard switch\n * would leave every storefront with no platform strings at all. A missing common\n * file therefore falls back to the old global one, which is exactly today's\n * behaviour — so this is safe to ship before the bucket is populated, and stops\n * using the fallback on its own once it is.\n */\nimport { queryOptions } from '@tanstack/react-query';\nimport { cdn, filesCdn } from './client';\nimport { storeTranslationsQueryKey, translationsQueryKey } from './translations-key';\nimport { composeMessages, isPlainObject, type Messages } from './messages';\nimport type { TranslationMessages } from '../providers/I18nProvider';\n\n/** The global file this used to be the only reader of. See the file comment. */\nconst LEGACY_GLOBAL_FILE = 'js/translations.json';\n\n/** One language of platform copy, shared by every store. */\nexport function commonTranslationsPath(locale: string): string {\n return `translations/common/${locale}.json`;\n}\n\n/**\n * One language of a single merchant's own wording.\n *\n * `storeId` is `settings.store.id`, which is the value `Languages-Module` names\n * the object with (`store()->getRouteKey()`, the Optimus-encoded numeric id).\n * It is **not** `resolveStoreIdentifier()`: that returns a hostname on a custom\n * domain and a username on a shared host, both of which 404 here and would read\n * as \"this merchant has no overrides\" — silently, on every store but a preview.\n */\nexport function storeTranslationsPath(storeId: string | number, locale: string): string {\n return `translations/${storeId}/${locale}.json`;\n}\n\n/**\n * Reads one language file, or `null` when there is nothing to read.\n *\n * A 404 is the ordinary answer, not a failure: most stores have never had a\n * word customised, so their file does not exist. Distinguishing it from a real\n * error matters only for the log — both end in `null` — but a warning on every\n * page load of every uncustomised store is a warning nobody will read.\n */\nasync function readLocaleFile(\n path: string,\n { failLoudly = false }: { failLoudly?: boolean } = {}\n): Promise<Messages | null> {\n /** A 404 always means \"absent\"; everything else is a failure to read. */\n const unreadable = (reason: string, cause?: unknown): null => {\n if (failLoudly) throw new Error(`[translations] ${path}: ${reason}`, { cause });\n console.warn('[translations]', reason, path, cause ?? '');\n return null;\n };\n\n try {\n const response = await filesCdn.get(path, { throwHttpErrors: false, timeout: 5000 });\n if (response.status === 404) return null;\n\n if (!response.ok) {\n return unreadable(`answered ${response.status}`);\n }\n\n const data: unknown = await response.json();\n if (!isPlainObject(data)) {\n return unreadable('is not a JSON object');\n }\n\n return data;\n } catch (error) {\n if (error instanceof Error && error.message.startsWith('[translations]')) throw error;\n return unreadable('could not be read', error);\n }\n}\n\n/**\n * The pre-CDN global file, sliced to one language.\n *\n * Only reached when `translations/common/<locale>.json` is missing, which is\n * the state of the bucket until the sync has run once.\n */\nasync function readLegacyGlobal(locale: string): Promise<Messages | null> {\n try {\n const data = await cdn.get(LEGACY_GLOBAL_FILE, { timeout: 5000 }).json<TranslationMessages>();\n const forLocale = data?.[`${locale}.trans`];\n return isPlainObject(forLocale) ? forLocale : null;\n } catch {\n console.warn('[translations] the legacy global file could not be read either');\n return null;\n }\n}\n\nexport const translations = {\n /**\n * The platform's copy for `locale`.\n *\n * One file, so one request. See the file comment for why the merchant's own\n * wording is not merged in here yet and what it is waiting on.\n */\n get: async (locale: string): Promise<TranslationMessages | null> => {\n const common = await readLocaleFile(commonTranslationsPath(locale));\n const base = common ?? (await readLegacyGlobal(locale));\n if (!base) return null;\n\n // Still wrapped in the `<locale>.trans` shape the rest of the engine reads.\n // `createI18nInstance` slices by that key and so does the SDK bridge in\n // `I18nProvider`; changing the envelope here would be a second change for\n // no gain, since one language is all any of them ever take out of it.\n return { [`${locale}.trans`]: base as Record<string, string> };\n },\n\n /**\n * This merchant's own wording for `locale`, or `null` if they have none.\n *\n * Only worth calling when `settings.languages[<ISO>].has_custom_translations`\n * says there is something to get. Most stores have never customised a word,\n * and a miss here is an uncached round trip — `cf-cache-status: DYNAMIC` on a\n * 404 — on the critical path of an SSR render. The flag is what makes this\n * free for everyone who does not use it.\n *\n * Returned unwrapped, unlike {@link translations.get}: this is merged into\n * that one's messages rather than handed to i18next on its own.\n */\n forStore: async (storeId: string | number, locale: string): Promise<Messages | null> =>\n // `failLoudly`, unlike the platform file: this is only ever called because\n // the settings said overrides exist, so a 500, a timeout or a body that is\n // not JSON is a failure to read them — not a store that has none. Returning\n // `null` there would cache \"no overrides\" as a success, skip the query's\n // retry, and serve Salla's wording in place of the merchant's until the\n // entry expired. A 404 still means absent, and `rootBeforeLoad` catches the\n // throw and keeps the platform copy, so the worst case is unchanged.\n readLocaleFile(storeTranslationsPath(storeId, locale), { failLoudly: true }),\n\n /**\n * The platform's copy for `locale` with this merchant's wording laid over it.\n *\n * Takes the two as values rather than fetching them, so the caller decides\n * whether the second request happens at all and both stay separately cached.\n */\n /**\n * The platform's copy for `locale` with this merchant's wording over it.\n *\n * Delegates to `composeMessages`, which every other reader of these two\n * entries also uses — see `api/messages.ts` for why there is exactly one.\n */\n merge: (\n common: TranslationMessages | null,\n overrides: Messages | null,\n locale: string\n ): TranslationMessages | null => composeMessages(common, overrides, locale) ?? null,\n\n queries: {\n /**\n * @param locale taken as an argument rather than read from the twilight\n * context, and that is load-bearing. This key is built on the server, on\n * hydration, and again lazily from the context accessor; if any of the\n * three read a locale the others had not been given yet, the hydrated page\n * would miss the dehydrated entry and refetch both files it was just\n * handed. Every caller already has the locale in hand.\n *\n * The store is deliberately **not** in the key. One document serves one\n * store — a request that names a different one is redirected with\n * `reloadDocument`, so the client never changes store under a live cache —\n * and adding a value that resolves from the request on the server and from\n * the injected env on the client is how a key stops matching across\n * hydration.\n */\n byLocale: (locale: string) =>\n queryOptions({\n queryKey: translationsQueryKey(locale),\n queryFn: () => translations.get(locale),\n }),\n\n /**\n * This merchant's overrides, cached apart from the platform's copy.\n *\n * Its own entry rather than a wider `byLocale` key, so the common file is\n * fetched and dehydrated once per language whatever the store does, and a\n * store with no overrides never has an entry at all. Both sides compute the\n * key from the settings payload, so the hydrated page finds what the server\n * dehydrated instead of refetching it.\n */\n byStore: (storeId: string | number, locale: string) =>\n queryOptions({\n queryKey: storeTranslationsQueryKey(storeId, locale),\n queryFn: () => translations.forStore(storeId, locale),\n }),\n },\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { api } from './chunk-
|
|
1
|
+
import { api } from './chunk-P3OPJL6I.js';
|
|
2
2
|
import { queryOptions } from '@tanstack/react-query';
|
|
3
3
|
|
|
4
4
|
var notification = {
|
|
@@ -24,5 +24,5 @@ var notification = {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
export { notification };
|
|
27
|
-
//# sourceMappingURL=chunk-
|
|
28
|
-
//# sourceMappingURL=chunk-
|
|
27
|
+
//# sourceMappingURL=chunk-RJAVZBUK.js.map
|
|
28
|
+
//# sourceMappingURL=chunk-RJAVZBUK.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/notification.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D,CAAA;AAAA,EAEA,eAAe,YAA2B;AACxC,IAAA,MAAM,GAAA,CAAI,GAAA,CAAI,wBAAwB,CAAA,CAAE,IAAA,EAAK;AAAA,EAC/C,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,IAAA,EAAM,MACJ,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,eAAA,EAAiB,MAAM,CAAA;AAAA,MAClC,OAAA,EAAS,MAAM,YAAA,CAAa,IAAA;AAAK,KAClC;AAAA;AAEP","file":"chunk-RJAVZBUK.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\nimport type { Notification } from '../routes/account/notifications/types';\n\nexport interface NotificationsListResponse {\n data: Notification[];\n cursor: {\n current: number;\n previous: number | null;\n next: number | null;\n count: number;\n };\n}\n\nexport const notification = {\n list: async (): Promise<NotificationsListResponse> => {\n const response = await api\n .get('notifications')\n .json<{ data: Notification[] | null; cursor: NotificationsListResponse['cursor'] }>();\n return {\n data: response.data ?? [],\n cursor: response.cursor,\n };\n },\n\n markAsRead: async (id: number): Promise<void> => {\n await api.put(`notifications/${id}/read`).json();\n },\n\n markAllAsRead: async (): Promise<void> => {\n await api.put('notifications/read-all').json();\n },\n\n queries: {\n list: () =>\n queryOptions({\n queryKey: ['notifications', 'list'],\n queryFn: () => notification.list(),\n }),\n },\n};\n"]}
|
|
@@ -11,6 +11,9 @@ function parseRequestId(raw) {
|
|
|
11
11
|
if (!raw) return null;
|
|
12
12
|
return /^[1-9][0-9]{0,18}$/.test(raw) ? raw : null;
|
|
13
13
|
}
|
|
14
|
+
function parseStoreId(raw) {
|
|
15
|
+
return parseRequestId(raw);
|
|
16
|
+
}
|
|
14
17
|
var STORE_ID_HOSTS = ["preview.salla.design"];
|
|
15
18
|
function hostnameOf(host) {
|
|
16
19
|
const trimmed = host.trim().toLowerCase();
|
|
@@ -32,9 +35,10 @@ function hostIdentifiesStore(host) {
|
|
|
32
35
|
function resolveRequestStoreId(url, cookieHeader, host) {
|
|
33
36
|
return resolveRequestId(url, cookieHeader, host, STORE_ID_PARAM, STORE_ID_COOKIE_NAME);
|
|
34
37
|
}
|
|
35
|
-
var STORE_BASE_SEGMENT = /^[a-z0-9][a-z0-
|
|
38
|
+
var STORE_BASE_SEGMENT = /^[a-z0-9][a-z0-9._-]{0,62}$/i;
|
|
39
|
+
var ROOT_FILE = /\.(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;
|
|
36
40
|
function isStoreBaseSegment(value) {
|
|
37
|
-
return typeof value === "string" && STORE_BASE_SEGMENT.test(value) && !isLocale(value.toLowerCase());
|
|
41
|
+
return typeof value === "string" && STORE_BASE_SEGMENT.test(value) && !ROOT_FILE.test(value) && !isLocale(value.toLowerCase());
|
|
38
42
|
}
|
|
39
43
|
function resolveRequestStoreBase(url, host) {
|
|
40
44
|
if (!allowsRequestStoreId(host)) return null;
|
|
@@ -67,6 +71,11 @@ function resolveRequestId(url, cookieHeader, host, param, cookieName) {
|
|
|
67
71
|
}
|
|
68
72
|
return fromQuery ?? parseRequestId(extractTokenFromCookies(cookieHeader, cookieName));
|
|
69
73
|
}
|
|
74
|
+
function rememberDevStoreId(id) {
|
|
75
|
+
if (typeof document === "undefined" || !isLoopback(window.location.hostname)) return;
|
|
76
|
+
const storeId = parseStoreId(id == null ? null : String(id));
|
|
77
|
+
if (storeId) document.cookie = `${STORE_ID_COOKIE_NAME}=${storeId}; path=/; SameSite=Lax`;
|
|
78
|
+
}
|
|
70
79
|
function clearAuthTokenCookie() {
|
|
71
80
|
if (typeof document === "undefined") return;
|
|
72
81
|
document.cookie = `${AUTH_TOKEN_COOKIE_NAME}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;
|
|
@@ -173,7 +182,16 @@ function storeBaseRedirectHref(args) {
|
|
|
173
182
|
url.searchParams.delete(STORE_ID_PARAM);
|
|
174
183
|
return `${prefixStoreBase(url.pathname, username)}${url.search}${url.hash}`;
|
|
175
184
|
}
|
|
185
|
+
function loginRedirectHref(args) {
|
|
186
|
+
const { pathname, searchStr, origin, base } = args;
|
|
187
|
+
const first = pathname.split("/")[1];
|
|
188
|
+
const home = isLocale(first) ? `/${first}` : "/";
|
|
189
|
+
if ((pathname.replace(/\/$/, "") || "/") === home) return null;
|
|
190
|
+
const browserPath = (path) => base ? prefixStoreBase(path, base) : path;
|
|
191
|
+
const intended = `${origin}${browserPath(pathname)}${searchStr}`;
|
|
192
|
+
return `${browserPath(home)}?intended_to=${encodeURIComponent(intended)}`;
|
|
193
|
+
}
|
|
176
194
|
|
|
177
|
-
export { AUTH_TOKEN_COOKIE_NAME, clearAuthTokenCookie, extractScopeFromCookies, extractTokenFromCookies, hostIdentifiesStore, prefixStoreBase, readSdkScope, resolveRequestStore, resolveRequestStoreBase, resolveRequestVersionId, storeBaseRedirectHref, stripStoreBase, syncScopeCookie, withoutStoreUrlBase };
|
|
178
|
-
//# sourceMappingURL=chunk-
|
|
179
|
-
//# sourceMappingURL=chunk-
|
|
195
|
+
export { AUTH_TOKEN_COOKIE_NAME, clearAuthTokenCookie, extractScopeFromCookies, extractTokenFromCookies, hostIdentifiesStore, isLoopback, loginRedirectHref, prefixStoreBase, readSdkScope, rememberDevStoreId, resolveRequestStore, resolveRequestStoreBase, resolveRequestVersionId, storeBaseRedirectHref, stripStoreBase, syncScopeCookie, withoutStoreUrlBase };
|
|
196
|
+
//# sourceMappingURL=chunk-SR4OTLTJ.js.map
|
|
197
|
+
//# sourceMappingURL=chunk-SR4OTLTJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/cookies.ts","../src/utils/store-base.ts"],"names":[],"mappings":";;;AAEO,IAAM,sBAAA,GAAyB;AAC/B,IAAM,iBAAA,GAAoB,OAAA;AAoB1B,IAAM,oBAAA,GAAuB,WAAA;AAG7B,IAAM,cAAA,GAAiB,SAAA;AAsBvB,IAAM,s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AAK,QAAA,KAAa,IAAA,EAAM;AACrF,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,IAAA,EAAM,2BAA2B,CAAA;AACrD,EAAA,GAAA,CAAI,YAAA,CAAa,OAAO,cAAc,CAAA;AACtC,EAAA,OAAO,CAAA,EAAG,eAAA,CAAgB,GAAA,CAAI,QAAA,EAAU,QAAQ,CAAC,CAAA,EAAG,GAAA,CAAI,MAAM,CAAA,EAAG,GAAA,CAAI,IAAI,CAAA,CAAA;AAC3E;AAOO,SAAS,kBAAkB,IAAA,EAKhB;AAChB,EAAA,MAAM,EAAE,QAAA,EAAU,SAAA,EAAW,MAAA,EAAQ,MAAK,GAAI,IAAA;AAC9C,EAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,KAAA,CAAM,GAAG,EAAE,CAAC,CAAA;AACnC,EAAA,MAAM,OAAO,QAAA,CAAS,KAAK,CAAA,GAAI,CAAA,CAAA,EAAI,KAAK,CAAA,CAAA,GAAK,GAAA;AAC7C,EAAA,IAAA,CAAK,SAAS,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA,IAAK,GAAA,MAAS,MAAM,OAAO,IAAA;AAE1D,EAAA,MAAM,cAAc,CAAC,IAAA,KAAkB,OAAO,eAAA,CAAgB,IAAA,EAAM,IAAI,CAAA,GAAI,IAAA;AAC5E,EAAA,MAAM,QAAA,GAAW,GAAG,MAAM,CAAA,EAAG,YAAY,QAAQ,CAAC,GAAG,SAAS,CAAA,CAAA;AAC9D,EAAA,OAAO,GAAG,WAAA,CAAY,IAAI,CAAC,CAAA,aAAA,EAAgB,kBAAA,CAAmB,QAAQ,CAAC,CAAA,CAAA;AACzE","file":"chunk-SR4OTLTJ.js","sourcesContent":["import { isLocale } from '../providers/locale-constants';\n\nexport const AUTH_TOKEN_COOKIE_NAME = 'token';\nexport const SCOPE_COOKIE_NAME = 'scope';\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 * 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 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 const hostname = hostnameOf(host);\n return STORE_ID_HOSTS.includes(hostname) || isLoopback(hostname);\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 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/** {@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 */\nexport function readSdkScope(): ActiveScope | null | undefined {\n const storage = typeof window !== 'undefined' ? window.salla?.storage : undefined;\n if (typeof storage?.get !== 'function') return undefined;\n return normalizeScope(storage.get(SCOPE_COOKIE_NAME));\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. */\nconst SCOPE_COOKIE_MAX_AGE = 60 * 60 * 24 * 365;\n\nconst 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 * @fileoverview Paths on a host where the store is the root.\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 * Which segment it is, and on which hosts, is decided once, by\n * `resolveRequestStoreBase` in `utils/cookies.ts`. This file only moves it on and\n * off a path. See `docs/store-base-path.md`.\n */\nimport { allowsRequestStoreId, isStoreBaseSegment, STORE_ID_PARAM } from './cookies';\nimport { isLocale } from '../providers/locale-constants';\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 */\nexport function stripStoreBase(pathname: string, base: string): string {\n const prefix = `/${base}`;\n if (pathname === prefix) return '/';\n return pathname.startsWith(`${prefix}/`) ? pathname.slice(prefix.length) : pathname;\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 */\nexport function prefixStoreBase(path: string, base: string): string {\n const rooted = path.startsWith('/') ? path : `/${path}`;\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 * 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/** 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 * 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}): string | null {\n const { pathname, searchStr, origin, base } = 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) => (base ? prefixStoreBase(path, base) : path);\n const intended = `${origin}${browserPath(pathname)}${searchStr}`;\n return `${browserPath(home)}?intended_to=${encodeURIComponent(intended)}`;\n}\n"]}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { configureNavigation, UnauthorizedError, NavigationProvider } from './chunk-
|
|
1
|
+
import { configureNavigation, UnauthorizedError, NavigationProvider } from './chunk-WH225GEC.js';
|
|
2
|
+
import { resolveStoreBase } from './chunk-TYLKNVQA.js';
|
|
3
|
+
import { loginRedirectHref, isLoopback } from './chunk-SR4OTLTJ.js';
|
|
4
|
+
import { getTwilightContext, getRequestStore } from './chunk-N2S25NXP.js';
|
|
2
5
|
import { isLocale } from './chunk-T72DAX7R.js';
|
|
3
6
|
import { LinkProvider } from './chunk-BYMOPN2S.js';
|
|
4
7
|
import { useParams, Link, redirect, notFound, useNavigate } from '@tanstack/react-router';
|
|
@@ -40,7 +43,7 @@ var TanStackLinkAdapter = forwardRef(
|
|
|
40
43
|
target,
|
|
41
44
|
rel,
|
|
42
45
|
onClick,
|
|
43
|
-
preload: preload === "intent" ?
|
|
46
|
+
preload: preload === "intent" || preload === false ? preload : void 0,
|
|
44
47
|
replace,
|
|
45
48
|
"aria-label": ariaLabel,
|
|
46
49
|
...rest
|
|
@@ -53,6 +56,24 @@ TanStackLinkAdapter.displayName = "TanStackLinkAdapter";
|
|
|
53
56
|
function createTanStackLinkAdapter() {
|
|
54
57
|
return TanStackLinkAdapter;
|
|
55
58
|
}
|
|
59
|
+
|
|
60
|
+
// src/utils/request-host.ts
|
|
61
|
+
function requestHostOf(request) {
|
|
62
|
+
try {
|
|
63
|
+
const fromUrl = new URL(request.url).host;
|
|
64
|
+
if (fromUrl) return fromUrl;
|
|
65
|
+
} catch {
|
|
66
|
+
}
|
|
67
|
+
return request.headers.get("Host")?.trim() || null;
|
|
68
|
+
}
|
|
69
|
+
function requestOriginOf(host) {
|
|
70
|
+
return `${isLoopback(host.replace(/:\d+$/, "")) ? "http" : "https"}://${host}`;
|
|
71
|
+
}
|
|
72
|
+
function currentOrigin() {
|
|
73
|
+
if (typeof window !== "undefined") return window.location.origin;
|
|
74
|
+
const host = getRequestStore().requestHost;
|
|
75
|
+
return host ? requestOriginOf(host) : null;
|
|
76
|
+
}
|
|
56
77
|
configureNavigation({
|
|
57
78
|
notFound: (message) => {
|
|
58
79
|
throw notFound({ data: message });
|
|
@@ -61,6 +82,10 @@ configureNavigation({
|
|
|
61
82
|
throw redirect({ to: path, replace: opts?.replace });
|
|
62
83
|
},
|
|
63
84
|
unauthorized: (message) => {
|
|
85
|
+
const origin = currentOrigin();
|
|
86
|
+
const { pathname, searchStr } = getTwilightContext().location;
|
|
87
|
+
const href = origin && loginRedirectHref({ pathname, searchStr, origin, base: resolveStoreBase() });
|
|
88
|
+
if (href) throw redirect({ href, reloadDocument: true, replace: true });
|
|
64
89
|
throw new UnauthorizedError(message);
|
|
65
90
|
}
|
|
66
91
|
});
|
|
@@ -84,6 +109,6 @@ function TanStackNavigationProvider({ children }) {
|
|
|
84
109
|
);
|
|
85
110
|
}
|
|
86
111
|
|
|
87
|
-
export { NavigationSetup, TanStackLinkAdapter, TanStackNavigationProvider, createTanStackLinkAdapter };
|
|
88
|
-
//# sourceMappingURL=chunk-
|
|
89
|
-
//# sourceMappingURL=chunk-
|
|
112
|
+
export { NavigationSetup, TanStackLinkAdapter, TanStackNavigationProvider, createTanStackLinkAdapter, requestHostOf };
|
|
113
|
+
//# sourceMappingURL=chunk-TDZSHACC.js.map
|
|
114
|
+
//# sourceMappingURL=chunk-TDZSHACC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/tanstack/link.tsx","../src/utils/request-host.ts","../src/tanstack/navigation.tsx"],"names":["TanStackLink","tanstackNotFound","tanstackRedirect","useParams"],"mappings":";;;;;;;;;;AAWO,SAAS,mBAAA,CAAoB,aAAqB,MAAA,EAAiB;AACxE,EAAA,IAAI,CAAC,MAAA,IAAU,CAAC,WAAA,CAAY,UAAA,CAAW,GAAG,CAAA,IAAK,WAAA,CAAY,UAAA,CAAW,IAAI,CAAA,EAAG,OAAO,WAAA;AACpF,EAAA,MAAM,YAAA,GAAe,WAAA,CAAY,KAAA,CAAM,GAAG,CAAA,CAAE,CAAC,CAAA,EAAG,KAAA,CAAM,MAAM,CAAA,CAAE,CAAC,CAAA;AAC/D,EAAA,IAAI,QAAA,CAAS,YAAY,CAAA,EAAG,OAAO,WAAA;AACnC,EAAA,OAAO,WAAA,KAAgB,MAAM,CAAA,CAAA,EAAI,MAAM,KAAK,CAAA,CAAA,EAAI,MAAM,GAAG,WAAW,CAAA,CAAA;AACtE;AAMO,IAAM,mBAAA,GAAsB,UAAA;AAAA,EACjC,CACE;AAAA,IACE,EAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,SAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,MAAA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EAAE,MAAA,EAAQ,OAAO,CAAA;AAC9C,EAAA,MAAM,UAAA,GAAa,WAAA;AAAA,IACjB,CAAC,EAAA,EAAY,IAAA,KACX,QAAA,CAAS,EAAE,EAAA,EAAI,mBAAA,CAAoB,EAAA,EAAI,MAAM,CAAA,EAAG,OAAA,EAAS,IAAA,EAAM,SAAS,CAAA;AAAA,IAC1E,CAAC,UAAU,MAAM;AAAA,GACnB;AAEA,EAAA,uBACE,GAAA,CAAC,sBAAmB,QAAA,EAAU,UAAA,EAC5B,8BAAC,YAAA,EAAA,EAAa,OAAA,EAAS,mBAAA,EAAsB,QAAA,EAAS,CAAA,EACxD,CAAA;AAEJ;AAGO,SAAS,0BAAA,CAA2B,EAAE,QAAA,EAAS,EAA4B;AAChF,EAAA,MAAM,WAAW,WAAA,EAAY;AAC7B,EAAA,uBACE,GAAA;AAAA,IAAC,kBAAA;AAAA,IAAA;AAAA,MACC,QAAA,EAAU,CAAC,EAAA,EAAY,IAAA,KAA2B,QAAA,CAAS,EAAE,EAAA,EAAI,OAAA,EAAS,IAAA,EAAM,OAAA,EAAS,CAAA;AAAA,MAEzF,QAAA,kBAAA,GAAA,CAAC,YAAA,EAAA,EAAa,OAAA,EAAS,mBAAA,EAAsB,QAAA,EAAS;AAAA;AAAA,GACxD;AAEJ","file":"chunk-TDZSHACC.js","sourcesContent":["import { forwardRef, createElement } from 'react';\nimport { Link as TanStackLink, useParams } from '@tanstack/react-router';\nimport { isLocale } from '../providers/locale-constants';\nimport type { BaseLinkProps } from '../components/common/Link.types';\n\n/**\n * Routes live under an optional `/{-$locale}` param, so a bare `to=\"/brands\"`\n * resolves with the locale omitted and the $locale loader bounces the user to\n * the fallback locale. Prefix the current locale onto internal paths that\n * don't already carry one.\n */\nexport function localizeDestination(destination: string, locale?: string) {\n if (!locale || !destination.startsWith('/') || destination.startsWith('//')) return destination;\n const firstSegment = destination.split('/')[1]?.split(/[?#]/)[0];\n if (isLocale(firstSegment)) return destination;\n return destination === '/' ? `/${locale}` : `/${locale}${destination}`;\n}\n\n/**\n * TanStack Router Link adapter.\n * Translates framework-agnostic props to TanStack Router Link props.\n */\nexport const TanStackLinkAdapter = forwardRef<HTMLAnchorElement, BaseLinkProps>(\n (\n {\n to,\n href,\n children,\n className,\n style,\n title,\n target,\n rel,\n onClick,\n preload,\n replace,\n 'aria-label': ariaLabel,\n ...rest\n },\n ref\n ) => {\n const { locale } = useParams({ strict: false }) as { locale?: string };\n const destination = localizeDestination(to ?? href ?? '/', locale);\n\n return createElement(\n TanStackLink,\n {\n ref,\n to: destination,\n className,\n style,\n title,\n target,\n rel,\n onClick,\n preload: preload === 'intent' || preload === false ? preload : undefined,\n replace,\n 'aria-label': ariaLabel,\n ...(rest as Record<string, unknown>),\n },\n children\n );\n }\n);\n\nTanStackLinkAdapter.displayName = 'TanStackLinkAdapter';\n\n/**\n * Create a TanStack Router Link adapter component.\n */\nexport function createTanStackLinkAdapter() {\n return TanStackLinkAdapter;\n}\n","/**\n * What the request itself is enough to describe: its host.\n *\n * Small, and deliberately its own module rather than a helper inside the\n * middleware. This value decides two things — which store a live storefront is,\n * and whether the request is allowed to name a store at all — so it is worth\n * testing directly instead of only through the wiring that calls it.\n */\nimport { isLoopback } from './cookies';\n\n/** The part of a `Request` this needs, so a test does not have to build a whole one. */\nexport interface HostSource {\n url: string;\n headers: { get(name: string): string | null };\n}\n\n/**\n * The host this request arrived on, with its port when it has one.\n *\n * Taken from the request URL, which in a Worker is the address the platform\n * actually routed on, and from the `Host` header only when that fails.\n *\n * **`X-Forwarded-Host` is deliberately not consulted.** A client can set it, and\n * this value gates `allowsRequestStoreId` — so honouring it would be a way to\n * talk a merchant's own domain into behaving like the preview host, and from\n * there into serving a stranger's shop. The dispatcher strips that header today;\n * a theme must not be one edit to another repository's allowlist away from a\n * spoofable identity.\n */\nexport function requestHostOf(request: HostSource): string | null {\n try {\n const fromUrl = new URL(request.url).host;\n if (fromUrl) return fromUrl;\n } catch {\n /* an unparseable URL falls through to the header */\n }\n\n return request.headers.get('Host')?.trim() || null;\n}\n\n/** The origin a browser reached this host on: `http` for a dev server, `https` otherwise. */\nexport function requestOriginOf(host: string): string {\n return `${isLoopback(host.replace(/:\\d+$/, '')) ? 'http' : 'https'}://${host}`;\n}\n","import {\n useNavigate,\n useParams,\n redirect as tanstackRedirect,\n notFound as tanstackNotFound,\n} from '@tanstack/react-router';\nimport {\n NavigationProvider,\n configureNavigation,\n type NavigateOptions,\n} from '../providers/NavigationProvider';\nimport { LinkProvider } from '../providers/LinkProvider';\nimport { TanStackLinkAdapter, localizeDestination } from './link';\nimport { useCallback, type ReactNode } from 'react';\nimport { UnauthorizedError } from '../providers/NavigationProvider';\nimport { getRequestStore, getTwilightContext } from '../twilight/context';\nimport { resolveStoreBase } from '../utils/store-identity';\nimport { loginRedirectHref } from '../utils/store-base';\nimport { requestOriginOf } from '../utils/request-host';\n\nfunction currentOrigin(): string | null {\n if (typeof window !== 'undefined') return window.location.origin;\n const host = getRequestStore().requestHost;\n return host ? requestOriginOf(host) : null;\n}\n\nconfigureNavigation({\n notFound: (message?: string) => {\n throw tanstackNotFound({ data: message });\n },\n redirect: (path: string, opts?: { replace?: boolean }) => {\n throw tanstackRedirect({ to: path, replace: opts?.replace });\n },\n unauthorized: (message?: string) => {\n const origin = currentOrigin();\n const { pathname, searchStr } = getTwilightContext().location;\n const href =\n origin && loginRedirectHref({ pathname, searchStr, origin, base: resolveStoreBase() });\n // A full load, because the SDK only reads `intended_to` when a page starts.\n if (href) throw tanstackRedirect({ href, reloadDocument: true, replace: true });\n throw new UnauthorizedError(message);\n },\n});\n\n/**\n * TanStack navigation setup - wraps children with NavigationProvider and LinkProvider.\n * Called by TwilightProvider when client.framework === 'tanstack'.\n */\nexport function NavigationSetup({ children }: { children: ReactNode }) {\n const navigate = useNavigate();\n const { locale } = useParams({ strict: false }) as { locale?: string };\n const navigateFn = useCallback(\n (to: string, opts?: NavigateOptions) =>\n navigate({ to: localizeDestination(to, locale), replace: opts?.replace }),\n [navigate, locale]\n );\n\n return (\n <NavigationProvider navigate={navigateFn}>\n <LinkProvider adapter={TanStackLinkAdapter}>{children}</LinkProvider>\n </NavigationProvider>\n );\n}\n\n/** @deprecated Use NavigationSetup instead */\nexport function TanStackNavigationProvider({ children }: { children: ReactNode }) {\n const navigate = useNavigate();\n return (\n <NavigationProvider\n navigate={(to: string, opts?: NavigateOptions) => navigate({ to, replace: opts?.replace })}\n >\n <LinkProvider adapter={TanStackLinkAdapter}>{children}</LinkProvider>\n </NavigationProvider>\n );\n}\n"]}
|
|
@@ -4,7 +4,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
4
4
|
export { BlogSkeleton, BreadcrumbSkeleton, CustomerLayoutSkeleton, CustomerPageSkeleton, PageSkeleton, ProductCardSkeleton, ProductDetailSkeleton, ProductGridSkeleton, SkeletonPulse } from '@salla.sa/twilight-components-react';
|
|
5
5
|
|
|
6
6
|
var LazyBreadcrumb = lazy(
|
|
7
|
-
() => import('./Breadcrumb-
|
|
7
|
+
() => import('./Breadcrumb-NXXVZJJD.js').then((m) => ({ default: m.Breadcrumb }))
|
|
8
8
|
);
|
|
9
9
|
var LazyNoContent = lazy(
|
|
10
10
|
() => import('./NoContent-63TMCPGY.js').then((m) => ({ default: m.NoContent }))
|
|
@@ -151,5 +151,5 @@ function DeferredData({ promise, fallback, children }) {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
export { DeferredData, Image, LazyBreadcrumb, LazyCurrencySymbol, LazyErrorPage, LazyNoContent, LazyRenderWhenVisible, resolveDeferred };
|
|
154
|
-
//# sourceMappingURL=chunk-
|
|
155
|
-
//# sourceMappingURL=chunk-
|
|
154
|
+
//# sourceMappingURL=chunk-TLAEW7TB.js.map
|
|
155
|
+
//# sourceMappingURL=chunk-TLAEW7TB.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/common/lazy.ts","../src/components/common/Image.tsx","../src/components/common/DeferredData.tsx"],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,YAAY,CAAA;AACnC,EAAA,IAAI,KAAA,EAAO,MAAA,KAAW,SAAA,EAAW,OAAO,KAAA,CAAM,KAAA;AAC9C,EAAA,OAAO,cAAA;AACT;AAEO,SAAS,YAAA,CAAgB,EAAE,OAAA,EAAS,QAAA,EAAU,UAAS,EAAyB;AACrF,EAAA,IAAI,EAAE,mBAAmB,OAAA,CAAA,EAAU;AACjC,IAAA,OAAO,SAAS,OAAO,CAAA;AAAA,EACzB;AAEA,EAAA,IAAI,YAAA,IAAgB,OAAA,YAAmB,OAAA,EAAS,YAAA,CAAa,IAAI,OAAO,CAAA;AAExE,EAAA,MAAM,QAAA,GAAW,MAAM,OAAO,CAAA;AAC9B,EAAA,MAAM,KAAA,GAAQ,SAAS,YAAY,CAAA;AAEnC,EAAA,IAAI,KAAA,EAAO,WAAW,SAAA,EAAW;AAC/B,IAAA,OAAO,QAAA,CAAS,MAAM,KAAM,CAAA;AAAA,EAC9B;AAEA,EAAA,IAAI,KAAA,EAAO,WAAW,OAAA,EAAS;AAC7B,IAAA,MAAM,KAAA,CAAM,KAAA;AAAA,EACd;AAEA,EAAA,uBACEA,GAAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,0BACEA,GAAAA,CAAC,oBAAiB,OAAA,EAAS,QAAA,EAAU,UAClC,QAAA,EACH,CAAA;AAAA,MAGF,QAAA,kBAAAA,GAAAA,CAAC,gBAAA,EAAA,EAAiB,OAAA,EAAS,UAAW,QAAA,EAAS;AAAA;AAAA,GACjD;AAEJ","file":"chunk-JMBO6VHQ.js","sourcesContent":["import { lazy } from 'react';\n\n/**\n * Lazy-loaded common components\n * Use these for code-splitting non-critical components\n *\n * NOTE: Skeleton components are sourced from @salla.sa/twilight-components-react\n * because they must render instantly during route transitions.\n */\nexport const LazyBreadcrumb = lazy(() =>\n import('./Breadcrumb').then((m) => ({ default: m.Breadcrumb }))\n);\n\nexport const LazyNoContent = lazy(() =>\n import('./NoContent').then((m) => ({ default: m.NoContent }))\n);\n\nexport const LazyRenderWhenVisible = lazy(() =>\n import('./RenderWhenVisible').then((m) => ({ default: m.RenderWhenVisible }))\n);\n\nexport const LazyCurrencySymbol = lazy(() =>\n import('./CurrencySymbol').then((m) => ({ default: m.CurrencySymbol }))\n);\n\nexport const LazyErrorPage = lazy(() =>\n import('./ErrorPage').then((m) => ({ default: m.ErrorPage }))\n);\n","import { memo } from 'react';\nimport { getCdnImageSrcSet, getCdnImageUrl } from '../../utils/cdn-image';\n\nexport interface ImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {\n /** Image source URL */\n src?: string;\n /** Alt text for accessibility */\n alt: string;\n /** Whether this image is above the fold / LCP candidate */\n priority?: boolean;\n /** Aspect ratio for CLS prevention (e.g. \"16/9\", \"1/1\", \"4/3\") */\n aspectRatio?: string;\n /** Object fit mode */\n objectFit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';\n /** Mobile image source for <picture> element */\n mobileSrc?: string;\n /** Mobile breakpoint for <source> media query (default: 768px) */\n mobileBreakpoint?: number;\n /** Skip the wrapper div */\n noWrapper?: boolean;\n /**\n * CDN widths for a density `srcset`. Pass `sizes` so the browser picks a\n * candidate close to the displayed CSS size.\n */\n srcSetWidths?: readonly number[];\n}\n\n/**\n * Optimized Image component with native browser lazy loading.\n *\n * - Uses `loading=\"lazy\"` + `decoding=\"async\"` by default for below-the-fold images.\n * - Uses `loading=\"eager\"` + `fetchPriority=\"high\"` for priority (above-the-fold / LCP) images.\n * - Supports responsive `<picture>` with mobile source.\n * - Provides `aspectRatio` for CLS prevention.\n * - When `srcSetWidths` + `sizes` are set, emits a sized CDN `srcset`.\n */\nexport const Image = memo(function Image({\n src,\n alt,\n priority = false,\n aspectRatio,\n objectFit = 'cover',\n mobileSrc,\n mobileBreakpoint = 768,\n noWrapper = false,\n className = '',\n style,\n width,\n height,\n sizes,\n srcSet: srcSetProp,\n srcSetWidths,\n ...rest\n}: ImageProps) {\n if (!src) return null;\n\n const generatedSrcSet =\n srcSetProp || (srcSetWidths?.length ? getCdnImageSrcSet(src, srcSetWidths) : undefined);\n const generatedMobileSrcSet =\n srcSetWidths?.length && mobileSrc ? getCdnImageSrcSet(mobileSrc, srcSetWidths) : undefined;\n const cdnWidth = srcSetWidths?.length\n ? width != null && srcSetWidths.includes(Number(width))\n ? Number(width)\n : srcSetWidths[0]\n : width;\n // Width-only CDN URLs so `src` matches a srcset candidate for preload.\n const cdnOptions = generatedSrcSet ? { width: cdnWidth } : { width: cdnWidth, height };\n\n const optimizedSrc = getCdnImageUrl(src, cdnOptions);\n const optimizedMobileSrc = getCdnImageUrl(mobileSrc, cdnOptions);\n\n const objectFitClass = `object-${objectFit}`;\n const imgClasses = [className, objectFitClass].filter(Boolean).join(' ');\n\n const loadingProps: React.ImgHTMLAttributes<HTMLImageElement> = priority\n ? { loading: 'eager' as const, fetchPriority: 'high' as const, decoding: 'sync' as const }\n : { loading: 'lazy' as const, decoding: 'async' as const };\n\n const img = (\n <img\n src={optimizedSrc}\n alt={alt}\n className={imgClasses}\n width={width}\n height={height}\n sizes={sizes}\n srcSet={generatedSrcSet}\n {...loadingProps}\n {...rest}\n />\n );\n\n const imgElement = optimizedMobileSrc ? (\n <picture>\n <source\n media={`(max-width: ${mobileBreakpoint}px)`}\n srcSet={generatedMobileSrcSet || optimizedMobileSrc}\n sizes={generatedMobileSrcSet ? sizes : undefined}\n />\n {img}\n </picture>\n ) : (\n img\n );\n\n if (noWrapper || !aspectRatio) {\n return imgElement;\n }\n\n return (\n <div className=\"relative overflow-hidden\" style={{ aspectRatio, ...style }}>\n {imgElement}\n </div>\n );\n});\n","import { Suspense, memo, use, type ReactNode } from 'react';\n\nexport interface DeferredDataProps<T> {\n promise: Promise<T> | T;\n fallback: ReactNode;\n children: (data: T) => ReactNode;\n}\n\nconst DEFERRED_KEY = Symbol.for('twilight.deferred');\n\ninterface DeferredState<T> {\n status: 'pending' | 'success' | 'error';\n value?: T;\n error?: unknown;\n}\n\nexport interface DeferredPromise<T> extends Promise<T> {\n [DEFERRED_KEY]?: DeferredState<T>;\n}\n\nconst seenPromises = typeof WeakSet !== 'undefined' ? new WeakSet() : null;\n\nfunction defer<T>(promise: Promise<T>): DeferredPromise<T> {\n const existing = (promise as DeferredPromise<T>)[DEFERRED_KEY];\n if (existing) return promise as DeferredPromise<T>;\n\n const state: DeferredState<T> = { status: 'pending' };\n\n const deferred = promise as DeferredPromise<T>;\n deferred[DEFERRED_KEY] = state;\n\n promise.then(\n (value) => {\n state.status = 'success';\n state.value = value;\n },\n (error) => {\n state.status = 'error';\n state.error = error;\n }\n );\n\n return deferred;\n}\n\nconst DeferredRenderer = memo(function DeferredRenderer<T>({\n promise,\n children,\n}: {\n promise: DeferredPromise<T>;\n children: (data: T) => ReactNode;\n}) {\n const state = promise[DEFERRED_KEY];\n\n if (state?.status === 'success') {\n return children(state.value!);\n }\n\n if (state?.status === 'error') {\n throw state.error;\n }\n\n const data = use(promise);\n return children(data);\n}) as <T>(props: { promise: DeferredPromise<T>; children: (data: T) => ReactNode }) => ReactNode;\n\nfunction DeferredFallback<T>({\n promise,\n fallback,\n children,\n}: {\n promise: DeferredPromise<T>;\n fallback: ReactNode;\n children: (data: T) => ReactNode;\n}) {\n const state = promise[DEFERRED_KEY];\n if (state?.status === 'success') {\n return children(state.value!);\n }\n return <>{fallback}</>;\n}\n\nexport function resolveDeferred<T>(\n promiseOrValue: Promise<T> | T | undefined\n): T | Promise<T> | undefined {\n if (promiseOrValue == null || !(promiseOrValue instanceof Promise)) return promiseOrValue;\n const deferred = defer(promiseOrValue);\n const state = deferred[DEFERRED_KEY];\n if (state?.status === 'success') return state.value as T;\n return promiseOrValue;\n}\n\nexport function DeferredData<T>({ promise, fallback, children }: DeferredDataProps<T>) {\n if (!(promise instanceof Promise)) {\n return children(promise);\n }\n\n if (seenPromises && promise instanceof Promise) seenPromises.add(promise);\n\n const deferred = defer(promise);\n const state = deferred[DEFERRED_KEY];\n\n if (state?.status === 'success') {\n return children(state.value!);\n }\n\n if (state?.status === 'error') {\n throw state.error;\n }\n\n return (\n <Suspense\n fallback={\n <DeferredFallback promise={deferred} fallback={fallback}>\n {children}\n </DeferredFallback>\n }\n >\n <DeferredRenderer promise={deferred}>{children}</DeferredRenderer>\n </Suspense>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/common/lazy.ts","../src/components/common/Image.tsx","../src/components/common/DeferredData.tsx"],"names":["Image","memo","DeferredRenderer","jsx"],"mappings":";;;;;AASO,IAAM,cAAA,GAAiB,IAAA;AAAA,EAAK,MACjC,OAAO,0BAAc,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,UAAA,EAAW,CAAE;AAChE;AAEO,IAAM,aAAA,GAAgB,IAAA;AAAA,EAAK,MAChC,OAAO,yBAAa,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,SAAA,EAAU,CAAE;AAC9D;AAEO,IAAM,qBAAA,GAAwB,IAAA;AAAA,EAAK,MACxC,OAAO,iCAAqB,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,iBAAA,EAAkB,CAAE;AAC9E;AAEO,IAAM,kBAAA,GAAqB,IAAA;AAAA,EAAK,MACrC,OAAO,8BAAkB,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,cAAA,EAAe,CAAE;AACxE;AAEO,IAAM,aAAA,GAAgB,IAAA;AAAA,EAAK,MAChC,OAAO,yBAAa,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,SAAA,EAAU,CAAE;AAC9D;ACSO,IAAM,KAAA,GAAQ,IAAA,CAAK,SAASA,MAAAA,CAAM;AAAA,EACvC,GAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA,GAAW,KAAA;AAAA,EACX,WAAA;AAAA,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\n/**\n * Lazy-loaded common components\n * Use these for code-splitting non-critical components\n *\n * NOTE: Skeleton components are sourced from @salla.sa/twilight-components-react\n * because they must render instantly during route transitions.\n */\nexport const LazyBreadcrumb = lazy(() =>\n import('./Breadcrumb').then((m) => ({ default: m.Breadcrumb }))\n);\n\nexport const LazyNoContent = lazy(() =>\n import('./NoContent').then((m) => ({ default: m.NoContent }))\n);\n\nexport const LazyRenderWhenVisible = lazy(() =>\n import('./RenderWhenVisible').then((m) => ({ default: m.RenderWhenVisible }))\n);\n\nexport const LazyCurrencySymbol = lazy(() =>\n import('./CurrencySymbol').then((m) => ({ default: m.CurrencySymbol }))\n);\n\nexport const LazyErrorPage = lazy(() =>\n import('./ErrorPage').then((m) => ({ default: m.ErrorPage }))\n);\n","import { memo } from 'react';\nimport { getCdnImageSrcSet, getCdnImageUrl } from '../../utils/cdn-image';\n\nexport interface ImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {\n /** Image source URL */\n src?: string;\n /** Alt text for accessibility */\n alt: string;\n /** Whether this image is above the fold / LCP candidate */\n priority?: boolean;\n /** Aspect ratio for CLS prevention (e.g. \"16/9\", \"1/1\", \"4/3\") */\n aspectRatio?: string;\n /** Object fit mode */\n objectFit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';\n /** Mobile image source for <picture> element */\n mobileSrc?: string;\n /** Mobile breakpoint for <source> media query (default: 768px) */\n mobileBreakpoint?: number;\n /** Skip the wrapper div */\n noWrapper?: boolean;\n /**\n * CDN widths for a density `srcset`. Pass `sizes` so the browser picks a\n * candidate close to the displayed CSS size.\n */\n srcSetWidths?: readonly number[];\n}\n\n/**\n * Optimized Image component with native browser lazy loading.\n *\n * - Uses `loading=\"lazy\"` + `decoding=\"async\"` by default for below-the-fold images.\n * - Uses `loading=\"eager\"` + `fetchPriority=\"high\"` for priority (above-the-fold / LCP) images.\n * - Supports responsive `<picture>` with mobile source.\n * - Provides `aspectRatio` for CLS prevention.\n * - When `srcSetWidths` + `sizes` are set, emits a sized CDN `srcset`.\n */\nexport const Image = memo(function Image({\n src,\n alt,\n priority = false,\n aspectRatio,\n objectFit = 'cover',\n mobileSrc,\n mobileBreakpoint = 768,\n noWrapper = false,\n className = '',\n style,\n width,\n height,\n sizes,\n srcSet: srcSetProp,\n srcSetWidths,\n ...rest\n}: ImageProps) {\n if (!src) return null;\n\n const generatedSrcSet =\n srcSetProp || (srcSetWidths?.length ? getCdnImageSrcSet(src, srcSetWidths) : undefined);\n const generatedMobileSrcSet =\n srcSetWidths?.length && mobileSrc ? getCdnImageSrcSet(mobileSrc, srcSetWidths) : undefined;\n const cdnWidth = srcSetWidths?.length\n ? width != null && srcSetWidths.includes(Number(width))\n ? Number(width)\n : srcSetWidths[0]\n : width;\n // Width-only CDN URLs so `src` matches a srcset candidate for preload.\n const cdnOptions = generatedSrcSet ? { width: cdnWidth } : { width: cdnWidth, height };\n\n const optimizedSrc = getCdnImageUrl(src, cdnOptions);\n const optimizedMobileSrc = getCdnImageUrl(mobileSrc, cdnOptions);\n\n const objectFitClass = `object-${objectFit}`;\n const imgClasses = [className, objectFitClass].filter(Boolean).join(' ');\n\n const loadingProps: React.ImgHTMLAttributes<HTMLImageElement> = priority\n ? { loading: 'eager' as const, fetchPriority: 'high' as const, decoding: 'sync' as const }\n : { loading: 'lazy' as const, decoding: 'async' as const };\n\n const img = (\n <img\n src={optimizedSrc}\n alt={alt}\n className={imgClasses}\n width={width}\n height={height}\n sizes={sizes}\n srcSet={generatedSrcSet}\n {...loadingProps}\n {...rest}\n />\n );\n\n const imgElement = optimizedMobileSrc ? (\n <picture>\n <source\n media={`(max-width: ${mobileBreakpoint}px)`}\n srcSet={generatedMobileSrcSet || optimizedMobileSrc}\n sizes={generatedMobileSrcSet ? sizes : undefined}\n />\n {img}\n </picture>\n ) : (\n img\n );\n\n if (noWrapper || !aspectRatio) {\n return imgElement;\n }\n\n return (\n <div className=\"relative overflow-hidden\" style={{ aspectRatio, ...style }}>\n {imgElement}\n </div>\n );\n});\n","import { Suspense, memo, use, type ReactNode } from 'react';\n\nexport interface DeferredDataProps<T> {\n promise: Promise<T> | T;\n fallback: ReactNode;\n children: (data: T) => ReactNode;\n}\n\nconst DEFERRED_KEY = Symbol.for('twilight.deferred');\n\ninterface DeferredState<T> {\n status: 'pending' | 'success' | 'error';\n value?: T;\n error?: unknown;\n}\n\nexport interface DeferredPromise<T> extends Promise<T> {\n [DEFERRED_KEY]?: DeferredState<T>;\n}\n\nconst seenPromises = typeof WeakSet !== 'undefined' ? new WeakSet() : null;\n\nfunction defer<T>(promise: Promise<T>): DeferredPromise<T> {\n const existing = (promise as DeferredPromise<T>)[DEFERRED_KEY];\n if (existing) return promise as DeferredPromise<T>;\n\n const state: DeferredState<T> = { status: 'pending' };\n\n const deferred = promise as DeferredPromise<T>;\n deferred[DEFERRED_KEY] = state;\n\n promise.then(\n (value) => {\n state.status = 'success';\n state.value = value;\n },\n (error) => {\n state.status = 'error';\n state.error = error;\n }\n );\n\n return deferred;\n}\n\nconst DeferredRenderer = memo(function DeferredRenderer<T>({\n promise,\n children,\n}: {\n promise: DeferredPromise<T>;\n children: (data: T) => ReactNode;\n}) {\n const state = promise[DEFERRED_KEY];\n\n if (state?.status === 'success') {\n return children(state.value!);\n }\n\n if (state?.status === 'error') {\n throw state.error;\n }\n\n const data = use(promise);\n return children(data);\n}) as <T>(props: { promise: DeferredPromise<T>; children: (data: T) => ReactNode }) => ReactNode;\n\nfunction DeferredFallback<T>({\n promise,\n fallback,\n children,\n}: {\n promise: DeferredPromise<T>;\n fallback: ReactNode;\n children: (data: T) => ReactNode;\n}) {\n const state = promise[DEFERRED_KEY];\n if (state?.status === 'success') {\n return children(state.value!);\n }\n return <>{fallback}</>;\n}\n\nexport function resolveDeferred<T>(\n promiseOrValue: Promise<T> | T | undefined\n): T | Promise<T> | undefined {\n if (promiseOrValue == null || !(promiseOrValue instanceof Promise)) return promiseOrValue;\n const deferred = defer(promiseOrValue);\n const state = deferred[DEFERRED_KEY];\n if (state?.status === 'success') return state.value as T;\n return promiseOrValue;\n}\n\nexport function DeferredData<T>({ promise, fallback, children }: DeferredDataProps<T>) {\n if (!(promise instanceof Promise)) {\n return children(promise);\n }\n\n if (seenPromises && promise instanceof Promise) seenPromises.add(promise);\n\n const deferred = defer(promise);\n const state = deferred[DEFERRED_KEY];\n\n if (state?.status === 'success') {\n return children(state.value!);\n }\n\n if (state?.status === 'error') {\n throw state.error;\n }\n\n return (\n <Suspense\n fallback={\n <DeferredFallback promise={deferred} fallback={fallback}>\n {children}\n </DeferredFallback>\n }\n >\n <DeferredRenderer promise={deferred}>{children}</DeferredRenderer>\n </Suspense>\n );\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { orThrow } from './chunk-
|
|
2
|
-
import { getActiveScope, api } from './chunk-
|
|
3
|
-
import { getTwilightContext } from './chunk-
|
|
1
|
+
import { orThrow } from './chunk-WH225GEC.js';
|
|
2
|
+
import { getActiveScope, api } from './chunk-P3OPJL6I.js';
|
|
3
|
+
import { getTwilightContext } from './chunk-N2S25NXP.js';
|
|
4
4
|
import { defaultShouldDehydrateQuery, queryOptions } from '@tanstack/react-query';
|
|
5
5
|
|
|
6
6
|
function queryClientOrNull() {
|
|
@@ -174,5 +174,5 @@ var product = {
|
|
|
174
174
|
};
|
|
175
175
|
|
|
176
176
|
export { getProductPreview, isProductPreviewQuery, product, productDetailQueryKey, productPreviewQueryKey, rememberProductPreview, shouldDehydrateQuery };
|
|
177
|
-
//# sourceMappingURL=chunk-
|
|
178
|
-
//# sourceMappingURL=chunk-
|
|
177
|
+
//# sourceMappingURL=chunk-TLO2M5TJ.js.map
|
|
178
|
+
//# sourceMappingURL=chunk-TLO2M5TJ.js.map
|