@salla.sa/twilight-theme-engine 1.0.168 → 1.0.170
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-MJET75YK.js → AddToCartForm-N5KRFZHA.js} +3 -3
- package/dist/{AddToCartForm-MJET75YK.js.map → AddToCartForm-N5KRFZHA.js.map} +1 -1
- package/dist/{BlogAuthorPage-STM7CHCX.js → BlogAuthorPage-CFZJ4GBK.js} +30 -30
- package/dist/{BlogAuthorPage-STM7CHCX.js.map → BlogAuthorPage-CFZJ4GBK.js.map} +1 -1
- package/dist/{BlogCategoryPage-4RC5Z3S5.js → BlogCategoryPage-U234IWSO.js} +30 -30
- package/dist/{BlogCategoryPage-4RC5Z3S5.js.map → BlogCategoryPage-U234IWSO.js.map} +1 -1
- package/dist/{BlogPage-YTCOYYNJ.js → BlogPage-S3UANDPF.js} +28 -28
- package/dist/{BlogPage-YTCOYYNJ.js.map → BlogPage-S3UANDPF.js.map} +1 -1
- package/dist/{BlogSinglePage-ZA645VKI.js → BlogSinglePage-VGQOKXCD.js} +28 -28
- package/dist/{BlogSinglePage-ZA645VKI.js.map → BlogSinglePage-VGQOKXCD.js.map} +1 -1
- package/dist/{BlogTagPage-H5ZAKDY3.js → BlogTagPage-H2JY5LUB.js} +30 -30
- package/dist/{BlogTagPage-H5ZAKDY3.js.map → BlogTagPage-H2JY5LUB.js.map} +1 -1
- package/dist/{BrandsPage-EI3RXI7P.js → BrandsPage-DILFCLUR.js} +29 -29
- package/dist/{BrandsPage-EI3RXI7P.js.map → BrandsPage-DILFCLUR.js.map} +1 -1
- package/dist/{Breadcrumb-2VTKPEDN.js → Breadcrumb-AWJTQ3UI.js} +28 -28
- package/dist/{Breadcrumb-2VTKPEDN.js.map → Breadcrumb-AWJTQ3UI.js.map} +1 -1
- package/dist/{CartItem-GQQFSJWY.js → CartItem-3MUT6WOD.js} +28 -28
- package/dist/{CartItem-GQQFSJWY.js.map → CartItem-3MUT6WOD.js.map} +1 -1
- package/dist/{CartSummary-QLFV3PMY.js → CartSummary-WDDX4RO6.js} +28 -28
- package/dist/{CartSummary-QLFV3PMY.js.map → CartSummary-WDDX4RO6.js.map} +1 -1
- package/dist/{Copyright-Y5YOBPMO.js → Copyright-3VHGRYFB.js} +3 -3
- package/dist/{Copyright-Y5YOBPMO.js.map → Copyright-3VHGRYFB.js.map} +1 -1
- package/dist/{CustomerLayout-4J4PXFCZ.js → CustomerLayout-4AXP2TSB.js} +28 -28
- package/dist/{CustomerLayout-4J4PXFCZ.js.map → CustomerLayout-4AXP2TSB.js.map} +1 -1
- package/dist/{Footer-FFAPF75A.js → Footer-2EMD7B6K.js} +4 -4
- package/dist/{Footer-FFAPF75A.js.map → Footer-2EMD7B6K.js.map} +1 -1
- package/dist/GoogleTag-CEYIEWCD.js +15 -0
- package/dist/{GoogleTag-KJQJWIGL.js.map → GoogleTag-CEYIEWCD.js.map} +1 -1
- package/dist/Header-BWUDOZIG.js +24 -0
- package/dist/{Header-V4UEPHWU.js.map → Header-BWUDOZIG.js.map} +1 -1
- package/dist/{LatestProducts-BQXOELU5.js → LatestProducts-FGBUOJNV.js} +30 -30
- package/dist/{LatestProducts-BQXOELU5.js.map → LatestProducts-FGBUOJNV.js.map} +1 -1
- package/dist/{LoyaltyPage-6UTFEXKJ.js → LoyaltyPage-GZRK5ALQ.js} +28 -28
- package/dist/{LoyaltyPage-6UTFEXKJ.js.map → LoyaltyPage-GZRK5ALQ.js.map} +1 -1
- package/dist/{LoyaltyPointsPage-BUI2AQ6D.js → LoyaltyPointsPage-UQEPGH4O.js} +9 -9
- package/dist/{LoyaltyPointsPage-BUI2AQ6D.js.map → LoyaltyPointsPage-UQEPGH4O.js.map} +1 -1
- package/dist/{MainMenu-BY4YGIKY.js → MainMenu-SJIJTJDI.js} +8 -8
- package/dist/{MainMenu-BY4YGIKY.js.map → MainMenu-SJIJTJDI.js.map} +1 -1
- package/dist/MaintenancePage-SFZN7G27.js +7 -0
- package/dist/{MaintenancePage-U5P43D52.js.map → MaintenancePage-SFZN7G27.js.map} +1 -1
- package/dist/{MasterLayout-NFUEMWTA.js → MasterLayout-UKYVRBWD.js} +28 -28
- package/dist/{MasterLayout-NFUEMWTA.js.map → MasterLayout-UKYVRBWD.js.map} +1 -1
- package/dist/{MobileMenu-7CBD3WLM.js → MobileMenu-EXT5NER6.js} +29 -29
- package/dist/{MobileMenu-7CBD3WLM.js.map → MobileMenu-EXT5NER6.js.map} +1 -1
- package/dist/{NotificationsPage-3MBXQY44.js → NotificationsPage-JKPLPPRY.js} +28 -28
- package/dist/{NotificationsPage-3MBXQY44.js.map → NotificationsPage-JKPLPPRY.js.map} +1 -1
- package/dist/{OrderSinglePage-5VLPW436.js → OrderSinglePage-YEZUALDJ.js} +29 -29
- package/dist/{OrderSinglePage-5VLPW436.js.map → OrderSinglePage-YEZUALDJ.js.map} +1 -1
- package/dist/{OrdersPage-4XHZMJHG.js → OrdersPage-3NX6H3M2.js} +28 -28
- package/dist/{OrdersPage-4XHZMJHG.js.map → OrdersPage-3NX6H3M2.js.map} +1 -1
- package/dist/{PageSingle-ISZVV5KV.js → PageSingle-WHCTDTN4.js} +7 -7
- package/dist/{PageSingle-ISZVV5KV.js.map → PageSingle-WHCTDTN4.js.map} +1 -1
- package/dist/{ProductDetails-AGXBUXNF.js → ProductDetails-6A4NQZUG.js} +8 -8
- package/dist/{ProductDetails-AGXBUXNF.js.map → ProductDetails-6A4NQZUG.js.map} +1 -1
- package/dist/{ProfilePage-FJOR5B3D.js → ProfilePage-4JN4FWDL.js} +28 -28
- package/dist/{ProfilePage-FJOR5B3D.js.map → ProfilePage-4JN4FWDL.js.map} +1 -1
- package/dist/{ReviewsPage-7LUNOZ6K.js → ReviewsPage-Z72EVOUP.js} +3 -3
- package/dist/{ReviewsPage-7LUNOZ6K.js.map → ReviewsPage-Z72EVOUP.js.map} +1 -1
- package/dist/{SeoCartWidget-QZEXYDDZ.js → SeoCartWidget-YTUXIE5K.js} +28 -28
- package/dist/{SeoCartWidget-QZEXYDDZ.js.map → SeoCartWidget-YTUXIE5K.js.map} +1 -1
- package/dist/{SettingsPage-ISAJVECQ.js → SettingsPage-KP3TZA6T.js} +28 -28
- package/dist/{SettingsPage-ISAJVECQ.js.map → SettingsPage-KP3TZA6T.js.map} +1 -1
- package/dist/{StoreClosedNotification-N3IBELFL.js → StoreClosedNotification-PKCCIWYS.js} +29 -29
- package/dist/{StoreClosedNotification-N3IBELFL.js.map → StoreClosedNotification-PKCCIWYS.js.map} +1 -1
- package/dist/{TestimonialsPage-JSCUGFKU.js → TestimonialsPage-L6TPOHFS.js} +7 -7
- package/dist/{TestimonialsPage-JSCUGFKU.js.map → TestimonialsPage-L6TPOHFS.js.map} +1 -1
- package/dist/{ThankYouPage-3IJMBXF4.js → ThankYouPage-AJQHNAMC.js} +28 -28
- package/dist/{ThankYouPage-3IJMBXF4.js.map → ThankYouPage-AJQHNAMC.js.map} +1 -1
- package/dist/{WalletPage-OGVRLC5Z.js → WalletPage-OODS46SY.js} +29 -29
- package/dist/{WalletPage-OGVRLC5Z.js.map → WalletPage-OODS46SY.js.map} +1 -1
- package/dist/{WebMcpTools-QLTEVKNZ.js → WebMcpTools-QER3LZDE.js} +10 -10
- package/dist/{WebMcpTools-QLTEVKNZ.js.map → WebMcpTools-QER3LZDE.js.map} +1 -1
- package/dist/{WishlistPage-O4CIL5EO.js → WishlistPage-CPFMDBOK.js} +30 -30
- package/dist/{WishlistPage-O4CIL5EO.js.map → WishlistPage-CPFMDBOK.js.map} +1 -1
- package/dist/api/advertisement.js +5 -5
- package/dist/api/apps.js +5 -5
- package/dist/api/blog.js +7 -7
- package/dist/api/brands.js +7 -7
- package/dist/api/cart.js +7 -7
- package/dist/api/category.js +7 -7
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +4 -4
- package/dist/api/custom-url.js +5 -5
- package/dist/api/home.js +5 -5
- package/dist/api/loyalty.js +7 -7
- package/dist/api/menu.js +5 -5
- package/dist/api/notification.js +5 -5
- package/dist/api/order.js +7 -7
- package/dist/api/page.js +7 -7
- package/dist/api/product.js +7 -7
- package/dist/api/profile.js +4 -4
- package/dist/api/store.js +6 -6
- package/dist/api/translations.js +5 -5
- package/dist/api/user.js +5 -5
- package/dist/api/wallet.js +5 -5
- package/dist/api/wishlist.js +8 -8
- package/dist/{chunk-24JPD5MN.js → chunk-2KZ7XUJU.js} +3 -3
- package/dist/{chunk-24JPD5MN.js.map → chunk-2KZ7XUJU.js.map} +1 -1
- package/dist/{chunk-MDE65FXE.js → chunk-4W3WHZMS.js} +5 -5
- package/dist/{chunk-MDE65FXE.js.map → chunk-4W3WHZMS.js.map} +1 -1
- package/dist/{chunk-YFAALRGJ.js → chunk-5BOLKNHR.js} +3 -3
- package/dist/{chunk-YFAALRGJ.js.map → chunk-5BOLKNHR.js.map} +1 -1
- package/dist/{chunk-24SECEZ4.js → chunk-5EQTMPDZ.js} +4 -4
- package/dist/{chunk-24SECEZ4.js.map → chunk-5EQTMPDZ.js.map} +1 -1
- package/dist/{chunk-LK643DPN.js → chunk-5VIATSFK.js} +3 -3
- package/dist/{chunk-LK643DPN.js.map → chunk-5VIATSFK.js.map} +1 -1
- package/dist/{chunk-TZOXDPIG.js → chunk-5VOMO5MU.js} +4 -4
- package/dist/{chunk-TZOXDPIG.js.map → chunk-5VOMO5MU.js.map} +1 -1
- package/dist/{chunk-I2WKCWOQ.js → chunk-6HIW7MTL.js} +9 -9
- package/dist/{chunk-I2WKCWOQ.js.map → chunk-6HIW7MTL.js.map} +1 -1
- package/dist/{chunk-CMBMJNKU.js → chunk-75EUSH73.js} +4 -4
- package/dist/{chunk-CMBMJNKU.js.map → chunk-75EUSH73.js.map} +1 -1
- package/dist/{chunk-7LP5WA3U.js → chunk-7EQX7PQH.js} +3 -3
- package/dist/{chunk-7LP5WA3U.js.map → chunk-7EQX7PQH.js.map} +1 -1
- package/dist/{chunk-M54B252W.js → chunk-7XV65HOU.js} +3 -3
- package/dist/{chunk-M54B252W.js.map → chunk-7XV65HOU.js.map} +1 -1
- package/dist/{chunk-5VG3PFTB.js → chunk-7YULQON5.js} +4 -4
- package/dist/{chunk-5VG3PFTB.js.map → chunk-7YULQON5.js.map} +1 -1
- package/dist/{chunk-EZ7U2LSG.js → chunk-ADILJ36S.js} +4 -4
- package/dist/{chunk-EZ7U2LSG.js.map → chunk-ADILJ36S.js.map} +1 -1
- package/dist/{chunk-3VII4U2I.js → chunk-AN75QHVE.js} +3 -3
- package/dist/{chunk-3VII4U2I.js.map → chunk-AN75QHVE.js.map} +1 -1
- package/dist/{chunk-LRJFPMD2.js → chunk-ASIK6ELH.js} +8 -8
- package/dist/{chunk-LRJFPMD2.js.map → chunk-ASIK6ELH.js.map} +1 -1
- package/dist/{chunk-6K34BCUP.js → chunk-AWV3WEKH.js} +12 -4
- package/dist/chunk-AWV3WEKH.js.map +1 -0
- package/dist/{chunk-QHTO6H7T.js → chunk-DDH4NPLR.js} +3 -3
- package/dist/{chunk-QHTO6H7T.js.map → chunk-DDH4NPLR.js.map} +1 -1
- package/dist/{chunk-W2TVQNZT.js → chunk-DQ2N5TEK.js} +7 -7
- package/dist/{chunk-W2TVQNZT.js.map → chunk-DQ2N5TEK.js.map} +1 -1
- package/dist/{chunk-6IUO4G6Z.js → chunk-DWSLSXJ3.js} +5 -5
- package/dist/{chunk-6IUO4G6Z.js.map → chunk-DWSLSXJ3.js.map} +1 -1
- package/dist/{chunk-A5MCFXY2.js → chunk-F7YL2DOY.js} +5 -5
- package/dist/{chunk-A5MCFXY2.js.map → chunk-F7YL2DOY.js.map} +1 -1
- package/dist/{chunk-ILCDUF7M.js → chunk-FTVDHLIQ.js} +4 -4
- package/dist/{chunk-ILCDUF7M.js.map → chunk-FTVDHLIQ.js.map} +1 -1
- package/dist/{chunk-PQMG5FDD.js → chunk-G5V2MPC5.js} +4 -4
- package/dist/{chunk-PQMG5FDD.js.map → chunk-G5V2MPC5.js.map} +1 -1
- package/dist/{chunk-4B75V3OU.js → chunk-HTMXU4ZK.js} +3 -3
- package/dist/{chunk-4B75V3OU.js.map → chunk-HTMXU4ZK.js.map} +1 -1
- package/dist/{chunk-7P2ZLW6S.js → chunk-HVUC24DL.js} +4 -4
- package/dist/{chunk-7P2ZLW6S.js.map → chunk-HVUC24DL.js.map} +1 -1
- package/dist/{chunk-CZ6VJPCG.js → chunk-IDFWFDVF.js} +3 -3
- package/dist/{chunk-CZ6VJPCG.js.map → chunk-IDFWFDVF.js.map} +1 -1
- package/dist/{chunk-SY7ESZ44.js → chunk-IPW4JC7Z.js} +3 -3
- package/dist/{chunk-SY7ESZ44.js.map → chunk-IPW4JC7Z.js.map} +1 -1
- package/dist/{chunk-ZCBBDLJU.js → chunk-JS2UUQ5B.js} +5 -5
- package/dist/{chunk-ZCBBDLJU.js.map → chunk-JS2UUQ5B.js.map} +1 -1
- package/dist/{chunk-4YGEAIFB.js → chunk-JW4QTH2U.js} +3 -3
- package/dist/{chunk-4YGEAIFB.js.map → chunk-JW4QTH2U.js.map} +1 -1
- package/dist/{chunk-AKPRDR3B.js → chunk-KNVMG7LJ.js} +5 -5
- package/dist/{chunk-AKPRDR3B.js.map → chunk-KNVMG7LJ.js.map} +1 -1
- package/dist/{chunk-MJHYGAN3.js → chunk-KY2VNPZX.js} +4 -4
- package/dist/{chunk-MJHYGAN3.js.map → chunk-KY2VNPZX.js.map} +1 -1
- package/dist/{chunk-AWYEN6BR.js → chunk-LQY6T5AK.js} +4 -4
- package/dist/{chunk-AWYEN6BR.js.map → chunk-LQY6T5AK.js.map} +1 -1
- package/dist/{chunk-N6ZPXZ6I.js → chunk-MHWMDWOK.js} +9 -9
- package/dist/{chunk-N6ZPXZ6I.js.map → chunk-MHWMDWOK.js.map} +1 -1
- package/dist/{chunk-USK24DJ7.js → chunk-ODMEJVTL.js} +6 -6
- package/dist/{chunk-USK24DJ7.js.map → chunk-ODMEJVTL.js.map} +1 -1
- package/dist/{chunk-G3BVPJQL.js → chunk-OQDYOVAR.js} +7 -7
- package/dist/{chunk-G3BVPJQL.js.map → chunk-OQDYOVAR.js.map} +1 -1
- package/dist/{chunk-QAA4KBUH.js → chunk-OYZPZU4A.js} +4 -4
- package/dist/{chunk-QAA4KBUH.js.map → chunk-OYZPZU4A.js.map} +1 -1
- package/dist/{chunk-NKRWGDGH.js → chunk-P5KLE7KA.js} +7 -7
- package/dist/{chunk-NKRWGDGH.js.map → chunk-P5KLE7KA.js.map} +1 -1
- package/dist/{chunk-FYCIDZJW.js → chunk-P62RTWYQ.js} +37 -7
- package/dist/chunk-P62RTWYQ.js.map +1 -0
- package/dist/{chunk-7IW6QMVN.js → chunk-PJYPHDVM.js} +7 -7
- package/dist/{chunk-7IW6QMVN.js.map → chunk-PJYPHDVM.js.map} +1 -1
- package/dist/{chunk-3Y6HAX72.js → chunk-PQR776WF.js} +43 -6
- package/dist/chunk-PQR776WF.js.map +1 -0
- package/dist/{chunk-X55R4VVK.js → chunk-PZ4ARDUK.js} +3 -3
- package/dist/{chunk-X55R4VVK.js.map → chunk-PZ4ARDUK.js.map} +1 -1
- package/dist/{chunk-7QGUNZQI.js → chunk-QWHZO63B.js} +4 -4
- package/dist/{chunk-7QGUNZQI.js.map → chunk-QWHZO63B.js.map} +1 -1
- package/dist/{chunk-WIU2K7P7.js → chunk-R2QTV2BX.js} +3 -3
- package/dist/{chunk-WIU2K7P7.js.map → chunk-R2QTV2BX.js.map} +1 -1
- package/dist/{chunk-LOSHC7HD.js → chunk-RASX3WAM.js} +4 -4
- package/dist/{chunk-LOSHC7HD.js.map → chunk-RASX3WAM.js.map} +1 -1
- package/dist/{chunk-4D6MHAXI.js → chunk-RBTYXV7Z.js} +7 -7
- package/dist/{chunk-4D6MHAXI.js.map → chunk-RBTYXV7Z.js.map} +1 -1
- package/dist/{chunk-IXUYCRYA.js → chunk-RRCEFLFD.js} +3 -3
- package/dist/{chunk-IXUYCRYA.js.map → chunk-RRCEFLFD.js.map} +1 -1
- package/dist/{chunk-6S3RRREO.js → chunk-S5CMEVMB.js} +25 -25
- package/dist/{chunk-6S3RRREO.js.map → chunk-S5CMEVMB.js.map} +1 -1
- package/dist/{chunk-JUIALGO2.js → chunk-SDYSEO5A.js} +4 -4
- package/dist/{chunk-JUIALGO2.js.map → chunk-SDYSEO5A.js.map} +1 -1
- package/dist/{chunk-J5HHXQQO.js → chunk-SZ5FM2HR.js} +5 -5
- package/dist/{chunk-J5HHXQQO.js.map → chunk-SZ5FM2HR.js.map} +1 -1
- package/dist/{chunk-VSB6OH62.js → chunk-T3NWHBEO.js} +5 -5
- package/dist/{chunk-VSB6OH62.js.map → chunk-T3NWHBEO.js.map} +1 -1
- package/dist/{chunk-KHBMMAK7.js → chunk-TGOHNUQJ.js} +5 -5
- package/dist/{chunk-KHBMMAK7.js.map → chunk-TGOHNUQJ.js.map} +1 -1
- package/dist/{chunk-I62L6AEC.js → chunk-TPL7C44F.js} +3 -3
- package/dist/{chunk-I62L6AEC.js.map → chunk-TPL7C44F.js.map} +1 -1
- package/dist/{chunk-ENHT7GRB.js → chunk-TPLORTAB.js} +7 -7
- package/dist/{chunk-ENHT7GRB.js.map → chunk-TPLORTAB.js.map} +1 -1
- package/dist/{chunk-HWFTMI37.js → chunk-UF7APKW2.js} +3 -3
- package/dist/{chunk-HWFTMI37.js.map → chunk-UF7APKW2.js.map} +1 -1
- package/dist/{chunk-UB22F4FC.js → chunk-ULGMHZXV.js} +3 -3
- package/dist/{chunk-UB22F4FC.js.map → chunk-ULGMHZXV.js.map} +1 -1
- package/dist/{chunk-5IM34REC.js → chunk-USSE7F4G.js} +4 -4
- package/dist/{chunk-5IM34REC.js.map → chunk-USSE7F4G.js.map} +1 -1
- package/dist/{chunk-ANECYRP2.js → chunk-VI2MEH77.js} +23 -19
- package/dist/chunk-VI2MEH77.js.map +1 -0
- package/dist/{chunk-2VUFGJHL.js → chunk-VUTFOCYS.js} +5 -5
- package/dist/{chunk-2VUFGJHL.js.map → chunk-VUTFOCYS.js.map} +1 -1
- package/dist/{chunk-5MOYPNLN.js → chunk-WIRMHJF3.js} +4 -4
- package/dist/{chunk-5MOYPNLN.js.map → chunk-WIRMHJF3.js.map} +1 -1
- package/dist/{chunk-AHR2RGKC.js → chunk-WZNSF45B.js} +3 -3
- package/dist/{chunk-AHR2RGKC.js.map → chunk-WZNSF45B.js.map} +1 -1
- package/dist/{chunk-5OIZY4FF.js → chunk-YGWCFYTF.js} +5 -5
- package/dist/{chunk-5OIZY4FF.js.map → chunk-YGWCFYTF.js.map} +1 -1
- package/dist/{chunk-4E5X7COD.js → chunk-YKWH7W75.js} +5 -5
- package/dist/{chunk-4E5X7COD.js.map → chunk-YKWH7W75.js.map} +1 -1
- package/dist/{chunk-MSZVSP2O.js → chunk-YZU3GL3K.js} +3 -3
- package/dist/{chunk-MSZVSP2O.js.map → chunk-YZU3GL3K.js.map} +1 -1
- package/dist/{chunk-Y2JWGES7.js → chunk-ZJUQMRLD.js} +6 -6
- package/dist/{chunk-Y2JWGES7.js.map → chunk-ZJUQMRLD.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 +26 -26
- package/dist/components/home/index.js +31 -31
- package/dist/components/layout/index.js +7 -7
- package/dist/components/product/index.js +28 -28
- package/dist/components/store/index.js +28 -28
- package/dist/components/toast/index.js +5 -5
- package/dist/components/tracking/index.js +10 -10
- package/dist/custom-urls-JDYZLJSU.js +17 -0
- package/dist/{custom-urls-2JI5ITZZ.js.map → custom-urls-JDYZLJSU.js.map} +1 -1
- package/dist/dev/editor/index.js +3 -3
- package/dist/dev/index.js +3 -3
- package/dist/document-class-CZ2DCXTF.js +38 -0
- package/dist/{document-class-UAA7Q3HO.js.map → document-class-CZ2DCXTF.js.map} +1 -1
- package/dist/hooks/index.js +26 -26
- package/dist/hooks/useComments.js +4 -4
- package/dist/hooks/useGtm.js +26 -26
- package/dist/hooks/useMoney.js +26 -26
- package/dist/hooks/useProduct.js +4 -4
- package/dist/hooks/useStore.js +26 -26
- package/dist/hooks/useUser.js +6 -6
- package/dist/hooks/useWishlist.js +4 -4
- package/dist/index.js +26 -26
- package/dist/native-app/index.js +4 -4
- package/dist/navigation-6LMWRB3S.js +15 -0
- package/dist/{navigation-H57C5F3A.js.map → navigation-6LMWRB3S.js.map} +1 -1
- package/dist/{navigation-MMMUJNJL.js → navigation-IZVDSLQ5.js} +8 -8
- package/dist/{navigation-MMMUJNJL.js.map → navigation-IZVDSLQ5.js.map} +1 -1
- package/dist/{not-found-ILLMC2E6.js → not-found-FVQDUMNN.js} +29 -29
- package/dist/{not-found-ILLMC2E6.js.map → not-found-FVQDUMNN.js.map} +1 -1
- package/dist/providers/index.js +26 -26
- package/dist/routes/account/orders.js +9 -9
- package/dist/routes/account.js +18 -18
- package/dist/routes/blog.js +13 -13
- package/dist/routes/brands.js +9 -9
- package/dist/routes/cart.js +35 -35
- package/dist/routes/home.js +32 -32
- package/dist/routes/index.js +13 -13
- package/dist/routes/loyalty.js +10 -10
- package/dist/routes/page.js +9 -9
- package/dist/routes/product-listing.js +36 -36
- package/dist/routes/product.js +35 -35
- package/dist/routes/root/beforeLoad.d.ts.map +1 -1
- package/dist/routes/seo-redirects.js +13 -13
- package/dist/routes/testimonials.js +5 -5
- package/dist/routes/thank-you.js +9 -9
- package/dist/skeleton.js +32 -32
- package/dist/{store-lookup-756PL3AO.js → store-lookup-ATPY4J4T.js} +12 -12
- package/dist/{store-lookup-756PL3AO.js.map → store-lookup-ATPY4J4T.js.map} +1 -1
- package/dist/tanstack/middleware/twilight.d.ts.map +1 -1
- package/dist/tanstack.js +28 -26
- package/dist/tanstack.js.map +1 -1
- package/dist/twilight/context.d.ts +7 -0
- package/dist/twilight/context.d.ts.map +1 -1
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/api-base.d.ts +26 -0
- package/dist/utils/api-base.d.ts.map +1 -0
- package/dist/utils/baseHead.js +3 -3
- package/dist/utils/index.js +7 -7
- package/dist/utils/runtime-env.d.ts +1 -1
- package/dist/utils/runtime-env.d.ts.map +1 -1
- package/dist/utils/store-base.d.ts +39 -0
- package/dist/utils/store-base.d.ts.map +1 -1
- package/dist/utils/store-identity.d.ts +9 -0
- package/dist/utils/store-identity.d.ts.map +1 -1
- package/dist/vite/index.js +5 -5
- package/package.json +1 -1
- package/tailwind/routes/root/beforeLoad.ts.txt +14 -2
- package/dist/GoogleTag-KJQJWIGL.js +0 -15
- package/dist/Header-V4UEPHWU.js +0 -24
- package/dist/MaintenancePage-U5P43D52.js +0 -7
- package/dist/chunk-3Y6HAX72.js.map +0 -1
- package/dist/chunk-6K34BCUP.js.map +0 -1
- package/dist/chunk-ANECYRP2.js.map +0 -1
- package/dist/chunk-FYCIDZJW.js.map +0 -1
- package/dist/custom-urls-2JI5ITZZ.js +0 -17
- package/dist/document-class-UAA7Q3HO.js +0 -38
- package/dist/navigation-H57C5F3A.js +0 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/store/MaintenancePage.tsx"],"names":[],"mappings":";;;;AAIA,IAAM,SAAA,GAAY,yEAAA;AAClB,IAAM,mBAAA,GACJ,4EAAA;AAGF,IAAM,YAAA,GAA8C;AAAA,EAClD,CAAC,WAAW,SAAS,CAAA;AAAA,EACrB,CAAC,YAAY,gBAAgB,CAAA;AAAA,EAC7B,CAAC,WAAW,eAAe,CAAA;AAAA,EAC3B,CAAC,UAAU,cAAc,CAAA;AAAA,EACzB,CAAC,YAAY,gBAAgB,CAAA;AAAA,EAC7B,CAAC,aAAa,iBAAiB;AACjC,CAAA;AAGA,SAAS,YAAY,KAAA,EAA0B;AAC7C,EAAA,OAAO,aAAa,OAAA,CAAQ,CAAC,CAAC,GAAA,EAAK,IAAI,CAAA,KAAM;AAC3C,IAAA,MAAM,IAAA,GAAO,KAAA,EAAO,MAAA,GAAS,GAAG,CAAA;AAChC,IAAA,OAAO,IAAA,GAAO,CAAC,EAAE,GAAA,EAAK,MAAM,IAAA,EAAM,IAAI,EA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BACA,GAAA,CAAC,GAAA,EAAA,EACE,QAAA,EAAA,CAAA,CAAE,0BAAA,EAA4B;AAAA,YAC7B,YAAA,EAAc,SAAS,qEAAA,GAAiB;AAAA,WACzC,CAAA,EACH;AAAA,SAAA,EACF,CAAA,EAEJ,CAAA;AAAA,wBACA,GAAA,CAAC,QAAA,EAAA,EAAS,KAAA,EAAc,MAAA,EAAgB;AAAA,OAAA,EAC1C,CAAA;AAAA,sBACA,GAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,OAAA,EACb,QAAA,kBAAA,GAAA,CAAC,SAAI,GAAA,EAAK,SAAA,EAAW,GAAA,EAAI,EAAA,EAAG,CAAA,EAC9B;AAAA,KAAA,EACF,CAAA,EACF;AAAA,GAAA,EACF,CAAA;AAEJ","file":"chunk-CZ6VJPCG.js","sourcesContent":["import { getTwilightContext } from '../../twilight/context';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport type { Store, StoreSocial } from '../../types';\n\nconst THUMB_URL = 'https://cdn.assets.salla.network/prod/stores/images/construction-01.png';\nconst LAUNCHING_THUMB_URL =\n 'https://cdn.assets.salla.network/prod/stores/images/under-construction.png';\n\n/** Social networks the page links to, in the old page's order, with their Salla icon class. */\nconst SOCIAL_ICONS: [keyof StoreSocial, string][] = [\n ['twitter', 'sicon-x'],\n ['snapchat', 'sicon-snapchat'],\n ['youtube', 'sicon-youtube'],\n ['tiktok', 'sicon-tiktok'],\n ['facebook', 'sicon-facebook'],\n ['instagram', 'sicon-instagram'],\n];\n\n/** The store's social links the page shows, each with its icon class. */\nfunction socialLinks(store: Store | undefined) {\n return SOCIAL_ICONS.flatMap(([key, icon]) => {\n const href = store?.social?.[key];\n return href ? [{ key, icon, href }] : [];\n });\n}\n\n// The platform's maintenance page (Store `pages/maintenance.blade.php` + `_maintenance.scss`),\n// trimmed to what it renders: greyscale, logo + title beside the message, contacts under a\n// rule, the illustration alongside; stacked and centred under 1024px.\n//\n// The page is its own scroll container, the viewport tall, because app-shell themes lock\n// `html, body { overflow: hidden }` and scroll only their main element, which this page\n// replaces. Centring is by auto margins, not `justify-content`, so content taller than the\n// viewport starts at the top instead of being clipped at both ends.\nconst STYLE = `\n.s-maintenance{display:flex;flex-direction:column;align-items:center;width:100%;height:100vh;height:100dvh;overflow-y:auto;color:#a3a3a3;background:#fff;filter:grayscale(100%);box-sizing:border-box}\n.s-maintenance *{box-sizing:border-box}\n.s-maintenance .mt-container{width:100%;max-width:1200px;margin:auto 0;padding:0 15px}\n.s-maintenance .mt-panel{display:flex;flex-direction:row;align-items:center;justify-content:space-between;width:100%}\n.s-maintenance .mt-message{width:100%;padding-inline-start:80px;animation:revealMtBlock 1.5s forwards}\n.s-maintenance .mt-title{display:flex;align-items:center;margin:0 0 20px}\n.s-maintenance .mt-logo{display:block;flex-shrink:0;width:80px;height:80px;margin-inline-end:20px;border-radius:50%;overflow:hidden;box-shadow:0 0 5px rgb(0 0 0 / 10%)}\n.s-maintenance .mt-logo img{display:block;width:100%;height:100%;object-fit:cover}\n.s-maintenance .mt-title h1{font-size:2.25rem;line-height:1;margin:0;color:#666}\n.s-maintenance .mt-content p{margin:0;white-space:pre-line}\n.s-maintenance .mt-contact-list{display:inline-block;list-style:none;width:100%;max-width:500px;margin:20px 0 0;padding:20px 0 0;border-top:1px solid #eee}\n.s-maintenance .mt-contact-list li{display:inline-block;margin-inline-end:10px}\n.s-maintenance .mt-contact-list a{display:inline-flex;align-items:center;padding:5px;color:rgb(102 102 102 / 80%);text-decoration:none;font-size:1.25rem}\n.s-maintenance .mt-contact-list a:hover{color:#666}\n.s-maintenance .mt-contact--btn{padding:3px 20px 5px;border-radius:20px;color:#fff!important;background:rgb(102 102 102 / 80%);font-size:1rem!important}\n.s-maintenance .mt-contact--btn:hover{background:#666}\n.s-maintenance .mt-contact--btn i{margin-inline-end:10px}\n.s-maintenance .thumb{width:100%;animation:revealMtBlock 1.5s .1s forwards;opacity:0}\n.s-maintenance .thumb img{display:block;width:100%;max-width:450px;margin:0 auto}\n@media (max-width:1024px){\n.s-maintenance{padding:40px 0 10px}\n.s-maintenance .mt-panel{flex-direction:column}\n.s-maintenance .mt-message{order:2;text-align:center;padding:0;margin:50px 0 0}\n.s-maintenance .mt-title{flex-direction:column;margin-bottom:30px}\n.s-maintenance .mt-logo{margin:0 0 10px}\n.s-maintenance .mt-title h1{font-size:1.5rem}\n}\n@media (max-width:640px){.s-maintenance .thumb img{width:80%}}\n@keyframes revealMtBlock{from{opacity:0;transform:translateY(50%)}to{opacity:1;transform:translateY(0)}}\n`;\n\n/** The phone button and social links under the message; nothing when the store lists none. */\nfunction Contacts({ store, arabic }: { store: Store | undefined; arabic: boolean }) {\n const { t } = useTranslation();\n const mobile = store?.contacts?.mobile;\n const socials = socialLinks(store);\n if (!mobile && socials.length === 0) return null;\n\n return (\n <ul className=\"mt-contact-list\">\n {mobile && (\n <li>\n <a href={`tel:${mobile}`} className=\"mt-contact--btn\">\n <i className=\"sicon-phone\" aria-hidden=\"true\" />\n {t('common.elements.contact_us', {\n defaultValue: arabic ? 'تواصل معنا' : 'Contact us',\n })}\n </a>\n </li>\n )}\n {socials.map(({ key, icon, href }) => (\n <li key={key}>\n <a href={href} target=\"_blank\" rel=\"noreferrer\" aria-label={key}>\n <i className={icon} aria-hidden=\"true\" />\n </a>\n </li>\n ))}\n </ul>\n );\n}\n\n// The platform's page for a store that has not launched yet (Store\n// `pages/construction.blade.php` + the `construction` rules of `_maintenance.scss`): in\n// colour, logo over the illustration over the title, centred, contacts in a bar along the\n// bottom. Its own scroll container, as the maintenance page above is.\nconst LAUNCHING_STYLE = `\n.s-launching{display:flex;flex-direction:column;align-items:center;width:100%;height:100vh;height:100dvh;overflow-y:auto;color:#a3a3a3;background:#fff;text-align:center;box-sizing:border-box}\n.s-launching *{box-sizing:border-box}\n.s-launching .ls-panel{display:flex;flex-direction:column;align-items:center;width:100%;max-width:1200px;margin:auto 0;padding:40px 15px 100px;animation:revealMtBlock 1.5s forwards}\n.s-launching .ls-logo{display:block;max-width:70px;margin:0 0 60px}\n.s-launching .ls-thumb{display:block;width:100%;max-width:250px}\n.s-launching h1{font-size:3.125rem;line-height:1;margin:20px 0;color:#000}\n.s-launching .ls-content p{margin:0;white-space:pre-line}\n.s-launching .ls-footer{position:fixed;inset-inline:0;bottom:0;display:flex;align-items:center;justify-content:space-between;padding:0 25px;color:#000;background:#fbfbfb}\n.s-launching .ls-contacts{display:flex;align-items:center}\n.s-launching .ls-contacts h2{margin:1em 0;font-size:1rem;color:#7d7d7d}\n.s-launching .ls-contacts h2::after{content:\"|\";margin:0 10px;font-weight:700;color:#dbdbdb}\n.s-launching .ls-contacts ul{display:flex;list-style:none;margin:0;padding:0}\n.s-launching .ls-contacts li{padding:0 10px}\n.s-launching .ls-contacts a{display:inline-flex;align-items:center;gap:5px;color:#000;text-decoration:none}\n.s-launching .ls-footer-logo{display:block;max-width:30px}\n@media (max-width:1024px){.s-launching h1{font-size:1.5625rem}}\n@media (max-width:767px){.s-launching .ls-contacts a span{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}}\n@keyframes revealMtBlock{from{opacity:0;transform:translateY(50%)}to{opacity:1;transform:translateY(0)}}\n`;\n\n/** The bar along the bottom with the phone and social links; nothing when the store lists none. */\nfunction LaunchingContacts({ store, arabic }: { store: Store | undefined; arabic: boolean }) {\n const { t } = useTranslation();\n const mobile = store?.contacts?.mobile;\n const socials = socialLinks(store);\n if (!mobile && socials.length === 0) return null;\n\n return (\n <footer className=\"ls-footer\">\n <div className=\"ls-contacts\">\n <h2>\n {t('common.elements.contact_us', {\n defaultValue: arabic ? 'تواصل معنا' : 'Contact us',\n })}\n </h2>\n <ul>\n {mobile && (\n <li>\n <a href={`tel:${mobile}`}>\n <i className=\"sicon-phone\" aria-hidden=\"true\" />\n <span dir=\"ltr\">{mobile}</span>\n </a>\n </li>\n )}\n {socials.map(({ key, icon, href }) => (\n <li key={key}>\n <a href={href} target=\"_blank\" rel=\"noreferrer\" aria-label={key}>\n <i className={icon} aria-hidden=\"true\" />\n </a>\n </li>\n ))}\n </ul>\n </div>\n {store?.logo && <img className=\"ls-footer-logo\" src={store.logo} alt=\"\" />}\n </footer>\n );\n}\n\n/**\n * The page a customer sees while the store has not launched yet. Its wording is the\n * platform's own, not `maintenance_details`: for an unlaunched store that holds the\n * merchant's \"finish launching\" notice, addressed to the merchant.\n */\nfunction LaunchingSoon({ store, arabic }: { store: Store | undefined; arabic: boolean }) {\n const { t } = useTranslation();\n const logoAlt =\n store?.name ||\n t('common.elements.store_logo', { defaultValue: arabic ? 'شعار المتجر' : 'Store logo' });\n\n return (\n <div className=\"s-launching\" data-testid=\"store-launching-soon-page\">\n <style>{LAUNCHING_STYLE}</style>\n <section className=\"ls-panel\">\n {store?.logo && <img className=\"ls-logo\" src={store.logo} alt={logoAlt} />}\n <img className=\"ls-thumb\" src={LAUNCHING_THUMB_URL} alt=\"\" />\n <h1>\n {t('pages.launching_soon.title', {\n defaultValue: arabic ? 'ترقَّب إطلاق المتجر' : 'The store is launching soon',\n })}\n </h1>\n <div className=\"ls-content\">\n <p>\n {t('pages.launching_soon.message', {\n defaultValue: arabic\n ? 'نعمل على وضع اللمسات الأخيرة لنقدم لك تجربة تسوق متكاملة، قريبًا!'\n : \"We're putting the finishing touches on a complete shopping experience for you. Coming soon!\",\n })}\n </p>\n </div>\n </section>\n <LaunchingContacts store={store} arabic={arabic} />\n </div>\n );\n}\n\n/**\n * The page a customer sees while the store is closed: the platform's maintenance page,\n * fed by the settings' `maintenance_details` (the merchant's title and message) and the\n * store's contacts; or, while the store has not launched yet (`settings.launched` is\n * `false`), the platform's launching-soon page. Rendered by `TwilightProvider` in place\n * of the layout; see `rootBeforeLoad` for who sees it.\n */\nexport function MaintenancePage() {\n const { settings, locale } = getTwilightContext();\n const { t } = useTranslation();\n const store = settings.store;\n const details = settings.maintenance_details;\n const arabic = locale.startsWith('ar');\n\n if (settings.launched === false) return <LaunchingSoon store={store} arabic={arabic} />;\n\n const title =\n details?.title ||\n t('pages.maintenance.title', {\n defaultValue: arabic ? 'المتجر قيد الصيانة' : 'Store under maintenance',\n });\n\n return (\n <div className=\"s-maintenance\" data-testid=\"store-maintenance-page\">\n <style>{STYLE}</style>\n <div className=\"mt-container\">\n <section className=\"mt-panel\">\n <div className=\"mt-message\">\n <div className=\"mt-title\">\n {store?.logo && (\n <span className=\"mt-logo\">\n <img\n src={store.logo}\n alt={\n store.name ||\n t('common.elements.store_logo', {\n defaultValue: arabic ? 'شعار المتجر' : 'Store logo',\n })\n }\n />\n </span>\n )}\n <h1>{title}</h1>\n </div>\n <div className=\"mt-content\">\n {details?.message ? (\n // The merchant's own wording: a plain string the dashboard caps at 200 characters.\n <p>{details.message}</p>\n ) : (\n <>\n <p>\n {t('pages.maintenance.message', {\n defaultValue: arabic\n ? 'عذرا عزيزي العميل، المتجر حاليا قيد الصيانة و سنعاود العمل خلال فترة وجيزة'\n : 'Sorry, the store is under maintenance and will be back shortly.',\n })}\n </p>\n <p>\n {t('pages.maintenance.thanks', {\n defaultValue: arabic ? 'شكرا لتفهمكم' : 'Thank you for your understanding.',\n })}\n </p>\n </>\n )}\n </div>\n <Contacts store={store} arabic={arabic} />\n </div>\n <div className=\"thumb\">\n <img src={THUMB_URL} alt=\"\" />\n </div>\n </section>\n </div>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/store/MaintenancePage.tsx"],"names":[],"mappings":";;;;AAIA,IAAM,SAAA,GAAY,yEAAA;AAClB,IAAM,mBAAA,GACJ,4EAAA;AAGF,IAAM,YAAA,GAA8C;AAAA,EAClD,CAAC,WAAW,SAAS,CAAA;AAAA,EACrB,CAAC,YAAY,gBAAgB,CAAA;AAAA,EAC7B,CAAC,WAAW,eAAe,CAAA;AAAA,EAC3B,CAAC,UAAU,cAAc,CAAA;AAAA,EACzB,CAAC,YAAY,gBAAgB,CAAA;AAAA,EAC7B,CAAC,aAAa,iBAAiB;AACjC,CAAA;AAGA,SAAS,YAAY,KAA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AAG,QAAA,EAAA,OAAA,CAAQ,OAAA,EAAQ;AAAA,4BAEpB,IAAA,CAAA,QAAA,EAAA,EACE,QAAA,EAAA;AAAA,0BAAA,GAAA,CAAC,GAAA,EAAA,EACE,YAAE,2BAAA,EAA6B;AAAA,YAC9B,YAAA,EAAc,SACV,kYAAA,GACA;AAAA,WACL,CAAA,EACH,CAAA;AAAA,0BACA,GAAA,CAAC,GAAA,EAAA,EACE,QAAA,EAAA,CAAA,CAAE,0BAAA,EAA4B;AAAA,YAC7B,YAAA,EAAc,SAAS,qEAAA,GAAiB;AAAA,WACzC,CAAA,EACH;AAAA,SAAA,EACF,CAAA,EAEJ,CAAA;AAAA,wBACA,GAAA,CAAC,QAAA,EAAA,EAAS,KAAA,EAAc,MAAA,EAAgB;AAAA,OAAA,EAC1C,CAAA;AAAA,sBACA,GAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,OAAA,EACb,QAAA,kBAAA,GAAA,CAAC,SAAI,GAAA,EAAK,SAAA,EAAW,GAAA,EAAI,EAAA,EAAG,CAAA,EAC9B;AAAA,KAAA,EACF,CAAA,EACF;AAAA,GAAA,EACF,CAAA;AAEJ","file":"chunk-IDFWFDVF.js","sourcesContent":["import { getTwilightContext } from '../../twilight/context';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport type { Store, StoreSocial } from '../../types';\n\nconst THUMB_URL = 'https://cdn.assets.salla.network/prod/stores/images/construction-01.png';\nconst LAUNCHING_THUMB_URL =\n 'https://cdn.assets.salla.network/prod/stores/images/under-construction.png';\n\n/** Social networks the page links to, in the old page's order, with their Salla icon class. */\nconst SOCIAL_ICONS: [keyof StoreSocial, string][] = [\n ['twitter', 'sicon-x'],\n ['snapchat', 'sicon-snapchat'],\n ['youtube', 'sicon-youtube'],\n ['tiktok', 'sicon-tiktok'],\n ['facebook', 'sicon-facebook'],\n ['instagram', 'sicon-instagram'],\n];\n\n/** The store's social links the page shows, each with its icon class. */\nfunction socialLinks(store: Store | undefined) {\n return SOCIAL_ICONS.flatMap(([key, icon]) => {\n const href = store?.social?.[key];\n return href ? [{ key, icon, href }] : [];\n });\n}\n\n// The platform's maintenance page (Store `pages/maintenance.blade.php` + `_maintenance.scss`),\n// trimmed to what it renders: greyscale, logo + title beside the message, contacts under a\n// rule, the illustration alongside; stacked and centred under 1024px.\n//\n// The page is its own scroll container, the viewport tall, because app-shell themes lock\n// `html, body { overflow: hidden }` and scroll only their main element, which this page\n// replaces. Centring is by auto margins, not `justify-content`, so content taller than the\n// viewport starts at the top instead of being clipped at both ends.\nconst STYLE = `\n.s-maintenance{display:flex;flex-direction:column;align-items:center;width:100%;height:100vh;height:100dvh;overflow-y:auto;color:#a3a3a3;background:#fff;filter:grayscale(100%);box-sizing:border-box}\n.s-maintenance *{box-sizing:border-box}\n.s-maintenance .mt-container{width:100%;max-width:1200px;margin:auto 0;padding:0 15px}\n.s-maintenance .mt-panel{display:flex;flex-direction:row;align-items:center;justify-content:space-between;width:100%}\n.s-maintenance .mt-message{width:100%;padding-inline-start:80px;animation:revealMtBlock 1.5s forwards}\n.s-maintenance .mt-title{display:flex;align-items:center;margin:0 0 20px}\n.s-maintenance .mt-logo{display:block;flex-shrink:0;width:80px;height:80px;margin-inline-end:20px;border-radius:50%;overflow:hidden;box-shadow:0 0 5px rgb(0 0 0 / 10%)}\n.s-maintenance .mt-logo img{display:block;width:100%;height:100%;object-fit:cover}\n.s-maintenance .mt-title h1{font-size:2.25rem;line-height:1;margin:0;color:#666}\n.s-maintenance .mt-content p{margin:0;white-space:pre-line}\n.s-maintenance .mt-contact-list{display:inline-block;list-style:none;width:100%;max-width:500px;margin:20px 0 0;padding:20px 0 0;border-top:1px solid #eee}\n.s-maintenance .mt-contact-list li{display:inline-block;margin-inline-end:10px}\n.s-maintenance .mt-contact-list a{display:inline-flex;align-items:center;padding:5px;color:rgb(102 102 102 / 80%);text-decoration:none;font-size:1.25rem}\n.s-maintenance .mt-contact-list a:hover{color:#666}\n.s-maintenance .mt-contact--btn{padding:3px 20px 5px;border-radius:20px;color:#fff!important;background:rgb(102 102 102 / 80%);font-size:1rem!important}\n.s-maintenance .mt-contact--btn:hover{background:#666}\n.s-maintenance .mt-contact--btn i{margin-inline-end:10px}\n.s-maintenance .thumb{width:100%;animation:revealMtBlock 1.5s .1s forwards;opacity:0}\n.s-maintenance .thumb img{display:block;width:100%;max-width:450px;margin:0 auto}\n@media (max-width:1024px){\n.s-maintenance{padding:40px 0 10px}\n.s-maintenance .mt-panel{flex-direction:column}\n.s-maintenance .mt-message{order:2;text-align:center;padding:0;margin:50px 0 0}\n.s-maintenance .mt-title{flex-direction:column;margin-bottom:30px}\n.s-maintenance .mt-logo{margin:0 0 10px}\n.s-maintenance .mt-title h1{font-size:1.5rem}\n}\n@media (max-width:640px){.s-maintenance .thumb img{width:80%}}\n@keyframes revealMtBlock{from{opacity:0;transform:translateY(50%)}to{opacity:1;transform:translateY(0)}}\n`;\n\n/** The phone button and social links under the message; nothing when the store lists none. */\nfunction Contacts({ store, arabic }: { store: Store | undefined; arabic: boolean }) {\n const { t } = useTranslation();\n const mobile = store?.contacts?.mobile;\n const socials = socialLinks(store);\n if (!mobile && socials.length === 0) return null;\n\n return (\n <ul className=\"mt-contact-list\">\n {mobile && (\n <li>\n <a href={`tel:${mobile}`} className=\"mt-contact--btn\">\n <i className=\"sicon-phone\" aria-hidden=\"true\" />\n {t('common.elements.contact_us', {\n defaultValue: arabic ? 'تواصل معنا' : 'Contact us',\n })}\n </a>\n </li>\n )}\n {socials.map(({ key, icon, href }) => (\n <li key={key}>\n <a href={href} target=\"_blank\" rel=\"noreferrer\" aria-label={key}>\n <i className={icon} aria-hidden=\"true\" />\n </a>\n </li>\n ))}\n </ul>\n );\n}\n\n// The platform's page for a store that has not launched yet (Store\n// `pages/construction.blade.php` + the `construction` rules of `_maintenance.scss`): in\n// colour, logo over the illustration over the title, centred, contacts in a bar along the\n// bottom. Its own scroll container, as the maintenance page above is.\nconst LAUNCHING_STYLE = `\n.s-launching{display:flex;flex-direction:column;align-items:center;width:100%;height:100vh;height:100dvh;overflow-y:auto;color:#a3a3a3;background:#fff;text-align:center;box-sizing:border-box}\n.s-launching *{box-sizing:border-box}\n.s-launching .ls-panel{display:flex;flex-direction:column;align-items:center;width:100%;max-width:1200px;margin:auto 0;padding:40px 15px 100px;animation:revealMtBlock 1.5s forwards}\n.s-launching .ls-logo{display:block;max-width:70px;margin:0 0 60px}\n.s-launching .ls-thumb{display:block;width:100%;max-width:250px}\n.s-launching h1{font-size:3.125rem;line-height:1;margin:20px 0;color:#000}\n.s-launching .ls-content p{margin:0;white-space:pre-line}\n.s-launching .ls-footer{position:fixed;inset-inline:0;bottom:0;display:flex;align-items:center;justify-content:space-between;padding:0 25px;color:#000;background:#fbfbfb}\n.s-launching .ls-contacts{display:flex;align-items:center}\n.s-launching .ls-contacts h2{margin:1em 0;font-size:1rem;color:#7d7d7d}\n.s-launching .ls-contacts h2::after{content:\"|\";margin:0 10px;font-weight:700;color:#dbdbdb}\n.s-launching .ls-contacts ul{display:flex;list-style:none;margin:0;padding:0}\n.s-launching .ls-contacts li{padding:0 10px}\n.s-launching .ls-contacts a{display:inline-flex;align-items:center;gap:5px;color:#000;text-decoration:none}\n.s-launching .ls-footer-logo{display:block;max-width:30px}\n@media (max-width:1024px){.s-launching h1{font-size:1.5625rem}}\n@media (max-width:767px){.s-launching .ls-contacts a span{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}}\n@keyframes revealMtBlock{from{opacity:0;transform:translateY(50%)}to{opacity:1;transform:translateY(0)}}\n`;\n\n/** The bar along the bottom with the phone and social links; nothing when the store lists none. */\nfunction LaunchingContacts({ store, arabic }: { store: Store | undefined; arabic: boolean }) {\n const { t } = useTranslation();\n const mobile = store?.contacts?.mobile;\n const socials = socialLinks(store);\n if (!mobile && socials.length === 0) return null;\n\n return (\n <footer className=\"ls-footer\">\n <div className=\"ls-contacts\">\n <h2>\n {t('common.elements.contact_us', {\n defaultValue: arabic ? 'تواصل معنا' : 'Contact us',\n })}\n </h2>\n <ul>\n {mobile && (\n <li>\n <a href={`tel:${mobile}`}>\n <i className=\"sicon-phone\" aria-hidden=\"true\" />\n <span dir=\"ltr\">{mobile}</span>\n </a>\n </li>\n )}\n {socials.map(({ key, icon, href }) => (\n <li key={key}>\n <a href={href} target=\"_blank\" rel=\"noreferrer\" aria-label={key}>\n <i className={icon} aria-hidden=\"true\" />\n </a>\n </li>\n ))}\n </ul>\n </div>\n {store?.logo && <img className=\"ls-footer-logo\" src={store.logo} alt=\"\" />}\n </footer>\n );\n}\n\n/**\n * The page a customer sees while the store has not launched yet. Its wording is the\n * platform's own, not `maintenance_details`: for an unlaunched store that holds the\n * merchant's \"finish launching\" notice, addressed to the merchant.\n */\nfunction LaunchingSoon({ store, arabic }: { store: Store | undefined; arabic: boolean }) {\n const { t } = useTranslation();\n const logoAlt =\n store?.name ||\n t('common.elements.store_logo', { defaultValue: arabic ? 'شعار المتجر' : 'Store logo' });\n\n return (\n <div className=\"s-launching\" data-testid=\"store-launching-soon-page\">\n <style>{LAUNCHING_STYLE}</style>\n <section className=\"ls-panel\">\n {store?.logo && <img className=\"ls-logo\" src={store.logo} alt={logoAlt} />}\n <img className=\"ls-thumb\" src={LAUNCHING_THUMB_URL} alt=\"\" />\n <h1>\n {t('pages.launching_soon.title', {\n defaultValue: arabic ? 'ترقَّب إطلاق المتجر' : 'The store is launching soon',\n })}\n </h1>\n <div className=\"ls-content\">\n <p>\n {t('pages.launching_soon.message', {\n defaultValue: arabic\n ? 'نعمل على وضع اللمسات الأخيرة لنقدم لك تجربة تسوق متكاملة، قريبًا!'\n : \"We're putting the finishing touches on a complete shopping experience for you. Coming soon!\",\n })}\n </p>\n </div>\n </section>\n <LaunchingContacts store={store} arabic={arabic} />\n </div>\n );\n}\n\n/**\n * The page a customer sees while the store is closed: the platform's maintenance page,\n * fed by the settings' `maintenance_details` (the merchant's title and message) and the\n * store's contacts; or, while the store has not launched yet (`settings.launched` is\n * `false`), the platform's launching-soon page. Rendered by `TwilightProvider` in place\n * of the layout; see `rootBeforeLoad` for who sees it.\n */\nexport function MaintenancePage() {\n const { settings, locale } = getTwilightContext();\n const { t } = useTranslation();\n const store = settings.store;\n const details = settings.maintenance_details;\n const arabic = locale.startsWith('ar');\n\n if (settings.launched === false) return <LaunchingSoon store={store} arabic={arabic} />;\n\n const title =\n details?.title ||\n t('pages.maintenance.title', {\n defaultValue: arabic ? 'المتجر قيد الصيانة' : 'Store under maintenance',\n });\n\n return (\n <div className=\"s-maintenance\" data-testid=\"store-maintenance-page\">\n <style>{STYLE}</style>\n <div className=\"mt-container\">\n <section className=\"mt-panel\">\n <div className=\"mt-message\">\n <div className=\"mt-title\">\n {store?.logo && (\n <span className=\"mt-logo\">\n <img\n src={store.logo}\n alt={\n store.name ||\n t('common.elements.store_logo', {\n defaultValue: arabic ? 'شعار المتجر' : 'Store logo',\n })\n }\n />\n </span>\n )}\n <h1>{title}</h1>\n </div>\n <div className=\"mt-content\">\n {details?.message ? (\n // The merchant's own wording: a plain string the dashboard caps at 200 characters.\n <p>{details.message}</p>\n ) : (\n <>\n <p>\n {t('pages.maintenance.message', {\n defaultValue: arabic\n ? 'عذرا عزيزي العميل، المتجر حاليا قيد الصيانة و سنعاود العمل خلال فترة وجيزة'\n : 'Sorry, the store is under maintenance and will be back shortly.',\n })}\n </p>\n <p>\n {t('pages.maintenance.thanks', {\n defaultValue: arabic ? 'شكرا لتفهمكم' : 'Thank you for your understanding.',\n })}\n </p>\n </>\n )}\n </div>\n <Contacts store={store} arabic={arabic} />\n </div>\n <div className=\"thumb\">\n <img src={THUMB_URL} alt=\"\" />\n </div>\n </section>\n </div>\n </div>\n );\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { escapeForInlineScript } from './chunk-
|
|
1
|
+
import { escapeForInlineScript } from './chunk-PQR776WF.js';
|
|
2
2
|
|
|
3
3
|
// src/utils/app-scope.ts
|
|
4
4
|
var isBrowser = typeof window !== "undefined";
|
|
@@ -132,5 +132,5 @@ function renderThemeHookSlotsScript(names = getRegisteredThemeHookSlots()) {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
export { applyAppScopeMocks, applyThemeHookSlots, installAppScope, registerThemeHookSlots, renderAppScopeInstallScript, renderThemeHookSlotsScript };
|
|
135
|
-
//# sourceMappingURL=chunk-
|
|
136
|
-
//# sourceMappingURL=chunk-
|
|
135
|
+
//# sourceMappingURL=chunk-IPW4JC7Z.js.map
|
|
136
|
+
//# sourceMappingURL=chunk-IPW4JC7Z.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/app-scope.ts","../src/utils/theme-hook-slots.ts"],"names":[],"mappings":";;;AAGA,IAAM,SAAA,GAAY,OAAO,MAAA,KAAW,WAAA;AA2B7B,IAAM,qBAAA,GAAgD,CAAC,CAAA,EAAG,MAAA,KAAW;AAC1E,EAAA,MAAM,QAAA,GAAW,CAAC,GAAA,KAChB,OAAO,QAAQ,QAAA,IAAY,GAAA,CAAI,OAAA,CAAQ,MAAM,CAAA,KAAM,CAAA;AACrD,EAAA,MAAM,SAAA,GAAY,CAAC,GAAA,KAAwB,GAAA,CAAI,MAAM,CAAC,CAAA;AACtD,EAAA,MAAM,YAAY,MAA+B,CAAA,CAAE,KAAA,IAAS,CAAA,CAAE,SAAS,EAAC;AACxE,EAAA,MAAM,UAAA,GAAa,MAChB,SAAA,EAAU,CAAE,UAAsC,EAAC;AACtD,EAAA,MAAM,WAAA,GAAc,CAAC,GAAA,EAA8B,IAAA,KAAmC;AACpF,IAAA,MAAM,MAAA,GAAS,IAAI,IAAc,CAAA;AACjC,IAAA,OAAO,OAAO,MAAA,KAAW,UAAA,GAAa,MAAA,CAAO,IAAA,CAAK,GAAG,CAAA,GAAI,MAAA;AAAA,EAC3D,CAAA;AAEA,EAAA,MAAM,cAAA,GAAiB,CAAC,OAAA,KAA8B;AACpD,IAAA,MAAM,MAAA,GAAS,MAAqB,MA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;AAC1C,EAAA,IAAI,OAAO,MAAA,KAAW,WAAA,IAAe,UAAA,CAAW,SAAS,CAAA,EAAG;AAC5D,EAAA,IAAI,SAAA,MAAe,UAAA,EAAY;AAE/B,EAAA,UAAA,GAAa,IAAA;AACb,EAAA,MAAA,CAAO,gBAAA,CAAiB,uBAAuB,MAAM,KAAK,WAAU,EAAG,EAAE,IAAA,EAAM,IAAA,EAAM,CAAA;AACvF;AAGO,SAAS,2BAAA,GAAwC;AACtD,EAAA,OAAO,CAAC,GAAG,UAAU,CAAA;AACvB;AAeO,SAAS,0BAAA,CAA2B,KAAA,GAAkB,2BAAA,EAA4B,EAAG;AAC1F,EAAA,IAAI,CAAC,KAAA,CAAM,MAAA,EAAQ,OAAO,IAAA;AAC1B,EAAA,MAAM,IAAA,GAAO,qBAAA,CAAsB,IAAA,CAAK,SAAA,CAAU,KAAK,CAAC,CAAA;AACxD,EAAA,OACE,wUASM,IAAI,CAAA,EAAA,CAAA;AAEd","file":"chunk-SY7ESZ44.js","sourcesContent":["import type { SallaSDK } from '../types/salla-sdk';\nimport { escapeForInlineScript } from './inline-script';\n\nconst isBrowser = typeof window !== 'undefined';\n\n/** One app's private `app.*` bag, keyed without the `app.` prefix (`app.color` → `color`). */\nexport type AppConfigBag = Record<string, unknown>;\n\n/** One public `app.*` bucket per app, keyed by appScopeId. Everything else is read from the\n * real `salla.config` at runtime. */\nexport interface AppScopeContexts {\n apps: Record<string, AppConfigBag>;\n}\n\n/** Builds the `scopeId → sandboxed SDK` factory over a live bucket bag. */\nexport type AppScopeFactoryBuilder = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n w: any,\n appCtx: Record<string, AppConfigBag>\n) => (scopeId: string) => SallaSDK;\n\n/**\n * The sandbox itself: proxies that resolve `app.*` against the app's own bucket and pass\n * everything else through to the real SDK.\n *\n * MUST stay self-contained (only `Object`/`Proxy` and its two arguments): it is serialized via\n * `.toString()` next to {@link appScopeBootstrap} and handed in as an argument, so anything it\n * closed over at module scope would be undefined in the inline head copy. Split out from the\n * bootstrap purely to keep both halves reviewable.\n */\nexport const createAppScopeFactory: AppScopeFactoryBuilder = (w, appCtx) => {\n const isAppKey = (key: unknown): key is string =>\n typeof key === 'string' && key.indexOf('app.') === 0;\n const bucketKey = (key: string): string => key.slice(4);\n const realSalla = (): Record<string, unknown> => w.salla || w.Salla || {};\n const realConfig = (): Record<string, unknown> =>\n (realSalla().config as Record<string, unknown>) || {};\n const passthrough = (obj: Record<string, unknown>, prop: string | symbol): unknown => {\n const member = obj[prop as string];\n return typeof member === 'function' ? member.bind(obj) : member;\n };\n\n const createAppScope = (scopeId: string): SallaSDK => {\n const bucket = (): AppConfigBag => (appCtx[scopeId] = appCtx[scopeId] || {});\n\n const getConfig = (key: string, fallback?: unknown): unknown => {\n if (isAppKey(key)) {\n const sub = bucketKey(key);\n const b = bucket();\n // `app.*` miss returns the caller default, never the real config — a missing app\n // setting must not resolve to a same-named global.\n return sub in b ? b[sub] : fallback;\n }\n const cfg = realConfig();\n return typeof cfg.get === 'function'\n ? (cfg.get as (k: string, d?: unknown) => unknown)(key, fallback)\n : fallback;\n };\n\n const setConfig = (key: string, value: unknown): unknown => {\n if (isAppKey(key)) {\n bucket()[bucketKey(key)] = value;\n return value;\n }\n const cfg = realConfig();\n return typeof cfg.set === 'function'\n ? (cfg.set as (k: string, v: unknown) => unknown)(key, value)\n : value;\n };\n\n const hasConfig = (key: string): boolean =>\n isAppKey(key) ? bucketKey(key) in bucket() : key in realConfig();\n\n const configProxy = new Proxy({} as Record<string, unknown>, {\n get(_t, prop) {\n if (prop === 'get') return getConfig;\n if (prop === 'set') return setConfig;\n if (prop === 'has') return hasConfig;\n if (isAppKey(prop)) return getConfig(prop);\n return passthrough(realConfig(), prop);\n },\n set(_t, prop, value) {\n setConfig(prop as string, value);\n return true;\n },\n has(_t, prop) {\n return hasConfig(prop as string);\n },\n });\n\n return new Proxy({} as Record<string, unknown>, {\n get(_t, prop) {\n return prop === 'config' ? configProxy : passthrough(realSalla(), prop);\n },\n set(_t, prop, value) {\n // Reassigning `salla.config` wholesale would escape the sandbox; swallow it.\n if (prop === 'config') return true;\n realSalla()[prop as string] = value;\n return true;\n },\n }) as unknown as SallaSDK;\n };\n\n return createAppScope;\n};\n\n/**\n * Installs `window.Salla.appScope`, seeded with `contexts` and sandboxed by `makeFactory`.\n *\n * MUST stay self-contained (only `window`/`Object` and its arguments): it's serialized via\n * `.toString()` and inlined into the SSR head so the factory exists at parse time — before the\n * SDK init/hydration a CDN snippet's `onReady` races, else it throws `Salla.appScope is not a\n * function`. `makeFactory` is passed in rather than imported for exactly that reason. Also\n * called directly by `installAppScope` (tests/fallback).\n *\n * Idempotent: the factory is first-write-wins, while buckets are merged per scope (also\n * first-write-wins) so a later call can seed scopes the first one had no data for. `appCtx` is\n * closure-private (namespacing, not security: buckets are public-only and the boundary is\n * server-side).\n */\nexport function appScopeBootstrap(\n contexts: AppScopeContexts,\n makeFactory: AppScopeFactoryBuilder\n): void {\n if (typeof window === 'undefined') return;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const w = window as any;\n const Salla = (w.Salla = w.Salla || {});\n if (Salla.appScope) {\n // Already installed (normally by the inline head copy). The factory is first-write-wins,\n // but buckets are not: the head may have installed with none of them — the settings\n // endpoint can fail or lag behind the snippets one — so hand them to the existing install.\n if (Salla.__appScopeSeed) Salla.__appScopeSeed(contexts);\n return;\n }\n\n // Live bag + pristine snapshot (for mock overlays). Copy, don't alias: a snippet may\n // `config.set('app.x')` and the payload can be a cached response.\n const appCtx: Record<string, AppConfigBag> = {};\n const base: Record<string, AppConfigBag> = {};\n // Which scopes already got their real bucket, so a later seed can't overwrite one.\n const seeded: Record<string, boolean> = {};\n const seed = (next: AppScopeContexts): void => {\n const bags = (next && next.apps) || {};\n Object.keys(bags).forEach((scopeId) => {\n if (seeded[scopeId]) return;\n seeded[scopeId] = true;\n appCtx[scopeId] = Object.assign({}, appCtx[scopeId] || {}, bags[scopeId] || {});\n base[scopeId] = Object.assign({}, appCtx[scopeId]);\n });\n };\n seed(contexts);\n\n const createAppScope = makeFactory(w, appCtx);\n Salla.appScope = (scopeId: string): SallaSDK => createAppScope(scopeId);\n\n // Fill in buckets for scopes not seeded yet (first-write-wins per scope). Lets the head\n // install the factory unconditionally — at parse time, before any snippet's onReady — and\n // still pick up buckets that only the client managed to fetch.\n Salla.__appScopeSeed = (next: AppScopeContexts): void => seed(next);\n\n // Overlay preview mocks onto an app's pristine baseline, so fields the partner did not mock\n // keep their real values. Returns false for an unknown scope or before install.\n Salla.__appScopeMock = (scopeId: string, mocks: AppConfigBag): boolean => {\n if (!(scopeId in base)) return false;\n appCtx[scopeId] = Object.assign({}, base[scopeId], mocks);\n return true;\n };\n}\n\n/** Overlay preview mocks onto one app's bucket (over its pristine values). Delegates to the\n * bootstrap's `__appScopeMock`, so it works for both install paths. False if unknown/uninstalled. */\nexport function applyAppScopeMocks(appScopeId: string, mocks: AppConfigBag): boolean {\n if (!isBrowser) return false;\n const mock = (window.Salla as unknown as { __appScopeMock?: MockApplier } | undefined)\n ?.__appScopeMock;\n return mock?.(appScopeId, mocks) ?? false;\n}\n\ntype MockApplier = (appScopeId: string, mocks: AppConfigBag) => boolean;\n\n/** Serialize the installer into an inline `<script>` body seeded with `contexts` — both halves\n * via `.toString()`, hence their self-contained requirement. See `rootHead`. */\nexport function renderAppScopeInstallScript(contexts: AppScopeContexts): string {\n // Bucket values are partner-set, so escape the JSON seed against a `</script>` breakout.\n // The function sources have no `<`, so they need no escaping.\n const json = escapeForInlineScript(JSON.stringify(contexts));\n return `(${appScopeBootstrap.toString()})(${json},${createAppScopeFactory.toString()});`;\n}\n\n/** Install `Salla.appScope` on the client, or seed buckets into the inline SSR head copy that\n * already installed it. No-op on the server. Fallback for unseeded loads + the unit-test entry\n * point. */\nexport function installAppScope(contexts: AppScopeContexts): void {\n if (!isBrowser) return;\n appScopeBootstrap(contexts, createAppScopeFactory);\n}\n","import { escapeForInlineScript } from './inline-script';\n\nconst registered = new Set<string>();\n\nlet retryArmed = false;\n\n/**\n * Declare hook slots the theme renders itself so apps may mount into them.\n *\n * The SDK rejects `mount()` for any name absent from its `_themeSlots` whitelist, so a theme\n * rendering its own `<salla-hook>` must register the name. Call at module scope; the engine\n * applies the names via {@link applyThemeHookSlots}.\n */\nexport function registerThemeHookSlots(...names: string[]): void {\n for (const name of names) registered.add(name);\n}\n\n/** Push the registered names in. Returns false if the SDK hasn't exposed the list yet. */\nfunction pushSlots(): boolean {\n const slots = window.salla?.hooks?._themeSlots;\n if (!Array.isArray(slots)) return false;\n for (const name of registered) if (!slots.includes(name)) slots.push(name);\n return true;\n}\n\n/**\n * Push every registered slot name into the SDK whitelist. Idempotent. Engine-only.\n *\n * The SDK's hooks module may attach after this runs, so a first no-op falls back to a\n * one-shot retry on `twilight::initiated` — still before apps mount from their own onReady.\n *\n * This is only the late backstop: the whitelist is primarily seeded at parse time by the\n * inline head script from {@link renderThemeHookSlotsScript}, because an app's snippet\n * registers its `onReady` callback before React ever hydrates.\n */\nexport function applyThemeHookSlots(): void {\n if (typeof window === 'undefined' || registered.size === 0) return;\n if (pushSlots() || retryArmed) return;\n\n retryArmed = true;\n window.addEventListener('twilight::initiated', () => void pushSlots(), { once: true });\n}\n\n/** The slot names registered so far. Read by `rootHead` when rendering the inline script. */\nexport function getRegisteredThemeHookSlots(): string[] {\n return [...registered];\n}\n\n/**\n * Serialize the whitelist push into an inline head `<script>` body, so the slots are\n * registered at parse time.\n *\n * Ordering is the whole point: CDN snippets are parser-inserted `<script defer>` tags in the\n * body, so an app's `Salla.onReady` callback is registered long before React hydrates and runs\n * {@link applyThemeHookSlots}. Whichever `twilight::initiated` listener was added first runs\n * first, so the push must be armed from the head — otherwise the SDK rejects the app's\n * `hooks.mount()` with \"Hook <name> is not allowed\" and the app never renders.\n *\n * Returns null when the theme registered no slots. Kept self-contained (only `window`) since\n * it ships as raw source, not as a bundled module.\n */\nexport function renderThemeHookSlotsScript(names: string[] = getRegisteredThemeHookSlots()) {\n if (!names.length) return null;\n const json = escapeForInlineScript(JSON.stringify(names));\n return (\n `(function(names){` +\n `var w=window;` +\n `function push(){` +\n `var h=w.salla&&w.salla.hooks;var slots=h&&h._themeSlots;` +\n `if(!Array.isArray(slots))return false;` +\n `for(var i=0;i<names.length;i++)if(slots.indexOf(names[i])<0)slots.push(names[i]);` +\n `return true}` +\n `if(push())return;` +\n `w.addEventListener('twilight::initiated',function(){push()},{once:true})` +\n `})(${json});`\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/app-scope.ts","../src/utils/theme-hook-slots.ts"],"names":[],"mappings":";;;AAGA,IAAM,SAAA,GAAY,OAAO,MAAA,KAAW,WAAA;AA2B7B,IAAM,qBAAA,GAAgD,CAAC,CAAA,EAAG,MAAA,KAAW;AAC1E,EAAA,MAAM,QAAA,GAAW,CAAC,GAAA,KAChB,OAAO,QAAQ,QAAA,IAAY,GAAA,CAAI,OAAA,CAAQ,MAAM,CAAA,KAAM,CAAA;AACrD,EAAA,MAAM,SAAA,GAAY,CAAC,GAAA,KAAwB,GAAA,CAAI,MAAM,CAAC,CAAA;AACtD,EAAA,MAAM,YAAY,MAA+B,CAAA,CAAE,KAAA,IAAS,CAAA,CAAE,SAAS,EAAC;AACxE,EAAA,MAAM,UAAA,GAAa,MAChB,SAAA,EAAU,CAAE,UAAsC,EAAC;AACtD,EAAA,MAAM,WAAA,GAAc,CAAC,GAAA,EAA8B,IAAA,KAAmC;AACpF,IAAA,MAAM,MAAA,GAAS,IAAI,IAAc,CAAA;AACjC,IAAA,OAAO,OAAO,MAAA,KAAW,UAAA,GAAa,MAAA,CAAO,IAAA,CAAK,GAAG,CAAA,GAAI,MAAA;AAAA,EAC3D,CAAA;AAEA,EAAA,MAAM,cAAA,GAAiB,CAAC,OAAA,KAA8B;AACpD,IAAA,MAAM,MAAA,GAAS,MAAqB,MAAA,CAAO,OAAO,IAAI,MAAA,CAAO,OAAO,KAAK,EAAC;AAE1E,IAAA,MAAM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AAA,EAAG;AAC5D,EAAA,IAAI,SAAA,MAAe,UAAA,EAAY;AAE/B,EAAA,UAAA,GAAa,IAAA;AACb,EAAA,MAAA,CAAO,gBAAA,CAAiB,uBAAuB,MAAM,KAAK,WAAU,EAAG,EAAE,IAAA,EAAM,IAAA,EAAM,CAAA;AACvF;AAGO,SAAS,2BAAA,GAAwC;AACtD,EAAA,OAAO,CAAC,GAAG,UAAU,CAAA;AACvB;AAeO,SAAS,0BAAA,CAA2B,KAAA,GAAkB,2BAAA,EAA4B,EAAG;AAC1F,EAAA,IAAI,CAAC,KAAA,CAAM,MAAA,EAAQ,OAAO,IAAA;AAC1B,EAAA,MAAM,IAAA,GAAO,qBAAA,CAAsB,IAAA,CAAK,SAAA,CAAU,KAAK,CAAC,CAAA;AACxD,EAAA,OACE,wUASM,IAAI,CAAA,EAAA,CAAA;AAEd","file":"chunk-IPW4JC7Z.js","sourcesContent":["import type { SallaSDK } from '../types/salla-sdk';\nimport { escapeForInlineScript } from './inline-script';\n\nconst isBrowser = typeof window !== 'undefined';\n\n/** One app's private `app.*` bag, keyed without the `app.` prefix (`app.color` → `color`). */\nexport type AppConfigBag = Record<string, unknown>;\n\n/** One public `app.*` bucket per app, keyed by appScopeId. Everything else is read from the\n * real `salla.config` at runtime. */\nexport interface AppScopeContexts {\n apps: Record<string, AppConfigBag>;\n}\n\n/** Builds the `scopeId → sandboxed SDK` factory over a live bucket bag. */\nexport type AppScopeFactoryBuilder = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n w: any,\n appCtx: Record<string, AppConfigBag>\n) => (scopeId: string) => SallaSDK;\n\n/**\n * The sandbox itself: proxies that resolve `app.*` against the app's own bucket and pass\n * everything else through to the real SDK.\n *\n * MUST stay self-contained (only `Object`/`Proxy` and its two arguments): it is serialized via\n * `.toString()` next to {@link appScopeBootstrap} and handed in as an argument, so anything it\n * closed over at module scope would be undefined in the inline head copy. Split out from the\n * bootstrap purely to keep both halves reviewable.\n */\nexport const createAppScopeFactory: AppScopeFactoryBuilder = (w, appCtx) => {\n const isAppKey = (key: unknown): key is string =>\n typeof key === 'string' && key.indexOf('app.') === 0;\n const bucketKey = (key: string): string => key.slice(4);\n const realSalla = (): Record<string, unknown> => w.salla || w.Salla || {};\n const realConfig = (): Record<string, unknown> =>\n (realSalla().config as Record<string, unknown>) || {};\n const passthrough = (obj: Record<string, unknown>, prop: string | symbol): unknown => {\n const member = obj[prop as string];\n return typeof member === 'function' ? member.bind(obj) : member;\n };\n\n const createAppScope = (scopeId: string): SallaSDK => {\n const bucket = (): AppConfigBag => (appCtx[scopeId] = appCtx[scopeId] || {});\n\n const getConfig = (key: string, fallback?: unknown): unknown => {\n if (isAppKey(key)) {\n const sub = bucketKey(key);\n const b = bucket();\n // `app.*` miss returns the caller default, never the real config — a missing app\n // setting must not resolve to a same-named global.\n return sub in b ? b[sub] : fallback;\n }\n const cfg = realConfig();\n return typeof cfg.get === 'function'\n ? (cfg.get as (k: string, d?: unknown) => unknown)(key, fallback)\n : fallback;\n };\n\n const setConfig = (key: string, value: unknown): unknown => {\n if (isAppKey(key)) {\n bucket()[bucketKey(key)] = value;\n return value;\n }\n const cfg = realConfig();\n return typeof cfg.set === 'function'\n ? (cfg.set as (k: string, v: unknown) => unknown)(key, value)\n : value;\n };\n\n const hasConfig = (key: string): boolean =>\n isAppKey(key) ? bucketKey(key) in bucket() : key in realConfig();\n\n const configProxy = new Proxy({} as Record<string, unknown>, {\n get(_t, prop) {\n if (prop === 'get') return getConfig;\n if (prop === 'set') return setConfig;\n if (prop === 'has') return hasConfig;\n if (isAppKey(prop)) return getConfig(prop);\n return passthrough(realConfig(), prop);\n },\n set(_t, prop, value) {\n setConfig(prop as string, value);\n return true;\n },\n has(_t, prop) {\n return hasConfig(prop as string);\n },\n });\n\n return new Proxy({} as Record<string, unknown>, {\n get(_t, prop) {\n return prop === 'config' ? configProxy : passthrough(realSalla(), prop);\n },\n set(_t, prop, value) {\n // Reassigning `salla.config` wholesale would escape the sandbox; swallow it.\n if (prop === 'config') return true;\n realSalla()[prop as string] = value;\n return true;\n },\n }) as unknown as SallaSDK;\n };\n\n return createAppScope;\n};\n\n/**\n * Installs `window.Salla.appScope`, seeded with `contexts` and sandboxed by `makeFactory`.\n *\n * MUST stay self-contained (only `window`/`Object` and its arguments): it's serialized via\n * `.toString()` and inlined into the SSR head so the factory exists at parse time — before the\n * SDK init/hydration a CDN snippet's `onReady` races, else it throws `Salla.appScope is not a\n * function`. `makeFactory` is passed in rather than imported for exactly that reason. Also\n * called directly by `installAppScope` (tests/fallback).\n *\n * Idempotent: the factory is first-write-wins, while buckets are merged per scope (also\n * first-write-wins) so a later call can seed scopes the first one had no data for. `appCtx` is\n * closure-private (namespacing, not security: buckets are public-only and the boundary is\n * server-side).\n */\nexport function appScopeBootstrap(\n contexts: AppScopeContexts,\n makeFactory: AppScopeFactoryBuilder\n): void {\n if (typeof window === 'undefined') return;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const w = window as any;\n const Salla = (w.Salla = w.Salla || {});\n if (Salla.appScope) {\n // Already installed (normally by the inline head copy). The factory is first-write-wins,\n // but buckets are not: the head may have installed with none of them — the settings\n // endpoint can fail or lag behind the snippets one — so hand them to the existing install.\n if (Salla.__appScopeSeed) Salla.__appScopeSeed(contexts);\n return;\n }\n\n // Live bag + pristine snapshot (for mock overlays). Copy, don't alias: a snippet may\n // `config.set('app.x')` and the payload can be a cached response.\n const appCtx: Record<string, AppConfigBag> = {};\n const base: Record<string, AppConfigBag> = {};\n // Which scopes already got their real bucket, so a later seed can't overwrite one.\n const seeded: Record<string, boolean> = {};\n const seed = (next: AppScopeContexts): void => {\n const bags = (next && next.apps) || {};\n Object.keys(bags).forEach((scopeId) => {\n if (seeded[scopeId]) return;\n seeded[scopeId] = true;\n appCtx[scopeId] = Object.assign({}, appCtx[scopeId] || {}, bags[scopeId] || {});\n base[scopeId] = Object.assign({}, appCtx[scopeId]);\n });\n };\n seed(contexts);\n\n const createAppScope = makeFactory(w, appCtx);\n Salla.appScope = (scopeId: string): SallaSDK => createAppScope(scopeId);\n\n // Fill in buckets for scopes not seeded yet (first-write-wins per scope). Lets the head\n // install the factory unconditionally — at parse time, before any snippet's onReady — and\n // still pick up buckets that only the client managed to fetch.\n Salla.__appScopeSeed = (next: AppScopeContexts): void => seed(next);\n\n // Overlay preview mocks onto an app's pristine baseline, so fields the partner did not mock\n // keep their real values. Returns false for an unknown scope or before install.\n Salla.__appScopeMock = (scopeId: string, mocks: AppConfigBag): boolean => {\n if (!(scopeId in base)) return false;\n appCtx[scopeId] = Object.assign({}, base[scopeId], mocks);\n return true;\n };\n}\n\n/** Overlay preview mocks onto one app's bucket (over its pristine values). Delegates to the\n * bootstrap's `__appScopeMock`, so it works for both install paths. False if unknown/uninstalled. */\nexport function applyAppScopeMocks(appScopeId: string, mocks: AppConfigBag): boolean {\n if (!isBrowser) return false;\n const mock = (window.Salla as unknown as { __appScopeMock?: MockApplier } | undefined)\n ?.__appScopeMock;\n return mock?.(appScopeId, mocks) ?? false;\n}\n\ntype MockApplier = (appScopeId: string, mocks: AppConfigBag) => boolean;\n\n/** Serialize the installer into an inline `<script>` body seeded with `contexts` — both halves\n * via `.toString()`, hence their self-contained requirement. See `rootHead`. */\nexport function renderAppScopeInstallScript(contexts: AppScopeContexts): string {\n // Bucket values are partner-set, so escape the JSON seed against a `</script>` breakout.\n // The function sources have no `<`, so they need no escaping.\n const json = escapeForInlineScript(JSON.stringify(contexts));\n return `(${appScopeBootstrap.toString()})(${json},${createAppScopeFactory.toString()});`;\n}\n\n/** Install `Salla.appScope` on the client, or seed buckets into the inline SSR head copy that\n * already installed it. No-op on the server. Fallback for unseeded loads + the unit-test entry\n * point. */\nexport function installAppScope(contexts: AppScopeContexts): void {\n if (!isBrowser) return;\n appScopeBootstrap(contexts, createAppScopeFactory);\n}\n","import { escapeForInlineScript } from './inline-script';\n\nconst registered = new Set<string>();\n\nlet retryArmed = false;\n\n/**\n * Declare hook slots the theme renders itself so apps may mount into them.\n *\n * The SDK rejects `mount()` for any name absent from its `_themeSlots` whitelist, so a theme\n * rendering its own `<salla-hook>` must register the name. Call at module scope; the engine\n * applies the names via {@link applyThemeHookSlots}.\n */\nexport function registerThemeHookSlots(...names: string[]): void {\n for (const name of names) registered.add(name);\n}\n\n/** Push the registered names in. Returns false if the SDK hasn't exposed the list yet. */\nfunction pushSlots(): boolean {\n const slots = window.salla?.hooks?._themeSlots;\n if (!Array.isArray(slots)) return false;\n for (const name of registered) if (!slots.includes(name)) slots.push(name);\n return true;\n}\n\n/**\n * Push every registered slot name into the SDK whitelist. Idempotent. Engine-only.\n *\n * The SDK's hooks module may attach after this runs, so a first no-op falls back to a\n * one-shot retry on `twilight::initiated` — still before apps mount from their own onReady.\n *\n * This is only the late backstop: the whitelist is primarily seeded at parse time by the\n * inline head script from {@link renderThemeHookSlotsScript}, because an app's snippet\n * registers its `onReady` callback before React ever hydrates.\n */\nexport function applyThemeHookSlots(): void {\n if (typeof window === 'undefined' || registered.size === 0) return;\n if (pushSlots() || retryArmed) return;\n\n retryArmed = true;\n window.addEventListener('twilight::initiated', () => void pushSlots(), { once: true });\n}\n\n/** The slot names registered so far. Read by `rootHead` when rendering the inline script. */\nexport function getRegisteredThemeHookSlots(): string[] {\n return [...registered];\n}\n\n/**\n * Serialize the whitelist push into an inline head `<script>` body, so the slots are\n * registered at parse time.\n *\n * Ordering is the whole point: CDN snippets are parser-inserted `<script defer>` tags in the\n * body, so an app's `Salla.onReady` callback is registered long before React hydrates and runs\n * {@link applyThemeHookSlots}. Whichever `twilight::initiated` listener was added first runs\n * first, so the push must be armed from the head — otherwise the SDK rejects the app's\n * `hooks.mount()` with \"Hook <name> is not allowed\" and the app never renders.\n *\n * Returns null when the theme registered no slots. Kept self-contained (only `window`) since\n * it ships as raw source, not as a bundled module.\n */\nexport function renderThemeHookSlotsScript(names: string[] = getRegisteredThemeHookSlots()) {\n if (!names.length) return null;\n const json = escapeForInlineScript(JSON.stringify(names));\n return (\n `(function(names){` +\n `var w=window;` +\n `function push(){` +\n `var h=w.salla&&w.salla.hooks;var slots=h&&h._themeSlots;` +\n `if(!Array.isArray(slots))return false;` +\n `for(var i=0;i<names.length;i++)if(slots.indexOf(names[i])<0)slots.push(names[i]);` +\n `return true}` +\n `if(push())return;` +\n `w.addEventListener('twilight::initiated',function(){push()},{once:true})` +\n `})(${json});`\n );\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { customUrlRedirect } from './chunk-
|
|
1
|
+
import { customUrlRedirect } from './chunk-T3NWHBEO.js';
|
|
2
2
|
import { PRODUCT_SLUG_ROUTE_ID } from './chunk-NV4PF3O3.js';
|
|
3
|
-
import { product } from './chunk-
|
|
3
|
+
import { product } from './chunk-YKWH7W75.js';
|
|
4
4
|
import { productKeyOfId, publicProductKeyPath } from './chunk-SDBR4X3K.js';
|
|
5
|
-
import { notFound, orThrow, isMissingResource } from './chunk-
|
|
5
|
+
import { notFound, orThrow, isMissingResource } from './chunk-ODMEJVTL.js';
|
|
6
6
|
|
|
7
7
|
// src/routes/product/id.ts
|
|
8
8
|
var PRODUCT_ID = /^\d{1,18}$/;
|
|
@@ -42,5 +42,5 @@ async function resolveProductKeyPage(page, queryClient, address) {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
export { isProductId, productOfKey, resolveProductKeyPage };
|
|
45
|
-
//# sourceMappingURL=chunk-
|
|
46
|
-
//# sourceMappingURL=chunk-
|
|
45
|
+
//# sourceMappingURL=chunk-JS2UUQ5B.js.map
|
|
46
|
+
//# sourceMappingURL=chunk-JS2UUQ5B.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/routes/product/id.ts","../src/routes/product/key.ts"],"names":[],"mappings":";;;;;;;AAWA,IAAM,UAAA,GAAa,YAAA;AAGZ,SAAS,YAAY,KAAA,EAAoC;AAC9D,EAAA,OAAO,UAAA,CAAW,IAAA,CAAK,KAAA,IAAS,EAAE,CAAA;AACpC;;;ACAA,I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AAK,CAAA,EAAG,MAAM,KAAA;AACrC,IAAA,MAAM,UAAA,GAAa,OAAA,IAAW,oBAAA,CAAqB,OAAA,CAAQ,SAAS,QAAQ,CAAA;AAC5E,IAAA,IAAI,UAAA,EAAY;AACd,MAAA,MAAM,iBAAA,CAAkB,UAAA,EAAY,OAAA,CAAQ,QAAA,CAAS,SAAA,EAAW;AAAA,QAC9D,WAAA;AAAA,QACA,cAAc,OAAA,CAAQ;AAAA,OACvB,CAAA;AAAA,IACH;AACA,IAAA,QAAA,EAAS;AAAA,EACX;AACF","file":"chunk-JS2UUQ5B.js","sourcesContent":["/**\n * A product id: 1 to 18 digits.\n *\n * The API keeps product ids in a signed 64-bit integer. Up to 9223372036854775807 it answers\n * a missing product with 410; one past that, it answers 417, which is neither 404 nor 410, so\n * the page went out as a 500 (`/-/p99999999999999999999999`, which scanners ask for). Every\n * 18-digit number fits; real ids have about 10.\n *\n * `TWIG_PRODUCT_URL` in `../seo-redirects.ts` carries the same cap. Both are literals, because static\n * analysis flags a `RegExp` built from a string.\n */\nconst PRODUCT_ID = /^\\d{1,18}$/;\n\n/** Whether `value` can be a product id the API answers 200 or 410 for. */\nexport function isProductId(value: string | undefined): boolean {\n return PRODUCT_ID.test(value ?? '');\n}\n","/**\n * @fileoverview The product at a SKU-link address (`/{key}-{name}`, see `router/product-key-urls`).\n *\n * The rewrite hands the product route an id of `~{key}`. The key is `p{id}` (the product id\n * itself) or a SKU of letters and digits, as Twig's `getProductBySkuOrId` reads it.\n */\nimport type { QueryClient } from '@tanstack/react-query';\nimport type { Product } from '../../types';\nimport { product } from '../../api/product';\nimport { isMissingResource, notFound, orThrow } from '../../providers/NavigationProvider';\nimport { productKeyOfId, publicProductKeyPath } from '../../router/product-key-urls';\nimport { PRODUCT_SLUG_ROUTE_ID } from '../../router/slug-routes';\nimport { customUrlRedirect, type CustomUrlRedirectOptions } from '../custom-urls';\nimport { isProductId } from './id';\n\n/** `p{id}`: Sluggable's key for a product whose SKU is not letters and digits. */\nconst ID_KEY = /^p(\\d+)$/;\n\n/**\n * The product a key names: by id for `p{id}`, else by SKU. A SKU is read through the query cache,\n * which `resolveProductKeyPage` filled in the same navigation, so it costs one call.\n */\nexport async function productOfKey(\n key: string,\n queryClient?: QueryClient | null\n): Promise<Product> {\n const id = ID_KEY.exec(key)?.[1];\n if (id !== undefined) {\n // Past 18 digits the API answers 417, not 404 (see `./id`).\n if (!isProductId(id)) return notFound();\n return product.findOrThrow(id);\n }\n return orThrow(\n queryClient ? queryClient.ensureQueryData(product.queries.bySku(key)) : product.findBySku(key)\n );\n}\n\n/** The address a SKU-link lookup was made for, so a miss can still be one of the merchant's custom URLs. */\nexport interface ProductKeyAddress {\n /** The router's location: the internal path (`/{name}/p~{key}`) and the query string. */\n location: { pathname: string; searchStr: string };\n /** The language segment an item's page takes (the locale layout's rule). */\n targetLocale?: CustomUrlRedirectOptions['targetLocale'];\n}\n\n/**\n * Run by the locale layout's `beforeLoad`: a SKU that names no product is the not-found page, a\n * 404, as Twig's catch-all answers it, unless the address is one of the merchant's custom URLs.\n * Twig tries those after its SKU route: `/values-in-action` is first SKU `values`.\n *\n * It is resolved here, ahead of the product loader, because a theme may turn that loader's\n * not-found into something else: Raed sends it home with a toast. That suits a product that was\n * deleted, but not `/new-arrivals` or a scanner's path, which only look like a SKU link. The\n * answer stays in the query cache for the loader.\n */\nexport async function resolveProductKeyPage(\n page: { routeId: string; params: Record<string, string | undefined> } | undefined,\n queryClient: QueryClient,\n address?: ProductKeyAddress\n): Promise<void> {\n if (page?.routeId !== PRODUCT_SLUG_ROUTE_ID) return;\n const key = productKeyOfId(page.params.id);\n if (!key || ID_KEY.test(key)) return;\n try {\n await queryClient.ensureQueryData(product.queries.bySku(key));\n } catch (error) {\n if (!isMissingResource(error)) throw error;\n const publicPath = address && publicProductKeyPath(address.location.pathname);\n if (publicPath) {\n await customUrlRedirect(publicPath, address.location.searchStr, {\n queryClient,\n targetLocale: address.targetLocale,\n });\n }\n notFound();\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { api } from './chunk-
|
|
1
|
+
import { api } from './chunk-P62RTWYQ.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-JW4QTH2U.js.map
|
|
24
|
+
//# sourceMappingURL=chunk-JW4QTH2U.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,EAAkB,YAAA,CAAa,QAAA,EAAU,CAAA,CAAA,EAAI,OAAc,CAAA,CAC/D,IAAA,EAAsE;AAEzE,IAAA,MAAM,YAAA,GAAe,SAAS,IAAA,CAAK,YAAA;AAEnC,IAAA,OAAO;AAAA,MACL,KAAA,EAAO,YAAA,CAAa,IAAA,IAAQ,EAAC;AAAA,MAC7B,MAAM,YAAA,CAAa,aAAA;AAAA,MACnB,OAAA,EAAS,SAAS,IAAA,CAAK;AAAA,KACzB;AAAA,EACF;AACF","file":"chunk-
|
|
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,EAAkB,YAAA,CAAa,QAAA,EAAU,CAAA,CAAA,EAAI,OAAc,CAAA,CAC/D,IAAA,EAAsE;AAEzE,IAAA,MAAM,YAAA,GAAe,SAAS,IAAA,CAAK,YAAA;AAEnC,IAAA,OAAO;AAAA,MACL,KAAA,EAAO,YAAA,CAAa,IAAA,IAAQ,EAAC;AAAA,MAC7B,MAAM,YAAA,CAAa,aAAA;AAAA,MACnB,OAAA,EAAS,SAAS,IAAA,CAAK;AAAA,KACzB;AAAA,EACF;AACF","file":"chunk-JW4QTH2U.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"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { parseShortLinkPath } from './chunk-6T7N5FOL.js';
|
|
2
2
|
import { PRODUCT_SLUG_ROUTE_ID, CATEGORY_SLUG_ROUTE_ID } from './chunk-NV4PF3O3.js';
|
|
3
3
|
import { productKeyOfId } from './chunk-SDBR4X3K.js';
|
|
4
|
-
import { redirect, isMissingResource } from './chunk-
|
|
5
|
-
import { clearAuthTokenCookie } from './chunk-
|
|
4
|
+
import { redirect, isMissingResource } from './chunk-ODMEJVTL.js';
|
|
5
|
+
import { clearAuthTokenCookie } from './chunk-PQR776WF.js';
|
|
6
6
|
import { FALLBACK_LOCALE, isLocale } from './chunk-T72DAX7R.js';
|
|
7
7
|
import { useEffect } from 'react';
|
|
8
8
|
|
|
@@ -91,7 +91,7 @@ async function twigUrlRedirect(pathname, search, page, options = {}) {
|
|
|
91
91
|
throw redirect(`${locale ? `/${locale}` : ""}${target.path}${search}`, { statusCode: 301 });
|
|
92
92
|
}
|
|
93
93
|
if (!options.queryClient || twigPageUrl(pathname)) return;
|
|
94
|
-
const { customUrlRedirect } = await import('./custom-urls-
|
|
94
|
+
const { customUrlRedirect } = await import('./custom-urls-JDYZLJSU.js');
|
|
95
95
|
await customUrlRedirect(pathname, search, {
|
|
96
96
|
queryClient: options.queryClient,
|
|
97
97
|
targetLocale: options.targetLocale
|
|
@@ -106,5 +106,5 @@ function LogoutRedirect() {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
export { LogoutRedirect, accountRedirectLoader, orderRatingRedirectLoader, pendingOrdersRedirectLoader, productsSourceRedirectLoader, ratingRedirectLoader, slugBrandRedirectLoader, twigUrlRedirect };
|
|
109
|
-
//# sourceMappingURL=chunk-
|
|
110
|
-
//# sourceMappingURL=chunk-
|
|
109
|
+
//# sourceMappingURL=chunk-KNVMG7LJ.js.map
|
|
110
|
+
//# sourceMappingURL=chunk-KNVMG7LJ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/routes/seo-redirects.ts"],"names":["id"],"mappings":";;;;;;;;AAkBA,eAAsB,wBAAwB,GAAA,EAAkD;AAC9F,EAAA,MAAM,MAAA,GAAS,GAAA,CAAI,MAAA,CAAO,MAAA,IAAU,eAAA;AACpC,EAAA,MAAM,SAAS,CAAA,CAAA,EAAI,MAAM,WAAW,GAAA,CAAI,MAAA,CAAO,EAAE,CAAA,CAAE,CAAA;AACrD;AAOA,eAAsB,4BACpB,GAAA,GAA+C,EAAE,MAAA,EAAQ,IAAG,EAC5C;AAChB,EAAA,MAAM,MAAA,GAAS,GAAA,CAAI,MAAA,CAAO,MAAA,IAAU,eAAA;AACpC,EAAA,MAAM,QAAA,CAAS,CAAA,CAAA,EAAI,MAAM,CAAA,8BAAA,CAAgC,CAAA;AAC3D;AAGA,eAAsB,qBACpB,GAAA,GAA+C,EAAE,MAAA,EAAQ,IAAG,EAC5C;AAChB,EAAA,MAAM,MAAA,GAAS,GAAA,CAAI,MAAA,CAAO,MAAA,IAAU,eAAA;AACpC,EAAA,MAAM,QAAA,CAAS,CAAA,CAAA,EAAI,MAAM,CAAA,eAAA,CAAiB,CAAA;AAC5C;AAOA,eAAsB,0BAA0B,GAAA,EAI7B;AACjB,EAAA,MAAM,MAAA,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AM,OAAO,2BAAe,CAAA;AAC1D,EAAA,MAAM,iBAAA,CAAkB,UAAU,MAAA,EAAQ;AAAA,IACxC,aAAa,OAAA,CAAQ,WAAA;AAAA,IACrB,cAAc,OAAA,CAAQ;AAAA,GACvB,CAAA;AACH;AAUO,SAAS,cAAA,GAAuB;AACrC,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,oBAAA,EAAqB;AAErB,IAAA,MAAA,CAAO,QAAA,CAAS,QAAQ,MAAA,CAAO,QAAA,CAAS,KAAK,OAAA,CAAQ,8BAAA,EAAgC,EAAE,CAAC,CAAA;AAAA,EAC1F,CAAA,EAAG,EAAE,CAAA;AACL,EAAA,OAAO,IAAA;AACT","file":"chunk-AKPRDR3B.js","sourcesContent":["import { useEffect } from 'react';\nimport type { QueryClient } from '@tanstack/react-query';\nimport { isMissingResource, redirect } from '../providers/NavigationProvider';\nimport { FALLBACK_LOCALE, isLocale } from '../providers/locale-constants';\nimport { productKeyOfId } from '../router/product-key-urls';\nimport { CATEGORY_SLUG_ROUTE_ID, PRODUCT_SLUG_ROUTE_ID } from '../router/slug-routes';\nimport { clearAuthTokenCookie } from '../utils/cookies';\nimport { parseShortLinkPath } from './short-link-path';\n\nexport interface SlugBrandParams {\n /** SEO slug segment (ignored — only here to match the route pattern). */\n slug: string;\n /** Brand numeric ID to redirect to. */\n id: string;\n /** Active locale from the `/$locale` parent layout (e.g. `'ar'`, `'en'`). */\n locale?: string;\n}\n\nexport async function slugBrandRedirectLoader(ctx: { params: SlugBrandParams }): Promise<never> {\n const locale = ctx.params.locale || FALLBACK_LOCALE;\n throw redirect(`/${locale}/brands/${ctx.params.id}`);\n}\n\nexport interface PendingOrdersRedirectParams {\n /** Active locale from the `/$locale` parent layout (e.g. `'ar'`, `'en'`). */\n locale?: string;\n}\n\nexport async function pendingOrdersRedirectLoader(\n ctx: { params: PendingOrdersRedirectParams } = { params: {} }\n): Promise<never> {\n const locale = ctx.params.locale || FALLBACK_LOCALE;\n throw redirect(`/${locale}/account/orders?status=pending`);\n}\n\n/** `/account/rating`: the loyalty \"rate your orders\" link. Twig Raed has no rating page and sends it to the orders list. */\nexport async function ratingRedirectLoader(\n ctx: { params: PendingOrdersRedirectParams } = { params: {} }\n): Promise<never> {\n const locale = ctx.params.locale || FALLBACK_LOCALE;\n throw redirect(`/${locale}/account/orders`);\n}\n\n/**\n * `/rating/{id}` and `/account/rating/{id}`: the rate-your-order link in the order email and SMS,\n * sent like Twig to the order with its rating popup. The id goes as it came: the orders API\n * decodes it the way Store's `rateOrder` does (optimus when numeric, else the hash).\n */\nexport async function orderRatingRedirectLoader(ctx: {\n params: PendingOrdersRedirectParams & { id: string };\n /** The incoming query string, `token` included: the SDK signs the visitor in with it. */\n search?: string;\n}): Promise<never> {\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n const query = new URLSearchParams(ctx.search);\n query.set('show-rating-popup', 'true');\n throw redirect(`${prefix}/account/orders/${encodeURIComponent(ctx.params.id)}?${query}`);\n}\n\n/** A Twig customer URL (`/profile`, `/orders`, …) kept working as its `/account/…` page. */\nexport async function accountRedirectLoader(ctx: {\n params: PendingOrdersRedirectParams;\n page: string;\n /** The incoming query string (`?status=pending`), kept on the account page. */\n search?: string;\n}): Promise<never> {\n // No locale in the URL stays without one: the locale layout adds it only where the store has several.\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n throw redirect(`${prefix}/account/${ctx.page}${ctx.search ?? ''}`, { statusCode: 301 });\n}\n\n/** `/latest-products`, `/most-sales-products` and `/offers` now live at `/products?source=`. */\nexport async function productsSourceRedirectLoader(ctx: {\n params: PendingOrdersRedirectParams;\n source: 'latest' | 'sales' | 'offers';\n search?: string;\n}): Promise<never> {\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n const query = new URLSearchParams(ctx.search);\n query.delete('source');\n const rest = query.toString();\n throw redirect(`${prefix}/products?source=${ctx.source}${rest ? `&${rest}` : ''}`, {\n statusCode: 301,\n });\n}\n\nexport { resolveProductKeyPage } from './product/key';\nexport { publicProductKeyPath } from '../router/product-key-urls';\n\n/** Routes a Twig URL lands on by accident: a locale bound as `$slug`, or an id that is no number. */\nconst SLUG_ROUTES = new Set([PRODUCT_SLUG_ROUTE_ID, CATEGORY_SLUG_ROUTE_ID]);\n\n/** `/p{id}` or `/p{id}-{name}`, with or without a leading segment; the id capped as in `./product/id`. */\nconst TWIG_PRODUCT_URL = /^(?:\\/([^/]+))?\\/p(\\d{1,18})(?:-[^/]*)?\\/?$/;\n/** `/category/{hash}`, with or without a leading segment. */\nconst TWIG_CATEGORY_URL = /^(?:\\/([^/]+))?\\/category\\/([A-Za-z0-9]+)\\/?$/;\n\n/** The page the router matched, as the locale layout's `beforeLoad` sees it. */\nexport interface MatchedPage {\n routeId: string;\n params: Record<string, string | undefined>;\n}\n\nfunction rendersNoPage({ routeId, params }: MatchedPage): boolean {\n // A first segment that is no language binds as the locale, of the layout or of the home page.\n if (routeId === '/{-$locale}' || (params.locale && !isLocale(params.locale))) return true;\n if (!SLUG_ROUTES.has(routeId)) return false;\n // A SKU-link address the router's rewrite gave the product route (`router/product-key-urls`).\n if (productKeyOfId(params.id)) return false;\n return (!params.locale && isLocale(params.slug)) || !/^\\d+$/.test(params.id ?? '');\n}\n\nexport interface TwigUrlRedirectOptions {\n /**\n * The language segment the target takes, given the one the address had. The locale layout\n * knows how the store addresses its pages, so the redirect lands there in one hop: `/-/p1`\n * on a store with several languages was sent on again to `/ar/-/p1`, and that second request\n * also fetched the product, because the server starts every loader at once. Without it the\n * address's own segment is kept.\n */\n targetLocale?: (addressLocale: string | undefined) => Promise<string | undefined>;\n /**\n * The request's query client. The category lookup is then shared between a hover preload and\n * the click.\n */\n queryClient?: QueryClient;\n}\n\n/** The category's numeric id for its Twig hash, or `undefined` when the API has no such category. */\nasync function categoryIdOf(hash: string, queryClient?: QueryClient): Promise<string | undefined> {\n const { category } = await import('../api/category');\n try {\n const found = queryClient\n ? await queryClient.ensureQueryData(category.queries.detail(hash))\n : await category.find(hash);\n // Only the id is taken. The category is never filed under its id for the category page:\n // this lookup ran in the address's language (Arabic when it has none, the fallback), and\n // the page may be in another (`/en/-/c…` on an English-only store), while a category's\n // cache key carries no language.\n return String(found.id_ ?? found.id);\n } catch (error) {\n if (isMissingResource(error)) return undefined;\n throw error;\n }\n}\n\n/**\n * The product id behind a short link (`/KjQrpE`). A store without SEO URLs gives every product\n * that address, in its sitemap and in the API's `url`, and the API takes the code in place of\n * the id. Any failure counts as \"no such product\": a bare `/{code}` is also every scanner's\n * `/admin`, so an API error must not turn those into 500s. The not-found page's\n * `useProductShortLink` asks again from the browser, as it did before.\n */\nasync function shortLinkProductId(\n code: string,\n queryClient?: QueryClient\n): Promise<string | undefined> {\n const { product } = await import('../api/product');\n try {\n const found = queryClient\n ? await queryClient.ensureQueryData(product.queries.detail(code))\n : await product.find(code);\n return found?.id ? String(found.id) : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** Where a Twig URL's page is now, and the language its address carried. */\n/**\n * A Twig product or category URL: `/p{id}…` or `/category/{hash}`, bare or under a language. Under\n * any other first segment it is no Twig route, so the Store's catch-all would have it.\n */\nfunction twigPageUrl(\n pathname: string\n): { kind: 'p' | 'c'; ref: string; locale?: string } | undefined {\n const productUrl = TWIG_PRODUCT_URL.exec(pathname);\n const match = productUrl ?? TWIG_CATEGORY_URL.exec(pathname);\n if (!match || (match[1] && !isLocale(match[1]))) return undefined;\n return { kind: productUrl ? 'p' : 'c', ref: match[2], locale: match[1] };\n}\n\nasync function twigTarget(\n pathname: string,\n queryClient?: QueryClient\n): Promise<{ path: string; locale?: string } | undefined> {\n const pageUrl = twigPageUrl(pathname);\n if (pageUrl) {\n if (pageUrl.kind === 'p') return { path: `/-/p${pageUrl.ref}`, locale: pageUrl.locale };\n const id = await categoryIdOf(pageUrl.ref, queryClient);\n return id ? { path: `/-/c${id}`, locale: pageUrl.locale } : undefined;\n }\n const shortLink = parseShortLinkPath(pathname);\n if (!shortLink) return undefined;\n const id = await shortLinkProductId(shortLink.code, queryClient);\n return id ? { path: `/-/p${id}`, locale: shortLink.locale } : undefined;\n}\n\n/**\n * Twig's product and category URLs, each with or without a locale, sent to the page that has\n * them now: `/p{id}`, `/p{id}-{name}`, `/category/{hash}` and the product short link `/{code}`.\n * Run by the locale layout's `beforeLoad`, only for an address no page answers: the router binds\n * `/ar/p1` to `$slug/p{$id}` (slug `ar`) and `/p1` to the locale.\n *\n * A product URL carries its id, so it is redirected without asking the API: a product that is\n * gone is the product page's not-found, one hop on. A category hash or a short code only the API\n * can turn into the id; one that is gone stays the not-found page at its address.\n *\n * Any other address no page answers, a short code that names no product included, may be one of\n * the merchant's custom URLs, which Twig's catch-all answers last (`./custom-urls`). A gone\n * category's Twig URL is not: Twig's category route answers it.\n */\nexport async function twigUrlRedirect(\n pathname: string,\n search: string,\n page: MatchedPage | undefined,\n options: TwigUrlRedirectOptions = {}\n): Promise<void> {\n if (!page || !rendersNoPage(page)) return;\n const target = await twigTarget(pathname, options.queryClient);\n if (target) {\n const locale = options.targetLocale ? await options.targetLocale(target.locale) : target.locale;\n throw redirect(`${locale ? `/${locale}` : ''}${target.path}${search}`, { statusCode: 301 });\n }\n if (!options.queryClient || twigPageUrl(pathname)) return;\n const { customUrlRedirect } = await import('./custom-urls');\n await customUrlRedirect(pathname, search, {\n queryClient: options.queryClient,\n targetLocale: options.targetLocale,\n });\n}\n\n/**\n * `/logout` — where the SDK sends the browser once `salla.auth.logout()` has run\n * (`salla.url.get('logout?from=…')`). The Twig storefront serves that URL server-side. Here\n * it renders nothing and, in the browser, removes the theme's own `token` cookie (the SDK's\n * `cookie.clearAll()` leaves it) and then does a full navigation home. It has to be a\n * component, not a loader redirect: a loader runs during server rendering, where the cookie\n * can't be cleared, so the redirect would leave the visitor signed in on the next request.\n */\nexport function LogoutRedirect(): null {\n useEffect(() => {\n clearAuthTokenCookie();\n // `/{store base}/{locale}/logout?from=…` → `/{store base}/{locale}`\n window.location.replace(window.location.href.replace(/\\/logout\\/?(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A,EAAG,EAAE,CAAA;AACL,EAAA,OAAO,IAAA;AACT","file":"chunk-KNVMG7LJ.js","sourcesContent":["import { useEffect } from 'react';\nimport type { QueryClient } from '@tanstack/react-query';\nimport { isMissingResource, redirect } from '../providers/NavigationProvider';\nimport { FALLBACK_LOCALE, isLocale } from '../providers/locale-constants';\nimport { productKeyOfId } from '../router/product-key-urls';\nimport { CATEGORY_SLUG_ROUTE_ID, PRODUCT_SLUG_ROUTE_ID } from '../router/slug-routes';\nimport { clearAuthTokenCookie } from '../utils/cookies';\nimport { parseShortLinkPath } from './short-link-path';\n\nexport interface SlugBrandParams {\n /** SEO slug segment (ignored — only here to match the route pattern). */\n slug: string;\n /** Brand numeric ID to redirect to. */\n id: string;\n /** Active locale from the `/$locale` parent layout (e.g. `'ar'`, `'en'`). */\n locale?: string;\n}\n\nexport async function slugBrandRedirectLoader(ctx: { params: SlugBrandParams }): Promise<never> {\n const locale = ctx.params.locale || FALLBACK_LOCALE;\n throw redirect(`/${locale}/brands/${ctx.params.id}`);\n}\n\nexport interface PendingOrdersRedirectParams {\n /** Active locale from the `/$locale` parent layout (e.g. `'ar'`, `'en'`). */\n locale?: string;\n}\n\nexport async function pendingOrdersRedirectLoader(\n ctx: { params: PendingOrdersRedirectParams } = { params: {} }\n): Promise<never> {\n const locale = ctx.params.locale || FALLBACK_LOCALE;\n throw redirect(`/${locale}/account/orders?status=pending`);\n}\n\n/** `/account/rating`: the loyalty \"rate your orders\" link. Twig Raed has no rating page and sends it to the orders list. */\nexport async function ratingRedirectLoader(\n ctx: { params: PendingOrdersRedirectParams } = { params: {} }\n): Promise<never> {\n const locale = ctx.params.locale || FALLBACK_LOCALE;\n throw redirect(`/${locale}/account/orders`);\n}\n\n/**\n * `/rating/{id}` and `/account/rating/{id}`: the rate-your-order link in the order email and SMS,\n * sent like Twig to the order with its rating popup. The id goes as it came: the orders API\n * decodes it the way Store's `rateOrder` does (optimus when numeric, else the hash).\n */\nexport async function orderRatingRedirectLoader(ctx: {\n params: PendingOrdersRedirectParams & { id: string };\n /** The incoming query string, `token` included: the SDK signs the visitor in with it. */\n search?: string;\n}): Promise<never> {\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n const query = new URLSearchParams(ctx.search);\n query.set('show-rating-popup', 'true');\n throw redirect(`${prefix}/account/orders/${encodeURIComponent(ctx.params.id)}?${query}`);\n}\n\n/** A Twig customer URL (`/profile`, `/orders`, …) kept working as its `/account/…` page. */\nexport async function accountRedirectLoader(ctx: {\n params: PendingOrdersRedirectParams;\n page: string;\n /** The incoming query string (`?status=pending`), kept on the account page. */\n search?: string;\n}): Promise<never> {\n // No locale in the URL stays without one: the locale layout adds it only where the store has several.\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n throw redirect(`${prefix}/account/${ctx.page}${ctx.search ?? ''}`, { statusCode: 301 });\n}\n\n/** `/latest-products`, `/most-sales-products` and `/offers` now live at `/products?source=`. */\nexport async function productsSourceRedirectLoader(ctx: {\n params: PendingOrdersRedirectParams;\n source: 'latest' | 'sales' | 'offers';\n search?: string;\n}): Promise<never> {\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n const query = new URLSearchParams(ctx.search);\n query.delete('source');\n const rest = query.toString();\n throw redirect(`${prefix}/products?source=${ctx.source}${rest ? `&${rest}` : ''}`, {\n statusCode: 301,\n });\n}\n\nexport { resolveProductKeyPage } from './product/key';\nexport { publicProductKeyPath } from '../router/product-key-urls';\n\n/** Routes a Twig URL lands on by accident: a locale bound as `$slug`, or an id that is no number. */\nconst SLUG_ROUTES = new Set([PRODUCT_SLUG_ROUTE_ID, CATEGORY_SLUG_ROUTE_ID]);\n\n/** `/p{id}` or `/p{id}-{name}`, with or without a leading segment; the id capped as in `./product/id`. */\nconst TWIG_PRODUCT_URL = /^(?:\\/([^/]+))?\\/p(\\d{1,18})(?:-[^/]*)?\\/?$/;\n/** `/category/{hash}`, with or without a leading segment. */\nconst TWIG_CATEGORY_URL = /^(?:\\/([^/]+))?\\/category\\/([A-Za-z0-9]+)\\/?$/;\n\n/** The page the router matched, as the locale layout's `beforeLoad` sees it. */\nexport interface MatchedPage {\n routeId: string;\n params: Record<string, string | undefined>;\n}\n\nfunction rendersNoPage({ routeId, params }: MatchedPage): boolean {\n // A first segment that is no language binds as the locale, of the layout or of the home page.\n if (routeId === '/{-$locale}' || (params.locale && !isLocale(params.locale))) return true;\n if (!SLUG_ROUTES.has(routeId)) return false;\n // A SKU-link address the router's rewrite gave the product route (`router/product-key-urls`).\n if (productKeyOfId(params.id)) return false;\n return (!params.locale && isLocale(params.slug)) || !/^\\d+$/.test(params.id ?? '');\n}\n\nexport interface TwigUrlRedirectOptions {\n /**\n * The language segment the target takes, given the one the address had. The locale layout\n * knows how the store addresses its pages, so the redirect lands there in one hop: `/-/p1`\n * on a store with several languages was sent on again to `/ar/-/p1`, and that second request\n * also fetched the product, because the server starts every loader at once. Without it the\n * address's own segment is kept.\n */\n targetLocale?: (addressLocale: string | undefined) => Promise<string | undefined>;\n /**\n * The request's query client. The category lookup is then shared between a hover preload and\n * the click.\n */\n queryClient?: QueryClient;\n}\n\n/** The category's numeric id for its Twig hash, or `undefined` when the API has no such category. */\nasync function categoryIdOf(hash: string, queryClient?: QueryClient): Promise<string | undefined> {\n const { category } = await import('../api/category');\n try {\n const found = queryClient\n ? await queryClient.ensureQueryData(category.queries.detail(hash))\n : await category.find(hash);\n // Only the id is taken. The category is never filed under its id for the category page:\n // this lookup ran in the address's language (Arabic when it has none, the fallback), and\n // the page may be in another (`/en/-/c…` on an English-only store), while a category's\n // cache key carries no language.\n return String(found.id_ ?? found.id);\n } catch (error) {\n if (isMissingResource(error)) return undefined;\n throw error;\n }\n}\n\n/**\n * The product id behind a short link (`/KjQrpE`). A store without SEO URLs gives every product\n * that address, in its sitemap and in the API's `url`, and the API takes the code in place of\n * the id. Any failure counts as \"no such product\": a bare `/{code}` is also every scanner's\n * `/admin`, so an API error must not turn those into 500s. The not-found page's\n * `useProductShortLink` asks again from the browser, as it did before.\n */\nasync function shortLinkProductId(\n code: string,\n queryClient?: QueryClient\n): Promise<string | undefined> {\n const { product } = await import('../api/product');\n try {\n const found = queryClient\n ? await queryClient.ensureQueryData(product.queries.detail(code))\n : await product.find(code);\n return found?.id ? String(found.id) : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** Where a Twig URL's page is now, and the language its address carried. */\n/**\n * A Twig product or category URL: `/p{id}…` or `/category/{hash}`, bare or under a language. Under\n * any other first segment it is no Twig route, so the Store's catch-all would have it.\n */\nfunction twigPageUrl(\n pathname: string\n): { kind: 'p' | 'c'; ref: string; locale?: string } | undefined {\n const productUrl = TWIG_PRODUCT_URL.exec(pathname);\n const match = productUrl ?? TWIG_CATEGORY_URL.exec(pathname);\n if (!match || (match[1] && !isLocale(match[1]))) return undefined;\n return { kind: productUrl ? 'p' : 'c', ref: match[2], locale: match[1] };\n}\n\nasync function twigTarget(\n pathname: string,\n queryClient?: QueryClient\n): Promise<{ path: string; locale?: string } | undefined> {\n const pageUrl = twigPageUrl(pathname);\n if (pageUrl) {\n if (pageUrl.kind === 'p') return { path: `/-/p${pageUrl.ref}`, locale: pageUrl.locale };\n const id = await categoryIdOf(pageUrl.ref, queryClient);\n return id ? { path: `/-/c${id}`, locale: pageUrl.locale } : undefined;\n }\n const shortLink = parseShortLinkPath(pathname);\n if (!shortLink) return undefined;\n const id = await shortLinkProductId(shortLink.code, queryClient);\n return id ? { path: `/-/p${id}`, locale: shortLink.locale } : undefined;\n}\n\n/**\n * Twig's product and category URLs, each with or without a locale, sent to the page that has\n * them now: `/p{id}`, `/p{id}-{name}`, `/category/{hash}` and the product short link `/{code}`.\n * Run by the locale layout's `beforeLoad`, only for an address no page answers: the router binds\n * `/ar/p1` to `$slug/p{$id}` (slug `ar`) and `/p1` to the locale.\n *\n * A product URL carries its id, so it is redirected without asking the API: a product that is\n * gone is the product page's not-found, one hop on. A category hash or a short code only the API\n * can turn into the id; one that is gone stays the not-found page at its address.\n *\n * Any other address no page answers, a short code that names no product included, may be one of\n * the merchant's custom URLs, which Twig's catch-all answers last (`./custom-urls`). A gone\n * category's Twig URL is not: Twig's category route answers it.\n */\nexport async function twigUrlRedirect(\n pathname: string,\n search: string,\n page: MatchedPage | undefined,\n options: TwigUrlRedirectOptions = {}\n): Promise<void> {\n if (!page || !rendersNoPage(page)) return;\n const target = await twigTarget(pathname, options.queryClient);\n if (target) {\n const locale = options.targetLocale ? await options.targetLocale(target.locale) : target.locale;\n throw redirect(`${locale ? `/${locale}` : ''}${target.path}${search}`, { statusCode: 301 });\n }\n if (!options.queryClient || twigPageUrl(pathname)) return;\n const { customUrlRedirect } = await import('./custom-urls');\n await customUrlRedirect(pathname, search, {\n queryClient: options.queryClient,\n targetLocale: options.targetLocale,\n });\n}\n\n/**\n * `/logout` — where the SDK sends the browser once `salla.auth.logout()` has run\n * (`salla.url.get('logout?from=…')`). The Twig storefront serves that URL server-side. Here\n * it renders nothing and, in the browser, removes the theme's own `token` cookie (the SDK's\n * `cookie.clearAll()` leaves it) and then does a full navigation home. It has to be a\n * component, not a loader redirect: a loader runs during server rendering, where the cookie\n * can't be cleared, so the redirect would leave the visitor signed in on the next request.\n */\nexport function LogoutRedirect(): null {\n useEffect(() => {\n clearAuthTokenCookie();\n // `/{store base}/{locale}/logout?from=…` → `/{store base}/{locale}`\n window.location.replace(window.location.href.replace(/\\/logout\\/?(\\?[^#]*)?(#.*)?$/, ''));\n }, []);\n return null;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getInjectedRuntimeEnv, resolveStoreIdentifier } from './chunk-
|
|
2
|
-
import { getRequestStore, getTwilightContext } from './chunk-
|
|
1
|
+
import { getInjectedRuntimeEnv, resolveStoreIdentifier } from './chunk-PQR776WF.js';
|
|
2
|
+
import { getRequestStore, getTwilightContext } from './chunk-AWV3WEKH.js';
|
|
3
3
|
|
|
4
4
|
// src/utils/theme-version.ts
|
|
5
5
|
function requestedThemeVersionId() {
|
|
@@ -121,5 +121,5 @@ function syncSdkThemeVersion(headers) {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
export { getSallaSDK, getStoreIdentifier, onSallaEvent, requestedThemeVersionId, resolveThemeVersionId, syncSdkLocale, syncSdkThemeVersion, whenSallaLoaded, whenSallaReady, withSdkThemeVersion };
|
|
124
|
-
//# sourceMappingURL=chunk-
|
|
125
|
-
//# sourceMappingURL=chunk-
|
|
124
|
+
//# sourceMappingURL=chunk-KY2VNPZX.js.map
|
|
125
|
+
//# sourceMappingURL=chunk-KY2VNPZX.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/theme-version.ts","../src/utils/sdk-helpers.ts"],"names":[],"mappings":";;;;AAqCO,SAAS,uBAAA,GAAyC;AACvD,EAAA,MAAM,EAAE,SAAA,EAAU,GAAI,eAAA,EAAgB;AACtC,EAAA,IAAI,WAAW,OAAO,SAAA;AAEtB,EAAA,OAAO,qBAAA,GAAwB,SAAA,IAAa,IAAA;AAC9C;AAmCA,SAAS,YAAA,CAAa,UAA2C,aAAA,EAA8B;AAC7F,EAAA,MAAM,gBAAA,GAAmB,UAAU,gBAAA,IAAoB,IAAA;AACvD,EAAA,IAAI,aAAA,IAAiB,IAAA,EAAM,OAAO,gBAAA,IAAoB,IAAA;AACtD,EAAA,MAAM,eAAA,GAAkB,QAAA,EAAU,KAAA,EAAO,KAAA,EAAO,EAAA;AAChD,EAAA,OAAA,CAAQ,eAAA,IAAmB,IAAA,GAAO,MAAA,CAAO,eAAe,IAAI,gBAAA,MAAsB,aAAA;AACpF;AAEO,SAAS,qBAAA,CAAsB,gBAA+B,IAAA,EAAqB;AACxF,EAAA,MAAM,YAAY,uBAAA,EAAwB;AAC1C,EAAA,IAAI,WAAW,OAAO,SAAA;AAEtB,EAAA,IAAI;AACF,IAAA,MAAM,QAAA,GAAW,oBAAmB,CAAE,QAAA;AACtC,IAAA,IAAI,CAAC,YAAA,CAAa,QAAA,EAAU,aAAa,GAAG,OAAO,IA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AER;AACF","file":"chunk-MJHYGAN3.js","sourcesContent":["/**\n * @fileoverview Which version of the theme's settings to render — the one answer,\n * in one place.\n *\n * A merchant's theme settings are versioned. An ordinary storefront visit names\n * no version and gets the live one; the API decides, and reports it back as\n * `theme.profile.id`. Two surfaces need a different one, and both address it in\n * the URL of an iframe:\n *\n * - the merchant's theme editor at `s.salla.sa/themes/editor/…`, which shows a\n * draft version beside the controls that are editing it;\n * - a partner running the theme locally, whose dev server is the iframe.\n *\n * Written as a module of its own rather than inline at the one call site,\n * because `store-identity.ts` exists for exactly this reason: the identifier a\n * request resolved and the identifier it sent were two different values for\n * days, in two files, and every test passed. A second implementation of this is\n * the bug, not a refactor away from one.\n */\nimport { getRequestStore, getTwilightContext } from '../twilight/context';\nimport type { StoreContext } from '../api/store';\nimport { getInjectedRuntimeEnv } from './runtime-env';\n\n/**\n * The version this request asked for, or null when it asked for none.\n *\n * Deliberately excludes the version the *settings* name. This is the answer to\n * \"what did the caller address?\", and it has to be available before any settings\n * exist — React Query keys are built from it, and a key that means one thing\n * during SSR and another after hydration is how a page refetches everything it\n * was just handed.\n *\n * 1. what the request named, seeded by `twilightMiddleware` on a host permitted\n * to name one;\n * 2. what SSR resolved and published into the head, which is all the browser has\n * once the dispatcher has stripped `?versionId=` from the URL.\n */\nexport function requestedThemeVersionId(): string | null {\n const { versionId } = getRequestStore();\n if (versionId) return versionId;\n\n return getInjectedRuntimeEnv().versionId || null;\n}\n\n/**\n * The version every Salla API call is answered with — what goes in `s-version-id`.\n *\n * The requested version outranks the settings, because a request that named one\n * is the only reason this is ever anything but the live version: falling back to\n * the settings there would let the first answer overwrite the question.\n *\n * The settings' own `theme.profile.id` stays as the fallback, unchanged. It is\n * what this header has always carried, and on an ordinary storefront it still\n * is — it keeps the rest of a page's calls pinned to the version the settings\n * call resolved, rather than letting a version go live mid-render.\n *\n * That pin is only good for the scope the settings were requested with. Each\n * market (scope) has its own version, and the API lets a named version outrank\n * the market's: once the shopper switches market, the loaded settings still\n * describe the previous one, and replaying their version — on the settings call\n * for the new market first of all — gets the previous market's theme back, for\n * good. So the version is replayed only while the active scope is the one the\n * settings were answered for (`store.scope`), which is not always the one they\n * were requested for (`requestedScopeId`): the API falls back to another scope\n * when it does not accept the requested one, and that scope's version must not\n * ride along on the next request for the requested one. With no active scope it\n * is replayed only for settings requested without one. Otherwise nothing is\n * sent and the API picks the version of the scope on the request.\n *\n * `activeScopeId` is passed in by the caller that already resolved the scope for\n * its `s-scope-*` headers.\n *\n * Reading the settings is guarded because `getTwilightContext().settings` throws\n * a `SettingsError` when they have not loaded — which is the normal state on the\n * very first call, the settings call itself.\n */\n/** Whether `settings` were answered for `activeScopeId` (see {@link resolveThemeVersionId}). */\nfunction answersScope(settings: StoreContext | null | undefined, activeScopeId: string | null) {\n const requestedScopeId = settings?.requestedScopeId ?? null;\n if (activeScopeId == null) return requestedScopeId == null;\n const answeredScopeId = settings?.store?.scope?.id;\n return (answeredScopeId != null ? String(answeredScopeId) : requestedScopeId) === activeScopeId;\n}\n\nexport function resolveThemeVersionId(activeScopeId: string | null = null): string | null {\n const requested = requestedThemeVersionId();\n if (requested) return requested;\n\n try {\n const settings = getTwilightContext().settings;\n if (!answersScope(settings, activeScopeId)) return null;\n\n const profileId = settings?.theme?.profile?.id;\n return profileId != null ? String(profileId) : null;\n } catch {\n return null;\n }\n}\n","export type { StoreContext } from '../api/store';\nimport type { StoreContext } from '../api/store';\nimport type { SallaSDK } from '../types/salla-sdk';\nimport { resolveStoreIdentifier } from './store-identity';\nimport { requestedThemeVersionId } from './theme-version';\n\nconst isBrowser = typeof window !== 'undefined';\n\n/**\n * Which store to ask the API about — see {@link resolveStoreIdentifier}.\n *\n * A delegation, not a second implementation. This name is the one on the wire\n * (`api/client.ts` sets the `store-identifier` header from it) and the one\n * themes import from `@salla.sa/twilight-theme-engine/utils`, so it stays; what\n * it must never do again is answer differently from the resolver everything\n * else asks. It had its own copy of the order once, missing the store the\n * request names and preferring the build-time `VITE_STORE_DOMAIN` that a\n * deployed worker does not have — so every published theme sent an empty\n * identifier and rendered \"Store Unavailable\".\n */\nexport function getStoreIdentifier(explicit?: string): string {\n return resolveStoreIdentifier(explicit);\n}\n\n/**\n * Get Salla SDK instance if available\n */\nexport function getSallaSDK(): typeof window.salla | undefined {\n if (!isBrowser) return undefined;\n return window.salla;\n}\n\n/** Dispatched on `window` by the SDK as the last step of loading (twilight `src/index.js`). */\nconst SDK_CREATED_EVENT = 'salla::created';\n\nconst noop = () => {};\n\n/**\n * Whether `window.salla` is the SDK, rather than the stub that stands in for it.\n *\n * ⚠️ `window.salla` exists from the first bytes of the page. The `twilight-init`\n * head script defines it with an `onReady`, so app snippets can queue work, and\n * the SDK — a deferred module — fills it in later. React can hydrate and run\n * effects in between, and there `window.salla?.event.on(…)` passes its `?.` and\n * throws `Cannot read properties of undefined (reading 'on')`.\n *\n * The SDK defines `init` and `event` in one synchronous module evaluation and the\n * stub has neither, so either one means it has loaded.\n */\nfunction isLoaded(sdk: typeof window.salla): sdk is SallaSDK {\n return typeof sdk?.init === 'function' || typeof sdk?.event?.on === 'function';\n}\n\n/** An SDK whose event bus can take a listener — what {@link onSallaEvent} needs. */\nfunction hasEventBus(sdk: typeof window.salla): sdk is SallaSDK {\n return typeof sdk?.event?.on === 'function';\n}\n\n/**\n * Run `callback` with the SDK as soon as it has loaded: now if it has, otherwise\n * when it announces itself.\n *\n * Returns a cancel for an effect's cleanup, so a component that unmounts first\n * never has the callback run. An effect that returned early when the SDK was not\n * there yet never ran again — on a cold load, where hydration beats the SDK, the\n * engine never initialised it at all.\n */\nexport function whenSallaLoaded(callback: (sdk: SallaSDK) => void): () => void {\n return whenSalla(isLoaded, callback);\n}\n\nfunction whenSalla(\n isUsable: (sdk: typeof window.salla) => sdk is SallaSDK,\n callback: (sdk: SallaSDK) => void\n): () => void {\n if (!isBrowser) return noop;\n\n if (isUsable(window.salla)) {\n callback(window.salla);\n return noop;\n }\n\n let settled = false;\n const onCreated = () => {\n const sdk = window.salla;\n if (settled || !isUsable(sdk)) return;\n settled = true;\n window.removeEventListener(SDK_CREATED_EVENT, onCreated);\n callback(sdk);\n };\n window.addEventListener(SDK_CREATED_EVENT, onCreated);\n\n return () => {\n settled = true;\n window.removeEventListener(SDK_CREATED_EVENT, onCreated);\n };\n}\n\n/**\n * Run `callback` once the SDK has loaded **and been initialised** — for work that\n * talks to the API, which needs the store config `init` sets.\n *\n * Loaded is not enough for that: `init` finishes asynchronously, so a cart lookup\n * made the moment the SDK announces itself goes out without a store identifier\n * and is answered `Store Identifier not found`. Returns a cancel, as\n * {@link whenSallaLoaded} does.\n *\n * A rejected `onReady` still runs `callback`, as `useTwilightInit` carries on past\n * one: it means a partial initialisation, and waiting on it would leave the caller\n * waiting for good.\n */\nexport function whenSallaReady(callback: (sdk: SallaSDK) => void): () => void {\n let cancelled = false;\n const cancel = whenSallaLoaded((sdk) => {\n void new Promise((resolve) => resolve(sdk.onReady?.())).catch(noop).then(() => {\n if (!cancelled) callback(sdk);\n });\n });\n return () => {\n cancelled = true;\n cancel();\n };\n}\n\n/**\n * `salla.event.on(name, listener)` once the SDK has loaded. Returns the matching\n * unsubscribe, which also cancels a subscription still waiting for the SDK.\n *\n * Removed from the emitter it was added to, not from whatever `window.salla` is\n * by the time the component unmounts.\n *\n * Waits for an event bus specifically, not for \"loaded\": an SDK is recognised by\n * `init` alone, and subscribing on one without a bus would throw.\n */\nexport function onSallaEvent(name: string, listener: (...args: unknown[]) => void): () => void {\n let bus: SallaSDK['event'] | undefined;\n const cancel = whenSalla(hasEventBus, (sdk) => {\n bus = sdk.event;\n bus.on(name, listener);\n });\n return () => {\n cancel();\n bus?.off?.(name, listener);\n };\n}\n\n/**\n * Push the active route locale onto the Salla SDK.\n *\n * Why this is needed (and why it must run on every navigation):\n * - The SDK seeds its locale from `navigator.language` — the theme sets no `s-lang`\n * cookie or `window.locale` — so an English browser starts the SDK in `en` even on\n * an `/ar` store.\n * - The SDK fixes its axios `accept-language` header ONCE, at init. `salla.lang.setLocale`\n * only swaps UI translations (it never touches the header), and `salla.init()` is a\n * no-op after `Salla.status === 'ready'`, so the header never refreshes on its own.\n * - `profile::info.fetched` (login / profile refresh on navigation) overrides the header\n * to the *account's* language.\n *\n * Net result without this: `salla.api.*` calls (cart/product details) return data in the\n * wrong locale — e.g. English cart item names on `/ar/cart` — intermittently, depending on\n * load order and whether a profile fetch ran. Re-asserting the URL locale here keeps the\n * header correct. No-op on the server and until the SDK exposes the methods.\n */\nexport function syncSdkLocale(locale: string): void {\n const sdk = getSallaSDK();\n if (!sdk || !locale) return;\n try {\n sdk.lang?.setLocale?.(locale);\n sdk.api?.setHeader?.('accept-language', locale);\n // The localization modal swaps `/${user.language_code}/` in the URL on submit;\n // the SDK never sets this locally, so without it the switch reloads the same page.\n sdk.config?.set?.('user.language_code', locale);\n } catch {\n // SDK partially loaded — the header is re-asserted on the next navigation.\n }\n}\n\n/**\n * The `s-version-id` the SDK sends: the version the request named, else the one\n * the settings report.\n *\n * The request outranks the settings here for the reason it does in\n * `resolveThemeVersionId`. `headers['s-version-id']` is the version the API\n * *answered with*, and for a version it cannot reach it reports the live one\n * while rendering defaults. Read alone, a preview's `salla.api.*` calls asked\n * about the live version while the engine's own asked about the previewed one,\n * so one page showed two versions.\n */\nfunction sdkThemeVersionId(headers: StoreContext['headers']): string | null {\n const versionId = requestedThemeVersionId() ?? headers?.['s-version-id'];\n return versionId != null ? String(versionId) : null;\n}\n\n/**\n * Settings as the SDK's `init` should copy them: with `headers` naming the\n * version {@link sdkThemeVersionId} picks.\n *\n * `init` spreads `headers` over its axios defaults, and on a first load nothing\n * re-asserts the version afterwards: TanStack restores the root match's context\n * instead of re-running `rootBeforeLoad` in the browser, so\n * {@link syncSdkThemeVersion} first runs on a client navigation.\n */\nexport function withSdkThemeVersion<T extends Pick<StoreContext, 'headers'>>(settings: T): T {\n const versionId = requestedThemeVersionId();\n if (!versionId) return settings;\n return { ...settings, headers: { ...settings.headers, 's-version-id': versionId } };\n}\n\n/**\n * Push the theme version onto the Salla SDK: the requested one, else the one the\n * current settings name (see {@link sdkThemeVersionId}).\n *\n * The SDK copies `settings.headers` into its axios defaults ONCE, at init, and\n * `s-version-id` is one of them. Settings refetched on the client — the shopper\n * switched market, and each market has its own version — name a different one,\n * and without this every `salla.api.*` call keeps asking for the previous\n * market's version until a full page load. Settings that name no version take\n * the header off instead, so the SDK asks for the live one like the engine's own\n * client does. No-op on the server and until the SDK exposes its api.\n */\nexport function syncSdkThemeVersion(headers: StoreContext['headers']): void {\n const sdk = getSallaSDK();\n if (!sdk) return;\n const versionId = sdkThemeVersionId(headers);\n try {\n if (versionId != null) sdk.api?.setHeader?.('s-version-id', versionId);\n else delete sdk.api?.axios?.defaults?.headers?.common?.['s-version-id'];\n } catch {\n // SDK partially loaded — the header is re-asserted on the next navigation.\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/theme-version.ts","../src/utils/sdk-helpers.ts"],"names":[],"mappings":";;;;AAqCO,SAAS,uBAAA,GAAyC;AACvD,EAAA,MAAM,EAAE,SAAA,EAAU,GAAI,eAAA,EAAgB;AACtC,EAAA,IAAI,WAAW,OAAO,SAAA;AAEtB,EAAA,OAAO,qBAAA,GAAwB,SAAA,IAAa,IAAA;AAC9C;AAmCA,SAAS,YAAA,CAAa,UAA2C,aAAA,EAA8B;AAC7F,EAAA,MAAM,gBAAA,GAAmB,UAAU,gBAAA,IAAoB,IAAA;AACvD,EAAA,IAAI,aAAA,IAAiB,IAAA,EAAM,OAAO,gBAAA,IAAoB,IAAA;AACtD,EAAA,MAAM,eAAA,GAAkB,QAAA,EAAU,KAAA,EAAO,KAAA,EAAO,EAAA;AAChD,EAAA,OAAA,CAAQ,eAAA,IAAmB,IAAA,GAAO,MAAA,CAAO,eAAe,IAAI,gBAAA,MAAsB,aAAA;AACpF;AAEO,SAAS,qBAAA,CAAsB,gBAA+B,IAAA,EAAqB;AACxF,EAAA,MAAM,YAAY,uBAAA,EAAwB;AAC1C,EAAA,IAA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,SAAA,GAAY,gBAAgB,SAAS,CAAA;AAAA,gBACzD,GAAA,CAAI,GAAA,EAAK,OAAO,QAAA,EAAU,OAAA,EAAS,SAAS,cAAc,CAAA;AAAA,EACxE,CAAA,CAAA,MAAQ;AAAA,EAER;AACF","file":"chunk-KY2VNPZX.js","sourcesContent":["/**\n * @fileoverview Which version of the theme's settings to render — the one answer,\n * in one place.\n *\n * A merchant's theme settings are versioned. An ordinary storefront visit names\n * no version and gets the live one; the API decides, and reports it back as\n * `theme.profile.id`. Two surfaces need a different one, and both address it in\n * the URL of an iframe:\n *\n * - the merchant's theme editor at `s.salla.sa/themes/editor/…`, which shows a\n * draft version beside the controls that are editing it;\n * - a partner running the theme locally, whose dev server is the iframe.\n *\n * Written as a module of its own rather than inline at the one call site,\n * because `store-identity.ts` exists for exactly this reason: the identifier a\n * request resolved and the identifier it sent were two different values for\n * days, in two files, and every test passed. A second implementation of this is\n * the bug, not a refactor away from one.\n */\nimport { getRequestStore, getTwilightContext } from '../twilight/context';\nimport type { StoreContext } from '../api/store';\nimport { getInjectedRuntimeEnv } from './runtime-env';\n\n/**\n * The version this request asked for, or null when it asked for none.\n *\n * Deliberately excludes the version the *settings* name. This is the answer to\n * \"what did the caller address?\", and it has to be available before any settings\n * exist — React Query keys are built from it, and a key that means one thing\n * during SSR and another after hydration is how a page refetches everything it\n * was just handed.\n *\n * 1. what the request named, seeded by `twilightMiddleware` on a host permitted\n * to name one;\n * 2. what SSR resolved and published into the head, which is all the browser has\n * once the dispatcher has stripped `?versionId=` from the URL.\n */\nexport function requestedThemeVersionId(): string | null {\n const { versionId } = getRequestStore();\n if (versionId) return versionId;\n\n return getInjectedRuntimeEnv().versionId || null;\n}\n\n/**\n * The version every Salla API call is answered with — what goes in `s-version-id`.\n *\n * The requested version outranks the settings, because a request that named one\n * is the only reason this is ever anything but the live version: falling back to\n * the settings there would let the first answer overwrite the question.\n *\n * The settings' own `theme.profile.id` stays as the fallback, unchanged. It is\n * what this header has always carried, and on an ordinary storefront it still\n * is — it keeps the rest of a page's calls pinned to the version the settings\n * call resolved, rather than letting a version go live mid-render.\n *\n * That pin is only good for the scope the settings were requested with. Each\n * market (scope) has its own version, and the API lets a named version outrank\n * the market's: once the shopper switches market, the loaded settings still\n * describe the previous one, and replaying their version — on the settings call\n * for the new market first of all — gets the previous market's theme back, for\n * good. So the version is replayed only while the active scope is the one the\n * settings were answered for (`store.scope`), which is not always the one they\n * were requested for (`requestedScopeId`): the API falls back to another scope\n * when it does not accept the requested one, and that scope's version must not\n * ride along on the next request for the requested one. With no active scope it\n * is replayed only for settings requested without one. Otherwise nothing is\n * sent and the API picks the version of the scope on the request.\n *\n * `activeScopeId` is passed in by the caller that already resolved the scope for\n * its `s-scope-*` headers.\n *\n * Reading the settings is guarded because `getTwilightContext().settings` throws\n * a `SettingsError` when they have not loaded — which is the normal state on the\n * very first call, the settings call itself.\n */\n/** Whether `settings` were answered for `activeScopeId` (see {@link resolveThemeVersionId}). */\nfunction answersScope(settings: StoreContext | null | undefined, activeScopeId: string | null) {\n const requestedScopeId = settings?.requestedScopeId ?? null;\n if (activeScopeId == null) return requestedScopeId == null;\n const answeredScopeId = settings?.store?.scope?.id;\n return (answeredScopeId != null ? String(answeredScopeId) : requestedScopeId) === activeScopeId;\n}\n\nexport function resolveThemeVersionId(activeScopeId: string | null = null): string | null {\n const requested = requestedThemeVersionId();\n if (requested) return requested;\n\n try {\n const settings = getTwilightContext().settings;\n if (!answersScope(settings, activeScopeId)) return null;\n\n const profileId = settings?.theme?.profile?.id;\n return profileId != null ? String(profileId) : null;\n } catch {\n return null;\n }\n}\n","export type { StoreContext } from '../api/store';\nimport type { StoreContext } from '../api/store';\nimport type { SallaSDK } from '../types/salla-sdk';\nimport { resolveStoreIdentifier } from './store-identity';\nimport { requestedThemeVersionId } from './theme-version';\n\nconst isBrowser = typeof window !== 'undefined';\n\n/**\n * Which store to ask the API about — see {@link resolveStoreIdentifier}.\n *\n * A delegation, not a second implementation. This name is the one on the wire\n * (`api/client.ts` sets the `store-identifier` header from it) and the one\n * themes import from `@salla.sa/twilight-theme-engine/utils`, so it stays; what\n * it must never do again is answer differently from the resolver everything\n * else asks. It had its own copy of the order once, missing the store the\n * request names and preferring the build-time `VITE_STORE_DOMAIN` that a\n * deployed worker does not have — so every published theme sent an empty\n * identifier and rendered \"Store Unavailable\".\n */\nexport function getStoreIdentifier(explicit?: string): string {\n return resolveStoreIdentifier(explicit);\n}\n\n/**\n * Get Salla SDK instance if available\n */\nexport function getSallaSDK(): typeof window.salla | undefined {\n if (!isBrowser) return undefined;\n return window.salla;\n}\n\n/** Dispatched on `window` by the SDK as the last step of loading (twilight `src/index.js`). */\nconst SDK_CREATED_EVENT = 'salla::created';\n\nconst noop = () => {};\n\n/**\n * Whether `window.salla` is the SDK, rather than the stub that stands in for it.\n *\n * ⚠️ `window.salla` exists from the first bytes of the page. The `twilight-init`\n * head script defines it with an `onReady`, so app snippets can queue work, and\n * the SDK — a deferred module — fills it in later. React can hydrate and run\n * effects in between, and there `window.salla?.event.on(…)` passes its `?.` and\n * throws `Cannot read properties of undefined (reading 'on')`.\n *\n * The SDK defines `init` and `event` in one synchronous module evaluation and the\n * stub has neither, so either one means it has loaded.\n */\nfunction isLoaded(sdk: typeof window.salla): sdk is SallaSDK {\n return typeof sdk?.init === 'function' || typeof sdk?.event?.on === 'function';\n}\n\n/** An SDK whose event bus can take a listener — what {@link onSallaEvent} needs. */\nfunction hasEventBus(sdk: typeof window.salla): sdk is SallaSDK {\n return typeof sdk?.event?.on === 'function';\n}\n\n/**\n * Run `callback` with the SDK as soon as it has loaded: now if it has, otherwise\n * when it announces itself.\n *\n * Returns a cancel for an effect's cleanup, so a component that unmounts first\n * never has the callback run. An effect that returned early when the SDK was not\n * there yet never ran again — on a cold load, where hydration beats the SDK, the\n * engine never initialised it at all.\n */\nexport function whenSallaLoaded(callback: (sdk: SallaSDK) => void): () => void {\n return whenSalla(isLoaded, callback);\n}\n\nfunction whenSalla(\n isUsable: (sdk: typeof window.salla) => sdk is SallaSDK,\n callback: (sdk: SallaSDK) => void\n): () => void {\n if (!isBrowser) return noop;\n\n if (isUsable(window.salla)) {\n callback(window.salla);\n return noop;\n }\n\n let settled = false;\n const onCreated = () => {\n const sdk = window.salla;\n if (settled || !isUsable(sdk)) return;\n settled = true;\n window.removeEventListener(SDK_CREATED_EVENT, onCreated);\n callback(sdk);\n };\n window.addEventListener(SDK_CREATED_EVENT, onCreated);\n\n return () => {\n settled = true;\n window.removeEventListener(SDK_CREATED_EVENT, onCreated);\n };\n}\n\n/**\n * Run `callback` once the SDK has loaded **and been initialised** — for work that\n * talks to the API, which needs the store config `init` sets.\n *\n * Loaded is not enough for that: `init` finishes asynchronously, so a cart lookup\n * made the moment the SDK announces itself goes out without a store identifier\n * and is answered `Store Identifier not found`. Returns a cancel, as\n * {@link whenSallaLoaded} does.\n *\n * A rejected `onReady` still runs `callback`, as `useTwilightInit` carries on past\n * one: it means a partial initialisation, and waiting on it would leave the caller\n * waiting for good.\n */\nexport function whenSallaReady(callback: (sdk: SallaSDK) => void): () => void {\n let cancelled = false;\n const cancel = whenSallaLoaded((sdk) => {\n void new Promise((resolve) => resolve(sdk.onReady?.())).catch(noop).then(() => {\n if (!cancelled) callback(sdk);\n });\n });\n return () => {\n cancelled = true;\n cancel();\n };\n}\n\n/**\n * `salla.event.on(name, listener)` once the SDK has loaded. Returns the matching\n * unsubscribe, which also cancels a subscription still waiting for the SDK.\n *\n * Removed from the emitter it was added to, not from whatever `window.salla` is\n * by the time the component unmounts.\n *\n * Waits for an event bus specifically, not for \"loaded\": an SDK is recognised by\n * `init` alone, and subscribing on one without a bus would throw.\n */\nexport function onSallaEvent(name: string, listener: (...args: unknown[]) => void): () => void {\n let bus: SallaSDK['event'] | undefined;\n const cancel = whenSalla(hasEventBus, (sdk) => {\n bus = sdk.event;\n bus.on(name, listener);\n });\n return () => {\n cancel();\n bus?.off?.(name, listener);\n };\n}\n\n/**\n * Push the active route locale onto the Salla SDK.\n *\n * Why this is needed (and why it must run on every navigation):\n * - The SDK seeds its locale from `navigator.language` — the theme sets no `s-lang`\n * cookie or `window.locale` — so an English browser starts the SDK in `en` even on\n * an `/ar` store.\n * - The SDK fixes its axios `accept-language` header ONCE, at init. `salla.lang.setLocale`\n * only swaps UI translations (it never touches the header), and `salla.init()` is a\n * no-op after `Salla.status === 'ready'`, so the header never refreshes on its own.\n * - `profile::info.fetched` (login / profile refresh on navigation) overrides the header\n * to the *account's* language.\n *\n * Net result without this: `salla.api.*` calls (cart/product details) return data in the\n * wrong locale — e.g. English cart item names on `/ar/cart` — intermittently, depending on\n * load order and whether a profile fetch ran. Re-asserting the URL locale here keeps the\n * header correct. No-op on the server and until the SDK exposes the methods.\n */\nexport function syncSdkLocale(locale: string): void {\n const sdk = getSallaSDK();\n if (!sdk || !locale) return;\n try {\n sdk.lang?.setLocale?.(locale);\n sdk.api?.setHeader?.('accept-language', locale);\n // The localization modal swaps `/${user.language_code}/` in the URL on submit;\n // the SDK never sets this locally, so without it the switch reloads the same page.\n sdk.config?.set?.('user.language_code', locale);\n } catch {\n // SDK partially loaded — the header is re-asserted on the next navigation.\n }\n}\n\n/**\n * The `s-version-id` the SDK sends: the version the request named, else the one\n * the settings report.\n *\n * The request outranks the settings here for the reason it does in\n * `resolveThemeVersionId`. `headers['s-version-id']` is the version the API\n * *answered with*, and for a version it cannot reach it reports the live one\n * while rendering defaults. Read alone, a preview's `salla.api.*` calls asked\n * about the live version while the engine's own asked about the previewed one,\n * so one page showed two versions.\n */\nfunction sdkThemeVersionId(headers: StoreContext['headers']): string | null {\n const versionId = requestedThemeVersionId() ?? headers?.['s-version-id'];\n return versionId != null ? String(versionId) : null;\n}\n\n/**\n * Settings as the SDK's `init` should copy them: with `headers` naming the\n * version {@link sdkThemeVersionId} picks.\n *\n * `init` spreads `headers` over its axios defaults, and on a first load nothing\n * re-asserts the version afterwards: TanStack restores the root match's context\n * instead of re-running `rootBeforeLoad` in the browser, so\n * {@link syncSdkThemeVersion} first runs on a client navigation.\n */\nexport function withSdkThemeVersion<T extends Pick<StoreContext, 'headers'>>(settings: T): T {\n const versionId = requestedThemeVersionId();\n if (!versionId) return settings;\n return { ...settings, headers: { ...settings.headers, 's-version-id': versionId } };\n}\n\n/**\n * Push the theme version onto the Salla SDK: the requested one, else the one the\n * current settings name (see {@link sdkThemeVersionId}).\n *\n * The SDK copies `settings.headers` into its axios defaults ONCE, at init, and\n * `s-version-id` is one of them. Settings refetched on the client — the shopper\n * switched market, and each market has its own version — name a different one,\n * and without this every `salla.api.*` call keeps asking for the previous\n * market's version until a full page load. Settings that name no version take\n * the header off instead, so the SDK asks for the live one like the engine's own\n * client does. No-op on the server and until the SDK exposes its api.\n */\nexport function syncSdkThemeVersion(headers: StoreContext['headers']): void {\n const sdk = getSallaSDK();\n if (!sdk) return;\n const versionId = sdkThemeVersionId(headers);\n try {\n if (versionId != null) sdk.api?.setHeader?.('s-version-id', versionId);\n else delete sdk.api?.axios?.defaults?.headers?.common?.['s-version-id'];\n } catch {\n // SDK partially loaded — the header is re-asserted on the next navigation.\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EMPTY_PREVIEW_STATE, DEV_LOOKUP_TIMEOUT_MS, isEditorFrame, normalizePreviewState, DEV_PREVIEW_GLOBAL, DEV_PREVIEW_EVENT, DEV_PREVIEW_ENDPOINT } from './chunk-OXMUPNMH.js';
|
|
2
|
-
import { resolveStoreBase } from './chunk-
|
|
2
|
+
import { resolveStoreBase } from './chunk-PQR776WF.js';
|
|
3
3
|
import { useSyncExternalStore, useEffect, useRef, useMemo } from 'react';
|
|
4
4
|
|
|
5
5
|
var LEGACY_STORAGE_KEY = "twilight:dev-settings";
|
|
@@ -147,7 +147,7 @@ function takeFrameReport(message) {
|
|
|
147
147
|
async function answerLookup(message) {
|
|
148
148
|
const { requestId, source, query } = message;
|
|
149
149
|
try {
|
|
150
|
-
const { lookupInStore } = await import('./store-lookup-
|
|
150
|
+
const { lookupInStore } = await import('./store-lookup-ATPY4J4T.js');
|
|
151
151
|
sendToEditor({ kind: "lookup-result", requestId, items: await lookupInStore(source, query) });
|
|
152
152
|
} catch (error) {
|
|
153
153
|
sendToEditor({
|
|
@@ -500,5 +500,5 @@ function useDevLayoutBlocks(components) {
|
|
|
500
500
|
var useDevHomeBlocks = import.meta.env.DEV ? useDevLayoutBlocks : (components) => components;
|
|
501
501
|
|
|
502
502
|
export { blockPath, devSettingsStore, useDevEditorMeta, useDevHomeBlocks, useDevReportSettingsFetchedAt, useDevSettingsOverrides, useDevSettingsState };
|
|
503
|
-
//# sourceMappingURL=chunk-
|
|
504
|
-
//# sourceMappingURL=chunk-
|
|
503
|
+
//# sourceMappingURL=chunk-LQY6T5AK.js.map
|
|
504
|
+
//# sourceMappingURL=chunk-LQY6T5AK.js.map
|