@salla.sa/twilight-theme-engine 1.0.69 → 1.0.71
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-V5Q4YFK7.js → AddToCartForm-XA5X2C5K.js} +3 -3
- package/dist/{AddToCartForm-V5Q4YFK7.js.map → AddToCartForm-XA5X2C5K.js.map} +1 -1
- package/dist/{BlogAuthorPage-EYCANLF2.js → BlogAuthorPage-YWR52G5S.js} +21 -21
- package/dist/{BlogAuthorPage-EYCANLF2.js.map → BlogAuthorPage-YWR52G5S.js.map} +1 -1
- package/dist/{BlogCategoryPage-HVKYA62V.js → BlogCategoryPage-N644DZTN.js} +21 -21
- package/dist/{BlogCategoryPage-HVKYA62V.js.map → BlogCategoryPage-N644DZTN.js.map} +1 -1
- package/dist/{BlogPage-CQLHFLXK.js → BlogPage-5Z4X3Y2H.js} +19 -19
- package/dist/{BlogPage-CQLHFLXK.js.map → BlogPage-5Z4X3Y2H.js.map} +1 -1
- package/dist/{BlogSinglePage-Y4GTYEX5.js → BlogSinglePage-NSNVBBUS.js} +19 -19
- package/dist/{BlogSinglePage-Y4GTYEX5.js.map → BlogSinglePage-NSNVBBUS.js.map} +1 -1
- package/dist/{BlogTagPage-7BHVS4M2.js → BlogTagPage-GRYZRHDL.js} +21 -21
- package/dist/{BlogTagPage-7BHVS4M2.js.map → BlogTagPage-GRYZRHDL.js.map} +1 -1
- package/dist/{BrandsPage-ZJWQFMLT.js → BrandsPage-3Q4ZYOT7.js} +20 -20
- package/dist/{BrandsPage-ZJWQFMLT.js.map → BrandsPage-3Q4ZYOT7.js.map} +1 -1
- package/dist/{Breadcrumb-VQQDHSCR.js → Breadcrumb-WNSVFI75.js} +19 -19
- package/dist/{Breadcrumb-VQQDHSCR.js.map → Breadcrumb-WNSVFI75.js.map} +1 -1
- package/dist/{CartItem-3LBPOY7V.js → CartItem-A66ZG64I.js} +19 -19
- package/dist/{CartItem-3LBPOY7V.js.map → CartItem-A66ZG64I.js.map} +1 -1
- package/dist/{CartSummary-4L7L3566.js → CartSummary-BQC2IGQD.js} +19 -19
- package/dist/{CartSummary-4L7L3566.js.map → CartSummary-BQC2IGQD.js.map} +1 -1
- package/dist/{Copyright-PPGYFGPF.js → Copyright-UNROFFOC.js} +4 -4
- package/dist/{Copyright-PPGYFGPF.js.map → Copyright-UNROFFOC.js.map} +1 -1
- package/dist/{CustomerLayout-HWBZ54GG.js → CustomerLayout-TKS5QZMJ.js} +19 -19
- package/dist/{CustomerLayout-HWBZ54GG.js.map → CustomerLayout-TKS5QZMJ.js.map} +1 -1
- package/dist/{Footer-Q5EZE6RQ.js → Footer-2WD77PFB.js} +19 -19
- package/dist/{Footer-Q5EZE6RQ.js.map → Footer-2WD77PFB.js.map} +1 -1
- package/dist/{Header-Y3KW2LCJ.js → Header-3BANLNYK.js} +8 -8
- package/dist/{Header-Y3KW2LCJ.js.map → Header-3BANLNYK.js.map} +1 -1
- package/dist/{LoyaltyPage-SLRGEINN.js → LoyaltyPage-OAGJLFD2.js} +19 -19
- package/dist/{LoyaltyPage-SLRGEINN.js.map → LoyaltyPage-OAGJLFD2.js.map} +1 -1
- package/dist/{LoyaltyPointsPage-ELOIXQJH.js → LoyaltyPointsPage-G5FB2QTQ.js} +3 -3
- package/dist/{LoyaltyPointsPage-ELOIXQJH.js.map → LoyaltyPointsPage-G5FB2QTQ.js.map} +1 -1
- package/dist/{MainMenu-IVZDV6HY.js → MainMenu-FFLJR2EK.js} +9 -10
- package/dist/MainMenu-FFLJR2EK.js.map +1 -0
- package/dist/{MasterLayout-GKZ5F73U.js → MasterLayout-H54QAUUY.js} +19 -19
- package/dist/{MasterLayout-GKZ5F73U.js.map → MasterLayout-H54QAUUY.js.map} +1 -1
- package/dist/{MobileMenu-SCAWSSXT.js → MobileMenu-OVAY7EFJ.js} +20 -20
- package/dist/{MobileMenu-SCAWSSXT.js.map → MobileMenu-OVAY7EFJ.js.map} +1 -1
- package/dist/{NotificationsPage-O42AKXIZ.js → NotificationsPage-SEAEJEE7.js} +19 -19
- package/dist/{NotificationsPage-O42AKXIZ.js.map → NotificationsPage-SEAEJEE7.js.map} +1 -1
- package/dist/{OrderSinglePage-R7Z2YDO4.js → OrderSinglePage-L7OCFF7N.js} +20 -20
- package/dist/{OrderSinglePage-R7Z2YDO4.js.map → OrderSinglePage-L7OCFF7N.js.map} +1 -1
- package/dist/{OrdersPage-DHV7YH7A.js → OrdersPage-IOEC2JR2.js} +19 -19
- package/dist/{OrdersPage-DHV7YH7A.js.map → OrdersPage-IOEC2JR2.js.map} +1 -1
- package/dist/{PageSingle-TH4W7HCK.js → PageSingle-YYUIJVFP.js} +8 -9
- package/dist/PageSingle-YYUIJVFP.js.map +1 -0
- package/dist/{ProductDetails-JC4V7MIG.js → ProductDetails-KSB3OC25.js} +4 -4
- package/dist/{ProductDetails-JC4V7MIG.js.map → ProductDetails-KSB3OC25.js.map} +1 -1
- package/dist/{ProfilePage-F5NO3B4C.js → ProfilePage-SVQRTF55.js} +19 -19
- package/dist/{ProfilePage-F5NO3B4C.js.map → ProfilePage-SVQRTF55.js.map} +1 -1
- package/dist/{SeoCartWidget-GSGSRTJN.js → SeoCartWidget-G4Y4NRMH.js} +19 -19
- package/dist/{SeoCartWidget-GSGSRTJN.js.map → SeoCartWidget-G4Y4NRMH.js.map} +1 -1
- package/dist/{SettingsPage-BYYBYEEQ.js → SettingsPage-ZVBMBGZL.js} +19 -19
- package/dist/{SettingsPage-BYYBYEEQ.js.map → SettingsPage-ZVBMBGZL.js.map} +1 -1
- package/dist/{StoreClosedNotification-TMVQPUSU.js → StoreClosedNotification-PRXVWUV7.js} +20 -20
- package/dist/{StoreClosedNotification-TMVQPUSU.js.map → StoreClosedNotification-PRXVWUV7.js.map} +1 -1
- package/dist/{TestimonialsPage-WXSORMJA.js → TestimonialsPage-QENPQ2JK.js} +8 -9
- package/dist/TestimonialsPage-QENPQ2JK.js.map +1 -0
- package/dist/{ThankYouPage-FVWY3VBU.js → ThankYouPage-GB6M5I4Z.js} +19 -19
- package/dist/{ThankYouPage-FVWY3VBU.js.map → ThankYouPage-GB6M5I4Z.js.map} +1 -1
- package/dist/{WalletPage-XYU47SH2.js → WalletPage-IG5B33XQ.js} +20 -20
- package/dist/{WalletPage-XYU47SH2.js.map → WalletPage-IG5B33XQ.js.map} +1 -1
- package/dist/{WishlistPage-GHMUTPSM.js → WishlistPage-SYNLUIGO.js} +21 -21
- package/dist/{WishlistPage-GHMUTPSM.js.map → WishlistPage-SYNLUIGO.js.map} +1 -1
- package/dist/api/apps.js +4 -5
- package/dist/api/brands.js +5 -6
- package/dist/api/cart.js +5 -6
- package/dist/api/category.js +5 -6
- package/dist/api/client.js +3 -4
- package/dist/api/home.js +4 -5
- package/dist/api/loyalty.js +5 -6
- package/dist/api/menu.js +4 -5
- package/dist/api/notification.js +4 -5
- package/dist/api/order.js +5 -6
- package/dist/api/page.js +5 -6
- package/dist/api/product.js +5 -6
- package/dist/api/profile.js +3 -4
- package/dist/api/profile.js.map +1 -1
- package/dist/api/store.js +4 -5
- package/dist/api/translations.js +4 -5
- package/dist/api/user.js +4 -5
- package/dist/api/wishlist.js +6 -7
- package/dist/{chunk-5NUQ6UAK.js → chunk-2JL4S2LE.js} +6 -6
- package/dist/{chunk-5NUQ6UAK.js.map → chunk-2JL4S2LE.js.map} +1 -1
- package/dist/chunk-3IHFA2X5.js +33 -0
- package/dist/chunk-3IHFA2X5.js.map +1 -0
- package/dist/{chunk-KPEG5XY3.js → chunk-4YHSQSM6.js} +4 -4
- package/dist/{chunk-KPEG5XY3.js.map → chunk-4YHSQSM6.js.map} +1 -1
- package/dist/{chunk-634A6AYN.js → chunk-5H4NIOTY.js} +4 -4
- package/dist/{chunk-634A6AYN.js.map → chunk-5H4NIOTY.js.map} +1 -1
- package/dist/{chunk-FZH27PXS.js → chunk-5HOD4BKK.js} +3 -3
- package/dist/{chunk-FZH27PXS.js.map → chunk-5HOD4BKK.js.map} +1 -1
- package/dist/{chunk-66JAXHHY.js → chunk-5O6PTKI5.js} +3 -3
- package/dist/{chunk-66JAXHHY.js.map → chunk-5O6PTKI5.js.map} +1 -1
- package/dist/{chunk-G73YJT4F.js → chunk-6F5QZKIY.js} +7 -7
- package/dist/{chunk-G73YJT4F.js.map → chunk-6F5QZKIY.js.map} +1 -1
- package/dist/{chunk-X3GCZAOZ.js → chunk-7BGEGHAI.js} +3 -3
- package/dist/{chunk-X3GCZAOZ.js.map → chunk-7BGEGHAI.js.map} +1 -1
- package/dist/{chunk-KRUPRDOL.js → chunk-7PYHB3PP.js} +4 -4
- package/dist/{chunk-KRUPRDOL.js.map → chunk-7PYHB3PP.js.map} +1 -1
- package/dist/{chunk-DWIS2VUE.js → chunk-7W7SLN5M.js} +4 -4
- package/dist/{chunk-DWIS2VUE.js.map → chunk-7W7SLN5M.js.map} +1 -1
- package/dist/{chunk-CUKPKJCF.js → chunk-A32NANNC.js} +3 -3
- package/dist/{chunk-CUKPKJCF.js.map → chunk-A32NANNC.js.map} +1 -1
- package/dist/{chunk-VR4FXFPY.js → chunk-BQURS54V.js} +43 -18
- package/dist/chunk-BQURS54V.js.map +1 -0
- package/dist/{chunk-YNWP5VPR.js → chunk-DIVEHHMD.js} +3 -3
- package/dist/{chunk-YNWP5VPR.js.map → chunk-DIVEHHMD.js.map} +1 -1
- package/dist/{chunk-BRZ74D5D.js → chunk-DY5WGKDX.js} +4 -4
- package/dist/{chunk-BRZ74D5D.js.map → chunk-DY5WGKDX.js.map} +1 -1
- package/dist/{chunk-IDRGC4LA.js → chunk-DZDSTTHW.js} +7 -7
- package/dist/{chunk-IDRGC4LA.js.map → chunk-DZDSTTHW.js.map} +1 -1
- package/dist/{chunk-DCH3X6TO.js → chunk-E7PYHBCX.js} +4 -4
- package/dist/{chunk-DCH3X6TO.js.map → chunk-E7PYHBCX.js.map} +1 -1
- package/dist/{chunk-EARXTU6P.js → chunk-FGROIU3Y.js} +3 -3
- package/dist/{chunk-EARXTU6P.js.map → chunk-FGROIU3Y.js.map} +1 -1
- package/dist/{chunk-GEQKQQND.js → chunk-GTG22RZG.js} +3 -3
- package/dist/{chunk-GEQKQQND.js.map → chunk-GTG22RZG.js.map} +1 -1
- package/dist/{chunk-AMASCYNB.js → chunk-GVJHDJW7.js} +9 -8
- package/dist/chunk-GVJHDJW7.js.map +1 -0
- package/dist/{chunk-44ZVB7F5.js → chunk-H2DXJCJP.js} +4 -4
- package/dist/{chunk-44ZVB7F5.js.map → chunk-H2DXJCJP.js.map} +1 -1
- package/dist/{chunk-2XGQSJKH.js → chunk-HBTIZWT2.js} +3 -3
- package/dist/{chunk-2XGQSJKH.js.map → chunk-HBTIZWT2.js.map} +1 -1
- package/dist/chunk-IHZVVSPW.js +14 -0
- package/dist/{chunk-HURQEDJZ.js.map → chunk-IHZVVSPW.js.map} +1 -1
- package/dist/{chunk-OVYCFJGU.js → chunk-ILMX45PO.js} +6 -6
- package/dist/{chunk-OVYCFJGU.js.map → chunk-ILMX45PO.js.map} +1 -1
- package/dist/{chunk-AEPBDT5F.js → chunk-IXG6BF2M.js} +35 -15
- package/dist/chunk-IXG6BF2M.js.map +1 -0
- package/dist/chunk-J427UFSZ.js +186 -0
- package/dist/chunk-J427UFSZ.js.map +1 -0
- package/dist/{chunk-SBXD5CSG.js → chunk-LDMLFJGQ.js} +4 -4
- package/dist/{chunk-SBXD5CSG.js.map → chunk-LDMLFJGQ.js.map} +1 -1
- package/dist/{chunk-YKWNH4S2.js → chunk-LGT3T7VF.js} +4 -4
- package/dist/{chunk-YKWNH4S2.js.map → chunk-LGT3T7VF.js.map} +1 -1
- package/dist/{chunk-SR4OTLTJ.js → chunk-LPQFTXBB.js} +9 -3
- package/dist/chunk-LPQFTXBB.js.map +1 -0
- package/dist/{chunk-SVPXQCOA.js → chunk-MISI3T6V.js} +4 -3
- package/dist/chunk-MISI3T6V.js.map +1 -0
- package/dist/{chunk-2D5HJQZK.js → chunk-MSUGP566.js} +4 -4
- package/dist/{chunk-2D5HJQZK.js.map → chunk-MSUGP566.js.map} +1 -1
- package/dist/{chunk-GL6QTNZA.js → chunk-N3BSUMD7.js} +3 -3
- package/dist/{chunk-GL6QTNZA.js.map → chunk-N3BSUMD7.js.map} +1 -1
- package/dist/{chunk-URWXE2RQ.js → chunk-NFE2H5JE.js} +5 -5
- package/dist/{chunk-URWXE2RQ.js.map → chunk-NFE2H5JE.js.map} +1 -1
- package/dist/{chunk-P6CLO4M7.js → chunk-OGVUFMLX.js} +3 -3
- package/dist/{chunk-P6CLO4M7.js.map → chunk-OGVUFMLX.js.map} +1 -1
- package/dist/{chunk-RMFDKT5P.js → chunk-P6EOXGUE.js} +4 -4
- package/dist/{chunk-RMFDKT5P.js.map → chunk-P6EOXGUE.js.map} +1 -1
- package/dist/{chunk-TYLKNVQA.js → chunk-QVJDYSCT.js} +89 -4
- package/dist/chunk-QVJDYSCT.js.map +1 -0
- package/dist/{chunk-M5WPU7BR.js → chunk-R2BAI6QI.js} +5 -5
- package/dist/{chunk-M5WPU7BR.js.map → chunk-R2BAI6QI.js.map} +1 -1
- package/dist/{chunk-4YWBXQV5.js → chunk-R5MZV6KW.js} +4 -4
- package/dist/{chunk-4YWBXQV5.js.map → chunk-R5MZV6KW.js.map} +1 -1
- package/dist/{chunk-SSPAMQRV.js → chunk-SDIQHTDG.js} +4 -4
- package/dist/{chunk-SSPAMQRV.js.map → chunk-SDIQHTDG.js.map} +1 -1
- package/dist/{chunk-W5MS4UNG.js → chunk-USN5NHJ5.js} +3 -3
- package/dist/{chunk-W5MS4UNG.js.map → chunk-USN5NHJ5.js.map} +1 -1
- package/dist/{chunk-6ETNDIHM.js → chunk-VX2T7JCB.js} +4 -5
- package/dist/chunk-VX2T7JCB.js.map +1 -0
- package/dist/{chunk-OJW6UOS4.js → chunk-VYJDRAWX.js} +3 -3
- package/dist/{chunk-OJW6UOS4.js.map → chunk-VYJDRAWX.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 +17 -17
- package/dist/components/home/index.js +21 -21
- package/dist/components/layout/index.js +1 -1
- package/dist/components/product/ProductGallery.d.ts.map +1 -1
- package/dist/components/product/index.js +18 -18
- package/dist/components/store/index.js +19 -19
- package/dist/components/toast/Toaster.d.ts.map +1 -1
- package/dist/components/toast/index.js +6 -1
- package/dist/components/toast/index.js.map +1 -1
- package/dist/components/tracking/index.js +1 -1
- package/dist/document-class-7U45CO5V.js +25 -0
- package/dist/{document-class-NUILLVSR.js.map → document-class-7U45CO5V.js.map} +1 -1
- package/dist/hooks/index.js +17 -17
- package/dist/hooks/useBlogLike.js +1 -1
- package/dist/hooks/useComments.js +3 -4
- package/dist/hooks/useGtm.js +17 -17
- package/dist/hooks/useMoney.js +17 -17
- package/dist/hooks/useProduct.js +3 -4
- package/dist/hooks/useStore.js +17 -17
- package/dist/hooks/useUser.js +5 -6
- package/dist/index.js +17 -17
- package/dist/native-app/index.d.ts +27 -0
- package/dist/native-app/index.d.ts.map +1 -0
- package/dist/native-app/index.js +8 -0
- package/dist/native-app/index.js.map +1 -0
- package/dist/{navigation-F2TD5X2P.js → navigation-P3GZOWUU.js} +8 -7
- package/dist/{navigation-F2TD5X2P.js.map → navigation-P3GZOWUU.js.map} +1 -1
- package/dist/{navigation-CJHPA74M.js → navigation-TA3I3XEC.js} +5 -5
- package/dist/{navigation-CJHPA74M.js.map → navigation-TA3I3XEC.js.map} +1 -1
- package/dist/{not-found-63YCT7SJ.js → not-found-W7RACNK7.js} +20 -20
- package/dist/{not-found-63YCT7SJ.js.map → not-found-W7RACNK7.js.map} +1 -1
- package/dist/providers/TwilightProvider.d.ts.map +1 -1
- package/dist/providers/index.js +17 -17
- package/dist/providers/native-safe-area.d.ts +13 -0
- package/dist/providers/native-safe-area.d.ts.map +1 -0
- package/dist/routes/account/orders.js +6 -7
- package/dist/routes/account.js +15 -16
- package/dist/routes/account.js.map +1 -1
- package/dist/routes/blog.js +10 -11
- package/dist/routes/blog.js.map +1 -1
- package/dist/routes/brands.js +6 -7
- package/dist/routes/brands.js.map +1 -1
- package/dist/routes/cart.js +25 -25
- package/dist/routes/home.js +22 -22
- package/dist/routes/index.js +4 -4
- package/dist/routes/loyalty.js +7 -8
- package/dist/routes/loyalty.js.map +1 -1
- package/dist/routes/page.js +6 -7
- package/dist/routes/page.js.map +1 -1
- package/dist/routes/product-listing.js +23 -23
- package/dist/routes/product.js +21 -21
- package/dist/routes/root/head.d.ts.map +1 -1
- package/dist/routes/seo-redirects.js +3 -3
- package/dist/routes/testimonials.js +1 -1
- package/dist/routes/thank-you.js +6 -7
- package/dist/routes/thank-you.js.map +1 -1
- package/dist/skeleton.js +22 -22
- package/dist/tanstack/native-app-events.d.ts +18 -0
- package/dist/tanstack/native-app-events.d.ts.map +1 -0
- package/dist/tanstack/navigation.d.ts.map +1 -1
- package/dist/tanstack.js +17 -17
- package/dist/utils/index.js +4 -5
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/store-base.d.ts +9 -0
- package/dist/utils/store-base.d.ts.map +1 -1
- package/dist/vite/index.js +1 -0
- package/dist/vite/index.js.map +1 -1
- package/dist/vite/plugins/package-aliases.plugin.d.ts.map +1 -1
- package/package.json +5 -1
- package/dist/MainMenu-IVZDV6HY.js.map +0 -1
- package/dist/PageSingle-TH4W7HCK.js.map +0 -1
- package/dist/TestimonialsPage-WXSORMJA.js.map +0 -1
- package/dist/chunk-6ETNDIHM.js.map +0 -1
- package/dist/chunk-AEPBDT5F.js.map +0 -1
- package/dist/chunk-AMASCYNB.js.map +0 -1
- package/dist/chunk-GNH3W6T4.js +0 -114
- package/dist/chunk-GNH3W6T4.js.map +0 -1
- package/dist/chunk-HURQEDJZ.js +0 -14
- package/dist/chunk-RCHTHIIZ.js +0 -90
- package/dist/chunk-RCHTHIIZ.js.map +0 -1
- package/dist/chunk-SR4OTLTJ.js.map +0 -1
- package/dist/chunk-SVPXQCOA.js.map +0 -1
- package/dist/chunk-TYLKNVQA.js.map +0 -1
- package/dist/chunk-VR4FXF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AM,OAAO,QAAA,CAAS,KAAK,CAAA,GAAI,CAAA,CAAA,EAAI,KAAK,CAAA,CAAA,GAAK,GAAA;AAC7C,EAAA,IAAA,CAAK,SAAS,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA,IAAK,GAAA,MAAS,MAAM,OAAO,IAAA;AAE1D,EAAA,MAAM,cAAc,CAAC,IAAA,KAAkB,OAAO,eAAA,CAAgB,IAAA,EAAM,IAAI,CAAA,GAAI,IAAA;AAC5E,EAAA,MAAM,QAAA,GAAW,GAAG,MAAM,CAAA,EAAG,YAAY,QAAQ,CAAC,GAAG,SAAS,CAAA,CAAA;AAC9D,EAAA,OAAO,GAAG,WAAA,CAAY,IAAI,CAAC,CAAA,aAAA,EAAgB,kBAAA,CAAmB,QAAQ,CAAC,CAAA,CAAA;AACzE","file":"chunk-LPQFTXBB.js","sourcesContent":["import { isLocale } from '../providers/locale-constants';\n\nexport const AUTH_TOKEN_COOKIE_NAME = 'token';\nexport const SCOPE_COOKIE_NAME = 'scope';\n\n/**\n * Which store this request is for, when the hostname does not say.\n *\n * A live storefront is reached at its own domain, so the hostname identifies it\n * and nothing else is needed. A preview is not: every theme under review is\n * served from the one preview hostname, so the store has to be named some other\n * way — the dispatcher takes it from `?storeId=` and puts it here, the same way\n * it remembers which theme to serve.\n *\n * Written by the dispatcher rather than the theme, and set on the *forwarded\n * request* as well as the response, because the response cookie only arrives in\n * time for the second page load and the first one has to render too.\n *\n * The literal is a contract with `STORE_COOKIE` in store-front-dispacher\n * (`src/dispatch/preview.ts`), and **nothing checks the two agree**. Drift does\n * not fail loudly — it renders somebody else's shop. Grep both repos before\n * changing it.\n */\nexport const STORE_ID_COOKIE_NAME = 'salla_sid';\n\n/** Query parameter naming the store, on a host that serves more than one. */\nexport const STORE_ID_PARAM = 'storeId';\n\n/**\n * Which version of the theme's settings to render.\n *\n * A merchant's theme settings are versioned, and the storefront normally shows\n * whichever version is live — the API answers with it, and names it back as\n * `theme.profile.id`. Two places need a different one: the merchant's own theme\n * editor, which previews a draft version before it is published, and a partner\n * running a theme locally against a store whose settings they are editing. Both\n * open the theme inside an iframe, and the version travels in that URL.\n *\n * Named `versionId` rather than the `version_id` the Dashboard uses internally,\n * because it sits beside `?storeId=` and one URL should not spell two ids two\n * ways. The value is the same one either way: the Optimus-encoded version id,\n * which is exactly what `s-version-id` has always carried.\n *\n * The literal is a contract with `VERSION_COOKIE` in store-front-dispacher\n * (`src/dispatch/preview.ts`), on the same terms as {@link STORE_ID_COOKIE_NAME}:\n * nothing checks the two agree, and drift shows a merchant the wrong version of\n * their own settings rather than failing.\n */\nexport const VERSION_ID_COOKIE_NAME = 'salla_vid';\n\n/** Query parameter naming the theme-settings version, where one may be named. */\nexport const VERSION_ID_PARAM = 'versionId';\n\n/**\n * An id named by a request is an integer, and anything else is not one.\n *\n * Validated rather than passed through because these values end up in an upstream\n * API path and header. Leading zeroes, signs, decimals and whitespace are all\n * rejected: the point is a single canonical form, not the widest set of things\n * that could be coerced into a number.\n *\n * One function for both ids on purpose. They arrive the same way, from the same\n * untrusted place, and are spent the same way; two copies of this rule would be\n * two chances for one of them to be relaxed on its own.\n */\nfunction parseRequestId(raw: string | null | undefined): string | null {\n if (!raw) return null;\n return /^[1-9][0-9]{0,18}$/.test(raw) ? raw : null;\n}\n\n/** A store id in its canonical form, or null when it is not one. */\nexport function parseStoreId(raw: string | null | undefined): string | null {\n return parseRequestId(raw);\n}\n\n/** A theme-settings version id in its canonical form, or null when it is not one. */\nexport function parseVersionId(raw: string | null | undefined): string | null {\n return parseRequestId(raw);\n}\n\n/** The store id the dispatcher left in the cookie, or null when absent or malformed. */\nexport function extractStoreIdFromCookies(cookieHeader: string | null): string | null {\n return parseStoreId(extractTokenFromCookies(cookieHeader, STORE_ID_COOKIE_NAME));\n}\n\n/** The version id the dispatcher left in the cookie, or null when absent or malformed. */\nexport function extractVersionIdFromCookies(cookieHeader: string | null): string | null {\n return parseVersionId(extractTokenFromCookies(cookieHeader, VERSION_ID_COOKIE_NAME));\n}\n\n/**\n * The only hosts on which a request may name its own store.\n *\n * **This is a security boundary, not a convenience.** On a merchant's own domain\n * the hostname *is* the store, and it is the only thing that may decide. A theme\n * that also honoured `?storeId=` there would let anyone open\n * `https://reefperfumes.com/?storeId=<someone else>` and be served a different\n * merchant's shop from the domain its owner controls — their branding, their\n * customers' address bar, somebody else's catalogue — and the cookie would keep\n * serving it for the rest of that browser's session. Salla points SaaS domains\n * at this dispatcher, so those hostnames are real and reachable.\n *\n * The override exists for one situation: a host that serves many stores and so\n * cannot identify one from its name. That is the preview host, where every theme\n * under review answers on the same address, and local development.\n *\n * Adding an entry grants that host the ability to render any store on request.\n * Add nothing that a merchant's traffic reaches.\n */\nexport const STORE_ID_HOSTS: readonly string[] = ['preview.salla.design'];\n\n/** The hostname alone — a port never distinguishes one host's authority from another's. */\nfunction hostnameOf(host: string): string {\n const trimmed = host.trim().toLowerCase();\n // IPv6 literals are bracketed, and the colons inside them are not a port.\n if (trimmed.startsWith('[')) return trimmed.slice(0, trimmed.indexOf(']') + 1) || trimmed;\n const colon = trimmed.indexOf(':');\n return colon === -1 ? trimmed : trimmed.slice(0, colon);\n}\n\nexport function isLoopback(hostname: string): boolean {\n return (\n hostname === 'localhost' ||\n hostname === '127.0.0.1' ||\n hostname === '[::1]' ||\n hostname.endsWith('.localhost')\n );\n}\n\n/**\n * Whether this host is allowed to let the request choose a store.\n *\n * Deliberately an allowlist of exact hostnames plus loopback. No suffix matching:\n * a rule like \"anything ending in salla.design\" is one wildcard DNS record away\n * from admitting a host nobody meant to admit, and the list of hosts that serve\n * more than one store is short and known.\n *\n * It gates {@link resolveRequestVersionId} as well, and the name has been left\n * alone rather than generalised because one predicate that both call is the\n * property worth keeping — a second, subtly different list is how a host ends up\n * permitted to name one thing and not the other. A version is worth gating for\n * the same reason a store is: on a merchant's own domain, honouring\n * `?versionId=` would publish whatever draft settings they are still working on\n * to anyone who guessed the URL.\n */\nexport function allowsRequestStoreId(host: string | null | undefined): boolean {\n if (!host) return false;\n const hostname = hostnameOf(host);\n return STORE_ID_HOSTS.includes(hostname) || isLoopback(hostname);\n}\n\n/**\n * Whether this host *is* a store, so its name can be used as the identifier.\n *\n * The exact inverse of {@link allowsRequestStoreId}, and deliberately written as\n * one so the two can never disagree: a host that may name its store is a host\n * that serves more than one, and a host that serves more than one cannot be the\n * answer to \"which store is this?\". `preview.salla.design` and `localhost:5188`\n * are not shops; asking the API about them earns a 422 and a page that reads as\n * a broken theme.\n */\nexport function hostIdentifiesStore(host: string | null | undefined): boolean {\n return Boolean(host) && !allowsRequestStoreId(host);\n}\n\n/**\n * The store this request names, on a host permitted to name one.\n *\n * The host check is inside the resolution rather than at a call site, because a\n * call site is a thing someone can add without reading this comment. There is no\n * way to ask \"what store did the request name?\" without also asking \"is this a\n * host that may say?\" — get it wrong and the answer is a security bug that looks\n * like a feature.\n *\n * Between the two permitted sources the URL wins, the same precedence the\n * dispatcher uses for the theme and for the same reason: a link is how someone\n * switches, and a cookie they cannot see should never beat the address they\n * just typed.\n */\nexport function resolveRequestStoreId(\n url: string,\n cookieHeader: string | null,\n host: string | null | undefined\n): string | null {\n return resolveRequestId(url, cookieHeader, host, STORE_ID_PARAM, STORE_ID_COOKIE_NAME);\n}\n\n/**\n * A store username as it can appear as the first segment of a path.\n *\n * Starts with a letter or digit, so nothing the platform mounts at the root of a\n * host — `/_serverFn/`, `/.well-known/` — is ever read as a store. Dots are allowed\n * (`zyros.sa`), but a root file (`/favicon.ico`, `/robots.txt`) is not a store.\n * The value is sent upstream as the `store-identifier` header, so the set is kept\n * narrow on purpose: a username outside it cannot be addressed by path, and\n * `?storeId=` still can.\n */\nconst STORE_BASE_SEGMENT = /^[a-z0-9][a-z0-9._-]{0,62}$/i;\nconst ROOT_FILE =\n /\\.(ico|txt|xml|json|webmanifest|html?|js|mjs|css|map|png|jpe?g|gif|svg|webp|avif|woff2?|ttf|otf|eot|pdf|mp4|webm|wasm)$/i;\n\n/**\n * Whether this could be a store's username in the first segment of a path.\n *\n * A supported locale code never is, in any case: `/ar` and `/EN` are languages,\n * so `preview.salla.design/en/cart` is the English cart of the store the cookie\n * names. That makes a store whose username is a locale code (`ar` is one)\n * unreachable by path; `?storeId=` still reaches it.\n *\n * The same predicate decides whether a username may become a path's root\n * (`storeBaseRedirectHref`). That is what stops the redirect from looping: a\n * store called `ar`, sent to `/ar/…`, would find no store there and be sent again.\n */\nexport function isStoreBaseSegment(value: string | null | undefined): value is string {\n return (\n typeof value === 'string' &&\n STORE_BASE_SEGMENT.test(value) &&\n !ROOT_FILE.test(value) &&\n !isLocale(value.toLowerCase())\n );\n}\n\n/**\n * The store the first segment of this request's path names, on a host permitted\n * to name one.\n *\n * On such a host the first segment **is** the store. It is the root of the\n * application there, so `https://preview.salla.design/mtgr-alaatr-2/cart` is the\n * cart of the store whose username is `mtgr-alaatr-2`. This is a rule rather than\n * a guess, and it has to be: `cart`, `offers` and `search` are all real store\n * usernames, so a store cannot be told from a page by looking at the segment.\n * `/cart` on these hosts is the store called `cart`.\n *\n * The one segment that is not a store is a supported locale code (see\n * {@link isStoreBaseSegment}). `/ar/cart` names a language, and the store comes\n * from the cookie or `VITE_STORE_DOMAIN`, as it would at `/`.\n *\n * A URL that carries `storeId` is not read this way at all, whatever its value.\n * That is how `salla theme dev` names a store (`/ar?storeId=…`), on a path that\n * begins with a page; the root loader then redirects to the store's own address.\n * Checking for a *valid* id instead would let a malformed one hand the page's\n * first segment the store's job. (On the preview host the dispatcher removes the\n * parameter and sends a cookie; the editor opens that host at `/`, where there is\n * no segment to read.)\n *\n * Same gate as {@link resolveRequestStoreId}, for the same reason: on a merchant's\n * own domain the hostname is the store and the path is only ever a page.\n */\nexport function resolveRequestStoreBase(\n url: string,\n host: string | null | undefined\n): string | null {\n if (!allowsRequestStoreId(host)) return null;\n\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return null;\n }\n if (parsed.searchParams.has(STORE_ID_PARAM)) return null;\n\n const first = parsed.pathname.split('/')[1];\n return isStoreBaseSegment(first) ? first : null;\n}\n\n/** Which store a request addressed, and how. At most one of the two is set. */\nexport interface RequestStore {\n /** Named by `?storeId=`, or by the cookie remembering it. */\n storeId: string | null;\n /** Named by the first segment of the path. */\n storeBase: string | null;\n}\n\n/**\n * The store this request addressed: the query, then the path, then the cookie.\n *\n * The path outranks the cookie because it is the address the visitor can see.\n * The cookie is one value for the whole preview host, so with two stores open in\n * two tabs it names whichever was opened last; the path names the one in front\n * of them.\n */\nexport function resolveRequestStore(\n url: string,\n cookieHeader: string | null,\n host: string | null | undefined\n): RequestStore {\n const storeBase = resolveRequestStoreBase(url, host);\n return {\n storeBase,\n storeId: storeBase ? null : resolveRequestStoreId(url, cookieHeader, host),\n };\n}\n\n/**\n * The theme-settings version this request names, on a host permitted to name one.\n *\n * Same shape and the same host gate as {@link resolveRequestStoreId}, deliberately:\n * both answer \"what did this request ask to be shown?\", both are reached only on\n * a host that serves more than one thing, and a version that could be named where\n * a store could not would be a second rule to keep in step with the first.\n *\n * Null is the ordinary answer, and it is not a failure — it means nothing\n * addressed a version, so the store's own live one is what gets rendered.\n */\nexport function resolveRequestVersionId(\n url: string,\n cookieHeader: string | null,\n host: string | null | undefined\n): string | null {\n return resolveRequestId(url, cookieHeader, host, VERSION_ID_PARAM, VERSION_ID_COOKIE_NAME);\n}\n\n/**\n * The id this request names, from the query first and the cookie after.\n *\n * The host check lives here rather than at either call site, for the reason the\n * two wrappers above are wrappers at all: there must be no way to ask what a\n * request named without also asking whether this host may say.\n */\nfunction resolveRequestId(\n url: string,\n cookieHeader: string | null,\n host: string | null | undefined,\n param: string,\n cookieName: string\n): string | null {\n if (!allowsRequestStoreId(host)) return null;\n\n let fromQuery: string | null = null;\n try {\n fromQuery = parseRequestId(new URL(url).searchParams.get(param));\n } catch {\n /* a relative or malformed URL simply names nothing */\n }\n return fromQuery ?? parseRequestId(extractTokenFromCookies(cookieHeader, cookieName));\n}\n\n/**\n * Deletes the auth `token` cookie. This cookie is written client-side by the theme\n * (TwilightProvider), not by the SDK — `salla.cookie.clearAll()` only clears its own\n * allowlist and leaves `token` behind — so logout must clear it here. Client-only.\n */\n/**\n * On a dev server, remembers the store the page is showing, so a later URL that\n * names no store keeps it instead of falling back to `VITE_STORE_DOMAIN`.\n * Loopback only: on the preview host this cookie belongs to the dispatcher. Client-only.\n */\nexport function rememberDevStoreId(id: string | number | null | undefined): void {\n if (typeof document === 'undefined' || !isLoopback(window.location.hostname)) return;\n const storeId = parseStoreId(id == null ? null : String(id));\n if (storeId) document.cookie = `${STORE_ID_COOKIE_NAME}=${storeId}; path=/; SameSite=Lax`;\n}\n\nexport function clearAuthTokenCookie(): void {\n if (typeof document === 'undefined') return;\n document.cookie = `${AUTH_TOKEN_COOKIE_NAME}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;\n}\n\nexport function extractTokenFromCookies(\n cookieHeader: string | null,\n cookieName: string\n): string | null {\n if (!cookieHeader) return null;\n\n const prefix = `${cookieName}=`;\n let start = 0;\n\n while (start < cookieHeader.length) {\n const idx = cookieHeader.indexOf(prefix, start);\n if (idx === -1) return null;\n\n const prevChar = idx > 0 ? cookieHeader[idx - 1] : '';\n if (prevChar === '' || prevChar === ';' || prevChar === ' ') {\n let end = cookieHeader.indexOf(';', idx);\n if (end === -1) end = cookieHeader.length;\n\n const value = cookieHeader.slice(idx + prefix.length, end).trim();\n try {\n return decodeURIComponent(value) || null;\n } catch {\n return value || null;\n }\n }\n\n start = idx + prefix.length;\n }\n\n return null;\n}\n\n/**\n * The scope the Salla SDK persists as `scope`: the market (`id`/`type`) plus, once\n * bullet delivery confirms an address or branch, the allocation. The SDK sends all\n * four as request headers (`s-scope-id`, `s-scope-type`, `s-scope-allocation-type`,\n * `s-scope-allocation-id`) and the API resolves stock per allocation — a scope sent\n * without its allocation is a different question, answered from a different branch.\n */\nexport interface ActiveScope {\n id: string;\n type?: string;\n allocation_type?: string;\n allocation_id?: string;\n}\n\n/** The SDK stores the scope either as its full object or as a bare id. */\nfunction normalizeScope(raw: unknown): ActiveScope | null {\n if (raw == null) return null;\n if (typeof raw !== 'object') return { id: String(raw) };\n const s = raw as Record<string, unknown>;\n if (s.id == null) return null;\n const scope: ActiveScope = { id: String(s.id) };\n if (s.type != null) scope.type = String(s.type);\n if (s.allocation_type != null) scope.allocation_type = String(s.allocation_type);\n if (s.allocation_id != null) scope.allocation_id = String(s.allocation_id);\n return scope;\n}\n\n/**\n * Reads the active scope from the `scope` cookie, which Salla persists as a JSON\n * object (e.g. `{\"id\":123,\"type\":\"scope\",\"allocation_type\":\"branch\",\"allocation_id\":\"9\"}`).\n * Returns null when the cookie is missing or unparseable. Used server-side, where\n * `salla.storage` is absent.\n */\nexport function extractScopeFromCookies(cookieHeader: string | null): ActiveScope | null {\n const raw = extractTokenFromCookies(cookieHeader, SCOPE_COOKIE_NAME);\n if (!raw) return null;\n try {\n return normalizeScope(JSON.parse(raw));\n } catch {\n return null;\n }\n}\n\n/** {@link extractScopeFromCookies} reduced to the id. */\nexport function extractScopeIdFromCookies(cookieHeader: string | null): string | null {\n return extractScopeFromCookies(cookieHeader)?.id ?? null;\n}\n\n/**\n * The scope the Salla SDK persisted in its storage (`salla.storage.get('scope')`).\n *\n * Returns `undefined` when the SDK storage API isn't ready yet — deliberately\n * distinct from `null` (\"no branch selected\"), so callers can't mistake a\n * not-yet-hydrated SDK for a cleared selection. Client-only.\n */\nexport function readSdkScope(): ActiveScope | null | undefined {\n const storage = typeof window !== 'undefined' ? window.salla?.storage : undefined;\n if (typeof storage?.get !== 'function') return undefined;\n return normalizeScope(storage.get(SCOPE_COOKIE_NAME));\n}\n\n/** {@link readSdkScope} reduced to the id; keeps the not-ready/none distinction. */\nexport function readSdkScopeId(): string | null | undefined {\n const scope = readSdkScope();\n return scope === undefined ? undefined : (scope?.id ?? null);\n}\n\n/** One year — the SDK keeps the selected branch in localStorage indefinitely. */\nconst SCOPE_COOKIE_MAX_AGE = 60 * 60 * 24 * 365;\n\nconst sameScope = (a: ActiveScope | null, b: ActiveScope | null): boolean =>\n JSON.stringify(a) === JSON.stringify(b);\n\n/**\n * Mirrors the scope the Salla SDK selected into the `scope` cookie so the SERVER\n * can see it. The SDK persists the selection in localStorage ONLY and writes no\n * cookie, so without this the server computes scope=null for every visitor who\n * picked a branch while the client computes the branch id — the dehydrated settings\n * query key never matches and the client refetches store settings on every page\n * load (SAL-122).\n *\n * Written in the SDK's own JSON shape so {@link extractScopeFromCookies} parses it,\n * allocation included: the bullet-delivery component writes the same cookie with the\n * full object, and rewriting it with the id alone would drop the branch the server\n * needs. Returns true when the cookie was (re)written. Client-only; no-op on the server.\n */\nexport function writeScopeCookie(scope: ActiveScope | null): boolean {\n if (typeof document === 'undefined') return false;\n if (sameScope(extractScopeFromCookies(document.cookie), scope)) return false;\n\n if (scope == null) {\n document.cookie = `${SCOPE_COOKIE_NAME}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;\n return true;\n }\n\n const value = encodeURIComponent(JSON.stringify(scope));\n document.cookie = `${SCOPE_COOKIE_NAME}=${value}; path=/; max-age=${SCOPE_COOKIE_MAX_AGE}; samesite=lax`;\n return true;\n}\n\n/**\n * Keeps the `scope` cookie in step with the SDK's selected branch. Call on every\n * client navigation; it no-ops while the SDK storage API is still hydrating so a\n * late-loading SDK can't wipe a valid cookie.\n */\nexport function syncScopeCookie(): boolean {\n const scope = readSdkScope();\n return scope === undefined ? false : writeScopeCookie(scope);\n}\n","/**\n * @fileoverview Paths on a host where the store is the root.\n *\n * On `preview.salla.design` and a dev server a store is addressed by the first\n * segment of the path — `/mtgr-alaatr-2/cart` — and that segment is the root of\n * the application. No route knows about it: the router takes it off every URL on\n * the way in and puts it back on every URL on the way out\n * (`tanstack/store-base.ts`), so pages, links and loaders all see `/cart`.\n *\n * Which segment it is, and on which hosts, is decided once, by\n * `resolveRequestStoreBase` in `utils/cookies.ts`. This file only moves it on and\n * off a path. See `docs/store-base-path.md`.\n */\nimport { allowsRequestStoreId, isStoreBaseSegment, STORE_ID_PARAM } from './cookies';\nimport { isLocale } from '../providers/locale-constants';\n\n/**\n * An application pathname, without the store segment in front.\n *\n * Only a whole segment is removed, so `/mtgr-alaatr-2x/cart` is left alone, and a\n * pathname that does not start with the segment comes back unchanged.\n */\nexport function stripStoreBase(pathname: string, base: string): string {\n const prefix = `/${base}`;\n if (pathname === prefix) return '/';\n return pathname.startsWith(`${prefix}/`) ? pathname.slice(prefix.length) : pathname;\n}\n\n/**\n * An application path as the browser addresses it, with the store segment in front.\n *\n * It never checks whether the segment is already there, because that cannot be\n * told apart from a page of the same name: a store called `cart` keeps its cart at\n * `/cart/cart`. Callers pass application paths only.\n */\nexport function prefixStoreBase(path: string, base: string): string {\n const rooted = path.startsWith('/') ? path : `/${path}`;\n // The store's root is `/<base>`, not `/<base>/`, with or without a query or hash.\n const atRoot = rooted === '/' || rooted[1] === '?' || rooted[1] === '#';\n return `/${base}${atRoot ? rooted.slice(1) : rooted}`;\n}\n\n/**\n * A pathname from a link the Salla API handed out, without the store's username in it.\n *\n * A store with no domain of its own is served under its username on a shared host,\n * and every URL the API returns for it carries that segment. Its `store.url` is\n * `/{lang}/{username}/` when the store is multilingual and `/{username}/` when it is\n * not: `https://demostore.salla.sa/ar/dev-vgckq3fssfhjewwi/`, `https://salla.sa/cart/`.\n * The segment there belongs to Salla's host, not to the application. Left in, it\n * lands where a page slug is expected and matches no route.\n *\n * The username is the last segment of `store.url`, but only when it equals the\n * store's username. Neither its position nor its spelling says so on its own: `/ar/`\n * is the locale of `https://3tir.com/ar/`, a store on its own domain whose links carry\n * no username, and it is also the whole address of the store called `ar`,\n * `https://salla.sa/ar/`. Without a username to compare against, a last segment\n * spelled like a locale is taken to be one, which is wrong only for a store whose\n * username is a locale code.\n *\n * The locale stays wherever the link put it.\n */\nexport function withoutStoreUrlBase(\n pathname: string,\n storeUrlPathname: string,\n username?: string | null\n): string {\n const own = storeUrlSegment(storeUrlPathname, username);\n if (!own) return pathname;\n\n const segments = pathname.split('/');\n // Salla puts the locale first (`/ar/dev-x/…`); a store that is not multilingual has\n // none (`/dev-x/…`). Checked in that order, `/ar/ar/…` for a store called `ar` keeps\n // its locale.\n let at = -1;\n if (isLocale(segments[1]) && segments[2] === own) at = 2;\n else if (segments[1] === own) at = 1;\n if (at === -1) return pathname;\n\n segments.splice(at, 1);\n return segments.join('/') || '/';\n}\n\n/**\n * Whether a pathname on the store's host is this store's.\n *\n * On a shared host the origin belongs to every store there, and a link names its store\n * by the username in its path, where {@link withoutStoreUrlBase} looks for it. One\n * without it is another store's page, or the host's own. A store on its own domain has\n * no such segment, and every path on its host is its own.\n */\nexport function hasStoreUrlBase(\n pathname: string,\n storeUrlPathname: string,\n username?: string | null\n): boolean {\n const own = storeUrlSegment(storeUrlPathname, username);\n if (!own) return true;\n\n const segments = pathname.split('/');\n return segments[1] === own || (isLocale(segments[1]) && segments[2] === own);\n}\n\n/** The segment `store.url` serves the store under, or null when it has none. */\nfunction storeUrlSegment(storeUrlPathname: string, username?: string | null): string | null {\n const last = storeUrlPathname.split('/').filter(Boolean).pop();\n if (!last) return null;\n if (username) return last === username ? last : null;\n return isLocale(last) ? null : last;\n}\n\n/**\n * Where to send a page whose store was not named by its own first segment, or null\n * when it already was.\n *\n * On a host where the store is the root, every page has one address,\n * `/<username>/…`. A request that found its store some other way (`?storeId=`, the\n * preview cookie, `VITE_STORE_DOMAIN`, or a first segment that named the store by\n * another spelling, such as its numeric id) is sent there once the store's settings\n * say what its username is.\n *\n * `storeId` is dropped from the query on the way. It has to be: a URL carrying it\n * is never read for a store segment, so keeping it would redirect to an address\n * that redirects again, forever. For the same reason a username that could not be\n * read back out of a path produces no redirect at all.\n *\n * `href` is the application's own href (path, query and hash, already without any\n * store segment), which the router keeps percent-encoded, so the result is safe to\n * put in a `Location` header.\n */\nexport function storeBaseRedirectHref(args: {\n host: string | null | undefined;\n base: string | null;\n username: string | null | undefined;\n href: string;\n}): string | null {\n const { host, base, username, href } = args;\n if (!allowsRequestStoreId(host) || !isStoreBaseSegment(username) || username === base) {\n return null;\n }\n\n const url = new URL(href, 'http://store-base.invalid');\n url.searchParams.delete(STORE_ID_PARAM);\n return `${prefixStoreBase(url.pathname, username)}${url.search}${url.hash}`;\n}\n\n/**\n * Where to send a guest who opened a customer-only page: the locale's home with\n * `intended_to`, which the SDK reads to open the login modal and come back after.\n * Null when already there, so the redirect cannot loop.\n */\nexport function loginRedirectHref(args: {\n pathname: string;\n searchStr: string;\n origin: string;\n base: string | null;\n}): string | null {\n const { pathname, searchStr, origin, base } = args;\n const first = pathname.split('/')[1];\n const home = isLocale(first) ? `/${first}` : '/';\n if ((pathname.replace(/\\/$/, '') || '/') === home) return null;\n\n const browserPath = (path: string) => (base ? prefixStoreBase(path, base) : path);\n const intended = `${origin}${browserPath(pathname)}${searchStr}`;\n return `${browserPath(home)}?intended_to=${encodeURIComponent(intended)}`;\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isNativeApp } from './chunk-3IHFA2X5.js';
|
|
1
2
|
import { useTwilight } from './chunk-DF6FBKDN.js';
|
|
2
3
|
import { useRef, useState, useEffect } from 'react';
|
|
3
4
|
import { toast, Toaster as Toaster$1 } from 'sonner';
|
|
@@ -19,7 +20,7 @@ var MOBILE_BREAKPOINT = 768;
|
|
|
19
20
|
var NATIVE_ALERT_EVENT = "ui::alert";
|
|
20
21
|
function dispatchNativeAlert(type, message, title) {
|
|
21
22
|
const salla = window.salla;
|
|
22
|
-
if (!
|
|
23
|
+
if (!isNativeApp() || !salla?.event?.dispatch) return false;
|
|
23
24
|
salla.event.dispatch(NATIVE_ALERT_EVENT, {
|
|
24
25
|
type,
|
|
25
26
|
message,
|
|
@@ -136,5 +137,5 @@ function Toaster({
|
|
|
136
137
|
}
|
|
137
138
|
|
|
138
139
|
export { Toaster };
|
|
139
|
-
//# sourceMappingURL=chunk-
|
|
140
|
-
//# sourceMappingURL=chunk-
|
|
140
|
+
//# sourceMappingURL=chunk-MISI3T6V.js.map
|
|
141
|
+
//# source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C,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,uBACE,GAAA;AAAA,IAACA,SAAA;AAAA,IAAA;AAAA,MACC,QAAA;AAAA,MAIA,MAAA,EAAQ,EAAE,GAAA,EAAK,4CAAA,EAA6C;AAAA,MAC5D,YAAA,EAAc,EAAE,GAAA,EAAK,4CAAA,EAA6C;AAAA,MAClE,YAAA,EAAc;AAAA,QACZ,UAAA,EAAY,eAAA;AAAA,QACZ,KAAA,EAAO;AAAA,UACL,UAAA,EAAY;AAAA;AACd,OACF;AAAA,MACA,KAAA,EAAO;AAAA,QACL,UAAA,EAAY;AAAA;AACd;AAAA,GACF;AAEJ","file":"chunk-MISI3T6V.js","sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport { Toaster as SonnerToaster, toast } from 'sonner';\nimport { useTwilight } from '../../providers/twilight-context';\nimport { isNativeApp } from '../../native-app';\nimport type { ToastPosition } from './types';\n\nconst toastClassNames = {\n toast: 'group bg-white border-2 rounded-xl shadow-2xl p-4 font-primary',\n title: 'text-base font-bold',\n description: 'text-sm mt-1 text-gray-600',\n actionButton: 'bg-primary text-white px-3 py-1 rounded',\n cancelButton: 'bg-gray-100 px-3 py-1 rounded',\n success: 'border-green-500 [&_svg]:text-green-500 [&_aside]:text-green-700',\n error: 'border-red-500 [&_svg]:text-red-500 [&_aside]:text-red-700',\n warning: 'border-yellow-500 [&_svg]:text-yellow-500 [&_aside]:text-yellow-700',\n info: 'border-blue-500 [&_svg]:text-blue-500 [&_aside]:text-blue-700',\n loading: 'border-gray-400',\n};\n\ntype RawMessage = string | { title?: string; text?: string; icon?: string };\ntype ToastVariant = 'success' | 'error' | 'warning' | 'info';\n\nconst MOBILE_BREAKPOINT = 768;\nconst NATIVE_ALERT_EVENT = 'ui::alert';\n\nfunction dispatchNativeAlert(type: ToastVariant, message: string, title?: string) {\n const salla = window.salla;\n if (!isNativeApp() || !salla?.event?.dispatch) return false;\n\n salla.event.dispatch(NATIVE_ALERT_EVENT, {\n type,\n message,\n ...(title ? { title } : {}),\n });\n return true;\n}\n\nexport function Toaster({\n mobilePosition = 'bottom-center',\n addToCartToast = true,\n}: {\n mobilePosition?: ToastPosition;\n /** Show the default add-to-cart toast. Themes whose cart badge is the feedback can turn it off. */\n addToCartToast?: boolean;\n}) {\n const { theme } = useTwilight();\n const themeRef = useRef(theme);\n themeRef.current = theme;\n const flashShownRef = useRef(false);\n\n const isRtl = theme.is_rtl;\n const desktopPosition: ToastPosition = isRtl ? 'top-left' : 'top-right';\n\n const [position, setPosition] = useState<ToastPosition>(() => {\n if (typeof window === 'undefined') return desktopPosition;\n return window.innerWidth < MOBILE_BREAKPOINT ? mobilePosition : desktopPosition;\n });\n\n useEffect(() => {\n const handleResize = () => {\n setPosition(window.innerWidth < MOBILE_BREAKPOINT ? mobilePosition : desktopPosition);\n };\n window.addEventListener('resize', handleResize);\n return () => window.removeEventListener('resize', handleResize);\n }, [desktopPosition, mobilePosition]);\n\n useEffect(() => {\n const salla = window.salla;\n if (!salla) return;\n let active = true;\n\n const handleNotify = (message: RawMessage, type: string, data?: unknown) => {\n const eventData = data as { data?: { googleTags?: { event?: string } } } | undefined;\n const shouldSuppressAddToCartToast =\n (!addToCartToast || themeRef.current.settings?.enable_add_product_toast) &&\n eventData?.data?.googleTags?.event === 'addToCart';\n let title: string;\n let toastType: ToastVariant;\n\n if (typeof message === 'object' && message !== null) {\n title = message.title || message.text || '';\n toastType = (message.icon || type || 'info') as ToastVariant;\n } else {\n title = message;\n toastType = (type || 'info') as ToastVariant;\n }\n\n // Suppress the default addToCart toast when the theme opted out (addToCartToast=false)\n // or renders its own rich toast (enable_add_product_toast) so they don't double up.\n if (shouldSuppressAddToCartToast) {\n return;\n }\n\n if (dispatchNativeAlert(toastType, title)) {\n return;\n }\n\n if (toastType === 'success') {\n toast.success(title, { duration: 3000 });\n } else if (toastType === 'error') {\n toast.error(title, { duration: 3000 });\n } else if (toastType === 'warning') {\n toast.warning(title, { duration: 3000 });\n } else {\n toast.info(title, { duration: 3000 });\n }\n };\n\n // Before the SDK loads `salla` is the head stub, and the SDK's default notifier is alert().\n void (async () => {\n try {\n await salla.onReady?.();\n } catch {\n // onReady() may fail during partial initialization; the toast still beats alert().\n }\n if (active) salla.notify?.setNotifier?.(handleNotify);\n })();\n return () => {\n active = false;\n salla.notify?.setNotifier?.(() => {});\n };\n }, [addToCartToast]);\n\n useEffect(() => {\n if (flashShownRef.current || typeof window === 'undefined') return;\n\n const params = new URLSearchParams(window.location.search);\n const successMsg = params.get('success');\n const dangerMsg = params.get('danger');\n\n if (!successMsg && !dangerMsg) return;\n\n flashShownRef.current = true;\n\n const message = successMsg || dangerMsg || '';\n const toastType = dangerMsg ? 'error' : 'success';\n\n const url = new URL(window.location.href);\n url.searchParams.delete('success');\n url.searchParams.delete('danger');\n window.history.replaceState({}, '', url.toString());\n\n const timer = setTimeout(() => {\n if (dispatchNativeAlert(toastType, message)) return;\n\n if (toastType === 'success') {\n toast.success(message, { duration: 3000 });\n } else {\n toast.error(message, { duration: 3000 });\n }\n }, 100);\n\n return () => clearTimeout(timer);\n }, []);\n\n return (\n <SonnerToaster\n position={position}\n // Keep sonner's default gaps (24px desktop / 16px mobile) but clear the\n // native status bar inset (--app-safe-area-top, set by useSafeAreaInset)\n // so top-positioned toasts aren't covered in the app webview.\n offset={{ top: 'calc(var(--app-safe-area-top, 0px) + 24px)' }}\n mobileOffset={{ top: 'calc(var(--app-safe-area-top, 0px) + 16px)' }}\n toastOptions={{\n classNames: toastClassNames,\n style: {\n fontFamily: 'var(--font-main, inherit)',\n },\n }}\n style={{\n fontFamily: 'var(--font-main, inherit)',\n }}\n />\n );\n}\n\nexport type { ToasterProps } from 'sonner';\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { orThrow, orUnauthorized } from './chunk-
|
|
2
|
-
import { api } from './chunk-
|
|
1
|
+
import { orThrow, orUnauthorized } from './chunk-SDIQHTDG.js';
|
|
2
|
+
import { api } from './chunk-VX2T7JCB.js';
|
|
3
3
|
import { queryOptions } from '@tanstack/react-query';
|
|
4
4
|
|
|
5
5
|
var order = {
|
|
@@ -78,5 +78,5 @@ var order = {
|
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
export { order };
|
|
81
|
-
//# sourceMappingURL=chunk-
|
|
82
|
-
//# sourceMappingURL=chunk-
|
|
81
|
+
//# sourceMappingURL=chunk-MSUGP566.js.map
|
|
82
|
+
//# sourceMappingURL=chunk-MSUGP566.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/order.ts"],"names":[],"mappings":";;;;AAoDO,IAAM,KAAA,GAAQ;AAAA,EACnB,IAAA,EAAM,OAAO,MAAA,KAA2D;AACtE,IAAA,MAAM;AAAA,MACJ,IAAA;AAAA,MACA,MAAA;AAAA,MACA,MAAA;AAAA,MACA,eAAA,EAAiB,cAAA;AAAA,MACjB,UAAA,EAAY,SAAA;AAAA,MACZ;AAAA,KACF,GAAI,UAAU,EAAC;AAEf,IAAA,MAAM,YAAA,GAAe,IAAI,eAAA,EAAgB;AACzC,IAAA,IAAI,SAAS,MAAA,EAAW,YAAA,CAAa,IAAI,MAAA,EAAQ,MAAA,CAAO,IAAI,CAAC,CAAA;AAC7D,IAAA,IAAI,MAAA,EAAQ,YAAA,CAAa,GAAA,CAAI,QAAA,EAAU,MAAM,CAAA;AAC7C,IAAA,IAAI,MAAA,EAAQ,YAAA,CAAa,GAAA,CAAI,QAAA,EAAU,MAAM,CAAA;AAC7C,IAAA,IAAI,cAAA,EAAgB,YAAA,CAAa,GAAA,CAAI,iBAAA,EAAmB,cAAc,CAAA;AACtE,IAAA,IAAI,SAAA,EAAW,YAAA,CAAa,GAAA,CAAI,YAAA,EAAc,GAAG,CAAA;AAEjD,IAAA,MAAM,UAAmC,EAAC;AAC1C,IAAA,IAAI,MAAA,UAAgB,MAAA,GAAS,MAAA;AAE7B,IAAA,MAAM,QAAA,GAAW,MAAM,GAAA,CACpB,GAAA,CAAI,CAAA,OAA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AA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,QAAA,EAAU,UAAA,EAAY,OAAO,CAAA;AAAA,MACxC,OAAA,EAAS,MAAM,KAAA,CAAM,QAAA,CAAS,OAAO;AAAA,KACtC;AAAA;AAEP","file":"chunk-MSUGP566.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\nimport type {\n Order,\n OrderListItem,\n OrderShipmentItem,\n OrderRatingItem,\n} from '../routes/account/types';\nimport type { Pagination } from './types';\nimport { orThrow, orUnauthorized } from '../providers/NavigationProvider';\n\nexport interface OrderDetailResponse {\n order: Order;\n}\n\n/**\n * The order in the shape the Twilight web components read (`salla-order-details`,\n * `salla-order-totals-card`) and the Twig themes render: the API answers `orders/{id}` this\n * way when the request does not say it comes from a React theme (`s-theme-type`).\n */\nexport interface TwilightOrder {\n items: Array<{\n name: string;\n quantity: number;\n product?: { id: number; url?: string; type?: string; image?: { url?: string } };\n options?: unknown[];\n }>;\n [key: string]: unknown;\n}\n\nexport interface CheckoutThankYouData {\n thank_you_title?: string;\n messages?: string[];\n share_message?: string;\n short_share_message?: string;\n}\n\nexport interface OrdersListResponse {\n data: OrderListItem[];\n cursor?: Pagination;\n}\n\nexport interface OrdersListParams {\n page?: number;\n cursor?: string | null;\n status?: string;\n feedback_status?: string;\n /** When set, the list payload includes each order's `items[]` (`with_items=1`). */\n with_items?: boolean | number;\n signal?: AbortSignal;\n}\n\nexport const order = {\n list: async (params?: OrdersListParams): Promise<OrdersListResponse> => {\n const {\n page,\n cursor,\n status,\n feedback_status: feedbackStatus,\n with_items: withItems,\n signal,\n } = params ?? {};\n\n const searchParams = new URLSearchParams();\n if (page !== undefined) searchParams.set('page', String(page));\n if (cursor) searchParams.set('cursor', cursor);\n if (status) searchParams.set('status', status);\n if (feedbackStatus) searchParams.set('feedback_status', feedbackStatus);\n if (withItems) searchParams.set('with_items', '1');\n\n const options: Record<string, unknown> = {};\n if (signal) options.signal = signal;\n\n const response = await api\n .get(`orders?${searchParams.toString()}`, options as any)\n .json<{ data: OrderListItem[] | null; cursor?: Pagination }>();\n\n return {\n data: response.data ?? [],\n cursor: response.cursor,\n };\n },\n\n find: async (id: string): Promise<OrderDetailResponse> => {\n const response = await api.get(`orders/${id}`).json<{ data: Order }>();\n\n return { order: response.data };\n },\n\n findForComponents: async (id: string): Promise<TwilightOrder> => {\n const response = await api\n .get(`orders/${id}`, {\n hooks: {\n // Runs after the client's own hook, which marks every request as from a React theme.\n beforeRequest: [({ request }) => request.headers.delete('s-theme-type')],\n },\n })\n .json<{ data: TwilightOrder }>();\n return response.data;\n },\n\n shipments: async (orderId: string): Promise<OrderShipmentItem[]> => {\n const response = await api\n .get(`orders/${orderId}/shipments`)\n .json<{ data: OrderShipmentItem[] }>();\n return response.data ?? [];\n },\n\n ratings: async (orderId: string): Promise<OrderRatingItem[]> => {\n const response = await api.get(`orders/${orderId}/ratings`).json<{ data: OrderRatingItem[] }>();\n return response.data ?? [];\n },\n\n findOrThrow: (id: string): Promise<OrderDetailResponse> => orUnauthorized(order.find(id)),\n\n thankYou: async (orderId: string): Promise<CheckoutThankYouData> => {\n const { data } = await api\n .get(`checkout/thank-you/${orderId}`)\n .json<{ data: CheckoutThankYouData }>();\n return data;\n },\n\n thankYouOrThrow: (orderId: string): Promise<CheckoutThankYouData> =>\n orThrow(order.thankYou(orderId)),\n\n queries: {\n list: (params?: Omit<OrdersListParams, 'signal'>) =>\n queryOptions({\n queryKey: ['orders', 'list', params],\n queryFn: ({ signal }) => order.list({ ...params, signal }),\n }),\n find: (id: string) =>\n queryOptions({\n queryKey: ['orders', 'detail', id],\n queryFn: () => order.find(id),\n }),\n shipments: (orderId: string) =>\n queryOptions({\n queryKey: ['orders', 'shipments', orderId],\n queryFn: () => order.shipments(orderId),\n }),\n ratings: (orderId: string) =>\n queryOptions({\n queryKey: ['orders', 'ratings', orderId],\n queryFn: () => order.ratings(orderId),\n }),\n thankYou: (orderId: string) =>\n queryOptions({\n queryKey: ['orders', 'thankYou', orderId],\n queryFn: () => order.thankYou(orderId),\n }),\n },\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { api } from './chunk-
|
|
1
|
+
import { api } from './chunk-VX2T7JCB.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-N3BSUMD7.js.map
|
|
24
|
+
//# sourceMappingURL=chunk-N3BSUMD7.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-N3BSUMD7.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,6 +1,6 @@
|
|
|
1
|
-
import { orThrow } from './chunk-
|
|
2
|
-
import { api } from './chunk-
|
|
3
|
-
import { getSallaSDK } from './chunk-
|
|
1
|
+
import { orThrow } from './chunk-SDIQHTDG.js';
|
|
2
|
+
import { api } from './chunk-VX2T7JCB.js';
|
|
3
|
+
import { getSallaSDK } from './chunk-QVJDYSCT.js';
|
|
4
4
|
import { queryOptions } from '@tanstack/react-query';
|
|
5
5
|
|
|
6
6
|
function normalizeCartResponse(data) {
|
|
@@ -43,5 +43,5 @@ var cart = {
|
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
export { cart };
|
|
46
|
-
//# sourceMappingURL=chunk-
|
|
47
|
-
//# sourceMappingURL=chunk-
|
|
46
|
+
//# sourceMappingURL=chunk-NFE2H5JE.js.map
|
|
47
|
+
//# sourceMappingURL=chunk-NFE2H5JE.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/cart.ts"],"names":[],"mappings":";;;;;AAaA,SAAS,sBAAsB,IAAA,EAAoC;AACjE,EAAA,IAAI,CAAC,IAAA,CAAK,IAAA,EAAM,OAAO,IAAA;AACvB,E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,MACX,MAAA,EAAQ;AAAA,KACT,CAAA;AAAA,IACH,SAAA,EAAW,MACT,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,MAAA,EAAQ,YAAY,CAAA;AAAA,MAC/B,OAAA,EAAS,MAAM,IAAA,CAAK,YAAA,EAAa;AAAA;AAAA,MAEjC,SAAA,EAAW,CAAA;AAAA,MACX,MAAA,EAAQ;AAAA,KACT;AAAA;AAEP","file":"chunk-NFE2H5JE.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\nimport type { Cart } from '../types';\nimport { orThrow } from '../providers/NavigationProvider';\nimport { getSallaSDK } from '../utils/sdk-helpers';\n\nexport interface CartApiResponse {\n /** Absent once the cart was turned into an order (the body then carries a top-level `redirect`). */\n cart?: Omit<Cart, 'loyalty' | 'gift'>;\n loyalty?: Cart['loyalty'];\n gift?: Cart['gift'];\n}\n\nfunction normalizeCartResponse(data: CartApiResponse): Cart | null {\n if (!data.cart) return null;\n return {\n ...data.cart,\n loyalty: data.loyalty ?? null,\n gift: data.gift ?? null,\n } as Cart;\n}\n\nexport const cart = {\n get: async (cartId: number): Promise<Cart | null> => {\n const { data } = await api.get(`cart/${cartId}`).json<{ data: CartApiResponse }>();\n return normalizeCartResponse(data);\n },\n\n getOrThrow: (cartId: number): Promise<Cart | null> => orThrow(cart.get(cartId)),\n\n /** The visitor's cart id, which only the Salla SDK knows; `null` outside the browser. */\n getCurrentId: async (): Promise<number | null> => {\n const salla = getSallaSDK();\n if (!salla) return null;\n // The app bundle can run before the SDK module, when `salla` is still the head stub.\n await salla.onReady().catch(() => undefined);\n return salla.cart.api.getCurrentCartId();\n },\n\n queries: {\n detail: (cartId: number) =>\n queryOptions({\n queryKey: ['cart', cartId],\n queryFn: () => cart.get(cartId),\n // The SDK changes the cart from any page, so a cached copy is never safe to show.\n staleTime: 0,\n gcTime: 0,\n }),\n currentId: () =>\n queryOptions({\n queryKey: ['cart', 'current-id'],\n queryFn: () => cart.getCurrentId(),\n // Completing an order starts a new cart, so an earlier id is never reused.\n staleTime: 0,\n gcTime: 0,\n }),\n },\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { onSallaEvent } from './chunk-
|
|
1
|
+
import { onSallaEvent } from './chunk-QVJDYSCT.js';
|
|
2
2
|
import { useState, useRef, useEffect, useCallback } from 'react';
|
|
3
3
|
|
|
4
4
|
function useProduct(initialProduct, options) {
|
|
@@ -61,5 +61,5 @@ function useProduct(initialProduct, options) {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
export { useProduct };
|
|
64
|
-
//# sourceMappingURL=chunk-
|
|
65
|
-
//# sourceMappingURL=chunk-
|
|
64
|
+
//# sourceMappingURL=chunk-OGVUFMLX.js.map
|
|
65
|
+
//# sourceMappingURL=chunk-OGVUFMLX.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/useProduct.ts"],"names":[],"mappings":";;;AA4DO,SAAS,UAAA,CAAW,gBAAyB,OAAA,EAA+C;AACjG,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAI,SAAkB,cAAc,CAAA;AAI9D,EAAA,MAAM,iBAAA,GAAoB,OAAgB,cAAc,CAAA;AACxD,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,iBAAA,CAAkB,OAAA,GAAU,cAAA;AAAA,EAC9B,CAAC,CAAA;AAED,EAAA,MAAM,MAAA,GAAS,YAAY,YAAY;AACrC,IAAA,MAAM,QAAQ,MAAA,CAAO,KAAA;AACrB,IAAA,IAAI,CAAC,KAAA,EAAO,GAAA,EAAK,OAAA,EAAS,UAAA,EAAY;AACtC,IAAA,IAAI;AACF,MAAA,MAAM,QAAA,GAAW,MAAM,KAAA,CAAM,GAAA,CAAI,QAAQ,UAAA,CAAW,MAAA,CAAO,OAAA,CAAQ,EAAE,CAAA,EAAG;AAAA,QACtE,QAAA;AAAA,QACA;AAAA,OACD,CAAA;AACD,MAAA,IAAI,QAA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MAAA,EAAS,KAAK,MAAA,IAAqB,EAAA;AAAA;AAAA,UAEnC,KAAK,IAAA,CAAK,GAAA,KAAQ,SAAY,IAAA,CAAK,GAAA,GAAO,KAAK,GAAA,IAAkB,EAAA;AAAA,UACjE,SAAS,IAAA,CAAK,OAAA,KAAY,SAAY,IAAA,CAAK,OAAA,GAAW,KAAK,OAAA,IAAsB,EAAA;AAAA,UACjF,eAAA,EAAiB;AAAA,SACnB;AAAA,MACF,CAAC,CAAA;AAAA,IACH,CAAA;AAEA,IAAA,MAAM,QAAA,GAAW,kBAAA;AAGjB,IAAA,OAAO,YAAA,CAAa,0BAA0B,QAAQ,CAAA;AAAA,EACxD,CAAA,EAAG,EAAE,CAAA;AAGL,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,oBAAoB,MAAM;AAC9B,MAAA,UAAA,CAAW,CAAC,IAAA,MAAU,EAAE,GAAG,IAAA,EAAM,eAAA,EAAiB,MAAK,CAAE,CAAA;AAAA,IAC3D,CAAA;AAEA,IAAA,OAAO,YAAA,CAAa,iCAAiC,iBAAiB,CAAA;AAAA,EACxE,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO,EAAE,SAAS,MAAA,EAAO;AAC3B","file":"chunk-OGVUFMLX.js","sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport type { Product } from '../types';\nimport { onSallaEvent } from '../utils/sdk-helpers';\n\n/**\n * UseProductResult - Return type for useProduct hook\n */\nexport interface UseProductResult {\n /** Current product state (updates on option changes) */\n product: Product;\n /** Reload product data from API */\n reload: () => Promise<void>;\n}\n\nexport interface UseProductOptions {\n /**\n * True while `initialProduct` is a list-card stand-in. When it flips to false\n * (details arrived), state re-seeds. Do not infer this from `options`/`images`\n * — list payloads may include those fields.\n */\n isPreview?: boolean;\n}\n\n/**\n * useProduct - Hook for managing product state with live updates\n *\n * Provides reactive product data with automatic updates for price, stock,\n * and variant changes. Handles manual reloads (e.g., after add-to-cart)\n * and subscribes to Salla SDK events for real-time price updates.\n *\n * Stock status is reflected in `product.is_out_of_stock` which updates\n * when price calculations succeed or fail (e.g., unavailable option combinations).\n *\n * @param initialProduct - The initial product object (typically from loader/SSR).\n * @param options.isPreview - Pass true for a list-card placeholder so the hook\n * re-seeds when details for the same id arrive (`isPreview` goes false).\n *\n * @returns Object with product and reload function\n *\n * @example\n * ```tsx\n * function ProductDetails({ product }) {\n * const { product: updatedProduct, reload } = useProduct(product);\n *\n * const handleAddToCart = async () => {\n * await addToCart(updatedProduct.id);\n * await reload(); // Refresh product state after cart update\n * };\n *\n * return (\n * <div>\n * <h1>{updatedProduct.name}</h1>\n * <p>Price: {formatMoney(updatedProduct.price)}</p>\n * {updatedProduct.is_out_of_stock && <p>Currently out of stock</p>}\n * <button onClick={handleAddToCart}>Add to Cart</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useProduct(initialProduct: Product, options?: UseProductOptions): UseProductResult {\n const [product, setProduct] = useState<Product>(initialProduct);\n\n // Always keep a ref to the latest initialProduct so the re-seed effect below\n // can read it without adding the full object to the dependency array.\n const initialProductRef = useRef<Product>(initialProduct);\n useEffect(() => {\n initialProductRef.current = initialProduct;\n });\n\n const reload = useCallback(async () => {\n const salla = window.salla;\n if (!salla?.api?.product?.getDetails) return;\n try {\n const response = await salla.api.product.getDetails(String(product.id), [\n 'images',\n 'category',\n ]);\n if (response?.success && response.data) {\n setProduct(response.data as Product);\n }\n } catch {\n // silently ignore network errors during reload\n }\n }, [product.id]);\n\n // Re-seed when the loader navigates to a different product, or when a\n // list-card placeholder (`isPreview`) is replaced by details for the same id.\n // Object identity is not a dependency — that would reset live option/price state.\n useEffect(() => {\n setProduct(initialProductRef.current);\n }, [initialProduct.id, options?.isPreview]);\n\n // Subscribe to Salla option-change events so price/stock stays in sync\n useEffect(() => onSallaEvent('product:options.updated', reload), [reload]);\n\n // Subscribe to price update events (matches product.js registerEvents)\n useEffect(() => {\n const handlePriceUpdated = (res: { data?: Record<string, unknown> }) => {\n const data = res.data;\n if (!data) return;\n\n setProduct((prev) => {\n const price = (data.price as number) ?? prev.price;\n const regularPrice = (data.regular_price as number) ?? prev.regular_price;\n // The payload has no sale_price: like product.js, `price` is the payable (sale) figure.\n const isOnSale = Boolean(data.has_sale_price) && regularPrice > price;\n return {\n ...prev,\n price,\n sale_price: isOnSale ? price : prev.sale_price,\n regular_price: regularPrice,\n is_on_sale: isOnSale,\n starting_price: null,\n weight: (data.weight as string) || '',\n // An empty variant SKU/barcode blanks it; a payload without the field keeps it (product.js).\n sku: data.sku === undefined ? prev.sku : (data.sku as string) || '',\n barcode: data.barcode === undefined ? prev.barcode : (data.barcode as string) || '',\n is_out_of_stock: false,\n };\n });\n };\n\n const listener = handlePriceUpdated as (...args: unknown[]) => void;\n\n // Root on/off: onPriceUpdated registers a wrapper that salla.event.off can't match.\n return onSallaEvent('product::price.updated', listener);\n }, []);\n\n // Subscribe to price update failed events (matches product.js)\n useEffect(() => {\n const handlePriceFailed = () => {\n setProduct((prev) => ({ ...prev, is_out_of_stock: true }));\n };\n\n return onSallaEvent('product::price.updated.failed', handlePriceFailed);\n }, []);\n\n return { product, reload };\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { rememberProductPreview } from './chunk-
|
|
2
|
-
import { getActiveScope, api } from './chunk-
|
|
1
|
+
import { rememberProductPreview } from './chunk-H2DXJCJP.js';
|
|
2
|
+
import { getActiveScope, api } from './chunk-VX2T7JCB.js';
|
|
3
3
|
import { queryOptions } from '@tanstack/react-query';
|
|
4
4
|
|
|
5
5
|
var wishlist = {
|
|
@@ -31,5 +31,5 @@ var wishlist = {
|
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
export { wishlist };
|
|
34
|
-
//# sourceMappingURL=chunk-
|
|
35
|
-
//# sourceMappingURL=chunk-
|
|
34
|
+
//# sourceMappingURL=chunk-P6EOXGUE.js.map
|
|
35
|
+
//# sourceMappingURL=chunk-P6EOXGUE.js.map
|
|
@@ -1 +1 @@
|
|
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I,CAAA;AAErD,IAAA,OAAO;AAAA,MACL,KAAA;AAAA,MACA,IAAA,EAAM,QAAA,CAAS,MAAA,EAAQ,IAAA,IAAQ;AAAA,KACjC;AAAA,EACF,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,IAAA,EAAM,CAAC,MAAA,KACL,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,UAAA,EAAY,MAAA,EAAQ,QAAQ,EAAE,KAAA,EAAO,cAAA,EAAe,EAAG,CAAA;AAAA,MAClE,OAAA,EAAS,CAAC,EAAE,MAAA,EAAO,KAAM,QAAA,CAAS,IAAA,CAAK,EAAE,GAAG,MAAA,EAAQ,MAAA,EAAQ;AAAA,KAC7D;AAAA;AAEP","file":"chunk-P6EOXGUE.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api, getActiveScope } from './client';\nimport {\n rememberProductPreview,\n type ProductsListResult,\n type ProductsListResponse,\n} from './product';\n\nexport interface WishlistListParams {\n page?: number;\n perPage?: number;\n filterable?: boolean;\n signal?: AbortSignal;\n}\n\n/**\n * Wishlist API — page-based pagination only.\n * Kept separate from product.list to avoid mixing cursor and page pagination strategies.\n */\nexport const wishlist = {\n list: async (params: WishlistListParams = {}): Promise<ProductsListResult> => {\n const { page = 1, perPage = 15, filterable, signal } = params;\n\n const searchParams = new URLSearchParams();\n searchParams.set('source', 'wishlist');\n searchParams.set('page', String(page));\n searchParams.set('per_page', String(perPage));\n\n if (filterable !== undefined) {\n searchParams.set('filterable', filterable ? '1' : '0');\n }\n\n const options: Record<string, unknown> = {};\n if (signal) options.signal = signal;\n\n const response = await api\n .get(`products?${searchParams.toString()}`, options as any)\n .json<ProductsListResponse>();\n\n const items = response.data ?? [];\n for (const item of items) rememberProductPreview(item);\n\n return {\n items,\n next: response.cursor?.next ?? null,\n };\n },\n\n queries: {\n list: (params: Omit<WishlistListParams, 'signal'>) =>\n queryOptions({\n queryKey: ['wishlist', 'list', params, { scope: getActiveScope() }],\n queryFn: ({ signal }) => wishlist.list({ ...params, signal }),\n }),\n },\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { hostIdentifiesStore, resolveRequestStoreBase, storeBaseRedirectHref } from './chunk-
|
|
1
|
+
import { hostIdentifiesStore, resolveRequestStoreBase, storeBaseRedirectHref } from './chunk-LPQFTXBB.js';
|
|
2
2
|
import { getRequestStore } from './chunk-N2S25NXP.js';
|
|
3
3
|
|
|
4
4
|
// src/utils/inline-script.ts
|
|
@@ -76,6 +76,91 @@ function resolveStoreBaseRedirect(username, href) {
|
|
|
76
76
|
return storeBaseRedirectHref({ host, base: resolveStoreBase(), username, href });
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
// src/utils/sdk-helpers.ts
|
|
80
|
+
var isBrowser = typeof window !== "undefined";
|
|
81
|
+
function getStoreIdentifier(explicit) {
|
|
82
|
+
return resolveStoreIdentifier(explicit);
|
|
83
|
+
}
|
|
84
|
+
function getSallaSDK() {
|
|
85
|
+
if (!isBrowser) return void 0;
|
|
86
|
+
return window.salla;
|
|
87
|
+
}
|
|
88
|
+
var SDK_CREATED_EVENT = "salla::created";
|
|
89
|
+
var noop = () => {
|
|
90
|
+
};
|
|
91
|
+
function isLoaded(sdk) {
|
|
92
|
+
return typeof sdk?.init === "function" || typeof sdk?.event?.on === "function";
|
|
93
|
+
}
|
|
94
|
+
function hasEventBus(sdk) {
|
|
95
|
+
return typeof sdk?.event?.on === "function";
|
|
96
|
+
}
|
|
97
|
+
function whenSallaLoaded(callback) {
|
|
98
|
+
return whenSalla(isLoaded, callback);
|
|
99
|
+
}
|
|
100
|
+
function whenSalla(isUsable, callback) {
|
|
101
|
+
if (!isBrowser) return noop;
|
|
102
|
+
if (isUsable(window.salla)) {
|
|
103
|
+
callback(window.salla);
|
|
104
|
+
return noop;
|
|
105
|
+
}
|
|
106
|
+
let settled = false;
|
|
107
|
+
const onCreated = () => {
|
|
108
|
+
const sdk = window.salla;
|
|
109
|
+
if (settled || !isUsable(sdk)) return;
|
|
110
|
+
settled = true;
|
|
111
|
+
window.removeEventListener(SDK_CREATED_EVENT, onCreated);
|
|
112
|
+
callback(sdk);
|
|
113
|
+
};
|
|
114
|
+
window.addEventListener(SDK_CREATED_EVENT, onCreated);
|
|
115
|
+
return () => {
|
|
116
|
+
settled = true;
|
|
117
|
+
window.removeEventListener(SDK_CREATED_EVENT, onCreated);
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function whenSallaReady(callback) {
|
|
121
|
+
let cancelled = false;
|
|
122
|
+
const cancel = whenSallaLoaded((sdk) => {
|
|
123
|
+
void new Promise((resolve) => resolve(sdk.onReady?.())).catch(noop).then(() => {
|
|
124
|
+
if (!cancelled) callback(sdk);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
return () => {
|
|
128
|
+
cancelled = true;
|
|
129
|
+
cancel();
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function onSallaEvent(name, listener) {
|
|
133
|
+
let bus;
|
|
134
|
+
const cancel = whenSalla(hasEventBus, (sdk) => {
|
|
135
|
+
bus = sdk.event;
|
|
136
|
+
bus.on(name, listener);
|
|
137
|
+
});
|
|
138
|
+
return () => {
|
|
139
|
+
cancel();
|
|
140
|
+
bus?.off?.(name, listener);
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function syncSdkLocale(locale) {
|
|
144
|
+
const sdk = getSallaSDK();
|
|
145
|
+
if (!sdk || !locale) return;
|
|
146
|
+
try {
|
|
147
|
+
sdk.lang?.setLocale?.(locale);
|
|
148
|
+
sdk.api?.setHeader?.("accept-language", locale);
|
|
149
|
+
sdk.config?.set?.("user.language_code", locale);
|
|
150
|
+
} catch {
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function syncSdkThemeVersion(headers) {
|
|
154
|
+
const sdk = getSallaSDK();
|
|
155
|
+
if (!sdk) return;
|
|
156
|
+
const versionId = headers?.["s-version-id"];
|
|
157
|
+
try {
|
|
158
|
+
if (versionId != null) sdk.api?.setHeader?.("s-version-id", String(versionId));
|
|
159
|
+
else delete sdk.api?.axios?.defaults?.headers?.common?.["s-version-id"];
|
|
160
|
+
} catch {
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export { escapeForInlineScript, getInjectedRuntimeEnv, getSallaSDK, getStoreIdentifier, onSallaEvent, readEnv, renderRuntimeEnvScript, resolveStoreBase, resolveStoreBaseRedirect, resolveStoreIdentifier, syncSdkLocale, syncSdkThemeVersion, whenSallaLoaded, whenSallaReady };
|
|
165
|
+
//# sourceMappingURL=chunk-QVJDYSCT.js.map
|
|
166
|
+
//# sourceMappingURL=chunk-QVJDYSCT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/inline-script.ts","../src/utils/runtime-env.ts","../src/utils/store-identity.ts","../src/utils/sdk-helpers.ts"],"names":[],"mappings":";;;;AAMO,SAAS,sBAAsB,KAAA,EAAuB;AAC3D,EAAA,OAAO,MACJ,OAAA,CAAQ,IAAA,EAAM,SAAS,CAAA,CACvB,OAAA,CAAQ,MAAM,SAAS,CAAA,CACvB,QAAQ,IAAA,EAAM,SAAS,EACvB,OAAA,CAAQ,SAAA,EAAW,SAAS,CAAA,CAC5B,OAAA,CAAQ,WAAW,SAAS,CAAA;AACjC;;;ACRA,IAAM,eAAA,GAAkB,uBAAA;AAsCjB,SAAS,QAAQ,GAAA,EAAiC;AACvD,EAAA,IAAI;AACF,IAAA,MAAM,IAAA,GAAQ,MAAA,CAAA,IAAA,CAAwE,GAAA,GACpF,GACF,CAAA;AACA,IAAA,IAAI,MAAM,OAAO,IAAA;AAAA,EACnB,CAAA,CAAA,MAAQ;AAAA,EAER;AACA,EAAA,OAAO,OAAO,OAAA,KAAY,WAAA,GAAc,OAAA,CAAQ,GAAA,GAAM,GAAG,CAAA,GAAI,MAAA;AAC/D;AAOO,SAAS,iBAAA,GAAgC;A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,IAAO,CAAC,MAAA,EAAQ;AACrB,EAAA,IAAI;AACF,IAAA,GAAA,CAAI,IAAA,EAAM,YAAY,MAAM,CAAA;AAC5B,IAAA,GAAA,CAAI,GAAA,EAAK,SAAA,GAAY,iBAAA,EAAmB,MAAM,CAAA;AAG9C,IAAA,GAAA,CAAI,MAAA,EAAQ,GAAA,GAAM,oBAAA,EAAsB,MAAM,CAAA;AAAA,EAChD,CAAA,CAAA,MAAQ;AAAA,EAER;AACF;AAaO,SAAS,oBAAoB,OAAA,EAAwC;AAC1E,EAAA,MAAM,MAAM,WAAA,EAAY;AACxB,EAAA,IAAI,CAAC,GAAA,EAAK;AACV,EAAA,MAAM,SAAA,GAAY,UAAU,cAAc,CAAA;AAC1C,EAAA,IAAI;AACF,IAAA,IAAI,SAAA,IAAa,MAAM,GAAA,CAAI,GAAA,EAAK,YAAY,cAAA,EAAgB,MAAA,CAAO,SAAS,CAAC,CAAA;AAAA,gBACjE,GAAA,CAAI,GAAA,EAAK,OAAO,QAAA,EAAU,OAAA,EAAS,SAAS,cAAc,CAAA;AAAA,EACxE,CAAA,CAAA,MAAQ;AAAA,EAER;AACF","file":"chunk-QVJDYSCT.js","sourcesContent":["/**\n * Escape a JSON-stringified value for safe embedding inside an inline `<script>` body.\n *\n * The head injects script bodies raw, so a `</script>` inside partner-set data would break out\n * of the tag; U+2028/U+2029 are line terminators in JS but not in JSON, so they must go too.\n */\nexport function escapeForInlineScript(value: string): string {\n return value\n .replace(/</g, '\\\\u003c')\n .replace(/>/g, '\\\\u003e')\n .replace(/&/g, '\\\\u0026')\n .replace(/\\u2028/g, '\\\\u2028')\n .replace(/\\u2029/g, '\\\\u2029');\n}\n","import { escapeForInlineScript } from './inline-script';\nimport { getRequestStore } from '../twilight/context';\nimport { hostIdentifiesStore } from './cookies';\n\n/** Where `rootHead` publishes the SSR-resolved env for the browser bundle to read. */\nconst RUNTIME_ENV_KEY = '__SALLA_RUNTIME_ENV__';\n\n/** The env values that must agree between the SSR render and the hydrated client. */\nexport interface RuntimeEnv {\n /** Store API base — `VITE_API_URL`. */\n apiBase?: string;\n /** Store identifier — `VITE_STORE_DOMAIN`. */\n storeIdentifier?: string;\n /**\n * The theme-settings version the request named, if any.\n *\n * Published for the same reason `storeIdentifier` is: the dispatcher strips\n * `?versionId=` on the way in, so by the time the browser has the page its own\n * URL no longer says which version it is showing. Without this the hydrated\n * client would ask the API about the store's live version and quietly replace\n * the draft it was handed.\n *\n * Absent — not empty — when nothing named one, so it drops out of the inline\n * script entirely rather than publishing a value that means \"live\".\n */\n versionId?: string;\n /**\n * The store segment at the root of this page's paths, when the store is\n * addressed that way — see `resolveStoreBase`.\n *\n * Published because the browser's address is not always the URL the server\n * read: the dispatcher removes `?storeId=` from the request it forwards but not\n * from the address bar, and a URL carrying it is never read for a segment. The\n * client builds its router from this, and a router that disagreed with the\n * server about the root would hydrate a different page.\n */\n storeBase?: string;\n}\n\n/**\n * A build-time `import.meta.env` var, falling back to the worker's runtime `process.env`\n * (wrangler `vars`, exposed via the `nodejs_compat_populate_process_env` flag).\n */\nexport function readEnv(key: string): string | undefined {\n try {\n const vite = (import.meta as unknown as { env?: Record<string, string | undefined> }).env?.[\n key\n ];\n if (vite) return vite;\n } catch {\n /* import.meta.env not available in all environments */\n }\n return typeof process !== 'undefined' ? process.env?.[key] : undefined;\n}\n\n/**\n * What this runtime resolves from its own env — server-side that includes the worker vars.\n * Prefers what the server already published, so re-rendering the head during hydration yields\n * the same script instead of dropping it.\n */\nexport function resolveRuntimeEnv(): RuntimeEnv {\n const injected = getInjectedRuntimeEnv();\n const { storeId, storeBase, versionId, requestHost } = getRequestStore();\n return {\n apiBase: injected.apiBase || readEnv('VITE_API_URL'),\n // The request outranks the build-time var here for the same reason it does\n // in `resolveStoreIdentifier`, and this is the copy that reaches the\n // browser: publish the store SSR actually rendered, or hydration resolves\n // again from a URL whose `?storeId=` the dispatcher has already stripped and\n // queries a different store than the markup it is hydrating.\n storeIdentifier:\n injected.storeIdentifier ||\n storeId ||\n storeBase ||\n (hostIdentifiesStore(requestHost) ? requestHost : null) ||\n readEnv('VITE_STORE_DOMAIN'),\n // Absent rather than empty when the path named no store, so it drops out of\n // the inline script, like `versionId`.\n storeBase: injected.storeBase || storeBase || undefined,\n // No env fallback on purpose. A store identifier has one because a build can\n // legitimately be pinned to a store; a version is something a request asks\n // for, and a build-time default would make every visitor of every store see\n // whichever draft was current when the theme was compiled.\n versionId: injected.versionId || versionId || undefined,\n };\n}\n\n/**\n * The env the SSR worker resolved, as handed to the browser by `rootHead`. Empty on the server\n * and on a client whose head carried nothing.\n *\n * Worker `vars` are *runtime* env: they live in `process.env` on the server only, while\n * `import.meta.env` is substituted at build time. A bundle built without those vars therefore\n * sees `undefined` in the browser and silently falls back to the production defaults — SSR\n * would render off the configured backend while every post-hydration fetch hits another one.\n */\nexport function getInjectedRuntimeEnv(): RuntimeEnv {\n const holder = globalThis as typeof globalThis & { [RUNTIME_ENV_KEY]?: RuntimeEnv };\n return holder[RUNTIME_ENV_KEY] ?? {};\n}\n\n/**\n * Inline head `<script>` body publishing the server-resolved env, or null when there is nothing\n * to publish (no overrides configured — the defaults already agree on both sides).\n */\nexport function renderRuntimeEnvScript(env: RuntimeEnv = resolveRuntimeEnv()): string | null {\n const set = Object.entries(env).filter(([, value]) => Boolean(value));\n if (!set.length) return null;\n const json = escapeForInlineScript(JSON.stringify(Object.fromEntries(set)));\n return `window.${RUNTIME_ENV_KEY}=${json};`;\n}\n","/**\n * @fileoverview Which store to ask about — the one answer, in one place.\n *\n * This lived in two places once. `api/store.ts` learned to read the store a\n * request names, and `utils/sdk-helpers.ts` — the copy `api/client.ts` actually\n * sets the `store-identifier` header from — did not. So the resolver that had\n * been taught the answer was consulted for a null check and thrown away, every\n * outgoing request carried an empty identifier, the API answered\n * `422 Store Identifier not found`, and every published theme rendered\n * \"Store Unavailable\" while its tests passed: the client's suite mocked the\n * resolver, and the resolver's suite never went near a request.\n *\n * Hence one module, imported by both. If a third place ever needs a store\n * identifier, it imports this — a second implementation is the bug, not a\n * refactor away from it.\n *\n * See `docs/store-identity.md` for the full picture, including the security\n * boundary on who may name a store.\n */\nimport { getRequestStore } from '../twilight/context';\nimport { hostIdentifiesStore, resolveRequestStoreBase } from './cookies';\nimport { getInjectedRuntimeEnv, readEnv } from './runtime-env';\nimport { storeBaseRedirectHref } from './store-base';\n\n/**\n * Which store to ask about, in the order the answers can be trusted.\n *\n * A deployed theme worker is published with **no vars and no bindings** — the\n * script metadata carries `main_module`, compatibility settings, assets and tags\n * and nothing else — so `VITE_STORE_DOMAIN` exists only where a build baked it\n * in, which is local development. In production this function used to reach the\n * end of that chain and return the empty string, `store.settings` refused to\n * call with no identifier, and the root loader threw \"Store Unavailable\" — a\n * theme that renders its own failure page for every visitor of every store.\n *\n * The order:\n *\n * 1. what the caller passed, which is always deliberate;\n * 2. the store this request names — the `?storeId=` a preview was opened with,\n * then the cookie remembering it — seeded by `twilightMiddleware`, and only\n * on a host permitted to name one;\n * 3. the store the first segment of the path names, on those same hosts — its\n * username, which the API accepts as an identifier as readily as an id (see\n * {@link resolveStoreBase});\n * 4. what SSR already resolved and published, so the hydrated client asks about\n * the same store the server rendered instead of resolving again from a URL\n * that no longer names it;\n * 5. the request's own host, which *is* the identity of a live storefront —\n * but only when that host is a storefront. `preview.salla.design` and\n * `localhost` serve many stores, so their names identify none;\n * 6. `VITE_STORE_DOMAIN`, last, because a build-time constant is a development\n * convenience and must never outrank what the request actually said.\n *\n * Steps 2 and 3 never both answer: a path that names a store takes the place of\n * the cookie, and a URL carrying `?storeId=` is not read for a path segment.\n */\nexport function resolveStoreIdentifier(explicit?: string): string {\n if (explicit) return explicit;\n\n const { storeId, requestHost } = getRequestStore();\n if (storeId) return storeId;\n\n const storeBase = resolveStoreBase();\n if (storeBase) return storeBase;\n\n const injected = getInjectedRuntimeEnv().storeIdentifier;\n if (injected) return injected;\n\n if (hostIdentifiesStore(requestHost)) return requestHost as string;\n\n // The browser's own address, for a client render that reached neither of the\n // above — a live storefront, where the host is the store.\n const browserHost = typeof window !== 'undefined' ? window.location.host : null;\n if (hostIdentifiesStore(browserHost)) return browserHost as string;\n\n return readEnv('VITE_STORE_DOMAIN') || readEnv('STORE_DOMAIN') || '';\n}\n\n/**\n * The store segment at the root of this page's paths, or null when the store is\n * not addressed that way.\n *\n * On the server it is what `twilightMiddleware` read off the request. In the\n * browser it is what SSR published, because the address bar is not always the\n * URL the server rendered: on the preview host the dispatcher removes\n * `?storeId=` from the request it forwards and leaves it in the browser's, and a\n * URL carrying `storeId` is never read for a segment. Re-reading\n * `window.location` would, for `/ar?storeId=…`, route the page under a different\n * store than the one it was rendered for.\n *\n * The address bar is read only when SSR published nothing at all: a page the dev\n * server answered with its client shell instead of a render, where there is no\n * server decision to agree with.\n */\nexport function resolveStoreBase(): string | null {\n const { storeBase } = getRequestStore();\n if (storeBase) return storeBase;\n if (typeof window === 'undefined') return null;\n\n const published = getInjectedRuntimeEnv();\n if (published.storeBase) return published.storeBase;\n if (Object.keys(published).length > 0) return null;\n\n return resolveRequestStoreBase(window.location.href, window.location.host);\n}\n\n/**\n * The address this page should be loaded from instead, when the store is the root\n * of every URL on this host and this request did not use it; null otherwise.\n *\n * @param username - the store's username, from the settings the request loaded\n * @param href - the router's own href for the page, without any store segment\n *\n * See `storeBaseRedirectHref` for the rules. The host is the request's on the\n * server and the browser's own in the browser, so the decision is gated the same\n * way on both sides.\n */\nexport function resolveStoreBaseRedirect(\n username: string | null | undefined,\n href: string\n): string | null {\n const host =\n getRequestStore().requestHost ?? (typeof window !== 'undefined' ? window.location.host : null);\n return storeBaseRedirectHref({ host, base: resolveStoreBase(), username, href });\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';\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 * Push the theme version the current settings name onto the Salla SDK.\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 = headers?.['s-version-id'];\n try {\n if (versionId != null) sdk.api?.setHeader?.('s-version-id', String(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,10 +1,10 @@
|
|
|
1
1
|
import { buildHreflangAlternates } from './chunk-TZ3E5BN4.js';
|
|
2
|
-
import { HomeComponentRenderer } from './chunk-
|
|
3
|
-
import { home } from './chunk-
|
|
2
|
+
import { HomeComponentRenderer } from './chunk-2JL4S2LE.js';
|
|
3
|
+
import { home } from './chunk-5HOD4BKK.js';
|
|
4
4
|
import { useDevHomeComponentOverrides } from './chunk-2JV6WZ6O.js';
|
|
5
5
|
import { RouteId } from './chunk-ZGHRSRDO.js';
|
|
6
|
-
import { getTwilightContext } from './chunk-N2S25NXP.js';
|
|
7
6
|
import { HookSlot } from './chunk-Q7VWURUR.js';
|
|
7
|
+
import { getTwilightContext } from './chunk-N2S25NXP.js';
|
|
8
8
|
import { memo } from 'react';
|
|
9
9
|
import { Pulse } from '@salla.sa/twilight-components-react';
|
|
10
10
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
@@ -84,5 +84,5 @@ function head(ctx) {
|
|
|
84
84
|
var Home = { id: RouteId.INDEX, loader, head, Component: HomePage };
|
|
85
85
|
|
|
86
86
|
export { Home, HomeSkeleton, homeLoader };
|
|
87
|
-
//# sourceMappingURL=chunk-
|
|
88
|
-
//# sourceMappingURL=chunk-
|
|
87
|
+
//# sourceMappingURL=chunk-R2BAI6QI.js.map
|
|
88
|
+
//# sourceMappingURL=chunk-R2BAI6QI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/routes/home/loader.ts","../src/routes/home/HomePage.tsx","../src/routes/home/index.tsx"],"names":["HomeSkeleton","HomePage"],"mappings":";;;;;;;;;;;;AAWA,eAAsB,WAAW,GAAA,EAAoD;AACnF,EAAA,MAAM,EAAE,WAAA,EAAY,GAAI,kBAAA,EAAmB;AAC3C,EAAA,MAAM,aAAa,MAAM,WAAA,CAAY,gBAAgB,IAAA,CAAK,OAAA,CAAQ,YAAY,CAAA;AAC9E,EAAA,MAAM,MAAA,GAAS;AAAA,IACb,MAAA,EAAQ,KAAK,MAAA,IAA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O;AAAA,IACL,KAAA;AAAA,IACA,WAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAW,KAAA,CAAM,GAAA;AAAA,IACjB,SAAA,EAAW;AAAA,MACT,IAAA,EAAM,SAAA;AAAA,MACN,KAAA;AAAA,MACA,WAAA;AAAA,MACA,QAAQ,KAAA,CAAM,IAAA;AAAA,MACd,KAAK,KAAA,CAAM;AAAA,KACb;AAAA,IACA,OAAA,EAAS;AAAA,MACP,IAAA,EAAM,qBAAA;AAAA,MACN,KAAA;AAAA,MACA,WAAA;AAAA,MACA,QAAQ,KAAA,CAAM;AAAA,KAChB;AAAA,IACA,oBAAoB,uBAAA,CAAwB,GAAA,CAAI,QAAA,EAAU,GAAA,CAAI,SAAS,QAAQ;AAAA,GACjF;AACF;AAEO,IAAM,IAAA,GAAO,EAAE,EAAA,EAAI,OAAA,CAAQ,OAAO,MAAA,EAAQ,IAAA,EAAM,WAAW,QAAA","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/routes/home/loader.ts","../src/routes/home/HomePage.tsx","../src/routes/home/index.tsx"],"names":["HomeSkeleton","HomePage"],"mappings":";;;;;;;;;;;;AAWA,eAAsB,WAAW,GAAA,EAAoD;AACnF,EAAA,MAAM,EAAE,WAAA,EAAY,GAAI,kBAAA,EAAmB;AAC3C,EAAA,MAAM,aAAa,MAAM,WAAA,CAAY,gBAAgB,IAAA,CAAK,OAAA,CAAQ,YAAY,CAAA;AAC9E,EAAA,MAAM,MAAA,GAAS;AAAA,IACb,MAAA,EAAQ,KAAK,MAAA,IAAU,IAAA;AAAA,IACvB,UAAA,EAAY,UAAA,CAAW,GAAA,CAAI,CAAC,IAAA,MAAU;AAAA,MACpC,GAAG,IAAA;AAAA,MACH,MAAM,IAAA,CAAK,IAAA,EAAM,QAAQ,OAAA,EAAS,EAAE,KAAK,IAAA,CAAK;AAAA,KAChD,CAAE,CAAA;AAAA,IACF,IAAA,EAAM,EAAE,IAAA,EAAM,OAAA,CAAQ,KAAA;AAAM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;AAAA,MACP,IAAA,EAAM,qBAAA;AAAA,MACN,KAAA;AAAA,MACA,WAAA;AAAA,MACA,QAAQ,KAAA,CAAM;AAAA,KAChB;AAAA,IACA,oBAAoB,uBAAA,CAAwB,GAAA,CAAI,QAAA,EAAU,GAAA,CAAI,SAAS,QAAQ;AAAA,GACjF;AACF;AAEO,IAAM,IAAA,GAAO,EAAE,EAAA,EAAI,OAAA,CAAQ,OAAO,MAAA,EAAQ,IAAA,EAAM,WAAW,QAAA","file":"chunk-R2BAI6QI.js","sourcesContent":["import { getTwilightContext } from '../../twilight/context';\nimport { home } from '../../api/home';\nimport type { HomeComponentData } from '../../types';\nimport { RouteId } from '../../router/route-ids';\n\nexport interface HomeLoaderData {\n locale: string;\n components: HomeComponentData[];\n page: { slug: string };\n}\n\nexport async function homeLoader(ctx?: { locale?: string }): Promise<HomeLoaderData> {\n const { queryClient } = getTwilightContext();\n const components = await queryClient.ensureQueryData(home.queries.components());\n const result = {\n locale: ctx?.locale || 'ar',\n components: components.map((comp) => ({\n ...comp,\n path: comp.path?.replace('home.', '') || comp.path,\n })),\n page: { slug: RouteId.INDEX },\n };\n return result;\n}\n","import { memo } from 'react';\nimport { useDevHomeComponentOverrides } from '../../dev/dev-settings-store';\nimport { HookSlot } from '../../hooks';\nimport { HomeComponentRenderer } from '../../components/home';\nimport type { HomePageProps } from './types';\nimport { Pulse } from '@salla.sa/twilight-components-react';\n\nexport const HomeSkeleton = memo(function HomeSkeleton() {\n return (\n <>\n <div className=\"s-block container skeleton-block-hero\">\n <Pulse className=\"h-64 sm:h-80 rounded-md\" />\n </div>\n <div className=\"s-block container skeleton-block-products\">\n <Pulse className=\"h-10 w-48 mb-4\" />\n <div className=\"grid grid-cols-2 sm:grid-cols-4 gap-4\">\n {[1, 2, 3, 4].map((i) => (\n <Pulse key={i} className=\"h-56\" />\n ))}\n </div>\n </div>\n <div className=\"s-block container skeleton-block-products\">\n <Pulse className=\"h-10 w-48 mb-4\" />\n <div className=\"grid grid-cols-2 sm:grid-cols-4 gap-4\">\n {[1, 2, 3, 4].map((i) => (\n <Pulse key={i} className=\"h-56\" />\n ))}\n </div>\n </div>\n </>\n );\n});\n\nexport const HomePage = memo(function HomePage({ components = [] }: HomePageProps) {\n // Dev-mode only: overlay DevSettingsWidget component-field overrides onto the\n // blocks so edits render live. No-op passthrough in production builds.\n const renderedComponents = useDevHomeComponentOverrides(components);\n return (\n <>\n <HookSlot name=\"home:start\" />\n <HookSlot name=\"home:content\" />\n {renderedComponents.map((data, index) => (\n // `data.key` is the twilight.json catalog id, shared by every placement\n // of that block. Platform blocks send null. Position is unique.\n <HomeComponentRenderer key={index} data={data} index={index} />\n ))}\n <HookSlot name=\"home:end\" />\n </>\n );\n});\n\nexport { HomePage as default };\n","import type { HeadDescriptor } from '../../utils/head';\nimport { buildHreflangAlternates } from '../../utils/baseHead';\nimport type { HomeLoaderData } from './loader';\nimport { homeLoader } from './loader';\nimport type { TwilightContext } from '../../twilight/context';\nimport { HomePage } from './HomePage';\nimport { RouteId } from '../../router/route-ids';\n\nexport { HomeSkeleton } from './HomePage';\nexport { registerHomeComponents, DefaultHomeComponents } from '../../components/home/register';\nexport { registerHomeComponentConfig } from '../../components/home';\nexport type { HomePageProps } from './types';\nexport type { HomeLoaderData } from './loader';\nexport type {\n HomeComponentsProps,\n AnyHomeComponent,\n HomeComponentConfig,\n} from '../../components/home';\n\nfunction loader(_ctx?: { locale?: string }): Promise<HomeLoaderData> {\n return homeLoader({ locale: _ctx?.locale });\n}\n\nfunction head(ctx: TwilightContext): HeadDescriptor {\n const store = ctx.settings?.store;\n if (!store) return {};\n\n const title = store.meta?.title ?? store.name;\n const description = store.meta?.description ?? store.description;\n const keywords = store.meta?.keywords;\n\n return {\n title,\n description,\n keywords,\n canonical: store.url,\n openGraph: {\n type: 'website',\n title,\n description,\n images: store.logo,\n url: store.url,\n },\n twitter: {\n card: 'summary_large_image',\n title,\n description,\n images: store.logo,\n },\n alternateLanguages: buildHreflangAlternates(ctx.settings, ctx.location.pathname),\n };\n}\n\nexport const Home = { id: RouteId.INDEX, loader, head, Component: HomePage } as const;\n\nexport { homeLoader };\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { redirect } from './chunk-
|
|
2
|
-
import { clearAuthTokenCookie } from './chunk-
|
|
1
|
+
import { redirect } from './chunk-SDIQHTDG.js';
|
|
2
|
+
import { clearAuthTokenCookie } from './chunk-LPQFTXBB.js';
|
|
3
3
|
import { FALLBACK_LOCALE } from './chunk-T72DAX7R.js';
|
|
4
4
|
import { useEffect } from 'react';
|
|
5
5
|
|
|
@@ -28,5 +28,5 @@ function LogoutRedirect() {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export { LogoutRedirect, accountRedirectLoader, pendingOrdersRedirectLoader, ratingRedirectLoader, slugBrandRedirectLoader };
|
|
31
|
-
//# sourceMappingURL=chunk-
|
|
32
|
-
//# sourceMappingURL=chunk-
|
|
31
|
+
//# sourceMappingURL=chunk-R5MZV6KW.js.map
|
|
32
|
+
//# sourceMappingURL=chunk-R5MZV6KW.js.map
|