@salla.sa/twilight-theme-engine 1.0.74 → 1.0.76
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-H2PRWRO7.js → AddToCartForm-ELTXWGK7.js} +3 -3
- package/dist/{AddToCartForm-H2PRWRO7.js.map → AddToCartForm-ELTXWGK7.js.map} +1 -1
- package/dist/{BlogAuthorPage-QDGBWGGT.js → BlogAuthorPage-MBVZGSPQ.js} +19 -20
- package/dist/BlogAuthorPage-MBVZGSPQ.js.map +1 -0
- package/dist/{BlogCategoryPage-BK4OL6T4.js → BlogCategoryPage-V4HHHLCL.js} +19 -20
- package/dist/BlogCategoryPage-V4HHHLCL.js.map +1 -0
- package/dist/{BlogPage-5LLIKUOQ.js → BlogPage-LWRXQVF6.js} +17 -18
- package/dist/BlogPage-LWRXQVF6.js.map +1 -0
- package/dist/{BlogSinglePage-3BDXSFTY.js → BlogSinglePage-DPO6N4BK.js} +17 -18
- package/dist/BlogSinglePage-DPO6N4BK.js.map +1 -0
- package/dist/{BlogTagPage-S77JPNEZ.js → BlogTagPage-QCV2BNEV.js} +19 -20
- package/dist/BlogTagPage-QCV2BNEV.js.map +1 -0
- package/dist/{BrandsPage-2TJALMEG.js → BrandsPage-YECC2M27.js} +18 -19
- package/dist/BrandsPage-YECC2M27.js.map +1 -0
- package/dist/{Breadcrumb-SXC43X3D.js → Breadcrumb-ENQ4QMRD.js} +17 -18
- package/dist/Breadcrumb-ENQ4QMRD.js.map +1 -0
- package/dist/{CartItem-R6BYAM4O.js → CartItem-4CPUCDZE.js} +17 -18
- package/dist/CartItem-4CPUCDZE.js.map +1 -0
- package/dist/{CartSummary-YQ2RMHID.js → CartSummary-XSFNCT5V.js} +17 -18
- package/dist/CartSummary-XSFNCT5V.js.map +1 -0
- package/dist/{Copyright-5VLQICDY.js → Copyright-OJ2EKXRI.js} +3 -3
- package/dist/{Copyright-5VLQICDY.js.map → Copyright-OJ2EKXRI.js.map} +1 -1
- package/dist/{CustomerLayout-DUT7BEKW.js → CustomerLayout-UPXQEA26.js} +17 -18
- package/dist/CustomerLayout-UPXQEA26.js.map +1 -0
- package/dist/{Footer-J2KXYFB3.js → Footer-4CAAFHB2.js} +17 -18
- package/dist/{Footer-J2KXYFB3.js.map → Footer-4CAAFHB2.js.map} +1 -1
- package/dist/{Header-GZQINLEQ.js → Header-HDYYP4C6.js} +7 -6
- package/dist/{Header-GZQINLEQ.js.map → Header-HDYYP4C6.js.map} +1 -1
- package/dist/{LoyaltyPage-IXLUF6MF.js → LoyaltyPage-AOHHLCLU.js} +17 -18
- package/dist/LoyaltyPage-AOHHLCLU.js.map +1 -0
- package/dist/{LoyaltyPointsPage-RDNXI5VY.js → LoyaltyPointsPage-XWRBDU27.js} +3 -3
- package/dist/{LoyaltyPointsPage-RDNXI5VY.js.map → LoyaltyPointsPage-XWRBDU27.js.map} +1 -1
- package/dist/{MainMenu-KNJDJFJX.js → MainMenu-CTRSU7ZV.js} +6 -7
- package/dist/MainMenu-CTRSU7ZV.js.map +1 -0
- package/dist/{MasterLayout-MFL2NYPF.js → MasterLayout-PRM5ELY3.js} +17 -18
- package/dist/{MasterLayout-MFL2NYPF.js.map → MasterLayout-PRM5ELY3.js.map} +1 -1
- package/dist/{MobileMenu-RXLYUAWL.js → MobileMenu-3YHFM2UF.js} +18 -19
- package/dist/MobileMenu-3YHFM2UF.js.map +1 -0
- package/dist/{NotificationsPage-QSF7S2PD.js → NotificationsPage-F344UHAJ.js} +17 -18
- package/dist/NotificationsPage-F344UHAJ.js.map +1 -0
- package/dist/{OrderSinglePage-CWBHU2C6.js → OrderSinglePage-YX7NRH6P.js} +18 -19
- package/dist/OrderSinglePage-YX7NRH6P.js.map +1 -0
- package/dist/{OrdersPage-L76IEAXR.js → OrdersPage-TDZ3OX3J.js} +17 -18
- package/dist/OrdersPage-TDZ3OX3J.js.map +1 -0
- package/dist/{PageSingle-BUAZBPIQ.js → PageSingle-U5XNYQ6W.js} +5 -6
- package/dist/PageSingle-U5XNYQ6W.js.map +1 -0
- package/dist/{ProductDetails-MPNSWRTQ.js → ProductDetails-KLJDRLJ6.js} +6 -7
- package/dist/ProductDetails-KLJDRLJ6.js.map +1 -0
- package/dist/{ProfilePage-I72265CD.js → ProfilePage-Z6YJQ6C2.js} +17 -18
- package/dist/ProfilePage-Z6YJQ6C2.js.map +1 -0
- package/dist/{ReviewsPage-M5GNHNZG.js → ReviewsPage-A2PZTDEA.js} +3 -3
- package/dist/{ReviewsPage-M5GNHNZG.js.map → ReviewsPage-A2PZTDEA.js.map} +1 -1
- package/dist/{SeoCartWidget-KV3T3BO7.js → SeoCartWidget-MDNO2GBO.js} +17 -18
- package/dist/SeoCartWidget-MDNO2GBO.js.map +1 -0
- package/dist/{SettingsPage-3F5HZNXX.js → SettingsPage-JKC3CLCB.js} +17 -18
- package/dist/SettingsPage-JKC3CLCB.js.map +1 -0
- package/dist/{StoreClosedNotification-65QIOIAM.js → StoreClosedNotification-E3E4C5G7.js} +18 -19
- package/dist/{StoreClosedNotification-65QIOIAM.js.map → StoreClosedNotification-E3E4C5G7.js.map} +1 -1
- package/dist/{TestimonialsPage-5U7PH4TT.js → TestimonialsPage-TIFOLC6V.js} +5 -6
- package/dist/TestimonialsPage-TIFOLC6V.js.map +1 -0
- package/dist/{ThankYouPage-HFUTJCRT.js → ThankYouPage-XYKVHOJ4.js} +17 -18
- package/dist/ThankYouPage-XYKVHOJ4.js.map +1 -0
- package/dist/{WalletPage-KURO6WSP.js → WalletPage-KTDDXEEZ.js} +18 -19
- package/dist/WalletPage-KTDDXEEZ.js.map +1 -0
- package/dist/{WishlistPage-RLUK4JRD.js → WishlistPage-4JEBFBW4.js} +19 -20
- package/dist/WishlistPage-4JEBFBW4.js.map +1 -0
- package/dist/api/apps.js +3 -4
- package/dist/api/blog.js +4 -5
- package/dist/api/brands.js +4 -5
- package/dist/api/cart.js +4 -5
- package/dist/api/category.js +4 -5
- package/dist/api/client.js +2 -3
- package/dist/api/home.js +3 -4
- package/dist/api/loyalty.js +4 -5
- package/dist/api/menu.js +3 -4
- package/dist/api/notification.js +3 -4
- package/dist/api/order.js +4 -5
- package/dist/api/page.js +4 -5
- package/dist/api/product.js +4 -5
- package/dist/api/profile.js +2 -3
- package/dist/api/profile.js.map +1 -1
- package/dist/api/store.js +3 -4
- package/dist/api/translations.js +3 -4
- package/dist/api/user.js +3 -4
- package/dist/api/wallet.js +3 -4
- package/dist/api/wishlist.js +5 -6
- package/dist/{chunk-E5O5ICIY.js → chunk-2APQP7KK.js} +4 -4
- package/dist/{chunk-E5O5ICIY.js.map → chunk-2APQP7KK.js.map} +1 -1
- package/dist/{chunk-PNM4NP4U.js → chunk-3GZ5OOAK.js} +3 -3
- package/dist/{chunk-PNM4NP4U.js.map → chunk-3GZ5OOAK.js.map} +1 -1
- package/dist/{chunk-2OYXPNCE.js → chunk-3UMHUKMJ.js} +3 -3
- package/dist/{chunk-2OYXPNCE.js.map → chunk-3UMHUKMJ.js.map} +1 -1
- package/dist/{chunk-Y5OGXJLH.js → chunk-4A5IAMNL.js} +196 -4
- package/dist/chunk-4A5IAMNL.js.map +1 -0
- package/dist/{chunk-D2T6246Q.js → chunk-7FDT2IFI.js} +3 -3
- package/dist/{chunk-D2T6246Q.js.map → chunk-7FDT2IFI.js.map} +1 -1
- package/dist/{chunk-VYCNB6VN.js → chunk-7HWX2PEO.js} +3 -3
- package/dist/{chunk-VYCNB6VN.js.map → chunk-7HWX2PEO.js.map} +1 -1
- package/dist/{chunk-IK57LAIA.js → chunk-BP6LUZXJ.js} +10 -5
- package/dist/chunk-BP6LUZXJ.js.map +1 -0
- package/dist/{chunk-FVDUTMH6.js → chunk-DUA2GB5Z.js} +4 -4
- package/dist/{chunk-FVDUTMH6.js.map → chunk-DUA2GB5Z.js.map} +1 -1
- package/dist/{chunk-R72Q5Z6M.js → chunk-EUWKQJNI.js} +4 -4
- package/dist/{chunk-R72Q5Z6M.js.map → chunk-EUWKQJNI.js.map} +1 -1
- package/dist/{chunk-3TJKB3WR.js → chunk-F2YLRVPH.js} +3 -3
- package/dist/{chunk-3TJKB3WR.js.map → chunk-F2YLRVPH.js.map} +1 -1
- package/dist/{chunk-JEG5WPNT.js → chunk-F4FCETQT.js} +3 -3
- package/dist/{chunk-JEG5WPNT.js.map → chunk-F4FCETQT.js.map} +1 -1
- package/dist/{chunk-3QT7JMAD.js → chunk-FSCIJ55A.js} +4 -4
- package/dist/{chunk-3QT7JMAD.js.map → chunk-FSCIJ55A.js.map} +1 -1
- package/dist/{chunk-FIFNYC7B.js → chunk-H2CED43W.js} +7 -7
- package/dist/{chunk-FIFNYC7B.js.map → chunk-H2CED43W.js.map} +1 -1
- package/dist/{chunk-P2YAPWMS.js → chunk-HZYFU3PZ.js} +4 -4
- package/dist/{chunk-P2YAPWMS.js.map → chunk-HZYFU3PZ.js.map} +1 -1
- package/dist/{chunk-3EBAXWBJ.js → chunk-J2VJGXIX.js} +5 -5
- package/dist/{chunk-3EBAXWBJ.js.map → chunk-J2VJGXIX.js.map} +1 -1
- package/dist/{chunk-WHGOO4A2.js → chunk-L4EX7DLC.js} +6 -6
- package/dist/{chunk-WHGOO4A2.js.map → chunk-L4EX7DLC.js.map} +1 -1
- package/dist/{chunk-RYSJOCHI.js → chunk-LCDSHSP7.js} +3 -3
- package/dist/{chunk-RYSJOCHI.js.map → chunk-LCDSHSP7.js.map} +1 -1
- package/dist/{chunk-JAPH535M.js → chunk-LL3X2N7L.js} +4 -4
- package/dist/{chunk-JAPH535M.js.map → chunk-LL3X2N7L.js.map} +1 -1
- package/dist/{chunk-E7EBWXCA.js → chunk-LLQE4JAW.js} +3 -3
- package/dist/{chunk-E7EBWXCA.js.map → chunk-LLQE4JAW.js.map} +1 -1
- package/dist/{chunk-IDY6OEXA.js → chunk-MCZJEDPZ.js} +7 -7
- package/dist/{chunk-IDY6OEXA.js.map → chunk-MCZJEDPZ.js.map} +1 -1
- package/dist/{chunk-2ZQKAGSZ.js → chunk-MHVR2OUR.js} +4 -4
- package/dist/{chunk-2ZQKAGSZ.js.map → chunk-MHVR2OUR.js.map} +1 -1
- package/dist/{chunk-4YVGMXG7.js → chunk-MOANE2YM.js} +3 -3
- package/dist/{chunk-4YVGMXG7.js.map → chunk-MOANE2YM.js.map} +1 -1
- package/dist/{chunk-TWVTIAMO.js → chunk-MYJL5MGW.js} +3 -3
- package/dist/{chunk-TWVTIAMO.js.map → chunk-MYJL5MGW.js.map} +1 -1
- package/dist/{chunk-MEMB7JYJ.js → chunk-NDJWR7EF.js} +4 -4
- package/dist/{chunk-MEMB7JYJ.js.map → chunk-NDJWR7EF.js.map} +1 -1
- package/dist/{chunk-WS3WQ3OL.js → chunk-NJWKVTQD.js} +4 -4
- package/dist/{chunk-WS3WQ3OL.js.map → chunk-NJWKVTQD.js.map} +1 -1
- package/dist/{chunk-XN7TVPAU.js → chunk-O6L3BZBB.js} +4 -4
- package/dist/{chunk-XN7TVPAU.js.map → chunk-O6L3BZBB.js.map} +1 -1
- package/dist/{chunk-6KVB2WHE.js → chunk-ODF4CAF4.js} +4 -4
- package/dist/{chunk-6KVB2WHE.js.map → chunk-ODF4CAF4.js.map} +1 -1
- package/dist/{chunk-JHCLU3PS.js → chunk-OXQL57QN.js} +8 -8
- package/dist/{chunk-JHCLU3PS.js.map → chunk-OXQL57QN.js.map} +1 -1
- package/dist/{chunk-JNZLH2OR.js → chunk-PVNF6JXS.js} +7 -7
- package/dist/{chunk-JNZLH2OR.js.map → chunk-PVNF6JXS.js.map} +1 -1
- package/dist/{chunk-3EHECJ7M.js → chunk-RA2CIT7N.js} +4 -4
- package/dist/{chunk-3EHECJ7M.js.map → chunk-RA2CIT7N.js.map} +1 -1
- package/dist/chunk-RL4WOX4L.js +14 -0
- package/dist/{chunk-WG47KLHH.js.map → chunk-RL4WOX4L.js.map} +1 -1
- package/dist/{chunk-YUGZDWD6.js → chunk-RYFIWQ6L.js} +4 -4
- package/dist/{chunk-YUGZDWD6.js.map → chunk-RYFIWQ6L.js.map} +1 -1
- package/dist/{chunk-BLWLKRKH.js → chunk-S3R7B6QH.js} +17 -18
- package/dist/chunk-S3R7B6QH.js.map +1 -0
- package/dist/{chunk-5NUDOT33.js → chunk-SLXGP6KF.js} +3 -3
- package/dist/{chunk-5NUDOT33.js.map → chunk-SLXGP6KF.js.map} +1 -1
- package/dist/{chunk-6I4LWF5Y.js → chunk-UKVYP7ME.js} +3 -3
- package/dist/{chunk-6I4LWF5Y.js.map → chunk-UKVYP7ME.js.map} +1 -1
- package/dist/{chunk-OQA2MKZA.js → chunk-V76JM4UW.js} +60 -13
- package/dist/chunk-V76JM4UW.js.map +1 -0
- package/dist/{chunk-M6BXZTRK.js → chunk-VPNKJFT7.js} +3 -3
- package/dist/{chunk-M6BXZTRK.js.map → chunk-VPNKJFT7.js.map} +1 -1
- package/dist/{chunk-OKNJFS44.js → chunk-VPPSRRGK.js} +18 -4
- package/dist/chunk-VPPSRRGK.js.map +1 -0
- package/dist/{chunk-KO3HG5GQ.js → chunk-W3LADQOR.js} +3 -3
- package/dist/{chunk-KO3HG5GQ.js.map → chunk-W3LADQOR.js.map} +1 -1
- package/dist/{chunk-4VWWIA4M.js → chunk-WV3B2FOG.js} +4 -4
- package/dist/{chunk-4VWWIA4M.js.map → chunk-WV3B2FOG.js.map} +1 -1
- package/dist/{chunk-GFSTJ2PF.js → chunk-XON5AXAP.js} +3 -3
- package/dist/{chunk-GFSTJ2PF.js.map → chunk-XON5AXAP.js.map} +1 -1
- package/dist/{chunk-CJDAZQV6.js → chunk-YJAMQRFS.js} +5 -6
- package/dist/chunk-YJAMQRFS.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 +15 -16
- package/dist/components/home/index.js +19 -20
- package/dist/components/layout/index.js +1 -1
- package/dist/components/product/index.js +16 -17
- package/dist/components/store/index.js +17 -18
- package/dist/components/store/index.js.map +1 -1
- package/dist/components/toast/index.js +3 -4
- package/dist/components/toast/index.js.map +1 -1
- package/dist/document-class-SUOV33NA.js +24 -0
- package/dist/{document-class-5FTU6EZE.js.map → document-class-SUOV33NA.js.map} +1 -1
- package/dist/hooks/index.js +15 -16
- package/dist/hooks/useComments.js +2 -3
- package/dist/hooks/useGtm.js +15 -16
- package/dist/hooks/useMoney.js +15 -16
- package/dist/hooks/useProduct.js +2 -3
- package/dist/hooks/useStore.js +15 -16
- package/dist/hooks/useUser.js +4 -5
- package/dist/hooks/useWishlist.js +2 -3
- package/dist/index.js +15 -16
- package/dist/index.js.map +1 -1
- package/dist/native-app/index.js +2 -3
- package/dist/{navigation-CDITJYUW.js → navigation-KMDVLHXU.js} +7 -7
- package/dist/{navigation-CDITJYUW.js.map → navigation-KMDVLHXU.js.map} +1 -1
- package/dist/{navigation-WCGV6RUK.js → navigation-WEV6XJJT.js} +5 -4
- package/dist/navigation-WEV6XJJT.js.map +1 -0
- package/dist/{not-found-EL2XQE5D.js → not-found-M77B5UIT.js} +18 -19
- package/dist/not-found-M77B5UIT.js.map +1 -0
- package/dist/providers/NavigationProvider.d.ts +9 -0
- package/dist/providers/NavigationProvider.d.ts.map +1 -1
- package/dist/providers/index.js +15 -16
- package/dist/routes/account/orders.js +5 -6
- package/dist/routes/account.js +14 -15
- package/dist/routes/account.js.map +1 -1
- package/dist/routes/blog.js +9 -10
- package/dist/routes/blog.js.map +1 -1
- package/dist/routes/brands.js +5 -6
- package/dist/routes/brands.js.map +1 -1
- package/dist/routes/cart.js +23 -24
- package/dist/routes/cart.js.map +1 -1
- package/dist/routes/home.js +20 -21
- package/dist/routes/index.js +4 -3
- package/dist/routes/loyalty.js +6 -7
- package/dist/routes/loyalty.js.map +1 -1
- package/dist/routes/page.js +5 -6
- package/dist/routes/page.js.map +1 -1
- package/dist/routes/product-listing.js +21 -22
- package/dist/routes/product-listing.js.map +1 -1
- package/dist/routes/product.js +19 -20
- package/dist/routes/product.js.map +1 -1
- package/dist/routes/root/beforeLoad.d.ts +28 -0
- package/dist/routes/root/beforeLoad.d.ts.map +1 -1
- package/dist/routes/seo-redirects.js +4 -3
- package/dist/routes/testimonials.js +2 -2
- package/dist/routes/thank-you.js +5 -6
- package/dist/routes/thank-you.js.map +1 -1
- package/dist/skeleton.js +20 -21
- package/dist/tanstack/middleware/twilight.d.ts.map +1 -1
- package/dist/tanstack.js +15 -16
- package/dist/tanstack.js.map +1 -1
- package/dist/utils/cookies.d.ts +26 -0
- package/dist/utils/cookies.d.ts.map +1 -1
- package/dist/utils/index.js +4 -5
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/theme-version.d.ts +0 -29
- package/dist/utils/theme-version.d.ts.map +1 -1
- package/dist/vite/adapters/tanstack.adapter.d.ts.map +1 -1
- package/dist/vite/index.js +3 -1
- package/dist/vite/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/BlogAuthorPage-QDGBWGGT.js.map +0 -1
- package/dist/BlogCategoryPage-BK4OL6T4.js.map +0 -1
- package/dist/BlogPage-5LLIKUOQ.js.map +0 -1
- package/dist/BlogSinglePage-3BDXSFTY.js.map +0 -1
- package/dist/BlogTagPage-S77JPNEZ.js.map +0 -1
- package/dist/BrandsPage-2TJALMEG.js.map +0 -1
- package/dist/Breadcrumb-SXC43X3D.js.map +0 -1
- package/dist/CartItem-R6BYAM4O.js.map +0 -1
- package/dist/CartSummary-YQ2RMHID.js.map +0 -1
- package/dist/CustomerLayout-DUT7BEKW.js.map +0 -1
- package/dist/LoyaltyPage-IXLUF6MF.js.map +0 -1
- package/dist/MainMenu-KNJDJFJX.js.map +0 -1
- package/dist/MobileMenu-RXLYUAWL.js.map +0 -1
- package/dist/NotificationsPage-QSF7S2PD.js.map +0 -1
- package/dist/OrderSinglePage-CWBHU2C6.js.map +0 -1
- package/dist/OrdersPage-L76IEAXR.js.map +0 -1
- package/dist/PageSingle-BUAZBPIQ.js.map +0 -1
- package/dist/ProductDetails-MPNSWRTQ.js.map +0 -1
- package/dist/ProfilePage-I72265CD.js.map +0 -1
- package/dist/SeoCartWidget-KV3T3BO7.js.map +0 -1
- package/dist/SettingsPage-3F5HZNXX.js.map +0 -1
- package/dist/TestimonialsPage-5U7PH4TT.js.map +0 -1
- package/dist/ThankYouPage-HFUTJCRT.js.map +0 -1
- package/dist/WalletPage-KURO6WSP.js.map +0 -1
- package/dist/WishlistPage-RLUK4JRD.js.map +0 -1
- package/dist/chunk-BLWLKRKH.js.map +0 -1
- package/dist/chunk-CJDAZQV6.js.map +0 -1
- package/dist/chunk-IK57LAIA.js.map +0 -1
- package/dist/chunk-OKNJFS44.js.map +0 -1
- package/dist/chunk-OQA2MKZA.js.map +0 -1
- package/dist/chunk-P4GOLSA2.js +0 -166
- package/dist/chunk-P4GOLSA2.js.map +0 -1
- package/dist/chunk-WG47KLHH.js +0 -14
- package/dist/chunk-Y5OGXJLH.js.map +0 -1
- package/dist/document-class-5FTU6EZE.js +0 -25
- package/dist/navigation-WCGV6RUK.js.map +0 -1
- package/dist/not-found-EL2XQE5D.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useIsHome } from './chunk-
|
|
1
|
+
import { useIsHome } from './chunk-VPPSRRGK.js';
|
|
2
2
|
import { useTranslation } from './chunk-TYNZ5B2B.js';
|
|
3
3
|
import { HookSlot } from './chunk-5XDPAKF5.js';
|
|
4
|
-
import { Image } from './chunk-
|
|
4
|
+
import { Image } from './chunk-UKVYP7ME.js';
|
|
5
5
|
import { useTwilight } from './chunk-DF6FBKDN.js';
|
|
6
6
|
import { lazy, useState } from 'react';
|
|
7
7
|
import { SallaAdvertisement } from '@salla.sa/twilight-components-react/advertisement';
|
|
@@ -13,9 +13,9 @@ import { SallaSearch } from '@salla.sa/twilight-components-react/search';
|
|
|
13
13
|
import { SallaUserMenu } from '@salla.sa/twilight-components-react/user-menu';
|
|
14
14
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
15
15
|
|
|
16
|
-
var LazyMainMenu = lazy(() => import('./MainMenu-
|
|
16
|
+
var LazyMainMenu = lazy(() => import('./MainMenu-CTRSU7ZV.js').then((m) => ({ default: m.MainMenu })));
|
|
17
17
|
var LazyMobileMenu = lazy(
|
|
18
|
-
() => import('./MobileMenu-
|
|
18
|
+
() => import('./MobileMenu-3YHFM2UF.js').then((m) => ({ default: m.MobileMenu }))
|
|
19
19
|
);
|
|
20
20
|
function Header(_props) {
|
|
21
21
|
const { currency, theme, store } = useTwilight();
|
|
@@ -120,5 +120,5 @@ function Header(_props) {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
export { Header };
|
|
123
|
-
//# sourceMappingURL=chunk-
|
|
124
|
-
//# sourceMappingURL=chunk-
|
|
123
|
+
//# sourceMappingURL=chunk-L4EX7DLC.js.map
|
|
124
|
+
//# sourceMappingURL=chunk-L4EX7DLC.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/navigation/lazy.ts","../src/components/layout/Header.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAMO,IAAM,YAAA,GAAe,IAAA,CAAK,MAAM,OAAO,wBAAY,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,QAAA,GAAW,CAAC,CAAA;AAE3F,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,CAAA;ACUO,SAAS,OAAO,MAAA,EAAqB;AAC1C,EAAA,MAAM,EAAE,QAAA,EAAU,KAAA,EAAO,KAAA,KAAU,WAAA,EAAY;AAC/C,EAAA,MAAM,EAAE,MAAA,EAAQ,YAAA,EAAa,GAAI,cAAA,EAAe;AAChD,EAAA,MAAM,QAAA,GAAW,KAAA,EAAO,QAAA,IAAY,EAAC;AACrC,EAAA,MAAM,CAAC,gBAAA,EAAkB,mBAAmB,CAAA,GAAI,SAAS,KAAK,CAAA;AAG9D,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AA,EACb,QAAA,kBAAA,GAAA;AAAA,gBAAC,KAAA;AAAA,gBAAA;AAAA,kBACC,KAAK,KAAA,EAAO,IAAA;AAAA,kBACZ,GAAA,EAAK,CAAA,EAAG,KAAA,EAAO,IAAA,IAAQ,OAAO,CAAA,KAAA,CAAA;AAAA,kBAC9B,QAAA,EAAQ,IAAA;AAAA,kBACR,KAAA,EAAO,GAAA;AAAA,kBACP,MAAA,EAAQ;AAAA;AAAA,eACV,EACF,CAAA;AAAA,kCACC,UAAA,EAAA,EAAW,SAAA,EAAU,SAAA,EAAW,QAAA,EAAA,KAAA,EAAO,QAAQ,OAAA,EAAQ;AAAA,aAAA,EAC1D,CAAA;AAAA,gCACC,YAAA,EAAA,EAAS;AAAA,WAAA,EACZ,CAAA;AAAA,0BACA,IAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,sCAAA,EACb,QAAA,EAAA;AAAA,4BAAA,GAAA,CAAC,iBAAc,UAAA,EAAU,IAAA,EAAC,UAAA,EAAU,IAAA,EAAC,WAAU,YAAA,EAAa,CAAA;AAAA,4BAC5D,GAAA,CAAC,gBAAA,EAAA,EAAiB,SAAA,EAAU,8BAAA,EAC1B,QAAA,kBAAA,GAAA,CAAC,OAAE,IAAA,EAAK,MAAA,EAAO,SAAA,EAAU,0CAAA,EAA2C,CAAA,EACtE;AAAA,WAAA,EACF;AAAA,SAAA,EACF,GACF,CAAA,EACF;AAAA;AAAA,KACF;AAAA,oBAGA,GAAA,CAAC,kBAAW,MAAA,EAAQ,gBAAA,EAAkB,SAAS,MAAM,mBAAA,CAAoB,KAAK,CAAA,EAAG,CAAA;AAAA,oBACjF,GAAA,CAAC,QAAA,EAAA,EAAS,IAAA,EAAK,YAAA,EAAa;AAAA,GAAA,EAC9B,CAAA;AAEJ","file":"chunk-WHGOO4A2.js","sourcesContent":["import { lazy } from 'react';\n\n/**\n * Lazy-loaded navigation components\n * Use these for code-splitting navigation sections\n */\nexport const LazyMainMenu = lazy(() => import('./MainMenu').then((m) => ({ default: m.MainMenu })));\n\nexport const LazyMobileMenu = lazy(() =>\n import('./MobileMenu').then((m) => ({ default: m.MobileMenu }))\n);\n","import { useState } from 'react';\nimport { useIsHome } from '../../providers/NavigationProvider';\nimport { SallaAdvertisement } from '@salla.sa/twilight-components-react/advertisement';\nimport { SallaCartSummary } from '@salla.sa/twilight-components-react/cart-summary';\nimport { SallaContacts } from '@salla.sa/twilight-components-react/contacts';\nimport { SallaLocalizationModal } from '@salla.sa/twilight-components-react/localization-modal';\nimport { SallaMenu } from '@salla.sa/twilight-components-react/menu';\nimport { SallaSearch } from '@salla.sa/twilight-components-react/search';\nimport { SallaUserMenu } from '@salla.sa/twilight-components-react/user-menu';\nimport { useTwilight } from '../../providers/twilight-context';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport { HookSlot } from '../../hooks/HookSlot';\nimport { MainMenu, MobileMenu } from '../navigation';\nimport { Image } from '../common';\nimport type { Cart } from '../../types';\n\ninterface HeaderProps {\n cart?: Cart;\n}\n\nexport function Header(_props: HeaderProps) {\n const { currency, theme, store } = useTwilight();\n const { locale, languageName } = useTranslation();\n const settings = theme?.settings || {};\n const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);\n\n // Check if we're on homepage\n const isHomepage = useIsHome();\n\n const StoreTitle = isHomepage ? 'h1' : 'span';\n\n return (\n <header className=\"store-header\" suppressHydrationWarning>\n <HookSlot name=\"header:start\" />\n <div className=\"advertisement-slot\">\n <SallaAdvertisement />\n </div>\n {/* Top Nav */}\n <div className={`top-navbar${settings.topnav_is_dark ? ' top-navbar--dark' : ''}`}>\n <div className=\"container flex justify-between\">\n <div className=\"flex-1 flex items-center gap-2\">\n {/* Footer Menu */}\n {settings.important_links && <SallaMenu source=\"footer\" topnav />}\n\n {/* Language & Currency */}\n <div className=\"header-buttons\">\n {(store?.settings?.is_multilingual || store?.settings?.currencies_enabled) && (\n <>\n <button\n type=\"button\"\n onClick={() => window.salla?.event.dispatch('localization::open')}\n className=\"btn--rounded-gray basis-0\"\n >\n <span>{languageName}</span>\n <span className=\"mx-1.5\">|</span>\n <span className={`flag iti__flag iti__${store?.country.toLowerCase()}`}></span>\n\n <span>\n {store?.settings?.use_sar_symbol && currency?.code === 'SAR' ? (\n <i className=\"sicon-sar\"></i>\n ) : (\n <>{currency?.symbol}</>\n )}\n </span>\n </button>\n {/* TODO:: support switch the lang without hit the web API, by set it in the sdk and local storage */}\n {/* TODO:: Support switch the curency without hit the web API, by set it in the sdk and local storage */}\n <SallaLocalizationModal\n language={locale}\n currency={currency?.code || 'SAR'}\n suppressHydrationWarning\n />\n </>\n )}\n </div>\n\n {/* Scopes / Branches */}\n {store?.scope && (\n <button\n type=\"button\"\n className=\"btn--rounded-gray\"\n onClick={() =>\n window.salla?.event.dispatch('scopes::open', {\n mode: 'default',\n })\n }\n >\n <i className=\"sicon-location rtl:ml-1 ltr:mr-1\"></i>\n {store.scope.name}\n </button>\n )}\n\n {/* Search bar */}\n <div className=\"header-search flex-1\">\n {/* todo:: use a search icon insted with open the search popup */}\n <SallaSearch inline oval height={36} />\n </div>\n </div>\n\n <SallaContacts contacts={store?.contacts} contactsTitle=\"N/A\" isHeader />\n </div>\n </div>\n\n {/* Main Nav */}\n <div\n id=\"mainnav\"\n className={`main-nav-container shadow-default bg-white flex items-center relative z-50${settings.header_is_sticky ? ' sticky top-0' : ''}`}\n >\n <div className=\"inner bg-inherit w-full\">\n <div className=\"container\">\n <div className=\"flex items-stretch justify-between relative\">\n <div className=\"flex items-center\">\n <a\n className=\"lg:hidden mburger mburger--collapse leading-none rtl:ml-4 ltr:mr-4\"\n href=\"#mobile-menu\"\n aria-label=\"Open-menu\"\n onClick={(e) => {\n e.preventDefault();\n setIsMobileMenuOpen(true);\n }}\n >\n <i className=\"sicon-menu text-primary text-2xl\"></i>\n </a>\n <a className=\"navbar-brand\" href={store?.url || '/'}>\n <div className=\"logo-wrapper\">\n <Image\n src={store?.logo}\n alt={`${store?.name || 'Store'} logo`}\n priority\n width={120}\n height={48}\n />\n </div>\n <StoreTitle className=\"sr-only\">{store?.name || 'Store'}</StoreTitle>\n </a>\n <MainMenu />\n </div>\n <div className=\"flex items-center justify-end my-2.5\">\n <SallaUserMenu avatarOnly showHeader className=\"header-btn\" />\n <SallaCartSummary className=\"ml-4 rtl:ml-[unset] rtl:mr-4\">\n <i slot=\"icon\" className=\"header-btn__icon icon sicon-shopping-bag\"></i>\n </SallaCartSummary>\n </div>\n </div>\n </div>\n </div>\n </div>\n\n {/* Mobile Menu */}\n <MobileMenu isOpen={isMobileMenuOpen} onClose={() => setIsMobileMenuOpen(false)} />\n <HookSlot name=\"header:end\" />\n </header>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/navigation/lazy.ts","../src/components/layout/Header.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAMO,IAAM,YAAA,GAAe,IAAA,CAAK,MAAM,OAAO,wBAAY,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,QAAA,GAAW,CAAC,CAAA;AAE3F,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,CAAA;ACUO,SAAS,OAAO,MAAA,EAAqB;AAC1C,EAAA,MAAM,EAAE,QAAA,EAAU,KAAA,EAAO,KAAA,KAAU,WAAA,EAAY;AAC/C,EAAA,MAAM,EAAE,MAAA,EAAQ,YAAA,EAAa,GAAI,cAAA,EAAe;AAChD,EAAA,MAAM,QAAA,GAAW,KAAA,EAAO,QAAA,IAAY,EAAC;AACrC,EAAA,MAAM,CAAC,gBAAA,EAAkB,mBAAmB,CAAA,GAAI,SAAS,KAAK,CAAA;AAG9D,EAAA,MAAM,aAAa,SAAA,EAAU;AAE7B,EAAA,MAAM,UAAA,GAAa,aAAa,IAAA,GAAO,MAAA;A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AO,IAAA;AAAA,kBACZ,GAAA,EAAK,CAAA,EAAG,KAAA,EAAO,IAAA,IAAQ,OAAO,CAAA,KAAA,CAAA;AAAA,kBAC9B,QAAA,EAAQ,IAAA;AAAA,kBACR,KAAA,EAAO,GAAA;AAAA,kBACP,MAAA,EAAQ;AAAA;AAAA,eACV,EACF,CAAA;AAAA,kCACC,UAAA,EAAA,EAAW,SAAA,EAAU,SAAA,EAAW,QAAA,EAAA,KAAA,EAAO,QAAQ,OAAA,EAAQ;AAAA,aAAA,EAC1D,CAAA;AAAA,gCACC,YAAA,EAAA,EAAS;AAAA,WAAA,EACZ,CAAA;AAAA,0BACA,IAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,sCAAA,EACb,QAAA,EAAA;AAAA,4BAAA,GAAA,CAAC,iBAAc,UAAA,EAAU,IAAA,EAAC,UAAA,EAAU,IAAA,EAAC,WAAU,YAAA,EAAa,CAAA;AAAA,4BAC5D,GAAA,CAAC,gBAAA,EAAA,EAAiB,SAAA,EAAU,8BAAA,EAC1B,QAAA,kBAAA,GAAA,CAAC,OAAE,IAAA,EAAK,MAAA,EAAO,SAAA,EAAU,0CAAA,EAA2C,CAAA,EACtE;AAAA,WAAA,EACF;AAAA,SAAA,EACF,GACF,CAAA,EACF;AAAA;AAAA,KACF;AAAA,oBAGA,GAAA,CAAC,kBAAW,MAAA,EAAQ,gBAAA,EAAkB,SAAS,MAAM,mBAAA,CAAoB,KAAK,CAAA,EAAG,CAAA;AAAA,oBACjF,GAAA,CAAC,QAAA,EAAA,EAAS,IAAA,EAAK,YAAA,EAAa;AAAA,GAAA,EAC9B,CAAA;AAEJ","file":"chunk-L4EX7DLC.js","sourcesContent":["import { lazy } from 'react';\n\n/**\n * Lazy-loaded navigation components\n * Use these for code-splitting navigation sections\n */\nexport const LazyMainMenu = lazy(() => import('./MainMenu').then((m) => ({ default: m.MainMenu })));\n\nexport const LazyMobileMenu = lazy(() =>\n import('./MobileMenu').then((m) => ({ default: m.MobileMenu }))\n);\n","import { useState } from 'react';\nimport { useIsHome } from '../../providers/NavigationProvider';\nimport { SallaAdvertisement } from '@salla.sa/twilight-components-react/advertisement';\nimport { SallaCartSummary } from '@salla.sa/twilight-components-react/cart-summary';\nimport { SallaContacts } from '@salla.sa/twilight-components-react/contacts';\nimport { SallaLocalizationModal } from '@salla.sa/twilight-components-react/localization-modal';\nimport { SallaMenu } from '@salla.sa/twilight-components-react/menu';\nimport { SallaSearch } from '@salla.sa/twilight-components-react/search';\nimport { SallaUserMenu } from '@salla.sa/twilight-components-react/user-menu';\nimport { useTwilight } from '../../providers/twilight-context';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport { HookSlot } from '../../hooks/HookSlot';\nimport { MainMenu, MobileMenu } from '../navigation';\nimport { Image } from '../common';\nimport type { Cart } from '../../types';\n\ninterface HeaderProps {\n cart?: Cart;\n}\n\nexport function Header(_props: HeaderProps) {\n const { currency, theme, store } = useTwilight();\n const { locale, languageName } = useTranslation();\n const settings = theme?.settings || {};\n const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);\n\n // Check if we're on homepage\n const isHomepage = useIsHome();\n\n const StoreTitle = isHomepage ? 'h1' : 'span';\n\n return (\n <header className=\"store-header\" suppressHydrationWarning>\n <HookSlot name=\"header:start\" />\n <div className=\"advertisement-slot\">\n <SallaAdvertisement />\n </div>\n {/* Top Nav */}\n <div className={`top-navbar${settings.topnav_is_dark ? ' top-navbar--dark' : ''}`}>\n <div className=\"container flex justify-between\">\n <div className=\"flex-1 flex items-center gap-2\">\n {/* Footer Menu */}\n {settings.important_links && <SallaMenu source=\"footer\" topnav />}\n\n {/* Language & Currency */}\n <div className=\"header-buttons\">\n {(store?.settings?.is_multilingual || store?.settings?.currencies_enabled) && (\n <>\n <button\n type=\"button\"\n onClick={() => window.salla?.event.dispatch('localization::open')}\n className=\"btn--rounded-gray basis-0\"\n >\n <span>{languageName}</span>\n <span className=\"mx-1.5\">|</span>\n <span className={`flag iti__flag iti__${store?.country.toLowerCase()}`}></span>\n\n <span>\n {store?.settings?.use_sar_symbol && currency?.code === 'SAR' ? (\n <i className=\"sicon-sar\"></i>\n ) : (\n <>{currency?.symbol}</>\n )}\n </span>\n </button>\n {/* TODO:: support switch the lang without hit the web API, by set it in the sdk and local storage */}\n {/* TODO:: Support switch the curency without hit the web API, by set it in the sdk and local storage */}\n <SallaLocalizationModal\n language={locale}\n currency={currency?.code || 'SAR'}\n suppressHydrationWarning\n />\n </>\n )}\n </div>\n\n {/* Scopes / Branches */}\n {store?.scope && (\n <button\n type=\"button\"\n className=\"btn--rounded-gray\"\n onClick={() =>\n window.salla?.event.dispatch('scopes::open', {\n mode: 'default',\n })\n }\n >\n <i className=\"sicon-location rtl:ml-1 ltr:mr-1\"></i>\n {store.scope.name}\n </button>\n )}\n\n {/* Search bar */}\n <div className=\"header-search flex-1\">\n {/* todo:: use a search icon insted with open the search popup */}\n <SallaSearch inline oval height={36} />\n </div>\n </div>\n\n <SallaContacts contacts={store?.contacts} contactsTitle=\"N/A\" isHeader />\n </div>\n </div>\n\n {/* Main Nav */}\n <div\n id=\"mainnav\"\n className={`main-nav-container shadow-default bg-white flex items-center relative z-50${settings.header_is_sticky ? ' sticky top-0' : ''}`}\n >\n <div className=\"inner bg-inherit w-full\">\n <div className=\"container\">\n <div className=\"flex items-stretch justify-between relative\">\n <div className=\"flex items-center\">\n <a\n className=\"lg:hidden mburger mburger--collapse leading-none rtl:ml-4 ltr:mr-4\"\n href=\"#mobile-menu\"\n aria-label=\"Open-menu\"\n onClick={(e) => {\n e.preventDefault();\n setIsMobileMenuOpen(true);\n }}\n >\n <i className=\"sicon-menu text-primary text-2xl\"></i>\n </a>\n <a className=\"navbar-brand\" href={store?.url || '/'}>\n <div className=\"logo-wrapper\">\n <Image\n src={store?.logo}\n alt={`${store?.name || 'Store'} logo`}\n priority\n width={120}\n height={48}\n />\n </div>\n <StoreTitle className=\"sr-only\">{store?.name || 'Store'}</StoreTitle>\n </a>\n <MainMenu />\n </div>\n <div className=\"flex items-center justify-end my-2.5\">\n <SallaUserMenu avatarOnly showHeader className=\"header-btn\" />\n <SallaCartSummary className=\"ml-4 rtl:ml-[unset] rtl:mr-4\">\n <i slot=\"icon\" className=\"header-btn__icon icon sicon-shopping-bag\"></i>\n </SallaCartSummary>\n </div>\n </div>\n </div>\n </div>\n </div>\n\n {/* Mobile Menu */}\n <MobileMenu isOpen={isMobileMenuOpen} onClose={() => setIsMobileMenuOpen(false)} />\n <HookSlot name=\"header:end\" />\n </header>\n );\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { escapeForInlineScript } from './chunk-
|
|
1
|
+
import { escapeForInlineScript } from './chunk-4A5IAMNL.js';
|
|
2
2
|
|
|
3
3
|
// src/utils/app-scope.ts
|
|
4
4
|
var isBrowser = typeof window !== "undefined";
|
|
@@ -132,5 +132,5 @@ function renderThemeHookSlotsScript(names = getRegisteredThemeHookSlots()) {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
export { applyAppScopeMocks, applyThemeHookSlots, installAppScope, registerThemeHookSlots, renderAppScopeInstallScript, renderThemeHookSlotsScript };
|
|
135
|
-
//# sourceMappingURL=chunk-
|
|
136
|
-
//# sourceMappingURL=chunk-
|
|
135
|
+
//# sourceMappingURL=chunk-LCDSHSP7.js.map
|
|
136
|
+
//# sourceMappingURL=chunk-LCDSHSP7.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/app-scope.ts","../src/utils/theme-hook-slots.ts"],"names":[],"mappings":";;;AAGA,IAAM,SAAA,GAAY,OAAO,MAAA,KAAW,WAAA;AA2B7B,IAAM,qBAAA,GAAgD,CAAC,CAAA,EAAG,MAAA,KAAW;AAC1E,EAAA,MAAM,QAAA,GAAW,CAAC,GAAA,KAChB,OAAO,QAAQ,QAAA,IAAY,GAAA,CAAI,OAAA,CAAQ,MAAM,CAAA,KAAM,CAAA;AACrD,EAAA,MAAM,SAAA,GAAY,CAAC,GAA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AA,GAAa,KAAA;AASV,SAAS,0BAA0B,KAAA,EAAuB;AAC/D,EAAA,KAAA,MAAW,IAAA,IAAQ,KAAA,EAAO,UAAA,CAAW,GAAA,CAAI,IAAI,CAAA;AAC/C;AAGA,SAAS,SAAA,GAAqB;AAC5B,EAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,KAAA,EAAO,KAAA,EAAO,WAAA;AACnC,EAAA,IAAI,CAAC,KAAA,CAAM,OAAA,CAAQ,KAAK,GAAG,OAAO,KAAA;AAClC,EAAA,KAAA,MAAW,IAAA,IAAQ,UAAA,EAAY,IAAI,CAAC,KAAA,CAAM,SAAS,IAAI,CAAA,EAAG,KAAA,CAAM,IAAA,CAAK,IAAI,CAAA;AACzE,EAAA,OAAO,IAAA;AACT;AAYO,SAAS,mBAAA,GAA4B;AAC1C,EAAA,IAAI,OAAO,MAAA,KAAW,WAAA,IAAe,UAAA,CAAW,SAAS,CAAA,EAAG;AAC5D,EAAA,IAAI,SAAA,MAAe,UAAA,EAAY;AAE/B,EAAA,UAAA,GAAa,IAAA;AACb,EAAA,MAAA,CAAO,gBAAA,CAAiB,uBAAuB,MAAM,KAAK,WAAU,EAAG,EAAE,IAAA,EAAM,IAAA,EAAM,CAAA;AACvF;AAGO,SAAS,2BAAA,GAAwC;AACtD,EAAA,OAAO,CAAC,GAAG,UAAU,CAAA;AACvB;AAeO,SAAS,0BAAA,CAA2B,KAAA,GAAkB,2BAAA,EAA4B,EAAG;AAC1F,EAAA,IAAI,CAAC,KAAA,CAAM,MAAA,EAAQ,OAAO,IAAA;AAC1B,EAAA,MAAM,IAAA,GAAO,qBAAA,CAAsB,IAAA,CAAK,SAAA,CAAU,KAAK,CAAC,CAAA;AACxD,EAAA,OACE,wUASM,IAAI,CAAA,EAAA,CAAA;AAEd","file":"chunk-RYSJOCHI.js","sourcesContent":["import type { SallaSDK } from '../types/salla-sdk';\nimport { escapeForInlineScript } from './inline-script';\n\nconst isBrowser = typeof window !== 'undefined';\n\n/** One app's private `app.*` bag, keyed without the `app.` prefix (`app.color` → `color`). */\nexport type AppConfigBag = Record<string, unknown>;\n\n/** One public `app.*` bucket per app, keyed by appScopeId. Everything else is read from the\n * real `salla.config` at runtime. */\nexport interface AppScopeContexts {\n apps: Record<string, AppConfigBag>;\n}\n\n/** Builds the `scopeId → sandboxed SDK` factory over a live bucket bag. */\nexport type AppScopeFactoryBuilder = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n w: any,\n appCtx: Record<string, AppConfigBag>\n) => (scopeId: string) => SallaSDK;\n\n/**\n * The sandbox itself: proxies that resolve `app.*` against the app's own bucket and pass\n * everything else through to the real SDK.\n *\n * MUST stay self-contained (only `Object`/`Proxy` and its two arguments): it is serialized via\n * `.toString()` next to {@link appScopeBootstrap} and handed in as an argument, so anything it\n * closed over at module scope would be undefined in the inline head copy. Split out from the\n * bootstrap purely to keep both halves reviewable.\n */\nexport const createAppScopeFactory: AppScopeFactoryBuilder = (w, appCtx) => {\n const isAppKey = (key: unknown): key is string =>\n typeof key === 'string' && key.indexOf('app.') === 0;\n const bucketKey = (key: string): string => key.slice(4);\n const realSalla = (): Record<string, unknown> => w.salla || w.Salla || {};\n const realConfig = (): Record<string, unknown> =>\n (realSalla().config as Record<string, unknown>) || {};\n const passthrough = (obj: Record<string, unknown>, prop: string | symbol): unknown => {\n const member = obj[prop as string];\n return typeof member === 'function' ? member.bind(obj) : member;\n };\n\n const createAppScope = (scopeId: string): SallaSDK => {\n const bucket = (): AppConfigBag => (appCtx[scopeId] = appCtx[scopeId] || {});\n\n const getConfig = (key: string, fallback?: unknown): unknown => {\n if (isAppKey(key)) {\n const sub = bucketKey(key);\n const b = bucket();\n // `app.*` miss returns the caller default, never the real config — a missing app\n // setting must not resolve to a same-named global.\n return sub in b ? b[sub] : fallback;\n }\n const cfg = realConfig();\n return typeof cfg.get === 'function'\n ? (cfg.get as (k: string, d?: unknown) => unknown)(key, fallback)\n : fallback;\n };\n\n const setConfig = (key: string, value: unknown): unknown => {\n if (isAppKey(key)) {\n bucket()[bucketKey(key)] = value;\n return value;\n }\n const cfg = realConfig();\n return typeof cfg.set === 'function'\n ? (cfg.set as (k: string, v: unknown) => unknown)(key, value)\n : value;\n };\n\n const hasConfig = (key: string): boolean =>\n isAppKey(key) ? bucketKey(key) in bucket() : key in realConfig();\n\n const configProxy = new Proxy({} as Record<string, unknown>, {\n get(_t, prop) {\n if (prop === 'get') return getConfig;\n if (prop === 'set') return setConfig;\n if (prop === 'has') return hasConfig;\n if (isAppKey(prop)) return getConfig(prop);\n return passthrough(realConfig(), prop);\n },\n set(_t, prop, value) {\n setConfig(prop as string, value);\n return true;\n },\n has(_t, prop) {\n return hasConfig(prop as string);\n },\n });\n\n return new Proxy({} as Record<string, unknown>, {\n get(_t, prop) {\n return prop === 'config' ? configProxy : passthrough(realSalla(), prop);\n },\n set(_t, prop, value) {\n // Reassigning `salla.config` wholesale would escape the sandbox; swallow it.\n if (prop === 'config') return true;\n realSalla()[prop as string] = value;\n return true;\n },\n }) as unknown as SallaSDK;\n };\n\n return createAppScope;\n};\n\n/**\n * Installs `window.Salla.appScope`, seeded with `contexts` and sandboxed by `makeFactory`.\n *\n * MUST stay self-contained (only `window`/`Object` and its arguments): it's serialized via\n * `.toString()` and inlined into the SSR head so the factory exists at parse time — before the\n * SDK init/hydration a CDN snippet's `onReady` races, else it throws `Salla.appScope is not a\n * function`. `makeFactory` is passed in rather than imported for exactly that reason. Also\n * called directly by `installAppScope` (tests/fallback).\n *\n * Idempotent: the factory is first-write-wins, while buckets are merged per scope (also\n * first-write-wins) so a later call can seed scopes the first one had no data for. `appCtx` is\n * closure-private (namespacing, not security: buckets are public-only and the boundary is\n * server-side).\n */\nexport function appScopeBootstrap(\n contexts: AppScopeContexts,\n makeFactory: AppScopeFactoryBuilder\n): void {\n if (typeof window === 'undefined') return;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const w = window as any;\n const Salla = (w.Salla = w.Salla || {});\n if (Salla.appScope) {\n // Already installed (normally by the inline head copy). The factory is first-write-wins,\n // but buckets are not: the head may have installed with none of them — the settings\n // endpoint can fail or lag behind the snippets one — so hand them to the existing install.\n if (Salla.__appScopeSeed) Salla.__appScopeSeed(contexts);\n return;\n }\n\n // Live bag + pristine snapshot (for mock overlays). Copy, don't alias: a snippet may\n // `config.set('app.x')` and the payload can be a cached response.\n const appCtx: Record<string, AppConfigBag> = {};\n const base: Record<string, AppConfigBag> = {};\n // Which scopes already got their real bucket, so a later seed can't overwrite one.\n const seeded: Record<string, boolean> = {};\n const seed = (next: AppScopeContexts): void => {\n const bags = (next && next.apps) || {};\n Object.keys(bags).forEach((scopeId) => {\n if (seeded[scopeId]) return;\n seeded[scopeId] = true;\n appCtx[scopeId] = Object.assign({}, appCtx[scopeId] || {}, bags[scopeId] || {});\n base[scopeId] = Object.assign({}, appCtx[scopeId]);\n });\n };\n seed(contexts);\n\n const createAppScope = makeFactory(w, appCtx);\n Salla.appScope = (scopeId: string): SallaSDK => createAppScope(scopeId);\n\n // Fill in buckets for scopes not seeded yet (first-write-wins per scope). Lets the head\n // install the factory unconditionally — at parse time, before any snippet's onReady — and\n // still pick up buckets that only the client managed to fetch.\n Salla.__appScopeSeed = (next: AppScopeContexts): void => seed(next);\n\n // Overlay preview mocks onto an app's pristine baseline, so fields the partner did not mock\n // keep their real values. Returns false for an unknown scope or before install.\n Salla.__appScopeMock = (scopeId: string, mocks: AppConfigBag): boolean => {\n if (!(scopeId in base)) return false;\n appCtx[scopeId] = Object.assign({}, base[scopeId], mocks);\n return true;\n };\n}\n\n/** Overlay preview mocks onto one app's bucket (over its pristine values). Delegates to the\n * bootstrap's `__appScopeMock`, so it works for both install paths. False if unknown/uninstalled. */\nexport function applyAppScopeMocks(appScopeId: string, mocks: AppConfigBag): boolean {\n if (!isBrowser) return false;\n const mock = (window.Salla as unknown as { __appScopeMock?: MockApplier } | undefined)\n ?.__appScopeMock;\n return mock?.(appScopeId, mocks) ?? false;\n}\n\ntype MockApplier = (appScopeId: string, mocks: AppConfigBag) => boolean;\n\n/** Serialize the installer into an inline `<script>` body seeded with `contexts` — both halves\n * via `.toString()`, hence their self-contained requirement. See `rootHead`. */\nexport function renderAppScopeInstallScript(contexts: AppScopeContexts): string {\n // Bucket values are partner-set, so escape the JSON seed against a `</script>` breakout.\n // The function sources have no `<`, so they need no escaping.\n const json = escapeForInlineScript(JSON.stringify(contexts));\n return `(${appScopeBootstrap.toString()})(${json},${createAppScopeFactory.toString()});`;\n}\n\n/** Install `Salla.appScope` on the client, or seed buckets into the inline SSR head copy that\n * already installed it. No-op on the server. Fallback for unseeded loads + the unit-test entry\n * point. */\nexport function installAppScope(contexts: AppScopeContexts): void {\n if (!isBrowser) return;\n appScopeBootstrap(contexts, createAppScopeFactory);\n}\n","import { escapeForInlineScript } from './inline-script';\n\nconst registered = new Set<string>();\n\nlet retryArmed = false;\n\n/**\n * Declare hook slots the theme renders itself so apps may mount into them.\n *\n * The SDK rejects `mount()` for any name absent from its `_themeSlots` whitelist, so a theme\n * rendering its own `<salla-hook>` must register the name. Call at module scope; the engine\n * applies the names via {@link applyThemeHookSlots}.\n */\nexport function registerThemeHookSlots(...names: string[]): void {\n for (const name of names) registered.add(name);\n}\n\n/** Push the registered names in. Returns false if the SDK hasn't exposed the list yet. */\nfunction pushSlots(): boolean {\n const slots = window.salla?.hooks?._themeSlots;\n if (!Array.isArray(slots)) return false;\n for (const name of registered) if (!slots.includes(name)) slots.push(name);\n return true;\n}\n\n/**\n * Push every registered slot name into the SDK whitelist. Idempotent. Engine-only.\n *\n * The SDK's hooks module may attach after this runs, so a first no-op falls back to a\n * one-shot retry on `twilight::initiated` — still before apps mount from their own onReady.\n *\n * This is only the late backstop: the whitelist is primarily seeded at parse time by the\n * inline head script from {@link renderThemeHookSlotsScript}, because an app's snippet\n * registers its `onReady` callback before React ever hydrates.\n */\nexport function applyThemeHookSlots(): void {\n if (typeof window === 'undefined' || registered.size === 0) return;\n if (pushSlots() || retryArmed) return;\n\n retryArmed = true;\n window.addEventListener('twilight::initiated', () => void pushSlots(), { once: true });\n}\n\n/** The slot names registered so far. Read by `rootHead` when rendering the inline script. */\nexport function getRegisteredThemeHookSlots(): string[] {\n return [...registered];\n}\n\n/**\n * Serialize the whitelist push into an inline head `<script>` body, so the slots are\n * registered at parse time.\n *\n * Ordering is the whole point: CDN snippets are parser-inserted `<script defer>` tags in the\n * body, so an app's `Salla.onReady` callback is registered long before React hydrates and runs\n * {@link applyThemeHookSlots}. Whichever `twilight::initiated` listener was added first runs\n * first, so the push must be armed from the head — otherwise the SDK rejects the app's\n * `hooks.mount()` with \"Hook <name> is not allowed\" and the app never renders.\n *\n * Returns null when the theme registered no slots. Kept self-contained (only `window`) since\n * it ships as raw source, not as a bundled module.\n */\nexport function renderThemeHookSlotsScript(names: string[] = getRegisteredThemeHookSlots()) {\n if (!names.length) return null;\n const json = escapeForInlineScript(JSON.stringify(names));\n return (\n `(function(names){` +\n `var w=window;` +\n `function push(){` +\n `var h=w.salla&&w.salla.hooks;var slots=h&&h._themeSlots;` +\n `if(!Array.isArray(slots))return false;` +\n `for(var i=0;i<names.length;i++)if(slots.indexOf(names[i])<0)slots.push(names[i]);` +\n `return true}` +\n `if(push())return;` +\n `w.addEventListener('twilight::initiated',function(){push()},{once:true})` +\n `})(${json});`\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/app-scope.ts","../src/utils/theme-hook-slots.ts"],"names":[],"mappings":";;;AAGA,IAAM,SAAA,GAAY,OAAO,MAAA,KAAW,WAAA;AA2B7B,IAAM,qBAAA,GAAgD,CAAC,CAAA,EAAG,MAAA,KAAW;AAC1E,EAAA,MAAM,QAAA,GAAW,CAAC,GAAA,KAChB,OAAO,QAAQ,QAAA,IAAY,GAAA,CAAI,OAAA,CAAQ,MAAM,CAAA,KAAM,CAAA;AACrD,EAAA,MAAM,SAAA,GAAY,CAAC,GAAA,KAAwB,GAAA,CAAI,MAAM,CAAC,CAAA;AACtD,EAAA,MAAM,YAAY,MAA+B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AW,IAAA,IAAQ,KAAA,EAAO,UAAA,CAAW,GAAA,CAAI,IAAI,CAAA;AAC/C;AAGA,SAAS,SAAA,GAAqB;AAC5B,EAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,KAAA,EAAO,KAAA,EAAO,WAAA;AACnC,EAAA,IAAI,CAAC,KAAA,CAAM,OAAA,CAAQ,KAAK,GAAG,OAAO,KAAA;AAClC,EAAA,KAAA,MAAW,IAAA,IAAQ,UAAA,EAAY,IAAI,CAAC,KAAA,CAAM,SAAS,IAAI,CAAA,EAAG,KAAA,CAAM,IAAA,CAAK,IAAI,CAAA;AACzE,EAAA,OAAO,IAAA;AACT;AAYO,SAAS,mBAAA,GAA4B;AAC1C,EAAA,IAAI,OAAO,MAAA,KAAW,WAAA,IAAe,UAAA,CAAW,SAAS,CAAA,EAAG;AAC5D,EAAA,IAAI,SAAA,MAAe,UAAA,EAAY;AAE/B,EAAA,UAAA,GAAa,IAAA;AACb,EAAA,MAAA,CAAO,gBAAA,CAAiB,uBAAuB,MAAM,KAAK,WAAU,EAAG,EAAE,IAAA,EAAM,IAAA,EAAM,CAAA;AACvF;AAGO,SAAS,2BAAA,GAAwC;AACtD,EAAA,OAAO,CAAC,GAAG,UAAU,CAAA;AACvB;AAeO,SAAS,0BAAA,CAA2B,KAAA,GAAkB,2BAAA,EAA4B,EAAG;AAC1F,EAAA,IAAI,CAAC,KAAA,CAAM,MAAA,EAAQ,OAAO,IAAA;AAC1B,EAAA,MAAM,IAAA,GAAO,qBAAA,CAAsB,IAAA,CAAK,SAAA,CAAU,KAAK,CAAC,CAAA;AACxD,EAAA,OACE,wUASM,IAAI,CAAA,EAAA,CAAA;AAEd","file":"chunk-LCDSHSP7.js","sourcesContent":["import type { SallaSDK } from '../types/salla-sdk';\nimport { escapeForInlineScript } from './inline-script';\n\nconst isBrowser = typeof window !== 'undefined';\n\n/** One app's private `app.*` bag, keyed without the `app.` prefix (`app.color` → `color`). */\nexport type AppConfigBag = Record<string, unknown>;\n\n/** One public `app.*` bucket per app, keyed by appScopeId. Everything else is read from the\n * real `salla.config` at runtime. */\nexport interface AppScopeContexts {\n apps: Record<string, AppConfigBag>;\n}\n\n/** Builds the `scopeId → sandboxed SDK` factory over a live bucket bag. */\nexport type AppScopeFactoryBuilder = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n w: any,\n appCtx: Record<string, AppConfigBag>\n) => (scopeId: string) => SallaSDK;\n\n/**\n * The sandbox itself: proxies that resolve `app.*` against the app's own bucket and pass\n * everything else through to the real SDK.\n *\n * MUST stay self-contained (only `Object`/`Proxy` and its two arguments): it is serialized via\n * `.toString()` next to {@link appScopeBootstrap} and handed in as an argument, so anything it\n * closed over at module scope would be undefined in the inline head copy. Split out from the\n * bootstrap purely to keep both halves reviewable.\n */\nexport const createAppScopeFactory: AppScopeFactoryBuilder = (w, appCtx) => {\n const isAppKey = (key: unknown): key is string =>\n typeof key === 'string' && key.indexOf('app.') === 0;\n const bucketKey = (key: string): string => key.slice(4);\n const realSalla = (): Record<string, unknown> => w.salla || w.Salla || {};\n const realConfig = (): Record<string, unknown> =>\n (realSalla().config as Record<string, unknown>) || {};\n const passthrough = (obj: Record<string, unknown>, prop: string | symbol): unknown => {\n const member = obj[prop as string];\n return typeof member === 'function' ? member.bind(obj) : member;\n };\n\n const createAppScope = (scopeId: string): SallaSDK => {\n const bucket = (): AppConfigBag => (appCtx[scopeId] = appCtx[scopeId] || {});\n\n const getConfig = (key: string, fallback?: unknown): unknown => {\n if (isAppKey(key)) {\n const sub = bucketKey(key);\n const b = bucket();\n // `app.*` miss returns the caller default, never the real config — a missing app\n // setting must not resolve to a same-named global.\n return sub in b ? b[sub] : fallback;\n }\n const cfg = realConfig();\n return typeof cfg.get === 'function'\n ? (cfg.get as (k: string, d?: unknown) => unknown)(key, fallback)\n : fallback;\n };\n\n const setConfig = (key: string, value: unknown): unknown => {\n if (isAppKey(key)) {\n bucket()[bucketKey(key)] = value;\n return value;\n }\n const cfg = realConfig();\n return typeof cfg.set === 'function'\n ? (cfg.set as (k: string, v: unknown) => unknown)(key, value)\n : value;\n };\n\n const hasConfig = (key: string): boolean =>\n isAppKey(key) ? bucketKey(key) in bucket() : key in realConfig();\n\n const configProxy = new Proxy({} as Record<string, unknown>, {\n get(_t, prop) {\n if (prop === 'get') return getConfig;\n if (prop === 'set') return setConfig;\n if (prop === 'has') return hasConfig;\n if (isAppKey(prop)) return getConfig(prop);\n return passthrough(realConfig(), prop);\n },\n set(_t, prop, value) {\n setConfig(prop as string, value);\n return true;\n },\n has(_t, prop) {\n return hasConfig(prop as string);\n },\n });\n\n return new Proxy({} as Record<string, unknown>, {\n get(_t, prop) {\n return prop === 'config' ? configProxy : passthrough(realSalla(), prop);\n },\n set(_t, prop, value) {\n // Reassigning `salla.config` wholesale would escape the sandbox; swallow it.\n if (prop === 'config') return true;\n realSalla()[prop as string] = value;\n return true;\n },\n }) as unknown as SallaSDK;\n };\n\n return createAppScope;\n};\n\n/**\n * Installs `window.Salla.appScope`, seeded with `contexts` and sandboxed by `makeFactory`.\n *\n * MUST stay self-contained (only `window`/`Object` and its arguments): it's serialized via\n * `.toString()` and inlined into the SSR head so the factory exists at parse time — before the\n * SDK init/hydration a CDN snippet's `onReady` races, else it throws `Salla.appScope is not a\n * function`. `makeFactory` is passed in rather than imported for exactly that reason. Also\n * called directly by `installAppScope` (tests/fallback).\n *\n * Idempotent: the factory is first-write-wins, while buckets are merged per scope (also\n * first-write-wins) so a later call can seed scopes the first one had no data for. `appCtx` is\n * closure-private (namespacing, not security: buckets are public-only and the boundary is\n * server-side).\n */\nexport function appScopeBootstrap(\n contexts: AppScopeContexts,\n makeFactory: AppScopeFactoryBuilder\n): void {\n if (typeof window === 'undefined') return;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const w = window as any;\n const Salla = (w.Salla = w.Salla || {});\n if (Salla.appScope) {\n // Already installed (normally by the inline head copy). The factory is first-write-wins,\n // but buckets are not: the head may have installed with none of them — the settings\n // endpoint can fail or lag behind the snippets one — so hand them to the existing install.\n if (Salla.__appScopeSeed) Salla.__appScopeSeed(contexts);\n return;\n }\n\n // Live bag + pristine snapshot (for mock overlays). Copy, don't alias: a snippet may\n // `config.set('app.x')` and the payload can be a cached response.\n const appCtx: Record<string, AppConfigBag> = {};\n const base: Record<string, AppConfigBag> = {};\n // Which scopes already got their real bucket, so a later seed can't overwrite one.\n const seeded: Record<string, boolean> = {};\n const seed = (next: AppScopeContexts): void => {\n const bags = (next && next.apps) || {};\n Object.keys(bags).forEach((scopeId) => {\n if (seeded[scopeId]) return;\n seeded[scopeId] = true;\n appCtx[scopeId] = Object.assign({}, appCtx[scopeId] || {}, bags[scopeId] || {});\n base[scopeId] = Object.assign({}, appCtx[scopeId]);\n });\n };\n seed(contexts);\n\n const createAppScope = makeFactory(w, appCtx);\n Salla.appScope = (scopeId: string): SallaSDK => createAppScope(scopeId);\n\n // Fill in buckets for scopes not seeded yet (first-write-wins per scope). Lets the head\n // install the factory unconditionally — at parse time, before any snippet's onReady — and\n // still pick up buckets that only the client managed to fetch.\n Salla.__appScopeSeed = (next: AppScopeContexts): void => seed(next);\n\n // Overlay preview mocks onto an app's pristine baseline, so fields the partner did not mock\n // keep their real values. Returns false for an unknown scope or before install.\n Salla.__appScopeMock = (scopeId: string, mocks: AppConfigBag): boolean => {\n if (!(scopeId in base)) return false;\n appCtx[scopeId] = Object.assign({}, base[scopeId], mocks);\n return true;\n };\n}\n\n/** Overlay preview mocks onto one app's bucket (over its pristine values). Delegates to the\n * bootstrap's `__appScopeMock`, so it works for both install paths. False if unknown/uninstalled. */\nexport function applyAppScopeMocks(appScopeId: string, mocks: AppConfigBag): boolean {\n if (!isBrowser) return false;\n const mock = (window.Salla as unknown as { __appScopeMock?: MockApplier } | undefined)\n ?.__appScopeMock;\n return mock?.(appScopeId, mocks) ?? false;\n}\n\ntype MockApplier = (appScopeId: string, mocks: AppConfigBag) => boolean;\n\n/** Serialize the installer into an inline `<script>` body seeded with `contexts` — both halves\n * via `.toString()`, hence their self-contained requirement. See `rootHead`. */\nexport function renderAppScopeInstallScript(contexts: AppScopeContexts): string {\n // Bucket values are partner-set, so escape the JSON seed against a `</script>` breakout.\n // The function sources have no `<`, so they need no escaping.\n const json = escapeForInlineScript(JSON.stringify(contexts));\n return `(${appScopeBootstrap.toString()})(${json},${createAppScopeFactory.toString()});`;\n}\n\n/** Install `Salla.appScope` on the client, or seed buckets into the inline SSR head copy that\n * already installed it. No-op on the server. Fallback for unseeded loads + the unit-test entry\n * point. */\nexport function installAppScope(contexts: AppScopeContexts): void {\n if (!isBrowser) return;\n appScopeBootstrap(contexts, createAppScopeFactory);\n}\n","import { escapeForInlineScript } from './inline-script';\n\nconst registered = new Set<string>();\n\nlet retryArmed = false;\n\n/**\n * Declare hook slots the theme renders itself so apps may mount into them.\n *\n * The SDK rejects `mount()` for any name absent from its `_themeSlots` whitelist, so a theme\n * rendering its own `<salla-hook>` must register the name. Call at module scope; the engine\n * applies the names via {@link applyThemeHookSlots}.\n */\nexport function registerThemeHookSlots(...names: string[]): void {\n for (const name of names) registered.add(name);\n}\n\n/** Push the registered names in. Returns false if the SDK hasn't exposed the list yet. */\nfunction pushSlots(): boolean {\n const slots = window.salla?.hooks?._themeSlots;\n if (!Array.isArray(slots)) return false;\n for (const name of registered) if (!slots.includes(name)) slots.push(name);\n return true;\n}\n\n/**\n * Push every registered slot name into the SDK whitelist. Idempotent. Engine-only.\n *\n * The SDK's hooks module may attach after this runs, so a first no-op falls back to a\n * one-shot retry on `twilight::initiated` — still before apps mount from their own onReady.\n *\n * This is only the late backstop: the whitelist is primarily seeded at parse time by the\n * inline head script from {@link renderThemeHookSlotsScript}, because an app's snippet\n * registers its `onReady` callback before React ever hydrates.\n */\nexport function applyThemeHookSlots(): void {\n if (typeof window === 'undefined' || registered.size === 0) return;\n if (pushSlots() || retryArmed) return;\n\n retryArmed = true;\n window.addEventListener('twilight::initiated', () => void pushSlots(), { once: true });\n}\n\n/** The slot names registered so far. Read by `rootHead` when rendering the inline script. */\nexport function getRegisteredThemeHookSlots(): string[] {\n return [...registered];\n}\n\n/**\n * Serialize the whitelist push into an inline head `<script>` body, so the slots are\n * registered at parse time.\n *\n * Ordering is the whole point: CDN snippets are parser-inserted `<script defer>` tags in the\n * body, so an app's `Salla.onReady` callback is registered long before React hydrates and runs\n * {@link applyThemeHookSlots}. Whichever `twilight::initiated` listener was added first runs\n * first, so the push must be armed from the head — otherwise the SDK rejects the app's\n * `hooks.mount()` with \"Hook <name> is not allowed\" and the app never renders.\n *\n * Returns null when the theme registered no slots. Kept self-contained (only `window`) since\n * it ships as raw source, not as a bundled module.\n */\nexport function renderThemeHookSlotsScript(names: string[] = getRegisteredThemeHookSlots()) {\n if (!names.length) return null;\n const json = escapeForInlineScript(JSON.stringify(names));\n return (\n `(function(names){` +\n `var w=window;` +\n `function push(){` +\n `var h=w.salla&&w.salla.hooks;var slots=h&&h._themeSlots;` +\n `if(!Array.isArray(slots))return false;` +\n `for(var i=0;i<names.length;i++)if(slots.indexOf(names[i])<0)slots.push(names[i]);` +\n `return true}` +\n `if(push())return;` +\n `w.addEventListener('twilight::initiated',function(){push()},{once:true})` +\n `})(${json});`\n );\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { orThrow } from './chunk-
|
|
2
|
-
import { api } from './chunk-
|
|
1
|
+
import { orThrow } from './chunk-VPPSRRGK.js';
|
|
2
|
+
import { api } from './chunk-BP6LUZXJ.js';
|
|
3
3
|
import { queryOptions } from '@tanstack/react-query';
|
|
4
4
|
|
|
5
5
|
var blog = {
|
|
@@ -63,5 +63,5 @@ var blog = {
|
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
export { blog };
|
|
66
|
-
//# sourceMappingURL=chunk-
|
|
67
|
-
//# sourceMappingURL=chunk-
|
|
66
|
+
//# sourceMappingURL=chunk-LL3X2N7L.js.map
|
|
67
|
+
//# sourceMappingURL=chunk-LL3X2N7L.js.map
|
|
@@ -1 +1 @@
|
|
|
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AEP","file":"chunk-LL3X2N7L.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport type { Options as KyOptions } from 'ky';\nimport { api } from './client';\nimport type { Pagination } from './types';\nimport type {\n ArticleSummary,\n ArticleDetail,\n BlogAuthor,\n BlogCategory,\n BlogTag,\n BlogOverview,\n} from '../routes/blog/types';\nimport { orThrow } from '../providers/NavigationProvider';\n\nexport interface BlogArticlesListParams {\n category?: string;\n author?: string;\n tag?: string;\n page?: number;\n cursor?: string | null;\n signal?: AbortSignal;\n}\n\nexport interface BlogArticlesListResponse {\n data: ArticleSummary[];\n categories?: BlogCategory[];\n category: BlogCategory;\n author: BlogAuthor;\n tag: BlogTag;\n cursor: Pagination;\n}\n\nexport interface BlogGetResponse {\n data: {\n categories: BlogCategory[] | null;\n slides: ArticleSummary[] | null;\n articles: ArticleSummary[] | null;\n popular: ArticleSummary[] | null;\n };\n}\n\nexport const blog = {\n get: async (signal?: AbortSignal): Promise<BlogOverview> => {\n const options: Record<string, unknown> = {};\n if (signal) options.signal = signal;\n\n const response = await api.get('blog', options as KyOptions).json<BlogGetResponse>();\n\n return {\n categories: response.data.categories ?? [],\n slides: response.data.slides ?? [],\n articles: response.data.articles ?? [],\n popular: response.data.popular ?? [],\n };\n },\n\n articles: {\n list: async (params?: BlogArticlesListParams): Promise<BlogArticlesListResponse> => {\n const { category, author, tag, page, cursor, signal } = params ?? {};\n\n const searchParams = new URLSearchParams();\n if (page !== undefined) searchParams.set('page', String(page));\n if (cursor) searchParams.set('cursor', cursor);\n if (category) searchParams.set('category', category);\n if (author) searchParams.set('author', author);\n if (tag) searchParams.set('tag', tag);\n\n const options: Record<string, unknown> = {};\n if (signal) options.signal = signal;\n\n const response = await api\n .get(`blog/articles?${searchParams.toString()}`, options as KyOptions)\n .json<{\n data: ArticleSummary[] | null;\n categories?: BlogCategory[] | null;\n category: BlogCategory;\n author: BlogAuthor;\n tag: BlogTag;\n cursor: Pagination;\n }>();\n\n return {\n data: response.data ?? [],\n categories: response.categories ?? undefined,\n category: response.category,\n author: response.author,\n tag: response.tag,\n cursor: response.cursor,\n };\n },\n\n find: async (id: string, signal?: AbortSignal): Promise<ArticleDetail> => {\n const options: Record<string, unknown> = {};\n if (signal) options.signal = signal;\n\n const response = await api\n .get(`blog/articles/${id}`, options as KyOptions)\n .json<{ data: ArticleDetail | null }>();\n\n if (!response.data) {\n throw new Error(`Article ${id} not found`);\n }\n\n return response.data;\n },\n\n findOrThrow: (id: string, signal?: AbortSignal): Promise<ArticleDetail> =>\n orThrow(blog.articles.find(id, signal)),\n },\n\n queries: {\n overview: () =>\n queryOptions({\n queryKey: ['blog', 'overview'],\n queryFn: ({ signal }) => blog.get(signal),\n }),\n articles: (params?: Omit<BlogArticlesListParams, 'signal'>) =>\n queryOptions({\n queryKey: ['blog', 'articles', params],\n queryFn: ({ signal }) => blog.articles.list({ ...params, signal }),\n }),\n article: (id: string) =>\n queryOptions({\n queryKey: ['blog', 'article', id],\n queryFn: ({ signal }) => blog.articles.find(id, signal),\n }),\n },\n};\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useTranslation } from './chunk-TYNZ5B2B.js';
|
|
2
2
|
import { useAsyncFn } from './chunk-6BZ5TKEV.js';
|
|
3
|
-
import { whenSallaLoaded, onSallaEvent } from './chunk-
|
|
3
|
+
import { whenSallaLoaded, onSallaEvent } from './chunk-4A5IAMNL.js';
|
|
4
4
|
import { useSyncExternalStore, useCallback } from 'react';
|
|
5
5
|
|
|
6
6
|
var WISHLIST_STORAGE_KEY = "salla::wishlist";
|
|
@@ -126,5 +126,5 @@ function resetWishlistStore() {
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
export { resetWishlistStore, useWishlist };
|
|
129
|
-
//# sourceMappingURL=chunk-
|
|
130
|
-
//# sourceMappingURL=chunk-
|
|
129
|
+
//# sourceMappingURL=chunk-LLQE4JAW.js.map
|
|
130
|
+
//# sourceMappingURL=chunk-LLQE4JAW.js.map
|
|
@@ -1 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AM,SAAS,CAAA,YAA0B,KAAA,CAAA;AAErD,EAAA,MAAM,SAAS,OAAO,SAAA,KACpB,EAAI,MAAM,QAAA,CAAS,SAAS,CAAA,YAA0B,KAAA,CAAA;AAExD,EAAA,MAAM,MAAA,GAAS,WAAA;AAAA,IACb,CAAC,cAAuB,GAAA,CAAI,SAAS,IAAI,MAAA,CAAO,SAAS,CAAA,GAAI,GAAA,CAAI,SAAS,CAAA;AAAA,IAC1E,CAAC,GAAA,EAAK,KAAA,EAAO,QAAQ;AAAA,GACvB;AAEA,EAAA,OAAO;AAAA,IACL,GAAA,EAAK,SAAA;AAAA,IACL,OAAO,SAAA,CAAU,MAAA;AAAA,IACjB,GAAA;AAAA,IACA,GAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,OAAA,EAAS,QAAA,CAAS,OAAA,IAAW,WAAA,CAAY,OAAA;AAAA,IACzC,KAAA,EAAA,CAAQ,QAAA,CAAS,KAAA,IAAS,WAAA,CAAY,QAAQ,OAAA,IAAW;AAAA,GAC3D;AACF;AAEO,SAAS,kBAAA,GAAqB;AACnC,EAAA,GAAA,GAAM,EAAC;AACP,EAAA,SAAA,CAAU,KAAA,EAAM;AAChB,EAAA,UAAA,GAAa,KAAA;AACf","file":"chunk-LLQE4JAW.js","sourcesContent":["import { useCallback, useSyncExternalStore } from 'react';\nimport { useAsyncFn } from './useAsyncFn';\nimport { useTranslation } from '../providers/I18nProvider';\nimport { onSallaEvent, whenSallaLoaded } from '../utils/sdk-helpers';\nimport type { UseToggleWithItems } from './types';\n\nexport type UseWishlistResult = UseToggleWithItems<number>;\n\n/**\n * useWishlist - Hook for managing wishlist functionality\n *\n * Provides wishlist product management with local storage persistence\n * and Salla SDK integration. Syncs with the SDK's wishlist state and\n * listens for events to maintain real-time consistency.\n *\n * Uses a module-level singleton store so SDK event listeners are\n * registered ONCE globally — not per-component. All hook instances\n * share the same state via `useSyncExternalStore`.\n *\n * @returns Wishlist state and management functions\n *\n * @example\n * ```tsx\n * function WishlistButton({ productId }) {\n * const { has, toggle, loading } = useWishlist();\n *\n * return (\n * <button\n * onClick={() => toggle(productId)}\n * disabled={loading}\n * className={has(productId) ? 'liked' : ''}\n * >\n * ❤️\n * </button>\n * );\n * }\n * ```\n */\n\nconst WISHLIST_STORAGE_KEY = 'salla::wishlist';\n\nlet ids: number[] = [];\nconst listeners = new Set<() => void>();\nlet subscribed = false;\n\nfunction emitChange() {\n for (const listener of listeners) listener();\n}\n\nfunction subscribe(listener: () => void) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n}\n\nfunction getSnapshot(): number[] {\n return ids;\n}\n\nconst getServerSnapshot = (): number[] => [];\n\nfunction persistIds() {\n try {\n localStorage.setItem(WISHLIST_STORAGE_KEY, JSON.stringify(ids));\n } catch {\n /* ignore storage errors */\n }\n}\n\nfunction initFromStorage() {\n try {\n // `storage` is missing while `window.salla` is still the head script's stub.\n const sdkWishlist = window.salla?.storage?.get(WISHLIST_STORAGE_KEY, []);\n const stored = localStorage.getItem(WISHLIST_STORAGE_KEY);\n const parsed = stored ? JSON.parse(stored) : [];\n ids = Array.isArray(sdkWishlist) && sdkWishlist.length > 0 ? sdkWishlist : parsed;\n } catch {\n /* ignore storage errors */\n }\n}\n\nfunction reloadFromStorage() {\n initFromStorage();\n emitChange();\n}\n\nfunction ensureSubscribed() {\n if (subscribed || typeof window === 'undefined') return;\n subscribed = true;\n initFromStorage();\n\n // On a cold load hydration runs before the SDK has loaded.\n whenSallaLoaded((salla) => {\n reloadFromStorage();\n if (!salla.wishlist?.event) return;\n\n salla.wishlist.event.onAdded((_event: unknown, id: number) => {\n if (ids.includes(id)) return;\n ids = [...ids, id];\n persistIds();\n emitChange();\n });\n\n salla.wishlist.event.onRemoved((_response: unknown, id: number) => {\n ids = ids.filter((itemId) => itemId !== id);\n persistIds();\n emitChange();\n });\n });\n\n // The SDK fills its storage with the customer's saved wishlist after init.\n onSallaEvent('wishlist::storage.synced', reloadFromStorage);\n}\n\n/**\n * useAsyncFn resolves with whatever the SDK rejected with, and callers detect\n * failure via `instanceof Error`. Normalize non-Error rejections so they are\n * never mistaken for success.\n */\nfunction toError(reason: unknown, fallback: string): Error {\n if (reason instanceof Error) return reason;\n if (typeof reason === 'string') return new Error(reason);\n const message = (reason as { message?: unknown } | null)?.message;\n return new Error(typeof message === 'string' ? message : fallback);\n}\n\nexport function useWishlist(): UseWishlistResult {\n ensureSubscribed();\n const storedIds = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n const { t } = useTranslation();\n const failed = t('common.errors.error_occurred', 'Something went wrong');\n\n const [addState, addFn] = useAsyncFn(\n async (productId: number) => {\n const salla = window.salla;\n try {\n await salla?.wishlist.add(productId);\n } catch (reason) {\n throw toError(reason, failed);\n }\n if (!ids.includes(productId)) {\n ids = [...ids, productId];\n persistIds();\n emitChange();\n }\n },\n [failed]\n );\n\n const [removeState, removeFn] = useAsyncFn(\n async (productId: number) => {\n const salla = window.salla;\n try {\n await salla?.wishlist.remove(productId);\n } catch (reason) {\n throw toError(reason, failed);\n }\n ids = ids.filter((id) => id !== productId);\n persistIds();\n emitChange();\n },\n [failed]\n );\n\n const has = useCallback((productId: number) => storedIds.includes(productId), [storedIds]);\n\n const add = async (productId: number): Promise<boolean> =>\n !(((await addFn(productId)) as unknown) instanceof Error);\n\n const remove = async (productId: number): Promise<boolean> =>\n !(((await removeFn(productId)) as unknown) instanceof Error);\n\n const toggle = useCallback(\n (productId: number) => (has(productId) ? remove(productId) : add(productId)),\n [has, addFn, removeFn]\n );\n\n return {\n ids: storedIds,\n count: storedIds.length,\n has,\n add,\n remove,\n toggle,\n loading: addState.loading || removeState.loading,\n error: (addState.error ?? removeState.error)?.message ?? null,\n };\n}\n\nexport function resetWishlistStore() {\n ids = [];\n listeners.clear();\n subscribed = false;\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { order } from './chunk-
|
|
1
|
+
import { order } from './chunk-O6L3BZBB.js';
|
|
2
2
|
import { buildHreflangAlternates } from './chunk-TZ3E5BN4.js';
|
|
3
|
-
import { unauthorized, orUnauthorized } from './chunk-
|
|
3
|
+
import { unauthorized, orUnauthorized } from './chunk-VPPSRRGK.js';
|
|
4
4
|
import { RouteId } from './chunk-OUW6WESU.js';
|
|
5
|
-
import { getAuthToken } from './chunk-
|
|
5
|
+
import { getAuthToken } from './chunk-BP6LUZXJ.js';
|
|
6
6
|
import { getTwilightContext } from './chunk-N2S25NXP.js';
|
|
7
7
|
import { lazy } from 'react';
|
|
8
8
|
|
|
@@ -55,9 +55,9 @@ async function orderSingleLoader({
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
// src/routes/account/orders/index.tsx
|
|
58
|
-
var LazyOrdersPage = lazy(() => import('./OrdersPage-
|
|
58
|
+
var LazyOrdersPage = lazy(() => import('./OrdersPage-TDZ3OX3J.js').then((m) => ({ default: m.OrdersPage })));
|
|
59
59
|
var LazyOrderSinglePage = lazy(
|
|
60
|
-
() => import('./OrderSinglePage-
|
|
60
|
+
() => import('./OrderSinglePage-YX7NRH6P.js').then((m) => ({ default: m.OrderSinglePage }))
|
|
61
61
|
);
|
|
62
62
|
var OrdersPage = LazyOrdersPage;
|
|
63
63
|
var OrderSinglePage = LazyOrderSinglePage;
|
|
@@ -104,5 +104,5 @@ var OrderSingle = {
|
|
|
104
104
|
};
|
|
105
105
|
|
|
106
106
|
export { OrderSingle, OrderSinglePage, Orders, OrdersPage, orderSingleLoader, ordersLoader };
|
|
107
|
-
//# sourceMappingURL=chunk-
|
|
108
|
-
//# sourceMappingURL=chunk-
|
|
107
|
+
//# sourceMappingURL=chunk-MCZJEDPZ.js.map
|
|
108
|
+
//# sourceMappingURL=chunk-MCZJEDPZ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/routes/account/orders/loader.ts","../src/routes/account/orders/index.tsx"],"names":[],"mappings":";;;;;;;;;AAQA,eAAsB,YAAA,CACpB,KACA,MAAA,EAI0B;A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"chunk-MCZJEDPZ.js","sourcesContent":["import { order } from '../../../api/order';\nimport { getTwilightContext } from '../../../twilight/context';\nimport { RouteId } from '../../../router/route-ids';\nimport { orUnauthorized, unauthorized } from '../../../providers/NavigationProvider';\nimport { getAuthToken } from '../../../api/client';\nimport type { OrdersPageProps, OrderSinglePageProps, OrdersQuery } from './types';\nimport type { IdParams } from '../../types';\n\nexport async function ordersLoader(\n ctx: { query?: OrdersQuery; with_items?: boolean | number },\n extend?: (\n data: OrdersPageProps,\n ctx: { params: Record<string, never> }\n ) => Promise<Record<string, unknown>> | Record<string, unknown>\n): Promise<OrdersPageProps> {\n if (!getAuthToken()) throw unauthorized();\n const query = ctx.query;\n const isPending = query?.status === 'pending';\n const response = await orUnauthorized(\n order.list({\n // Only decides the empty state; <salla-orders> applies its own review filter (`?tab=waiting`).\n status: query?.status,\n ...(ctx.with_items ? { with_items: ctx.with_items } : {}),\n })\n );\n const i18n = getTwilightContext().i18n;\n const pageData: OrdersPageProps = {\n page: {\n title: isPending ? i18n.t('common.titles.pending_orders') : i18n.t('common.titles.orders'),\n slug: RouteId.CUSTOMER_ORDERS_INDEX,\n },\n orders: response.data,\n cursor: response.cursor,\n query,\n };\n\n if (extend) {\n const extra = await extend(pageData, { params: {} });\n return { ...pageData, ...extra } as OrdersPageProps;\n }\n return pageData;\n}\n\nexport async function orderSingleLoader({\n params,\n}: {\n params: IdParams;\n}): Promise<OrderSinglePageProps> {\n if (!getAuthToken()) throw unauthorized();\n const [data, componentsOrder] = await Promise.all([\n order.findOrThrow(params.id),\n orUnauthorized(order.findForComponents(params.id)),\n ]);\n const i18n = getTwilightContext().i18n;\n return {\n page: {\n slug: RouteId.CUSTOMER_ORDERS_SINGLE,\n id: String(params.id),\n title: i18n\n .t('pages.orders.order_details')\n .replace(':id', String(data.order.reference_id ?? params.id)),\n },\n order: data.order,\n componentsOrder,\n };\n}\n","import type { HeadDescriptor } from '../../../utils/head';\nimport { buildHreflangAlternates } from '../../../utils/baseHead';\nimport { lazy } from 'react';\nimport { ordersLoader, orderSingleLoader } from './loader';\nimport type { OrdersPageProps, OrderSinglePageProps, OrdersSearchParams } from './types';\nimport type { IdParams } from '../../types';\nimport type { TwilightContext } from '../../../twilight/context';\nimport { RouteId } from '../../../router/route-ids';\n\n// Lazy-load components for code-splitting\nconst LazyOrdersPage = lazy(() => import('./OrdersPage').then((m) => ({ default: m.OrdersPage })));\nconst LazyOrderSinglePage = lazy(() =>\n import('./OrderSinglePage').then((m) => ({ default: m.OrderSinglePage }))\n);\n\nexport const OrdersPage = LazyOrdersPage;\nexport const OrderSinglePage = LazyOrderSinglePage;\nexport { ordersLoader, orderSingleLoader } from './loader';\nexport type {\n OrdersPageProps,\n OrderSinglePageProps,\n OrdersSearchParams,\n OrdersQuery,\n} from './types';\n\nasync function ordersLoaderWithExtend(\n ctx: { search?: OrdersSearchParams; locale?: string; with_items?: boolean | number },\n extend?: (\n data: OrdersPageProps,\n ctx: { params: Record<string, never> }\n ) => Promise<Record<string, unknown>> | Record<string, unknown>\n): Promise<OrdersPageProps> {\n const query = ctx.search;\n // ordersLoader already merges the result of `extend`; calling it again here ran it twice.\n return ordersLoader({ query, with_items: ctx.with_items }, extend);\n}\n\nfunction ordersHead(ctx: TwilightContext, data: OrdersPageProps): HeadDescriptor {\n const isPending = data.query?.status === 'pending';\n const base: HeadDescriptor = {\n title: ctx.i18n.t(isPending ? 'common.titles.pending_orders' : 'common.titles.orders'),\n description: data.page.description,\n alternateLanguages: buildHreflangAlternates(ctx.settings, ctx.location.pathname),\n };\n\n return base;\n}\n\nasync function orderSingleLoaderWithExtend(\n ctx: { params: IdParams; locale?: string },\n extend?: (\n data: OrderSinglePageProps,\n ctx: { params: IdParams }\n ) => Promise<Record<string, unknown>> | Record<string, unknown>\n): Promise<OrderSinglePageProps> {\n const data = await orderSingleLoader({ params: ctx.params });\n\n if (extend) {\n const extra = await extend(data, ctx);\n return { ...data, ...extra } as OrderSinglePageProps;\n }\n return data;\n}\n\nfunction orderSingleHead(ctx: TwilightContext, data: OrderSinglePageProps): HeadDescriptor {\n const base: HeadDescriptor = {\n title: data.page.title,\n description: data.page.description,\n alternateLanguages: buildHreflangAlternates(ctx.settings, ctx.location.pathname),\n };\n\n return base;\n}\n\nexport const Orders = {\n id: RouteId.CUSTOMER_ORDERS_INDEX,\n loader: ordersLoaderWithExtend,\n head: ordersHead,\n Component: LazyOrdersPage,\n} as const;\nexport const OrderSingle = {\n id: RouteId.CUSTOMER_ORDERS_SINGLE,\n loader: orderSingleLoaderWithExtend,\n head: orderSingleHead,\n Component: LazyOrderSinglePage,\n} as const;\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { orThrow } from './chunk-
|
|
2
|
-
import { getActiveScope, api } from './chunk-
|
|
1
|
+
import { orThrow } from './chunk-VPPSRRGK.js';
|
|
2
|
+
import { getActiveScope, api } from './chunk-BP6LUZXJ.js';
|
|
3
3
|
import { queryOptions } from '@tanstack/react-query';
|
|
4
4
|
|
|
5
5
|
var category = {
|
|
@@ -26,5 +26,5 @@ var category = {
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
export { category };
|
|
29
|
-
//# sourceMappingURL=chunk-
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
29
|
+
//# sourceMappingURL=chunk-MHVR2OUR.js.map
|
|
30
|
+
//# sourceMappingURL=chunk-MHVR2OUR.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/category.ts"],"names":[],"mappings":";;;;AAKO,IAAM,QAAA,GAAW;AAAA,EACtB,IAAA,EAAM,OAAO,EAAA,KAAkC;AAC7C,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CAAI,IAAI,CAAA,WAAA,EAAc,EAAE,CAAA,CAAE,CAAA,CAAE,IAAA,EAAyB;AAC5E,IAAA,OAAO,IAAA;AAAA,EACT,CAAA;AAAA,EAEA,aAAa,CAAC,EAAA,KAAkC,QAAQ,QAAA,CAAS,I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AAA,KACP,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,YAAA,EAAc,QAAA,EAAU,EAAE,CAAA;AAAA,MACrC,OAAA,EAAS,MAAM,QAAA,CAAS,IAAA,CAAK,EAAE;AAAA,KAChC,CAAA;AAAA,IAEH,IAAA,EAAM,MACJ,YAAA,CAAa;AAAA;AAAA,MAEX,QAAA,EAAU,CAAC,YAAA,EAAc,MAAA,EAAQ,EAAE,KAAA,EAAO,cAAA,IAAkB,CAAA;AAAA,MAC5D,OAAA,EAAS,MAAM,QAAA,CAAS,IAAA;AAAK,KAC9B;AAAA;AAEP","file":"chunk-MHVR2OUR.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api, getActiveScope } from './client';\nimport type { Category } from '../types';\nimport { orThrow } from '../providers/NavigationProvider';\n\nexport const category = {\n find: async (id: string): Promise<Category> => {\n const { data } = await api.get(`categories/${id}`).json<{ data: Category }>();\n return data;\n },\n\n findOrThrow: (id: string): Promise<Category> => orThrow(category.find(id)),\n\n list: async (): Promise<Category[]> => {\n const { data } = await api.get('categories').json<{ data: Category[] }>();\n return data ?? [];\n },\n\n queries: {\n detail: (id: string) =>\n queryOptions({\n queryKey: ['categories', 'detail', id],\n queryFn: () => category.find(id),\n }),\n\n list: () =>\n queryOptions({\n // Scope (branch) varies the API response — key must include it.\n queryKey: ['categories', 'list', { scope: getActiveScope() }],\n queryFn: () => category.list(),\n }),\n },\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { onSallaEvent } from './chunk-
|
|
1
|
+
import { onSallaEvent } from './chunk-4A5IAMNL.js';
|
|
2
2
|
import { useState, useCallback, useEffect } from 'react';
|
|
3
3
|
|
|
4
4
|
function useComments() {
|
|
@@ -16,5 +16,5 @@ function useComments() {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export { useComments };
|
|
19
|
-
//# sourceMappingURL=chunk-
|
|
20
|
-
//# sourceMappingURL=chunk-
|
|
19
|
+
//# sourceMappingURL=chunk-MOANE2YM.js.map
|
|
20
|
+
//# sourceMappingURL=chunk-MOANE2YM.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/useComments.ts"],"names":[],"mappings":";;;AAuCO,SAAS,WAAA,GAAiC;AAC/C,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,SAAS,CAAC,CAAA;AAEhD,EAAA,MAAM,OAAA,GAAU,YAAY,MAAM;AAChC,IAAA,cAAA,CAAe,CAAC,IAAA,KAAS,IAAA,GAAO,CAAC,CAAA;AAAA,EACnC,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,qBAAqB,MAAM;AAC/B,MAAA,cAAA,CAAe,CAAC,IAAA,KAAS,IAAA,GAAO,CAAC,CAAA;AAAA,IACnC,CAAA;AAEA,IAAA,OAAO,YAAA,CAAa,kBAAkB,kBAAkB,CAAA;AAAA,EAC1D,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO,EAAE,aAAa,OAAA,EAAQ;AAChC","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useComments.ts"],"names":[],"mappings":";;;AAuCO,SAAS,WAAA,GAAiC;AAC/C,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,SAAS,CAAC,CAAA;AAEhD,EAAA,MAAM,OAAA,GAAU,YAAY,MAAM;AAChC,IAAA,cAAA,CAAe,CAAC,IAAA,KAAS,IAAA,GAAO,CAAC,CAAA;AAAA,EACnC,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,qBAAqB,MAAM;AAC/B,MAAA,cAAA,CAAe,CAAC,IAAA,KAAS,IAAA,GAAO,CAAC,CAAA;AAAA,IACnC,CAAA;AAEA,IAAA,OAAO,YAAA,CAAa,kBAAkB,kBAAkB,CAAA;AAAA,EAC1D,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO,EAAE,aAAa,OAAA,EAAQ;AAChC","file":"chunk-MOANE2YM.js","sourcesContent":["import { useState, useEffect, useCallback } from 'react';\nimport { onSallaEvent } from '../utils/sdk-helpers';\n\n/**\n * UseCommentsResult - Return type for useComments hook\n *\n * @property commentsKey - Key to pass to salla-comments component for re-render\n * @property refresh - Function to manually trigger a comments refresh\n */\nexport interface UseCommentsResult {\n commentsKey: number;\n refresh: () => void;\n}\n\n/**\n * useComments - Hook for managing salla-comments web component re-renders\n *\n * Listens to the Salla SDK's comment added events and automatically\n * increments a re-render key for the salla-comments component. This\n * eliminates the need for full page reloads when comments are added.\n *\n * @returns Object with comments key for component re-rendering and manual refresh function\n *\n * @example\n * ```tsx\n * function ProductPage({ product }) {\n * const { commentsKey } = useComments();\n *\n * return (\n * <salla-comments\n * key={commentsKey}\n * item-id={product.id}\n * type=\"product\"\n * />\n * );\n * }\n * ```\n */\n\nexport function useComments(): UseCommentsResult {\n const [commentsKey, setCommentsKey] = useState(0);\n\n const refresh = useCallback(() => {\n setCommentsKey((prev) => prev + 1);\n }, []);\n\n useEffect(() => {\n const handleCommentAdded = () => {\n setCommentsKey((prev) => prev + 1);\n };\n\n return onSallaEvent('comment::added', handleCommentAdded);\n }, []);\n\n return { commentsKey, refresh };\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { filesCdn, cdn } from './chunk-
|
|
1
|
+
import { filesCdn, cdn } from './chunk-BP6LUZXJ.js';
|
|
2
2
|
import { storeTranslationsQueryKey, translationsQueryKey, composeMessages, isPlainObject } from './chunk-N2S25NXP.js';
|
|
3
3
|
import { queryOptions } from '@tanstack/react-query';
|
|
4
4
|
|
|
@@ -126,5 +126,5 @@ var translations = {
|
|
|
126
126
|
};
|
|
127
127
|
|
|
128
128
|
export { commonTranslationsPath, storeTranslationsPath, translations };
|
|
129
|
-
//# sourceMappingURL=chunk-
|
|
130
|
-
//# sourceMappingURL=chunk-
|
|
129
|
+
//# s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A;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,QAAA,EAAU,OAAO,OAAA,EAA0B,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQzC,cAAA,CAAe,sBAAsB,OAAA,EAAS,MAAM,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-TWVTIAMO.js","sourcesContent":["/**\n * @fileoverview Where a storefront's words come from.\n *\n * Two files, merged: the platform's copy for this language, and the merchant's\n * own edits for this language and this store. Both are plain JSON objects on\n * the uploader's CDN, one per language.\n *\n * ```\n * https://cdn.files.salla.network/translations/common/<locale>.json the platform's\n * https://cdn.files.salla.network/translations/<storeId>/<locale>.json the merchant's\n * ```\n *\n * **What this replaces, and why.** Until now the engine read a single global\n * file, `cdn.salla.network/js/translations.json`, holding every language keyed\n * `\"<locale>.trans\"`. Nothing publishes that file: it is an object last written\n * on 2026-03-26, carrying only `ar` and `en` where the platform has 39 locales,\n * 405 keys behind `Languages-Module` and 959 English strings textually\n * different from it. So every React storefront has been serving copy from\n * March, and a key added since has never reached one. It also carried no\n * merchant overrides at all — a merchant editing their theme's wording in the\n * Dashboard changed nothing on a React theme.\n *\n * **Merchant overrides are read, and only when there are any.** Getting here\n * took two corrections worth keeping.\n *\n * The first is the address. A merchant's own wording lives at\n * `translations/<storeId>/<locale>.json`, keyed by `store()->getRouteKey()` —\n * the Optimus-encoded numeric id. An early version addressed it with\n * `resolveStoreIdentifier()`, on the claim that the two are the same string.\n * That is true of the `store-identifier` *header*, which accepts a host, a\n * username or an id, and false of the R2 key: on a custom domain the resolver\n * returns `reefperfumes.com` and on a shared host a username like\n * `mtgr-alaatr-2`. Both 404, both then read as \"this store has no overrides\",\n * and the merchant's wording silently never appears — so the feature would have\n * worked under `?storeId=` alone, which is preview and localhost. It is\n * `settings.store.id` now, which is known only after the settings query.\n *\n * The second is when to ask at all. Most stores have never customised a word,\n * and a miss is an uncached round trip (`cf-cache-status: DYNAMIC` on the 404)\n * on the critical path of every SSR render. So the request is made only when\n * `settings.languages[<ISO>].has_custom_translations` says there is something\n * to get — a flag `Languages-Module` writes when a merchant saves a\n * translation. A store without overrides pays nothing, which is what made this\n * shippable at all.\n *\n * ⚠️ The flag is written on save, so a store whose wording predates it reads as\n * `false` until someone edits a translation or the backfill runs. That is a\n * store keeping today's behaviour, not a regression — React themes have never\n * read merchant overrides — but it does mean the feature is only as complete as\n * the backfill.\n *\n * **Rollout is by fallback, not by flag.** `translations/common/` is written by\n * a sync in the theme build service that may not have run yet, and a hard switch\n * would leave every storefront with no platform strings at all. A missing common\n * file therefore falls back to the old global one, which is exactly today's\n * behaviour — so this is safe to ship before the bucket is populated, and stops\n * using the fallback on its own once it is.\n */\nimport { queryOptions } from '@tanstack/react-query';\nimport { cdn, filesCdn } from './client';\nimport { storeTranslationsQueryKey, translationsQueryKey } from './translations-key';\nimport { composeMessages, isPlainObject, type Messages } from './messages';\nimport type { TranslationMessages } from '../providers/I18nProvider';\n\n/** The global file this used to be the only reader of. See the file comment. */\nconst LEGACY_GLOBAL_FILE = 'js/translations.json';\n\n/** One language of platform copy, shared by every store. */\nexport function commonTranslationsPath(locale: string): string {\n return `translations/common/${locale}.json`;\n}\n\n/**\n * One language of a single merchant's own wording.\n *\n * `storeId` is `settings.store.id`, which is the value `Languages-Module` names\n * the object with (`store()->getRouteKey()`, the Optimus-encoded numeric id).\n * It is **not** `resolveStoreIdentifier()`: that returns a hostname on a custom\n * domain and a username on a shared host, both of which 404 here and would read\n * as \"this merchant has no overrides\" — silently, on every store but a preview.\n */\nexport function storeTranslationsPath(storeId: string | number, locale: string): string {\n return `translations/${storeId}/${locale}.json`;\n}\n\n/**\n * Reads one language file, or `null` when there is nothing to read.\n *\n * A 404 is the ordinary answer, not a failure: most stores have never had a\n * word customised, so their file does not exist. Distinguishing it from a real\n * error matters only for the log — both end in `null` — but a warning on every\n * page load of every uncustomised store is a warning nobody will read.\n */\nasync function readLocaleFile(\n path: string,\n { failLoudly = false }: { failLoudly?: boolean } = {}\n): Promise<Messages | null> {\n /** A 404 always means \"absent\"; everything else is a failure to read. */\n const unreadable = (reason: string, cause?: unknown): null => {\n if (failLoudly) throw new Error(`[translations] ${path}: ${reason}`, { cause });\n console.warn('[translations]', reason, path, cause ?? '');\n return null;\n };\n\n try {\n const response = await filesCdn.get(path, { throwHttpErrors: false, timeout: 5000 });\n if (response.status === 404) return null;\n\n if (!response.ok) {\n return unreadable(`answered ${response.status}`);\n }\n\n const data: unknown = await response.json();\n if (!isPlainObject(data)) {\n return unreadable('is not a JSON object');\n }\n\n return data;\n } catch (error) {\n if (error instanceof Error && error.message.startsWith('[translations]')) throw error;\n return unreadable('could not be read', error);\n }\n}\n\n/**\n * The pre-CDN global file, sliced to one language.\n *\n * Only reached when `translations/common/<locale>.json` is missing, which is\n * the state of the bucket until the sync has run once.\n */\nasync function readLegacyGlobal(locale: string): Promise<Messages | null> {\n try {\n const data = await cdn.get(LEGACY_GLOBAL_FILE, { timeout: 5000 }).json<TranslationMessages>();\n const forLocale = data?.[`${locale}.trans`];\n return isPlainObject(forLocale) ? forLocale : null;\n } catch {\n console.warn('[translations] the legacy global file could not be read either');\n return null;\n }\n}\n\nexport const translations = {\n /**\n * The platform's copy for `locale`.\n *\n * One file, so one request. See the file comment for why the merchant's own\n * wording is not merged in here yet and what it is waiting on.\n */\n get: async (locale: string): Promise<TranslationMessages | null> => {\n const common = await readLocaleFile(commonTranslationsPath(locale));\n const base = common ?? (await readLegacyGlobal(locale));\n if (!base) return null;\n\n // Still wrapped in the `<locale>.trans` shape the rest of the engine reads.\n // `createI18nInstance` slices by that key and so does the SDK bridge in\n // `I18nProvider`; changing the envelope here would be a second change for\n // no gain, since one language is all any of them ever take out of it.\n return { [`${locale}.trans`]: base as Record<string, string> };\n },\n\n /**\n * This merchant's own wording for `locale`, or `null` if they have none.\n *\n * Only worth calling when `settings.languages[<ISO>].has_custom_translations`\n * says there is something to get. Most stores have never customised a word,\n * and a miss here is an uncached round trip — `cf-cache-status: DYNAMIC` on a\n * 404 — on the critical path of an SSR render. The flag is what makes this\n * free for everyone who does not use it.\n *\n * Returned unwrapped, unlike {@link translations.get}: this is merged into\n * that one's messages rather than handed to i18next on its own.\n */\n forStore: async (storeId: string | number, locale: string): Promise<Messages | null> =>\n // `failLoudly`, unlike the platform file: this is only ever called because\n // the settings said overrides exist, so a 500, a timeout or a body that is\n // not JSON is a failure to read them — not a store that has none. Returning\n // `null` there would cache \"no overrides\" as a success, skip the query's\n // retry, and serve Salla's wording in place of the merchant's until the\n // entry expired. A 404 still means absent, and `rootBeforeLoad` catches the\n // throw and keeps the platform copy, so the worst case is unchanged.\n readLocaleFile(storeTranslationsPath(storeId, locale), { failLoudly: true }),\n\n /**\n * The platform's copy for `locale` with this merchant's wording laid over it.\n *\n * Takes the two as values rather than fetching them, so the caller decides\n * whether the second request happens at all and both stay separately cached.\n */\n /**\n * The platform's copy for `locale` with this merchant's wording over it.\n *\n * Delegates to `composeMessages`, which every other reader of these two\n * entries also uses — see `api/messages.ts` for why there is exactly one.\n */\n merge: (\n common: TranslationMessages | null,\n overrides: Messages | null,\n locale: string\n ): TranslationMessages | null => composeMessages(common, overrides, locale) ?? null,\n\n queries: {\n /**\n * @param locale taken as an argument rather than read from the twilight\n * context, and that is load-bearing. This key is built on the server, on\n * hydration, and again lazily from the context accessor; if any of the\n * three read a locale the others had not been given yet, the hydrated page\n * would miss the dehydrated entry and refetch both files it was just\n * handed. Every caller already has the locale in hand.\n *\n * The store is deliberately **not** in the key. One document serves one\n * store — a request that names a different one is redirected with\n * `reloadDocument`, so the client never changes store under a live cache —\n * and adding a value that resolves from the request on the server and from\n * the injected env on the client is how a key stops matching across\n * hydration.\n */\n byLocale: (locale: string) =>\n queryOptions({\n queryKey: translationsQueryKey(locale),\n queryFn: () => translations.get(locale),\n }),\n\n /**\n * This merchant's overrides, cached apart from the platform's copy.\n *\n * Its own entry rather than a wider `byLocale` key, so the common file is\n * fetched and dehydrated once per language whatever the store does, and a\n * store with no overrides never has an entry at all. Both sides compute the\n * key from the settings payload, so the hydrated page finds what the server\n * dehydrated instead of refetching it.\n */\n byStore: (storeId: string | number, locale: string) =>\n queryOptions({\n queryKey: storeTranslationsQueryKey(storeId, locale),\n queryFn: () => translations.forStore(storeId, locale),\n }),\n },\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/api/translations.ts"],"names":[],"mappings":";;;;AAiEA,IAAM,kBAAA,GAAqB,sBAAA;AAGpB,SAAS,uBAAuB,MAAA,EAAwB;AAC7D,EAAA,OAAO,uBAAuB,MAAM,CAAA,KAAA,CAAA;AACtC;AAWO,SAAS,qBAAA,CAAsB,SAA0B,MAAA,EAAwB;AACtF,EAAA,OAAO,CAAA,a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,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-MYJL5MGW.js","sourcesContent":["/**\n * @fileoverview Where a storefront's words come from.\n *\n * Two files, merged: the platform's copy for this language, and the merchant's\n * own edits for this language and this store. Both are plain JSON objects on\n * the uploader's CDN, one per language.\n *\n * ```\n * https://cdn.files.salla.network/translations/common/<locale>.json the platform's\n * https://cdn.files.salla.network/translations/<storeId>/<locale>.json the merchant's\n * ```\n *\n * **What this replaces, and why.** Until now the engine read a single global\n * file, `cdn.salla.network/js/translations.json`, holding every language keyed\n * `\"<locale>.trans\"`. Nothing publishes that file: it is an object last written\n * on 2026-03-26, carrying only `ar` and `en` where the platform has 39 locales,\n * 405 keys behind `Languages-Module` and 959 English strings textually\n * different from it. So every React storefront has been serving copy from\n * March, and a key added since has never reached one. It also carried no\n * merchant overrides at all — a merchant editing their theme's wording in the\n * Dashboard changed nothing on a React theme.\n *\n * **Merchant overrides are read, and only when there are any.** Getting here\n * took two corrections worth keeping.\n *\n * The first is the address. A merchant's own wording lives at\n * `translations/<storeId>/<locale>.json`, keyed by `store()->getRouteKey()` —\n * the Optimus-encoded numeric id. An early version addressed it with\n * `resolveStoreIdentifier()`, on the claim that the two are the same string.\n * That is true of the `store-identifier` *header*, which accepts a host, a\n * username or an id, and false of the R2 key: on a custom domain the resolver\n * returns `reefperfumes.com` and on a shared host a username like\n * `mtgr-alaatr-2`. Both 404, both then read as \"this store has no overrides\",\n * and the merchant's wording silently never appears — so the feature would have\n * worked under `?storeId=` alone, which is preview and localhost. It is\n * `settings.store.id` now, which is known only after the settings query.\n *\n * The second is when to ask at all. Most stores have never customised a word,\n * and a miss is an uncached round trip (`cf-cache-status: DYNAMIC` on the 404)\n * on the critical path of every SSR render. So the request is made only when\n * `settings.languages[<ISO>].has_custom_translations` says there is something\n * to get — a flag `Languages-Module` writes when a merchant saves a\n * translation. A store without overrides pays nothing, which is what made this\n * shippable at all.\n *\n * ⚠️ The flag is written on save, so a store whose wording predates it reads as\n * `false` until someone edits a translation or the backfill runs. That is a\n * store keeping today's behaviour, not a regression — React themes have never\n * read merchant overrides — but it does mean the feature is only as complete as\n * the backfill.\n *\n * **Rollout is by fallback, not by flag.** `translations/common/` is written by\n * a sync in the theme build service that may not have run yet, and a hard switch\n * would leave every storefront with no platform strings at all. A missing common\n * file therefore falls back to the old global one, which is exactly today's\n * behaviour — so this is safe to ship before the bucket is populated, and stops\n * using the fallback on its own once it is.\n */\nimport { queryOptions } from '@tanstack/react-query';\nimport { cdn, filesCdn } from './client';\nimport { storeTranslationsQueryKey, translationsQueryKey } from './translations-key';\nimport { composeMessages, isPlainObject, type Messages } from './messages';\nimport type { TranslationMessages } from '../providers/I18nProvider';\n\n/** The global file this used to be the only reader of. See the file comment. */\nconst LEGACY_GLOBAL_FILE = 'js/translations.json';\n\n/** One language of platform copy, shared by every store. */\nexport function commonTranslationsPath(locale: string): string {\n return `translations/common/${locale}.json`;\n}\n\n/**\n * One language of a single merchant's own wording.\n *\n * `storeId` is `settings.store.id`, which is the value `Languages-Module` names\n * the object with (`store()->getRouteKey()`, the Optimus-encoded numeric id).\n * It is **not** `resolveStoreIdentifier()`: that returns a hostname on a custom\n * domain and a username on a shared host, both of which 404 here and would read\n * as \"this merchant has no overrides\" — silently, on every store but a preview.\n */\nexport function storeTranslationsPath(storeId: string | number, locale: string): string {\n return `translations/${storeId}/${locale}.json`;\n}\n\n/**\n * Reads one language file, or `null` when there is nothing to read.\n *\n * A 404 is the ordinary answer, not a failure: most stores have never had a\n * word customised, so their file does not exist. Distinguishing it from a real\n * error matters only for the log — both end in `null` — but a warning on every\n * page load of every uncustomised store is a warning nobody will read.\n */\nasync function readLocaleFile(\n path: string,\n { failLoudly = false }: { failLoudly?: boolean } = {}\n): Promise<Messages | null> {\n /** A 404 always means \"absent\"; everything else is a failure to read. */\n const unreadable = (reason: string, cause?: unknown): null => {\n if (failLoudly) throw new Error(`[translations] ${path}: ${reason}`, { cause });\n console.warn('[translations]', reason, path, cause ?? '');\n return null;\n };\n\n try {\n const response = await filesCdn.get(path, { throwHttpErrors: false, timeout: 5000 });\n if (response.status === 404) return null;\n\n if (!response.ok) {\n return unreadable(`answered ${response.status}`);\n }\n\n const data: unknown = await response.json();\n if (!isPlainObject(data)) {\n return unreadable('is not a JSON object');\n }\n\n return data;\n } catch (error) {\n if (error instanceof Error && error.message.startsWith('[translations]')) throw error;\n return unreadable('could not be read', error);\n }\n}\n\n/**\n * The pre-CDN global file, sliced to one language.\n *\n * Only reached when `translations/common/<locale>.json` is missing, which is\n * the state of the bucket until the sync has run once.\n */\nasync function readLegacyGlobal(locale: string): Promise<Messages | null> {\n try {\n const data = await cdn.get(LEGACY_GLOBAL_FILE, { timeout: 5000 }).json<TranslationMessages>();\n const forLocale = data?.[`${locale}.trans`];\n return isPlainObject(forLocale) ? forLocale : null;\n } catch {\n console.warn('[translations] the legacy global file could not be read either');\n return null;\n }\n}\n\nexport const translations = {\n /**\n * The platform's copy for `locale`.\n *\n * One file, so one request. See the file comment for why the merchant's own\n * wording is not merged in here yet and what it is waiting on.\n */\n get: async (locale: string): Promise<TranslationMessages | null> => {\n const common = await readLocaleFile(commonTranslationsPath(locale));\n const base = common ?? (await readLegacyGlobal(locale));\n if (!base) return null;\n\n // Still wrapped in the `<locale>.trans` shape the rest of the engine reads.\n // `createI18nInstance` slices by that key and so does the SDK bridge in\n // `I18nProvider`; changing the envelope here would be a second change for\n // no gain, since one language is all any of them ever take out of it.\n return { [`${locale}.trans`]: base as Record<string, string> };\n },\n\n /**\n * This merchant's own wording for `locale`, or `null` if they have none.\n *\n * Only worth calling when `settings.languages[<ISO>].has_custom_translations`\n * says there is something to get. Most stores have never customised a word,\n * and a miss here is an uncached round trip — `cf-cache-status: DYNAMIC` on a\n * 404 — on the critical path of an SSR render. The flag is what makes this\n * free for everyone who does not use it.\n *\n * Returned unwrapped, unlike {@link translations.get}: this is merged into\n * that one's messages rather than handed to i18next on its own.\n */\n forStore: async (storeId: string | number, locale: string): Promise<Messages | null> =>\n // `failLoudly`, unlike the platform file: this is only ever called because\n // the settings said overrides exist, so a 500, a timeout or a body that is\n // not JSON is a failure to read them — not a store that has none. Returning\n // `null` there would cache \"no overrides\" as a success, skip the query's\n // retry, and serve Salla's wording in place of the merchant's until the\n // entry expired. A 404 still means absent, and `rootBeforeLoad` catches the\n // throw and keeps the platform copy, so the worst case is unchanged.\n readLocaleFile(storeTranslationsPath(storeId, locale), { failLoudly: true }),\n\n /**\n * The platform's copy for `locale` with this merchant's wording laid over it.\n *\n * Takes the two as values rather than fetching them, so the caller decides\n * whether the second request happens at all and both stay separately cached.\n */\n /**\n * The platform's copy for `locale` with this merchant's wording over it.\n *\n * Delegates to `composeMessages`, which every other reader of these two\n * entries also uses — see `api/messages.ts` for why there is exactly one.\n */\n merge: (\n common: TranslationMessages | null,\n overrides: Messages | null,\n locale: string\n ): TranslationMessages | null => composeMessages(common, overrides, locale) ?? null,\n\n queries: {\n /**\n * @param locale taken as an argument rather than read from the twilight\n * context, and that is load-bearing. This key is built on the server, on\n * hydration, and again lazily from the context accessor; if any of the\n * three read a locale the others had not been given yet, the hydrated page\n * would miss the dehydrated entry and refetch both files it was just\n * handed. Every caller already has the locale in hand.\n *\n * The store is deliberately **not** in the key. One document serves one\n * store — a request that names a different one is redirected with\n * `reloadDocument`, so the client never changes store under a live cache —\n * and adding a value that resolves from the request on the server and from\n * the injected env on the client is how a key stops matching across\n * hydration.\n */\n byLocale: (locale: string) =>\n queryOptions({\n queryKey: translationsQueryKey(locale),\n queryFn: () => translations.get(locale),\n }),\n\n /**\n * This merchant's overrides, cached apart from the platform's copy.\n *\n * Its own entry rather than a wider `byLocale` key, so the common file is\n * fetched and dehydrated once per language whatever the store does, and a\n * store with no overrides never has an entry at all. Both sides compute the\n * key from the settings payload, so the hydrated page finds what the server\n * dehydrated instead of refetching it.\n */\n byStore: (storeId: string | number, locale: string) =>\n queryOptions({\n queryKey: storeTranslationsQueryKey(storeId, locale),\n queryFn: () => translations.forStore(storeId, locale),\n }),\n },\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useOpeningHours } from './chunk-
|
|
2
|
-
import { useIsProduct } from './chunk-
|
|
1
|
+
import { useOpeningHours } from './chunk-S3R7B6QH.js';
|
|
2
|
+
import { useIsProduct } from './chunk-VPPSRRGK.js';
|
|
3
3
|
import { useTranslation } from './chunk-TYNZ5B2B.js';
|
|
4
4
|
import { useTwilight } from './chunk-DF6FBKDN.js';
|
|
5
5
|
import { useState } from 'react';
|
|
@@ -54,5 +54,5 @@ function StoreClosedNotification(_props) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
export { StoreClosedNotification };
|
|
57
|
-
//# sourceMappingURL=chunk-
|
|
58
|
-
//# sourceMappingURL=chunk-
|
|
57
|
+
//# sourceMappingURL=chunk-NDJWR7EF.js.map
|
|
58
|
+
//# sourceMappingURL=chunk-NDJWR7EF.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/store/StoreClosed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AA,uBACE,IAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAU,cAAA;AAAA,MACV,EAAA,EAAG,2BAAA;AAAA,MACH,aAAA,EAAY,2BAAA;AAAA,MACZ,KAAA,EAAO;AAAA,QACL,eAAA,EAAiB,SAAA;AAAA,QACjB,KAAA,EAAO,MAAA;AAAA,QACP,OAAA,EAAS,WAAA;AAAA,QACT,OAAA,EAAS,MAAA;AAAA,QACT,UAAA,EAAY,QAAA;AAAA,QACZ,cAAA,EAAgB,QAAA;AAAA,QAChB,QAAA,EAAU;AAAA,OACZ;AAAA,MAEA,QAAA,EAAA;AAAA,wBAAA,GAAA;AAAA,UAAC,GAAA;AAAA,UAAA;AAAA,YACC,IAAA,EAAK,GAAA;AAAA,YACL,EAAA,EAAG,cAAA;AAAA,YACH,OAAA,EAAS,WAAA;AAAA,YACT,KAAA,EAAO,EAAE,QAAA,EAAU,UAAA,EAAY,MAAM,EAAA,EAAI,KAAA,EAAO,MAAA,EAAQ,cAAA,EAAgB,MAAA,EAAO;AAAA,YAE/E,QAAA,kBAAA,GAAA,CAAC,GAAA,EAAA,EAAE,SAAA,EAAU,cAAA,EAAe;AAAA;AAAA,SAC9B;AAAA,wBACA,GAAA,CAAC,GAAA,EAAA,EAAE,KAAA,EAAO,EAAE,MAAA,EAAQ,CAAA,EAAG,SAAA,EAAW,QAAA,EAAU,IAAA,EAAM,CAAA,EAAE,EACjD,QAAA,EAAA,CAAA,CAAE,2BAAA,EAA6B;AAAA,UAC9B,YAAA,EAAc,qPAAkD,iBAAiB,CAAA,CAAA,CAAA;AAAA,UACjF,QAAA,EAAU;AAAA,SACX,CAAA,EACH;AAAA;AAAA;AAAA,GACF;AAEJ","file":"chunk-NDJWR7EF.js","sourcesContent":["import { useState } from 'react';\nimport { useIsProduct } from '../../providers/NavigationProvider';\nimport { useTwilight } from '../../providers/TwilightProvider';\nimport { useOpeningHours } from '../../hooks/useOpeningHours';\nimport { useTranslation } from '../../providers/I18nProvider';\n\nexport interface StoreClosedNotificationProps {\n /** Whether to show the notification (defaults to true when store is closed on product page) */\n show?: boolean;\n}\n\n/**\n * StoreClosedNotification - Shows a notification bar when the store is closed.\n *\n * Mirrors PHP ReceivingOrdersTimesWidget:\n * - Only shows on product pages\n * - Only shows when store is closed for receiving orders\n * - Displays when the store will open next\n * - Has a close button to dismiss\n *\n * Injected via hook registry at body:start.\n */\nexport function StoreClosedNotification(_props: StoreClosedNotificationProps) {\n const { store } = useTwilight();\n const { t } = useTranslation();\n const { isOpen, isEnabled, nextOpenFormatted } = useOpeningHours(store.settings?.opening_hours);\n const [dismissed, setDismissed] = useState(false);\n\n // Check if we're on a product page\n const isProductPage = useIsProduct();\n\n // Conditions: product page, opening hours enabled, store closed, not dismissed\n if (!isProductPage || !isEnabled || isOpen || dismissed || !nextOpenFormatted) {\n return null;\n }\n\n const handleClose = (e: React.MouseEvent) => {\n e.preventDefault();\n setDismissed(true);\n };\n\n return (\n <div\n className=\"store-notify\"\n id=\"store-closed-notification\"\n data-testid=\"store-closed-notification\"\n style={{\n backgroundColor: '#d63031',\n color: '#fff',\n padding: '10px 15px',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n position: 'relative',\n }}\n >\n <a\n href=\"#\"\n id=\"notify-close\"\n onClick={handleClose}\n style={{ position: 'absolute', left: 15, color: '#fff', textDecoration: 'none' }}\n >\n <i className=\"sicon-cancel\" />\n </a>\n <p style={{ margin: 0, textAlign: 'center', flex: 1 }}>\n {t('store.closed_notification', {\n defaultValue: `المتجر حاليا مغلق لاستقبال الطلبات وسيتم فتحه (${nextOpenFormatted})`,\n nextOpen: nextOpenFormatted,\n })}\n </p>\n </div>\n );\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { orThrow } from './chunk-
|
|
2
|
-
import { getAuthToken, api } from './chunk-
|
|
1
|
+
import { orThrow } from './chunk-VPPSRRGK.js';
|
|
2
|
+
import { getAuthToken, api } from './chunk-BP6LUZXJ.js';
|
|
3
3
|
import { queryOptions } from '@tanstack/react-query';
|
|
4
4
|
|
|
5
5
|
var loyalty = {
|
|
@@ -29,5 +29,5 @@ var loyalty = {
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
export { loyalty };
|
|
32
|
-
//# sourceMappingURL=chunk-
|
|
33
|
-
//# sourceMappingURL=chunk-
|
|
32
|
+
//# sourceMappingURL=chunk-NJWKVTQD.js.map
|
|
33
|
+
//# sourceMappingURL=chunk-NJWKVTQD.js.map
|