@salla.sa/twilight-theme-engine 1.0.152 → 1.0.153
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-HOBSTMWX.js → AddToCartForm-SOC5GBBM.js} +3 -3
- package/dist/{AddToCartForm-HOBSTMWX.js.map → AddToCartForm-SOC5GBBM.js.map} +1 -1
- package/dist/{BlogAuthorPage-56OY5GCN.js → BlogAuthorPage-TTL4SIQA.js} +16 -16
- package/dist/{BlogAuthorPage-56OY5GCN.js.map → BlogAuthorPage-TTL4SIQA.js.map} +1 -1
- package/dist/{BlogCategoryPage-HW7A6RNL.js → BlogCategoryPage-RQ3VXFKP.js} +16 -16
- package/dist/{BlogCategoryPage-HW7A6RNL.js.map → BlogCategoryPage-RQ3VXFKP.js.map} +1 -1
- package/dist/{BlogPage-RRHKP3GP.js → BlogPage-TAGSF4PK.js} +14 -14
- package/dist/{BlogPage-RRHKP3GP.js.map → BlogPage-TAGSF4PK.js.map} +1 -1
- package/dist/{BlogSinglePage-STNMFQHX.js → BlogSinglePage-WFECBPGR.js} +14 -14
- package/dist/{BlogSinglePage-STNMFQHX.js.map → BlogSinglePage-WFECBPGR.js.map} +1 -1
- package/dist/{BlogTagPage-YD3EPTQY.js → BlogTagPage-LEUUDNOX.js} +16 -16
- package/dist/{BlogTagPage-YD3EPTQY.js.map → BlogTagPage-LEUUDNOX.js.map} +1 -1
- package/dist/{BrandsPage-KJFB4QBN.js → BrandsPage-3DKJL2UC.js} +15 -15
- package/dist/{BrandsPage-KJFB4QBN.js.map → BrandsPage-3DKJL2UC.js.map} +1 -1
- package/dist/{Breadcrumb-QKHYTTFB.js → Breadcrumb-CZUWG3RH.js} +14 -14
- package/dist/{Breadcrumb-QKHYTTFB.js.map → Breadcrumb-CZUWG3RH.js.map} +1 -1
- package/dist/{CartItem-DCCYGMRI.js → CartItem-ZZZ34FK2.js} +14 -14
- package/dist/{CartItem-DCCYGMRI.js.map → CartItem-ZZZ34FK2.js.map} +1 -1
- package/dist/{CartSummary-DAAYDRFS.js → CartSummary-YICFP2HG.js} +14 -14
- package/dist/{CartSummary-DAAYDRFS.js.map → CartSummary-YICFP2HG.js.map} +1 -1
- package/dist/{Copyright-GL5Q4FTN.js → Copyright-N7AWWM6R.js} +3 -3
- package/dist/{Copyright-GL5Q4FTN.js.map → Copyright-N7AWWM6R.js.map} +1 -1
- package/dist/{CustomerLayout-D7HC4G7V.js → CustomerLayout-CDARXLTX.js} +14 -14
- package/dist/{CustomerLayout-D7HC4G7V.js.map → CustomerLayout-CDARXLTX.js.map} +1 -1
- package/dist/{Footer-3NQWLPAA.js → Footer-UAEQ5SBA.js} +4 -4
- package/dist/{Footer-3NQWLPAA.js.map → Footer-UAEQ5SBA.js.map} +1 -1
- package/dist/{Header-SCR46P4B.js → Header-TNV53WAC.js} +8 -8
- package/dist/{Header-SCR46P4B.js.map → Header-TNV53WAC.js.map} +1 -1
- package/dist/{LatestProducts-4UML6BNG.js → LatestProducts-CPULMFWH.js} +16 -16
- package/dist/{LatestProducts-4UML6BNG.js.map → LatestProducts-CPULMFWH.js.map} +1 -1
- package/dist/{LoyaltyPage-CQIUT7MD.js → LoyaltyPage-YYYXZOYO.js} +14 -14
- package/dist/{LoyaltyPage-CQIUT7MD.js.map → LoyaltyPage-YYYXZOYO.js.map} +1 -1
- package/dist/{LoyaltyPointsPage-ZOZFDRZT.js → LoyaltyPointsPage-66N76CP7.js} +6 -6
- package/dist/{LoyaltyPointsPage-ZOZFDRZT.js.map → LoyaltyPointsPage-66N76CP7.js.map} +1 -1
- package/dist/{MainMenu-YLCB4MT7.js → MainMenu-7WKMQYJE.js} +5 -5
- package/dist/{MainMenu-YLCB4MT7.js.map → MainMenu-7WKMQYJE.js.map} +1 -1
- package/dist/{MasterLayout-BDDKPLS6.js → MasterLayout-NXS4567C.js} +14 -14
- package/dist/{MasterLayout-BDDKPLS6.js.map → MasterLayout-NXS4567C.js.map} +1 -1
- package/dist/{MobileMenu-S5LB622I.js → MobileMenu-2ISSFTOL.js} +15 -15
- package/dist/{MobileMenu-S5LB622I.js.map → MobileMenu-2ISSFTOL.js.map} +1 -1
- package/dist/{NotificationsPage-FPF7UU3Q.js → NotificationsPage-GRLVJK4Q.js} +14 -14
- package/dist/{NotificationsPage-FPF7UU3Q.js.map → NotificationsPage-GRLVJK4Q.js.map} +1 -1
- package/dist/{OrderSinglePage-M37ROUBX.js → OrderSinglePage-XEX3ZDU4.js} +15 -15
- package/dist/{OrderSinglePage-M37ROUBX.js.map → OrderSinglePage-XEX3ZDU4.js.map} +1 -1
- package/dist/{OrdersPage-GIZFTPQ7.js → OrdersPage-7H5NZQYQ.js} +14 -14
- package/dist/{OrdersPage-GIZFTPQ7.js.map → OrdersPage-7H5NZQYQ.js.map} +1 -1
- package/dist/{PageSingle-EQD5Y3L5.js → PageSingle-Q6RGRZEC.js} +3 -3
- package/dist/{PageSingle-EQD5Y3L5.js.map → PageSingle-Q6RGRZEC.js.map} +1 -1
- package/dist/{ProductDetails-53BXVF37.js → ProductDetails-6W6YIGUS.js} +4 -4
- package/dist/{ProductDetails-53BXVF37.js.map → ProductDetails-6W6YIGUS.js.map} +1 -1
- package/dist/{ProfilePage-6GJXTBFN.js → ProfilePage-P5NHML4X.js} +14 -14
- package/dist/{ProfilePage-6GJXTBFN.js.map → ProfilePage-P5NHML4X.js.map} +1 -1
- package/dist/{ReviewsPage-SCHVMKXV.js → ReviewsPage-D2EPXJJZ.js} +3 -3
- package/dist/{ReviewsPage-SCHVMKXV.js.map → ReviewsPage-D2EPXJJZ.js.map} +1 -1
- package/dist/{SeoCartWidget-IUXLYOTC.js → SeoCartWidget-VMNWM3FM.js} +14 -14
- package/dist/{SeoCartWidget-IUXLYOTC.js.map → SeoCartWidget-VMNWM3FM.js.map} +1 -1
- package/dist/{SettingsPage-2TKL2COF.js → SettingsPage-JYEI7C4T.js} +14 -14
- package/dist/{SettingsPage-2TKL2COF.js.map → SettingsPage-JYEI7C4T.js.map} +1 -1
- package/dist/{StoreClosedNotification-HHOQXT6N.js → StoreClosedNotification-U36UX33X.js} +15 -15
- package/dist/{StoreClosedNotification-HHOQXT6N.js.map → StoreClosedNotification-U36UX33X.js.map} +1 -1
- package/dist/{TestimonialsPage-GJJT7F5G.js → TestimonialsPage-O2FN7CPT.js} +3 -3
- package/dist/{TestimonialsPage-GJJT7F5G.js.map → TestimonialsPage-O2FN7CPT.js.map} +1 -1
- package/dist/{ThankYouPage-ZAEZWSUK.js → ThankYouPage-UEHR5653.js} +14 -14
- package/dist/{ThankYouPage-ZAEZWSUK.js.map → ThankYouPage-UEHR5653.js.map} +1 -1
- package/dist/{WalletPage-74LAUONG.js → WalletPage-5X37XHOU.js} +15 -15
- package/dist/{WalletPage-74LAUONG.js.map → WalletPage-5X37XHOU.js.map} +1 -1
- package/dist/{WebMcpTools-J6HCO5B6.js → WebMcpTools-6ZN6KROP.js} +5 -5
- package/dist/{WebMcpTools-J6HCO5B6.js.map → WebMcpTools-6ZN6KROP.js.map} +1 -1
- package/dist/{WishlistPage-SV55V5CP.js → WishlistPage-2JCIUJEP.js} +16 -16
- package/dist/{WishlistPage-SV55V5CP.js.map → WishlistPage-2JCIUJEP.js.map} +1 -1
- package/dist/api/advertisement.js +2 -2
- package/dist/api/apps.js +2 -2
- package/dist/api/blog.js +3 -3
- package/dist/api/brands.js +3 -3
- package/dist/api/cart.js +3 -3
- package/dist/api/category.js +3 -3
- package/dist/api/client.js +1 -1
- package/dist/api/home.js +2 -2
- package/dist/api/loyalty.js +3 -3
- package/dist/api/menu.js +2 -2
- package/dist/api/notification.js +2 -2
- package/dist/api/order.js +3 -3
- package/dist/api/page.js +3 -3
- package/dist/api/product.js +3 -3
- package/dist/api/profile.js +1 -1
- package/dist/api/store.js +2 -2
- package/dist/api/translations.js +2 -2
- package/dist/api/user.js +2 -2
- package/dist/api/wallet.js +2 -2
- package/dist/api/wishlist.js +4 -4
- package/dist/{chunk-UL2DRYH3.js → chunk-2BRLDR24.js} +3 -3
- package/dist/{chunk-UL2DRYH3.js.map → chunk-2BRLDR24.js.map} +1 -1
- package/dist/{chunk-MJQ3HFLJ.js → chunk-3YMCWKFT.js} +3 -3
- package/dist/{chunk-MJQ3HFLJ.js.map → chunk-3YMCWKFT.js.map} +1 -1
- package/dist/{chunk-VBAFSMNX.js → chunk-46CWPZSI.js} +3 -3
- package/dist/{chunk-VBAFSMNX.js.map → chunk-46CWPZSI.js.map} +1 -1
- package/dist/{chunk-64RDACOS.js → chunk-4FPHFWEU.js} +4 -4
- package/dist/{chunk-64RDACOS.js.map → chunk-4FPHFWEU.js.map} +1 -1
- package/dist/{chunk-I3KAWUPG.js → chunk-4UPADKLB.js} +4 -4
- package/dist/{chunk-I3KAWUPG.js.map → chunk-4UPADKLB.js.map} +1 -1
- package/dist/{chunk-A2SS3TNE.js → chunk-4XT63VFN.js} +3 -3
- package/dist/{chunk-A2SS3TNE.js.map → chunk-4XT63VFN.js.map} +1 -1
- package/dist/{chunk-EAQAPYYU.js → chunk-53ULTYEF.js} +7 -7
- package/dist/{chunk-EAQAPYYU.js.map → chunk-53ULTYEF.js.map} +1 -1
- package/dist/{chunk-XEHOZTER.js → chunk-5WVJYMDS.js} +3 -3
- package/dist/{chunk-XEHOZTER.js.map → chunk-5WVJYMDS.js.map} +1 -1
- package/dist/{chunk-F5RU2UCE.js → chunk-6REUUGFM.js} +15 -15
- package/dist/{chunk-F5RU2UCE.js.map → chunk-6REUUGFM.js.map} +1 -1
- package/dist/{chunk-R4LA6IMS.js → chunk-6VBQ6HJO.js} +3 -3
- package/dist/{chunk-R4LA6IMS.js.map → chunk-6VBQ6HJO.js.map} +1 -1
- package/dist/{chunk-OZRGUVHQ.js → chunk-7RM7W4G7.js} +4 -4
- package/dist/{chunk-OZRGUVHQ.js.map → chunk-7RM7W4G7.js.map} +1 -1
- package/dist/{chunk-LAO3MSKN.js → chunk-7TEJBYGD.js} +7 -7
- package/dist/{chunk-LAO3MSKN.js.map → chunk-7TEJBYGD.js.map} +1 -1
- package/dist/{chunk-LJXWCGBH.js → chunk-A5QIBUZ5.js} +7 -7
- package/dist/{chunk-LJXWCGBH.js.map → chunk-A5QIBUZ5.js.map} +1 -1
- package/dist/{chunk-UBRG55VM.js → chunk-AME4LBNH.js} +4 -4
- package/dist/{chunk-UBRG55VM.js.map → chunk-AME4LBNH.js.map} +1 -1
- package/dist/{chunk-S5KE6KPV.js → chunk-ASLHSLMC.js} +4 -4
- package/dist/{chunk-S5KE6KPV.js.map → chunk-ASLHSLMC.js.map} +1 -1
- package/dist/{chunk-BIVBSVWR.js → chunk-BBTYM4OY.js} +4 -4
- package/dist/{chunk-BIVBSVWR.js.map → chunk-BBTYM4OY.js.map} +1 -1
- package/dist/{chunk-ZBGMIDDO.js → chunk-DWWPRLD3.js} +3 -3
- package/dist/{chunk-ZBGMIDDO.js.map → chunk-DWWPRLD3.js.map} +1 -1
- package/dist/{chunk-FCFIG4M3.js → chunk-EMGVOEZZ.js} +3 -3
- package/dist/{chunk-FCFIG4M3.js.map → chunk-EMGVOEZZ.js.map} +1 -1
- package/dist/{chunk-XTBFIIAR.js → chunk-G4DDINNW.js} +4 -4
- package/dist/{chunk-XTBFIIAR.js.map → chunk-G4DDINNW.js.map} +1 -1
- package/dist/{chunk-UG44HSCN.js → chunk-JIFM6LXR.js} +4 -4
- package/dist/{chunk-UG44HSCN.js.map → chunk-JIFM6LXR.js.map} +1 -1
- package/dist/{chunk-IO4CVUL5.js → chunk-KAIASXU7.js} +6 -4
- package/dist/chunk-KAIASXU7.js.map +1 -0
- package/dist/{chunk-BWKHA4ZD.js → chunk-LDDZ7TUR.js} +4 -4
- package/dist/{chunk-BWKHA4ZD.js.map → chunk-LDDZ7TUR.js.map} +1 -1
- package/dist/{chunk-CV32FSEL.js → chunk-LYKDZ74X.js} +3 -3
- package/dist/{chunk-CV32FSEL.js.map → chunk-LYKDZ74X.js.map} +1 -1
- package/dist/{chunk-JWYZLXJZ.js → chunk-MO2NP3WX.js} +5 -5
- package/dist/{chunk-JWYZLXJZ.js.map → chunk-MO2NP3WX.js.map} +1 -1
- package/dist/{chunk-N2RAPPQ3.js → chunk-O6O2PDH5.js} +4 -4
- package/dist/{chunk-N2RAPPQ3.js.map → chunk-O6O2PDH5.js.map} +1 -1
- package/dist/{chunk-AU2XMLTH.js → chunk-ONBDJMLJ.js} +3 -3
- package/dist/{chunk-AU2XMLTH.js.map → chunk-ONBDJMLJ.js.map} +1 -1
- package/dist/{chunk-KNY2ZZ5M.js → chunk-P7RERWEY.js} +3 -3
- package/dist/{chunk-KNY2ZZ5M.js.map → chunk-P7RERWEY.js.map} +1 -1
- package/dist/{chunk-HSJCVD3P.js → chunk-PBTIZ7UF.js} +4 -4
- package/dist/{chunk-HSJCVD3P.js.map → chunk-PBTIZ7UF.js.map} +1 -1
- package/dist/{chunk-677OXNGV.js → chunk-PSWUFTNS.js} +3 -3
- package/dist/{chunk-677OXNGV.js.map → chunk-PSWUFTNS.js.map} +1 -1
- package/dist/{chunk-AFFBCOH6.js → chunk-QEE2A7O2.js} +3 -3
- package/dist/{chunk-AFFBCOH6.js.map → chunk-QEE2A7O2.js.map} +1 -1
- package/dist/{chunk-5VTVPQQB.js → chunk-QJR5FRIA.js} +4 -4
- package/dist/{chunk-5VTVPQQB.js.map → chunk-QJR5FRIA.js.map} +1 -1
- package/dist/chunk-T3GORIJL.js +69 -0
- package/dist/chunk-T3GORIJL.js.map +1 -0
- package/dist/{chunk-EFKVEYML.js → chunk-T3UUH7YX.js} +5 -5
- package/dist/{chunk-EFKVEYML.js.map → chunk-T3UUH7YX.js.map} +1 -1
- package/dist/{chunk-LPF6YURL.js → chunk-TK2ZIYF6.js} +3 -3
- package/dist/{chunk-LPF6YURL.js.map → chunk-TK2ZIYF6.js.map} +1 -1
- package/dist/{chunk-BY4DQTOG.js → chunk-U7ZHPOGI.js} +7 -7
- package/dist/{chunk-BY4DQTOG.js.map → chunk-U7ZHPOGI.js.map} +1 -1
- package/dist/{chunk-URBOD4MX.js → chunk-WYMDZDEZ.js} +3 -3
- package/dist/{chunk-URBOD4MX.js.map → chunk-WYMDZDEZ.js.map} +1 -1
- package/dist/{chunk-4SZNUX4K.js → chunk-YBWXK2OT.js} +11 -11
- package/dist/{chunk-4SZNUX4K.js.map → chunk-YBWXK2OT.js.map} +1 -1
- package/dist/{chunk-ZC4O472R.js → chunk-YY74QOIL.js} +5 -5
- package/dist/{chunk-ZC4O472R.js.map → chunk-YY74QOIL.js.map} +1 -1
- package/dist/{chunk-O76H6TDP.js → chunk-YZPHKPYI.js} +3 -3
- package/dist/{chunk-O76H6TDP.js.map → chunk-YZPHKPYI.js.map} +1 -1
- package/dist/{chunk-I5GFTVR2.js → chunk-ZHBZ6YMB.js} +4 -4
- package/dist/{chunk-I5GFTVR2.js.map → chunk-ZHBZ6YMB.js.map} +1 -1
- package/dist/{chunk-SXJEZEGN.js → chunk-ZKTSLYTT.js} +3 -3
- package/dist/{chunk-SXJEZEGN.js.map → chunk-ZKTSLYTT.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 +12 -12
- package/dist/components/home/index.js +17 -17
- package/dist/components/layout/index.js +4 -4
- package/dist/components/product/index.js +14 -14
- package/dist/components/store/index.js +13 -13
- package/dist/dev/editor/index.js +1 -1
- package/dist/dev/index.js +1 -1
- package/dist/{document-class-XYBFXCE7.js → document-class-YJDZSSZA.js} +12 -12
- package/dist/{document-class-XYBFXCE7.js.map → document-class-YJDZSSZA.js.map} +1 -1
- package/dist/hooks/index.js +12 -12
- package/dist/hooks/useGtm.js +12 -12
- package/dist/hooks/useMoney.js +12 -12
- package/dist/hooks/useStore.js +12 -12
- package/dist/hooks/useUser.js +3 -3
- package/dist/index.js +12 -12
- package/dist/{navigation-SHFUWYCA.js → navigation-W43IKI56.js} +5 -5
- package/dist/{navigation-SHFUWYCA.js.map → navigation-W43IKI56.js.map} +1 -1
- package/dist/{navigation-QDTYXINL.js → navigation-XQLKHMIZ.js} +4 -4
- package/dist/{navigation-QDTYXINL.js.map → navigation-XQLKHMIZ.js.map} +1 -1
- package/dist/{not-found-IFD562WC.js → not-found-LE7TH53E.js} +15 -15
- package/dist/{not-found-IFD562WC.js.map → not-found-LE7TH53E.js.map} +1 -1
- package/dist/providers/index.js +12 -12
- package/dist/routes/account/orders.js +4 -4
- package/dist/routes/account.js +13 -13
- package/dist/routes/blog.js +8 -8
- package/dist/routes/brands.js +4 -4
- package/dist/routes/cart.js +21 -21
- package/dist/routes/home.js +18 -18
- package/dist/routes/index.js +3 -3
- package/dist/routes/loyalty.js +5 -5
- package/dist/routes/page.js +4 -4
- package/dist/routes/product-listing.js +22 -22
- package/dist/routes/product.js +17 -17
- package/dist/routes/seo-redirects.d.ts +12 -0
- package/dist/routes/seo-redirects.d.ts.map +1 -1
- package/dist/routes/seo-redirects.js +3 -3
- package/dist/routes/testimonials.js +2 -2
- package/dist/routes/thank-you.js +4 -4
- package/dist/skeleton.js +18 -18
- package/dist/{store-lookup-AJT3ZHTS.js → store-lookup-FL54XOJB.js} +8 -8
- package/dist/{store-lookup-AJT3ZHTS.js.map → store-lookup-FL54XOJB.js.map} +1 -1
- package/dist/tanstack/link.d.ts.map +1 -1
- package/dist/tanstack/templates/locale-wrapper.d.ts.map +1 -1
- package/dist/tanstack.js +12 -12
- package/dist/utils/index.js +2 -2
- package/dist/vite/index.js +3 -1
- package/dist/vite/index.js.map +1 -1
- package/package.json +1 -1
- package/tailwind/routes/seo-redirects.ts.txt +52 -2
- package/dist/chunk-IO4CVUL5.js.map +0 -1
- package/dist/chunk-SIYINCXL.js +0 -41
- package/dist/chunk-SIYINCXL.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
|
-
import { redirect } from '../providers/NavigationProvider';
|
|
3
|
-
import { FALLBACK_LOCALE } from '../providers/locale-constants';
|
|
2
|
+
import { isMissingResource, redirect } from '../providers/NavigationProvider';
|
|
3
|
+
import { FALLBACK_LOCALE, isLocale } from '../providers/locale-constants';
|
|
4
4
|
import { clearAuthTokenCookie } from '../utils/cookies';
|
|
5
5
|
|
|
6
6
|
export interface SlugBrandParams {
|
|
@@ -64,6 +64,56 @@ export async function productsSourceRedirectLoader(ctx: {
|
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
/** Routes a Twig URL lands on by accident: a locale bound as `$slug`, or an id that is no number. */
|
|
68
|
+
const SLUG_ROUTES = new Set(['/{-$locale}/$slug/p{$id}', '/{-$locale}/$slug/c{$id}']);
|
|
69
|
+
|
|
70
|
+
/** The page the router matched, as the locale layout's `beforeLoad` sees it. */
|
|
71
|
+
export interface MatchedPage {
|
|
72
|
+
routeId: string;
|
|
73
|
+
params: Record<string, string | undefined>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function rendersNoPage({ routeId, params }: MatchedPage): boolean {
|
|
77
|
+
// A first segment that is no language binds as the locale, of the layout or of the home page.
|
|
78
|
+
if (routeId === '/{-$locale}' || (params.locale && !isLocale(params.locale))) return true;
|
|
79
|
+
if (!SLUG_ROUTES.has(routeId)) return false;
|
|
80
|
+
return (!params.locale && isLocale(params.slug)) || !/^\d+$/.test(params.id ?? '');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Twig's product and category URLs (`/p{id}`, `/p{id}-{name}`, `/category/{hash}`, each with or
|
|
85
|
+
* without a locale) sent to the page that has them now. Run by the locale layout's `beforeLoad`,
|
|
86
|
+
* only for an address no page answers: the router binds `/ar/p1` to `$slug/p{$id}` (slug `ar`)
|
|
87
|
+
* and `/p1` to the locale. A product or category that is gone stays the not-found page.
|
|
88
|
+
*/
|
|
89
|
+
export async function twigUrlRedirect(
|
|
90
|
+
pathname: string,
|
|
91
|
+
search: string,
|
|
92
|
+
page: MatchedPage | undefined
|
|
93
|
+
): Promise<void> {
|
|
94
|
+
if (!page || !rendersNoPage(page)) return;
|
|
95
|
+
const productUrl = /^(?:\/([^/]+))?\/p(\d+)(?:-[^/]*)?\/?$/.exec(pathname);
|
|
96
|
+
const match = productUrl ?? /^(?:\/([^/]+))?\/category\/([A-Za-z0-9]+)\/?$/.exec(pathname);
|
|
97
|
+
if (!match || (match[1] && !isLocale(match[1]))) return;
|
|
98
|
+
|
|
99
|
+
let target: string;
|
|
100
|
+
try {
|
|
101
|
+
if (productUrl) {
|
|
102
|
+
const { product } = await import('../api/product');
|
|
103
|
+
await product.find(match[2]);
|
|
104
|
+
target = `/-/p${match[2]}`;
|
|
105
|
+
} else {
|
|
106
|
+
const { category } = await import('../api/category');
|
|
107
|
+
const found = await category.find(match[2]);
|
|
108
|
+
target = `/-/c${found.id_ ?? found.id}`;
|
|
109
|
+
}
|
|
110
|
+
} catch (error) {
|
|
111
|
+
if (isMissingResource(error)) return;
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
throw redirect(`${match[1] ? `/${match[1]}` : ''}${target}${search}`, { statusCode: 301 });
|
|
115
|
+
}
|
|
116
|
+
|
|
67
117
|
/**
|
|
68
118
|
* `/logout` — where the SDK sends the browser once `salla.auth.logout()` has run
|
|
69
119
|
* (`salla.url.get('logout?from=…')`). The Twig storefront serves that URL server-side. Here
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/tanstack/link.tsx","../src/tanstack/native-app-events.tsx","../src/utils/request-host.ts","../src/tanstack/navigation.tsx"],"names":["TanStackLink","tanstackNotFound","tanstackRedirect","useParams","jsx"],"mappings":";;;;;;;;;;;;AAWO,SAAS,mBAAA,CAAoB,aAAqB,MAAA,EAAiB;AACxE,EAAA,IAAI,CAAC,MAAA,IAAU,CAAC,WAAA,CAAY,UAAA,CAAW,GAAG,CAAA,IAAK,WAAA,CAAY,UAAA,CAAW,IAAI,CAAA,EAAG,OAAO,WAAA;AACpF,EAAA,MAAM,YAAA,GAAe,WAAA,CAAY,KAAA,CAAM,GAAG,CAAA,CAAE,CAAC,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,IAAA,EAAM,OAAA,EAAS,CAAA;AAAA,MAEzF,QAAA,kBAAAA,GAAAA,CAAC,YAAA,EAAA,EAAa,OAAA,EAAS,qBAAsB,QAAA,EAAS;AAAA;AAAA,GACxD;AAEJ","file":"chunk-IO4CVUL5.js","sourcesContent":["import { forwardRef, createElement } from 'react';\nimport { Link as TanStackLink, useParams } from '@tanstack/react-router';\nimport { isLocale } from '../providers/locale-constants';\nimport type { BaseLinkProps } from '../components/common/Link.types';\n\n/**\n * Routes live under an optional `/{-$locale}` param, so a bare `to=\"/brands\"`\n * resolves with the locale omitted and the $locale loader bounces the user to\n * the fallback locale. Prefix the current locale onto internal paths that\n * don't already carry one.\n */\nexport function localizeDestination(destination: string, locale?: string) {\n if (!locale || !destination.startsWith('/') || destination.startsWith('//')) return destination;\n const firstSegment = destination.split('/')[1]?.split(/[?#]/)[0];\n if (isLocale(firstSegment)) return destination;\n return destination === '/' ? `/${locale}` : `/${locale}${destination}`;\n}\n\n/**\n * TanStack Router Link adapter.\n * Translates framework-agnostic props to TanStack Router Link props.\n */\nexport const TanStackLinkAdapter = forwardRef<HTMLAnchorElement, BaseLinkProps>(\n (\n {\n to,\n href,\n children,\n className,\n style,\n title,\n target,\n rel,\n onClick,\n preload,\n replace,\n 'aria-label': ariaLabel,\n ...rest\n },\n ref\n ) => {\n const { locale } = useParams({ strict: false }) as { locale?: string };\n const destination = localizeDestination(to ?? href ?? '/', locale);\n\n // `#` is how a block says it has nowhere to go, such as a banner with no URL. An anchor with\n // no href keeps the theme's `a` styles, and the router can neither preload nor follow it.\n if (destination === '#') {\n return createElement(\n 'a',\n { ref, className, style, title, onClick, 'aria-label': ariaLabel, ...rest },\n children\n );\n }\n\n return createElement(\n TanStackLink,\n {\n ref,\n to: destination,\n className,\n style,\n title,\n target,\n rel,\n onClick,\n preload: preload === 'intent' || preload === false ? preload : undefined,\n replace,\n 'aria-label': ariaLabel,\n ...(rest as Record<string, unknown>),\n },\n children\n );\n }\n);\n\nTanStackLinkAdapter.displayName = 'TanStackLinkAdapter';\n\n/**\n * Create a TanStack Router Link adapter component.\n */\nexport function createTanStackLinkAdapter() {\n return TanStackLinkAdapter;\n}\n","import { useEffect } from 'react';\nimport { useRouter } from '@tanstack/react-router';\nimport { resolveRelativePath } from '../providers/NavigationProvider';\nimport { useTwilight } from '../providers/twilight-context';\nimport { isLocale } from '../providers/locale-constants';\nimport { getTwilightContext } from '../twilight/context';\nimport { useIsNativeApp } from '../native-app';\nimport { onSallaEvent } from '../utils/sdk-helpers';\nimport { hasStoreUrlBase } from '../utils/store-base';\nimport { localizeDestination } from './link';\n\nconst UI_UPDATE_EVENT = 'mobile::ui.update';\nconst OPEN_ORDER_EVENT = 'mobile::open.order';\nconst NAVIGATE_TO_EVENT = 'mobile::navigate.to';\n\n/**\n * Events the native app sends into its webview. `NavigationSetup` mounts this once, so a\n * theme adds no listener of its own:\n *\n * - `mobile::ui.update` re-runs the route loaders and refetches what is on screen.\n * - `mobile::open.order` `{ id }` opens that order, with a fresh cart.\n * - `mobile::navigate.to` `{ url }` opens a notification deep link in-app. Only a link to\n * this store is followed (`deepLinkPath`), so `javascript:`, off-site and other stores'\n * URLs are dropped.\n *\n * Nothing is mounted outside the app (`useIsNativeApp()`), so a browser runs none of it.\n */\nexport function NativeAppEvents({ locale }: { locale?: string }) {\n return useIsNativeApp() ? <Listeners locale={locale} /> : null;\n}\n\nfunction Listeners({ locale }: { locale?: string }) {\n useNativeAppEvents(locale);\n return null;\n}\n\n/** The listeners themselves. `NativeAppEvents` mounts them inside the app only. */\nexport function useNativeAppEvents(locale?: string): void {\n const router = useRouter();\n const { store } = useTwilight();\n const storeUrl = store?.url;\n const username = store?.username;\n\n useEffect(() => {\n // `href`, not `to`: the router parses the query and the hash out of it.\n const open = (path: string) =>\n void router.navigate({ href: localizeDestination(path, locale) });\n\n const refresh = () => {\n void Promise.allSettled([\n router.invalidate(),\n getTwilightContext().queryClient?.refetchQueries({ type: 'active' }),\n ]);\n };\n const openOrder = (data?: unknown) => {\n const rawId = (data as { id?: unknown } | undefined)?.id;\n if (typeof rawId !== 'string' && typeof rawId !== 'number') return;\n\n const id = String(rawId).trim();\n if (!id) return;\n\n void getTwilightContext().queryClient?.invalidateQueries({ queryKey: ['cart'] });\n open(`/account/orders/${encodeURIComponent(id)}`);\n };\n const navigateTo = (data?: unknown) => {\n const url = (data as { url?: unknown } | undefined)?.url;\n if (typeof url !== 'string' || !url.trim() || !storeUrl) return;\n\n const path = deepLinkPath(url.trim(), storeUrl, username);\n if (path) void router.navigate({ href: inLocale(path, locale) });\n };\n\n const offs = [\n onSallaEvent(UI_UPDATE_EVENT, refresh),\n onSallaEvent(OPEN_ORDER_EVENT, openOrder),\n onSallaEvent(NAVIGATE_TO_EVENT, navigateTo),\n ];\n return () => offs.forEach((off) => off());\n }, [router, locale, storeUrl, username]);\n}\n\n/** A URL that names its host: `https://…` or `//…`. Anything else is a path of this app. */\nfunction isAbsoluteUrl(url: string): boolean {\n if (url.startsWith('//')) return true;\n try {\n // Without a base, only a URL with its own scheme parses.\n new URL(url);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * The application path of a deep link to this store, or null for any other link.\n *\n * It passes the test a tapped link does (`resolveRelativePath`: the store's origin, the\n * username taken off), and one more. On a shared host that origin is every store's, so\n * an absolute link has to carry this store's username: without it, another store's\n * `/ar/offers` would open this store's offers.\n */\nfunction deepLinkPath(url: string, storeUrl: string, username?: string): string | null {\n const path = resolveRelativePath(url, storeUrl, username);\n if (!path || !isAbsoluteUrl(url)) return path;\n\n // Both parse: `resolveRelativePath` returns null when either does not.\n const { pathname } = new URL(url, window.location.href);\n return hasStoreUrlBase(pathname, new URL(storeUrl).pathname, username) ? path : null;\n}\n\n/**\n * A deep link in the locale the visitor is browsing in. A notification is written in one\n * language and opened in whichever is on screen, so the link's own locale gives way.\n *\n * The prefix is written here, not by `localizeDestination`: that one leaves a path alone\n * when it already starts with a locale, and would take the slug of `/ar/en/p456` for one.\n */\nfunction inLocale(path: string, locale?: string): string {\n const first = path.split('/')[1]?.split(/[?#]/)[0];\n const own = isLocale(first) ? path.slice(first.length + 1) : path;\n const rest = own.startsWith('/') ? own : `/${own}`;\n\n if (!locale) return rest;\n return rest === '/' ? `/${locale}` : `/${locale}${rest}`;\n}\n","/**\n * What the request itself is enough to describe: its host.\n *\n * Small, and deliberately its own module rather than a helper inside the\n * middleware. This value decides two things — which store a live storefront is,\n * and whether the request is allowed to name a store at all — so it is worth\n * testing directly instead of only through the wiring that calls it.\n */\nimport { isLoopback } from './cookies';\n\n/** The part of a `Request` this needs, so a test does not have to build a whole one. */\nexport interface HostSource {\n url: string;\n headers: { get(name: string): string | null };\n}\n\n/**\n * The host this request arrived on, with its port when it has one.\n *\n * Taken from the request URL, which in a Worker is the address the platform\n * actually routed on, and from the `Host` header only when that fails.\n *\n * **`X-Forwarded-Host` is deliberately not consulted.** A client can set it, and\n * this value gates `allowsRequestStoreId` — so honouring it would be a way to\n * talk a merchant's own domain into behaving like the preview host, and from\n * there into serving a stranger's shop. The dispatcher strips that header today;\n * a theme must not be one edit to another repository's allowlist away from a\n * spoofable identity.\n */\nexport function requestHostOf(request: HostSource): string | null {\n try {\n const fromUrl = new URL(request.url).host;\n if (fromUrl) return fromUrl;\n } catch {\n /* an unparseable URL falls through to the header */\n }\n\n return request.headers.get('Host')?.trim() || null;\n}\n\n/** The origin a browser reached this host on: `http` for a dev server, `https` otherwise. */\nexport function requestOriginOf(host: string): string {\n return `${isLoopback(host.replace(/:\\d+$/, '')) ? 'http' : 'https'}://${host}`;\n}\n","import {\n useNavigate,\n useParams,\n redirect as tanstackRedirect,\n notFound as tanstackNotFound,\n} from '@tanstack/react-router';\nimport {\n NavigationProvider,\n configureNavigation,\n type NavigateOptions,\n} from '../providers/NavigationProvider';\nimport { LinkProvider } from '../providers/LinkProvider';\nimport { TanStackLinkAdapter, localizeDestination } from './link';\nimport { NativeAppEvents } from './native-app-events';\nimport { useCallback, type ReactNode } from 'react';\nimport { UnauthorizedError, type RedirectOptions } from '../providers/NavigationProvider';\nimport { getRequestStore, getTwilightContext } from '../twilight/context';\nimport { resolveStoreBase, resolveStoreBaseFollowsLocale } from '../utils/store-identity';\nimport { loginRedirectHref } from '../utils/store-base';\nimport { requestOriginOf } from '../utils/request-host';\n\nfunction currentOrigin(): string | null {\n if (typeof window !== 'undefined') return window.location.origin;\n const host = getRequestStore().requestHost;\n return host ? requestOriginOf(host) : null;\n}\n\nconfigureNavigation({\n notFound: (message?: string) => {\n throw tanstackNotFound({ data: message });\n },\n redirect: (path: string, opts?: RedirectOptions) => {\n throw tanstackRedirect({ to: path, replace: opts?.replace, statusCode: opts?.statusCode });\n },\n unauthorized: (message?: string) => {\n const origin = currentOrigin();\n const { pathname, searchStr } = getTwilightContext().location;\n const href =\n origin &&\n loginRedirectHref({\n pathname,\n searchStr,\n origin,\n base: resolveStoreBase(),\n baseFollowsLocale: resolveStoreBaseFollowsLocale(),\n });\n // A full load, because the SDK only reads `intended_to` when a page starts.\n if (href) throw tanstackRedirect({ href, reloadDocument: true, replace: true });\n throw new UnauthorizedError(message);\n },\n});\n\n/**\n * TanStack navigation setup - wraps children with NavigationProvider and LinkProvider.\n * Called by TwilightProvider when client.framework === 'tanstack'.\n */\nexport function NavigationSetup({ children }: { children: ReactNode }) {\n const navigate = useNavigate();\n const { locale } = useParams({ strict: false }) as { locale?: string };\n const navigateFn = useCallback(\n (to: string, opts?: NavigateOptions) =>\n navigate({ to: localizeDestination(to, locale), replace: opts?.replace }),\n [navigate, locale]\n );\n\n return (\n <NavigationProvider navigate={navigateFn}>\n <NativeAppEvents locale={locale} />\n <LinkProvider adapter={TanStackLinkAdapter}>{children}</LinkProvider>\n </NavigationProvider>\n );\n}\n\n/** @deprecated Use NavigationSetup instead */\nexport function TanStackNavigationProvider({ children }: { children: ReactNode }) {\n const navigate = useNavigate();\n return (\n <NavigationProvider\n navigate={(to: string, opts?: NavigateOptions) => navigate({ to, replace: opts?.replace })}\n >\n <LinkProvider adapter={TanStackLinkAdapter}>{children}</LinkProvider>\n </NavigationProvider>\n );\n}\n"]}
|
package/dist/chunk-SIYINCXL.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { redirect } from './chunk-ZBGMIDDO.js';
|
|
2
|
-
import { clearAuthTokenCookie } from './chunk-EEL6OYAQ.js';
|
|
3
|
-
import { FALLBACK_LOCALE } from './chunk-T72DAX7R.js';
|
|
4
|
-
import { useEffect } from 'react';
|
|
5
|
-
|
|
6
|
-
async function slugBrandRedirectLoader(ctx) {
|
|
7
|
-
const locale = ctx.params.locale || FALLBACK_LOCALE;
|
|
8
|
-
throw redirect(`/${locale}/brands/${ctx.params.id}`);
|
|
9
|
-
}
|
|
10
|
-
async function pendingOrdersRedirectLoader(ctx = { params: {} }) {
|
|
11
|
-
const locale = ctx.params.locale || FALLBACK_LOCALE;
|
|
12
|
-
throw redirect(`/${locale}/account/orders?status=pending`);
|
|
13
|
-
}
|
|
14
|
-
async function ratingRedirectLoader(ctx = { params: {} }) {
|
|
15
|
-
const locale = ctx.params.locale || FALLBACK_LOCALE;
|
|
16
|
-
throw redirect(`/${locale}/account/orders`);
|
|
17
|
-
}
|
|
18
|
-
async function accountRedirectLoader(ctx) {
|
|
19
|
-
const prefix = ctx.params.locale ? `/${ctx.params.locale}` : "";
|
|
20
|
-
throw redirect(`${prefix}/account/${ctx.page}${ctx.search ?? ""}`, { statusCode: 301 });
|
|
21
|
-
}
|
|
22
|
-
async function productsSourceRedirectLoader(ctx) {
|
|
23
|
-
const prefix = ctx.params.locale ? `/${ctx.params.locale}` : "";
|
|
24
|
-
const query = new URLSearchParams(ctx.search);
|
|
25
|
-
query.delete("source");
|
|
26
|
-
const rest = query.toString();
|
|
27
|
-
throw redirect(`${prefix}/products?source=${ctx.source}${rest ? `&${rest}` : ""}`, {
|
|
28
|
-
statusCode: 301
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
function LogoutRedirect() {
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
clearAuthTokenCookie();
|
|
34
|
-
window.location.replace(window.location.href.replace(/\/logout\/?(\?[^#]*)?(#.*)?$/, ""));
|
|
35
|
-
}, []);
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export { LogoutRedirect, accountRedirectLoader, pendingOrdersRedirectLoader, productsSourceRedirectLoader, ratingRedirectLoader, slugBrandRedirectLoader };
|
|
40
|
-
//# sourceMappingURL=chunk-SIYINCXL.js.map
|
|
41
|
-
//# sourceMappingURL=chunk-SIYINCXL.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/routes/seo-redirects.ts"],"names":[],"mappings":";;;;;AAcA,eAAsB,wBAAwB,GAAA,EAAkD;AAC9F,EAAA,MAAM,MAAA,GAAS,GAAA,CAAI,MAAA,CAAO,MAAA,IAAU,eAAA;AACpC,EAAA,MAAM,SAAS,CAAA,CAAA,EAAI,MAAM,WAAW,GAAA,CAAI,MAAA,CAAO,EAAE,CAAA,CAAE,CAAA;AACrD;AAOA,eAAsB,4BACpB,GAAA,GAA+C,EAAE,MAAA,EAAQ,IAAG,EAC5C;AAChB,EAAA,MAAM,MAAA,GAAS,GAAA,CAAI,MAAA,CAAO,MAAA,IAAU,eAAA;AACpC,EAAA,MAAM,QAAA,CAAS,CAAA,CAAA,EAAI,MAAM,CAAA,8BAAA,CAAgC,CAAA;AAC3D;AAGA,eAAsB,qBACpB,GAAA,GAA+C,EAAE,MAAA,EAAQ,IAAG,EAC5C;AAChB,EAAA,MAAM,MAAA,GAAS,GAAA,CAAI,MAAA,CAAO,MAAA,IAAU,eAAA;AACpC,EAAA,MAAM,QAAA,CAAS,CAAA,CAAA,EAAI,MAAM,CAAA,eAAA,CAAiB,CAAA;AAC5C;AAGA,eAAsB,sBAAsB,GAAA,EAKzB;AAEjB,EAAA,MAAM,MAAA,GAAS,IAAI,MAAA,CAAO,MAAA,GAAS,IAAI,GAAA,CAAI,MAAA,CAAO,MAAM,CAAA,CAAA,GAAK,EAAA;AAC7D,EAAA,MAAM,QAAA,CAAS,CAAA,EAAG,MAAM,CAAA,SAAA,EAAY,IAAI,IAAI,CAAA,EAAG,GAAA,CAAI,MAAA,IAAU,EAAE,CAAA,CAAA,EAAI,EAAE,UAAA,EAAY,KAAK,CAAA;AACxF;AAGA,eAAsB,6BAA6B,GAAA,EAIhC;AACjB,EAAA,MAAM,MAAA,GAAS,IAAI,MAAA,CAAO,MAAA,GAAS,IAAI,GAAA,CAAI,MAAA,CAAO,MAAM,CAAA,CAAA,GAAK,EAAA;AAC7D,EAAA,MAAM,KAAA,GAAQ,IAAI,eAAA,CAAgB,GAAA,CAAI,MAAM,CAAA;AAC5C,EAAA,KAAA,CAAM,OAAO,QAAQ,CAAA;AACrB,EAAA,MAAM,IAAA,GAAO,MAAM,QAAA,EAAS;AAC5B,EAAA,MAAM,QAAA,CAAS,CAAA,EAAG,MAAM,CAAA,iBAAA,EAAoB,GAAA,CAAI,MAAM,CAAA,EAAG,IAAA,GAAO,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA,GAAK,EAAE,CAAA,CAAA,EAAI;AAAA,IACjF,UAAA,EAAY;AAAA,GACb,CAAA;AACH;AAUO,SAAS,cAAA,GAAuB;AACrC,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,oBAAA,EAAqB;AAErB,IAAA,MAAA,CAAO,QAAA,CAAS,QAAQ,MAAA,CAAO,QAAA,CAAS,KAAK,OAAA,CAAQ,8BAAA,EAAgC,EAAE,CAAC,CAAA;AAAA,EAC1F,CAAA,EAAG,EAAE,CAAA;AACL,EAAA,OAAO,IAAA;AACT","file":"chunk-SIYINCXL.js","sourcesContent":["import { useEffect } from 'react';\nimport { redirect } from '../providers/NavigationProvider';\nimport { FALLBACK_LOCALE } from '../providers/locale-constants';\nimport { clearAuthTokenCookie } from '../utils/cookies';\n\nexport interface SlugBrandParams {\n /** SEO slug segment (ignored — only here to match the route pattern). */\n slug: string;\n /** Brand numeric ID to redirect to. */\n id: string;\n /** Active locale from the `/$locale` parent layout (e.g. `'ar'`, `'en'`). */\n locale?: string;\n}\n\nexport async function slugBrandRedirectLoader(ctx: { params: SlugBrandParams }): Promise<never> {\n const locale = ctx.params.locale || FALLBACK_LOCALE;\n throw redirect(`/${locale}/brands/${ctx.params.id}`);\n}\n\nexport interface PendingOrdersRedirectParams {\n /** Active locale from the `/$locale` parent layout (e.g. `'ar'`, `'en'`). */\n locale?: string;\n}\n\nexport async function pendingOrdersRedirectLoader(\n ctx: { params: PendingOrdersRedirectParams } = { params: {} }\n): Promise<never> {\n const locale = ctx.params.locale || FALLBACK_LOCALE;\n throw redirect(`/${locale}/account/orders?status=pending`);\n}\n\n/** `/account/rating`: the loyalty \"rate your orders\" link. Twig Raed has no rating page and sends it to the orders list. */\nexport async function ratingRedirectLoader(\n ctx: { params: PendingOrdersRedirectParams } = { params: {} }\n): Promise<never> {\n const locale = ctx.params.locale || FALLBACK_LOCALE;\n throw redirect(`/${locale}/account/orders`);\n}\n\n/** A Twig customer URL (`/profile`, `/orders`, …) kept working as its `/account/…` page. */\nexport async function accountRedirectLoader(ctx: {\n params: PendingOrdersRedirectParams;\n page: string;\n /** The incoming query string (`?status=pending`), kept on the account page. */\n search?: string;\n}): Promise<never> {\n // No locale in the URL stays without one: the locale layout adds it only where the store has several.\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n throw redirect(`${prefix}/account/${ctx.page}${ctx.search ?? ''}`, { statusCode: 301 });\n}\n\n/** `/latest-products`, `/most-sales-products` and `/offers` now live at `/products?source=`. */\nexport async function productsSourceRedirectLoader(ctx: {\n params: PendingOrdersRedirectParams;\n source: 'latest' | 'sales' | 'offers';\n search?: string;\n}): Promise<never> {\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n const query = new URLSearchParams(ctx.search);\n query.delete('source');\n const rest = query.toString();\n throw redirect(`${prefix}/products?source=${ctx.source}${rest ? `&${rest}` : ''}`, {\n statusCode: 301,\n });\n}\n\n/**\n * `/logout` — where the SDK sends the browser once `salla.auth.logout()` has run\n * (`salla.url.get('logout?from=…')`). The Twig storefront serves that URL server-side. Here\n * it renders nothing and, in the browser, removes the theme's own `token` cookie (the SDK's\n * `cookie.clearAll()` leaves it) and then does a full navigation home. It has to be a\n * component, not a loader redirect: a loader runs during server rendering, where the cookie\n * can't be cleared, so the redirect would leave the visitor signed in on the next request.\n */\nexport function LogoutRedirect(): null {\n useEffect(() => {\n clearAuthTokenCookie();\n // `/{store base}/{locale}/logout?from=…` → `/{store base}/{locale}`\n window.location.replace(window.location.href.replace(/\\/logout\\/?(\\?[^#]*)?(#.*)?$/, ''));\n }, []);\n return null;\n}\n"]}
|