@salla.sa/twilight-theme-engine 1.0.67 → 1.0.69
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-UVQG3BI5.js → AddToCartForm-V5Q4YFK7.js} +3 -3
- package/dist/{AddToCartForm-UVQG3BI5.js.map → AddToCartForm-V5Q4YFK7.js.map} +1 -1
- package/dist/{BlogAuthorPage-7HVGT3CS.js → BlogAuthorPage-EYCANLF2.js} +17 -17
- package/dist/{BlogAuthorPage-7HVGT3CS.js.map → BlogAuthorPage-EYCANLF2.js.map} +1 -1
- package/dist/{BlogCategoryPage-MSITS6B3.js → BlogCategoryPage-HVKYA62V.js} +17 -17
- package/dist/{BlogCategoryPage-MSITS6B3.js.map → BlogCategoryPage-HVKYA62V.js.map} +1 -1
- package/dist/{BlogPage-6FLWZBK3.js → BlogPage-CQLHFLXK.js} +15 -15
- package/dist/{BlogPage-6FLWZBK3.js.map → BlogPage-CQLHFLXK.js.map} +1 -1
- package/dist/{BlogSinglePage-LSF5P4GA.js → BlogSinglePage-Y4GTYEX5.js} +15 -15
- package/dist/{BlogSinglePage-LSF5P4GA.js.map → BlogSinglePage-Y4GTYEX5.js.map} +1 -1
- package/dist/{BlogTagPage-JPOF3OC4.js → BlogTagPage-7BHVS4M2.js} +17 -17
- package/dist/{BlogTagPage-JPOF3OC4.js.map → BlogTagPage-7BHVS4M2.js.map} +1 -1
- package/dist/{BrandsPage-7G5VWJ2S.js → BrandsPage-ZJWQFMLT.js} +16 -16
- package/dist/{BrandsPage-7G5VWJ2S.js.map → BrandsPage-ZJWQFMLT.js.map} +1 -1
- package/dist/{Breadcrumb-MNYKDV27.js → Breadcrumb-VQQDHSCR.js} +15 -15
- package/dist/{Breadcrumb-MNYKDV27.js.map → Breadcrumb-VQQDHSCR.js.map} +1 -1
- package/dist/{CartItem-DNA2TJ6B.js → CartItem-3LBPOY7V.js} +15 -15
- package/dist/{CartItem-DNA2TJ6B.js.map → CartItem-3LBPOY7V.js.map} +1 -1
- package/dist/{CartSummary-RTDKJUV7.js → CartSummary-4L7L3566.js} +15 -15
- package/dist/{CartSummary-RTDKJUV7.js.map → CartSummary-4L7L3566.js.map} +1 -1
- package/dist/{Copyright-IR4VD3I6.js → Copyright-PPGYFGPF.js} +3 -3
- package/dist/{Copyright-IR4VD3I6.js.map → Copyright-PPGYFGPF.js.map} +1 -1
- package/dist/{CustomerLayout-6YWOUFEN.js → CustomerLayout-HWBZ54GG.js} +15 -15
- package/dist/{CustomerLayout-6YWOUFEN.js.map → CustomerLayout-HWBZ54GG.js.map} +1 -1
- package/dist/{Footer-YQHS47HV.js → Footer-Q5EZE6RQ.js} +15 -15
- package/dist/{Footer-YQHS47HV.js.map → Footer-Q5EZE6RQ.js.map} +1 -1
- package/dist/{Header-VEI2M3XJ.js → Header-Y3KW2LCJ.js} +4 -4
- package/dist/{Header-VEI2M3XJ.js.map → Header-Y3KW2LCJ.js.map} +1 -1
- package/dist/{LoyaltyPage-L7LABJWG.js → LoyaltyPage-SLRGEINN.js} +15 -15
- package/dist/{LoyaltyPage-L7LABJWG.js.map → LoyaltyPage-SLRGEINN.js.map} +1 -1
- package/dist/{LoyaltyPointsPage-Z2GAMWCG.js → LoyaltyPointsPage-ELOIXQJH.js} +3 -3
- package/dist/{LoyaltyPointsPage-Z2GAMWCG.js.map → LoyaltyPointsPage-ELOIXQJH.js.map} +1 -1
- package/dist/{MainMenu-76GBUVNZ.js → MainMenu-IVZDV6HY.js} +6 -6
- package/dist/{MainMenu-76GBUVNZ.js.map → MainMenu-IVZDV6HY.js.map} +1 -1
- package/dist/{MasterLayout-GEQBU2MH.js → MasterLayout-GKZ5F73U.js} +15 -15
- package/dist/{MasterLayout-GEQBU2MH.js.map → MasterLayout-GKZ5F73U.js.map} +1 -1
- package/dist/{MobileMenu-DS5OJRCO.js → MobileMenu-SCAWSSXT.js} +16 -16
- package/dist/{MobileMenu-DS5OJRCO.js.map → MobileMenu-SCAWSSXT.js.map} +1 -1
- package/dist/{NotificationsPage-OT2WY2EF.js → NotificationsPage-O42AKXIZ.js} +15 -15
- package/dist/{NotificationsPage-OT2WY2EF.js.map → NotificationsPage-O42AKXIZ.js.map} +1 -1
- package/dist/{OrderSinglePage-XGPSBIA3.js → OrderSinglePage-R7Z2YDO4.js} +16 -16
- package/dist/{OrderSinglePage-XGPSBIA3.js.map → OrderSinglePage-R7Z2YDO4.js.map} +1 -1
- package/dist/{OrdersPage-A5TARKJ7.js → OrdersPage-DHV7YH7A.js} +15 -15
- package/dist/{OrdersPage-A5TARKJ7.js.map → OrdersPage-DHV7YH7A.js.map} +1 -1
- package/dist/{PageSingle-VUNU2BG4.js → PageSingle-TH4W7HCK.js} +9 -4
- package/dist/PageSingle-TH4W7HCK.js.map +1 -0
- package/dist/{ProductDetails-2JWKUXLI.js → ProductDetails-JC4V7MIG.js} +3 -3
- package/dist/{ProductDetails-2JWKUXLI.js.map → ProductDetails-JC4V7MIG.js.map} +1 -1
- package/dist/{ProfilePage-AVUCRBHQ.js → ProfilePage-F5NO3B4C.js} +15 -15
- package/dist/{ProfilePage-AVUCRBHQ.js.map → ProfilePage-F5NO3B4C.js.map} +1 -1
- package/dist/{SeoCartWidget-X5HTL62D.js → SeoCartWidget-GSGSRTJN.js} +19 -21
- package/dist/SeoCartWidget-GSGSRTJN.js.map +1 -0
- package/dist/{SettingsPage-WGGKT3I4.js → SettingsPage-BYYBYEEQ.js} +15 -15
- package/dist/{SettingsPage-WGGKT3I4.js.map → SettingsPage-BYYBYEEQ.js.map} +1 -1
- package/dist/{StoreClosedNotification-XDYQO7JF.js → StoreClosedNotification-TMVQPUSU.js} +16 -16
- package/dist/{StoreClosedNotification-XDYQO7JF.js.map → StoreClosedNotification-TMVQPUSU.js.map} +1 -1
- package/dist/{TestimonialsPage-CKAYXFER.js → TestimonialsPage-WXSORMJA.js} +8 -4
- package/dist/TestimonialsPage-WXSORMJA.js.map +1 -0
- package/dist/{ThankYouPage-ZTCFTEI7.js → ThankYouPage-FVWY3VBU.js} +16 -21
- package/dist/ThankYouPage-FVWY3VBU.js.map +1 -0
- package/dist/{WalletPage-XKAOZIO2.js → WalletPage-XYU47SH2.js} +16 -16
- package/dist/{WalletPage-XKAOZIO2.js.map → WalletPage-XYU47SH2.js.map} +1 -1
- package/dist/{WishlistPage-LHIUUR4U.js → WishlistPage-GHMUTPSM.js} +18 -23
- package/dist/WishlistPage-GHMUTPSM.js.map +1 -0
- package/dist/api/apps.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.d.ts.map +1 -1
- package/dist/api/client.js +2 -2
- package/dist/api/home.d.ts +9 -3
- package/dist/api/home.d.ts.map +1 -1
- package/dist/api/home.js +3 -3
- package/dist/api/loyalty.js +3 -3
- package/dist/api/menu.js +3 -3
- package/dist/api/notification.js +3 -3
- 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 +2 -2
- package/dist/api/store.d.ts +6 -0
- package/dist/api/store.d.ts.map +1 -1
- package/dist/api/store.js +3 -3
- package/dist/api/translations.js +3 -3
- package/dist/api/user.js +3 -3
- package/dist/api/wishlist.js +4 -4
- package/dist/{chunk-6IRWFBGU.js → chunk-2D5HJQZK.js} +3 -3
- package/dist/{chunk-6IRWFBGU.js.map → chunk-2D5HJQZK.js.map} +1 -1
- package/dist/{chunk-HDO37URJ.js → chunk-44ZVB7F5.js} +3 -3
- package/dist/{chunk-HDO37URJ.js.map → chunk-44ZVB7F5.js.map} +1 -1
- package/dist/{chunk-W5K6YUA2.js → chunk-5NUQ6UAK.js} +6 -6
- package/dist/{chunk-W5K6YUA2.js.map → chunk-5NUQ6UAK.js.map} +1 -1
- package/dist/{chunk-TOPFB6FL.js → chunk-634A6AYN.js} +3 -3
- package/dist/{chunk-TOPFB6FL.js.map → chunk-634A6AYN.js.map} +1 -1
- package/dist/{chunk-SOPZ72BU.js → chunk-66JAXHHY.js} +3 -3
- package/dist/{chunk-SOPZ72BU.js.map → chunk-66JAXHHY.js.map} +1 -1
- package/dist/{chunk-P3OPJL6I.js → chunk-6ETNDIHM.js} +9 -7
- package/dist/chunk-6ETNDIHM.js.map +1 -0
- package/dist/{chunk-VAW73MFZ.js → chunk-AEPBDT5F.js} +10 -9
- package/dist/chunk-AEPBDT5F.js.map +1 -0
- package/dist/{chunk-FAVZMJRY.js → chunk-AMASCYNB.js} +6 -6
- package/dist/{chunk-FAVZMJRY.js.map → chunk-AMASCYNB.js.map} +1 -1
- package/dist/{chunk-EFMAB636.js → chunk-BRZ74D5D.js} +3 -3
- package/dist/{chunk-EFMAB636.js.map → chunk-BRZ74D5D.js.map} +1 -1
- package/dist/{chunk-UIOLSYKV.js → chunk-CUKPKJCF.js} +3 -3
- package/dist/{chunk-UIOLSYKV.js.map → chunk-CUKPKJCF.js.map} +1 -1
- package/dist/{chunk-GYXT7T2Z.js → chunk-DCH3X6TO.js} +3 -3
- package/dist/{chunk-GYXT7T2Z.js.map → chunk-DCH3X6TO.js.map} +1 -1
- package/dist/{chunk-EYFMLMMF.js → chunk-DWIS2VUE.js} +3 -3
- package/dist/{chunk-EYFMLMMF.js.map → chunk-DWIS2VUE.js.map} +1 -1
- package/dist/{chunk-5X2UFNKY.js → chunk-EARXTU6P.js} +3 -3
- package/dist/{chunk-5X2UFNKY.js.map → chunk-EARXTU6P.js.map} +1 -1
- package/dist/{chunk-Y43T7PJV.js → chunk-FZH27PXS.js} +5 -4
- package/dist/chunk-FZH27PXS.js.map +1 -0
- package/dist/{chunk-FRFTO2HP.js → chunk-G73YJT4F.js} +6 -6
- package/dist/{chunk-FRFTO2HP.js.map → chunk-G73YJT4F.js.map} +1 -1
- package/dist/{chunk-RJAVZBUK.js → chunk-GEQKQQND.js} +3 -3
- package/dist/{chunk-RJAVZBUK.js.map → chunk-GEQKQQND.js.map} +1 -1
- package/dist/{chunk-EAZGFREP.js → chunk-GL6QTNZA.js} +3 -3
- package/dist/{chunk-EAZGFREP.js.map → chunk-GL6QTNZA.js.map} +1 -1
- package/dist/chunk-HURQEDJZ.js +14 -0
- package/dist/{chunk-TFROBJP5.js.map → chunk-HURQEDJZ.js.map} +1 -1
- package/dist/{chunk-VI5R46KX.js → chunk-IDRGC4LA.js} +7 -7
- package/dist/{chunk-VI5R46KX.js.map → chunk-IDRGC4LA.js.map} +1 -1
- package/dist/{chunk-EQ32CL4D.js → chunk-KPEG5XY3.js} +7 -6
- package/dist/chunk-KPEG5XY3.js.map +1 -0
- package/dist/{chunk-VKB5AQUS.js → chunk-KRUPRDOL.js} +3 -3
- package/dist/{chunk-VKB5AQUS.js.map → chunk-KRUPRDOL.js.map} +1 -1
- package/dist/{chunk-VGIK4BW6.js → chunk-M5WPU7BR.js} +4 -4
- package/dist/{chunk-VGIK4BW6.js.map → chunk-M5WPU7BR.js.map} +1 -1
- package/dist/{chunk-UZKTK6YV.js → chunk-OJW6UOS4.js} +3 -3
- package/dist/{chunk-UZKTK6YV.js.map → chunk-OJW6UOS4.js.map} +1 -1
- package/dist/{chunk-3Q22KK7C.js → chunk-OVYCFJGU.js} +5 -5
- package/dist/{chunk-3Q22KK7C.js.map → chunk-OVYCFJGU.js.map} +1 -1
- package/dist/{chunk-PWBMSGMU.js → chunk-P6CLO4M7.js} +6 -23
- package/dist/chunk-P6CLO4M7.js.map +1 -0
- package/dist/chunk-RCHTHIIZ.js +90 -0
- package/dist/chunk-RCHTHIIZ.js.map +1 -0
- package/dist/{chunk-RH5VLLTG.js → chunk-RMFDKT5P.js} +4 -4
- package/dist/{chunk-RH5VLLTG.js.map → chunk-RMFDKT5P.js.map} +1 -1
- package/dist/{chunk-A4UQKSOU.js → chunk-SBXD5CSG.js} +4 -4
- package/dist/{chunk-A4UQKSOU.js.map → chunk-SBXD5CSG.js.map} +1 -1
- package/dist/{chunk-3L5VG2X4.js → chunk-URWXE2RQ.js} +4 -4
- package/dist/{chunk-3L5VG2X4.js.map → chunk-URWXE2RQ.js.map} +1 -1
- package/dist/{chunk-UEQFXSTX.js → chunk-VR4FXFPY.js} +124 -119
- package/dist/chunk-VR4FXFPY.js.map +1 -0
- package/dist/{chunk-TTMYT3RB.js → chunk-W5MS4UNG.js} +3 -3
- package/dist/{chunk-TTMYT3RB.js.map → chunk-W5MS4UNG.js.map} +1 -1
- package/dist/{chunk-Q3COPV5Z.js → chunk-X3GCZAOZ.js} +3 -3
- package/dist/{chunk-Q3COPV5Z.js.map → chunk-X3GCZAOZ.js.map} +1 -1
- package/dist/{chunk-FTM3RIVB.js → chunk-YKWNH4S2.js} +3 -3
- package/dist/{chunk-FTM3RIVB.js.map → chunk-YKWNH4S2.js.map} +1 -1
- package/dist/{chunk-GOPUP26T.js → chunk-YNWP5VPR.js} +4 -9
- package/dist/chunk-YNWP5VPR.js.map +1 -0
- package/dist/components/cart/SeoCartWidget.d.ts.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 +13 -13
- package/dist/components/home/index.js +17 -17
- package/dist/components/layout/index.js +1 -1
- package/dist/components/product/index.js +14 -14
- package/dist/components/store/index.js +15 -15
- package/dist/{document-class-SPTMBRWL.js → document-class-NUILLVSR.js} +9 -9
- package/dist/{document-class-SPTMBRWL.js.map → document-class-NUILLVSR.js.map} +1 -1
- package/dist/hooks/index.js +13 -13
- package/dist/hooks/useComments.d.ts.map +1 -1
- package/dist/hooks/useComments.js +6 -1
- package/dist/hooks/useGtm.js +13 -13
- package/dist/hooks/useMoney.js +13 -13
- package/dist/hooks/usePageConfig.d.ts.map +1 -1
- package/dist/hooks/useProduct.d.ts.map +1 -1
- package/dist/hooks/useProduct.js +6 -1
- package/dist/hooks/useStore.js +13 -13
- package/dist/hooks/useUser.js +4 -4
- package/dist/index.js +13 -13
- package/dist/{not-found-T2WYF64G.js → not-found-63YCT7SJ.js} +16 -16
- package/dist/{not-found-T2WYF64G.js.map → not-found-63YCT7SJ.js.map} +1 -1
- package/dist/providers/TwilightProvider.d.ts.map +1 -1
- package/dist/providers/index.js +13 -13
- package/dist/providers/twilight-init.d.ts.map +1 -1
- package/dist/routes/account/orders.js +4 -4
- package/dist/routes/account/wishlist/WishlistPage.d.ts.map +1 -1
- 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/loyalty.js +5 -5
- package/dist/routes/page.js +4 -4
- package/dist/routes/product-listing/ProductListPage.d.ts.map +1 -1
- package/dist/routes/product-listing/useAppliedFilters.d.ts.map +1 -1
- package/dist/routes/product-listing.js +21 -29
- package/dist/routes/product-listing.js.map +1 -1
- package/dist/routes/product.js +17 -17
- package/dist/routes/root/beforeLoad.d.ts.map +1 -1
- package/dist/routes/testimonials.js +1 -1
- package/dist/routes/thank-you/ThankYouPage.d.ts.map +1 -1
- package/dist/routes/thank-you.js +4 -4
- package/dist/skeleton.js +18 -18
- package/dist/tanstack.js +8 -8
- package/dist/types/salla-sdk.d.ts +8 -0
- package/dist/types/salla-sdk.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -2
- package/dist/utils/sdk-helpers.d.ts +49 -0
- package/dist/utils/sdk-helpers.d.ts.map +1 -1
- package/dist/utils/theme-version.d.ts +14 -1
- package/dist/utils/theme-version.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/PageSingle-VUNU2BG4.js.map +0 -1
- package/dist/SeoCartWidget-X5HTL62D.js.map +0 -1
- package/dist/TestimonialsPage-CKAYXFER.js.map +0 -1
- package/dist/ThankYouPage-ZTCFTEI7.js.map +0 -1
- package/dist/WishlistPage-LHIUUR4U.js.map +0 -1
- package/dist/chunk-EQ32CL4D.js.map +0 -1
- package/dist/chunk-GOPUP26T.js.map +0 -1
- package/dist/chunk-P3OPJL6I.js.map +0 -1
- package/dist/chunk-PWBMSGMU.js.map +0 -1
- package/dist/chunk-TFROBJP5.js +0 -14
- package/dist/chunk-UEQFXSTX.js.map +0 -1
- package/dist/chunk-VAW73MFZ.js.map +0 -1
- package/dist/chunk-WY4IYO3G.js +0 -25
- package/dist/chunk-WY4IYO3G.js.map +0 -1
- package/dist/chunk-Y43T7PJV.js.map +0 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export type { StoreContext } from '../api/store';
|
|
2
|
+
import type { StoreContext } from '../api/store';
|
|
3
|
+
import type { SallaSDK } from '../types/salla-sdk';
|
|
2
4
|
/**
|
|
3
5
|
* Which store to ask the API about — see {@link resolveStoreIdentifier}.
|
|
4
6
|
*
|
|
@@ -16,6 +18,41 @@ export declare function getStoreIdentifier(explicit?: string): string;
|
|
|
16
18
|
* Get Salla SDK instance if available
|
|
17
19
|
*/
|
|
18
20
|
export declare function getSallaSDK(): typeof window.salla | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Run `callback` with the SDK as soon as it has loaded: now if it has, otherwise
|
|
23
|
+
* when it announces itself.
|
|
24
|
+
*
|
|
25
|
+
* Returns a cancel for an effect's cleanup, so a component that unmounts first
|
|
26
|
+
* never has the callback run. An effect that returned early when the SDK was not
|
|
27
|
+
* there yet never ran again — on a cold load, where hydration beats the SDK, the
|
|
28
|
+
* engine never initialised it at all.
|
|
29
|
+
*/
|
|
30
|
+
export declare function whenSallaLoaded(callback: (sdk: SallaSDK) => void): () => void;
|
|
31
|
+
/**
|
|
32
|
+
* Run `callback` once the SDK has loaded **and been initialised** — for work that
|
|
33
|
+
* talks to the API, which needs the store config `init` sets.
|
|
34
|
+
*
|
|
35
|
+
* Loaded is not enough for that: `init` finishes asynchronously, so a cart lookup
|
|
36
|
+
* made the moment the SDK announces itself goes out without a store identifier
|
|
37
|
+
* and is answered `Store Identifier not found`. Returns a cancel, as
|
|
38
|
+
* {@link whenSallaLoaded} does.
|
|
39
|
+
*
|
|
40
|
+
* A rejected `onReady` still runs `callback`, as `useTwilightInit` carries on past
|
|
41
|
+
* one: it means a partial initialisation, and waiting on it would leave the caller
|
|
42
|
+
* waiting for good.
|
|
43
|
+
*/
|
|
44
|
+
export declare function whenSallaReady(callback: (sdk: SallaSDK) => void): () => void;
|
|
45
|
+
/**
|
|
46
|
+
* `salla.event.on(name, listener)` once the SDK has loaded. Returns the matching
|
|
47
|
+
* unsubscribe, which also cancels a subscription still waiting for the SDK.
|
|
48
|
+
*
|
|
49
|
+
* Removed from the emitter it was added to, not from whatever `window.salla` is
|
|
50
|
+
* by the time the component unmounts.
|
|
51
|
+
*
|
|
52
|
+
* Waits for an event bus specifically, not for "loaded": an SDK is recognised by
|
|
53
|
+
* `init` alone, and subscribing on one without a bus would throw.
|
|
54
|
+
*/
|
|
55
|
+
export declare function onSallaEvent(name: string, listener: (...args: unknown[]) => void): () => void;
|
|
19
56
|
/**
|
|
20
57
|
* Push the active route locale onto the Salla SDK.
|
|
21
58
|
*
|
|
@@ -35,4 +72,16 @@ export declare function getSallaSDK(): typeof window.salla | undefined;
|
|
|
35
72
|
* header correct. No-op on the server and until the SDK exposes the methods.
|
|
36
73
|
*/
|
|
37
74
|
export declare function syncSdkLocale(locale: string): void;
|
|
75
|
+
/**
|
|
76
|
+
* Push the theme version the current settings name onto the Salla SDK.
|
|
77
|
+
*
|
|
78
|
+
* The SDK copies `settings.headers` into its axios defaults ONCE, at init, and
|
|
79
|
+
* `s-version-id` is one of them. Settings refetched on the client — the shopper
|
|
80
|
+
* switched market, and each market has its own version — name a different one,
|
|
81
|
+
* and without this every `salla.api.*` call keeps asking for the previous
|
|
82
|
+
* market's version until a full page load. Settings that name no version take
|
|
83
|
+
* the header off instead, so the SDK asks for the live one like the engine's own
|
|
84
|
+
* client does. No-op on the server and until the SDK exposes its api.
|
|
85
|
+
*/
|
|
86
|
+
export declare function syncSdkThemeVersion(headers: StoreContext['headers']): void;
|
|
38
87
|
//# sourceMappingURL=sdk-helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-helpers.d.ts","sourceRoot":"","sources":["../../src/utils/sdk-helpers.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk-helpers.d.ts","sourceRoot":"","sources":["../../src/utils/sdk-helpers.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAKnD;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,OAAO,MAAM,CAAC,KAAK,GAAG,SAAS,CAG7D;AA4BD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,QAAQ,KAAK,IAAI,GAAG,MAAM,IAAI,CAE7E;AA6BD;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,QAAQ,KAAK,IAAI,GAAG,MAAM,IAAI,CAW5E;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,MAAM,IAAI,CAU7F;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAYlD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,GAAG,IAAI,CAU1E"}
|
|
@@ -25,9 +25,22 @@ export declare function requestedThemeVersionId(): string | null;
|
|
|
25
25
|
* is — it keeps the rest of a page's calls pinned to the version the settings
|
|
26
26
|
* call resolved, rather than letting a version go live mid-render.
|
|
27
27
|
*
|
|
28
|
+
* That pin is only good for the scope the settings were requested with. Each
|
|
29
|
+
* market (scope) has its own version, and the API lets a named version outrank
|
|
30
|
+
* the market's: once the shopper switches market, the loaded settings still
|
|
31
|
+
* describe the previous one, and replaying their version — on the settings call
|
|
32
|
+
* for the new market first of all — gets the previous market's theme back, for
|
|
33
|
+
* good. So the version is replayed only while the active scope is the one
|
|
34
|
+
* `store.settings` stamped on them (`requestedScopeId`); otherwise nothing is
|
|
35
|
+
* sent and the API picks the version of the scope on the request. That covers a
|
|
36
|
+
* market selected, switched, or cleared.
|
|
37
|
+
*
|
|
38
|
+
* `activeScopeId` is passed in by the caller that already resolved the scope for
|
|
39
|
+
* its `s-scope-*` headers.
|
|
40
|
+
*
|
|
28
41
|
* Reading the settings is guarded because `getTwilightContext().settings` throws
|
|
29
42
|
* a `SettingsError` when they have not loaded — which is the normal state on the
|
|
30
43
|
* very first call, the settings call itself.
|
|
31
44
|
*/
|
|
32
|
-
export declare function resolveThemeVersionId(): string | null;
|
|
45
|
+
export declare function resolveThemeVersionId(activeScopeId?: string | null): string | null;
|
|
33
46
|
//# sourceMappingURL=theme-version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-version.d.ts","sourceRoot":"","sources":["../../src/utils/theme-version.ts"],"names":[],"mappings":"AAsBA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,GAAG,IAAI,CAKvD;AAED
|
|
1
|
+
{"version":3,"file":"theme-version.d.ts","sourceRoot":"","sources":["../../src/utils/theme-version.ts"],"names":[],"mappings":"AAsBA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,GAAG,IAAI,CAKvD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,GAAE,MAAM,GAAG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A;AAEJ","file":"PageSingle-VUNU2BG4.js","sourcesContent":["import { useMemo } from 'react';\nimport { SallaComments } from '@salla.sa/twilight-components-react/comments';\nimport type { PageSingleProps } from './types';\nimport { Breadcrumb } from '../../components/common';\nimport { useComments } from '../../hooks/useComments';\n\nexport function PageSingle({ page }: PageSingleProps) {\n const { commentsKey } = useComments();\n\n // Clean content articles - matches app.js commonThings()\n const cleanContent = useMemo(() => {\n if (!page.content) return '';\n // Replace entities with regular spaces\n return page.content.replace(/ /g, ' ');\n }, [page.content]);\n\n return (\n <div key={page.slug} className=\"container\">\n <Breadcrumb page={page} />\n\n <div className=\"flex justify-center\">\n <div className=\"content content--single-page w-full lg:w-10/12 bg-white rounded p-6 lg:p-8 mt-4 lg:mt-12\">\n <h1 className=\"font-bold text-2xl mb-6\">{page.title}</h1>\n {cleanContent && (\n <div className=\"content-entry\" dangerouslySetInnerHTML={{ __html: cleanContent }} />\n )}\n {page.id && (\n <SallaComments key={commentsKey} itemId={Number(page.id)} type={'page' as any} />\n )}\n </div>\n </div>\n </div>\n );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/analytics/gtm.ts","../src/components/cart/SeoCartWidget.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAS,eAAe,KAAA,EAAkC;AACxD,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,EAAU,OAAO,KAAA;AACtC,EAAA,OAAO,KAAA,CAAM,MAAA;AACf;AAEA,SAAS,eAAe,KAAA,EAA8B;AACpD,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,EAAU,OAAO,KAAA;AACtC,EAAA,OAAO,UAAA,CAAW,KAAK,CAAA,IAAK,CAAA;AAC9B;AAOO,SAAS,uBAAuB,KAAA,EAAyC;AAC9E,EAAA,OAAO,KAAA,CACJ,OAAO,CAAC,IAAA,KAAS,KAAK,YAAY,CAAA,CAClC,G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"SeoCartWidget-X5HTL62D.js","sourcesContent":["import type { Cart, CartItem } from '../../types';\n\n// ─── Payload Types ───────────────────────────────────────────────────────────\n\nexport interface GtmCheckoutProduct {\n id: number;\n name: string;\n price: number;\n quantity: number;\n}\n\nexport interface GtmCheckoutEvent {\n event: 'checkout';\n ecommerce: {\n checkout: {\n actionField: { step: 1 | 2 | 3 };\n products: GtmCheckoutProduct[];\n cart_total: number;\n currency: string;\n };\n };\n}\n\n// ─── Helpers ─────────────────────────────────────────────────────────────────\n\nfunction getPriceAmount(value: CartItem['price']): number {\n if (typeof value === 'number') return value;\n return value.amount;\n}\n\nfunction getTotalAmount(value: Cart['total']): number {\n if (typeof value === 'number') return value;\n return parseFloat(value) || 0;\n}\n\n/**\n * Maps `Cart.items` to the GTM product array format.\n *\n * Only available items are included — mirrors PHP `$cartService->getAvailableItems()`.\n */\nexport function mapCartItemsToProducts(items: CartItem[]): GtmCheckoutProduct[] {\n return items\n .filter((item) => item.is_available)\n .map((item) => ({\n id: item.product_id,\n name: item.product_name,\n price: getPriceAmount(item.price),\n quantity: item.quantity,\n }));\n}\n\n// ─── Main Utility ─────────────────────────────────────────────────────────────\n\n/**\n * Pushes a GTM `checkout` event to `window.dataLayer`.\n *\n * Safe to call in SSR environments — guards against `typeof window`.\n * Initialises `window.dataLayer` if GTM hasn't done so yet.\n *\n * @param step Checkout funnel step (1 = cart, 2 = shipping, 3 = payment)\n * @param cart Current cart data from the Twilight loader\n * @param currencyCode ISO 4217 currency code, e.g. \"SAR\"\n */\nexport function pushCheckoutEvent(step: 1 | 2 | 3, cart: Cart, currencyCode: string): void {\n if (typeof window === 'undefined') return;\n\n window.dataLayer = window.dataLayer ?? [];\n\n const payload: GtmCheckoutEvent = {\n event: 'checkout',\n ecommerce: {\n checkout: {\n actionField: { step },\n products: mapCartItemsToProducts(cart.items),\n cart_total: getTotalAmount(cart.total),\n currency: currencyCode,\n },\n },\n };\n\n window.dataLayer.push(payload);\n}\n","import { useEffect } from 'react';\nimport { useTwilight } from '../../providers/TwilightProvider';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport type { Cart } from '../../types';\nimport { pushCheckoutEvent } from '../../lib/analytics/gtm';\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\nexport interface SeoCartWidgetProps {\n /**\n * Cart data from the TanStack Router loader — no extra fetch needed.\n */\n cart: Cart;\n /**\n * Current checkout funnel step.\n * Defaults to `1` (cart view) — CartPage always passes this default.\n * The widget internally listens to Salla SDK events to promote to 2 / 3.\n */\n step?: 1 | 2 | 3;\n}\n\n// ─── Page title translation keys (mirrors PHP SeoCartWidget::$pageTitle) ─────\n\n/**\n * Matches the PHP backend exactly:\n * ```php\n * protected $pageTitle = [\n * self::STEP_CART => 'common.titles.cart',\n * self::STEP_SHIPPING => 'common.titles.shipping',\n * self::STEP_PAYMENT => 'common.titles.checkout',\n * ];\n * ```\n */\nconst PAGE_TITLE_KEYS: Record<1 | 2 | 3, string> = {\n 1: 'common.titles.cart',\n 2: 'common.titles.shipping',\n 3: 'common.titles.checkout',\n};\n\n// ─── Component ────────────────────────────────────────────────────────────────\n\n/**\n * SeoCartWidget — Null-rendering analytics side-effect component.\n *\n * Responsibilities:\n * 1. Fires a GTM `checkout` event (step 1) on cart page load.\n * 2. Listens to Salla SDK checkout overlay events to fire steps 2 & 3.\n * 3. Updates `document.title` to reflect the cart context.\n *\n * Architecture:\n * - Lives in `theme-engine` so all themes using the engine get GTM tracking.\n * - Mounted directly inside `CartPage`, which already has loader data.\n * - `window.dataLayer` must be initialised by the store's GTM embed snippet;\n * the widget initialises it as a safe-guard but does NOT inject GTM itself.\n * - Must be mounted inside `<TwilightProvider>` (reads `currency` from context).\n *\n * @example\n * // In CartPage:\n * <SeoCartWidget cart={cart} />\n */\nexport function SeoCartWidget({ cart, step = 1 }: SeoCartWidgetProps) {\n const { store, currency } = useTwilight();\n const { t } = useTranslation();\n const currencyCode = currency?.code ?? 'SAR';\n\n // ── Fire GTM checkout event for step 1 (or whichever step is passed) ────────\n useEffect(() => {\n pushCheckoutEvent(step, cart, currencyCode);\n // Re-fire if the cart id, contents, or currency changes\n }, [step, cart, currencyCode]);\n\n // ── Subscribe to Salla SDK checkout step events (steps 2 & 3) ──────────────\n // Fires GTM events when the user advances through the checkout overlay.\n useEffect(() => {\n const salla = window.salla;\n if (!salla?.event?.on) return;\n\n const onShipping = () => pushCheckoutEvent(2, cart, currencyCode);\n const onPayment = () => pushCheckoutEvent(3, cart, currencyCode);\n\n salla.event.on('checkout::step.shipping', onShipping);\n salla.event.on('checkout::step.payment', onPayment);\n\n return () => {\n salla.event?.off?.('checkout::step.shipping', onShipping);\n salla.event?.off?.('checkout::step.payment', onPayment);\n };\n }, [cart, currencyCode]);\n\n // ── Update document title — mirrors PHP SeoCartWidget::$pageTitle ───────────\n // Step 1 → 'common.titles.cart' (e.g. \"Cart\")\n // Step 2 → 'common.titles.shipping' (e.g. \"Shipping\")\n // Step 3 → 'common.titles.checkout' (e.g. \"Checkout\")\n useEffect(() => {\n const storeTitle = store.meta?.title || store.name;\n const stepTitle = t(PAGE_TITLE_KEYS[step], PAGE_TITLE_KEYS[step]);\n document.title = storeTitle ? `${stepTitle} - ${storeTitle}` : stepTitle;\n }, [step, store.meta?.title, store.name, t]);\n\n return null;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/routes/testimonials/TestimonialsPage.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAOA,IAAM,gBAAA,GAAmB,CAAC,CAAA,KAA2C;AAAA,EACnE,EAAE,EAAA,EAAI,QAAA,EAAU,OAAO,CAAA,CAAE,sCAAA,EAAwC,QAAQ,CAAA,EAAE;AAAA,EAC3E,EAAE,EAAA,EAAI,QAAA,EAAU,OAAO,CAAA,CAAE,qCAAA,EAAuC,QAAQ,CAAA,EAAE;AAAA,EAC1E;AAAA,IACE,EAAA,EAAI,YAAA;AAAA,IACJ,KAAA,EAAO,CAAA,CAAE,wCAAA,EAA0C,WAAW;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U,oBAAA,EAAsB,QAAA,EAAA,IAAA,CAAK,KAAA,EAAM,CAAA;AAAA,wBAC/C,IAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,mBAAA,EACb,QAAA,EAAA;AAAA,0BAAA,GAAA;AAAA,YAAC,OAAA;AAAA,YAAA;AAAA,cACC,SAAA,EAAU,qDAAA;AAAA,cACV,OAAA,EAAQ,qBAAA;AAAA,cAEP,QAAA,EAAA,CAAA,CAAE,4BAA4B,SAAS;AAAA;AAAA,WAC1C;AAAA,0BACA,GAAA;AAAA,YAAC,QAAA;AAAA,YAAA;AAAA,cACC,EAAA,EAAG,qBAAA;AAAA,cACH,SAAA,EAAU,iEAAA;AAAA,cACV,KAAA,EAAO,YAAA;AAAA,cACP,UAAU,CAAC,CAAA,KAAM,eAAA,CAAgB,CAAA,CAAE,OAAO,KAAK,CAAA;AAAA,cAE9C,QAAA,EAAA,gBAAA,CAAiB,CAAC,CAAA,CAAE,GAAA,CAAI,CAAC,GAAA,qBACxB,GAAA,CAAC,QAAA,EAAA,EAAoB,KAAA,EAAO,IAAI,EAAA,EAC7B,QAAA,EAAA,GAAA,CAAI,KAAA,EAAA,EADM,GAAA,CAAI,EAEjB,CACD;AAAA;AAAA;AACH,SAAA,EACF;AAAA,OAAA,EACF,CAAA;AAAA,sBAGA,GAAA;AAAA,QAAC,aAAA;AAAA,QAAA;AAAA,UAEC,YAAA,EAAY,IAAA;AAAA,UAEZ,MAAA,EAAQ,MAAA;AAAA,UACR,IAAA,EAAM;AAAA,SAAA;AAAA,QAJD,CAAA,EAAG,YAAY,CAAA,CAAA,EAAI,WAAW,CAAA;AAAA;AAKrC,KAAA,EACF,CAAA,EACF;AAAA,GAAA,EACF,CAAA;AAEJ","file":"TestimonialsPage-CKAYXFER.js","sourcesContent":["import { useState, useEffect } from 'react';\nimport { SallaComments } from '@salla.sa/twilight-components-react/comments';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport { useComments } from '../../hooks/useComments';\nimport type { TestimonialsPageProps } from './types';\nimport { Breadcrumb } from '../../components/common';\n\nconst buildSortOptions = (t: (key: string, fb: string) => string) => [\n { id: 'latest', label: t('pages.testimonials.sort_by_date_desc', 'Latest') },\n { id: 'oldest', label: t('pages.testimonials.sort_by_date_asc', 'Oldest') },\n {\n id: 'top_rating',\n label: t('pages.testimonials.sort_by_rating_desc', 'Top rated'),\n },\n {\n id: 'bottom_rating',\n label: t('pages.testimonials.sort_by_rating_asc', 'Low rated'),\n },\n];\n\nexport function TestimonialsPage({ page }: TestimonialsPageProps) {\n const { t } = useTranslation();\n const { commentsKey } = useComments();\n\n // Sync sort state with URL\n const [selectedSort, setSelectedSort] = useState(() => {\n const params = new URLSearchParams(window.location.search);\n return params.get('sort') || 'latest';\n });\n\n // Update URL when sort changes\n useEffect(() => {\n const url = new URL(window.location.href);\n url.searchParams.set('sort', selectedSort);\n window.history.replaceState(null, '', url.toString());\n }, [selectedSort]);\n\n return (\n <div className=\"container\">\n <Breadcrumb page={page} />\n\n <div className=\"flex justify-center\">\n <div className=\"w-full lg:w-10/12 bg-white rounded p-6 lg:p-8 mt-4 lg:mt-12\">\n <div className=\"mb-4 sm:mb-6 flex justify-between items-center\">\n <h1 className=\"font-bold text-2xl\">{page.title}</h1>\n <div className=\"flex items-center\">\n <label\n className=\"hidden sm:block rtl:ml-3 ltr:mr-3 whitespace-nowrap\"\n htmlFor=\"testimonials-filter\"\n >\n {t('pages.categories.sorting', 'Sort by')}\n </label>\n <select\n id=\"testimonials-filter\"\n className=\"form-input pt-0 pb-1 rtl:pl-10 ltr:pr-10 bg-white text-gray-900\"\n value={selectedSort}\n onChange={(e) => setSelectedSort(e.target.value)}\n >\n {buildSortOptions(t).map((opt) => (\n <option key={opt.id} value={opt.id}>\n {opt.label}\n </option>\n ))}\n </select>\n </div>\n </div>\n\n {/* Key prop forces reload when sort changes or new comment added */}\n <SallaComments\n key={`${selectedSort}-${commentsKey}`}\n testimonials\n // drifted wrapper types require itemId; testimonials mode has none\n itemId={undefined as never}\n sort={selectedSort as any}\n />\n </div>\n </div>\n </div>\n );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/routes/thank-you/ThankYouPage.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,IAAM,iBAA6D,EAAC;AAE7D,SAAS,YAAA,CAAa;AAAA,EAC3B,IAAA;AAAA,EACA,KAAA;AAAA,EACA,eAAA;AAAA,EACA,QAAA,GAAW;AACb,CAAA,EAAsB;AACpB,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,WAAA,EAAY;AAC9B,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,cAAA,EAAe;AAE7B,EAAA,aAAA,CAAc,IAAI,CAAA;AAClB,EAAA,MAAM,KAAA,GACJ,eAAA,IAAmB,CAAA,CAAE,4BAAA,EAA8B,2CAAoC,CAAA;AACzF,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,IAAI,QAAA,CAAS,KAAA,EAAO,cAAc,KAAK,CAAA;AACzE,EAAA,MAAM,CAAC,cAAA,EAAgB,iBAAiB,CAAA,GAAI,SAAwB,IAAI,CAAA;AACxE,EAAA,MAAM,GAAG,eAAe,CAAA,GAAI,kBAAA,EAAmB;AAG/C,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,QAAQ,MAAA,CAAO,KAAA;AACrB,IAAA,IAAI,CAAC,KAAA,EAAO,KAAA,EAAO,EAAA,EAAI;AAEvB,IAAA,MAAM,iBAAA,GAAoB,CAAC,GAAA,KAAyC;AAClE,MAAA,iBAAA;AAAA,QACE,GAAA,CAAI,IAAA,EAAM,OAAA,IAAW,CAAA,CAAE,wCAAwC,2BAA2B;AAAA,OAC5F;AACA,MAAA,cAAA,CAAe,IAAI,CAAA;AAAA,IACrB,CAAA;AACA,IAAA,MAAM,QAAA,GAAW,iBAAA;AAEjB,IAAA,KAAA,CAAM,KAAA,CA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AAAA,sBAEA,GAAA,CAAC,QAAA,EAAA,EAAS,IAAA,EAAK,eAAA,EAAgB;AAAA,KAAA,EACjC;AAAA,GAAA,EACF,CAAA;AAEJ","file":"ThankYouPage-ZTCFTEI7.js","sourcesContent":["import { useState, useEffect } from 'react';\nimport { useCopyToClipboard } from '@uidotdev/usehooks';\nimport { SallaButton } from '@salla.sa/twilight-components-react/button';\nimport { SallaNextOrderCoupon } from '@salla.sa/twilight-components-react/next-order-coupon';\nimport { SallaOrderBranch } from '@salla.sa/twilight-components-react/order-branch';\nimport { Link } from '../../components/common';\nimport { HookSlot, usePageConfig } from '../../hooks';\nimport type { ThankYouPageProps } from './types';\nimport { useTwilight } from '../../providers/twilight-context';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport confettiImage from './confetti.svg';\n\nconst EMPTY_MESSAGES: NonNullable<ThankYouPageProps['messages']> = [];\n\nexport function ThankYouPage({\n page,\n order,\n thank_you_title,\n messages = EMPTY_MESSAGES,\n}: ThankYouPageProps) {\n const { store } = useTwilight();\n const { t } = useTranslation();\n // `<salla-order-branch>` reads the order id from `salla.config.page.id` (see OrderSinglePage).\n usePageConfig(page);\n const title =\n thank_you_title ?? t('pages.thank_you.hero_title', 'Thank you for shopping with us! 😊');\n const [invoiceSent, setInvoiceSent] = useState(order?.email_sent ?? false);\n const [invoiceMessage, setInvoiceMessage] = useState<string | null>(null);\n const [, copyToClipboard] = useCopyToClipboard();\n\n // Listen for invoice sent event (matches thankyou.js)\n useEffect(() => {\n const salla = window.salla;\n if (!salla?.event?.on) return;\n\n const handleInvoiceSent = (res: { data?: { message?: string } }) => {\n setInvoiceMessage(\n res.data?.message || t('pages.thank_you.invoice_sent_success', 'Invoice sent successfully')\n );\n setInvoiceSent(true);\n };\n const listener = handleInvoiceSent as (...args: unknown[]) => void;\n\n salla.event.on('order::invoice.sent', listener);\n\n return () => {\n salla.event.off('order::invoice.sent', listener);\n };\n }, [t]);\n\n return (\n <>\n <HookSlot name=\"thank-you:start\" />\n\n <div className=\"h-52 -mb-52 w-full bg-primary rtl:right-0 ltr:left-0 relative -z-1\">\n <svg\n className=\"text-primary absolute top-full\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 1440 320\"\n >\n <path\n className=\"fill-current\"\n fillOpacity=\"1\"\n d=\"M0,96L120,112C240,128,480,160,720,165.3C960,171,1200,149,1320,138.7L1440,128L1440,0L1320,0C1200,0,960,0,720,0C480,0,240,0,120,0L0,0Z\"\n ></path>\n </svg>\n </div>\n\n <div className=\"container mb-20\">\n <nav className=\"w-full py-5\">\n <ol className=\"list-reset flex items-center text-sm text-primary-reverse\">\n <li>\n <Link to=\"/\" className=\"fix-align text-primary-reverse\">\n {t('common.titles.home', 'Home')}\n </Link>\n </li>\n <li>\n <i className=\"sicon-keyboard_arrow_left mx-2\"></i>\n </li>\n <li>\n <span className=\"fix-align\">{title}</span>\n </li>\n </ol>\n </nav>\n\n <div className=\"bg-white p-4 md:p-8 rounded-md mb-6 md:mb-8\">\n <div className=\"flex flex-col items-center pt-16 pb-10\">\n <img src={confettiImage} alt={title} className=\"size-[140px] mb-8\" />\n <h1 className=\"font-bold text-lg mb-2.5\">{title}</h1>\n <p className=\"text-gray-500 max-w-xs text-center text-sm leading-6 mb-2.5\">\n {t(\n 'pages.thank_you.description',\n 'Your order has been received and will be reviewed and confirmed shortly.'\n )}\n </p>\n {order && (\n <>\n <p className=\"text-gray-500 max-w-xs text-center text-sm leading-6 mb-6\">\n {t('pages.thank_you.order_id_label', 'Order ID')}{' '}\n <SallaButton\n className=\"relative\"\n onClick={() => copyToClipboard(String(order.reference_id))}\n color=\"dark\"\n shape=\"link\"\n >\n <span>#{order.reference_id}</span>\n <i className=\"copy-icon sicon-swap-stroke pointer-events-none rtl:mr-1 ltr:ml-1\"></i>\n </SallaButton>\n </p>\n <Link\n to={`/account/orders/${order.id}`}\n className=\"bg-primary text-white text-sm font-bold h-10 px-4 rounded-md flex items-center justify-center gap-1.5\"\n >\n <i className=\"sicon-newspaper rtl:ml-1 ltr:mr-1\"></i>\n {t('pages.thank_you.view_order_details', 'View Order Details')}\n </Link>\n </>\n )}\n </div>\n\n {(order as { instructions?: string } | undefined)?.instructions && (\n <article\n className=\"article article--main article--small text-center\"\n dangerouslySetInnerHTML={{\n __html: (order as { instructions?: string }).instructions ?? '',\n }}\n />\n )}\n\n {messages.map((message) => (\n <div\n key={message}\n className=\"flex flex-col items-center pt-1 pb-10 justify-start rtl:space-x-reverse space-x-2\"\n >\n <span className=\"font-bold\">{message}</span>\n </div>\n ))}\n\n <HookSlot name=\"thank-you:items.start\" />\n <HookSlot name=\"thank-you:items.end\" />\n </div>\n\n {/* Next-order coupon and pickup branch — each renders nothing when it doesn't apply */}\n <SallaNextOrderCoupon />\n <SallaOrderBranch />\n\n <div className=\"lg:flex rtl:space-x-reverse lg:space-x-8\">\n {invoiceSent ? (\n <div className=\"duration-500 hover:shadow-default flex-1 bg-white p-8 rounded-md mb-6 md:mb-10 flex flex-col items-center justify-center\">\n <div className=\"bg-gray-100 rounded-icon w-12 h-12 mb-2.5\">\n <i className=\"sicon-newspaper-alt text-xl\"></i>\n </div>\n <p className=\"text-sm mb-2.5\">\n {t('pages.thank_you.email_sent_to', 'Email sent to')}\n </p>\n <b className=\"text-sm\">{order?.customer?.email}</b>\n {invoiceMessage && <p className=\"text-sm text-green-600 mt-2\">{invoiceMessage}</p>}\n </div>\n ) : (\n <div\n id=\"invoice-form\"\n className={invoiceMessage ? 'thankyou-block sent' : 'thankyou-block'}\n >\n {invoiceMessage ? (\n <div className=\"text-center\">\n <div className=\"bg-gray-100 rounded-icon w-12 h-12 mb-2.5 mx-auto\">\n <i className=\"sicon-newspaper-alt text-xl\"></i>\n </div>\n <p className=\"text-sm\" dangerouslySetInnerHTML={{ __html: invoiceMessage }} />\n </div>\n ) : (\n <>\n <div className=\"bg-gray-100 rounded-icon w-12 h-12 mb-2.5\">\n <i className=\"sicon-newspaper-alt text-xl\"></i>\n </div>\n <p className=\"text-sm mb-2.5\">\n {t('pages.thank_you.resend_invoice', 'Resend invoice email')}\n </p>\n <form\n onSubmit={(e) => {\n e.preventDefault();\n window.salla?.form.onSubmit('order.sendInvoice', e);\n }}\n >\n <div className=\"flex max-w-3xl w-full\">\n <input\n type=\"email\"\n className=\"form-input rtl:rounded-l-none ltr:rounded-r-none rtl:border-l-0 ltr:border-r-0 !w-[160px] sm:!w-[220px]\"\n placeholder=\"your@email.com\"\n required\n name=\"email\"\n />\n <SallaButton\n type=\"submit\"\n loaderPosition=\"center\"\n className=\"rtl:rounded-r-none ltr:rounded-l-none lg:w-24 h-10\"\n >\n <span className=\"btn__text\">{t('pages.thank_you.send', 'Send')}</span>\n </SallaButton>\n </div>\n </form>\n </>\n )}\n </div>\n )}\n\n <div className=\"thankyou-block\">\n <div className=\"bg-gray-100 rounded-icon w-12 h-12 mb-2.5\">\n <i className=\"sicon-mail-letter text-xl\"></i>\n </div>\n <p className=\"text-sm mb-2.5\">{t('pages.thank_you.support', 'Support')}</p>\n\n <div className=\"flex rtl:space-x-reverse space-x-6\">\n {store.contacts.mobile && (\n <div className=\"text-sm unicode flex items-center\">\n <i className=\"sicon-phone\"></i>\n <a\n href={`tel:${store.contacts.mobile}`}\n className=\"hover:text-primary transition\"\n >\n <b className=\"unicode mx-1.5\">{store.contacts.mobile}</b>\n </a>\n </div>\n )}\n\n {store.contacts.whatsapp && (\n <div className=\"text-sm unicode flex items-center\">\n <i className=\"sicon-whatsapp\"></i>\n <a\n href={`https://wa.me/${store.contacts.whatsapp.replace(/[\\s+-]/g, '')}`}\n className=\"hover:text-primary transition\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n <b className=\"unicode mx-1.5\">{store.contacts.whatsapp}</b>\n </a>\n </div>\n )}\n </div>\n </div>\n </div>\n\n <HookSlot name=\"thank-you:end\" />\n </div>\n </>\n );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/routes/account/wishlist/WishlistShare.tsx","../src/routes/account/wishlist/WishlistPage.tsx"],"names":["SallaSocialShare","useEffect","jsxs","jsx","SallaButton","useRef","useState","useCallback","items"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBO,SAAS,gBAAA,GAAmB;AACjC,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAI,SAAS,KAAK,CAAA;AAC9C,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAAI,SAAS,KAAK,CAAA;AAChD,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,QAAA,CAAmB,EAAE,CAAA;AAC3D,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAI,SAAS,KAAK,CAAA;AAC5C,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAI,SAAS,EAAE,CAAA;AAE3C,EAAA,MAAM,YAAA,GAAe,MAAA,CAAiB,EAAE,CAAA;AACxC,EAAA,MAAM,cAAA,GAAiB,OAAkC,IAAI,CAAA;AAE7D,EAAA,MAAM,KAAA,GAAQ,WAAA,CAAY,OAAO,GAAA,EAAe,SAAA,KAAuB;AACrE,IAAA,IAAI,CAAC,MAAA,CAAO,KAAA,EAAO,QAAA,EAAU,KAAA,EAAO;AACpC,IAAA,UAAA,CAAW,IAAI,CAAA;AACf,IAAA,IAAI;AACF,MAAA,MAAM,WAAY,MAAM,MAAA,CAAO,MAAM,QAAA,CAAS,KAAA,CAAM,KAAK,SAAS,CAAA;AAClE,MAAA,MAAM,GAAA,GAAM,QAAA,EAAU,IAAA,EAAM,GAAA,IAAO,UAAU,GAAA,IAAO,EAAA;AACpD,MAAA,IAAI,CAAC,GAAA,EAAK;AACV,MAAA,WAAA,CAAY,GAAG,CAAA;AACf,MAAA,MAAM,UAAU,cAAA,CAAe,OAAA;AAC/B,MAAA,IAAI,OAAA,EAAS;AACX,QAAA,OAAA,CAAQ,GAAA,GAAM,GAAA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AAW,YAAA,CAAa,UAAU,SAAA,CAAU,GAAA,CAAI,CAAC,IAAA,KAAS,MAAA,CAAO,IAAA,CAAK,EAAE,CAAC,CAAA;AACzE,UAAA,OAAO,SAAA,CAAU,GAAA,CAAI,CAAC,IAAA,qBACpBL,GAAAA;AAAA,YAAC,YAAA;AAAA,YAAA;AAAA,cAEC,OAAA,EAAS,IAAA;AAAA,cACT,UAAU,WAAA,CAAY,GAAA,CAAI,MAAA,CAAO,IAAA,CAAK,EAAE,CAAC,CAAA;AAAA,cACzC,SAAA,EAAW,cAAA;AAAA,cACX,SAAA,EAAW;AAAA,gBACT,WAAW,UAAA,CAAW,SAAA;AAAA,gBACtB,UAAU,aAAA,CAAc,GAAA,CAAI,MAAA,CAAO,IAAA,CAAK,EAAE,CAAC,CAAA;AAAA,gBAC3C,UAAU,UAAA,CAAW;AAAA;AACvB,aAAA;AAAA,YARK,IAAA,CAAK;AAAA,WAUb,CAAA;AAAA,QACH;AAAA,OAAA;AAAA,MAnCK;AAAA,KAoCP;AAAA,oBACAA,GAAAA,CAAC,QAAA,EAAA,EAAS,IAAA,EAAK,6BAAA,EAA8B;AAAA,GAAA,EAC/C,CAAA;AAEJ","file":"WishlistPage-LHIUUR4U.js","sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport { SallaButton } from '@salla.sa/twilight-components-react/button';\n// The eager (non-deferred) export: the share dialog is opened imperatively through a ref, and the\n// deferred wrapper doesn't attach it until it has hydrated — a click before that would do nothing.\nimport { SallaSocialShareCore as SallaSocialShare } from '@salla.sa/twilight-components-react/social-share';\nimport { useTranslation } from '../../../providers/I18nProvider';\n\ntype ShareResponse = { data?: { url?: string }; url?: string } | undefined;\ntype SocialShareElement = HTMLElement & {\n url?: string;\n refresh?: () => Promise<void>;\n open?: () => Promise<void>;\n close?: () => Promise<void>;\n};\n\n/**\n * Share state for the wishlist page: the \"Share\" dropdown (share the whole list / share\n * specific items), the selection used by \"specific items\", and the share request itself.\n * Mirrors what the SDK's `<salla-wishlist-actions>` does, but drives the page's own React\n * list — that component needs a sibling `<salla-products-list>`, which this page doesn't render.\n */\nexport function useWishlistShare() {\n const [menuOpen, setMenuOpen] = useState(false);\n const [selecting, setSelecting] = useState(false);\n const [selectedIds, setSelectedIds] = useState<number[]>([]);\n const [sharing, setSharing] = useState(false);\n const [shareUrl, setShareUrl] = useState('');\n /** Ids of every product currently rendered (later cursor pages included), for \"select all\". */\n const loadedIdsRef = useRef<number[]>([]);\n const socialShareRef = useRef<SocialShareElement | null>(null);\n\n const share = useCallback(async (ids: number[], selectAll: boolean) => {\n if (!window.salla?.wishlist?.share) return;\n setSharing(true);\n try {\n const response = (await window.salla.wishlist.share(ids, selectAll)) as ShareResponse;\n const url = response?.data?.url || response?.url || '';\n if (!url) return;\n setShareUrl(url);\n const element = socialShareRef.current;\n if (element) {\n element.url = url;\n await element.refresh?.();\n await element.open?.();\n }\n } catch {\n // The SDK reports a failed share itself (notification); nothing to recover here.\n } finally {\n setSharing(false);\n }\n }, []);\n\n const shareAll = useCallback(() => {\n setMenuOpen(false);\n void share([], true);\n }, [share]);\n\n const shareSelected = useCallback(() => {\n if (selectedIds.length) void share(selectedIds, false);\n }, [share, selectedIds]);\n\n const startSelecting = useCallback(() => {\n setMenuOpen(false);\n setSelecting(true);\n }, []);\n\n const cancelSelecting = useCallback(() => {\n setSelecting(false);\n setSelectedIds([]);\n setShareUrl('');\n void socialShareRef.current?.close?.();\n }, []);\n\n const toggleSelected = useCallback((id: number) => {\n setShareUrl('');\n setSelectedIds((current) =>\n current.includes(id) ? current.filter((existing) => existing !== id) : [...current, id]\n );\n }, []);\n\n const selectedIdsRef = useRef(selectedIds);\n useEffect(() => {\n selectedIdsRef.current = selectedIds;\n }, [selectedIds]);\n\n const deselect = useCallback((id: number) => {\n if (!selectedIdsRef.current.includes(id)) return;\n // A link built for the old selection would still offer the removed product.\n setShareUrl('');\n const element = socialShareRef.current;\n if (element) {\n element.url = undefined;\n void element.close?.();\n }\n setSelectedIds((current) => current.filter((existing) => existing !== id));\n }, []);\n\n const toggleAll = useCallback(() => {\n setShareUrl('');\n setSelectedIds((current) =>\n current.length && current.length === loadedIdsRef.current.length\n ? []\n : [...loadedIdsRef.current]\n );\n }, []);\n\n return {\n menuOpen,\n setMenuOpen,\n selecting,\n selectedIds,\n sharing,\n shareUrl,\n loadedIdsRef,\n socialShareRef,\n shareAll,\n shareSelected,\n startSelecting,\n cancelSelecting,\n toggleSelected,\n toggleAll,\n deselect,\n };\n}\n\nexport type WishlistShareState = ReturnType<typeof useWishlistShare>;\n\n/** The bar above the wishlist: the \"Share\" dropdown, or — while picking products — the selection controls. */\nexport function WishlistShareBar({\n state,\n hasProducts,\n}: {\n state: WishlistShareState;\n hasProducts: boolean;\n}) {\n const { t } = useTranslation();\n const rootRef = useRef<HTMLDivElement>(null);\n const { menuOpen, setMenuOpen } = state;\n\n // Close the dropdown on an outside click or Escape.\n useEffect(() => {\n if (!menuOpen) return;\n const onPointerDown = (event: MouseEvent) => {\n if (!rootRef.current?.contains(event.target as Node)) setMenuOpen(false);\n };\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') setMenuOpen(false);\n };\n document.addEventListener('mousedown', onPointerDown);\n document.addEventListener('keydown', onKeyDown);\n return () => {\n document.removeEventListener('mousedown', onPointerDown);\n document.removeEventListener('keydown', onKeyDown);\n };\n }, [menuOpen, setMenuOpen]);\n\n const selectedCount = state.selectedIds.length;\n const allSelected = selectedCount > 0 && selectedCount === state.loadedIdsRef.current.length;\n\n return (\n <div ref={rootRef} className=\"s-wishlist-actions\">\n <div className=\"s-wishlist-actions-bar flex items-center justify-end gap-3 mb-3\">\n {state.selecting ? (\n <div className=\"s-wishlist-actions-selection flex items-center gap-3\">\n <label className=\"s-wishlist-actions-select-all inline-flex items-center gap-2 text-sm\">\n <input\n type=\"checkbox\"\n checked={allSelected}\n ref={(input) => {\n if (input) input.indeterminate = selectedCount > 0 && !allSelected;\n }}\n onChange={state.toggleAll}\n />\n {t('pages.wishlist.select_all', 'Select all')}\n </label>\n <SallaButton\n color=\"primary\"\n disabled={selectedCount === 0 || state.sharing}\n onClick={state.shareSelected}\n >\n {t('pages.wishlist.share', 'Share')}\n {selectedCount > 0 ? ` (${selectedCount})` : ''}\n </SallaButton>\n <SallaButton fill=\"outline\" color=\"light\" onClick={state.cancelSelecting}>\n {t('common.elements.cancel', 'Cancel')}\n </SallaButton>\n </div>\n ) : (\n <div className=\"s-wishlist-actions-dropdown relative\">\n <SallaButton\n color=\"primary\"\n fill=\"outline\"\n disabled={!hasProducts || state.sharing}\n aria-haspopup=\"true\"\n aria-expanded={menuOpen}\n onClick={() => setMenuOpen(!menuOpen)}\n >\n <span className=\"flex items-center justify-center gap-2\">\n <i className=\"sicon-share-alt\" aria-hidden=\"true\" />\n {t('pages.wishlist.share', 'Share')}\n <i className=\"sicon-keyboard_arrow_down\" aria-hidden=\"true\" />\n </span>\n </SallaButton>\n {menuOpen && (\n <ul\n role=\"menu\"\n className=\"s-wishlist-actions-menu absolute z-10 mt-2 min-w-48 rounded-md bg-white py-2 shadow-default rtl:right-0 ltr:left-0\"\n >\n <li role=\"none\">\n <button\n type=\"button\"\n role=\"menuitem\"\n className=\"s-wishlist-actions-item block w-full px-4 py-2 text-start text-sm text-gray-700 hover:bg-gray-50\"\n onClick={state.shareAll}\n >\n {t('pages.wishlist.share_all', 'Share the list')}\n </button>\n </li>\n <li role=\"none\">\n <button\n type=\"button\"\n role=\"menuitem\"\n className=\"s-wishlist-actions-item block w-full px-4 py-2 text-start text-sm text-gray-700 hover:bg-gray-50\"\n onClick={state.startSelecting}\n >\n {t('pages.wishlist.share_specific', 'Share specific items')}\n </button>\n </li>\n </ul>\n )}\n </div>\n )}\n </div>\n {/* Same setup as the SDK's <salla-wishlist-actions>: the centered modal variant, opened by the\n dropdown rather than by the component's own round share button, so the default\n `widget` slot (that button) is replaced by an empty anchor. */}\n <SallaSocialShare\n ref={state.socialShareRef as never}\n url={state.shareUrl || undefined}\n mode=\"modal\"\n modalTitle={t('pages.wishlist.share_list_title', 'Share wishlist')}\n className=\"s-wishlist-actions-social\"\n >\n <span slot=\"widget\" className=\"s-wishlist-actions-social-anchor\" aria-hidden=\"true\" />\n </SallaSocialShare>\n </div>\n );\n}\n","import { useCallback, useEffect, useMemo, useRef, useState, type CSSProperties } from 'react';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { ItemsList } from '@salla.sa/twilight-components-react';\nimport { SallaAddProductButton } from '@salla.sa/twilight-components-react/add-product-button';\nimport { SallaButton } from '@salla.sa/twilight-components-react/button';\nimport { wishlist } from '../../../api/wishlist';\nimport type { Product } from '../../../types';\nimport { HookSlot, useWishlist, useMoney } from '../../../hooks';\nimport { useTranslation } from '../../../providers/I18nProvider';\nimport type { WishlistPageProps } from './types';\nimport { WishlistShareBar, useWishlistShare } from './WishlistShare';\nimport { NoContent, Image } from '../../../components/common';\nimport { useLocation } from '../../../providers/NavigationProvider';\n\ninterface WishlistCardSelection {\n /** \"Share specific items\" mode: the card shows a checkbox and toggles on click. */\n selecting: boolean;\n selected: boolean;\n onToggle: (id: number) => void;\n}\n\n// The loaded component copies host attributes (not properties) onto its inner salla-button.\nconst setAddButtonAttributes = (el: HTMLElement | null) => {\n el?.setAttribute('loader-position', 'center');\n el?.setAttribute('fill', 'outline');\n};\n\nconst REMOVING_MS = 300;\n\nconst REMOVING_STYLE: CSSProperties = {\n opacity: 0,\n transform: 'scale(0.95)',\n transition: `opacity ${REMOVING_MS}ms ease-in-out, transform ${REMOVING_MS}ms ease-in-out`,\n};\n\nfunction WishlistCard({\n product: prod,\n selection,\n removing,\n onRemoved,\n}: {\n product: Product;\n selection?: WishlistCardSelection;\n /** Fades the card out, then calls `onRemoved` once the fade ends. */\n removing?: boolean;\n onRemoved?: (id: number) => void;\n}) {\n const { remove } = useWishlist();\n const { format } = useMoney();\n\n // Drops the card even when `transitionend` never fires (hidden tab, overridden styles).\n useEffect(() => {\n if (!removing) return;\n const timer = setTimeout(() => onRemoved?.(Number(prod.id)), REMOVING_MS + 50);\n return () => clearTimeout(timer);\n }, [removing, onRemoved, prod.id]);\n\n const handleRemove = () => {\n if (prod.id) {\n remove(Number(prod.id));\n }\n };\n\n const displayPrice = prod.sale_price ?? prod.price;\n const regularPrice = prod.regular_price;\n\n return (\n <div\n id={`wishlist-product-${prod.id}`}\n className={`product-entry product-entry--wishlist${selection?.selected ? ' is-selected' : ''}`}\n style={removing ? REMOVING_STYLE : undefined}\n onTransitionEnd={(event) => {\n if (removing && event.target === event.currentTarget && event.propertyName === 'opacity') {\n onRemoved?.(Number(prod.id));\n }\n }}\n >\n {selection?.selecting && (\n <input\n type=\"checkbox\"\n className=\"s-wishlist-select shrink-0 rtl:ml-4 ltr:mr-4\"\n aria-label={prod.name}\n checked={selection.selected}\n onChange={() => selection.onToggle(Number(prod.id))}\n />\n )}\n <div className=\"flex items-center mb-4 sm:mb-0\">\n <a href={prod.url} className=\"product-entry__image\">\n <Image\n className=\"object-cover w-full h-full\"\n src={prod.image?.url}\n alt={prod.image?.alt ?? prod.name}\n aspectRatio=\"1/1\"\n />\n </a>\n <div className=\"flex-1 rtl:pr-5 ltr:pl-5\">\n <h3 className=\"text-sm text-gray-800 leading-6 mb-1.5 rtl:pl-5 ltr:pr-5 rtl:md:pl-8 ltr:md:pr-8 line-clamp-1\">\n <a href={prod.url}>{prod.name}</a>\n </h3>\n <div className=\"w-full center-between\">\n {prod.is_on_sale && regularPrice ? (\n <div className=\"space-x-1 rtl:space-x-reverse\">\n <h4 className=\"inline-block text-sm font-bold text-red-400\">\n {format(displayPrice)}\n </h4>\n <span className=\"text-sm text-gray-500 line-through\">{format(regularPrice)}</span>\n </div>\n ) : (\n <h4 className=\"text-sm font-bold\">{format(displayPrice)}</h4>\n )}\n </div>\n </div>\n </div>\n <div className=\"flex items-center space-x-4 rtl:space-x-reverse\">\n <SallaAddProductButton\n ref={setAddButtonAttributes}\n productStatus={prod.status}\n productId={prod.id}\n productType={prod.type}\n loaderPosition=\"center\"\n fill=\"outline\"\n className=\"flex-grow w-full sm:grow-0 md:w-40\"\n />\n <SallaButton\n loaderPosition=\"center\"\n shape=\"icon\"\n size=\"small\"\n color=\"danger\"\n className=\"btn--delete\"\n onClick={handleRemove}\n >\n <i className=\"sicon-cancel\" />\n </SallaButton>\n </div>\n </div>\n );\n}\n\n/** The loaded wishlist pages, reloaded from the server once every loaded card is removed (like Twig). */\nfunction useWishlistItems(\n { query, products, pagination }: WishlistPageProps,\n onRemoved: (id: number) => void\n) {\n const queryClient = useQueryClient();\n // Track the next page to load (starts at page 2 since page 1 is SSR)\n const nextPageRef = useRef(query.page + 1);\n const [removedIds, setRemovedIds] = useState<ReadonlySet<number>>(() => new Set());\n const [removingIds, setRemovingIds] = useState<ReadonlySet<number>>(() => new Set());\n const [reloaded, setReloaded] = useState<{\n items: Product[];\n next: string | null;\n generation: number;\n } | null>(null);\n const loadedRef = useRef({\n ids: products.map((prod) => Number(prod.id)),\n hasMore: !!pagination?.next,\n });\n\n // A `?page=` navigation keeps this instance, so drop what the previous page removed or reloaded.\n const [loadedProducts, setLoadedProducts] = useState(products);\n if (loadedProducts !== products) {\n setLoadedProducts(products);\n setRemovedIds(new Set());\n setRemovingIds(new Set());\n setReloaded(null);\n }\n\n useEffect(() => {\n nextPageRef.current = query.page + 1;\n loadedRef.current = {\n ids: products.map((prod) => Number(prod.id)),\n hasMore: !!pagination?.next,\n };\n }, [products, query.page, pagination?.next]);\n\n useEffect(() => {\n const salla = window.salla;\n if (!salla?.event) return;\n\n const handleRemoved = (_response: unknown, id: unknown) => {\n const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n (reduceMotion ? setRemovedIds : setRemovingIds)((current) =>\n new Set(current).add(Number(id))\n );\n onRemoved(Number(id));\n };\n\n salla.event.on('wishlist::removed', handleRemoved);\n return () => {\n salla.event.off('wishlist::removed', handleRemoved);\n };\n }, [onRemoved]);\n\n useEffect(() => {\n const { ids, hasMore } = loadedRef.current;\n if (!ids.length || !ids.every((id) => removedIds.has(id))) return;\n\n const reset = (items: Product[], next: string | null) => {\n nextPageRef.current = query.page + 1;\n loadedRef.current = { ids: items.map((prod) => Number(prod.id)), hasMore: !!next };\n setRemovedIds(new Set());\n setRemovingIds(new Set());\n setReloaded((current) => ({ items, next, generation: (current?.generation ?? 0) + 1 }));\n };\n\n if (!hasMore) {\n reset([], null);\n return;\n }\n\n let cancelled = false;\n queryClient\n .fetchQuery({ ...wishlist.queries.list({ page: query.page }), staleTime: 0 })\n .then((result) => {\n if (!cancelled) reset(result.items, result.next);\n })\n // A failed reload keeps the list as it is; later pages still load on scroll.\n .catch(() => undefined);\n return () => {\n cancelled = true;\n };\n }, [removedIds, query.page, products, queryClient]);\n\n const loader = async () => {\n const pageToLoad = nextPageRef.current;\n const result = await wishlist.list({ page: pageToLoad });\n\n nextPageRef.current = pageToLoad + 1;\n loadedRef.current = {\n ids: [...loadedRef.current.ids, ...result.items.map((prod) => Number(prod.id))],\n hasMore: !!result.next,\n };\n\n return {\n items: result.items,\n next: result.next,\n };\n };\n\n const finishRemoving = useCallback((id: number) => {\n setRemovedIds((current) => (current.has(id) ? current : new Set(current).add(id)));\n }, []);\n\n return {\n items: reloaded ? reloaded.items : products,\n next: reloaded ? reloaded.next : pagination?.next,\n generation: reloaded?.generation ?? 0,\n removedIds,\n removingIds,\n finishRemoving,\n loader,\n };\n}\n\nexport function WishlistPage(props: WishlistPageProps) {\n const { t } = useTranslation();\n const { pathname, searchStr } = useLocation();\n const shareState = useWishlistShare();\n const selectedIdSet = useMemo(() => new Set(shareState.selectedIds), [shareState.selectedIds]);\n const { items, next, generation, removedIds, removingIds, finishRemoving, loader } =\n useWishlistItems(props, shareState.deselect);\n const hasRemaining = items.some((prod) => !removedIds.has(Number(prod.id)));\n\n return (\n <div className=\"space-y-5\" id=\"wishlist\">\n <HookSlot name=\"customer:wishlist.items.start\" />\n <WishlistShareBar state={shareState} hasProducts={hasRemaining || !!next} />\n <ItemsList<Product>\n key={generation}\n items={items}\n loader={loader}\n mode={next ? 'infinite' : 'static'}\n pageUrl={pathname + searchStr}\n className=\"s-products-list\"\n itemsClassName=\"s-products-list-wrapper s-products-list-row-cards\"\n empty={\n <div className=\"text-center py-16\">\n <NoContent\n icon=\"sicon-heart\"\n message={t('common.errors.no_wishlist', \"You don't have any wishes\")}\n actionLabel={t('pages.offer.continue_shopping', 'Continue shopping')}\n actionUrl=\"/\"\n />\n </div>\n }\n t={(key, fallback) => t(key, fallback || key)}\n >\n {(items) => {\n const remaining = items.filter((item) => !removedIds.has(Number(item.id)));\n shareState.loadedIdsRef.current = remaining.map((item) => Number(item.id));\n return remaining.map((prod) => (\n <WishlistCard\n key={prod.id}\n product={prod}\n removing={removingIds.has(Number(prod.id))}\n onRemoved={finishRemoving}\n selection={{\n selecting: shareState.selecting,\n selected: selectedIdSet.has(Number(prod.id)),\n onToggle: shareState.toggleSelected,\n }}\n />\n ));\n }}\n </ItemsList>\n <HookSlot name=\"customer:wishlist.items.end\" />\n </div>\n );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/store.ts"],"names":[],"mappings":";;;;;AASA,IAAM,qBAAA,GAAwB;AAAA,EAC5B,OAAA;AAAA,EACA,UAAA;AAAA,EACA,OAAA;AAAA,EACA,gBAAA;AAAA,EACA,mBAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA,EACA,UAAA;AAAA,EACA,iBAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF,CAAA;AAkEA,SAAS,iBAAiB,SAAA,EAA8D;AACtF,EAAA,IAAI,CAAC,WAAW,OAAO,MAAA;AAGvB,EAAA,OAAO,MAAA,CAAO,MAAA,CAAO,SAAS,CAAA,CAAE,GAAA,CAAI,CAAC,IAAA,MAAU,EAAE,QAAA,EAAU,IAAA,CAAK,IAAA,EAAM,GAAG,MAAK,CAAE,CAAA;AAClF;AAEO,IAAM,KAAA,GAAQ;AAAA,EACn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IAAA;AAAA,QACX,QAAQ,IAAA,CAAK;AAAA,OACf;AAAA,IACF,SAAS,KAAA,EAAO;AACd,MAAA,OAAA,CAAQ,KAAA,CAAM,4BAA4B,KAAK,CAAA;AAC/C,MAAA,OAAO,IAAA;AAAA,IACT;AAAA,EACF,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,QAAA,EAAU,CAAC,eAAA,KACT,YAAA,CAAkC;AAAA,MAChC,QAAA,EAAU;AAAA,QACR,OAAA;AAAA,QACA,UAAA;AAAA,QACA,eAAA;AAAA,QACA,oBAAmB,CAAE,MAAA;AAAA,QACrB,cAAA,EAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAQf,uBAAA;AAAwB,OAC1B;AAAA,MACA,OAAA,EAAS,MAAM,KAAA,CAAM,QAAA,CAAS,eAAe;AAAA,KAC9C;AAAA;AAEP","file":"chunk-EQ32CL4D.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api, getActiveScope, getActiveScopeId, STORE_IDENTIFIER_HEADER } from './client';\nimport type { Store, Theme, Language } from '../types';\nimport { getTwilightContext } from '../twilight/context';\nimport { resolveStoreIdentifier } from '../utils/store-identity';\nimport { requestedThemeVersionId } from '../utils/theme-version';\n\nexport { resolveStoreIdentifier };\n\nconst DEFAULT_INCLUDE_ITEMS = [\n 'store',\n 'settings',\n 'theme',\n 'theme_settings',\n 'external_services',\n 'currencies',\n 'languages',\n 'payments',\n 'product_widgets',\n 'rating',\n 'ratings',\n 'user',\n];\n\n/** Twig's `salla.init({ user })` object; the endpoint ignores the token, so always the guest. */\nexport interface SettingsUser {\n type: 'guest' | 'user';\n id?: number | string | null;\n language_code?: string;\n currency_code?: string;\n country_code?: string;\n [key: string]: unknown;\n}\n\n/**\n * Raw API response for settings endpoint.\n * Languages come as object: { \"AR\": { code, name, ... }, \"EN\": {...} }\n */\ninterface SettingsApiResponse {\n store?: Store;\n theme?: Theme;\n languages?: Record<string, Language>;\n currencies?: Record<\n string,\n { code: string; name: string; symbol: string; amount: number; country_code: string }\n >;\n external_services?: Record<string, unknown>;\n headers?: Record<string, unknown>;\n login?: { url: string; turnstile_site_key: string };\n affiliate?: { utm_url: string; cta_enabled: boolean };\n debug?: boolean;\n trace_console?: boolean;\n policy_url?: string;\n user?: SettingsUser;\n swoole?: string[];\n}\n\n/**\n * Central settings context - single source of truth for all API data.\n * Contains everything from the settings endpoint response after processing.\n */\nexport interface StoreContext {\n store?: Store;\n theme?: Theme;\n /** Languages as array after conversion from API object format */\n languages?: Language[];\n currencies?: Record<\n string,\n { code: string; name: string; symbol: string; amount: number; country_code: string }\n >;\n external_services?: Record<string, unknown>;\n headers?: Record<string, unknown>;\n login?: { url: string; turnstile_site_key: string };\n affiliate?: { utm_url: string; cta_enabled: boolean };\n debug?: boolean;\n trace_console?: boolean; // todo:: remove it\n policy_url?: string;\n user?: SettingsUser;\n /** API paths the SDK sends with `s-store-api-version: swoole` */\n swoole?: string[];\n}\n\n/**\n * Converts languages object from API to array format.\n * API returns: { \"AR\": { code, name, ... }, \"EN\": { ... } }\n * We need: [{ code, name, ... }, { code, name, ... }]\n * todo:: return the languages as object from the APIs to avoid this\n */\nfunction languagesToArray(languages?: Record<string, Language>): Language[] | undefined {\n if (!languages) return undefined;\n // The SDK's localization modal reads `lang.iso_code` (not `code`) when a language is\n // selected — without it the switch navigates to `/undefined/...`.\n return Object.values(languages).map((lang) => ({ iso_code: lang.code, ...lang }));\n}\n\nexport const store = {\n settings: async (storeIdentifier?: string): Promise<StoreContext | null> => {\n const identifier = storeIdentifier ?? resolveStoreIdentifier();\n\n if (!identifier) {\n console.warn('[store.settings] No store identifier available');\n return null;\n }\n\n const includeParams = DEFAULT_INCLUDE_ITEMS.map((i) => `include[]=${i}`).join('&');\n const scopeId = getActiveScopeId();\n const params = scopeId != null ? `${includeParams}&scope=${scopeId}` : includeParams;\n\n try {\n const json = await api\n // Sent explicitly rather than left to the client's own resolution, so\n // the identifier this function checked is the identifier that travels.\n // They agree today; a caller passing one and being answered about\n // another is the failure this makes impossible rather than unlikely.\n .get(`store/settings?${params}`, {\n timeout: 5000,\n headers: { [STORE_IDENTIFIER_HEADER]: identifier },\n })\n .json<{ data?: SettingsApiResponse }>();\n\n const data = json?.data;\n if (!data) return null;\n\n // Convert languages from object to array\n const languages = languagesToArray(data.languages);\n\n return {\n store: data.store,\n theme: data.theme,\n languages,\n currencies: data.currencies,\n external_services: data.external_services,\n headers: data.headers,\n login: data.login,\n affiliate: data.affiliate,\n policy_url: data.policy_url,\n user: data.user,\n swoole: data.swoole,\n };\n } catch (error) {\n console.error('[store.settings] Failed:', error);\n return null;\n }\n },\n\n queries: {\n settings: (storeIdentifier?: string) =>\n queryOptions<StoreContext | null>({\n queryKey: [\n 'store',\n 'settings',\n storeIdentifier,\n getTwilightContext().locale,\n getActiveScope(),\n // Two versions of one store's settings are two different answers, and\n // this is the query whose answer decides what every other call is\n // pinned to. `requestedThemeVersionId` rather than the resolved one:\n // the resolved value falls back to what these settings report, so it\n // is not knowable until after this query has run — the key would be\n // one thing on the server and another on the client, and the hydrated\n // page would refetch the settings it was just handed.\n requestedThemeVersionId(),\n ],\n queryFn: () => store.settings(storeIdentifier),\n }),\n },\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/useComments.ts"],"names":[],"mappings":";;;AAsCO,SAAS,WAAA,GAAiC;AAC/C,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,SAAS,CAAC,CAAA;AAEhD,EAAA,MAAM,OAAA,GAAU,YAAY,MAAM;AAChC,IAAA,cAAA,CAAe,CAAC,IAAA,KAAS,IAAA,GAAO,CAAC,CAAA;AAAA,EACnC,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,QAAQ,MAAA,CAAO,KAAA;AACrB,IAAA,IAAI,CAAC,KAAA,EAAO,KAAA,EAAO,EAAA,EAAI;AAEvB,IAAA,MAAM,qBAAqB,MAAM;AAC/B,MAAA,cAAA,CAAe,CAAC,IAAA,KAAS,IAAA,GAAO,CAAC,CAAA;AAAA,IACnC,CAAA;AAEA,IAAA,KAAA,CAAM,KAAA,CAAM,EAAA,CAAG,gBAAA,EAAkB,kBAAkB,CAAA;AAEnD,IAAA,OAAO,MAAM;AACX,MAAA,KAAA,CAAM,KAAA,CAAM,GAAA,CAAI,gBAAA,EAAkB,kBAAkB,CAAA;AAAA,IACtD,CAAA;AAAA,EACF,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO,EAAE,aAAa,OAAA,EAAQ;AAChC","file":"chunk-GOPUP26T.js","sourcesContent":["import { useState, useEffect, useCallback } from 'react';\n\n/**\n * UseCommentsResult - Return type for useComments hook\n *\n * @property commentsKey - Key to pass to salla-comments component for re-render\n * @property refresh - Function to manually trigger a comments refresh\n */\nexport interface UseCommentsResult {\n commentsKey: number;\n refresh: () => void;\n}\n\n/**\n * useComments - Hook for managing salla-comments web component re-renders\n *\n * Listens to the Salla SDK's comment added events and automatically\n * increments a re-render key for the salla-comments component. This\n * eliminates the need for full page reloads when comments are added.\n *\n * @returns Object with comments key for component re-rendering and manual refresh function\n *\n * @example\n * ```tsx\n * function ProductPage({ product }) {\n * const { commentsKey } = useComments();\n *\n * return (\n * <salla-comments\n * key={commentsKey}\n * item-id={product.id}\n * type=\"product\"\n * />\n * );\n * }\n * ```\n */\n\nexport function useComments(): UseCommentsResult {\n const [commentsKey, setCommentsKey] = useState(0);\n\n const refresh = useCallback(() => {\n setCommentsKey((prev) => prev + 1);\n }, []);\n\n useEffect(() => {\n const salla = window.salla;\n if (!salla?.event?.on) return;\n\n const handleCommentAdded = () => {\n setCommentsKey((prev) => prev + 1);\n };\n\n salla.event.on('comment::added', handleCommentAdded);\n\n return () => {\n salla.event.off('comment::added', handleCommentAdded);\n };\n }, []);\n\n return { commentsKey, refresh };\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
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AAUM,IAAM,QAAA,GAAW,GAAG,MAAA,CAAO;AAAA,EAChC,MAAA,EAAQ,iCAAA;AAAA,EACR,OAAA,EAAS;AACX,CAAC","file":"chunk-P3OPJL6I.js","sourcesContent":["/**\n * @fileoverview Which version of the theme's settings to render — the one answer,\n * in one place.\n *\n * A merchant's theme settings are versioned. An ordinary storefront visit names\n * no version and gets the live one; the API decides, and reports it back as\n * `theme.profile.id`. Two surfaces need a different one, and both address it in\n * the URL of an iframe:\n *\n * - the merchant's theme editor at `s.salla.sa/themes/editor/…`, which shows a\n * draft version beside the controls that are editing it;\n * - a partner running the theme locally, whose dev server is the iframe.\n *\n * Written as a module of its own rather than inline at the one call site,\n * because `store-identity.ts` exists for exactly this reason: the identifier a\n * request resolved and the identifier it sent were two different values for\n * days, in two files, and every test passed. A second implementation of this is\n * the bug, not a refactor away from one.\n */\nimport { getRequestStore, getTwilightContext } from '../twilight/context';\nimport { getInjectedRuntimeEnv } from './runtime-env';\n\n/**\n * The version this request asked for, or null when it asked for none.\n *\n * Deliberately excludes the version the *settings* name. This is the answer to\n * \"what did the caller address?\", and it has to be available before any settings\n * exist — React Query keys are built from it, and a key that means one thing\n * during SSR and another after hydration is how a page refetches everything it\n * was just handed.\n *\n * 1. what the request named, seeded by `twilightMiddleware` on a host permitted\n * to name one;\n * 2. what SSR resolved and published into the head, which is all the browser has\n * once the dispatcher has stripped `?versionId=` from the URL.\n */\nexport function requestedThemeVersionId(): string | null {\n const { versionId } = getRequestStore();\n if (versionId) return versionId;\n\n return getInjectedRuntimeEnv().versionId || null;\n}\n\n/**\n * The version every Salla API call is answered with — what goes in `s-version-id`.\n *\n * The requested version outranks the settings, because a request that named one\n * is the only reason this is ever anything but the live version: falling back to\n * the settings there would let the first answer overwrite the question.\n *\n * The settings' own `theme.profile.id` stays as the fallback, unchanged. It is\n * what this header has always carried, and on an ordinary storefront it still\n * is — it keeps the rest of a page's calls pinned to the version the settings\n * call resolved, rather than letting a version go live mid-render.\n *\n * Reading the settings is guarded because `getTwilightContext().settings` throws\n * a `SettingsError` when they have not loaded — which is the normal state on the\n * very first call, the settings call itself.\n */\nexport function resolveThemeVersionId(): string | null {\n const requested = requestedThemeVersionId();\n if (requested) return requested;\n\n try {\n const profileId = getTwilightContext().settings?.theme?.profile?.id;\n return profileId != null ? String(profileId) : null;\n } catch {\n return null;\n }\n}\n","import ky from 'ky';\nimport { createIsomorphicFn } from '@tanstack/react-start';\nimport { getCookie } from '@tanstack/react-start/server';\nimport { getStoreIdentifier } from '../utils/sdk-helpers';\nimport { resolveThemeVersionId } from '../utils/theme-version';\n// import { getInjectedRuntimeEnv, readEnv } from '../utils/runtime-env';\nimport { getTwilightContext } from '../twilight/context';\nimport {\n AUTH_TOKEN_COOKIE_NAME,\n extractScopeFromCookies,\n extractTokenFromCookies,\n readSdkScope,\n type ActiveScope,\n} from '../utils/cookies';\n\n// The twilight module store doesn't reliably carry authToken into every scope: on the\n// SERVER workerd has no AsyncLocalStorage, and on BOTH sides this api client can live in a\n// different module instance than the one rootBeforeLoad populates (engine subpath import vs\n// engine-internal relative import). So `getTwilightContext().authToken` is often null even\n// for logged-in users → API calls (orders/customer/…) return `token_not_provided` (400).\n// Read the token directly from the request cookie (server) or document.cookie / salla.storage\n// (client) as a fallback. The server-only import is stripped from the client bundle by\n// createIsomorphicFn.\nconst readFallbackToken = createIsomorphicFn()\n .server((): string | null => {\n try {\n return getCookie(AUTH_TOKEN_COOKIE_NAME) ?? null;\n } catch {\n return null;\n }\n })\n .client((): string | null => {\n const fromCookie =\n typeof document !== 'undefined'\n ? extractTokenFromCookies(document.cookie, AUTH_TOKEN_COOKIE_NAME)\n : null;\n if (fromCookie) return fromCookie;\n const storage = typeof window !== 'undefined' ? window.salla?.storage : undefined;\n const fromStorage =\n typeof storage?.get === 'function' ? storage.get(AUTH_TOKEN_COOKIE_NAME) : null;\n if (typeof fromStorage === 'string' && fromStorage) return fromStorage;\n // `?token=` webview injection lands only on the SDK's axios instance\n const fromSdkApi = typeof window !== 'undefined' ? window.salla?.api?.token : undefined;\n return typeof fromSdkApi === 'string' && fromSdkApi ? fromSdkApi : null;\n });\n\n/**\n * The auth token as the api client sees it: twilight context first, cookie/storage fallback.\n * Use this (not `getTwilightContext().authToken`, which is often null for logged-in users —\n * see the note above) to decide whether an authenticated-only query should run.\n */\nexport const getAuthToken = (): string | null =>\n getTwilightContext().authToken ?? readFallbackToken();\n\nconst API_HEADERS = {\n ACCEPT: 'accept',\n ACCEPT_LANGUAGE: 'accept-language',\n APP_OS: 's-app-os',\n APP_VERSION: 's-app-version',\n RAY: 's-ray',\n SOURCE: 's-source',\n THEME_TYPE: 's-theme-type',\n STORE_API_VERSION: 's-store-api-version',\n REQUESTED_WITH: 'x-requested-with',\n CF_PROXY_WHITELIST: 's-cf-proxy-whitelist-id',\n STORE_IDENTIFIER: 'store-identifier',\n AUTHORIZATION: 'Authorization',\n VERSION_ID: 's-version-id',\n SCOPE_ID: 's-scope-id',\n SCOPE_TYPE: 's-scope-type',\n SCOPE_ALLOCATION_TYPE: 's-scope-allocation-type',\n SCOPE_ALLOCATION_ID: 's-scope-allocation-id',\n} as const;\n\n/**\n * The header every Salla API call is answered by store.\n *\n * Exported because a caller that already knows which store it is asking about\n * must be able to say so on the request itself — see `store.settings`. Without\n * it the only way to name a store is the ambient resolver, and \"the identifier\n * I checked\" and \"the identifier that was sent\" become two different things.\n */\nexport const STORE_IDENTIFIER_HEADER = API_HEADERS.STORE_IDENTIFIER;\n\n/**\n * Active scope: the market plus its branch allocation, as the SDK stores it. On the\n * client it comes from `salla.storage.get('scope')`; before the SDK hydrates storage\n * it falls back to the `scope` cookie the theme mirrors that selection into (see\n * writeScopeCookie), then to the scope twilightMiddleware seeded from the same\n * cookie on the server. Requests vary by the `s-scope-*` headers, so React Query\n * keys must include this to avoid serving another branch's cached categories/products.\n *\n * The cookie step matters for hydration: the SDK is not guaranteed to have\n * populated `salla.storage` by the time the client rebuilds a dehydrated query\n * key, and without it the client would compute null against a scoped SSR key.\n */\nexport const getActiveScope = (): ActiveScope | null => {\n // `!== undefined`, not `!= null`: a null here is the SDK authoritatively saying \"no branch\n // selected\", which must beat a cookie left over from the previous selection. Only a\n // not-yet-ready storage API (undefined) falls through to the cookie.\n const fromStorage = readSdkScope();\n if (fromStorage !== undefined) return fromStorage;\n\n if (typeof document !== 'undefined') {\n const fromCookie = extractScopeFromCookies(document.cookie);\n if (fromCookie != null) return fromCookie;\n }\n\n try {\n return getTwilightContext().scope;\n } catch {\n return null;\n }\n};\n\n/** {@link getActiveScope} reduced to the market id. */\nexport const getActiveScopeId = (): string | null => getActiveScope()?.id ?? null;\n\nconst sharedHeaders = (locale: string) => ({\n [API_HEADERS.ACCEPT]: 'application/json' as const,\n [API_HEADERS.ACCEPT_LANGUAGE]: locale,\n [API_HEADERS.APP_OS]: 'browser',\n [API_HEADERS.APP_VERSION]: '2.14.363',\n [API_HEADERS.RAY]: '50',\n [API_HEADERS.SOURCE]: 'twilight',\n [API_HEADERS.THEME_TYPE]: 'react',\n [API_HEADERS.STORE_API_VERSION]: 'swoole',\n [API_HEADERS.REQUESTED_WITH]: 'XMLHttpRequest',\n [API_HEADERS.CF_PROXY_WHITELIST]: '019a2f78-a64c-7edb-proxy-whitelist-id-9a3a-17afda90f03a',\n});\n\n/**\n * Store API base. `VITE_API_URL` override points a preview at a branch backend; unset → prod\n * `api.salla.dev`. Resolution order matters: the value the SSR worker resolved (published into\n * the head, since worker `vars` are server-only `process.env` and never reach the browser\n * bundle) wins, so the hydrated client keeps talking to the backend that rendered the page.\n */\n\n// const STORE_API_BASE = getInjectedRuntimeEnv().apiBase || readEnv('VITE_API_URL') || 'https://api.salla.dev/store/v1';\n\nexport const api = ky.extend({\n prefix: 'https://api.salla.dev/store/v1', // TODO: check env\n timeout: 8000,\n hooks: {\n beforeRequest: [\n ({ request }) => {\n const { locale, authToken } = getTwilightContext();\n const headers = sharedHeaders(locale);\n for (const [key, value] of Object.entries(headers)) {\n request.headers.set(key, value);\n }\n // Only when the caller did not say. `headers.set` here would otherwise\n // overwrite a per-request identifier with the ambient one, which is a\n // silent way to answer a question about one store with another's data.\n if (!request.headers.get(API_HEADERS.STORE_IDENTIFIER)) {\n request.headers.set(API_HEADERS.STORE_IDENTIFIER, getStoreIdentifier());\n }\n\n // The version the request asked for, else the one the settings named.\n // Absent means \"whatever is live\", which is what an ordinary storefront\n // visit wants — so a null is left off rather than sent empty.\n const versionId = resolveThemeVersionId();\n if (versionId) {\n request.headers.set(API_HEADERS.VERSION_ID, versionId);\n }\n\n const token = authToken ?? readFallbackToken();\n if (token) {\n request.headers.set(API_HEADERS.AUTHORIZATION, `Bearer ${token}`);\n }\n\n // The same four the SDK's own client sends. The API resolves stock per\n // allocation: id alone asks about the market, not the branch the shopper chose.\n const scope = getActiveScope();\n if (scope) {\n request.headers.set(API_HEADERS.SCOPE_ID, scope.id);\n if (scope.type) request.headers.set(API_HEADERS.SCOPE_TYPE, scope.type);\n if (scope.allocation_type)\n request.headers.set(API_HEADERS.SCOPE_ALLOCATION_TYPE, scope.allocation_type);\n if (scope.allocation_id)\n request.headers.set(API_HEADERS.SCOPE_ALLOCATION_ID, scope.allocation_id);\n }\n },\n ],\n },\n});\n\nexport const cdn = ky.extend({\n prefix: 'https://cdn.salla.network',\n timeout: 5000,\n});\n\n/**\n * The merchant uploader's public bucket, `admin-uploader-prod`.\n *\n * A different host from {@link cdn} and a different thing behind it: this one\n * is an R2 custom domain, so a read never passes through a worker. Storefront\n * translations live here, per language, under `translations/` — see\n * `api/translations.ts`.\n */\nexport const filesCdn = ky.extend({\n prefix: 'https://cdn.files.salla.network',\n timeout: 5000,\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/useProduct.ts"],"names":[],"mappings":";;;AA2DO,SAAS,UAAA,CAAW,gBAAyB,OAAA,EAA+C;AACjG,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAI,SAAkB,cAAc,CAAA;AAI9D,EA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AA,CAAM,KAAA,EAAO,GAAA,GAAM,wBAAA,EAA0B,QAAQ,CAAA;AAAA,IACvD,CAAA;AAAA,EACF,CAAA,EAAG,EAAE,CAAA;AAGL,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,QAAQ,MAAA,CAAO,KAAA;AACrB,IAAA,IAAI,CAAC,KAAA,EAAO,KAAA,EAAO,EAAA,EAAI;AAEvB,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,KAAA,CAAM,KAAA,CAAM,EAAA,CAAG,+BAAA,EAAiC,iBAAiB,CAAA;AACjE,IAAA,OAAO,MAAM;AACX,MAAA,KAAA,CAAM,KAAA,EAAO,GAAA,GAAM,+BAAA,EAAiC,iBAAiB,CAAA;AAAA,IACvE,CAAA;AAAA,EACF,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO,EAAE,SAAS,MAAA,EAAO;AAC3B","file":"chunk-PWBMSGMU.js","sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport type { Product } from '../types';\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(() => {\n const salla = window.salla;\n if (!salla?.event?.on) return;\n\n salla.event.on('product:options.updated', reload);\n return () => {\n salla.event?.off?.('product:options.updated', reload);\n };\n }, [reload]);\n\n // Subscribe to price update events (matches product.js registerEvents)\n useEffect(() => {\n const salla = window.salla;\n if (!salla?.event?.on) return;\n\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 salla.event.on('product::price.updated', listener);\n return () => {\n salla.event?.off?.('product::price.updated', listener);\n };\n }, []);\n\n // Subscribe to price update failed events (matches product.js)\n useEffect(() => {\n const salla = window.salla;\n if (!salla?.event?.on) return;\n\n const handlePriceFailed = () => {\n setProduct((prev) => ({ ...prev, is_out_of_stock: true }));\n };\n\n salla.event.on('product::price.updated.failed', handlePriceFailed);\n return () => {\n salla.event?.off?.('product::price.updated.failed', handlePriceFailed);\n };\n }, []);\n\n return { product, reload };\n}\n"]}
|
package/dist/chunk-TFROBJP5.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { lazy } from 'react';
|
|
2
|
-
|
|
3
|
-
// src/components/cart/lazy.ts
|
|
4
|
-
var LazyCartItem = lazy(() => import('./CartItem-DNA2TJ6B.js').then((m) => ({ default: m.CartItem })));
|
|
5
|
-
var LazyCartSummary = lazy(
|
|
6
|
-
() => import('./CartSummary-RTDKJUV7.js').then((m) => ({ default: m.CartSummary }))
|
|
7
|
-
);
|
|
8
|
-
var LazySeoCartWidget = lazy(
|
|
9
|
-
() => import('./SeoCartWidget-X5HTL62D.js').then((m) => ({ default: m.SeoCartWidget }))
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
export { LazyCartItem, LazyCartSummary, LazySeoCartWidget };
|
|
13
|
-
//# sourceMappingURL=chunk-TFROBJP5.js.map
|
|
14
|
-
//# sourceMappingURL=chunk-TFROBJP5.js.map
|