@salla.sa/twilight-theme-engine 1.0.185 → 1.0.187
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-LCSBAN3M.js → AddToCartForm-G4US2K7W.js} +3 -3
- package/dist/{AddToCartForm-LCSBAN3M.js.map → AddToCartForm-G4US2K7W.js.map} +1 -1
- package/dist/{BlogAuthorPage-ZYBQYUV7.js → BlogAuthorPage-222QDUPB.js} +19 -19
- package/dist/{BlogAuthorPage-ZYBQYUV7.js.map → BlogAuthorPage-222QDUPB.js.map} +1 -1
- package/dist/{BlogCategoryPage-O2ORXWYL.js → BlogCategoryPage-NHFUGGXZ.js} +19 -19
- package/dist/{BlogCategoryPage-O2ORXWYL.js.map → BlogCategoryPage-NHFUGGXZ.js.map} +1 -1
- package/dist/{BlogPage-RXWT2CV3.js → BlogPage-J3EMWHJL.js} +17 -17
- package/dist/{BlogPage-RXWT2CV3.js.map → BlogPage-J3EMWHJL.js.map} +1 -1
- package/dist/{BlogSinglePage-QY42WRDZ.js → BlogSinglePage-S3ZVQB4O.js} +17 -17
- package/dist/{BlogSinglePage-QY42WRDZ.js.map → BlogSinglePage-S3ZVQB4O.js.map} +1 -1
- package/dist/{BlogTagPage-P7B3CFAO.js → BlogTagPage-WMO6LP6V.js} +19 -19
- package/dist/{BlogTagPage-P7B3CFAO.js.map → BlogTagPage-WMO6LP6V.js.map} +1 -1
- package/dist/{BrandsPage-FV57PLGZ.js → BrandsPage-N77PNHAY.js} +18 -18
- package/dist/{BrandsPage-FV57PLGZ.js.map → BrandsPage-N77PNHAY.js.map} +1 -1
- package/dist/{Breadcrumb-TM4EXKTO.js → Breadcrumb-CH35SNV3.js} +17 -17
- package/dist/{Breadcrumb-TM4EXKTO.js.map → Breadcrumb-CH35SNV3.js.map} +1 -1
- package/dist/{CanvasOverlay-YNXYF27N.js → CanvasOverlay-OTXDNGBZ.js} +3 -3
- package/dist/{CanvasOverlay-YNXYF27N.js.map → CanvasOverlay-OTXDNGBZ.js.map} +1 -1
- package/dist/{CartItem-DVQET7SW.js → CartItem-UPANY4SI.js} +17 -17
- package/dist/{CartItem-DVQET7SW.js.map → CartItem-UPANY4SI.js.map} +1 -1
- package/dist/{CartSummary-XGMWN6PP.js → CartSummary-CSNEFF4A.js} +17 -17
- package/dist/{CartSummary-XGMWN6PP.js.map → CartSummary-CSNEFF4A.js.map} +1 -1
- package/dist/{Copyright-OTQZENUE.js → Copyright-6GQAFJLC.js} +3 -3
- package/dist/{Copyright-OTQZENUE.js.map → Copyright-6GQAFJLC.js.map} +1 -1
- package/dist/{CustomerLayout-IMI4SJDO.js → CustomerLayout-FHYJ2LCS.js} +17 -17
- package/dist/{CustomerLayout-IMI4SJDO.js.map → CustomerLayout-FHYJ2LCS.js.map} +1 -1
- package/dist/{Footer-JUHWLQCI.js → Footer-AZZTIGG2.js} +3 -3
- package/dist/{Footer-JUHWLQCI.js.map → Footer-AZZTIGG2.js.map} +1 -1
- package/dist/GoogleTag-UYTAI5BS.js +15 -0
- package/dist/{GoogleTag-VBFDNEU6.js.map → GoogleTag-UYTAI5BS.js.map} +1 -1
- package/dist/{Header-P46ZDWIQ.js → Header-QMMLLHII.js} +8 -8
- package/dist/{Header-P46ZDWIQ.js.map → Header-QMMLLHII.js.map} +1 -1
- package/dist/{LatestProducts-QWTQZVBJ.js → LatestProducts-NRHWV3GJ.js} +19 -19
- package/dist/{LatestProducts-QWTQZVBJ.js.map → LatestProducts-NRHWV3GJ.js.map} +1 -1
- package/dist/{LoyaltyPage-LJOJRJB5.js → LoyaltyPage-HWQSXH75.js} +17 -17
- package/dist/{LoyaltyPage-LJOJRJB5.js.map → LoyaltyPage-HWQSXH75.js.map} +1 -1
- package/dist/{LoyaltyPointsPage-4JYLRGKN.js → LoyaltyPointsPage-6WAVG4LY.js} +6 -6
- package/dist/{LoyaltyPointsPage-4JYLRGKN.js.map → LoyaltyPointsPage-6WAVG4LY.js.map} +1 -1
- package/dist/{MainMenu-LK22UWZO.js → MainMenu-SLR7KZNZ.js} +5 -5
- package/dist/{MainMenu-LK22UWZO.js.map → MainMenu-SLR7KZNZ.js.map} +1 -1
- package/dist/{MasterLayout-ZA32NBT4.js → MasterLayout-WRDTHUZD.js} +17 -17
- package/dist/{MasterLayout-ZA32NBT4.js.map → MasterLayout-WRDTHUZD.js.map} +1 -1
- package/dist/{MobileMenu-MMDICOBU.js → MobileMenu-N7XUYRY7.js} +18 -18
- package/dist/{MobileMenu-MMDICOBU.js.map → MobileMenu-N7XUYRY7.js.map} +1 -1
- package/dist/{NotificationsPage-V5JAFDFP.js → NotificationsPage-D3M5HSOT.js} +17 -17
- package/dist/{NotificationsPage-V5JAFDFP.js.map → NotificationsPage-D3M5HSOT.js.map} +1 -1
- package/dist/{OrderSinglePage-EKJ5Q4EM.js → OrderSinglePage-SJGZX2PX.js} +18 -18
- package/dist/{OrderSinglePage-EKJ5Q4EM.js.map → OrderSinglePage-SJGZX2PX.js.map} +1 -1
- package/dist/{OrdersPage-JGTRYEST.js → OrdersPage-SVAHMVKY.js} +17 -17
- package/dist/{OrdersPage-JGTRYEST.js.map → OrdersPage-SVAHMVKY.js.map} +1 -1
- package/dist/{PageSingle-J6JBAD45.js → PageSingle-FC6OZBXQ.js} +3 -3
- package/dist/{PageSingle-J6JBAD45.js.map → PageSingle-FC6OZBXQ.js.map} +1 -1
- package/dist/ProductDetails-GJQH2SYY.js +24 -0
- package/dist/ProductDetails-GJQH2SYY.js.map +1 -0
- package/dist/{ProfilePage-SWFGEY5Y.js → ProfilePage-OWWPOUBQ.js} +17 -17
- package/dist/{ProfilePage-SWFGEY5Y.js.map → ProfilePage-OWWPOUBQ.js.map} +1 -1
- package/dist/{ReviewsPage-A733RD4D.js → ReviewsPage-7BUBNVNY.js} +3 -3
- package/dist/{ReviewsPage-A733RD4D.js.map → ReviewsPage-7BUBNVNY.js.map} +1 -1
- package/dist/{SeoCartWidget-DIOS62BL.js → SeoCartWidget-L6BGLQ5D.js} +17 -17
- package/dist/{SeoCartWidget-DIOS62BL.js.map → SeoCartWidget-L6BGLQ5D.js.map} +1 -1
- package/dist/{SettingsPage-FZBUPLLA.js → SettingsPage-Q5IDLYYH.js} +17 -17
- package/dist/{SettingsPage-FZBUPLLA.js.map → SettingsPage-Q5IDLYYH.js.map} +1 -1
- package/dist/{StoreClosedNotification-ZWRTPUPP.js → StoreClosedNotification-N7CYMV76.js} +18 -18
- package/dist/{StoreClosedNotification-ZWRTPUPP.js.map → StoreClosedNotification-N7CYMV76.js.map} +1 -1
- package/dist/{TestimonialsPage-6TSZIUZX.js → TestimonialsPage-7PJLORJ3.js} +3 -3
- package/dist/{TestimonialsPage-6TSZIUZX.js.map → TestimonialsPage-7PJLORJ3.js.map} +1 -1
- package/dist/{ThankYouPage-RPZK6SRW.js → ThankYouPage-52YKBIXF.js} +17 -17
- package/dist/{ThankYouPage-RPZK6SRW.js.map → ThankYouPage-52YKBIXF.js.map} +1 -1
- package/dist/{WalletPage-42RFDAUY.js → WalletPage-EWRWZM7U.js} +18 -18
- package/dist/{WalletPage-42RFDAUY.js.map → WalletPage-EWRWZM7U.js.map} +1 -1
- package/dist/{WebMcpTools-DLW67GJM.js → WebMcpTools-4M2KPD5D.js} +5 -5
- package/dist/{WebMcpTools-DLW67GJM.js.map → WebMcpTools-4M2KPD5D.js.map} +1 -1
- package/dist/{WishlistPage-HW3ZQSGB.js → WishlistPage-YI3BJJBG.js} +19 -19
- package/dist/{WishlistPage-HW3ZQSGB.js.map → WishlistPage-YI3BJJBG.js.map} +1 -1
- package/dist/api/advertisement.js +2 -2
- package/dist/api/apps.js +2 -2
- package/dist/api/blog.js +3 -3
- package/dist/api/brands.js +3 -3
- package/dist/api/cart.js +3 -3
- package/dist/api/category.js +3 -3
- package/dist/api/client.js +1 -1
- package/dist/api/custom-url.js +2 -2
- package/dist/api/home.js +2 -2
- package/dist/api/loyalty.js +3 -3
- package/dist/api/menu.js +2 -2
- package/dist/api/notification.js +2 -2
- package/dist/api/order.js +3 -3
- package/dist/api/page.js +3 -3
- package/dist/api/product.js +3 -3
- package/dist/api/profile.js +1 -1
- package/dist/api/store.js +2 -2
- package/dist/api/translations.js +2 -2
- package/dist/api/user.js +2 -2
- package/dist/api/wallet.js +2 -2
- package/dist/api/wishlist.js +4 -4
- package/dist/{chunk-JZOBRBDY.js → chunk-25NSKD6D.js} +3 -3
- package/dist/{chunk-JZOBRBDY.js.map → chunk-25NSKD6D.js.map} +1 -1
- package/dist/{chunk-GYHZYJUL.js → chunk-2SKYTGSD.js} +3 -3
- package/dist/{chunk-GYHZYJUL.js.map → chunk-2SKYTGSD.js.map} +1 -1
- package/dist/{chunk-CSR5SCSP.js → chunk-2XVF3P7U.js} +4 -4
- package/dist/{chunk-CSR5SCSP.js.map → chunk-2XVF3P7U.js.map} +1 -1
- package/dist/chunk-35JSGMTO.js +53 -0
- package/dist/chunk-35JSGMTO.js.map +1 -0
- package/dist/{chunk-QHF66D3P.js → chunk-3MCICPB3.js} +4 -4
- package/dist/{chunk-QHF66D3P.js.map → chunk-3MCICPB3.js.map} +1 -1
- package/dist/{chunk-P65YIT3J.js → chunk-3NFAXTIG.js} +3 -3
- package/dist/{chunk-P65YIT3J.js.map → chunk-3NFAXTIG.js.map} +1 -1
- package/dist/{chunk-J3RK2CPN.js → chunk-3QAVHZBT.js} +3 -3
- package/dist/{chunk-J3RK2CPN.js.map → chunk-3QAVHZBT.js.map} +1 -1
- package/dist/{chunk-R2J4BECK.js → chunk-3QTCAC7A.js} +4 -4
- package/dist/{chunk-R2J4BECK.js.map → chunk-3QTCAC7A.js.map} +1 -1
- package/dist/{chunk-CDO7VXWO.js → chunk-5F2LF3P4.js} +4 -4
- package/dist/{chunk-CDO7VXWO.js.map → chunk-5F2LF3P4.js.map} +1 -1
- package/dist/{chunk-VEUY4U3G.js → chunk-7SVJZ6VQ.js} +3 -3
- package/dist/{chunk-VEUY4U3G.js.map → chunk-7SVJZ6VQ.js.map} +1 -1
- package/dist/{chunk-53IXAXYU.js → chunk-A3NSQLNV.js} +3 -3
- package/dist/{chunk-53IXAXYU.js.map → chunk-A3NSQLNV.js.map} +1 -1
- package/dist/{chunk-5BICYVE3.js → chunk-A7VR5G2M.js} +4 -4
- package/dist/{chunk-5BICYVE3.js.map → chunk-A7VR5G2M.js.map} +1 -1
- package/dist/{chunk-LKITJWSS.js → chunk-BG7GNCYV.js} +3 -3
- package/dist/{chunk-LKITJWSS.js.map → chunk-BG7GNCYV.js.map} +1 -1
- package/dist/{chunk-L3DCK3MF.js → chunk-CKQGZDW7.js} +3 -3
- package/dist/{chunk-L3DCK3MF.js.map → chunk-CKQGZDW7.js.map} +1 -1
- package/dist/{chunk-KFF5J6JN.js → chunk-E5HZTOWZ.js} +19 -19
- package/dist/{chunk-KFF5J6JN.js.map → chunk-E5HZTOWZ.js.map} +1 -1
- package/dist/{chunk-EV3MX2ZF.js → chunk-EFQJXQVA.js} +3 -3
- package/dist/{chunk-EV3MX2ZF.js.map → chunk-EFQJXQVA.js.map} +1 -1
- package/dist/{chunk-E6SPIMQ5.js → chunk-EIDJUUBN.js} +5 -5
- package/dist/{chunk-E6SPIMQ5.js.map → chunk-EIDJUUBN.js.map} +1 -1
- package/dist/{chunk-CZHLGKXR.js → chunk-FKXP7SNP.js} +5 -5
- package/dist/{chunk-CZHLGKXR.js.map → chunk-FKXP7SNP.js.map} +1 -1
- package/dist/{chunk-5YLKWMNP.js → chunk-GIHEV2RT.js} +3 -3
- package/dist/{chunk-5YLKWMNP.js.map → chunk-GIHEV2RT.js.map} +1 -1
- package/dist/{chunk-5KEYJA77.js → chunk-GUEKZN22.js} +4 -4
- package/dist/{chunk-5KEYJA77.js.map → chunk-GUEKZN22.js.map} +1 -1
- package/dist/{chunk-EXPUSY6B.js → chunk-GZWEIGZP.js} +3 -3
- package/dist/{chunk-EXPUSY6B.js.map → chunk-GZWEIGZP.js.map} +1 -1
- package/dist/{chunk-KMAKPTHT.js → chunk-HZ2YCYJ5.js} +4 -4
- package/dist/{chunk-KMAKPTHT.js.map → chunk-HZ2YCYJ5.js.map} +1 -1
- package/dist/{chunk-Q2Z4IPAT.js → chunk-J3456BT4.js} +7 -7
- package/dist/{chunk-Q2Z4IPAT.js.map → chunk-J3456BT4.js.map} +1 -1
- package/dist/{chunk-MHSASWOS.js → chunk-K7F7U5NR.js} +4 -4
- package/dist/{chunk-MHSASWOS.js.map → chunk-K7F7U5NR.js.map} +1 -1
- package/dist/{chunk-V5FXJ6RG.js → chunk-KHIEGO2C.js} +3 -3
- package/dist/{chunk-V5FXJ6RG.js.map → chunk-KHIEGO2C.js.map} +1 -1
- package/dist/{chunk-TQ4UZJSG.js → chunk-KZ3MXRA7.js} +7 -7
- package/dist/{chunk-TQ4UZJSG.js.map → chunk-KZ3MXRA7.js.map} +1 -1
- package/dist/{chunk-QY77WLK3.js → chunk-MQ6TJ4AJ.js} +3 -3
- package/dist/{chunk-QY77WLK3.js.map → chunk-MQ6TJ4AJ.js.map} +1 -1
- package/dist/{chunk-OOZ7R5J6.js → chunk-NB5A65PP.js} +5 -5
- package/dist/{chunk-OOZ7R5J6.js.map → chunk-NB5A65PP.js.map} +1 -1
- package/dist/{chunk-SD4TYJN3.js → chunk-NE5XQJLZ.js} +3 -3
- package/dist/{chunk-SD4TYJN3.js.map → chunk-NE5XQJLZ.js.map} +1 -1
- package/dist/{chunk-JMJTCJGX.js → chunk-NEPSTGF6.js} +4 -4
- package/dist/{chunk-JMJTCJGX.js.map → chunk-NEPSTGF6.js.map} +1 -1
- package/dist/{chunk-7GUKPZQ6.js → chunk-NMVC5IGS.js} +3 -3
- package/dist/{chunk-7GUKPZQ6.js.map → chunk-NMVC5IGS.js.map} +1 -1
- package/dist/{chunk-QXAUEOHK.js → chunk-NUURM3QI.js} +2 -2
- package/dist/{chunk-QXAUEOHK.js.map → chunk-NUURM3QI.js.map} +1 -1
- package/dist/{ProductDetails-XLM3FGBY.js → chunk-OTJ3K76X.js} +5 -18
- package/dist/chunk-OTJ3K76X.js.map +1 -0
- package/dist/{chunk-XYVU5KGN.js → chunk-RRJZJHZK.js} +3 -3
- package/dist/{chunk-XYVU5KGN.js.map → chunk-RRJZJHZK.js.map} +1 -1
- package/dist/{chunk-DECKE4BB.js → chunk-SGEJUTTK.js} +3 -3
- package/dist/{chunk-DECKE4BB.js.map → chunk-SGEJUTTK.js.map} +1 -1
- package/dist/{chunk-CDMXPX4Z.js → chunk-TLE6US5E.js} +14 -14
- package/dist/{chunk-CDMXPX4Z.js.map → chunk-TLE6US5E.js.map} +1 -1
- package/dist/{chunk-2XFHSSMR.js → chunk-UVUG2YMJ.js} +4 -4
- package/dist/{chunk-2XFHSSMR.js.map → chunk-UVUG2YMJ.js.map} +1 -1
- package/dist/{chunk-XG2LXO24.js → chunk-V33YXUJZ.js} +7 -7
- package/dist/{chunk-XG2LXO24.js.map → chunk-V33YXUJZ.js.map} +1 -1
- package/dist/{chunk-R2ZCGB4G.js → chunk-VUQICWEC.js} +6 -6
- package/dist/{chunk-R2ZCGB4G.js.map → chunk-VUQICWEC.js.map} +1 -1
- package/dist/{chunk-HHZ7HY3D.js → chunk-VYPVJ4C6.js} +5 -5
- package/dist/{chunk-HHZ7HY3D.js.map → chunk-VYPVJ4C6.js.map} +1 -1
- package/dist/{chunk-CRW77N4M.js → chunk-W43EOOMR.js} +3 -3
- package/dist/{chunk-CRW77N4M.js.map → chunk-W43EOOMR.js.map} +1 -1
- package/dist/{chunk-53CWWIKH.js → chunk-WDIKLUO5.js} +4 -4
- package/dist/{chunk-53CWWIKH.js.map → chunk-WDIKLUO5.js.map} +1 -1
- package/dist/{chunk-AYZ6MRDT.js → chunk-WZDQRIFK.js} +4 -4
- package/dist/{chunk-AYZ6MRDT.js.map → chunk-WZDQRIFK.js.map} +1 -1
- package/dist/{chunk-5TGDSE64.js → chunk-XK2T6G6A.js} +4 -4
- package/dist/{chunk-5TGDSE64.js.map → chunk-XK2T6G6A.js.map} +1 -1
- package/dist/{chunk-N2346B57.js → chunk-XN6OZJHX.js} +3 -3
- package/dist/{chunk-N2346B57.js.map → chunk-XN6OZJHX.js.map} +1 -1
- package/dist/{chunk-3TZIFRGC.js → chunk-XRZ43AAK.js} +4 -4
- package/dist/{chunk-3TZIFRGC.js.map → chunk-XRZ43AAK.js.map} +1 -1
- package/dist/{chunk-5VWFGJS2.js → chunk-XWHSTFSB.js} +3 -3
- package/dist/{chunk-5VWFGJS2.js.map → chunk-XWHSTFSB.js.map} +1 -1
- package/dist/{chunk-3C55I5FU.js → chunk-YD7DCIWM.js} +3 -3
- package/dist/{chunk-3C55I5FU.js.map → chunk-YD7DCIWM.js.map} +1 -1
- package/dist/{chunk-MHA726OF.js → chunk-ZCD73EGZ.js} +4 -4
- package/dist/{chunk-MHA726OF.js.map → chunk-ZCD73EGZ.js.map} +1 -1
- package/dist/{chunk-3AOC4XPC.js → chunk-ZYL6NQ75.js} +3 -3
- package/dist/{chunk-3AOC4XPC.js.map → chunk-ZYL6NQ75.js.map} +1 -1
- package/dist/components/cart/index.js +1 -1
- package/dist/components/common/index.js +1 -1
- package/dist/components/drawer/index.js +15 -15
- package/dist/components/home/index.js +20 -20
- package/dist/components/layout/index.js +4 -4
- package/dist/components/product/ProductDetails.d.ts +3 -0
- package/dist/components/product/ProductDetails.d.ts.map +1 -1
- package/dist/components/product/index.js +17 -17
- package/dist/components/store/index.js +16 -16
- package/dist/components/tracking/index.js +6 -6
- package/dist/{custom-urls-DTRBRO4J.js → custom-urls-SBDPEIAR.js} +7 -7
- package/dist/{custom-urls-DTRBRO4J.js.map → custom-urls-SBDPEIAR.js.map} +1 -1
- package/dist/dev/editor/index.js +1 -1
- package/dist/dev/index.js +1 -1
- package/dist/{document-class-34BKJ6VD.js → document-class-LPVE4BRZ.js} +17 -17
- package/dist/{document-class-34BKJ6VD.js.map → document-class-LPVE4BRZ.js.map} +1 -1
- package/dist/hooks/index.js +15 -15
- package/dist/hooks/useGtm.js +15 -15
- package/dist/hooks/useMoney.js +15 -15
- package/dist/hooks/useStore.js +15 -15
- package/dist/hooks/useUser.js +3 -3
- package/dist/index.js +15 -15
- package/dist/{navigation-5ACP47I3.js → navigation-43FATW7U.js} +4 -4
- package/dist/{navigation-5ACP47I3.js.map → navigation-43FATW7U.js.map} +1 -1
- package/dist/{navigation-VVCRXGCD.js → navigation-SCBNHPBD.js} +5 -5
- package/dist/{navigation-VVCRXGCD.js.map → navigation-SCBNHPBD.js.map} +1 -1
- package/dist/{not-found-ABDLLYDO.js → not-found-DW3ZCJZW.js} +18 -18
- package/dist/{not-found-ABDLLYDO.js.map → not-found-DW3ZCJZW.js.map} +1 -1
- package/dist/providers/index.js +15 -15
- package/dist/routes/account/orders.js +4 -4
- package/dist/routes/account.js +13 -13
- package/dist/routes/blog.js +8 -8
- package/dist/routes/brands/loader.d.ts.map +1 -1
- package/dist/routes/brands.js +13 -5
- package/dist/routes/brands.js.map +1 -1
- package/dist/routes/cart.js +26 -24
- package/dist/routes/cart.js.map +1 -1
- package/dist/routes/home.js +21 -21
- package/dist/routes/index.js +8 -8
- package/dist/routes/loyalty.js +5 -5
- package/dist/routes/page.js +4 -4
- package/dist/routes/product/ProductPendingPreview.d.ts +19 -0
- package/dist/routes/product/ProductPendingPreview.d.ts.map +1 -0
- package/dist/routes/product-listing.js +25 -25
- package/dist/routes/product.js +24 -24
- package/dist/routes/seo-redirects.js +8 -8
- package/dist/routes/testimonials.js +2 -2
- package/dist/routes/thank-you.js +4 -4
- package/dist/skeleton.d.ts +1 -0
- package/dist/skeleton.d.ts.map +1 -1
- package/dist/skeleton.js +24 -22
- package/dist/{store-lookup-RKU4RHPS.js → store-lookup-5BYEW5GZ.js} +8 -8
- package/dist/{store-lookup-RKU4RHPS.js.map → store-lookup-5BYEW5GZ.js.map} +1 -1
- package/dist/tanstack.js +17 -17
- package/dist/utils/index.js +3 -3
- package/dist/vite/index.js +1 -1
- package/dist/vite/index.js.map +1 -1
- package/package.json +1 -1
- package/tailwind/components/product/ProductDetails.tsx.txt +1 -1
- package/tailwind/routes/brands/loader.ts.txt +19 -1
- package/tailwind/routes/product/ProductPendingPreview.tsx.txt +85 -0
- package/dist/GoogleTag-VBFDNEU6.js +0 -15
- package/dist/ProductDetails-XLM3FGBY.js.map +0 -1
- package/dist/chunk-N7CCSGZF.js +0 -3
- package/dist/chunk-N7CCSGZF.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/routes/custom-urls.ts"],"names":[],"mappings":";;;;;;AAiCO,SAAS,aAAa,QAAA,EAA2D;AACtF,EAAA,MAAM,WAAW,QAAA,CAAS,KAAA,CAAM,GAAG,CAAA,CAAE,OAAO,OAAO,CAAA;AACnD,EAAA,MAAM,MAAA,GAAS,SAAS,QAAA,CAAS,CAAC,CAAC,CAAA,GAAI,QAAA,CAAS,OAAM,GAAI,MAAA;AAC1D,EAAA,IAAI,CAAC,QAAA,CAAS,MAAA,EAAQ,OAAO,IAAA;AAC7B,EAAA,OAAO,EAAE,GAAA,EAAK,QAAA,CAAS,IAAA,CAAK,GAAG,GAAG,MAAA,EAAO;AAC3C;AAOO,SAAS,WAAA,CAAY,KAAa,QAAA,EAA6C;AACpF,EAAA,IAAI,IAAA;AACJ,EAAA,IAAI,IAAA;AACJ,EAAA,IAAI;AACF,IAAA,IAAA,GAAO,IAAI,IAAI,GAAG,CAAA;AAClB,IAAA,IAAA,GAAO,IAAI,GAAA,CAAI,QAAA,IAAY,EAAE,CAAA;AAAA,EAC/B,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,IAAI,IAAA,CAAK,IAAA,KAAS,IAAA,CAAK,IAAA,EAAM,OAAO,IAAA;AACpC,EAAA,MAAM,QAAA,GAAW,IAAA,CAAK,QAAA,CAAS,OAAA,CAAQ,QAAQ,EAAE,CAAA;AACjD,EAAA,IAAI,QAAA,IAAY,IAAA,CAAK,QAAA,KAAa,QAAA,IAAY,CAAC,IAAA,CAAK,QAAA,CAAS,UAAA,CAAW,CAAA,EAAG,QAAQ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AAU;AACf,EAAA,MAAM,SAAS,MAAM,MAAA,CAAO,OAAA,CAAQ,GAAA,EAAK,QAAQ,WAAW,CAAA;AAC5D,EAAA,IAAI,CAAC,MAAA,EAAQ;AAEb,EAAA,MAAM,IAAA,GAAO,iBAAA,CAAkB,MAAA,EAAQ,QAAA,CAAS,OAAO,GAAG,CAAA;AAC1D,EAAA,IAAI,IAAA,EAAM;AACR,IAAA,MAAM,MAAA,GAAS,QAAQ,YAAA,GACnB,MAAM,QAAQ,YAAA,CAAa,OAAA,CAAQ,MAAM,CAAA,GACzC,OAAA,CAAQ,MAAA;AACZ,IAAA,MAAM,QAAA,CAAS,gBAAA,CAAiB,CAAA,EAAG,MAAA,GAAS,CAAA,CAAA,EAAI,MAAM,CAAA,CAAA,GAAK,EAAE,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,MAAM,CAAA,EAAG;AAAA,MAC/E,UAAA,EAAY;AAAA,KACb,CAAA;AAAA,EACH;AACA,EAAA,MAAM,IAAA,GAAO,OAAA,CAAQ,MAAA,CAAO,GAAG,CAAA;AAC/B,EAAA,IAAI,IAAA,EAAM;AACR,IAAA,MAAM,QAAA,CAAS,gBAAA,CAAiB,IAAA,EAAM,MAAM,CAAA,EAAG,EAAE,UAAA,EAAY,GAAA,EAAK,cAAA,EAAgB,IAAA,EAAM,CAAA;AAAA,EAC1F;AACF","file":"chunk-OOZ7R5J6.js","sourcesContent":["/**\n * @fileoverview A merchant's custom URLs (Dashboard → SEO → custom links) on a React storefront.\n *\n * Twig answers them in the Store's catch-all, its last fallback: after every route, and after the\n * product lookups by short code (`/{code}`) and by SKU (`/{sku}-{name}`). A React theme has no\n * catch-all, so the locale layout's `beforeLoad` asks the API (Store-Module#1798, the catch-all's\n * own lookup) at the same two points:\n * - an address no page answers (`twigUrlRedirect`, after the short code);\n * - a SKU-link address whose SKU names no product (`resolveProductKeyPage`).\n *\n * It asks only on a store that lists `custom-urls` in `store.features` (the plan has it, and the\n * store has an active one), so an address no page answers costs a store without one nothing. The answer is a 302, as Twig's, because the\n * merchant can point the URL elsewhere at any time.\n */\nimport type { QueryClient } from '@tanstack/react-query';\nimport { customUrl, type CustomUrlTarget } from '../api/custom-url';\nimport { store } from '../api/store';\nimport type { StoreContext } from '../api/store';\nimport { redirect } from '../providers/NavigationProvider';\nimport { isLocale } from '../providers/locale-constants';\n\nexport interface CustomUrlRedirectOptions {\n /** The request's query client: the settings are in it already, and a lookup is shared. */\n queryClient: QueryClient;\n /** The language segment an item's page takes, given the one the address had (the locale layout's rule). */\n targetLocale?: (addressLocale: string | undefined) => Promise<string | undefined>;\n}\n\n/**\n * The path a custom URL is saved under, for an address the router hands over (the store base\n * already off): without a language segment, which the Store strips before its catch-all, and\n * without the slashes around it. `null` for a home page.\n */\nexport function customUrlKey(pathname: string): { key: string; locale?: string } | null {\n const segments = pathname.split('/').filter(Boolean);\n const locale = isLocale(segments[0]) ? segments.shift() : undefined;\n if (!segments.length) return null;\n return { key: segments.join('/'), locale };\n}\n\n/**\n * The path an item's URL has under the store root, without its language segment:\n * `https://salla.sa/dev-x/en/shoes/p1` with store URL `https://salla.sa/dev-x/` is `/shoes/p1`.\n * `null` when the URL is not on the store (another host, or outside the store's segment).\n */\nexport function storePathOf(url: string, storeUrl: string | undefined): string | null {\n let item: URL;\n let root: URL;\n try {\n item = new URL(url);\n root = new URL(storeUrl ?? '');\n } catch {\n return null;\n }\n if (item.host !== root.host) return null;\n const rootPath = root.pathname.replace(/\\/+$/, '');\n if (rootPath && item.pathname !== rootPath && !item.pathname.startsWith(`${rootPath}/`)) {\n return null;\n }\n const segments = item.pathname.slice(rootPath.length).split('/').filter(Boolean);\n if (isLocale(segments[0])) segments.shift();\n return `/${segments.join('/')}`;\n}\n\n/** Twig's brand address, `/{slug}/brand-{id}`: the engine's brand page is `/brands/{id}`. */\nconst TWIG_BRAND_PATH = /^\\/[^/]+\\/brand-(\\d+)$/;\n\n/**\n * The engine's page for the item a custom URL names, under the store root and with no language,\n * or `null` for a `custom` row or an item URL that is not on the store. The item's own address\n * is used: the engine serves Twig's product, category, tag and page addresses (and redirects a\n * hash URL itself), and only a brand is sent straight to its page, a hop shorter.\n */\nexport function customUrlPagePath(\n target: CustomUrlTarget,\n storeUrl: string | undefined\n): string | null {\n if (target.type === 'custom') return null;\n const path = storePathOf(target.url, storeUrl);\n if (!path) return null;\n const brand = TWIG_BRAND_PATH.exec(path);\n return brand ? `/brands/${brand[1]}` : path;\n}\n\n/**\n * `target` with the address's query string on it, as the Store's catch-all keeps it (an ad's\n * `utm_*`): after the target's own query, and before its fragment.\n */\nexport function withAddressQuery(target: string, search: string): string {\n const query = search.replace(/^\\?/, '');\n if (!query) return target;\n const hashAt = target.indexOf('#');\n const [head, fragment] =\n hashAt < 0 ? [target, ''] : [target.slice(0, hashAt), target.slice(hashAt)];\n return `${head}${head.includes('?') ? '&' : '?'}${query}${fragment}`;\n}\n\n/** A URL when it is http(s): the Dashboard asks for a URL, and the router refuses any other scheme. */\nfunction httpUrl(url: string): string | null {\n try {\n const { protocol } = new URL(url);\n return protocol === 'http:' || protocol === 'https:' ? url : null;\n } catch {\n return null;\n }\n}\n\n/** The settings, when they list `custom-urls` in the store's features; else `null`. */\nasync function settingsWithCustomUrls(queryClient: QueryClient): Promise<StoreContext | null> {\n try {\n const settings = await queryClient.ensureQueryData(store.queries.settings());\n return settings?.store?.features?.includes('custom-urls') ? settings : null;\n } catch {\n return null;\n }\n}\n\n/**\n * The custom URL saved for `key`, or `undefined`. Any failure counts as none: an address no page\n * answers is also every scanner's, and an API error must leave it the 404 it was, not a 500.\n */\nasync function lookup(key: string, queryClient: QueryClient): Promise<CustomUrlTarget | undefined> {\n try {\n return await queryClient.ensureQueryData(customUrl.queries.resolve(key));\n } catch {\n return undefined;\n }\n}\n\n/**\n * Sends the visitor where the custom URL saved for `pathname` leads, with the address's query, by\n * a 302; returns when there is none, and the caller answers as it would have. An item on the store\n * is reached in one hop, in the language the locale layout would give it. A `custom` row's URL,\n * or an item URL on another site, is a full page load.\n */\nexport async function customUrlRedirect(\n pathname: string,\n search: string,\n options: CustomUrlRedirectOptions\n): Promise<void> {\n const address = customUrlKey(pathname);\n if (!address) return;\n const settings = await settingsWithCustomUrls(options.queryClient);\n if (!settings) return;\n const target = await lookup(address.key, options.queryClient);\n if (!target) return;\n\n const path = customUrlPagePath(target, settings.store?.url);\n if (path) {\n const locale = options.targetLocale\n ? await options.targetLocale(address.locale)\n : address.locale;\n throw redirect(withAddressQuery(`${locale ? `/${locale}` : ''}${path}`, search), {\n statusCode: 302,\n });\n }\n const href = httpUrl(target.url);\n if (href) {\n throw redirect(withAddressQuery(href, search), { statusCode: 302, reloadDocument: true });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/routes/custom-urls.ts"],"names":[],"mappings":";;;;;;AAiCO,SAAS,aAAa,QAAA,EAA2D;AACtF,EAAA,MAAM,WAAW,QAAA,CAAS,KAAA,CAAM,GAAG,CAAA,CAAE,OAAO,OAAO,CAAA;AACnD,EAAA,MAAM,MAAA,GAAS,SAAS,QAAA,CAAS,CAAC,CAAC,CAAA,GAAI,QAAA,CAAS,OAAM,GAAI,MAAA;AAC1D,EAAA,IAAI,CAAC,QAAA,CAAS,MAAA,EAAQ,OAAO,IAAA;AAC7B,EAAA,OAAO,EAAE,GAAA,EAAK,QAAA,CAAS,IAAA,CAAK,GAAG,GAAG,MAAA,EAAO;AAC3C;AAOO,SAAS,WAAA,CAAY,KAAa,QAAA,EAA6C;AACpF,EAAA,IAAI,IAAA;AACJ,EAAA,IAAI,IAAA;AACJ,EAAA,IAAI;AACF,IAAA,IAAA,GAAO,IAAI,IAAI,GAAG,CAAA;AAClB,IAAA,IAAA,GAAO,IAAI,GAAA,CAAI,QAAA,IAAY,EAAE,CAAA;AAAA,EAC/B,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,IAAI,IAAA,CAAK,IAAA,KAAS,IAAA,CAAK,IAAA,EAAM,OAAO,IAAA;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MAAA,EACA,OAAA,EACe;AACf,EAAA,MAAM,OAAA,GAAU,aAAa,QAAQ,CAAA;AACrC,EAAA,IAAI,CAAC,OAAA,EAAS;AACd,EAAA,MAAM,QAAA,GAAW,MAAM,sBAAA,CAAuB,OAAA,CAAQ,WAAW,CAAA;AACjE,EAAA,IAAI,CAAC,QAAA,EAAU;AACf,EAAA,MAAM,SAAS,MAAM,MAAA,CAAO,OAAA,CAAQ,GAAA,EAAK,QAAQ,WAAW,CAAA;AAC5D,EAAA,IAAI,CAAC,MAAA,EAAQ;AAEb,EAAA,MAAM,IAAA,GAAO,iBAAA,CAAkB,MAAA,EAAQ,QAAA,CAAS,OAAO,GAAG,CAAA;AAC1D,EAAA,IAAI,IAAA,EAAM;AACR,IAAA,MAAM,MAAA,GAAS,QAAQ,YAAA,GACnB,MAAM,QAAQ,YAAA,CAAa,OAAA,CAAQ,MAAM,CAAA,GACzC,OAAA,CAAQ,MAAA;AACZ,IAAA,MAAM,QAAA,CAAS,gBAAA,CAAiB,CAAA,EAAG,MAAA,GAAS,CAAA,CAAA,EAAI,MAAM,CAAA,CAAA,GAAK,EAAE,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,MAAM,CAAA,EAAG;AAAA,MAC/E,UAAA,EAAY;AAAA,KACb,CAAA;AAAA,EACH;AACA,EAAA,MAAM,IAAA,GAAO,OAAA,CAAQ,MAAA,CAAO,GAAG,CAAA;AAC/B,EAAA,IAAI,IAAA,EAAM;AACR,IAAA,MAAM,QAAA,CAAS,gBAAA,CAAiB,IAAA,EAAM,MAAM,CAAA,EAAG,EAAE,UAAA,EAAY,GAAA,EAAK,cAAA,EAAgB,IAAA,EAAM,CAAA;AAAA,EAC1F;AACF","file":"chunk-NB5A65PP.js","sourcesContent":["/**\n * @fileoverview A merchant's custom URLs (Dashboard → SEO → custom links) on a React storefront.\n *\n * Twig answers them in the Store's catch-all, its last fallback: after every route, and after the\n * product lookups by short code (`/{code}`) and by SKU (`/{sku}-{name}`). A React theme has no\n * catch-all, so the locale layout's `beforeLoad` asks the API (Store-Module#1798, the catch-all's\n * own lookup) at the same two points:\n * - an address no page answers (`twigUrlRedirect`, after the short code);\n * - a SKU-link address whose SKU names no product (`resolveProductKeyPage`).\n *\n * It asks only on a store that lists `custom-urls` in `store.features` (the plan has it, and the\n * store has an active one), so an address no page answers costs a store without one nothing. The answer is a 302, as Twig's, because the\n * merchant can point the URL elsewhere at any time.\n */\nimport type { QueryClient } from '@tanstack/react-query';\nimport { customUrl, type CustomUrlTarget } from '../api/custom-url';\nimport { store } from '../api/store';\nimport type { StoreContext } from '../api/store';\nimport { redirect } from '../providers/NavigationProvider';\nimport { isLocale } from '../providers/locale-constants';\n\nexport interface CustomUrlRedirectOptions {\n /** The request's query client: the settings are in it already, and a lookup is shared. */\n queryClient: QueryClient;\n /** The language segment an item's page takes, given the one the address had (the locale layout's rule). */\n targetLocale?: (addressLocale: string | undefined) => Promise<string | undefined>;\n}\n\n/**\n * The path a custom URL is saved under, for an address the router hands over (the store base\n * already off): without a language segment, which the Store strips before its catch-all, and\n * without the slashes around it. `null` for a home page.\n */\nexport function customUrlKey(pathname: string): { key: string; locale?: string } | null {\n const segments = pathname.split('/').filter(Boolean);\n const locale = isLocale(segments[0]) ? segments.shift() : undefined;\n if (!segments.length) return null;\n return { key: segments.join('/'), locale };\n}\n\n/**\n * The path an item's URL has under the store root, without its language segment:\n * `https://salla.sa/dev-x/en/shoes/p1` with store URL `https://salla.sa/dev-x/` is `/shoes/p1`.\n * `null` when the URL is not on the store (another host, or outside the store's segment).\n */\nexport function storePathOf(url: string, storeUrl: string | undefined): string | null {\n let item: URL;\n let root: URL;\n try {\n item = new URL(url);\n root = new URL(storeUrl ?? '');\n } catch {\n return null;\n }\n if (item.host !== root.host) return null;\n const rootPath = root.pathname.replace(/\\/+$/, '');\n if (rootPath && item.pathname !== rootPath && !item.pathname.startsWith(`${rootPath}/`)) {\n return null;\n }\n const segments = item.pathname.slice(rootPath.length).split('/').filter(Boolean);\n if (isLocale(segments[0])) segments.shift();\n return `/${segments.join('/')}`;\n}\n\n/** Twig's brand address, `/{slug}/brand-{id}`: the engine's brand page is `/brands/{id}`. */\nconst TWIG_BRAND_PATH = /^\\/[^/]+\\/brand-(\\d+)$/;\n\n/**\n * The engine's page for the item a custom URL names, under the store root and with no language,\n * or `null` for a `custom` row or an item URL that is not on the store. The item's own address\n * is used: the engine serves Twig's product, category, tag and page addresses (and redirects a\n * hash URL itself), and only a brand is sent straight to its page, a hop shorter.\n */\nexport function customUrlPagePath(\n target: CustomUrlTarget,\n storeUrl: string | undefined\n): string | null {\n if (target.type === 'custom') return null;\n const path = storePathOf(target.url, storeUrl);\n if (!path) return null;\n const brand = TWIG_BRAND_PATH.exec(path);\n return brand ? `/brands/${brand[1]}` : path;\n}\n\n/**\n * `target` with the address's query string on it, as the Store's catch-all keeps it (an ad's\n * `utm_*`): after the target's own query, and before its fragment.\n */\nexport function withAddressQuery(target: string, search: string): string {\n const query = search.replace(/^\\?/, '');\n if (!query) return target;\n const hashAt = target.indexOf('#');\n const [head, fragment] =\n hashAt < 0 ? [target, ''] : [target.slice(0, hashAt), target.slice(hashAt)];\n return `${head}${head.includes('?') ? '&' : '?'}${query}${fragment}`;\n}\n\n/** A URL when it is http(s): the Dashboard asks for a URL, and the router refuses any other scheme. */\nfunction httpUrl(url: string): string | null {\n try {\n const { protocol } = new URL(url);\n return protocol === 'http:' || protocol === 'https:' ? url : null;\n } catch {\n return null;\n }\n}\n\n/** The settings, when they list `custom-urls` in the store's features; else `null`. */\nasync function settingsWithCustomUrls(queryClient: QueryClient): Promise<StoreContext | null> {\n try {\n const settings = await queryClient.ensureQueryData(store.queries.settings());\n return settings?.store?.features?.includes('custom-urls') ? settings : null;\n } catch {\n return null;\n }\n}\n\n/**\n * The custom URL saved for `key`, or `undefined`. Any failure counts as none: an address no page\n * answers is also every scanner's, and an API error must leave it the 404 it was, not a 500.\n */\nasync function lookup(key: string, queryClient: QueryClient): Promise<CustomUrlTarget | undefined> {\n try {\n return await queryClient.ensureQueryData(customUrl.queries.resolve(key));\n } catch {\n return undefined;\n }\n}\n\n/**\n * Sends the visitor where the custom URL saved for `pathname` leads, with the address's query, by\n * a 302; returns when there is none, and the caller answers as it would have. An item on the store\n * is reached in one hop, in the language the locale layout would give it. A `custom` row's URL,\n * or an item URL on another site, is a full page load.\n */\nexport async function customUrlRedirect(\n pathname: string,\n search: string,\n options: CustomUrlRedirectOptions\n): Promise<void> {\n const address = customUrlKey(pathname);\n if (!address) return;\n const settings = await settingsWithCustomUrls(options.queryClient);\n if (!settings) return;\n const target = await lookup(address.key, options.queryClient);\n if (!target) return;\n\n const path = customUrlPagePath(target, settings.store?.url);\n if (path) {\n const locale = options.targetLocale\n ? await options.targetLocale(address.locale)\n : address.locale;\n throw redirect(withAddressQuery(`${locale ? `/${locale}` : ''}${path}`, search), {\n statusCode: 302,\n });\n }\n const href = httpUrl(target.url);\n if (href) {\n throw redirect(withAddressQuery(href, search), { statusCode: 302, reloadDocument: true });\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { filesCdn, cdn } from './chunk-
|
|
1
|
+
import { filesCdn, cdn } from './chunk-SGEJUTTK.js';
|
|
2
2
|
import { storeTranslationsQueryKey, translationsQueryKey, composeMessages, isPlainObject } from './chunk-MWUAHDQL.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
|
+
//# sourceMappingURL=chunk-NE5XQJLZ.js.map
|
|
130
|
+
//# sourceMappingURL=chunk-NE5XQJLZ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/translations.ts"],"names":[],"mappings":";;;;AAiEA,IAAM,kBAAA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B,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-SD4TYJN3.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,aAAA,EAAgB,OAAO,CAAA,CAAA,EAAI,MAAM,CAAA,KAAA,CAAA;AAC1C;AAUA,eAAe,eACb,IAAA,EACA,EAAE,aAAa,KAAA,EAAM,GAA8B,EAAC,EAC1B;AAE1B,EAAA,MAAM,UAAA,GAAa,CA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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-NE5XQJLZ.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 { orThrow } from './chunk-
|
|
2
|
-
import { api } from './chunk-
|
|
1
|
+
import { orThrow } from './chunk-25NSKD6D.js';
|
|
2
|
+
import { api } from './chunk-SGEJUTTK.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-NEPSTGF6.js.map
|
|
67
|
+
//# sourceMappingURL=chunk-NEPSTGF6.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/blog.ts"],"names":[],"mappings":";;;;AAyCO,IAAM,IAAA,GAAO;AAAA,EAClB,GAAA,EAAK,OAAO,MAAA,KAAgD;AAC1D,IAAA,MAAM,UAAmC,EAAC;AAC1C,IAAA,IAAI,MAAA,UAAgB,MAAA,GAAS,MAAA;AAE7B,IAAA,MAAM,WAAW,MAAM,GAAA,CAAI,IAAI,MAAA,EAAQ,OAAoB,EAAE,IAAA,EAAsB;A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AAE,CAAA,UAAA,CAAY,CAAA;AAAA,MAC3C;AAEA,MAAA,OAAO,QAAA,CAAS,IAAA;AAAA,IAClB,CAAA;AAAA,IAEA,WAAA,EAAa,CAAC,EAAA,EAAY,MAAA,KACxB,OAAA,CAAQ,KAAK,QAAA,CAAS,IAAA,CAAK,EAAA,EAAI,MAAM,CAAC;AAAA,GAC1C;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,QAAA,EAAU,MACR,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,MAAA,EAAQ,UAAU,CAAA;AAAA,MAC7B,SAAS,CAAC,EAAE,QAAO,KAAM,IAAA,CAAK,IAAI,MAAM;AAAA,KACzC,CAAA;AAAA,IACH,QAAA,EAAU,CAAC,MAAA,KACT,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,MAAA,EAAQ,UAAA,EAAY,MAAM,CAAA;AAAA,MACrC,OAAA,EAAS,CAAC,EAAE,MAAA,EAAO,KAAM,IAAA,CAAK,QAAA,CAAS,IAAA,CAAK,EAAE,GAAG,MAAA,EAAQ,MAAA,EAAQ;AAAA,KAClE,CAAA;AAAA,IACH,OAAA,EAAS,CAAC,EAAA,KACR,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,MAAA,EAAQ,SAAA,EAAW,EAAE,CAAA;AAAA,MAChC,OAAA,EAAS,CAAC,EAAE,MAAA,OAAa,IAAA,CAAK,QAAA,CAAS,IAAA,CAAK,EAAA,EAAI,MAAM;AAAA,KACvD;AAAA;AAEP","file":"chunk-NEPSTGF6.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,4 +1,4 @@
|
|
|
1
|
-
import { advertisement, advertisementsFor } from './chunk-
|
|
1
|
+
import { advertisement, advertisementsFor } from './chunk-KHIEGO2C.js';
|
|
2
2
|
import { useTranslation } from './chunk-TYNZ5B2B.js';
|
|
3
3
|
import { whenSallaReady } from './chunk-MZPX4EPS.js';
|
|
4
4
|
import { subscribeTwilight, getTwilightContext } from './chunk-MWUAHDQL.js';
|
|
@@ -99,5 +99,5 @@ function PageAdvertisements() {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
export { PageAdvertisements };
|
|
102
|
-
//# sourceMappingURL=chunk-
|
|
103
|
-
//# sourceMappingURL=chunk-
|
|
102
|
+
//# sourceMappingURL=chunk-NMVC5IGS.js.map
|
|
103
|
+
//# sourceMappingURL=chunk-NMVC5IGS.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/layout/PageAdvertisements.tsx"],"names":[],"mappings":";;;;;;;;AAOA,IAAM,eAAA,GAAkB,MAAM,kBAAA,EAAmB,CAAE,IAAA,EAAM,IAAA;AAGzD,IAAM,YAAA,GAAe,CAAC,EAAA,KAAe,CAAA,SAAA,EAAY,EAAE,CAAA,CAAA;AAGnD,IAAM,SAA0B,EAAC;AAGjC,IAAM,qBAAA,GACJ,uPAAA;AAEF,SAAS,YAAY,EAAA,EAAqB;AACxC,EAAA,IAAI;AACF,IAAA,OA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EAAA,CAAG,GAAA;AAAA,gBACT,MAAA,EAAQ,GAAG,MAAA,IAAU,MAAA;AAAA,gBACrB,GAAA,EAAK,EAAA,CAAG,MAAA,KAAW,QAAA,GAAW,UAAA,GAAa,MAAA;AAAA,gBAE1C,QAAA,EAAA,EAAA,CAAG;AAAA;AAAA,gBAGN,EAAA,CAAG;AAAA,WAAA,EAEP,CAAA;AAAA,0BACA,GAAA;AAAA,YAAC,QAAA;AAAA,YAAA;AAAA,cACC,IAAA,EAAK,QAAA;AAAA,cACL,SAAA,EAAU,6BAAA;AAAA,cACV,YAAA,EAAY,CAAA,CAAE,sBAAA,EAAwB,OAAO,CAAA;AAAA,cAC7C,OAAA,EAAS,MAAM,KAAA,CAAM,EAAA,CAAG,EAAE,CAAA;AAAA,cAG1B,QAAA,kBAAA,GAAA,CAAC,GAAA,EAAA,EAAE,SAAA,EAAU,2BAAA,EAA4B;AAAA;AAAA;AAC3C,SAAA,EACF;AAAA,OAAA;AAAA,MAhCK,EAAA,CAAG;AAAA,KAkCX,CAAA;AAAA,oBACD,GAAA,CAAC,QAAA,EAAA,EAAO,wBAAA,EAAwB,IAAA,EAAE,QAAA,EAAA,qBAAA,EAAsB;AAAA,GAAA,EAC1D,CAAA;AAEJ","file":"chunk-NMVC5IGS.js","sourcesContent":["import { useEffect, useState, useSyncExternalStore } from 'react';\nimport { useQuery } from '@tanstack/react-query';\nimport { advertisement, advertisementsFor, type Advertisement } from '../../api/advertisement';\nimport { whenSallaReady } from '../../utils/sdk-helpers';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport { getTwilightContext, subscribeTwilight } from '../../twilight/context';\n\nconst currentPageSlug = () => getTwilightContext().page?.slug;\n\n/** The key `<salla-advertisement>` marks a closed ad with, through `salla.storage` (store.js, JSON). */\nconst dismissedKey = (id: number) => `statusAd-${id}`;\n\n/** Stable while the query has no data, so the effect below doesn't rerun on every render. */\nconst NO_ADS: Advertisement[] = [];\n\n/** Hides the ads this visitor closed before the first paint; the effect then drops them. */\nconst HIDE_DISMISSED_SCRIPT =\n \"(function(){try{if(window.self!==window.top)return;document.currentScript.parentNode.querySelectorAll('.s-advertisement[data-id]').forEach(function(e){if(localStorage.getItem('statusAd-'+e.getAttribute('data-id')))e.hidden=true})}catch(e){}})();\";\n\nfunction isDismissed(id: number): boolean {\n try {\n return Boolean(window.localStorage.getItem(dismissedKey(id)));\n } catch {\n return false;\n }\n}\n\nfunction dismiss(id: number): void {\n const storage = window.salla?.storage;\n if (typeof storage?.set === 'function') storage.set(dismissedKey(id), 'dismissed');\n else {\n try {\n window.localStorage.setItem(dismissedKey(id), JSON.stringify('dismissed'));\n } catch {\n // Storage disabled: the ad hides for this page view only.\n }\n }\n}\n\ninterface ClientView {\n /** The theme editor's iframe, or the SDK's debug flag: every ad shows, closed or not. */\n preview: boolean;\n /** Inside the Salla mobile app, which shows no ads. */\n inApp: boolean;\n dismissed: Set<number>;\n}\n\n/**\n * The merchant's announcement bars, in place of `<salla-advertisement>`. Same data, rules and\n * markup, but rendered on the server (the ads are prefetched in the root `beforeLoad`), so the\n * bar is in the first paint instead of pushing the page down when the web component fetches it.\n */\nexport function PageAdvertisements() {\n const { t } = useTranslation();\n // The deepest route loader's `page`, the page `salla.config` reports.\n const pageSlug = useSyncExternalStore(subscribeTwilight, currentPageSlug, currentPageSlug);\n // The query's `retry: 0` only bounds the server wait; the browser may retry.\n const { data: ads = NO_ADS } = useQuery({ ...advertisement.queries.list(), retry: 2 });\n const [view, setView] = useState<ClientView | null>(null);\n\n useEffect(() => {\n const dismissed = new Set(ads.filter((ad) => isDismissed(ad.id)).map((ad) => ad.id));\n setView({ preview: window.self !== window.top, inApp: false, dismissed });\n return whenSallaReady((sdk) => {\n const config = sdk.config as { isMobileApp?: () => boolean; isDebug?: () => boolean };\n const inApp = Boolean(config?.isMobileApp?.());\n const debug = Boolean(config?.isDebug?.());\n if (inApp || debug) {\n setView((current) =>\n current ? { ...current, inApp, preview: current.preview || debug } : current\n );\n }\n });\n }, [ads]);\n\n if (view?.inApp) return null;\n const shown = view?.preview\n ? ads\n : advertisementsFor(ads, pageSlug).filter((ad) => !view?.dismissed.has(ad.id));\n if (!shown.length) return null;\n\n const close = (id: number) => {\n dismiss(id);\n setView((current) =>\n current ? { ...current, dismissed: new Set(current.dismissed).add(id) } : current\n );\n };\n\n return (\n <>\n {shown.map((ad) => (\n <div\n key={ad.id}\n className=\"s-advertisement\"\n data-id={ad.id}\n style={{ backgroundColor: ad.colors?.bg, color: ad.colors?.text }}\n >\n <div className=\"s-advertisement-content container flex justify-between items-center py-2.5\">\n <span className=\"s-advertisement-content-main flex-1 font-bold text-center text-sm\">\n {/* Rendered without an icon too, as the SDK does: its margin is part of the layout. */}\n <i\n className={`s-advertisement-content-icon inline-block align-middle me-2 text-base ${ad.icon ?? ''}`}\n />\n {ad.url ? (\n <a\n href={ad.url}\n target={ad.target ?? undefined}\n rel={ad.target === '_blank' ? 'noopener' : undefined}\n >\n {ad.description}\n </a>\n ) : (\n ad.description\n )}\n </span>\n <button\n type=\"button\"\n className=\"s-advertisement-action px-1\"\n aria-label={t('common.buttons.close', 'Close')}\n onClick={() => close(ad.id)}\n >\n {/* `inline-block`: before the icon CSS loads, an empty inline `<i>` leaves the button 0px tall. */}\n <i className=\"sicon-cancel inline-block\" />\n </button>\n </div>\n </div>\n ))}\n <script suppressHydrationWarning>{HIDE_DISMISSED_SCRIPT}</script>\n </>\n );\n}\n"]}
|
|
@@ -184,5 +184,5 @@ function useCanvasHost() {
|
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
export { matchBlocks, postToCanvas, takeCanvasCommands, useCanvasHost };
|
|
187
|
-
//# sourceMappingURL=chunk-
|
|
188
|
-
//# sourceMappingURL=chunk-
|
|
187
|
+
//# sourceMappingURL=chunk-NUURM3QI.js.map
|
|
188
|
+
//# sourceMappingURL=chunk-NUURM3QI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/live-editor/canvas.ts"],"names":[],"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AA,CAAO,mBAAA,CAAoB,QAAQ,KAAK,CAAA;AAAA,IAC1C,CAAA;AAAA,EACF,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO,IAAA;AACT","file":"chunk-QXAUEOHK.js","sourcesContent":["/**\n * The storefront's side of the design studio's canvas mode: the studio frames\n * the store and draws its own cards and panels, and the store outlines what the\n * merchant points at and reports what is picked. The same `postMessage`\n * protocol the twig themes' `live-themes-editor.js` speaks in canvas mode.\n */\n\nimport { useEffect, useState } from 'react';\nimport { isEditorFrame } from '../../dev/schema-types';\nimport { getTwilightContext } from '../../twilight/context';\nimport { parentOrigin } from './frame';\nimport { drawLiveBlocks } from './moves';\n\nconst CHILD = 'salla-canvas';\nconst HOST = 'salla-canvas-host';\n\n/** Where the studio runs; it alone turns canvas mode on. */\nexport const CANVAS_ORIGINS = [\n 'https://s.salla.sa',\n 'https://s.salla.dev',\n 'https://s.beta.salla.group',\n 'http://localhost:9000',\n] as const;\n\nexport type CanvasRole = 'component' | 'header' | 'footer';\n\n/** The header's or footer's own logo or menu, picked on its own. */\nexport type CanvasPart = 'logo' | 'menu';\n\n/**\n * A home block as the studio lists it, in page order. The storefront's blocks\n * carry no row id, so the studio's list names them: `eid` is what the studio\n * calls the block, matched to the page by its uuid (`key`) or its `slug`.\n */\nexport interface CanvasBlock {\n eid: string;\n key?: string | null;\n slug?: string | null;\n title?: string | null;\n}\n\nexport type CanvasCommand =\n | { type: 'select'; eid: string; part?: CanvasPart }\n | { type: 'deselect' }\n | { type: 'move'; eid: string; direction: 'up' | 'down' }\n /** Lays the blocks out in this order without saving it. */\n | { type: 'order'; eids: string[] };\n\nexport interface CanvasHost {\n /** The studio's origin once it has spoken, else `null`: the page is not in canvas mode. */\n origin: string | null;\n enabled: boolean;\n blocks: CanvasBlock[] | null;\n}\n\nconst asEid = (value: unknown): string | null =>\n typeof value === 'string' && value ? value : null;\n\nconst asPart = (value: unknown): CanvasPart | undefined =>\n value === 'logo' || value === 'menu' ? value : undefined;\n\nfunction asBlocks(value: unknown): CanvasBlock[] | null {\n if (!Array.isArray(value)) return null;\n return value.flatMap((item) => {\n const block = item as Partial<CanvasBlock> | null;\n const eid = asEid(block?.eid);\n if (!eid) return [];\n return [\n {\n eid,\n key: typeof block?.key === 'string' ? block.key : null,\n slug: typeof block?.slug === 'string' ? block.slug : null,\n title: typeof block?.title === 'string' ? block.title : null,\n },\n ];\n });\n}\n\n/** The command a studio message carries, if it is a well-formed one. */\nexport function readCommand(data: Record<string, unknown>): CanvasCommand | null {\n switch (data.type) {\n case 'select': {\n const eid = asEid(data.eid);\n return eid ? { type: 'select', eid, part: asPart(data.part) } : null;\n }\n case 'deselect':\n return { type: 'deselect' };\n case 'move': {\n const eid = asEid(data.eid);\n const direction =\n data.direction === 'up' || data.direction === 'down' ? data.direction : null;\n return eid && direction ? { type: 'move', eid, direction } : null;\n }\n case 'order':\n return Array.isArray(data.eids)\n ? { type: 'order', eids: data.eids.flatMap((eid) => asEid(eid) ?? []) }\n : null;\n default:\n return null;\n }\n}\n\n/** The engine's name for a studio block: its uuid, or its slug spelled as the storefront's path. */\nconst refOf = (block: CanvasBlock): string => block.key || block.slug?.replace(/_/g, '-') || '';\n\n/**\n * The studio block each page block is, by page order: copies of one component\n * share a uuid, so the n-th on the page is the n-th in the list. `refs` are\n * the page blocks' `data-live-block` values; `null` where none matches, and\n * for every copy of a ref the page and the list count differently, where the\n * n-th could be another row.\n */\nexport function matchBlocks(\n refs: readonly string[],\n blocks: readonly CanvasBlock[]\n): (CanvasBlock | null)[] {\n const names = (block: CanvasBlock, ref: string) => block.eid === ref || refOf(block) === ref;\n const used = new Set<number>();\n return refs.map((ref) => {\n const onPage = refs.filter((each) => each === ref).length;\n if (blocks.filter((block) => names(block, ref)).length !== onPage) return null;\n const at = blocks.findIndex((block, index) => !used.has(index) && names(block, ref));\n if (at === -1) return null;\n used.add(at);\n return blocks[at];\n });\n}\n\n/** Sends `message` to the studio, or, before it has spoken, to whichever allowed origin frames the page. */\nexport function postToCanvas(origin: string | null, message: Record<string, unknown>): void {\n const data = { source: CHILD, v: 1, ...message };\n if (origin) {\n window.parent.postMessage(data, origin);\n return;\n }\n let parent: string | null = null;\n try {\n parent = parentOrigin();\n } catch {\n parent = null;\n }\n const targets: readonly string[] = parent ? [parent] : CANVAS_ORIGINS;\n for (const target of targets) {\n if ((CANVAS_ORIGINS as readonly string[]).includes(target))\n window.parent.postMessage(data, target);\n }\n}\n\n/** What the page redraws in place when the studio saves, as `hello` tells it. */\nexport const CANVAS_CAN = ['refresh'] as const;\n\nlet lastDraw: Promise<unknown> = Promise.resolve();\n\n// Under the studio's own wait, so the page answers before the studio gives up on it.\nconst DRAW_LIMIT = 15_000;\n\n/**\n * Draws the home page again from what the studio just saved, without reloading it: its\n * blocks fetched afresh, spelled as the home loader spells them. Fails off the home page.\n */\nexport function redrawPage(): Promise<void> {\n // One at a time: the query cache would hand this save a fetch started before it.\n const draw = lastDraw.then(drawAfresh);\n lastDraw = draw.catch(() => undefined);\n return draw;\n}\n\nasync function drawAfresh(): Promise<void> {\n const { home } = await import('../../api/home');\n const { queryClient } = getTwilightContext();\n const components = home.queries.components();\n let timer: ReturnType<typeof setTimeout> | undefined;\n const tooLong = new Promise<never>((_, reject) => {\n timer = setTimeout(() => {\n // Its fetch is called off too, or the next redraw would be handed it.\n void queryClient.cancelQueries({ queryKey: components.queryKey });\n reject(new Error('redraw took too long'));\n }, DRAW_LIMIT);\n });\n const blocks = await Promise.race([\n queryClient.fetchQuery({ ...components, staleTime: 0 }),\n tooLong,\n ]).finally(() => clearTimeout(timer));\n const drawn = drawLiveBlocks(\n blocks.map((block) => ({ ...block, path: block.path?.replace('home.', '') || block.path }))\n );\n if (!drawn) throw new Error('no home page');\n}\n\n// Draws the page again for the section the studio saved; false for a refresh that names none.\nfunction refreshFor(studio: string, data: Record<string, unknown>): boolean {\n const eid = asEid(data.eid);\n if (!eid) {\n postToCanvas(studio, { type: 'refresh-failed', eid: String(data.eid ?? '') });\n return false;\n }\n redrawPage().then(\n () => {\n if (data.select === true) deliver({ type: 'select', eid });\n postToCanvas(studio, { type: 'refreshed', eid });\n },\n () => postToCanvas(studio, { type: 'refresh-failed', eid })\n );\n return true;\n}\n\n/** The overlay on screen takes the studio's commands; ones sent before it mounted wait for it. */\nlet handler: ((command: CanvasCommand) => void) | null = null;\nlet queued: CanvasCommand[] = [];\n\nfunction deliver(command: CanvasCommand): void {\n if (handler) handler(command);\n else queued.push(command);\n}\n\n/** Hands the studio's commands to `fn` while it is set, the waiting ones first. */\nexport function takeCanvasCommands(fn: (command: CanvasCommand) => void): () => void {\n handler = fn;\n const waiting = queued;\n queued = [];\n waiting.forEach(fn);\n return () => {\n if (handler === fn) handler = null;\n };\n}\n\n/**\n * Says hello to the studio once the page has loaded, and follows what it asks\n * for. Off for shoppers, for the theme editor (which never answers) and for the\n * engine's own dev editor, which keep the live editor bar.\n */\nexport function useCanvasHost(): CanvasHost {\n const [host, setHost] = useState<CanvasHost>({ origin: null, enabled: false, blocks: null });\n\n useEffect(() => {\n if (window.self === window.top || (import.meta.env.DEV && isEditorFrame())) return;\n let origin: string | null = null;\n\n const onMessage = (event: MessageEvent) => {\n if (event.source !== window.parent) return;\n const data = (event.data ?? {}) as Record<string, unknown>;\n // The studio saved on the server and wants the page drawn again, as the twig preview does.\n if (data.action === 'preview::reload') {\n if (origin && event.origin === origin) window.location.reload();\n return;\n }\n if (data.source !== HOST) return;\n if (!origin) {\n if (!(CANVAS_ORIGINS as readonly string[]).includes(event.origin)) return;\n origin = event.origin;\n } else if (event.origin !== origin) return;\n const studio = origin;\n\n // A section saved: the page is drawn again in place, and the section picked once the studio names it.\n if (data.type === 'refresh') {\n if (refreshFor(studio, data))\n setHost((prev) => (prev.origin ? prev : { ...prev, origin: studio }));\n } else if (data.type === 'enable') {\n const blocks = asBlocks(data.blocks);\n setHost((prev) => ({ origin: studio, enabled: true, blocks: blocks ?? prev.blocks }));\n } else if (data.type === 'disable') {\n queued = [];\n setHost((prev) => ({ ...prev, origin: studio, enabled: false }));\n } else {\n setHost((prev) => (prev.origin ? prev : { ...prev, origin: studio }));\n const command = readCommand(data);\n if (command) deliver(command);\n }\n };\n\n const hello = () => postToCanvas(origin, { type: 'hello', can: [...CANVAS_CAN] });\n window.addEventListener('message', onMessage);\n if (document.readyState === 'complete') hello();\n else window.addEventListener('load', hello, { once: true });\n return () => {\n window.removeEventListener('message', onMessage);\n window.removeEventListener('load', hello);\n };\n }, []);\n\n return host;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/live-editor/canvas.ts"],"names":[],"mappings":";;;;;;AAaA,IAAM,KAAA,GAAQ,cAAA;AACd,IAAM,IAAA,GAAO,mBAAA;AAGN,IAAM,cAAA,GAAiB;AAAA,EAC5B,oBAAA;AAAA,EACA,qBAAA;AAAA,EACA,4BAAA;AAAA,EACA;AACF,CAAA;AAiCA,IAAM,QAAQ,CAAC,KAAA,KACb,OAAO,KAAA,KAAU,QAAA,IAAY,QAAQ,KAAA,GAAQ,IAAA;AAE/C,IAAM,SAAS,CAAC,KAAA,KACd,UAAU,MAAA,IAAU,KAAA,KAAU,SAAS,KAAA,GAAQ,MAAA;AAEjD,SAAS,SAAS,KAAA,EAAsC;AACtD,EAAA,IAAI,CAAC,KAAA,CAAM,OAAA,CAAQ,KAAK,GAAG,OAAO,IAAA;AAClC,EAAA,OAAO,KAAA,CAAM,OAAA,CAAQ,CAAC,IAAA,KAAS;AAC7B,IAAA,MAAM,KAAA,GAAQ,IAAA;AACd,IAAA,MAAM,GAAA,GAAM,KAAA,CAAM,KAAA,EAAO,GAAG,CAAA;AAC5B,IAAA,IAAI,CAAC,GAAA,EAAK,OAAO,EAAC;AAClB,IAAA,OAAO;AAAA,MACL;AAAA,QACE,GAAA;AAAA,QACA,KAAK,OAAO,KAAA,EAAO,GAAA,KAAQ,QAAA,GAAW,MAAM,GAAA,GAAM,IAAA;AAAA,QAClD,MAAM,OAAO,KAAA,EAAO,IAAA,KAAS,QAAA,GAAW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AM,OAAA,EAAS,GAAA,EAAK,CAAC,GAAG,UAAU,CAAA,EAAG,CAAA;AAChF,IAAA,MAAA,CAAO,gBAAA,CAAiB,WAAW,SAAS,CAAA;AAC5C,IAAA,IAAI,QAAA,CAAS,UAAA,KAAe,UAAA,EAAY,KAAA,EAAM;AAAA,gBAClC,gBAAA,CAAiB,MAAA,EAAQ,OAAO,EAAE,IAAA,EAAM,MAAM,CAAA;AAC1D,IAAA,OAAO,MAAM;AACX,MAAA,MAAA,CAAO,mBAAA,CAAoB,WAAW,SAAS,CAAA;AAC/C,MAAA,MAAA,CAAO,mBAAA,CAAoB,QAAQ,KAAK,CAAA;AAAA,IAC1C,CAAA;AAAA,EACF,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO,IAAA;AACT","file":"chunk-NUURM3QI.js","sourcesContent":["/**\n * The storefront's side of the design studio's canvas mode: the studio frames\n * the store and draws its own cards and panels, and the store outlines what the\n * merchant points at and reports what is picked. The same `postMessage`\n * protocol the twig themes' `live-themes-editor.js` speaks in canvas mode.\n */\n\nimport { useEffect, useState } from 'react';\nimport { isEditorFrame } from '../../dev/schema-types';\nimport { getTwilightContext } from '../../twilight/context';\nimport { parentOrigin } from './frame';\nimport { drawLiveBlocks } from './moves';\n\nconst CHILD = 'salla-canvas';\nconst HOST = 'salla-canvas-host';\n\n/** Where the studio runs; it alone turns canvas mode on. */\nexport const CANVAS_ORIGINS = [\n 'https://s.salla.sa',\n 'https://s.salla.dev',\n 'https://s.beta.salla.group',\n 'http://localhost:9000',\n] as const;\n\nexport type CanvasRole = 'component' | 'header' | 'footer';\n\n/** The header's or footer's own logo or menu, picked on its own. */\nexport type CanvasPart = 'logo' | 'menu';\n\n/**\n * A home block as the studio lists it, in page order. The storefront's blocks\n * carry no row id, so the studio's list names them: `eid` is what the studio\n * calls the block, matched to the page by its uuid (`key`) or its `slug`.\n */\nexport interface CanvasBlock {\n eid: string;\n key?: string | null;\n slug?: string | null;\n title?: string | null;\n}\n\nexport type CanvasCommand =\n | { type: 'select'; eid: string; part?: CanvasPart }\n | { type: 'deselect' }\n | { type: 'move'; eid: string; direction: 'up' | 'down' }\n /** Lays the blocks out in this order without saving it. */\n | { type: 'order'; eids: string[] };\n\nexport interface CanvasHost {\n /** The studio's origin once it has spoken, else `null`: the page is not in canvas mode. */\n origin: string | null;\n enabled: boolean;\n blocks: CanvasBlock[] | null;\n}\n\nconst asEid = (value: unknown): string | null =>\n typeof value === 'string' && value ? value : null;\n\nconst asPart = (value: unknown): CanvasPart | undefined =>\n value === 'logo' || value === 'menu' ? value : undefined;\n\nfunction asBlocks(value: unknown): CanvasBlock[] | null {\n if (!Array.isArray(value)) return null;\n return value.flatMap((item) => {\n const block = item as Partial<CanvasBlock> | null;\n const eid = asEid(block?.eid);\n if (!eid) return [];\n return [\n {\n eid,\n key: typeof block?.key === 'string' ? block.key : null,\n slug: typeof block?.slug === 'string' ? block.slug : null,\n title: typeof block?.title === 'string' ? block.title : null,\n },\n ];\n });\n}\n\n/** The command a studio message carries, if it is a well-formed one. */\nexport function readCommand(data: Record<string, unknown>): CanvasCommand | null {\n switch (data.type) {\n case 'select': {\n const eid = asEid(data.eid);\n return eid ? { type: 'select', eid, part: asPart(data.part) } : null;\n }\n case 'deselect':\n return { type: 'deselect' };\n case 'move': {\n const eid = asEid(data.eid);\n const direction =\n data.direction === 'up' || data.direction === 'down' ? data.direction : null;\n return eid && direction ? { type: 'move', eid, direction } : null;\n }\n case 'order':\n return Array.isArray(data.eids)\n ? { type: 'order', eids: data.eids.flatMap((eid) => asEid(eid) ?? []) }\n : null;\n default:\n return null;\n }\n}\n\n/** The engine's name for a studio block: its uuid, or its slug spelled as the storefront's path. */\nconst refOf = (block: CanvasBlock): string => block.key || block.slug?.replace(/_/g, '-') || '';\n\n/**\n * The studio block each page block is, by page order: copies of one component\n * share a uuid, so the n-th on the page is the n-th in the list. `refs` are\n * the page blocks' `data-live-block` values; `null` where none matches, and\n * for every copy of a ref the page and the list count differently, where the\n * n-th could be another row.\n */\nexport function matchBlocks(\n refs: readonly string[],\n blocks: readonly CanvasBlock[]\n): (CanvasBlock | null)[] {\n const names = (block: CanvasBlock, ref: string) => block.eid === ref || refOf(block) === ref;\n const used = new Set<number>();\n return refs.map((ref) => {\n const onPage = refs.filter((each) => each === ref).length;\n if (blocks.filter((block) => names(block, ref)).length !== onPage) return null;\n const at = blocks.findIndex((block, index) => !used.has(index) && names(block, ref));\n if (at === -1) return null;\n used.add(at);\n return blocks[at];\n });\n}\n\n/** Sends `message` to the studio, or, before it has spoken, to whichever allowed origin frames the page. */\nexport function postToCanvas(origin: string | null, message: Record<string, unknown>): void {\n const data = { source: CHILD, v: 1, ...message };\n if (origin) {\n window.parent.postMessage(data, origin);\n return;\n }\n let parent: string | null = null;\n try {\n parent = parentOrigin();\n } catch {\n parent = null;\n }\n const targets: readonly string[] = parent ? [parent] : CANVAS_ORIGINS;\n for (const target of targets) {\n if ((CANVAS_ORIGINS as readonly string[]).includes(target))\n window.parent.postMessage(data, target);\n }\n}\n\n/** What the page redraws in place when the studio saves, as `hello` tells it. */\nexport const CANVAS_CAN = ['refresh'] as const;\n\nlet lastDraw: Promise<unknown> = Promise.resolve();\n\n// Under the studio's own wait, so the page answers before the studio gives up on it.\nconst DRAW_LIMIT = 15_000;\n\n/**\n * Draws the home page again from what the studio just saved, without reloading it: its\n * blocks fetched afresh, spelled as the home loader spells them. Fails off the home page.\n */\nexport function redrawPage(): Promise<void> {\n // One at a time: the query cache would hand this save a fetch started before it.\n const draw = lastDraw.then(drawAfresh);\n lastDraw = draw.catch(() => undefined);\n return draw;\n}\n\nasync function drawAfresh(): Promise<void> {\n const { home } = await import('../../api/home');\n const { queryClient } = getTwilightContext();\n const components = home.queries.components();\n let timer: ReturnType<typeof setTimeout> | undefined;\n const tooLong = new Promise<never>((_, reject) => {\n timer = setTimeout(() => {\n // Its fetch is called off too, or the next redraw would be handed it.\n void queryClient.cancelQueries({ queryKey: components.queryKey });\n reject(new Error('redraw took too long'));\n }, DRAW_LIMIT);\n });\n const blocks = await Promise.race([\n queryClient.fetchQuery({ ...components, staleTime: 0 }),\n tooLong,\n ]).finally(() => clearTimeout(timer));\n const drawn = drawLiveBlocks(\n blocks.map((block) => ({ ...block, path: block.path?.replace('home.', '') || block.path }))\n );\n if (!drawn) throw new Error('no home page');\n}\n\n// Draws the page again for the section the studio saved; false for a refresh that names none.\nfunction refreshFor(studio: string, data: Record<string, unknown>): boolean {\n const eid = asEid(data.eid);\n if (!eid) {\n postToCanvas(studio, { type: 'refresh-failed', eid: String(data.eid ?? '') });\n return false;\n }\n redrawPage().then(\n () => {\n if (data.select === true) deliver({ type: 'select', eid });\n postToCanvas(studio, { type: 'refreshed', eid });\n },\n () => postToCanvas(studio, { type: 'refresh-failed', eid })\n );\n return true;\n}\n\n/** The overlay on screen takes the studio's commands; ones sent before it mounted wait for it. */\nlet handler: ((command: CanvasCommand) => void) | null = null;\nlet queued: CanvasCommand[] = [];\n\nfunction deliver(command: CanvasCommand): void {\n if (handler) handler(command);\n else queued.push(command);\n}\n\n/** Hands the studio's commands to `fn` while it is set, the waiting ones first. */\nexport function takeCanvasCommands(fn: (command: CanvasCommand) => void): () => void {\n handler = fn;\n const waiting = queued;\n queued = [];\n waiting.forEach(fn);\n return () => {\n if (handler === fn) handler = null;\n };\n}\n\n/**\n * Says hello to the studio once the page has loaded, and follows what it asks\n * for. Off for shoppers, for the theme editor (which never answers) and for the\n * engine's own dev editor, which keep the live editor bar.\n */\nexport function useCanvasHost(): CanvasHost {\n const [host, setHost] = useState<CanvasHost>({ origin: null, enabled: false, blocks: null });\n\n useEffect(() => {\n if (window.self === window.top || (import.meta.env.DEV && isEditorFrame())) return;\n let origin: string | null = null;\n\n const onMessage = (event: MessageEvent) => {\n if (event.source !== window.parent) return;\n const data = (event.data ?? {}) as Record<string, unknown>;\n // The studio saved on the server and wants the page drawn again, as the twig preview does.\n if (data.action === 'preview::reload') {\n if (origin && event.origin === origin) window.location.reload();\n return;\n }\n if (data.source !== HOST) return;\n if (!origin) {\n if (!(CANVAS_ORIGINS as readonly string[]).includes(event.origin)) return;\n origin = event.origin;\n } else if (event.origin !== origin) return;\n const studio = origin;\n\n // A section saved: the page is drawn again in place, and the section picked once the studio names it.\n if (data.type === 'refresh') {\n if (refreshFor(studio, data))\n setHost((prev) => (prev.origin ? prev : { ...prev, origin: studio }));\n } else if (data.type === 'enable') {\n const blocks = asBlocks(data.blocks);\n setHost((prev) => ({ origin: studio, enabled: true, blocks: blocks ?? prev.blocks }));\n } else if (data.type === 'disable') {\n queued = [];\n setHost((prev) => ({ ...prev, origin: studio, enabled: false }));\n } else {\n setHost((prev) => (prev.origin ? prev : { ...prev, origin: studio }));\n const command = readCommand(data);\n if (command) deliver(command);\n }\n };\n\n const hello = () => postToCanvas(origin, { type: 'hello', can: [...CANVAS_CAN] });\n window.addEventListener('message', onMessage);\n if (document.readyState === 'complete') hello();\n else window.addEventListener('load', hello, { once: true });\n return () => {\n window.removeEventListener('message', onMessage);\n window.removeEventListener('load', hello);\n };\n }, []);\n\n return host;\n}\n"]}
|
|
@@ -1,24 +1,11 @@
|
|
|
1
1
|
import { formatSallaPlural } from './chunk-BT6HEEAP.js';
|
|
2
|
-
import './chunk-6T55LXJL.js';
|
|
3
2
|
import { useWishlist } from './chunk-DVJGKIFQ.js';
|
|
4
3
|
import { HookSlot } from './chunk-5XDPAKF5.js';
|
|
5
|
-
import './chunk-
|
|
6
|
-
import { getActiveCurrency } from './chunk-DECKE4BB.js';
|
|
7
|
-
import './chunk-Z5M4YYWT.js';
|
|
4
|
+
import { getActiveCurrency } from './chunk-SGEJUTTK.js';
|
|
8
5
|
import { useTranslation } from './chunk-TYNZ5B2B.js';
|
|
9
6
|
import { Image } from './chunk-IVO6YRRK.js';
|
|
10
7
|
import { Link } from './chunk-3GFD7WTJ.js';
|
|
11
|
-
import { LazyCurrencySymbol } from './chunk-
|
|
12
|
-
import './chunk-EDCNCBSC.js';
|
|
13
|
-
import './chunk-SKLEJJ6M.js';
|
|
14
|
-
import './chunk-6BZ5TKEV.js';
|
|
15
|
-
import './chunk-MZPX4EPS.js';
|
|
16
|
-
import './chunk-4OZIBANF.js';
|
|
17
|
-
import './chunk-MWUAHDQL.js';
|
|
18
|
-
import './chunk-T72DAX7R.js';
|
|
19
|
-
import './chunk-DF6FBKDN.js';
|
|
20
|
-
import './chunk-VYGA5AT5.js';
|
|
21
|
-
import './chunk-DGUM43GV.js';
|
|
8
|
+
import { LazyCurrencySymbol } from './chunk-GIHEV2RT.js';
|
|
22
9
|
import { Fragment as Fragment$1, useState } from 'react';
|
|
23
10
|
import { SallaRatingStars } from '@salla.sa/twilight-components-react/rating-stars';
|
|
24
11
|
import { SallaSocialShare } from '@salla.sa/twilight-components-react/social-share';
|
|
@@ -215,6 +202,6 @@ function ProductQuantityInfo({ product }) {
|
|
|
215
202
|
] });
|
|
216
203
|
}
|
|
217
204
|
|
|
218
|
-
export { ProductDetails };
|
|
219
|
-
//# sourceMappingURL=
|
|
220
|
-
//# sourceMappingURL=
|
|
205
|
+
export { ProductDetails, ProductPrice };
|
|
206
|
+
//# sourceMappingURL=chunk-OTJ3K76X.js.map
|
|
207
|
+
//# sourceMappingURL=chunk-OTJ3K76X.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/product/ProductDetails.tsx"],"names":["Fragment"],"mappings":";;;;;;;;;;;;;;;;AAoBO,SAAS,cAAA,CAAe,EAAE,OAAA,EAAS,QAAA,GAAW,MAAK,EAAwB;AAChF,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,cAAA,EAAe;AAC7B,EAAA,MAAM,WAAW,WAAA,EAAY;AAG7B,EAAA,MAAM,kBAAA,GAAqB,EAAE,OAAA,EAAQ;AAErC,EAAA,uBACE,IAAA,CAAAA,UAAA,EACE,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,QAAA,EAAA,EAAS,IAAA,EAAA,kCAAA,kCAA0C,OAAA,EAAS,kBAAA,EAA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A,sBAAA,GAAA,CAAC,GAAA,EAAA,EAAE,WAAU,uDAAA,EAAwD,CAAA;AAAA,MACpE,CAAA,CAAE,2BAA2B,UAAU,CAAA;AAAA,MAAE,IAAA;AAAA,MAAG,OAAA,CAAQ;AAAA,KAAA,EACvD;AAAA,GAAA,EAEJ,CAAA;AAEJ","file":"chunk-OTJ3K76X.js","sourcesContent":["import { Fragment, useState } from 'react';\nimport { HookSlot } from '../../hooks/HookSlot';\nimport { HookName } from '../../types/hooks';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport { getActiveCurrency } from '../../api/client';\nimport { useWishlist } from '../../hooks/useWishlist';\nimport { CurrencySymbol, Link, Image } from '../common';\nimport { SallaRatingStars } from '@salla.sa/twilight-components-react/rating-stars';\nimport { SallaSocialShare } from '@salla.sa/twilight-components-react/social-share';\nimport { SallaButton } from '@salla.sa/twilight-components-react/button';\nimport { SallaInstallment } from '@salla.sa/twilight-components-react/installment';\nimport { SallaMetadata } from '@salla.sa/twilight-components-react/metadata';\nimport { formatSallaPlural } from '../../utils/salla-plural';\nimport type { Product } from '../../types';\n\ninterface ProductDetailsProps {\n product: Product;\n showTags?: boolean;\n}\n\nexport function ProductDetails({ product, showTags = true }: ProductDetailsProps) {\n const { t } = useTranslation();\n const wishlist = useWishlist();\n\n // Context for all product hooks - contains product data\n const productHookContext = { product };\n\n return (\n <>\n <HookSlot name={HookName.PRODUCT_DESCRIPTION_START} context={productHookContext} />\n\n {product.brand?.name && (\n <div className=\"product-brand mb-5 w-12\">\n <Link className=\"brand-logo\" to={product.brand.url || '#'} title={product.brand.name}>\n <Image\n className=\"max-h-full object-contain\"\n src={product.brand.logo}\n title={product.brand.name}\n alt={product.brand.name}\n aspectRatio=\"1/1\"\n />\n </Link>\n </div>\n )}\n\n <h1 className=\"text-xl md:text-2xl leading-10 font-bold mb-6 text-gray-800\">\n {product.name}\n </h1>\n\n {product.subtitle && (\n <h2 className=\"product-entry__sub-title text-sm text-gray-500 leading-6 mb-2.5\">\n {product.subtitle}\n </h2>\n )}\n\n {product.rating && (\n <SallaRatingStars value={product.rating.stars} reviews={product.rating.count} />\n )}\n\n {product.is_taxable && (\n <small className=\"color-grey\">{t('pages.products.tax_included', 'VAT Inclusive')}</small>\n )}\n\n <ProductPrice product={product} />\n\n <ProductDescription product={product} />\n\n {!!product.tags?.length && showTags && (\n <div className=\"mb-3\">\n {product.tags.map((tag, index) => (\n <Fragment key={tag.name}>\n <Link\n to={tag.url}\n className=\"rtl:ml-2 ltr:mr-2 inline-flex text-gray-500 hover:text-primary underline text-sm mb-1\"\n >\n {tag.name}\n </Link>\n {index < product.tags!.length - 1 && ','}\n </Fragment>\n ))}\n </div>\n )}\n\n <div className=\"flex rtl:space-x-reverse space-x-3\">\n <SallaSocialShare className=\"inline-flex mb-5\" aria-label=\"social share\" />\n\n <SallaButton\n className={`btn--wishlist animated hidden sm:inline-flex ${wishlist.has(Number(product.id)) ? 'is-added' : 'not-added'}`}\n data-id={product.id}\n onClick={() => window.salla?.wishlist.toggle(product.id)}\n shape=\"icon\"\n fill=\"outline\"\n color=\"light\"\n ariaLabel=\"add to wishlist\"\n >\n <i className=\"sicon-heart\"></i>\n </SallaButton>\n </div>\n\n <ProductQuantityInfo product={product} />\n\n {product.sku && (\n <div className=\"mb-4 flex justify-between sm:grid sm:grid-cols-3 bg-white rounded-md px-4 py-2\">\n <div className=\"flex items-center\">\n <i className=\"sicon-barcode mx-1\"></i>\n {t('pages.products.sku', 'SKU')}\n </div>\n <div className=\"text-unicode\">{product.sku}</div>\n </div>\n )}\n\n {product.barcode && (\n <div className=\"mb-4 flex justify-between sm:grid sm:grid-cols-3 bg-white rounded-md px-4 py-2\">\n <div className=\"flex items-center\">\n <i className=\"sicon-barcode mx-1\"></i>\n {t('pages.products.barcode')}\n </div>\n <div className=\"text-unicode\">{product.barcode}</div>\n </div>\n )}\n\n {product.show_availability && (\n <section className=\"bg-white p-5 rounded-md mb-5 last:mb-0\">\n <div className=\"center-between\">\n <label className=\"flex items-center text-base\">\n <span className=\"sicon-location rtl:ml-1 ltr:mr-1\"></span>\n <span className=\"inline-block\">\n {t('pages.products.availability', 'Availability')}\n </span>\n </label>\n <div className=\"mt-1 sm:mt-0 sm:col-span-2 text-end\">\n <div className=\"flex rtl:space-x-reverse space-x-3\">\n <a\n href=\"#!\"\n onClick={() =>\n window.salla?.event?.dispatch('scopes::open', {\n mode: 'availability',\n product_id: String(product.id),\n })\n }\n className=\"group text-primary flex items-center justify-center\"\n >\n <span>{t('pages.products.select_branch', 'Select Branch')}</span>\n <span className=\"sicon-keyboard_arrow_left mr-2 transition-all group-hover:-translate-x-1\"></span>\n </a>\n </div>\n </div>\n </div>\n </section>\n )}\n\n <HookSlot name={HookName.PRODUCT_DESCRIPTION} context={productHookContext} />\n\n <SallaInstallment\n price={String(\n typeof product.base_currency_price === 'object'\n ? product.base_currency_price.amount\n : product.base_currency_price\n )}\n />\n\n {product.has_metadata && <SallaMetadata />}\n </>\n );\n}\n\nexport function ProductPrice({ product }: { product: Product }) {\n const { t } = useTranslation();\n // The API converts the amounts but still labels them in the store's own currency.\n const priceCurrency = getActiveCurrency(product.currency);\n\n return (\n <div className=\"flex whitespace-nowrap gap-4 items-center\">\n <div\n className={`${product.is_on_sale ? '' : 'hidden'} space-x-2 rtl:space-x-reverse whitespace-nowrap`}\n >\n <p className=\"text-red-800 font-bold text-xl inline-block\">\n {product.sale_price} <CurrencySymbol currency={priceCurrency} />\n </p>\n <span className=\"text-gray-500 line-through\">\n {product.regular_price} <CurrencySymbol currency={priceCurrency} />\n </span>\n </div>\n <div className={`gap-4 ${product.is_on_sale ? 'hidden' : 'flex'}`}>\n {product.starting_price && (\n <span>{t('pages.products.starting_price', 'Starting from')}</span>\n )}\n <p className=\"font-bold text-xl inline-block\">\n {product.starting_price ?? product.price} <CurrencySymbol currency={priceCurrency} />\n </p>\n </div>\n </div>\n );\n}\n\n/** An `<iframe>` start tag; quoted values may hold `>`. */\nconst IFRAME_TAG = /<iframe\\b(?:[^>\"']|\"[^\"]*\"|'[^']*')*>/gi;\n\n/** Embedded players (YouTube, Vimeo, maps) load only when scrolled near, unless the merchant set `loading`. */\nfunction lazyIframes(html: string): string {\n return html.replace(IFRAME_TAG, (tag) =>\n /\\sloading\\s*=/i.test(tag.replace(/\"[^\"]*\"|'[^']*'/g, '\"\"'))\n ? tag\n : tag.replace(/^<iframe/i, '<iframe loading=\"lazy\"')\n );\n}\n\nfunction ProductDescription({ product }: { product: Product }) {\n const { t } = useTranslation();\n const [isExpanded, setIsExpanded] = useState(false);\n\n if (!product.description) return null;\n\n const description = lazyIframes(product.description.replace(/ /g, '\\n'));\n\n if (product.has_read_more) {\n return (\n <div className=\"product__description p-2 px-5 sm:p-1 leading-7 mb-3\">\n <article\n className=\"article article--main relative leading-8 overflow-hidden transition-all duration-300 py-4\"\n id=\"more-content\"\n style={{ maxHeight: isExpanded ? 'none' : '5.25rem' }}\n dangerouslySetInnerHTML={{ __html: description }}\n />\n <button\n type=\"button\"\n id=\"btn-show-more\"\n className={`link--primary inline-block mt-2 cursor-pointer bg-transparent border-0 p-0 ${isExpanded ? 'is-expanded' : ''}`}\n onClick={() => setIsExpanded(true)}\n >\n {t('pages.products.read_more', 'Read more')}\n </button>\n </div>\n );\n }\n\n return (\n <div className=\"product__description p-2 px-5 sm:p-1 leading-7 mb-3\">\n <article className=\"article--main pb-1\" dangerouslySetInnerHTML={{ __html: description }} />\n </div>\n );\n}\n\nfunction ProductQuantityInfo({ product }: { product: Product }) {\n const { t } = useTranslation();\n if (product.sold_quantity == null && !product.can_show_remained_quantity) {\n return null;\n }\n\n return (\n <div className=\"bg-white py-2.5 mb-5 rounded-md inline-flex text-sm\">\n {(product.sold_quantity ?? 0) > 0 && (\n <div className=\"px-4 !text-red-800\">\n <i className=\"sicon-fire rtl:ml-1.5 ltr:mr-1.5\"></i> {t('pages.products.sold', 'Sold')}{' '}\n {/* Salla ships `sold_times` in Laravel plural format; resolve it for the count. */}\n <span>{formatSallaPlural(t('pages.products.sold_times'), product.sold_quantity!)}</span>\n </div>\n )}\n {product.can_show_remained_quantity && (\n <div className=\"px-4 rtl:even:border-r ltr:even:border-l even:border-gray-200\">\n <i className=\"!text-red-800 sicon-box-bankers rtl:ml-1.5 ltr:mr-1.5\"></i>\n {t('pages.products.remained', 'Remained')}: {product.quantity}\n </div>\n )}\n </div>\n );\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { api } from './chunk-
|
|
1
|
+
import { api } from './chunk-SGEJUTTK.js';
|
|
2
2
|
|
|
3
3
|
// src/api/wallet.ts
|
|
4
4
|
var wallet = {
|
|
@@ -20,5 +20,5 @@ var wallet = {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export { wallet };
|
|
23
|
-
//# sourceMappingURL=chunk-
|
|
24
|
-
//# sourceMappingURL=chunk-
|
|
23
|
+
//# sourceMappingURL=chunk-RRJZJHZK.js.map
|
|
24
|
+
//# sourceMappingURL=chunk-RRJZJHZK.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/wallet.ts"],"names":[],"mappings":";;;AAgCO,IAAM,MAAA,GAAS;AAAA,EACpB,IAAA,EAAM,OAAO,MAAA,GAA2B,EAAC,KAAiC;AACxE,IAAA,MAAM,EAAE,IAAA,GAAO,CAAA,EAAG,OAAA,GAAU,EAAA,EAAI,QAAO,GAAI,MAAA;AAE3C,IAAA,MAAM,YAAA,GAAe,IAAI,eAAA,EAAgB;AACzC,IAAA,YAAA,CAAa,GAAA,CAAI,MAAA,EAAQ,MAAA,CAAO,IAAI,CAAC,CAAA;AACrC,IAAA,YAAA,CAAa,GAAA,CAAI,UAAA,EAAY,MAAA,CAAO,OAAO,CAAC,CAAA;AAE5C,IAAA,MAAM,UAAmC,EAAC;AAC1C,IAAA,IAAI,MAAA,UAAgB,MAAA,GAAS,MAAA;AAE7B,IAAA,MAAM,QAAA,GAAW,MAAM,GAAA,CACpB,GAAA,CAAI,CAAA,eAAA,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;AACF","file":"chunk-RRJZJHZK.js","sourcesContent":["import { api } from './client';\n\nexport interface TransactionItem {\n id: number;\n order_id: number;\n transaction_type: string;\n action_type: string;\n type: string;\n title: string;\n description: string;\n amount: number;\n created_at: number;\n expired_at: number;\n}\n\nexport interface WalletListParams {\n page?: number;\n perPage?: number;\n signal?: AbortSignal;\n}\n\nexport interface WalletListResponse {\n data: TransactionItem[];\n next_page_url: string | null;\n}\n\nexport interface WalletListResult {\n items: TransactionItem[];\n next: string | null;\n balance: number;\n}\n\nexport const wallet = {\n list: async (params: WalletListParams = {}): Promise<WalletListResult> => {\n const { page = 1, perPage = 10, signal } = params;\n\n const searchParams = new URLSearchParams();\n searchParams.set('page', String(page));\n searchParams.set('per_page', String(perPage));\n\n const options: Record<string, unknown> = {};\n if (signal) options.signal = signal;\n\n const response = await api\n .get(`balance/wallet?${searchParams.toString()}`, options as any)\n .json<{ data: { transactions: WalletListResponse; balance: number } }>();\n\n const transactions = response.data.transactions;\n\n return {\n items: transactions.data ?? [],\n next: transactions.next_page_url,\n balance: response.data.balance,\n };\n },\n};\n"]}
|
|
@@ -30,7 +30,7 @@ function rebaseApiUrl(url, from, to) {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
// src/utils/engine-version.ts
|
|
33
|
-
var ENGINE_VERSION = "1.0.
|
|
33
|
+
var ENGINE_VERSION = "1.0.187" ;
|
|
34
34
|
var DEV_SETTINGS_TTL_MS = 60 * 6e4;
|
|
35
35
|
var HIT_HEADER = "x-twilight-dev-cache";
|
|
36
36
|
var FETCHED_AT_HEADER = "x-twilight-dev-fetched-at";
|
|
@@ -275,5 +275,5 @@ var filesCdn = ky.extend({
|
|
|
275
275
|
});
|
|
276
276
|
|
|
277
277
|
export { API_BASE_HEADER, ENGINE_VERSION, STORE_IDENTIFIER_HEADER, api, cdn, devSettingsFetchedAt, filesCdn, getActiveCurrency, getActiveScope, getActiveScopeId, getAuthToken, resolveRequestApiBase };
|
|
278
|
-
//# sourceMappingURL=chunk-
|
|
279
|
-
//# sourceMappingURL=chunk-
|
|
278
|
+
//# sourceMappingURL=chunk-SGEJUTTK.js.map
|
|
279
|
+
//# sourceMappingURL=chunk-SGEJUTTK.js.map
|