@salla.sa/twilight-theme-engine 1.0.33 → 1.0.35

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.
Files changed (218) hide show
  1. package/dist/{AddToCartForm-JUL3VQJH.js → AddToCartForm-PNZBIPJU.js} +3 -3
  2. package/dist/{AddToCartForm-JUL3VQJH.js.map → AddToCartForm-PNZBIPJU.js.map} +1 -1
  3. package/dist/{BlogAuthorPage-E6U6IU75.js → BlogAuthorPage-FTVPPHHS.js} +15 -15
  4. package/dist/{BlogAuthorPage-E6U6IU75.js.map → BlogAuthorPage-FTVPPHHS.js.map} +1 -1
  5. package/dist/{BlogCategoryPage-AIVIJUI6.js → BlogCategoryPage-TJFW7DDI.js} +15 -15
  6. package/dist/{BlogCategoryPage-AIVIJUI6.js.map → BlogCategoryPage-TJFW7DDI.js.map} +1 -1
  7. package/dist/{BlogPage-Z5AESDKT.js → BlogPage-RD4JUGKY.js} +13 -13
  8. package/dist/{BlogPage-Z5AESDKT.js.map → BlogPage-RD4JUGKY.js.map} +1 -1
  9. package/dist/{BlogSinglePage-SK6UTGU2.js → BlogSinglePage-DVZX3WVW.js} +13 -13
  10. package/dist/{BlogSinglePage-SK6UTGU2.js.map → BlogSinglePage-DVZX3WVW.js.map} +1 -1
  11. package/dist/{BlogTagPage-7MW77IEJ.js → BlogTagPage-UON2ASKW.js} +15 -15
  12. package/dist/{BlogTagPage-7MW77IEJ.js.map → BlogTagPage-UON2ASKW.js.map} +1 -1
  13. package/dist/{BrandsPage-C4FVFHKY.js → BrandsPage-R4KTDEG3.js} +13 -13
  14. package/dist/{BrandsPage-C4FVFHKY.js.map → BrandsPage-R4KTDEG3.js.map} +1 -1
  15. package/dist/{Breadcrumb-LBUNL5UM.js → Breadcrumb-YNVX6ZXO.js} +13 -13
  16. package/dist/{Breadcrumb-LBUNL5UM.js.map → Breadcrumb-YNVX6ZXO.js.map} +1 -1
  17. package/dist/{CartItem-KUNLKUDS.js → CartItem-6P4AB6LQ.js} +13 -13
  18. package/dist/{CartItem-KUNLKUDS.js.map → CartItem-6P4AB6LQ.js.map} +1 -1
  19. package/dist/{CartSummary-34XD6TBJ.js → CartSummary-A25PNJSY.js} +13 -13
  20. package/dist/{CartSummary-34XD6TBJ.js.map → CartSummary-A25PNJSY.js.map} +1 -1
  21. package/dist/{Copyright-2LHIDE5F.js → Copyright-J6O4JUG7.js} +3 -3
  22. package/dist/{Copyright-2LHIDE5F.js.map → Copyright-J6O4JUG7.js.map} +1 -1
  23. package/dist/{CustomerLayout-DQXFC7GZ.js → CustomerLayout-JNUTNHBA.js} +13 -13
  24. package/dist/{CustomerLayout-DQXFC7GZ.js.map → CustomerLayout-JNUTNHBA.js.map} +1 -1
  25. package/dist/{Footer-YHULLC4R.js → Footer-GR7WW7UA.js} +13 -13
  26. package/dist/{Footer-YHULLC4R.js.map → Footer-GR7WW7UA.js.map} +1 -1
  27. package/dist/{Header-KTME4H7Z.js → Header-2CTHBDYE.js} +6 -6
  28. package/dist/{Header-KTME4H7Z.js.map → Header-2CTHBDYE.js.map} +1 -1
  29. package/dist/{LoyaltyPage-WFZ2ZORO.js → LoyaltyPage-EHRGBXF6.js} +14 -14
  30. package/dist/{LoyaltyPage-WFZ2ZORO.js.map → LoyaltyPage-EHRGBXF6.js.map} +1 -1
  31. package/dist/{MainMenu-YKAOXV25.js → MainMenu-TFUVK4W7.js} +7 -7
  32. package/dist/{MainMenu-YKAOXV25.js.map → MainMenu-TFUVK4W7.js.map} +1 -1
  33. package/dist/{MasterLayout-LIUS4RDW.js → MasterLayout-ODH7CFAU.js} +13 -13
  34. package/dist/{MasterLayout-LIUS4RDW.js.map → MasterLayout-ODH7CFAU.js.map} +1 -1
  35. package/dist/{MobileMenu-OQ356JT2.js → MobileMenu-5OJEI2CQ.js} +14 -14
  36. package/dist/{MobileMenu-OQ356JT2.js.map → MobileMenu-5OJEI2CQ.js.map} +1 -1
  37. package/dist/{NotificationsPage-VWHBYUL7.js → NotificationsPage-U4ULROLR.js} +13 -13
  38. package/dist/{NotificationsPage-VWHBYUL7.js.map → NotificationsPage-U4ULROLR.js.map} +1 -1
  39. package/dist/{OrderSinglePage-5ITWHCFM.js → OrderSinglePage-O2ODTG33.js} +14 -14
  40. package/dist/{OrderSinglePage-5ITWHCFM.js.map → OrderSinglePage-O2ODTG33.js.map} +1 -1
  41. package/dist/{OrdersPage-55AU4TI5.js → OrdersPage-72RXJGSH.js} +14 -14
  42. package/dist/{OrdersPage-55AU4TI5.js.map → OrdersPage-72RXJGSH.js.map} +1 -1
  43. package/dist/{PageSingle-KOVHYH4T.js → PageSingle-7Y4WJAA6.js} +3 -3
  44. package/dist/{PageSingle-KOVHYH4T.js.map → PageSingle-7Y4WJAA6.js.map} +1 -1
  45. package/dist/{ProductDetails-DIFPSRSW.js → ProductDetails-GYCTNAWE.js} +3 -3
  46. package/dist/{ProductDetails-DIFPSRSW.js.map → ProductDetails-GYCTNAWE.js.map} +1 -1
  47. package/dist/{ProfilePage-ZSXY4R5D.js → ProfilePage-GVYL5NVL.js} +13 -13
  48. package/dist/{ProfilePage-ZSXY4R5D.js.map → ProfilePage-GVYL5NVL.js.map} +1 -1
  49. package/dist/{RenderWhenVisible-2BRWQDOQ.js → RenderWhenVisible-F44J5MMG.js} +4 -4
  50. package/dist/RenderWhenVisible-F44J5MMG.js.map +1 -0
  51. package/dist/{SeoCartWidget-JAGDCGBR.js → SeoCartWidget-KHDAMXBG.js} +13 -13
  52. package/dist/{SeoCartWidget-JAGDCGBR.js.map → SeoCartWidget-KHDAMXBG.js.map} +1 -1
  53. package/dist/{SettingsPage-DAOVF5GP.js → SettingsPage-ZCLDJNHY.js} +13 -13
  54. package/dist/{SettingsPage-DAOVF5GP.js.map → SettingsPage-ZCLDJNHY.js.map} +1 -1
  55. package/dist/{StoreClosedNotification-GICIJCN4.js → StoreClosedNotification-6O34WQJV.js} +14 -14
  56. package/dist/{StoreClosedNotification-GICIJCN4.js.map → StoreClosedNotification-6O34WQJV.js.map} +1 -1
  57. package/dist/{TestimonialsPage-SHV2K5N6.js → TestimonialsPage-Y3DCS2RB.js} +3 -3
  58. package/dist/{TestimonialsPage-SHV2K5N6.js.map → TestimonialsPage-Y3DCS2RB.js.map} +1 -1
  59. package/dist/{ThankYouPage-HJRYYSLT.js → ThankYouPage-MPF4V5T3.js} +13 -13
  60. package/dist/{ThankYouPage-HJRYYSLT.js.map → ThankYouPage-MPF4V5T3.js.map} +1 -1
  61. package/dist/{WalletPage-BXSYYQGC.js → WalletPage-XVEZKUCP.js} +14 -14
  62. package/dist/{WalletPage-BXSYYQGC.js.map → WalletPage-XVEZKUCP.js.map} +1 -1
  63. package/dist/{WishlistPage-CAYYF5G6.js → WishlistPage-MALKVYV4.js} +14 -14
  64. package/dist/{WishlistPage-CAYYF5G6.js.map → WishlistPage-MALKVYV4.js.map} +1 -1
  65. package/dist/api/apps.js +4 -4
  66. package/dist/api/brands.js +5 -5
  67. package/dist/api/cart.js +5 -5
  68. package/dist/api/category.d.ts +3 -3
  69. package/dist/api/category.js +5 -5
  70. package/dist/api/client.d.ts +9 -6
  71. package/dist/api/client.d.ts.map +1 -1
  72. package/dist/api/client.js +3 -3
  73. package/dist/api/home.js +4 -4
  74. package/dist/api/loyalty.js +5 -5
  75. package/dist/api/menu.js +4 -4
  76. package/dist/api/notification.js +4 -4
  77. package/dist/api/order.js +5 -5
  78. package/dist/api/page.js +5 -5
  79. package/dist/api/product.d.ts +12 -6
  80. package/dist/api/product.d.ts.map +1 -1
  81. package/dist/api/product.js +5 -5
  82. package/dist/api/profile.js +3 -3
  83. package/dist/api/store.js +4 -4
  84. package/dist/api/translations.js +4 -4
  85. package/dist/api/user.js +4 -4
  86. package/dist/api/wishlist.js +4 -4
  87. package/dist/{chunk-NGYYCFTS.js → chunk-47C6C2NN.js} +4 -4
  88. package/dist/{chunk-NGYYCFTS.js.map → chunk-47C6C2NN.js.map} +1 -1
  89. package/dist/{chunk-C3UUGHTX.js → chunk-57RYHNW2.js} +3 -3
  90. package/dist/{chunk-C3UUGHTX.js.map → chunk-57RYHNW2.js.map} +1 -1
  91. package/dist/{chunk-XITF2PHC.js → chunk-5ACY5CD3.js} +10 -6
  92. package/dist/chunk-5ACY5CD3.js.map +1 -0
  93. package/dist/{chunk-AU7PMZV4.js → chunk-5IEQLAAY.js} +5 -5
  94. package/dist/chunk-5IEQLAAY.js.map +1 -0
  95. package/dist/{chunk-6MREJTVB.js → chunk-6BVPVYLN.js} +7 -6
  96. package/dist/chunk-6BVPVYLN.js.map +1 -0
  97. package/dist/{chunk-QFCBAWHP.js → chunk-6EBQ27KE.js} +15 -15
  98. package/dist/{chunk-QFCBAWHP.js.map → chunk-6EBQ27KE.js.map} +1 -1
  99. package/dist/{chunk-ALUEX3YC.js → chunk-6JLVUQWD.js} +4 -4
  100. package/dist/{chunk-ALUEX3YC.js.map → chunk-6JLVUQWD.js.map} +1 -1
  101. package/dist/{chunk-TN4M4DYQ.js → chunk-B4SPJFNB.js} +4 -4
  102. package/dist/{chunk-TN4M4DYQ.js.map → chunk-B4SPJFNB.js.map} +1 -1
  103. package/dist/{chunk-MT53C7SH.js → chunk-BOOOVZS4.js} +4 -4
  104. package/dist/{chunk-MT53C7SH.js.map → chunk-BOOOVZS4.js.map} +1 -1
  105. package/dist/{chunk-SY47NKC6.js → chunk-C4S4VXWW.js} +3 -3
  106. package/dist/{chunk-SY47NKC6.js.map → chunk-C4S4VXWW.js.map} +1 -1
  107. package/dist/{chunk-ZAJOW3MZ.js → chunk-CBQKQCKI.js} +4 -4
  108. package/dist/{chunk-ZAJOW3MZ.js.map → chunk-CBQKQCKI.js.map} +1 -1
  109. package/dist/{chunk-XVCBMEBY.js → chunk-DLDDKPRN.js} +12 -12
  110. package/dist/{chunk-XVCBMEBY.js.map → chunk-DLDDKPRN.js.map} +1 -1
  111. package/dist/{chunk-MAQPYTER.js → chunk-E3J2RXBS.js} +3 -3
  112. package/dist/{chunk-MAQPYTER.js.map → chunk-E3J2RXBS.js.map} +1 -1
  113. package/dist/{chunk-MQ4UTXPR.js → chunk-EV4JSMFZ.js} +3 -3
  114. package/dist/{chunk-MQ4UTXPR.js.map → chunk-EV4JSMFZ.js.map} +1 -1
  115. package/dist/{chunk-75HMCUTB.js → chunk-FPQAYFHZ.js} +3 -3
  116. package/dist/{chunk-75HMCUTB.js.map → chunk-FPQAYFHZ.js.map} +1 -1
  117. package/dist/{chunk-D2UOBR4H.js → chunk-FQGCCV4T.js} +3 -3
  118. package/dist/{chunk-D2UOBR4H.js.map → chunk-FQGCCV4T.js.map} +1 -1
  119. package/dist/{chunk-NR2XM4KT.js → chunk-GCAIIFF3.js} +3 -3
  120. package/dist/{chunk-NR2XM4KT.js.map → chunk-GCAIIFF3.js.map} +1 -1
  121. package/dist/{chunk-EXRS5IAC.js → chunk-GQ7IBJ55.js} +4 -4
  122. package/dist/{chunk-EXRS5IAC.js.map → chunk-GQ7IBJ55.js.map} +1 -1
  123. package/dist/{chunk-ZCLXL3VH.js → chunk-HYESKIWZ.js} +4 -4
  124. package/dist/{chunk-ZCLXL3VH.js.map → chunk-HYESKIWZ.js.map} +1 -1
  125. package/dist/chunk-IN5RFJF2.js +14 -0
  126. package/dist/{chunk-W26EE36N.js.map → chunk-IN5RFJF2.js.map} +1 -1
  127. package/dist/{chunk-JY7PNW7G.js → chunk-L6UGY2OB.js} +3 -3
  128. package/dist/{chunk-JY7PNW7G.js.map → chunk-L6UGY2OB.js.map} +1 -1
  129. package/dist/{chunk-3Z7TBM7W.js → chunk-LG556DIE.js} +3 -3
  130. package/dist/{chunk-3Z7TBM7W.js.map → chunk-LG556DIE.js.map} +1 -1
  131. package/dist/{chunk-DOOZU75W.js → chunk-LXIEAZZJ.js} +3 -3
  132. package/dist/{chunk-DOOZU75W.js.map → chunk-LXIEAZZJ.js.map} +1 -1
  133. package/dist/{chunk-RMS55CNX.js → chunk-MY3ZH5BA.js} +6 -6
  134. package/dist/{chunk-RMS55CNX.js.map → chunk-MY3ZH5BA.js.map} +1 -1
  135. package/dist/{chunk-EIFCJLBN.js → chunk-NTOIR3NK.js} +4 -4
  136. package/dist/{chunk-EIFCJLBN.js.map → chunk-NTOIR3NK.js.map} +1 -1
  137. package/dist/{chunk-3KRYKGMY.js → chunk-OOYJHQLQ.js} +4 -4
  138. package/dist/{chunk-3KRYKGMY.js.map → chunk-OOYJHQLQ.js.map} +1 -1
  139. package/dist/{chunk-HGMKQUCT.js → chunk-Q56S25OH.js} +6 -6
  140. package/dist/{chunk-HGMKQUCT.js.map → chunk-Q56S25OH.js.map} +1 -1
  141. package/dist/{chunk-GL3ZWX64.js → chunk-QOK3ANNB.js} +4 -4
  142. package/dist/{chunk-GL3ZWX64.js.map → chunk-QOK3ANNB.js.map} +1 -1
  143. package/dist/{chunk-HSKFHCKL.js → chunk-RQHOAA7U.js} +4 -4
  144. package/dist/{chunk-HSKFHCKL.js.map → chunk-RQHOAA7U.js.map} +1 -1
  145. package/dist/{chunk-IK6X5HMK.js → chunk-STHBBSK2.js} +3 -3
  146. package/dist/{chunk-IK6X5HMK.js.map → chunk-STHBBSK2.js.map} +1 -1
  147. package/dist/{chunk-OHKISMO2.js → chunk-T3I4T3XB.js} +7 -7
  148. package/dist/{chunk-OHKISMO2.js.map → chunk-T3I4T3XB.js.map} +1 -1
  149. package/dist/{chunk-3MEAEE7K.js → chunk-TXYT42AU.js} +3 -3
  150. package/dist/{chunk-3MEAEE7K.js.map → chunk-TXYT42AU.js.map} +1 -1
  151. package/dist/{chunk-5UB64JFA.js → chunk-VBXAGCNI.js} +5 -5
  152. package/dist/{chunk-5UB64JFA.js.map → chunk-VBXAGCNI.js.map} +1 -1
  153. package/dist/{chunk-EZSYN4P3.js → chunk-WXOABH6J.js} +22 -14
  154. package/dist/chunk-WXOABH6J.js.map +1 -0
  155. package/dist/{chunk-AGJFLQQ2.js → chunk-XBLA5RFR.js} +5 -5
  156. package/dist/{chunk-AGJFLQQ2.js.map → chunk-XBLA5RFR.js.map} +1 -1
  157. package/dist/{chunk-YZUNEFDM.js → chunk-Y5FBDMFV.js} +26 -17
  158. package/dist/chunk-Y5FBDMFV.js.map +1 -0
  159. package/dist/{chunk-QZ6I5CA7.js → chunk-Z2BE6MDB.js} +6 -6
  160. package/dist/chunk-Z2BE6MDB.js.map +1 -0
  161. package/dist/{chunk-OEGDGMRX.js → chunk-Z2P4M6T6.js} +3 -3
  162. package/dist/{chunk-OEGDGMRX.js.map → chunk-Z2P4M6T6.js.map} +1 -1
  163. package/dist/components/cart/index.js +1 -1
  164. package/dist/components/common/RenderWhenVisible.d.ts.map +1 -1
  165. package/dist/components/common/index.js +1 -1
  166. package/dist/components/drawer/index.js +11 -11
  167. package/dist/components/home/index.js +14 -14
  168. package/dist/components/layout/index.js +5 -5
  169. package/dist/components/product/index.js +12 -12
  170. package/dist/components/store/index.js +13 -13
  171. package/dist/document-class-BQBALA53.js +23 -0
  172. package/dist/{document-class-4VSG3RUT.js.map → document-class-BQBALA53.js.map} +1 -1
  173. package/dist/hooks/index.js +11 -11
  174. package/dist/hooks/useGtm.js +11 -11
  175. package/dist/hooks/useMoney.js +11 -11
  176. package/dist/hooks/useStore.js +11 -11
  177. package/dist/hooks/useUser.js +5 -5
  178. package/dist/index.js +11 -11
  179. package/dist/{navigation-ASMHNVYI.js → navigation-B6TEUWEK.js} +4 -4
  180. package/dist/{navigation-ASMHNVYI.js.map → navigation-B6TEUWEK.js.map} +1 -1
  181. package/dist/{navigation-3UQAUEHS.js → navigation-RYSVWICZ.js} +5 -5
  182. package/dist/{navigation-3UQAUEHS.js.map → navigation-RYSVWICZ.js.map} +1 -1
  183. package/dist/{not-found-ONLFUX5P.js → not-found-OPY73PW5.js} +13 -13
  184. package/dist/{not-found-ONLFUX5P.js.map → not-found-OPY73PW5.js.map} +1 -1
  185. package/dist/providers/index.js +11 -11
  186. package/dist/routes/account/orders.js +6 -6
  187. package/dist/routes/account.js +14 -14
  188. package/dist/routes/blog.js +10 -10
  189. package/dist/routes/brands.js +6 -6
  190. package/dist/routes/cart.js +19 -19
  191. package/dist/routes/home.js +16 -16
  192. package/dist/routes/index.js +3 -3
  193. package/dist/routes/loyalty.js +6 -6
  194. package/dist/routes/page.js +6 -6
  195. package/dist/routes/product-listing.js +16 -16
  196. package/dist/routes/product.js +14 -14
  197. package/dist/routes/seo-redirects.js +3 -3
  198. package/dist/routes/testimonials.js +2 -2
  199. package/dist/routes/thank-you.js +6 -6
  200. package/dist/skeleton.js +16 -16
  201. package/dist/tanstack.js +16 -16
  202. package/dist/tanstack.js.map +1 -1
  203. package/dist/twilight/context.d.ts +8 -0
  204. package/dist/twilight/context.d.ts.map +1 -1
  205. package/dist/utils/cookies.d.ts +28 -9
  206. package/dist/utils/cookies.d.ts.map +1 -1
  207. package/dist/utils/index.js +4 -4
  208. package/dist/vite/index.js +2 -2
  209. package/package.json +1 -1
  210. package/dist/RenderWhenVisible-2BRWQDOQ.js.map +0 -1
  211. package/dist/chunk-6MREJTVB.js.map +0 -1
  212. package/dist/chunk-AU7PMZV4.js.map +0 -1
  213. package/dist/chunk-EZSYN4P3.js.map +0 -1
  214. package/dist/chunk-QZ6I5CA7.js.map +0 -1
  215. package/dist/chunk-W26EE36N.js +0 -14
  216. package/dist/chunk-XITF2PHC.js.map +0 -1
  217. package/dist/chunk-YZUNEFDM.js.map +0 -1
  218. package/dist/document-class-4VSG3RUT.js +0 -23
@@ -2,6 +2,7 @@ import type { QueryClient } from '@tanstack/react-query';
2
2
  import type { i18n } from 'i18next';
3
3
  import type { StoreContext } from '../api/store';
4
4
  import type { AppSnippet, AppSettings } from '../api/apps';
5
+ import type { ActiveScope } from '../utils/cookies';
5
6
  export interface TwilightLocation<TSearch = Record<string, unknown>> {
6
7
  href: string;
7
8
  pathname: string;
@@ -32,6 +33,13 @@ export interface TwilightContext {
32
33
  routeId: string;
33
34
  location: TwilightLocation;
34
35
  authToken: string | null;
36
+ /**
37
+ * The selected market and, once bullet delivery confirmed one, its branch
38
+ * allocation — the full object the SDK sends as `s-scope-*` headers. Seeded from
39
+ * the `scope` cookie on the server; see {@link ActiveScope}.
40
+ */
41
+ scope: ActiveScope | null;
42
+ /** `scope.id`, kept for callers that only need the market. */
35
43
  scopeId: string | null;
36
44
  /**
37
45
  * Which store this request is for, when something other than the hostname says
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/twilight/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAU3D,MAAM,WAAW,gBAAgB,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACjE,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACnE,WAAW,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC/C;AAED,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,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earAuthTokenCookie(): void;
96
96
  export declare function extractTokenFromCookies(cookieHeader: string | null, cookieName: string): string | null;
97
97
  /**
98
- * Reads the active scope id from the `scope` cookie, which Salla persists as a
99
- * JSON object (e.g. `{"id":123,"type":"branch"}`). Returns null when the cookie
100
- * is missing or unparseable. Used server-side, where `salla.storage` is absent.
98
+ * The scope the Salla SDK persists as `scope`: the market (`id`/`type`) plus, once
99
+ * bullet delivery confirms an address or branch, the allocation. The SDK sends all
100
+ * four as request headers (`s-scope-id`, `s-scope-type`, `s-scope-allocation-type`,
101
+ * `s-scope-allocation-id`) and the API resolves stock per allocation — a scope sent
102
+ * without its allocation is a different question, answered from a different branch.
101
103
  */
104
+ export interface ActiveScope {
105
+ id: string;
106
+ type?: string;
107
+ allocation_type?: string;
108
+ allocation_id?: string;
109
+ }
110
+ /**
111
+ * Reads the active scope from the `scope` cookie, which Salla persists as a JSON
112
+ * object (e.g. `{"id":123,"type":"scope","allocation_type":"branch","allocation_id":"9"}`).
113
+ * Returns null when the cookie is missing or unparseable. Used server-side, where
114
+ * `salla.storage` is absent.
115
+ */
116
+ export declare function extractScopeFromCookies(cookieHeader: string | null): ActiveScope | null;
117
+ /** {@link extractScopeFromCookies} reduced to the id. */
102
118
  export declare function extractScopeIdFromCookies(cookieHeader: string | null): string | null;
103
119
  /**
104
- * The branch the Salla SDK persisted in its storage (`salla.storage.get('scope')`),
105
- * which it stores either as `{ id, type }` or as a bare id.
120
+ * The scope the Salla SDK persisted in its storage (`salla.storage.get('scope')`).
106
121
  *
107
122
  * Returns `undefined` when the SDK storage API isn't ready yet — deliberately
108
123
  * distinct from `null` ("no branch selected"), so callers can't mistake a
109
124
  * not-yet-hydrated SDK for a cleared selection. Client-only.
110
125
  */
126
+ export declare function readSdkScope(): ActiveScope | null | undefined;
127
+ /** {@link readSdkScope} reduced to the id; keeps the not-ready/none distinction. */
111
128
  export declare function readSdkScopeId(): string | null | undefined;
112
129
  /**
113
- * Mirrors the branch the Salla SDK selected into the `scope` cookie so the SERVER
130
+ * Mirrors the scope the Salla SDK selected into the `scope` cookie so the SERVER
114
131
  * can see it. The SDK persists the selection in localStorage ONLY and writes no
115
132
  * cookie, so without this the server computes scope=null for every visitor who
116
133
  * picked a branch while the client computes the branch id — the dehydrated settings
117
134
  * query key never matches and the client refetches store settings on every page
118
135
  * load (SAL-122).
119
136
  *
120
- * Written in the SDK's own JSON shape so {@link extractScopeIdFromCookies} parses it.
121
- * Returns true when the cookie was (re)written. Client-only; no-op on the server.
137
+ * Written in the SDK's own JSON shape so {@link extractScopeFromCookies} parses it,
138
+ * allocation included: the bullet-delivery component writes the same cookie with the
139
+ * full object, and rewriting it with the id alone would drop the branch the server
140
+ * needs. Returns true when the cookie was (re)written. Client-only; no-op on the server.
122
141
  */
123
- export declare function writeScopeCookie(scopeId: string | null): boolean;
142
+ export declare function writeScopeCookie(scope: ActiveScope | null): boolean;
124
143
  /**
125
144
  * Keeps the `scope` cookie in step with the SDK's selected branch. Call on every
126
145
  * client navigation; it no-ops while the SDK storage API is still hydrating so a
@@ -1 +1 @@
1
- {"version":3,"file":"cookies.d.ts","sourceRoot":"","sources":["../../src/utils/cookies.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,UAAU,CAAC;AAC9C,eAAO,MAAM,iBAAiB,UAAU,CAAC;AAEzC;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,oBAAoB,cAAc,CAAC;AAEhD,6EAA6E;AAC7E,eAAO,MAAM,cAAc,YAAY,CAAC;AAExC;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAG1E;AAED,wFAAwF;AACxF,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAEpF;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,E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AG,IAAI,CAEpF;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,IAAI,WAAW,GAAG,IAAI,GAAG,SAAS,CAI7D;AAED,oFAAoF;AACpF,wBAAgB,cAAc,IAAI,MAAM,GAAG,IAAI,GAAG,SAAS,CAG1D;AAQD;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,GAAG,OAAO,CAYnE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAGzC"}
@@ -1,13 +1,13 @@
1
1
  export { formatSallaPlural } from '../chunk-BT6HEEAP.js';
2
2
  export { stripUnsafeHtml } from '../chunk-RUHSV4Z6.js';
3
- export { dispatchRouteChanged } from '../chunk-MQ4UTXPR.js';
3
+ export { dispatchRouteChanged } from '../chunk-EV4JSMFZ.js';
4
4
  export { mergeHead, resolveHead, setHeadAdapter } from '../chunk-B3EFOE57.js';
5
5
  export { sortOptions } from '../chunk-6Z4MOC4S.js';
6
6
  export { buildBaseHead, buildHreflangAlternates, localeToOgLocale } from '../chunk-TZ3E5BN4.js';
7
7
  export { color } from '../chunk-VVZNW5CB.js';
8
- export { applyAppScopeMocks, registerThemeHookSlots } from '../chunk-3Z7TBM7W.js';
9
- export { AUTH_TOKEN_COOKIE_NAME, clearAuthTokenCookie, extractTokenFromCookies, getSallaSDK, getStoreIdentifier } from '../chunk-YZUNEFDM.js';
10
- import '../chunk-XITF2PHC.js';
8
+ export { applyAppScopeMocks, registerThemeHookSlots } from '../chunk-LG556DIE.js';
9
+ export { AUTH_TOKEN_COOKIE_NAME, clearAuthTokenCookie, extractTokenFromCookies, getSallaSDK, getStoreIdentifier } from '../chunk-Y5FBDMFV.js';
10
+ import '../chunk-5ACY5CD3.js';
11
11
  export { asset, cdn, isPlaceholder } from '../chunk-ZCH7W7DZ.js';
12
12
  export { mergeDocumentDescriptors, mergeElementAttrs, normalizeClasses, syncAttrsToElement, toReactProps } from '../chunk-CW625T2E.js';
13
13
  import '../chunk-T72DAX7R.js';
@@ -1,8 +1,8 @@
1
- import { tanstackHeadAdapter } from '../chunk-D2UOBR4H.js';
1
+ import { tanstackHeadAdapter } from '../chunk-FQGCCV4T.js';
2
2
  import { nextjsHeadAdapter } from '../chunk-HOSHJBPS.js';
3
3
  import { setHeadAdapter } from '../chunk-B3EFOE57.js';
4
4
  import { RouteId } from '../chunk-MTONGOJD.js';
5
- import '../chunk-XITF2PHC.js';
5
+ import '../chunk-5ACY5CD3.js';
6
6
  import '../chunk-T72DAX7R.js';
7
7
  import '../chunk-DGUM43GV.js';
8
8
  import { readFile, readdir } from 'fs/promises';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salla.sa/twilight-theme-engine",
3
- "version": "1.0.33",
3
+ "version": "1.0.35",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/common/RenderWhenVisible.tsx"],"names":["RenderWhenVisible"],"mappings":";;;;AAEA,SAAS,eAAA,CAAgB,EAAE,MAAA,EAAO,EAAuB;AACvD,EAAA,uBAAO,GAAA,CAAC,SAAI,KAAA,EAAO,EAAE,WAAW,MAAA,EAAO,EAAG,WAAU,mCAAA,EAAoC,CAAA;AAC1F;AAGA,SAAS,WAAA,CAAY,EAAE,OAAA,EAAQ,EAA4C;AACzE,EAAA,SAAA,CAAU,MAAM,OAAA,CAAQ,IAAI,CAAA,EAAG,CAAC,OAAO,CAAC,CAAA;AACxC,EAAA,OAAO,IAAA;AACT;AA0BO,IAAM,iBAAA,GAAoB,IAAA,CAAK,SAASA,kBAAAA,CAAkB;AAAA,EAC/D,QAAA;AAAA,EACA,UAAA,GAAa,MAAA;AAAA,EACb,WAAA;AAAA,EACA,SAAA;AAAA,EACA,EAAA;AAAA,EACA,eAAA,GAAkB,OAAA;AAAA,EAClB,aAAA,GAAgB;AAClB,CAAA,EAA2B;AACzB,EAAA,MAAM,GAAA,GAAM,OAAoB,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GAEA;AAAA;AAAA,GAEJ;AAEJ,CAAC","file":"RenderWhenVisible-2BRWQDOQ.js","sourcesContent":["import { memo, useState, useEffect, useRef, Suspense, type ReactNode } from 'react';\n\nfunction DefaultSkeleton({ height }: { height: string }) {\n return <div style={{ minHeight: height }} className=\"animate-pulse rounded bg-gray-100\" />;\n}\n\n/** Sibling of the children inside Suspense: its effect only runs once the boundary resolves. */\nfunction MarkMounted({ onMount }: { onMount: (mounted: boolean) => void }) {\n useEffect(() => onMount(true), [onMount]);\n return null;\n}\n\nexport interface RenderWhenVisibleProps {\n children: ReactNode;\n rootMargin?: string;\n placeholder?: ReactNode;\n className?: string;\n id?: string;\n estimatedHeight?: string;\n renderOnMount?: boolean;\n}\n\n/**\n * RenderWhenVisible — defers mounting children until the container enters the viewport.\n *\n * Children are NOT in the React tree at all until the Intersection Observer fires,\n * so no effects, API calls, or renders happen for off-screen sections.\n * Once rendered, children stay mounted permanently (no re-unmount on scroll away).\n *\n * The `estimatedHeight` prop prevents the zero-height collapse problem: without it\n * every unrendered section stacks at the top with 0px height, causing all observers\n * to fire at once on mount. It applies as a min-height until the children have\n * actually committed — through the Suspense window too, since a custom placeholder\n * may be shorter than the estimate. After that the section's height is owned by its\n * content, so shorter blocks don't leave reserved dead space below them.\n */\nexport const RenderWhenVisible = memo(function RenderWhenVisible({\n children,\n rootMargin = '50px',\n placeholder,\n className,\n id,\n estimatedHeight = '400px',\n renderOnMount = false,\n}: RenderWhenVisibleProps) {\n const ref = useRef<HTMLElement>(null);\n const [visible, setVisible] = useState(renderOnMount);\n const [mounted, setMounted] = useState(false);\n\n useEffect(() => {\n if (renderOnMount || visible) return;\n const el = ref.current;\n if (!el) return;\n\n const observer = new IntersectionObserver(\n ([entry]) => {\n if (entry.isIntersecting) {\n setVisible(true);\n observer.disconnect();\n }\n },\n { rootMargin }\n );\n\n observer.observe(el);\n\n return () => observer.disconnect();\n }, [renderOnMount, visible, rootMargin]);\n\n const fallback = placeholder ?? <DefaultSkeleton height={estimatedHeight} />;\n\n return (\n <section\n ref={!visible ? ref : undefined}\n className={className}\n id={id}\n style={{ minHeight: mounted ? undefined : estimatedHeight }}\n >\n {visible ? (\n <Suspense fallback={fallback}>\n {children}\n <MarkMounted onMount={setMounted} />\n </Suspense>\n ) : (\n fallback\n )}\n </section>\n );\n});\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/api/product.ts"],"names":[],"mappings":";;;;AA4EO,IAAM,OAAA,GAAU;AAAA,EACrB,IAAA,EAAM,OAAO,EAAA,KAAiC;AAC5C,IAAA,MAAM,QAAA,GAAW,YAAY,EAAE,CAAA,wNAAA,CAAA;AAC/B,IAAA,MAAM,EAAE,MAAK,GAAI,MAAM,IAAI,GAAA,CAAI,QAAQ,EAAE,IAAA,EAAwB;AACjE,IAAA,OAAO,IAAA;AAAA,EACT,CAAA;AAAA,EAEA,aAAa,CAAC,EAAA,KAAiC,QAAQ,OAAA,CAAQ,IAAA,CAAK,EAAE,CAAC,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQvE,IAAA,EAAM,OAAO,MAAA,KAA4D;AACvE,IAAA,MAAM,EAAE,MAAA,EAAQ,WAAA,EAAa,IAAA,EAAM,MAAA,EAAQ,UAAU,EAAA,EAAI,IAAA,EAAM,UAAA,EAAY,MAAA,EAAO,GAAI,MAAA;AAGtF,IAAA,MAAM,YAAA,GAAe,IAAI,eAAA,EAAgB;AACzC,IAAA,YAAA,CAAa,GAAA,CAAI,UAAU,MAAM,CAAA;AAEjC,IAAA,IAAI,SAAS,MAAA,EAAW,YAAA,CAAa,IAAI,MAAA,EAAQ,MAAA,CAAO,IAAI,CAAC,CAAA;AAC7D,IAAA,YAAA,CAAa,GAAA,CAAI,UAAA,EAAY,MAAA,CAAO,OAAO,CAAC,CAAA;AAI5C,IAAA,IAAI,gBAAgB,MAAA,EAAW;AAC7B,MAAA,IAAI,WAAW,QAAA,EAAU;AACvB,QAAA,YAAA,CAAa,GAAA,CAA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U,CAAC,UAAA,EAAY,QAAA,EAAU,EAAE,CAAA;AAAA,MACnC,OAAA,EAAS,MAAM,OAAA,CAAQ,IAAA,CAAK,EAAE;AAAA,KAC/B,CAAA;AAAA,IACH,IAAA,EAAM,CAAC,MAAA,KACL,YAAA,CAAa;AAAA;AAAA,MAEX,QAAA,EAAU,CAAC,UAAA,EAAY,MAAA,EAAQ,QAAQ,EAAE,KAAA,EAAO,gBAAA,EAAiB,EAAG,CAAA;AAAA,MACpE,OAAA,EAAS,CAAC,EAAE,MAAA,EAAO,KAAM,OAAA,CAAQ,IAAA,CAAK,EAAE,GAAG,MAAA,EAAQ,MAAA,EAAQ;AAAA,KAC5D;AAAA;AAEP","file":"chunk-6MREJTVB.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api, getActiveScopeId } from './client';\nimport type { Product } from '../types';\nimport type { Pagination, PaginatedResult } from './types';\nimport { orThrow } from '../providers/NavigationProvider';\n\n// ===== Filter Types =====\n\nexport interface FilterValue {\n key?: string;\n count?: number;\n value?: string;\n from?: number | '*';\n to?: number | '*';\n}\n\nexport interface Filter {\n key?: string;\n label?: string;\n type?: string;\n values?: FilterValue[];\n max?: number;\n min?: number;\n}\n\n// ===== Product List Types =====\n\nexport type ProductsListSource =\n | 'brands'\n | 'categories'\n | 'json'\n | 'landing-page'\n | 'latest'\n | 'offers'\n | 'recently'\n | 'related'\n | 'selected'\n | 'tags'\n | 'top-rated'\n | 'wishlist'\n | 'search'\n | 'sales'\n | 'reorder'\n | 'best_selling';\n\nexport interface ProductsListParams {\n /** Source type (wishlist, latest, brands, etc.) */\n source: ProductsListSource;\n /** Source value (brand_id, category_id, tag_id, search keyword, or JSON array of product IDs) */\n sourceValue?: string | number | number[] | null;\n /** Page number for offset-based pagination */\n page?: number;\n /** Cursor for cursor-based pagination (from previous response) */\n cursor?: string | null;\n /** Items per page (default: 15) */\n perPage?: number;\n /** Sort option */\n sort?: string;\n /** Enable filters on the response */\n filterable?: boolean;\n /** Abort signal for cancellation */\n signal?: AbortSignal;\n}\n\nexport type ProductsListResult = PaginatedResult<Product> & {\n filters?: Filter[];\n};\n\nexport interface ProductsListResponse {\n data: Product[];\n cursor?: Pagination;\n filters?: Filter[];\n}\n\n// ===== API Functions =====\n\nexport const product = {\n find: async (id: string): Promise<Product> => {\n const endpoint = `products/${id}/details?with[]=images&with[]=category&with[]=rating&with[]=notify_availability&with[]=tags&with[]=brand&with[]=options&with[]=skus&with[]=skus_availability&with[]=included_products&with[]=bundle&with[]=sold_quantity`;\n const { data } = await api.get(endpoint).json<{ data: Product }>();\n return data;\n },\n\n findOrThrow: (id: string): Promise<Product> => orThrow(product.find(id)),\n\n /**\n * Fetch products list with pagination support\n * Used by native ProductsList component for SSR loaders\n *\n * API pattern: GET /products?source=wishlist&page=1\n */\n list: async (params: ProductsListParams): Promise<ProductsListResult> => {\n const { source, sourceValue, page, cursor, perPage = 16, sort, filterable, signal } = params;\n\n // Build URL with query parameters\n const searchParams = new URLSearchParams();\n searchParams.set('source', source);\n // Only send page when explicitly provided — cursor-based callers omit it entirely\n if (page !== undefined) searchParams.set('page', String(page));\n searchParams.set('per_page', String(perPage));\n\n // Add source_value[] parameter (brand_id, category_id, tag_id, etc.)\n // For search source, use keyword parameter instead\n if (sourceValue !== undefined) {\n if (source === 'search') {\n searchParams.set('keyword', String(sourceValue));\n } else if (Array.isArray(sourceValue)) {\n sourceValue.forEach((val) => searchParams.append('source_value[]', String(val)));\n } else {\n searchParams.append('source_value[]', String(sourceValue));\n }\n }\n\n // Add filterable parameter\n if (filterable !== undefined) {\n searchParams.set('filterable', filterable ? '1' : '0');\n }\n\n // Add sort parameter\n if (sort) {\n searchParams.set('sort', sort);\n }\n\n // Add cursor for cursor-based pagination\n if (cursor) {\n searchParams.set('cursor', cursor);\n }\n\n // Make the request\n const options: Record<string, unknown> = {};\n if (signal) options.signal = signal;\n\n const response = await api\n .get(`products?${searchParams.toString()}`, options as any)\n .json<ProductsListResponse>();\n\n return {\n items: response.data ?? [],\n next: response.cursor?.next ?? null,\n filters: response.filters,\n };\n },\n\n queries: {\n detail: (id: string) =>\n queryOptions({\n queryKey: ['products', 'detail', id],\n queryFn: () => product.find(id),\n }),\n list: (params: Omit<ProductsListParams, 'signal'>) =>\n queryOptions({\n // Scope (branch) varies product availability — key must include it.\n queryKey: ['products', 'list', params, { scope: getActiveScopeId() }],\n queryFn: ({ signal }) => product.list({ ...params, signal }),\n }),\n },\n};\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/api/category.ts"],"names":[],"mappings":";;;;AAKO,IAAM,QAAA,GAAW;AAAA,EACtB,IAAA,EAAM,OAAO,EAAA,KAAkC;AAC7C,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CAAI,IAAI,CAAA,WAAA,EAAc,EAAE,CAAA,CAAE,CAAA,CAAE,IAAA,EAAyB;AAC5E,IAAA,OAAO,IAAA;AAAA,EACT,CAAA;AAAA,EAEA,aAAa,CAAC,EAAA,KAAkC,QAAQ,QAAA,CAAS,IAAA,CAAK,EAAE,CAAC,CAAA;AAAA,EAEzE,MAAM,YAAiC;AACrC,IAAA,MAAM,EAAE,MAAK,GAAI,MAAM,IAAI,GAAA,CAAI,YAAY,EAAE,IAAA,EAA2B;AACxE,IAAA,OAAO,QAAQ,EAAC;AAAA,EAClB,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,MAAA,EAAQ,CAAC,EAAA,KACP,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,YAAA,EAAc,QAAA,EAAU,EAAE,CAAA;AAAA,MACrC,OAAA,EAAS,MAAM,QAAA,CAAS,IAAA,CAAK,EAAE;AAAA,KAChC,CAAA;AAAA,IAEH,IAAA,EAAM,MACJ,YAAA,CAAa;AAAA;AAAA,MAEX,QAAA,EAAU,CAAC,YAAA,EAAc,MAAA,EAAQ,EAAE,KAAA,EAAO,gBAAA,IAAoB,CAAA;AAAA,MAC9D,OAAA,EAAS,MAAM,QAAA,CAAS,IAAA;AAAK,KAC9B;AAAA;AAEP","file":"chunk-AU7PMZV4.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api, getActiveScopeId } from './client';\nimport type { Category } from '../types';\nimport { orThrow } from '../providers/NavigationProvider';\n\nexport const category = {\n find: async (id: string): Promise<Category> => {\n const { data } = await api.get(`categories/${id}`).json<{ data: Category }>();\n return data;\n },\n\n findOrThrow: (id: string): Promise<Category> => orThrow(category.find(id)),\n\n list: async (): Promise<Category[]> => {\n const { data } = await api.get('categories').json<{ data: Category[] }>();\n return data ?? [];\n },\n\n queries: {\n detail: (id: string) =>\n queryOptions({\n queryKey: ['categories', 'detail', id],\n queryFn: () => category.find(id),\n }),\n\n list: () =>\n queryOptions({\n // Scope (branch) varies the API response — key must include it.\n queryKey: ['categories', 'list', { scope: getActiveScopeId() }],\n queryFn: () => category.list(),\n }),\n },\n};\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/api/client.ts"],"names":[],"mappings":";;;;;;AAqBA,IAAM,iBAAA,GAAoB,kBAAA,EAAmB,CAC1C,MAAA,CAAO,MAAqB;AAC3B,EAAA,IAAI;AACF,IAAA,OAAO,SAAA,CAAU,sBAAsB,CAAA,IAAK,IAAA;AAAA,EAC9C,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF,CAAC,CAAA,CACA,OAAO,MAAqB;AAC3B,EAAA,MAAM,UAAA,GACJ,OAAO,QAAA,KAAa,WAAA,GAChB,wBAAwB,QAAA,CAAS,MAAA,EAAQ,sBAAsB,CAAA,GAC/D,IAAA;AACN,EAAA,IAAI,YAAY,OAAO,UAAA;AACvB,EAAA,MAAM,UAAU,OAAO,MAAA,KAAW,WAAA,GAAc,MAAA,CAAO,OAAO,OAAA,GAAU,MAAA;AACxE,EAAA,MAAM,WAAA,GACJ,OAAO,OAAA,EAAS,GAAA,KAAQ,aAAa,OAAA,CAAQ,GAAA,CAAI,sBAAsB,CAAA,GAAI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AAA,CAAY,gBAAgB,CAAA,EAAG;AACtD,UAAA,OAAA,CAAQ,OAAA,CAAQ,GAAA,CAAI,WAAA,CAAY,gBAAA,EAAkB,oBAAoB,CAAA;AAAA,QACxE;AAEA,QAAA,IAAI;AACF,UAAA,MAAM,SAAA,GAAY,kBAAA,EAAmB,CAAE,QAAA,EAAU,OAAO,OAAA,EAAS,EAAA;AACjE,UAAA,IAAI,aAAa,IAAA,EAAM;AACrB,YAAA,OAAA,CAAQ,QAAQ,GAAA,CAAI,WAAA,CAAY,UAAA,EAAY,MAAA,CAAO,SAAS,CAAC,CAAA;AAAA,UAC/D;AAAA,QACF,CAAA,CAAA,MAAQ;AAAA,QAER;AAEA,QAAA,MAAM,KAAA,GAAQ,aAAa,iBAAA,EAAkB;AAC7C,QAAA,IAAI,KAAA,EAAO;AACT,UAAA,OAAA,CAAQ,QAAQ,GAAA,CAAI,WAAA,CAAY,aAAA,EAAe,CAAA,OAAA,EAAU,KAAK,CAAA,CAAE,CAAA;AAAA,QAClE;AAEA,QAAA,MAAM,UAAU,gBAAA,EAAiB;AACjC,QAAA,IAAI,WAAW,IAAA,EAAM;AACnB,UAAA,OAAA,CAAQ,OAAA,CAAQ,GAAA,CAAI,WAAA,CAAY,QAAA,EAAU,OAAO,CAAA;AAAA,QACnD;AAAA,MACF;AAAA;AACF;AAEJ,CAAC;AAEM,IAAM,GAAA,GAAM,GAAG,MAAA,CAAO;AAAA,EAC3B,MAAA,EAAQ,2BAAA;AAAA,EACR,OAAA,EAAS;AACX,CAAC","file":"chunk-EZSYN4P3.js","sourcesContent":["import ky from 'ky';\nimport { createIsomorphicFn } from '@tanstack/react-start';\nimport { getCookie } from '@tanstack/react-start/server';\nimport { getStoreIdentifier } from '../utils/sdk-helpers';\n// import { getInjectedRuntimeEnv, readEnv } from '../utils/runtime-env';\nimport { getTwilightContext } from '../twilight/context';\nimport {\n AUTH_TOKEN_COOKIE_NAME,\n extractScopeIdFromCookies,\n extractTokenFromCookies,\n readSdkScopeId,\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} 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 branch/scope id. On the client it comes from the branch Salla persists\n * in storage (`salla.storage.get('scope').id`); before the SDK hydrates storage it\n * falls back to the `scope` cookie the theme mirrors that selection into\n * (see writeScopeCookie), then to the id twilightMiddleware seeded from the same\n * cookie on the server. Requests vary by `s-scope-id`, so React Query keys must\n * include this to avoid serving another scope'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 getActiveScopeId = (): string | 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 = readSdkScopeId();\n if (fromStorage !== undefined) return fromStorage;\n\n if (typeof document !== 'undefined') {\n const fromCookie = extractScopeIdFromCookies(document.cookie);\n if (fromCookie != null) return fromCookie;\n }\n\n try {\n const { scopeId } = getTwilightContext();\n return scopeId != null ? String(scopeId) : null;\n } catch {\n return null;\n }\n};\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 try {\n const profileId = getTwilightContext().settings?.theme?.profile?.id;\n if (profileId != null) {\n request.headers.set(API_HEADERS.VERSION_ID, String(profileId));\n }\n } catch {\n // settings not loaded yet — skip VERSION_ID header\n }\n\n const token = authToken ?? readFallbackToken();\n if (token) {\n request.headers.set(API_HEADERS.AUTHORIZATION, `Bearer ${token}`);\n }\n\n const scopeId = getActiveScopeId();\n if (scopeId != null) {\n request.headers.set(API_HEADERS.SCOPE_ID, scopeId);\n }\n },\n ],\n },\n});\n\nexport const cdn = ky.extend({\n prefix: 'https://cdn.salla.network',\n timeout: 5000,\n});\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/api/store.ts"],"names":[],"mappings":";;;;;AAQA,IAAM,qBAAA,GAAwB;AAAA,EAC5B,OAAA;AAAA,EACA,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AM,OAAO,IAAA;AAGlB,MAAA,MAAM,SAAA,GAAY,gBAAA,CAAiB,IAAA,CAAK,SAAS,CAAA;AAEjD,MAAA,OAAO;AAAA,QACL,OAAO,IAAA,CAAK,KAAA;AAAA,QACZ,OAAO,IAAA,CAAK,KAAA;AAAA,QACZ,SAAA;AAAA,QACA,YAAY,IAAA,CAAK,UAAA;AAAA,QACjB,mBAAmB,IAAA,CAAK,iBAAA;AAAA,QACxB,SAAS,IAAA,CAAK,OAAA;AAAA,QACd,OAAO,IAAA,CAAK,KAAA;AAAA,QACZ,WAAW,IAAA,CAAK,SAAA;AAAA,QAChB,YAAY,IAAA,CAAK;AAAA,OACnB;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,gBAAA;AAAiB,OACnB;AAAA,MACA,OAAA,EAAS,MAAM,KAAA,CAAM,QAAA,CAAS,eAAe;AAAA,KAC9C;AAAA;AAEP","file":"chunk-QZ6I5CA7.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api, getActiveScopeId, STORE_IDENTIFIER_HEADER } from './client';\nimport type { Store, Theme, Language } from '../types';\nimport { getTwilightContext } from '../twilight/context';\nimport { resolveStoreIdentifier } from '../utils/store-identity';\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];\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}\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}\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 };\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 getActiveScopeId(),\n ],\n queryFn: () => store.settings(storeIdentifier),\n }),\n },\n};\n"]}
@@ -1,14 +0,0 @@
1
- import { lazy } from 'react';
2
-
3
- // src/components/cart/lazy.ts
4
- var LazyCartItem = lazy(() => import('./CartItem-KUNLKUDS.js').then((m) => ({ default: m.CartItem })));
5
- var LazyCartSummary = lazy(
6
- () => import('./CartSummary-34XD6TBJ.js').then((m) => ({ default: m.CartSummary }))
7
- );
8
- var LazySeoCartWidget = lazy(
9
- () => import('./SeoCartWidget-JAGDCGBR.js').then((m) => ({ default: m.SeoCartWidget }))
10
- );
11
-
12
- export { LazyCartItem, LazyCartSummary, LazySeoCartWidget };
13
- //# sourceMappingURL=chunk-W26EE36N.js.map
14
- //# sourceMappingURL=chunk-W26EE36N.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/errors.ts","../src/providers/i18n-factory.ts","../src/twilight/context.ts"],"names":[],"mappings":";;;;;;AAAO,IAAM,aAAA,GAAN,cAA4B,KAAA,CAAM;AAAA,EACvC,YAAY,OAAA,EAAkB;AAC5B,IAAA,KAAA,CAAM,WAAW,qCAAqC,CAAA;AACtD,IAA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IAAA,CAAK,IAAA;AAAA,IACd,CAAA;AAAA,IACA,IAAI,YAAA,GAAe;AACjB,MAAA,OAAO,IAAA,CAAK,YAAA;AAAA,IACd,CAAA;AAAA,IACA,IAAI,YAAA,GAAe;AACjB,MAAA,OAAO,IAAA,CAAK,YAAA;AAAA,IACd,CAAA;AAAA,IACA,IAAI,MAAA,GAAS;AACX,MAAA,OAAO,IAAA,CAAK,MAAA;AAAA,IACd;AAAA,GACF;AACF","file":"chunk-XITF2PHC.js","sourcesContent":["export class SettingsError extends Error {\n constructor(message?: string) {\n super(message ?? 'Store settings could not be loaded.');\n this.name = 'SettingsError';\n }\n}\n","import { createInstance, type i18n as I18nInstance } from 'i18next';\nimport { initReactI18next } from 'react-i18next';\n\nexport type TranslationMessages = Record<string, Record<string, string>>;\n\n/**\n * Creates a new i18next instance for the given locale.\n *\n * @param locale - Active locale code, e.g. `'ar'`\n * @param translations - App translations from the Salla API (store-specific)\n * @param themeTranslations - Bundled theme translations (static defaults)\n */\nexport function createI18nInstance(\n locale: string,\n translations?: TranslationMessages,\n themeTranslations?: TranslationMessages\n): I18nInstance {\n const instance = createInstance();\n const transKey = `${locale}.trans`;\n\n instance.use(initReactI18next).init({\n lng: locale,\n fallbackLng: locale,\n ns: ['app', 'theme'],\n defaultNS: 'app',\n fallbackNS: 'theme',\n resources: {\n [locale]: {\n app: translations?.[transKey] ?? {},\n theme: themeTranslations?.[transKey] ?? {},\n },\n },\n interpolation: { escapeValue: false },\n react: { useSuspense: false },\n keySeparator: '.',\n nsSeparator: false,\n });\n\n return instance;\n}\n\n/**\n * Creates i18n instance for testing\n * @param locale - Locale code (default: 'ar')\n * @param translations - Optional translations\n */\nexport function createTestI18n(locale = 'ar', translations?: TranslationMessages): I18nInstance {\n return createI18nInstance(locale, translations);\n}\n","import type { QueryClient } from '@tanstack/react-query';\nimport type { i18n } from 'i18next';\nimport type { StoreContext } from '../api/store';\nimport type { AppSnippet, AppSettings } from '../api/apps';\nimport { FALLBACK_LOCALE, getLanguageInfo } from '../providers/locale-constants';\nimport type { TranslationMessages } from '../providers/i18n-factory';\nimport { createI18nInstance } from '../providers/i18n-factory';\nimport { SettingsError } from '../utils/errors';\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface TwilightLocation<TSearch = Record<string, unknown>> {\n href: string;\n pathname: string;\n search: TSearch;\n searchStr: string;\n state: Record<string, unknown>;\n hash: string;\n}\n\nexport interface PageContext {\n slug: string;\n id?: string | number;\n title: string;\n url?: string;\n parent?: { id: string | number; name: string; url: string } | null;\n breadcrumbs?: { name: string; url: string }[];\n}\n\nexport interface TwilightContext {\n queryClient: QueryClient;\n settings: StoreContext;\n locale: string;\n routeId: string;\n location: TwilightLocation;\n authToken: string | null;\n scopeId: string | null;\n /**\n * Which store this request is for, when something other than the hostname says\n * so — the `?storeId=` a preview was opened with, or the cookie remembering it.\n *\n * Null on a live storefront, where the hostname is the answer and there is\n * nothing to carry. See {@link resolveRequestStoreId}.\n */\n storeId: string | null;\n /**\n * The host this request arrived on, captured server-side.\n *\n * A theme worker is deployed with no vars and no bindings, so the request is\n * the only thing that knows which storefront it is serving. On the client this\n * is `window.location.host`; on the server nothing else has it.\n */\n requestHost: string | null;\n i18n: i18n;\n dir: 'ltr' | 'rtl';\n page?: PageContext;\n /** Installed apps' snippets, fetched in rootBeforeLoad so AppsSnippets can render CDN\n * <script> tags during SSR (React Query isn't dehydrated here, so useQuery has no SSR data). */\n appsSnippets?: AppSnippet[];\n /** Per-app public `app.*` buckets, fetched in rootBeforeLoad so rootHead can install the\n * `Salla.appScope` factory inline at parse time — ahead of the snippets' onReady callbacks. */\n appsSettings?: AppSettings;\n extras?: Record<string, unknown>;\n}\n\n// ============================================================================\n// Internal Store\n// ============================================================================\n\nconst DEFAULT_LOCATION: TwilightLocation = {\n href: '',\n pathname: '',\n search: {},\n searchStr: '',\n state: {},\n hash: '',\n};\n\ninterface ContextData {\n queryClient: QueryClient;\n settings: StoreContext | null;\n locale: string;\n routeId: string;\n location: TwilightLocation;\n authToken: string | null;\n scopeId: string | null;\n storeId: string | null;\n requestHost: string | null;\n i18n?: i18n;\n page?: PageContext;\n appsSnippets?: AppSnippet[];\n appsSettings?: AppSettings;\n extras?: Record<string, unknown>;\n}\n\nconst DEFAULT_DATA: ContextData = {\n queryClient: null as unknown as QueryClient,\n settings: null,\n locale: FALLBACK_LOCALE,\n routeId: '',\n location: { ...DEFAULT_LOCATION },\n authToken: null,\n scopeId: null,\n storeId: null,\n requestHost: null,\n i18n: undefined,\n page: undefined,\n};\n\n// ============================================================================\n// Storage: AsyncLocalStorage (server) or module-level store (client)\n// ============================================================================\n\ntype AsyncLocalStore<T> = { getStore(): T | undefined; run(val: T, fn: () => unknown): unknown };\n\n// Initialize ALS at module load time for SSR — no race condition\nlet _als: AsyncLocalStore<ContextData> | null = null;\nif (typeof window === 'undefined') {\n try {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const { AsyncLocalStorage } = require('node:async_hooks') as {\n AsyncLocalStorage: new <T>() => AsyncLocalStore<T>;\n };\n _als = new AsyncLocalStorage<ContextData>();\n } catch {\n _als = null;\n }\n}\n\nconst clientStore: ContextData = { ...DEFAULT_DATA };\n\nfunction getTwilightStore(): ContextData {\n if (_als) {\n const store = _als.getStore();\n if (!store)\n throw new Error('[Twilight] No request context. Wrap with runWithTwilightContext().');\n return store;\n }\n return clientStore;\n}\n\nfunction writableStore(): ContextData {\n if (_als) {\n const store = _als.getStore();\n if (store) return store;\n }\n return clientStore;\n}\n\nfunction mergeIntoStore(store: ContextData, partial: Partial<TwilightContext>): void {\n if ('queryClient' in partial && partial.queryClient) store.queryClient = partial.queryClient;\n if ('settings' in partial && partial.settings != null) store.settings = partial.settings;\n if ('locale' in partial && partial.locale != null) store.locale = partial.locale;\n if ('routeId' in partial && partial.routeId != null) store.routeId = partial.routeId;\n if ('location' in partial && partial.location != null)\n store.location = { ...store.location, ...partial.location };\n if ('authToken' in partial && partial.authToken !== undefined)\n store.authToken = partial.authToken ?? null;\n if ('scopeId' in partial && partial.scopeId !== undefined)\n store.scopeId = partial.scopeId ?? null;\n if ('storeId' in partial && partial.storeId !== undefined)\n store.storeId = partial.storeId ?? null;\n if ('requestHost' in partial && partial.requestHost !== undefined)\n store.requestHost = partial.requestHost ?? null;\n if ('i18n' in partial && partial.i18n != null) store.i18n = partial.i18n;\n if ('page' in partial) store.page = partial.page;\n if ('appsSnippets' in partial) store.appsSnippets = partial.appsSnippets;\n if ('appsSettings' in partial) store.appsSettings = partial.appsSettings;\n if ('extras' in partial) store.extras = partial.extras;\n}\n\n// ============================================================================\n// Public API\n// ============================================================================\n\nexport function runWithTwilightContext<T>(partial: Partial<TwilightContext>, fn: () => T): T {\n if (_als) {\n const data: ContextData = { ...DEFAULT_DATA };\n mergeIntoStore(data, partial);\n return _als.run(data, fn) as T;\n }\n mergeIntoStore(clientStore, partial);\n return fn();\n}\n\n// Client-only subscription so React consumers (useRouteId/useIsHome/…) re-render\n// when navigation mutates the module store. Mirrors hooks/useWishlist.ts.\nconst listeners = new Set<() => void>();\n\nexport function subscribeTwilight(listener: () => void): () => void {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n}\n\nexport function updateTwilightContext(partial: Partial<TwilightContext>): void {\n mergeIntoStore(getTwilightStore(), partial);\n // Server uses AsyncLocalStorage and has no React subscribers; notify on client only.\n if (typeof window !== 'undefined') {\n for (const listener of listeners) listener();\n }\n}\n\n/**\n * Whether store settings are available, without throwing.\n *\n * `getTwilightContext().settings` throws a `SettingsError` when the store is\n * empty, which is fatal inside a head function during hydration. Callers that\n * need to *test* availability must use this instead of a try/catch around the\n * getter. Returns false when there is no request context at all (server-side\n * calls outside `runWithTwilightContext`).\n */\nexport function hasTwilightSettings(): boolean {\n try {\n return getTwilightStore().settings != null;\n } catch {\n return false;\n }\n}\n\n/**\n * The store this request names and the host it arrived on, without throwing.\n *\n * Separate from {@link getTwilightContext} because store identity is read while\n * deciding *what to fetch* — before there is a context worth having — and on the\n * server outside a request the getter throws. A caller asking \"which store?\" has\n * a sane answer for \"none named\"; it has none for an exception.\n */\nexport function getRequestStore(): { storeId: string | null; requestHost: string | null } {\n try {\n const data = getTwilightStore();\n return { storeId: data.storeId, requestHost: data.requestHost };\n } catch {\n return { storeId: null, requestHost: null };\n }\n}\n\nexport function getTwilightContext(): TwilightContext {\n const data = getTwilightStore();\n return {\n get queryClient() {\n return data.queryClient;\n },\n get settings() {\n if (!data.settings) throw new SettingsError();\n return data.settings;\n },\n get locale() {\n return data.locale;\n },\n get routeId() {\n return data.routeId;\n },\n get location() {\n return data.location;\n },\n get authToken() {\n return data.authToken;\n },\n get scopeId() {\n return data.scopeId;\n },\n get storeId() {\n return data.storeId;\n },\n get requestHost() {\n return data.requestHost;\n },\n get i18n() {\n if (!data.i18n) {\n const translations = data.queryClient?.getQueryData(['translations']) as\n TranslationMessages | undefined;\n data.i18n = createI18nInstance(data.locale, translations);\n }\n return data.i18n;\n },\n get dir() {\n return getLanguageInfo(data.locale).dir;\n },\n get page() {\n return data.page;\n },\n get appsSnippets() {\n return data.appsSnippets;\n },\n get appsSettings() {\n return data.appsSettings;\n },\n get extras() {\n return data.extras;\n },\n };\n}\n\n/** @internal Reset store for testing */\nexport function resetForTesting(): void {\n Object.assign(writableStore(), { ...DEFAULT_DATA });\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/cookies.ts","../src/utils/inline-script.ts","../src/utils/runtime-env.ts","../src/utils/store-identity.ts","../src/utils/sdk-helpers.ts"],"names":[],"mappings":";;;AAAO,IAAM,sBAAA,GAAyB;AAC/B,IAAM,iBAAA,GAAoB,OAAA;AAoB1B,IAAM,oBAAA,GAAuB,WAAA;AAG7B,IAAM,cAAA,GAAiB,SAAA;AAUvB,SAAS,aAAa,GAAA,EAA+C;AAC1E,EAAA,IAAI,CAAC,KAAK,OAAO,IAAA;AACjB,EAAA,OAAO,oBAAA,CAAqB,IAAA,CAAK,GAAG,CAAA,GAAI,GAAA,GAAM,IAAA;AA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,QAAA;AAErB,EAAA,IAAI,mBAAA,CAAoB,WAAW,CAAA,EAAG,OAAO,WAAA;AAI7C,EAAA,MAAM,cAAc,OAAO,MAAA,KAAW,WAAA,GAAc,MAAA,CAAO,SAAS,IAAA,GAAO,IAAA;AAC3E,EAAA,IAAI,mBAAA,CAAoB,WAAW,CAAA,EAAG,OAAO,WAAA;AAE7C,EAAA,OAAO,OAAA,CAAQ,mBAAmB,CAAA,IAAK,OAAA,CAAQ,cAAc,CAAA,IAAK,EAAA;AACpE;;;AC/DA,IAAM,SAAA,GAAY,OAAO,MAAA,KAAW,WAAA;AAc7B,SAAS,mBAAmB,QAAA,EAA2B;AAC5D,EAAA,OAAO,uBAAuB,QAAQ,CAAA;AACxC;AAKO,SAAS,WAAA,GAA+C;AAC7D,EAAA,IAAI,CAAC,WAAW,OAAO,MAAA;AACvB,EAAA,OAAO,MAAA,CAAO,KAAA;AAChB;AAoBO,SAAS,cAAc,MAAA,EAAsB;AAClD,EAAA,MAAM,MAAM,WAAA,EAAY;AACxB,EAAA,IAAI,CAAC,GAAA,IAAO,CAAC,MAAA,EAAQ;AACrB,EAAA,IAAI;AACF,IAAA,GAAA,CAAI,IAAA,EAAM,YAAY,MAAM,CAAA;AAC5B,IAAA,GAAA,CAAI,GAAA,EAAK,SAAA,GAAY,iBAAA,EAAmB,MAAM,CAAA;AAG9C,IAAA,GAAA,CAAI,MAAA,EAAQ,GAAA,GAAM,oBAAA,EAAsB,MAAM,CAAA;AAAA,EAChD,CAAA,CAAA,MAAQ;AAAA,EAER;AACF","file":"chunk-YZUNEFDM.js","sourcesContent":["export const AUTH_TOKEN_COOKIE_NAME = 'token';\nexport const SCOPE_COOKIE_NAME = 'scope';\n\n/**\n * Which store this request is for, when the hostname does not say.\n *\n * A live storefront is reached at its own domain, so the hostname identifies it\n * and nothing else is needed. A preview is not: every theme under review is\n * served from the one preview hostname, so the store has to be named some other\n * way — the dispatcher takes it from `?storeId=` and puts it here, the same way\n * it remembers which theme to serve.\n *\n * Written by the dispatcher rather than the theme, and set on the *forwarded\n * request* as well as the response, because the response cookie only arrives in\n * time for the second page load and the first one has to render too.\n *\n * The literal is a contract with `STORE_COOKIE` in store-front-dispacher\n * (`src/dispatch/preview.ts`), and **nothing checks the two agree**. Drift does\n * not fail loudly — it renders somebody else's shop. Grep both repos before\n * changing it.\n */\nexport const STORE_ID_COOKIE_NAME = 'salla_sid';\n\n/** Query parameter naming the store, on a host that serves more than one. */\nexport const STORE_ID_PARAM = 'storeId';\n\n/**\n * A store id is an integer, and anything else is not a store id.\n *\n * Validated rather than passed through because this value ends up in an upstream\n * API path. Leading zeroes, signs, decimals and whitespace are all rejected: the\n * point is a single canonical form, not the widest set of things that could be\n * coerced into a number.\n */\nexport function parseStoreId(raw: string | null | undefined): string | null {\n if (!raw) return null;\n return /^[1-9][0-9]{0,18}$/.test(raw) ? raw : null;\n}\n\n/** The store id the dispatcher left in the cookie, or null when absent or malformed. */\nexport function extractStoreIdFromCookies(cookieHeader: string | null): string | null {\n return parseStoreId(extractTokenFromCookies(cookieHeader, STORE_ID_COOKIE_NAME));\n}\n\n/**\n * The only hosts on which a request may name its own store.\n *\n * **This is a security boundary, not a convenience.** On a merchant's own domain\n * the hostname *is* the store, and it is the only thing that may decide. A theme\n * that also honoured `?storeId=` there would let anyone open\n * `https://reefperfumes.com/?storeId=<someone else>` and be served a different\n * merchant's shop from the domain its owner controls — their branding, their\n * customers' address bar, somebody else's catalogue — and the cookie would keep\n * serving it for the rest of that browser's session. Salla points SaaS domains\n * at this dispatcher, so those hostnames are real and reachable.\n *\n * The override exists for one situation: a host that serves many stores and so\n * cannot identify one from its name. That is the preview host, where every theme\n * under review answers on the same address, and local development.\n *\n * Adding an entry grants that host the ability to render any store on request.\n * Add nothing that a merchant's traffic reaches.\n */\nexport const STORE_ID_HOSTS: readonly string[] = ['preview.salla.design'];\n\n/** The hostname alone — a port never distinguishes one host's authority from another's. */\nfunction hostnameOf(host: string): string {\n const trimmed = host.trim().toLowerCase();\n // IPv6 literals are bracketed, and the colons inside them are not a port.\n if (trimmed.startsWith('[')) return trimmed.slice(0, trimmed.indexOf(']') + 1) || trimmed;\n const colon = trimmed.indexOf(':');\n return colon === -1 ? trimmed : trimmed.slice(0, colon);\n}\n\nfunction isLoopback(hostname: string): boolean {\n return (\n hostname === 'localhost' ||\n hostname === '127.0.0.1' ||\n hostname === '[::1]' ||\n hostname.endsWith('.localhost')\n );\n}\n\n/**\n * Whether this host is allowed to let the request choose a store.\n *\n * Deliberately an allowlist of exact hostnames plus loopback. No suffix matching:\n * a rule like \"anything ending in salla.design\" is one wildcard DNS record away\n * from admitting a host nobody meant to admit, and the list of hosts that serve\n * more than one store is short and known.\n */\nexport function allowsRequestStoreId(host: string | null | undefined): boolean {\n if (!host) return false;\n const hostname = hostnameOf(host);\n return STORE_ID_HOSTS.includes(hostname) || isLoopback(hostname);\n}\n\n/**\n * Whether this host *is* a store, so its name can be used as the identifier.\n *\n * The exact inverse of {@link allowsRequestStoreId}, and deliberately written as\n * one so the two can never disagree: a host that may name its store is a host\n * that serves more than one, and a host that serves more than one cannot be the\n * answer to \"which store is this?\". `preview.salla.design` and `localhost:5188`\n * are not shops; asking the API about them earns a 422 and a page that reads as\n * a broken theme.\n */\nexport function hostIdentifiesStore(host: string | null | undefined): boolean {\n return Boolean(host) && !allowsRequestStoreId(host);\n}\n\n/**\n * The store this request names, on a host permitted to name one.\n *\n * The host check is inside this function rather than at its call site, because a\n * call site is a thing someone can add without reading this comment. There is no\n * way to ask \"what store did the request name?\" without also asking \"is this a\n * host that may say?\" — get it wrong and the answer is a security bug that looks\n * like a feature.\n *\n * Between the two permitted sources the URL wins, the same precedence the\n * dispatcher uses for the theme and for the same reason: a link is how someone\n * switches, and a cookie they cannot see should never beat the address they\n * just typed.\n */\nexport function resolveRequestStoreId(\n url: string,\n cookieHeader: string | null,\n host: string | null | undefined\n): string | null {\n if (!allowsRequestStoreId(host)) return null;\n\n let fromQuery: string | null = null;\n try {\n fromQuery = parseStoreId(new URL(url).searchParams.get(STORE_ID_PARAM));\n } catch {\n /* a relative or malformed URL simply names no store */\n }\n return fromQuery ?? extractStoreIdFromCookies(cookieHeader);\n}\n\n/**\n * Deletes the auth `token` cookie. This cookie is written client-side by the theme\n * (TwilightProvider), not by the SDK — `salla.cookie.clearAll()` only clears its own\n * allowlist and leaves `token` behind — so logout must clear it here. Client-only.\n */\nexport function clearAuthTokenCookie(): void {\n if (typeof document === 'undefined') return;\n document.cookie = `${AUTH_TOKEN_COOKIE_NAME}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;\n}\n\nexport function extractTokenFromCookies(\n cookieHeader: string | null,\n cookieName: string\n): string | null {\n if (!cookieHeader) return null;\n\n const prefix = `${cookieName}=`;\n let start = 0;\n\n while (start < cookieHeader.length) {\n const idx = cookieHeader.indexOf(prefix, start);\n if (idx === -1) return null;\n\n const prevChar = idx > 0 ? cookieHeader[idx - 1] : '';\n if (prevChar === '' || prevChar === ';' || prevChar === ' ') {\n let end = cookieHeader.indexOf(';', idx);\n if (end === -1) end = cookieHeader.length;\n\n const value = cookieHeader.slice(idx + prefix.length, end).trim();\n try {\n return decodeURIComponent(value) || null;\n } catch {\n return value || null;\n }\n }\n\n start = idx + prefix.length;\n }\n\n return null;\n}\n\n/**\n * Reads the active scope id from the `scope` cookie, which Salla persists as a\n * JSON object (e.g. `{\"id\":123,\"type\":\"branch\"}`). Returns null when the cookie\n * is missing or unparseable. Used server-side, where `salla.storage` is absent.\n */\nexport function extractScopeIdFromCookies(cookieHeader: string | null): string | null {\n const raw = extractTokenFromCookies(cookieHeader, SCOPE_COOKIE_NAME);\n if (!raw) return null;\n try {\n const scope = JSON.parse(raw) as { id?: number | string | null };\n return scope?.id != null ? String(scope.id) : null;\n } catch {\n return null;\n }\n}\n\n/**\n * The branch the Salla SDK persisted in its storage (`salla.storage.get('scope')`),\n * which it stores either as `{ id, type }` or as a bare id.\n *\n * Returns `undefined` when the SDK storage API isn't ready yet — deliberately\n * distinct from `null` (\"no branch selected\"), so callers can't mistake a\n * not-yet-hydrated SDK for a cleared selection. Client-only.\n */\nexport function readSdkScopeId(): string | null | undefined {\n const storage = typeof window !== 'undefined' ? window.salla?.storage : undefined;\n if (typeof storage?.get !== 'function') return undefined;\n\n const scope = storage.get(SCOPE_COOKIE_NAME) as\n { id?: number | string | null } | number | string | null;\n const id = typeof scope === 'object' && scope !== null ? scope.id : scope;\n return id != null ? String(id) : null;\n}\n\n/** One year — the SDK keeps the selected branch in localStorage indefinitely. */\nconst SCOPE_COOKIE_MAX_AGE = 60 * 60 * 24 * 365;\n\n/**\n * Mirrors the branch the Salla SDK selected into the `scope` cookie so the SERVER\n * can see it. The SDK persists the selection in localStorage ONLY and writes no\n * cookie, so without this the server computes scope=null for every visitor who\n * picked a branch while the client computes the branch id — the dehydrated settings\n * query key never matches and the client refetches store settings on every page\n * load (SAL-122).\n *\n * Written in the SDK's own JSON shape so {@link extractScopeIdFromCookies} parses it.\n * Returns true when the cookie was (re)written. Client-only; no-op on the server.\n */\nexport function writeScopeCookie(scopeId: string | null): boolean {\n if (typeof document === 'undefined') return false;\n if (extractScopeIdFromCookies(document.cookie) === scopeId) return false;\n\n if (scopeId == null) {\n document.cookie = `${SCOPE_COOKIE_NAME}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;\n return true;\n }\n\n const value = encodeURIComponent(JSON.stringify({ id: scopeId }));\n document.cookie = `${SCOPE_COOKIE_NAME}=${value}; path=/; max-age=${SCOPE_COOKIE_MAX_AGE}; samesite=lax`;\n return true;\n}\n\n/**\n * Keeps the `scope` cookie in step with the SDK's selected branch. Call on every\n * client navigation; it no-ops while the SDK storage API is still hydrating so a\n * late-loading SDK can't wipe a valid cookie.\n */\nexport function syncScopeCookie(): boolean {\n const scopeId = readSdkScopeId();\n return scopeId === undefined ? false : writeScopeCookie(scopeId);\n}\n","/**\n * Escape a JSON-stringified value for safe embedding inside an inline `<script>` body.\n *\n * The head injects script bodies raw, so a `</script>` inside partner-set data would break out\n * of the tag; U+2028/U+2029 are line terminators in JS but not in JSON, so they must go too.\n */\nexport function escapeForInlineScript(value: string): string {\n return value\n .replace(/</g, '\\\\u003c')\n .replace(/>/g, '\\\\u003e')\n .replace(/&/g, '\\\\u0026')\n .replace(/\\u2028/g, '\\\\u2028')\n .replace(/\\u2029/g, '\\\\u2029');\n}\n","import { escapeForInlineScript } from './inline-script';\nimport { getRequestStore } from '../twilight/context';\nimport { hostIdentifiesStore } from './cookies';\n\n/** Where `rootHead` publishes the SSR-resolved env for the browser bundle to read. */\nconst RUNTIME_ENV_KEY = '__SALLA_RUNTIME_ENV__';\n\n/** The env values that must agree between the SSR render and the hydrated client. */\nexport interface RuntimeEnv {\n /** Store API base — `VITE_API_URL`. */\n apiBase?: string;\n /** Store identifier — `VITE_STORE_DOMAIN`. */\n storeIdentifier?: string;\n}\n\n/**\n * A build-time `import.meta.env` var, falling back to the worker's runtime `process.env`\n * (wrangler `vars`, exposed via the `nodejs_compat_populate_process_env` flag).\n */\nexport function readEnv(key: string): string | undefined {\n try {\n const vite = (import.meta as unknown as { env?: Record<string, string | undefined> }).env?.[\n key\n ];\n if (vite) return vite;\n } catch {\n /* import.meta.env not available in all environments */\n }\n return typeof process !== 'undefined' ? process.env?.[key] : undefined;\n}\n\n/**\n * What this runtime resolves from its own env — server-side that includes the worker vars.\n * Prefers what the server already published, so re-rendering the head during hydration yields\n * the same script instead of dropping it.\n */\nexport function resolveRuntimeEnv(): RuntimeEnv {\n const injected = getInjectedRuntimeEnv();\n const { storeId, requestHost } = getRequestStore();\n return {\n apiBase: injected.apiBase || readEnv('VITE_API_URL'),\n // The request outranks the build-time var here for the same reason it does\n // in `resolveStoreIdentifier`, and this is the copy that reaches the\n // browser: publish the store SSR actually rendered, or hydration resolves\n // again from a URL whose `?storeId=` the dispatcher has already stripped and\n // queries a different store than the markup it is hydrating.\n storeIdentifier:\n injected.storeIdentifier ||\n storeId ||\n (hostIdentifiesStore(requestHost) ? requestHost : null) ||\n readEnv('VITE_STORE_DOMAIN'),\n };\n}\n\n/**\n * The env the SSR worker resolved, as handed to the browser by `rootHead`. Empty on the server\n * and on a client whose head carried nothing.\n *\n * Worker `vars` are *runtime* env: they live in `process.env` on the server only, while\n * `import.meta.env` is substituted at build time. A bundle built without those vars therefore\n * sees `undefined` in the browser and silently falls back to the production defaults — SSR\n * would render off the configured backend while every post-hydration fetch hits another one.\n */\nexport function getInjectedRuntimeEnv(): RuntimeEnv {\n const holder = globalThis as typeof globalThis & { [RUNTIME_ENV_KEY]?: RuntimeEnv };\n return holder[RUNTIME_ENV_KEY] ?? {};\n}\n\n/**\n * Inline head `<script>` body publishing the server-resolved env, or null when there is nothing\n * to publish (no overrides configured — the defaults already agree on both sides).\n */\nexport function renderRuntimeEnvScript(env: RuntimeEnv = resolveRuntimeEnv()): string | null {\n const set = Object.entries(env).filter(([, value]) => Boolean(value));\n if (!set.length) return null;\n const json = escapeForInlineScript(JSON.stringify(Object.fromEntries(set)));\n return `window.${RUNTIME_ENV_KEY}=${json};`;\n}\n","/**\n * @fileoverview Which store to ask about — the one answer, in one place.\n *\n * This lived in two places once. `api/store.ts` learned to read the store a\n * request names, and `utils/sdk-helpers.ts` — the copy `api/client.ts` actually\n * sets the `store-identifier` header from — did not. So the resolver that had\n * been taught the answer was consulted for a null check and thrown away, every\n * outgoing request carried an empty identifier, the API answered\n * `422 Store Identifier not found`, and every published theme rendered\n * \"Store Unavailable\" while its tests passed: the client's suite mocked the\n * resolver, and the resolver's suite never went near a request.\n *\n * Hence one module, imported by both. If a third place ever needs a store\n * identifier, it imports this — a second implementation is the bug, not a\n * refactor away from it.\n *\n * See `docs/store-identity.md` for the full picture, including the security\n * boundary on who may name a store.\n */\nimport { getRequestStore } from '../twilight/context';\nimport { hostIdentifiesStore } from './cookies';\nimport { getInjectedRuntimeEnv, readEnv } from './runtime-env';\n\n/**\n * Which store to ask about, in the order the answers can be trusted.\n *\n * A deployed theme worker is published with **no vars and no bindings** — the\n * script metadata carries `main_module`, compatibility settings, assets and tags\n * and nothing else — so `VITE_STORE_DOMAIN` exists only where a build baked it\n * in, which is local development. In production this function used to reach the\n * end of that chain and return the empty string, `store.settings` refused to\n * call with no identifier, and the root loader threw \"Store Unavailable\" — a\n * theme that renders its own failure page for every visitor of every store.\n *\n * The order:\n *\n * 1. what the caller passed, which is always deliberate;\n * 2. the store this request names — the `?storeId=` a preview was opened with,\n * then the cookie remembering it — seeded by `twilightMiddleware`, and only\n * on a host permitted to name one;\n * 3. what SSR already resolved and published, so the hydrated client asks about\n * the same store the server rendered instead of resolving again from a URL\n * that no longer names it;\n * 4. the request's own host, which *is* the identity of a live storefront —\n * but only when that host is a storefront. `preview.salla.design` and\n * `localhost` serve many stores, so their names identify none;\n * 5. `VITE_STORE_DOMAIN`, last, because a build-time constant is a development\n * convenience and must never outrank what the request actually said.\n */\nexport function resolveStoreIdentifier(explicit?: string): string {\n if (explicit) return explicit;\n\n const { storeId, requestHost } = getRequestStore();\n if (storeId) return storeId;\n\n const injected = getInjectedRuntimeEnv().storeIdentifier;\n if (injected) return injected;\n\n if (hostIdentifiesStore(requestHost)) return requestHost as string;\n\n // The browser's own address, for a client render that reached neither of the\n // above — a live storefront, where the host is the store.\n const browserHost = typeof window !== 'undefined' ? window.location.host : null;\n if (hostIdentifiesStore(browserHost)) return browserHost as string;\n\n return readEnv('VITE_STORE_DOMAIN') || readEnv('STORE_DOMAIN') || '';\n}\n","export type { StoreContext } from '../api/store';\nimport { resolveStoreIdentifier } from './store-identity';\n\nconst isBrowser = typeof window !== 'undefined';\n\n/**\n * Which store to ask the API about — see {@link resolveStoreIdentifier}.\n *\n * A delegation, not a second implementation. This name is the one on the wire\n * (`api/client.ts` sets the `store-identifier` header from it) and the one\n * themes import from `@salla.sa/twilight-theme-engine/utils`, so it stays; what\n * it must never do again is answer differently from the resolver everything\n * else asks. It had its own copy of the order once, missing the store the\n * request names and preferring the build-time `VITE_STORE_DOMAIN` that a\n * deployed worker does not have — so every published theme sent an empty\n * identifier and rendered \"Store Unavailable\".\n */\nexport function getStoreIdentifier(explicit?: string): string {\n return resolveStoreIdentifier(explicit);\n}\n\n/**\n * Get Salla SDK instance if available\n */\nexport function getSallaSDK(): typeof window.salla | undefined {\n if (!isBrowser) return undefined;\n return window.salla;\n}\n\n/**\n * Push the active route locale onto the Salla SDK.\n *\n * Why this is needed (and why it must run on every navigation):\n * - The SDK seeds its locale from `navigator.language` — the theme sets no `s-lang`\n * cookie or `window.locale` — so an English browser starts the SDK in `en` even on\n * an `/ar` store.\n * - The SDK fixes its axios `accept-language` header ONCE, at init. `salla.lang.setLocale`\n * only swaps UI translations (it never touches the header), and `salla.init()` is a\n * no-op after `Salla.status === 'ready'`, so the header never refreshes on its own.\n * - `profile::info.fetched` (login / profile refresh on navigation) overrides the header\n * to the *account's* language.\n *\n * Net result without this: `salla.api.*` calls (cart/product details) return data in the\n * wrong locale — e.g. English cart item names on `/ar/cart` — intermittently, depending on\n * load order and whether a profile fetch ran. Re-asserting the URL locale here keeps the\n * header correct. No-op on the server and until the SDK exposes the methods.\n */\nexport function syncSdkLocale(locale: string): void {\n const sdk = getSallaSDK();\n if (!sdk || !locale) return;\n try {\n sdk.lang?.setLocale?.(locale);\n sdk.api?.setHeader?.('accept-language', locale);\n // The localization modal swaps `/${user.language_code}/` in the URL on submit;\n // the SDK never sets this locally, so without it the switch reloads the same page.\n sdk.config?.set?.('user.language_code', locale);\n } catch {\n // SDK partially loaded — the header is re-asserted on the next navigation.\n }\n}\n"]}
@@ -1,23 +0,0 @@
1
- export { RouteDocumentSync, TanStackDocumentSync, tanstackDocumentAdapter, useTanstackDocumentAttrs } from './chunk-XVCBMEBY.js';
2
- import './chunk-Z4Y55HWX.js';
3
- import './chunk-D2UOBR4H.js';
4
- import './chunk-MQ4UTXPR.js';
5
- import './chunk-B3EFOE57.js';
6
- import './chunk-QZ6I5CA7.js';
7
- import './chunk-NR2XM4KT.js';
8
- import './chunk-TZ3E5BN4.js';
9
- import './chunk-3MEAEE7K.js';
10
- import './chunk-3Z7TBM7W.js';
11
- import './chunk-MAQPYTER.js';
12
- import './chunk-MTONGOJD.js';
13
- import './chunk-EZSYN4P3.js';
14
- import './chunk-YZUNEFDM.js';
15
- import './chunk-XITF2PHC.js';
16
- import './chunk-JWXJPJBO.js';
17
- import './chunk-CW625T2E.js';
18
- import './chunk-TYNZ5B2B.js';
19
- import './chunk-T72DAX7R.js';
20
- import './chunk-DF6FBKDN.js';
21
- import './chunk-DGUM43GV.js';
22
- //# sourceMappingURL=document-class-4VSG3RUT.js.map
23
- //# sourceMappingURL=document-class-4VSG3RUT.js.map