@wix/himalaya-cli 0.1944.0 → 0.1946.0

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 (371) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/ecom/src/extensions.d.ts +27 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/motion.mjs +1 -0
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-ecom.mjs +16 -0
  4. package/dist/browser-plane/assets.json +5 -5
  5. package/dist/browser-plane/preview-deferred/{e113c7cdcf8f56ad861b2564505fab2a1975c7a995f92d2f999f9c4ce1a09a40.bin → 9521361aa5be10b9a96b96c0ea2f7e157e728874b20de5200879cbd735eefb38.bin} +1 -1
  6. package/dist/browser-plane/sw.js +9 -9
  7. package/dist/cli.mjs +1548 -912
  8. package/dist/preview-assets.generated.bin +0 -0
  9. package/fixtures/wix-canned.json +6 -0
  10. package/guides/himi-json-output.md +15 -6
  11. package/guides/one-app-section-mappings.md +2 -2
  12. package/guides/one-app-to-himi-app.md +13 -4
  13. package/guides/release-notes.md +8 -0
  14. package/guides/sdk-reference.json +55 -0
  15. package/package.json +2 -2
  16. package/templates/bare-fashion/dev/index.ts +3 -1
  17. package/templates/bare-fashion/tier5-src/_shared/bare-fashion-product-card.ts +5 -4
  18. package/templates/bare-fashion/tier5-src/_shared/collection-service.ts +35 -15
  19. package/templates/bare-fashion/tier5-src/_shared/engine-intl.ts +65 -0
  20. package/templates/bare-fashion/tier5-src/_shared/himi-store-saved.ts +275 -13
  21. package/templates/bare-fashion/tier5-src/himi-bare-fashion-cart/index.ts +19 -12
  22. package/templates/bare-fashion/tier5-src/himi-bare-fashion-collection/index.ts +9 -4
  23. package/templates/bare-fashion/tier5-src/himi-bare-fashion-home/index.ts +10 -4
  24. package/templates/bare-fashion/tier5-src/himi-bare-fashion-product/index.ts +17 -8
  25. package/templates/bare-fashion/tier5-src/himi-bare-fashion-products/index.ts +8 -4
  26. package/templates/bare-fashion/tier5-src/himi-bare-fashion-saved/index.ts +31 -12
  27. package/templates/bare-fashion/tier5-src/himi-bare-fashion-search/index.ts +8 -4
  28. package/templates/beauty-salon/dev/index.ts +1 -0
  29. package/templates/beauty-salon/tier5-src/_shared/collection-service.ts +35 -15
  30. package/templates/beauty-salon/tier5-src/_shared/engine-intl.ts +65 -0
  31. package/templates/beauty-salon/tier5-src/_shared/himi-store-facets.ts +4 -4
  32. package/templates/beauty-salon/tier5-src/_shared/himi-store-saved.ts +275 -13
  33. package/templates/beauty-salon/tier5-src/_shared/weekly-goal.ts +28 -12
  34. package/templates/beauty-salon/tier5-src/himi-booking-bookings/index.ts +7 -2
  35. package/templates/beauty-salon/tier5-src/himi-branded-lite-cart/index.ts +13 -7
  36. package/templates/beauty-salon/tier5-src/himi-branded-lite-category/index.ts +6 -1
  37. package/templates/beauty-salon/tier5-src/himi-branded-lite-home/index.ts +14 -13
  38. package/templates/beauty-salon/tier5-src/himi-branded-lite-shop/index.ts +9 -3
  39. package/templates/beauty-salon/tier5-src/himi-store-product/index.ts +7 -5
  40. package/templates/beauty-salon/tier5-src/himi-store-saved/index.ts +31 -12
  41. package/templates/beauty-salon-owner/tier5-src/_shared/collection-service.ts +35 -15
  42. package/templates/beauty-salon-owner/tier5-src/_shared/engine-intl.ts +65 -0
  43. package/templates/branded-lite/dev/index.ts +4 -2
  44. package/templates/branded-lite/l10n/ar.json +5 -5
  45. package/templates/branded-lite/l10n/cs.json +5 -5
  46. package/templates/branded-lite/l10n/da.json +5 -5
  47. package/templates/branded-lite/l10n/de.json +5 -5
  48. package/templates/branded-lite/l10n/el.json +5 -5
  49. package/templates/branded-lite/l10n/es.json +5 -5
  50. package/templates/branded-lite/l10n/fi.json +5 -5
  51. package/templates/branded-lite/l10n/fr.json +5 -5
  52. package/templates/branded-lite/l10n/he.json +4 -4
  53. package/templates/branded-lite/l10n/hu.json +5 -5
  54. package/templates/branded-lite/l10n/id.json +5 -5
  55. package/templates/branded-lite/l10n/it.json +5 -5
  56. package/templates/branded-lite/l10n/ja.json +5 -5
  57. package/templates/branded-lite/l10n/ko.json +5 -5
  58. package/templates/branded-lite/l10n/lt.json +5 -5
  59. package/templates/branded-lite/l10n/nl.json +5 -5
  60. package/templates/branded-lite/l10n/no.json +5 -5
  61. package/templates/branded-lite/l10n/pl.json +5 -5
  62. package/templates/branded-lite/l10n/pt.json +5 -5
  63. package/templates/branded-lite/l10n/ru.json +5 -5
  64. package/templates/branded-lite/l10n/sv.json +5 -5
  65. package/templates/branded-lite/l10n/th.json +5 -5
  66. package/templates/branded-lite/l10n/tr.json +5 -5
  67. package/templates/branded-lite/l10n/uk.json +5 -5
  68. package/templates/branded-lite/l10n/vi.json +5 -5
  69. package/templates/branded-lite/l10n/zh.json +5 -5
  70. package/templates/branded-lite/recipes/wishlist-grid.json +1 -1
  71. package/templates/branded-lite/tier5-src/_shared/collection-service.ts +42 -19
  72. package/templates/branded-lite/tier5-src/_shared/engine-intl.ts +65 -0
  73. package/templates/branded-lite/tier5-src/_shared/himi-store-facets.ts +4 -4
  74. package/templates/branded-lite/tier5-src/_shared/himi-store-saved.ts +275 -13
  75. package/templates/branded-lite/tier5-src/_shared/performance-tracker-section.ts +24 -16
  76. package/templates/branded-lite/tier5-src/_shared/performance-tracker-weeks.ts +27 -20
  77. package/templates/branded-lite/tier5-src/_shared/saved-products-section.ts +14 -8
  78. package/templates/branded-lite/tier5-src/_shared/weekly-goal.ts +28 -12
  79. package/templates/branded-lite/tier5-src/himi-booking-bookings/index.ts +7 -2
  80. package/templates/branded-lite/tier5-src/himi-branded-lite-cart/index.ts +13 -7
  81. package/templates/branded-lite/tier5-src/himi-branded-lite-category/index.ts +6 -1
  82. package/templates/branded-lite/tier5-src/himi-branded-lite-home/index.ts +14 -13
  83. package/templates/branded-lite/tier5-src/himi-branded-lite-shop/index.ts +9 -3
  84. package/templates/branded-lite/tier5-src/himi-store-product/index.ts +32 -15
  85. package/templates/branded-lite/tier5-src/himi-store-saved/index.ts +31 -12
  86. package/templates/brandy/tier5-src/_shared/collection-service.ts +42 -19
  87. package/templates/brandy/tier5-src/_shared/engine-intl.ts +65 -0
  88. package/templates/brandy/tier5-src/_shared/himi-store-saved.ts +275 -13
  89. package/templates/brandy/tier5-src/himi-branded-lite-cart/index.ts +13 -7
  90. package/templates/community-club/dev/index.ts +1 -0
  91. package/templates/community-club/l10n/ar.json +5 -0
  92. package/templates/community-club/l10n/cs.json +5 -0
  93. package/templates/community-club/l10n/da.json +5 -0
  94. package/templates/community-club/l10n/de.json +5 -0
  95. package/templates/community-club/l10n/el.json +5 -0
  96. package/templates/community-club/l10n/es.json +5 -0
  97. package/templates/community-club/l10n/fi.json +5 -0
  98. package/templates/community-club/l10n/fr.json +5 -0
  99. package/templates/community-club/l10n/he.json +4 -0
  100. package/templates/community-club/l10n/hu.json +5 -0
  101. package/templates/community-club/l10n/id.json +5 -0
  102. package/templates/community-club/l10n/it.json +5 -0
  103. package/templates/community-club/l10n/ja.json +5 -0
  104. package/templates/community-club/l10n/ko.json +5 -0
  105. package/templates/community-club/l10n/lt.json +5 -0
  106. package/templates/community-club/l10n/nl.json +5 -0
  107. package/templates/community-club/l10n/no.json +5 -0
  108. package/templates/community-club/l10n/pl.json +5 -0
  109. package/templates/community-club/l10n/pt.json +5 -0
  110. package/templates/community-club/l10n/ru.json +5 -0
  111. package/templates/community-club/l10n/sv.json +5 -0
  112. package/templates/community-club/l10n/th.json +5 -0
  113. package/templates/community-club/l10n/tr.json +5 -0
  114. package/templates/community-club/l10n/uk.json +5 -0
  115. package/templates/community-club/l10n/vi.json +5 -0
  116. package/templates/community-club/l10n/zh.json +5 -0
  117. package/templates/community-club/tier5-src/_shared/collection-service.ts +35 -15
  118. package/templates/community-club/tier5-src/_shared/engine-intl.ts +65 -0
  119. package/templates/community-club/tier5-src/_shared/himi-store-saved.ts +275 -13
  120. package/templates/community-club/tier5-src/_shared/weekly-goal.ts +28 -12
  121. package/templates/community-club/tier5-src/himi-branded-lite-home/index.ts +14 -13
  122. package/templates/community-club-owner/tier5-src/_shared/collection-service.ts +35 -15
  123. package/templates/community-club-owner/tier5-src/_shared/engine-intl.ts +65 -0
  124. package/templates/conference/tier5-src/_shared/collection-service.ts +35 -15
  125. package/templates/conference/tier5-src/_shared/engine-intl.ts +65 -0
  126. package/templates/events-meetups/dev/index.ts +1 -0
  127. package/templates/events-meetups/l10n/ar.json +5 -0
  128. package/templates/events-meetups/l10n/cs.json +5 -0
  129. package/templates/events-meetups/l10n/da.json +5 -0
  130. package/templates/events-meetups/l10n/de.json +5 -0
  131. package/templates/events-meetups/l10n/el.json +5 -0
  132. package/templates/events-meetups/l10n/es.json +5 -0
  133. package/templates/events-meetups/l10n/fi.json +5 -0
  134. package/templates/events-meetups/l10n/fr.json +5 -0
  135. package/templates/events-meetups/l10n/he.json +4 -0
  136. package/templates/events-meetups/l10n/hu.json +5 -0
  137. package/templates/events-meetups/l10n/id.json +5 -0
  138. package/templates/events-meetups/l10n/it.json +5 -0
  139. package/templates/events-meetups/l10n/ja.json +5 -0
  140. package/templates/events-meetups/l10n/ko.json +5 -0
  141. package/templates/events-meetups/l10n/lt.json +5 -0
  142. package/templates/events-meetups/l10n/nl.json +5 -0
  143. package/templates/events-meetups/l10n/no.json +5 -0
  144. package/templates/events-meetups/l10n/pl.json +5 -0
  145. package/templates/events-meetups/l10n/pt.json +5 -0
  146. package/templates/events-meetups/l10n/ru.json +5 -0
  147. package/templates/events-meetups/l10n/sv.json +5 -0
  148. package/templates/events-meetups/l10n/th.json +5 -0
  149. package/templates/events-meetups/l10n/tr.json +5 -0
  150. package/templates/events-meetups/l10n/uk.json +5 -0
  151. package/templates/events-meetups/l10n/vi.json +5 -0
  152. package/templates/events-meetups/l10n/zh.json +5 -0
  153. package/templates/events-meetups/tier5-src/_shared/collection-service.ts +35 -15
  154. package/templates/events-meetups/tier5-src/_shared/engine-intl.ts +65 -0
  155. package/templates/events-meetups/tier5-src/_shared/himi-store-saved.ts +275 -13
  156. package/templates/events-meetups/tier5-src/_shared/weekly-goal.ts +28 -12
  157. package/templates/events-meetups/tier5-src/himi-branded-lite-home/index.ts +14 -13
  158. package/templates/events-meetups-owner/tier5-src/_shared/collection-service.ts +35 -15
  159. package/templates/events-meetups-owner/tier5-src/_shared/engine-intl.ts +65 -0
  160. package/templates/fitness-gym/tier5-src/_shared/collection-service.ts +35 -15
  161. package/templates/fitness-gym/tier5-src/_shared/engine-intl.ts +65 -0
  162. package/templates/fitness-gym/tier5-src/_shared/weekly-goal.ts +28 -12
  163. package/templates/fitness-gym/tier5-src/himi-booking-bookings/index.ts +7 -2
  164. package/templates/fitness-gym/tier5-src/himi-fitcoach-home/index.ts +3 -2
  165. package/templates/gym-fitness/dev/index.ts +3 -1
  166. package/templates/gym-fitness/tier5-src/_shared/collection-service.ts +35 -15
  167. package/templates/gym-fitness/tier5-src/_shared/engine-intl.ts +65 -0
  168. package/templates/gym-fitness/tier5-src/_shared/himi-store-facets.ts +4 -4
  169. package/templates/gym-fitness/tier5-src/_shared/himi-store-saved.ts +275 -13
  170. package/templates/gym-fitness/tier5-src/_shared/weekly-goal.ts +28 -12
  171. package/templates/gym-fitness/tier5-src/himi-booking-bookings/index.ts +7 -2
  172. package/templates/gym-fitness/tier5-src/himi-branded-lite-cart/index.ts +13 -7
  173. package/templates/gym-fitness/tier5-src/himi-branded-lite-category/index.ts +6 -1
  174. package/templates/gym-fitness/tier5-src/himi-branded-lite-home/index.ts +14 -13
  175. package/templates/gym-fitness/tier5-src/himi-branded-lite-shop/index.ts +9 -3
  176. package/templates/gym-fitness/tier5-src/himi-store-product/index.ts +7 -5
  177. package/templates/gym-fitness/tier5-src/himi-store-saved/index.ts +31 -12
  178. package/templates/gym-fitness-owner/tier5-src/_shared/collection-service.ts +35 -15
  179. package/templates/gym-fitness-owner/tier5-src/_shared/engine-intl.ts +65 -0
  180. package/templates/medical-services/tier5-src/_shared/collection-service.ts +35 -15
  181. package/templates/medical-services/tier5-src/_shared/engine-intl.ts +65 -0
  182. package/templates/medical-services/tier5-src/_shared/weekly-goal.ts +28 -12
  183. package/templates/medical-services/tier5-src/himi-booking-bookings/index.ts +7 -2
  184. package/templates/nonprofit-cause/dev/index.ts +1 -0
  185. package/templates/nonprofit-cause/l10n/ar.json +5 -0
  186. package/templates/nonprofit-cause/l10n/cs.json +5 -0
  187. package/templates/nonprofit-cause/l10n/da.json +5 -0
  188. package/templates/nonprofit-cause/l10n/de.json +5 -0
  189. package/templates/nonprofit-cause/l10n/el.json +5 -0
  190. package/templates/nonprofit-cause/l10n/es.json +5 -0
  191. package/templates/nonprofit-cause/l10n/fi.json +5 -0
  192. package/templates/nonprofit-cause/l10n/fr.json +5 -0
  193. package/templates/nonprofit-cause/l10n/he.json +4 -0
  194. package/templates/nonprofit-cause/l10n/hu.json +5 -0
  195. package/templates/nonprofit-cause/l10n/id.json +5 -0
  196. package/templates/nonprofit-cause/l10n/it.json +5 -0
  197. package/templates/nonprofit-cause/l10n/ja.json +5 -0
  198. package/templates/nonprofit-cause/l10n/ko.json +5 -0
  199. package/templates/nonprofit-cause/l10n/lt.json +5 -0
  200. package/templates/nonprofit-cause/l10n/nl.json +5 -0
  201. package/templates/nonprofit-cause/l10n/no.json +5 -0
  202. package/templates/nonprofit-cause/l10n/pl.json +5 -0
  203. package/templates/nonprofit-cause/l10n/pt.json +5 -0
  204. package/templates/nonprofit-cause/l10n/ru.json +5 -0
  205. package/templates/nonprofit-cause/l10n/sv.json +5 -0
  206. package/templates/nonprofit-cause/l10n/th.json +5 -0
  207. package/templates/nonprofit-cause/l10n/tr.json +5 -0
  208. package/templates/nonprofit-cause/l10n/uk.json +5 -0
  209. package/templates/nonprofit-cause/l10n/vi.json +5 -0
  210. package/templates/nonprofit-cause/l10n/zh.json +5 -0
  211. package/templates/nonprofit-cause/tier5-src/_shared/collection-service.ts +35 -15
  212. package/templates/nonprofit-cause/tier5-src/_shared/engine-intl.ts +65 -0
  213. package/templates/nonprofit-cause/tier5-src/_shared/himi-store-saved.ts +275 -13
  214. package/templates/nonprofit-cause/tier5-src/_shared/weekly-goal.ts +28 -12
  215. package/templates/nonprofit-cause/tier5-src/himi-branded-lite-home/index.ts +14 -13
  216. package/templates/nonprofit-cause-owner/tier5-src/_shared/collection-service.ts +35 -15
  217. package/templates/nonprofit-cause-owner/tier5-src/_shared/engine-intl.ts +65 -0
  218. package/templates/owner-lite/tier5-src/_shared/collection-service.ts +35 -15
  219. package/templates/owner-lite/tier5-src/_shared/engine-intl.ts +65 -0
  220. package/templates/personal-fitness-trainer/tier5-src/_shared/collection-service.ts +35 -15
  221. package/templates/personal-fitness-trainer/tier5-src/_shared/engine-intl.ts +65 -0
  222. package/templates/personal-fitness-trainer/tier5-src/_shared/weekly-goal.ts +28 -12
  223. package/templates/personal-fitness-trainer/tier5-src/himi-booking-bookings/index.ts +7 -2
  224. package/templates/podcast-creator/dev/index.ts +1 -0
  225. package/templates/podcast-creator/l10n/ar.json +5 -0
  226. package/templates/podcast-creator/l10n/cs.json +5 -0
  227. package/templates/podcast-creator/l10n/da.json +5 -0
  228. package/templates/podcast-creator/l10n/de.json +5 -0
  229. package/templates/podcast-creator/l10n/el.json +5 -0
  230. package/templates/podcast-creator/l10n/es.json +5 -0
  231. package/templates/podcast-creator/l10n/fi.json +5 -0
  232. package/templates/podcast-creator/l10n/fr.json +5 -0
  233. package/templates/podcast-creator/l10n/he.json +4 -0
  234. package/templates/podcast-creator/l10n/hu.json +5 -0
  235. package/templates/podcast-creator/l10n/id.json +5 -0
  236. package/templates/podcast-creator/l10n/it.json +5 -0
  237. package/templates/podcast-creator/l10n/ja.json +5 -0
  238. package/templates/podcast-creator/l10n/ko.json +5 -0
  239. package/templates/podcast-creator/l10n/lt.json +5 -0
  240. package/templates/podcast-creator/l10n/nl.json +5 -0
  241. package/templates/podcast-creator/l10n/no.json +5 -0
  242. package/templates/podcast-creator/l10n/pl.json +5 -0
  243. package/templates/podcast-creator/l10n/pt.json +5 -0
  244. package/templates/podcast-creator/l10n/ru.json +5 -0
  245. package/templates/podcast-creator/l10n/sv.json +5 -0
  246. package/templates/podcast-creator/l10n/th.json +5 -0
  247. package/templates/podcast-creator/l10n/tr.json +5 -0
  248. package/templates/podcast-creator/l10n/uk.json +5 -0
  249. package/templates/podcast-creator/l10n/vi.json +5 -0
  250. package/templates/podcast-creator/l10n/zh.json +5 -0
  251. package/templates/podcast-creator/tier5-src/_shared/collection-service.ts +35 -15
  252. package/templates/podcast-creator/tier5-src/_shared/engine-intl.ts +65 -0
  253. package/templates/podcast-creator/tier5-src/_shared/himi-store-saved.ts +275 -13
  254. package/templates/podcast-creator/tier5-src/_shared/weekly-goal.ts +28 -12
  255. package/templates/podcast-creator/tier5-src/himi-branded-lite-home/index.ts +14 -13
  256. package/templates/podcast-creator-owner/tier5-src/_shared/collection-service.ts +35 -15
  257. package/templates/podcast-creator-owner/tier5-src/_shared/engine-intl.ts +65 -0
  258. package/templates/portfolio-creative/dev/index.ts +1 -0
  259. package/templates/portfolio-creative/tier5-src/_shared/collection-service.ts +35 -15
  260. package/templates/portfolio-creative/tier5-src/_shared/engine-intl.ts +65 -0
  261. package/templates/portfolio-creative/tier5-src/_shared/himi-store-facets.ts +4 -4
  262. package/templates/portfolio-creative/tier5-src/_shared/himi-store-saved.ts +275 -13
  263. package/templates/portfolio-creative/tier5-src/_shared/weekly-goal.ts +28 -12
  264. package/templates/portfolio-creative/tier5-src/himi-branded-lite-cart/index.ts +13 -7
  265. package/templates/portfolio-creative/tier5-src/himi-branded-lite-category/index.ts +6 -1
  266. package/templates/portfolio-creative/tier5-src/himi-branded-lite-home/index.ts +14 -13
  267. package/templates/portfolio-creative/tier5-src/himi-branded-lite-shop/index.ts +9 -3
  268. package/templates/portfolio-creative/tier5-src/himi-store-product/index.ts +7 -5
  269. package/templates/portfolio-creative/tier5-src/himi-store-saved/index.ts +31 -12
  270. package/templates/portfolio-creative-owner/tier5-src/_shared/collection-service.ts +35 -15
  271. package/templates/portfolio-creative-owner/tier5-src/_shared/engine-intl.ts +65 -0
  272. package/templates/professional-services/tier5-src/_shared/collection-service.ts +35 -15
  273. package/templates/professional-services/tier5-src/_shared/engine-intl.ts +65 -0
  274. package/templates/professional-services/tier5-src/_shared/weekly-goal.ts +28 -12
  275. package/templates/professional-services/tier5-src/himi-booking-bookings/index.ts +7 -2
  276. package/templates/restaurant/dev/index.ts +1 -0
  277. package/templates/restaurant/l10n/ar.json +5 -0
  278. package/templates/restaurant/l10n/cs.json +5 -0
  279. package/templates/restaurant/l10n/da.json +5 -0
  280. package/templates/restaurant/l10n/de.json +5 -0
  281. package/templates/restaurant/l10n/el.json +5 -0
  282. package/templates/restaurant/l10n/es.json +5 -0
  283. package/templates/restaurant/l10n/fi.json +5 -0
  284. package/templates/restaurant/l10n/fr.json +5 -0
  285. package/templates/restaurant/l10n/he.json +4 -0
  286. package/templates/restaurant/l10n/hu.json +5 -0
  287. package/templates/restaurant/l10n/id.json +5 -0
  288. package/templates/restaurant/l10n/it.json +5 -0
  289. package/templates/restaurant/l10n/ja.json +5 -0
  290. package/templates/restaurant/l10n/ko.json +5 -0
  291. package/templates/restaurant/l10n/lt.json +5 -0
  292. package/templates/restaurant/l10n/nl.json +5 -0
  293. package/templates/restaurant/l10n/no.json +5 -0
  294. package/templates/restaurant/l10n/pl.json +5 -0
  295. package/templates/restaurant/l10n/pt.json +5 -0
  296. package/templates/restaurant/l10n/ru.json +5 -0
  297. package/templates/restaurant/l10n/sv.json +5 -0
  298. package/templates/restaurant/l10n/th.json +5 -0
  299. package/templates/restaurant/l10n/tr.json +5 -0
  300. package/templates/restaurant/l10n/uk.json +5 -0
  301. package/templates/restaurant/l10n/vi.json +5 -0
  302. package/templates/restaurant/l10n/zh.json +5 -0
  303. package/templates/restaurant/tier5-src/_shared/collection-service.ts +35 -15
  304. package/templates/restaurant/tier5-src/_shared/engine-intl.ts +65 -0
  305. package/templates/restaurant/tier5-src/_shared/himi-store-saved.ts +275 -13
  306. package/templates/restaurant/tier5-src/_shared/weekly-goal.ts +28 -12
  307. package/templates/restaurant/tier5-src/himi-branded-lite-home/index.ts +14 -13
  308. package/templates/restaurant-owner/tier5-src/_shared/collection-service.ts +35 -15
  309. package/templates/restaurant-owner/tier5-src/_shared/engine-intl.ts +65 -0
  310. package/templates/retail-store/dev/index.ts +1 -0
  311. package/templates/retail-store/tier5-src/_shared/collection-service.ts +42 -19
  312. package/templates/retail-store/tier5-src/_shared/engine-intl.ts +65 -0
  313. package/templates/retail-store/tier5-src/_shared/himi-store-facets.ts +4 -4
  314. package/templates/retail-store/tier5-src/_shared/himi-store-saved.ts +275 -13
  315. package/templates/retail-store/tier5-src/_shared/weekly-goal.ts +28 -12
  316. package/templates/retail-store/tier5-src/himi-branded-lite-cart/index.ts +13 -7
  317. package/templates/retail-store/tier5-src/himi-branded-lite-category/index.ts +6 -1
  318. package/templates/retail-store/tier5-src/himi-branded-lite-home/index.ts +14 -13
  319. package/templates/retail-store/tier5-src/himi-branded-lite-shop/index.ts +9 -3
  320. package/templates/retail-store/tier5-src/himi-store-product/index.ts +32 -15
  321. package/templates/retail-store/tier5-src/himi-store-saved/index.ts +31 -12
  322. package/templates/retail-store-owner/tier5-src/_shared/collection-service.ts +35 -15
  323. package/templates/retail-store-owner/tier5-src/_shared/engine-intl.ts +65 -0
  324. package/templates/salon-spa/tier5-src/_shared/collection-service.ts +35 -15
  325. package/templates/salon-spa/tier5-src/_shared/engine-intl.ts +65 -0
  326. package/templates/salon-spa/tier5-src/_shared/weekly-goal.ts +28 -12
  327. package/templates/salon-spa/tier5-src/himi-booking-bookings/index.ts +7 -2
  328. package/templates/wholesale-store/dev/index.ts +2 -2
  329. package/templates/wholesale-store/tier5-src/_shared/collection-service.ts +42 -19
  330. package/templates/wholesale-store/tier5-src/_shared/engine-intl.ts +65 -0
  331. package/templates/wholesale-store/tier5-src/_shared/himi-store-collection.ts +7 -3
  332. package/templates/wholesale-store/tier5-src/_shared/himi-store-saved.ts +275 -13
  333. package/templates/wholesale-store/tier5-src/himi-branded-lite-cart/index.ts +13 -7
  334. package/templates/wholesale-store/tier5-src/himi-store-product/index.ts +32 -15
  335. package/templates/wholesale-store/tier5-src/himi-store-saved/index.ts +31 -12
  336. package/templates/wholesale-store/tier5-src/himi-wholesale-home/index.ts +19 -8
  337. package/templates/yoga-studio/dev/index.ts +3 -1
  338. package/templates/yoga-studio/l10n/ar.json +5 -0
  339. package/templates/yoga-studio/l10n/cs.json +5 -0
  340. package/templates/yoga-studio/l10n/da.json +5 -0
  341. package/templates/yoga-studio/l10n/de.json +5 -0
  342. package/templates/yoga-studio/l10n/el.json +5 -0
  343. package/templates/yoga-studio/l10n/es.json +5 -0
  344. package/templates/yoga-studio/l10n/fi.json +5 -0
  345. package/templates/yoga-studio/l10n/fr.json +5 -0
  346. package/templates/yoga-studio/l10n/he.json +4 -0
  347. package/templates/yoga-studio/l10n/hu.json +5 -0
  348. package/templates/yoga-studio/l10n/id.json +5 -0
  349. package/templates/yoga-studio/l10n/it.json +5 -0
  350. package/templates/yoga-studio/l10n/ja.json +5 -0
  351. package/templates/yoga-studio/l10n/ko.json +5 -0
  352. package/templates/yoga-studio/l10n/lt.json +5 -0
  353. package/templates/yoga-studio/l10n/nl.json +5 -0
  354. package/templates/yoga-studio/l10n/no.json +5 -0
  355. package/templates/yoga-studio/l10n/pl.json +5 -0
  356. package/templates/yoga-studio/l10n/pt.json +5 -0
  357. package/templates/yoga-studio/l10n/ru.json +5 -0
  358. package/templates/yoga-studio/l10n/sv.json +5 -0
  359. package/templates/yoga-studio/l10n/th.json +5 -0
  360. package/templates/yoga-studio/l10n/tr.json +5 -0
  361. package/templates/yoga-studio/l10n/uk.json +5 -0
  362. package/templates/yoga-studio/l10n/vi.json +5 -0
  363. package/templates/yoga-studio/l10n/zh.json +5 -0
  364. package/templates/yoga-studio/tier5-src/_shared/collection-service.ts +35 -15
  365. package/templates/yoga-studio/tier5-src/_shared/engine-intl.ts +65 -0
  366. package/templates/yoga-studio/tier5-src/_shared/himi-store-saved.ts +275 -13
  367. package/templates/yoga-studio/tier5-src/_shared/weekly-goal.ts +28 -12
  368. package/templates/yoga-studio/tier5-src/himi-booking-bookings/index.ts +7 -2
  369. package/templates/yoga-studio/tier5-src/himi-branded-lite-home/index.ts +14 -13
  370. package/templates/yoga-studio-owner/tier5-src/_shared/collection-service.ts +35 -15
  371. package/templates/yoga-studio-owner/tier5-src/_shared/engine-intl.ts +65 -0
@@ -1,12 +1,12 @@
1
- // A page's wishlist section as a registrable service: the products saved on this device, the same list the template's
1
+ // A page's wishlist section as a registrable service: the saved products, the same list the template's
2
2
  // `himi_saved_products` screen shows (`himi-store-saved`), as tiles that open the product.
3
3
  // limit -> how many tiles (the section is a short grid, not the wishlist screen); `noMore` is false when more are saved,
4
4
  // which is when the section's See All button (to `himi_saved_products`) shows.
5
- // The One App wishlist is the member's account list on a private One App service no worker can call, so this module reads the
6
- // device-local list only. A page worker registers it under a service name; the descriptor binds `$service:<serviceName>.*`
7
- // (recipe wishlist-grid).
5
+ // Like the One App's, a signed-in member's section lists their account wishlist (the list the Wix site and the One App show); a
6
+ // visitor's lists the products saved on this device. A page worker registers it under a service name; the descriptor binds
7
+ // `$service:<serviceName>.*` (recipe wishlist-grid).
8
8
  import { defineService } from "@himalaya/state";
9
- import { readSavedProducts, type SavedProduct } from "./himi-store-saved.js";
9
+ import { listSavedProducts, type SavedProduct } from "./himi-store-saved.js";
10
10
 
11
11
  export interface SavedProductsSectionOptions {
12
12
  /** How many products to show; unset shows every saved product. */
@@ -45,16 +45,22 @@ export function registerSavedProductsSection(serviceName: string, options: Saved
45
45
  notLoading: status !== "loading", notErrored: status !== "error", noRows: !rows.length,
46
46
  noEmpty: !(status === "ready" && !rows.length), noMore: !more,
47
47
  });
48
- return defineService<SavedProductsSectionState, { load: (state: SavedProductsSectionState, arg?: unknown) => SavedProductsSectionState }>(serviceName, {
48
+ let reads = 0;
49
+ return defineService<SavedProductsSectionState, { load: (state: SavedProductsSectionState, arg?: unknown) => Promise<SavedProductsSectionState | undefined> }>(serviceName, {
49
50
  state: view("loading", [], false),
50
51
  actions: {
51
52
  // The list is read on every appearance, so a product saved or removed on another screen shows when the page comes back.
52
- load: () => {
53
+ // Only the latest read lands: one started before a sign-out never paints over the one after it.
54
+ load: async () => {
55
+ const read = ++reads;
53
56
  try {
54
- const saved = readSavedProducts();
57
+ const saved = await listSavedProducts();
58
+ if (read !== reads) return undefined;
55
59
  const shown = options.limit !== undefined ? saved.slice(0, options.limit) : saved;
56
60
  return view("ready", shown.map(rowOf), shown.length < saved.length);
57
61
  } catch (error) {
62
+ if (read !== reads) return undefined;
63
+ // No rows: a failed read never keeps a list that may belong to whoever was signed in before.
58
64
  console.warn("saved_products_section: the saved products could not be read", error);
59
65
  return view("error", [], false);
60
66
  }
@@ -3,19 +3,28 @@
3
3
  // card (himi-booking-bookings), so the two can never count differently.
4
4
  //
5
5
  // WHAT COUNTS as a session toward the goal: a CONFIRMED booking whose start falls in the CURRENT
6
- // calendar week (Monday 00:00 local → now) and is already in the past. An allow-list, not a
6
+ // calendar week (its first day 00:00 local → now) and is already in the past. An allow-list, not a
7
7
  // deny-list: CREATED (checkout never completed), PENDING / PENDING_APPROVAL / PENDING_CHECKOUT,
8
8
  // WAITING_LIST, CANCELED and DECLINED — and any status Wix adds later — do not count. That is
9
9
  // "booked and it happened", not verified
10
10
  // attendance: the member-scoped queryBookings row carries no attendance/check-in field (the Wix
11
11
  // Attendance API is owner-scoped), so a no-show still counts. Future bookings this week do not
12
- // count — they have not happened yet.
12
+ // count — they have not happened yet. So every count here is of HELD sessions, never of attendance:
13
+ // a label that shows one must not say "attended".
14
+ //
15
+ // THE WEEK starts on the first day of the app language's region (CLDR week data: Sunday for "en" /
16
+ // "en-US", Monday for "en-GB" or "de", Saturday for "ar-EG"), as the migrated source starts it. A
17
+ // screen may pin another day with a `firstWeekday` onAppear param (0 = Sunday … 6 = Saturday).
18
+ // `firstWeekdayOf` reads ECMA-402 week info where the engine has it and a CLDR table where it has
19
+ // not, so iOS, Android and web agree on the same week.
13
20
  //
14
21
  // DETERMINISM: nothing here runs at worker boot; every clock read is an argument. PURE (no network,
15
22
  // no bridge) so the rules are unit-tested directly; the read lives with its caller.
16
23
 
17
24
  import type { MemberBookingRow } from "./member-bookings.js";
18
25
  import { copyParam, copyTemplate } from "./himi-copy.js";
26
+ import type { Weekday } from "./engine-intl.js";
27
+ export { MONDAY, firstWeekdayOf, resolveFirstWeekday, type Weekday } from "./engine-intl.js";
19
28
 
20
29
  export const MAX_WEEKLY_SESSION_GOAL = 21;
21
30
 
@@ -32,27 +41,33 @@ export function parseWeeklyGoal(raw: unknown): number {
32
41
  return Number.isInteger(n) && n >= 1 ? Math.min(n, MAX_WEEKLY_SESSION_GOAL) : 0;
33
42
  }
34
43
 
35
- /** Monday 00:00 local of `now`'s week, epoch ms. */
36
- export function weekStartMs(now: number): number {
44
+ /** 00:00 local of the first day (`firstWeekday`) of `now`'s week, epoch ms. */
45
+ export function weekStartMs(now: number, firstWeekday: Weekday): number {
37
46
  const d = new Date(now);
38
47
  d.setHours(0, 0, 0, 0);
39
- d.setDate(d.getDate() - ((d.getDay() + 6) % 7));
48
+ d.setDate(d.getDate() - ((d.getDay() - firstWeekday + 7) % 7));
40
49
  return d.getTime();
41
50
  }
42
51
 
43
- /** Is `row` a session that was booked and already held at `now`? The one rule every count here uses. */
52
+ /** Is `row` a session that was booked and already held at `now`? The one rule every count here uses.
53
+ * Held, not attended: the member's booking row carries no check-in. */
44
54
  export function isHeldSession(row: MemberBookingRow, now: number): boolean {
45
55
  const start = Date.parse(row.start);
46
56
  return Number.isFinite(start) && start < now && COUNTS_AS_SESSION.test((row.status || "").trim().toUpperCase());
47
57
  }
48
58
 
59
+ /** The key one booking counts under: a booking read twice (two pages, a retry) counts once. */
60
+ export function sessionKey(row: MemberBookingRow): string {
61
+ return row.id || `${row.start}|${row.title}`;
62
+ }
63
+
49
64
  /** Sessions toward the goal among `rows` — see the file header for what counts. */
50
- export function weeklySessionsDone(rows: readonly MemberBookingRow[], now: number): number {
51
- const from = weekStartMs(now);
65
+ export function weeklySessionsDone(rows: readonly MemberBookingRow[], now: number, firstWeekday: Weekday): number {
66
+ const from = weekStartMs(now, firstWeekday);
52
67
  const seen = new Set<string>();
53
68
  for (const row of rows) {
54
69
  if (Date.parse(row.start) < from || !isHeldSession(row, now)) continue;
55
- seen.add(row.id || `${row.start}|${row.title}`);
70
+ seen.add(sessionKey(row));
56
71
  }
57
72
  return seen.size;
58
73
  }
@@ -64,14 +79,15 @@ export interface BookingsPage {
64
79
 
65
80
  /** Sessions toward the goal from PAST bookings read newest-first: `first` is the first page, and
66
81
  * `next(cursor)` reads more only while the oldest row so far is still inside this week (a page of
67
- * 50 almost always reaches back before Monday). Bounded to MAX_WEEKLY_PAGES reads; a failing
82
+ * 50 almost always reaches back before the week's first day). Bounded to MAX_WEEKLY_PAGES reads; a failing
68
83
  * read rejects, so the caller hides the count rather than under-counting. */
69
84
  export async function weeklySessionsFromPages(
70
85
  first: BookingsPage,
71
86
  next: (cursor: string) => Promise<BookingsPage>,
72
87
  now: number,
88
+ firstWeekday: Weekday,
73
89
  ): Promise<number> {
74
- const from = weekStartMs(now);
90
+ const from = weekStartMs(now, firstWeekday);
75
91
  const rows = [...first.items];
76
92
  let page = first;
77
93
  for (let read = 1; read < MAX_WEEKLY_PAGES && page.nextCursor; read++) {
@@ -80,7 +96,7 @@ export async function weeklySessionsFromPages(
80
96
  page = await next(page.nextCursor);
81
97
  rows.push(...page.items);
82
98
  }
83
- return weeklySessionsDone(rows, now);
99
+ return weeklySessionsDone(rows, now, firstWeekday);
84
100
  }
85
101
 
86
102
  export interface WeeklyGoalProgress {
@@ -10,7 +10,7 @@ import { memberAccess, assertMemberAccess, memberAccessChanged, memberAccessDeni
10
10
  import { fetchMemberBookings, CANCELLED_STATUSES, UNCONFIRMED_STATUSES, type MemberBookingRow } from "../_shared/member-bookings.js";
11
11
  import { emitHostEvent } from "../_shared/host-events.js";
12
12
  import { formatClock, formatClockRange, formatDateMedium, formatMonthDay, formatWeekdayMonthDay, formatWeekdayMonthDayLong } from "../_shared/engine-intl.js";
13
- import { parseWeeklyGoal, weeklyGoalProgress, weeklySessionsFromPages } from "../_shared/weekly-goal.js";
13
+ import { parseWeeklyGoal, resolveFirstWeekday, weeklyGoalProgress, weeklySessionsFromPages } from "../_shared/weekly-goal.js";
14
14
 
15
15
  // My Bookings: Upcoming / Past / Canceled tabs over the member's own bookings, a booking sheet with
16
16
  // the details and the actions (add to calendar, directions, Book Again, Cancel Booking with a
@@ -50,6 +50,9 @@ let consumedBookingId = "";
50
50
  // count comes from a dedicated read of this week's PAST bookings on each first-page fetch, NOT
51
51
  // from `rows` (those follow the list's tab — Upcoming by default — and would read 0).
52
52
  let weeklyGoal = 0;
53
+ /** The onAppear `firstWeekday` param when the screen pins one; absent, the week starts on the app
54
+ * language's first day (`resolveFirstWeekday`), the rule every weekly count shares. */
55
+ let firstWeekdayParam: unknown;
53
56
  /** The count of the page that APPLIED — set in `apply`, never by a fetch, so a superseded fetch
54
57
  * (another member, a refresh) cannot overwrite it: it travels in that page's metadata and is
55
58
  * dropped with it. */
@@ -66,7 +69,7 @@ async function fetchWeeklySessionsDone(member: MemberAccess, now: number): Promi
66
69
  try {
67
70
  const nowIso = new Date(now).toISOString();
68
71
  const read = (cursor: string) => fetchMemberBookings({ query: "", filter: "value:Past", sort: "za", savedIds: [] }, cursor, nowIso, member);
69
- return await weeklySessionsFromPages(await read(""), read, now);
72
+ return await weeklySessionsFromPages(await read(""), read, now, resolveFirstWeekday(firstWeekdayParam));
70
73
  } catch {
71
74
  return null;
72
75
  }
@@ -304,6 +307,8 @@ const svc = defineBackendCollection<S, MemberBookingRow>("himiBookingBookings",
304
307
  readResultSnackbar(arg);
305
308
  const goal = parseWeeklyGoal((arg as Record<string, unknown> | undefined)?.weeklyGoal);
306
309
  if (goal) weeklyGoal = goal;
310
+ const pinnedWeekday = (arg as Record<string, unknown> | undefined)?.firstWeekday;
311
+ if (pinnedWeekday !== undefined) firstWeekdayParam = pinnedWeekday;
307
312
  // A deep link (the home "next booking", the place summary) names a booking: open its sheet once
308
313
  // its row is on the first page. `date` alone does nothing now (there is no day view).
309
314
  const linked = runtime()?.input?.bookingId;
@@ -47,7 +47,7 @@ const WIX_STORES_APP_ID = "1380b703-ce81-ff05-f115-39571d94dfcd";
47
47
  import { copyParam, copyTemplate, stashCopy } from "../_shared/himi-copy.js";
48
48
  import { getAll, upsert, remove as dbRemove, type DbEntity } from "@himalaya/local-db";
49
49
  import { isOfflineFailure, writeMayHaveLanded } from "../_shared/owner-load-error.js";
50
- import { isProductSaved, readSavedProducts, toggleSavedProduct } from "../_shared/himi-store-saved.js";
50
+ import { isProductSaved, readSavedProducts, refreshSavedThen, toggleSavedProduct } from "../_shared/himi-store-saved.js";
51
51
 
52
52
  // Offline-first (data-offline): the cart is READ-THROUGH — paint the last-synced line
53
53
  // items from the on-device `cart` entity first (instant, works offline), then
@@ -463,7 +463,8 @@ const svc = defineService<State, {
463
463
  applyPromo: (state: State) => Promise<State>;
464
464
  removePromo: (state: State) => Promise<State>;
465
465
  remove: (state: State, arg?: unknown) => Promise<State>;
466
- save: (state: State, arg?: unknown) => State;
466
+ save: (state: State, arg?: unknown) => Promise<State>;
467
+ savedChanged: () => State;
467
468
  increment: (state: State, arg?: unknown) => Promise<State>;
468
469
  decrement: (state: State, arg?: unknown) => Promise<State>;
469
470
  checkout: (state: State) => Promise<State>;
@@ -479,9 +480,14 @@ const svc = defineService<State, {
479
480
  webSignedIn = (change as { signedIn?: unknown } | undefined)?.signedIn === true;
480
481
  webGeneration++;
481
482
  if (memberOnlyCart) queueSessionReload();
483
+ refreshSavedThen(() => svc.savedChanged());
482
484
  return derive(state);
483
485
  },
486
+ // The signed-in member's saved list landed: `derive` re-marks the hearts.
487
+ savedChanged: (): State => derive(svc.getState() as State),
484
488
  load: async (state, arg) => {
489
+ // Hearts follow the signed-in member's account wishlist, read beside the cart.
490
+ refreshSavedThen(() => svc.savedChanged());
485
491
  // A members-only cart (a site shell) never shows a signed-out shopper's native cart. `prepare` sets the flag
486
492
  // before coalescing, so a load already in flight (the boot load) re-checks it before it lands.
487
493
  if (memberOnlyArg(arg)) memberOnlyCart = true;
@@ -575,15 +581,15 @@ const svc = defineService<State, {
575
581
  if (!id) return state;
576
582
  return removeLine(state, id);
577
583
  },
578
- save: (state, arg) => {
584
+ save: async (state, arg): Promise<State> => {
579
585
  const id = itemId(arg);
580
586
  const item = state.items.find(candidate => candidate.id === id);
581
587
  const productId = item?.catalogReference?.catalogItemId ?? item?.productId;
582
588
  if (!item || !productId) return state;
583
- try {
584
- const saved = toggleSavedProduct({ id: productId, name: item.name, price: item.unitPrice, wasPrice: item.wasPrice, image: item.image, swatches: item.swatches });
585
- return derive({ ...state, items: state.items.map(candidate => (candidate.catalogReference?.catalogItemId ?? candidate.productId) === productId ? { ...candidate, saved, notSaved: !saved } : candidate) });
586
- } catch { return derive({ ...state, checkoutHint: copyParam("cart.saveError", "Could not save this item.") }); }
589
+ // `derive` re-marks every row from the saved list, on the cart as it is once the write lands.
590
+ try { await toggleSavedProduct({ id: productId, name: item.name, price: item.unitPrice, wasPrice: item.wasPrice, image: item.image, swatches: item.swatches }); }
591
+ catch { return derive({ ...(svc.getState() as State), checkoutHint: copyParam("cart.saveError", "Could not save this item.") }); }
592
+ return derive(svc.getState() as State);
587
593
  },
588
594
  increment: async (state, arg) => {
589
595
  const id = itemId(arg);
@@ -8,6 +8,7 @@ import { createCollectionQuery } from "../_shared/collection-query.js";
8
8
  import { detailInputId, presence, presenceAfterError, type PresenceFlags } from "../_shared/detail-presence.js";
9
9
  import { stashCopy, copyParam, copyTemplate } from "../_shared/himi-copy.js";
10
10
  import { FACETS_BOOT, PAGE_SIZE, applyFacets, currencyOf, facetActions, idOf, readViewPrefs, tagFields, toRows, toggleSaved, type FacetState } from "../_shared/himi-store-facets.js";
11
+ import { refreshSavedThen } from "../_shared/himi-store-saved.js";
11
12
  import { withIapPresentation } from "../_shared/iap-presentation.js";
12
13
 
13
14
  interface State extends FacetState, PresenceFlags {
@@ -109,6 +110,8 @@ const facets = facetActions<State>(derive);
109
110
  const actions = {
110
111
  load: async (s: State, arg?: unknown): Promise<State | undefined> => {
111
112
  stashCopy(arg);
113
+ // Hearts follow the signed-in member's account wishlist, read beside the products.
114
+ refreshSavedThen(() => svc.savedChanged());
112
115
  const version = ++loadVersion;
113
116
  const id = detailInputId();
114
117
  if (!id) return derive({ ...s, ...presence("missing"), loadId: version });
@@ -153,7 +156,9 @@ const actions = {
153
156
  },
154
157
  productsChanged: (s: State) => s.loadId === loadVersion ? derive(s) : undefined,
155
158
  search: (s: State, arg?: { value?: string }) => derive({ ...s, query: (arg?.value ?? "").slice(0, 256), visible: PAGE_SIZE, cursorEpoch: s.cursorEpoch + 1 }),
156
- toggleSave: (s: State, arg?: unknown) => { try { toggleSaved(s.results, idOf(arg)); } catch { return s; } return derive(s); },
159
+ toggleSave: async (s: State, arg?: unknown): Promise<State> => { try { await toggleSaved(s.results, idOf(arg)); } catch { return s; } return derive(svc.getState() as State); },
160
+ // The signed-in member's saved list landed: re-mark the hearts.
161
+ savedChanged: (): State => derive(svc.getState() as State),
157
162
  ...facets,
158
163
  clearSearch: (s: State) => derive({ ...s, query: "", priceSelected: [], opt1Selected: [], opt2Selected: [], opt3Selected: [], visible: PAGE_SIZE, cursorEpoch: s.cursorEpoch + 1 }),
159
164
  toggleFacet: (s: State, arg?: { facet?: string; id?: string }) => {
@@ -30,10 +30,10 @@ import { cleanTitle, initials } from "../_shared/himi-text.js";
30
30
  import { LAYOUT_KEY, type LayoutId, recommendLayout, resolveLayout } from "../_shared/himi-layouts.js";
31
31
  import { copyParam, copyTemplate, stashCopy } from "../_shared/himi-copy.js";
32
32
  import { groupMemberCount } from "../_shared/group-member-count.js";
33
- import { parseWeeklyGoal, weeklyGoalProgress, weeklySessionsFromPages } from "../_shared/weekly-goal.js";
33
+ import { parseWeeklyGoal, resolveFirstWeekday, weekStartMs, weeklyGoalProgress, weeklySessionsFromPages, type Weekday } from "../_shared/weekly-goal.js";
34
34
  import { isBridgeUnavailable } from "../_shared/owner-load-error.js";
35
35
  import { formatDateMedium } from "../_shared/engine-intl.js";
36
- import { readSavedProducts, type SavedProduct } from "../_shared/himi-store-saved.js";
36
+ import { listSavedProducts, type SavedProduct } from "../_shared/himi-store-saved.js";
37
37
  import { loadStoreCategories, type StoreCategoryCard } from "../_shared/himi-store-categories.js";
38
38
  import { readSavedIds } from "../_shared/himi-blog-saved.js";
39
39
  import { withoutHidden } from "../_shared/himi-blog-hidden.js";
@@ -699,14 +699,15 @@ function savedPostCard(post: WixPost): SavedPostCard {
699
699
  interface SavedSignal { savedProducts: SavedProductCard[]; savedPosts: SavedPostCard[]; }
700
700
  function emptySavedSignal(): SavedSignal { return { savedProducts: [], savedPosts: [] }; }
701
701
 
702
- /** Resolve supported device-local saves into public rails. Member-only work remains
703
- * in refreshPersonal(), so a visitor can never trigger a bookings query here. */
702
+ /** Resolve supported saves into public rails: saved products are a signed-in member's account wishlist,
703
+ * a visitor's device list. Member-only work remains in refreshPersonal(), so a visitor can never trigger
704
+ * a bookings query here. */
704
705
  async function fetchSavedSignal(arg: unknown): Promise<SavedSignal> {
705
706
  const verticals = parseVerticals(arg);
706
707
  const signal = emptySavedSignal();
707
708
  if (verticals.includes("store")) {
708
- try { signal.savedProducts = readSavedProducts().slice(0, 6).map(savedProductCard); }
709
- catch { /* unavailable storage simply collapses the optional rail */ }
709
+ try { signal.savedProducts = (await listSavedProducts()).slice(0, 6).map(savedProductCard); }
710
+ catch { /* an unreadable list simply collapses the optional rail */ }
710
711
  }
711
712
  if (verticals.includes("blog")) {
712
713
  let ids: string[] = [];
@@ -1315,11 +1316,9 @@ async function refreshPublic(state: State, arg?: unknown): Promise<State | undef
1315
1316
 
1316
1317
  let personalGeneration = 0;
1317
1318
  let shopCategoryActivation = 0;
1318
- function memberSchedule(rows: MemberBookingRow[], now = new Date()): { label: string; fraction: number } {
1319
- const weekStart = new Date(now);
1320
- const day = (weekStart.getDay() + 6) % 7;
1321
- weekStart.setDate(weekStart.getDate() - day);
1322
- weekStart.setHours(0, 0, 0, 0);
1319
+ function memberSchedule(rows: MemberBookingRow[], now: Date, firstWeekday: Weekday): { label: string; fraction: number } {
1320
+ // The same week as the weekly-goal Gauge beside it (`weekly-goal.ts`).
1321
+ const weekStart = new Date(weekStartMs(now.getTime(), firstWeekday));
1323
1322
  const weekEnd = new Date(weekStart);
1324
1323
  weekEnd.setDate(weekEnd.getDate() + 7);
1325
1324
  const current = rows.filter((row) => {
@@ -1343,6 +1342,8 @@ async function refreshPersonal(generation: number, arg?: unknown): Promise<void>
1343
1342
  const weeklyGoal = parseWeeklyGoal(paramValue(arg, "weeklyGoal"));
1344
1343
  if (member.email && parseVerticals(arg).includes("bookings")) {
1345
1344
  const now = new Date();
1345
+ // The week starts on the screen's `firstWeekday` (the app's language, set by the descriptor), else the worker's language.
1346
+ const firstWeekday = resolveFirstWeekday(typeof arg === "string" ? undefined : paramValue(arg, "firstWeekday"));
1346
1347
  const [upcoming, past] = await Promise.allSettled([
1347
1348
  fetchMemberBookings({ query: "", filter: "value:Upcoming", sort: "default", savedIds: [] }, "", now.toISOString(), member),
1348
1349
  fetchMemberBookings({ query: "", filter: "value:Past", sort: "za", savedIds: [] }, "", now.toISOString(), member),
@@ -1356,7 +1357,7 @@ async function refreshPersonal(generation: number, arg?: unknown): Promise<void>
1356
1357
  if (upcoming.status === "fulfilled" && past.status === "fulfilled") {
1357
1358
  // A schedule total needs both halves. Hide it rather than under-counting
1358
1359
  // when either query failed.
1359
- progress = memberSchedule([...upcoming.value.items, ...past.value.items], now);
1360
+ progress = memberSchedule([...upcoming.value.items, ...past.value.items], now, firstWeekday);
1360
1361
  }
1361
1362
  if (weeklyGoal > 0 && past.status === "fulfilled") {
1362
1363
  // The goal counts sessions that already HAPPENED this week (_shared/weekly-goal.ts). A
@@ -1366,7 +1367,7 @@ async function refreshPersonal(generation: number, arg?: unknown): Promise<void>
1366
1367
  try {
1367
1368
  const readPast = (cursor: string) =>
1368
1369
  fetchMemberBookings({ query: "", filter: "value:Past", sort: "za", savedIds: [] }, cursor, now.toISOString(), member);
1369
- const goal = weeklyGoalProgress(await weeklySessionsFromPages(past.value, readPast, now.getTime()), weeklyGoal);
1370
+ const goal = weeklyGoalProgress(await weeklySessionsFromPages(past.value, readPast, now.getTime(), firstWeekday), weeklyGoal);
1370
1371
  weekly = { count: goal.done, fraction: goal.fraction, label: goal.label };
1371
1372
  } catch {
1372
1373
  weekly = null;
@@ -20,6 +20,7 @@ import {
20
20
  FACETS_BOOT, PAGE_SIZE, applyFacets, countText, currencyOf, facetActions, idOf, option, readViewPrefs, selected, tagFields, toRows, toggleSaved,
21
21
  type FacetState, type Option, type Row,
22
22
  } from "../_shared/himi-store-facets.js";
23
+ import { refreshSavedThen } from "../_shared/himi-store-saved.js";
23
24
 
24
25
  const ALL = "all";
25
26
  const PAGE = 100;
@@ -481,6 +482,8 @@ function loadedState(s: S, arg?: unknown): S | undefined {
481
482
 
482
483
  async function load(s: S, arg?: unknown, fresh = false): Promise<S | undefined> {
483
484
  stashCopy(arg);
485
+ // Hearts follow the signed-in member's account wishlist, read beside the products.
486
+ refreshSavedThen(() => svc.savedChanged());
484
487
  const route = input(arg);
485
488
  const routeCategory = route.categoryId ?? route.category;
486
489
  if (!fresh && routeCategory && (
@@ -733,10 +736,13 @@ const svc = register<S, Record<string, A>>("himiBrandedShop", {
733
736
  if (query === s.query) return s;
734
737
  return derive({ ...s, query, ...(query.trim() === s.query.trim() ? {} : { visible: PAGE_SIZE, cursorEpoch: s.cursorEpoch + 1 }) });
735
738
  },
736
- toggleSave: (s, arg) => {
737
- try { toggleSaved(s.results, idOf(arg)); } catch { return s; }
738
- return derive(s);
739
+ toggleSave: async (s, arg): Promise<S> => {
740
+ try { await toggleSaved(s.results, idOf(arg)); } catch { return s; }
741
+ // The page as it is now: other actions may have run while the save was on the wire.
742
+ return derive(svc.getState() as S);
739
743
  },
744
+ // The signed-in member's saved list landed: re-mark the hearts.
745
+ savedChanged: (): S => derive(svc.getState() as S),
740
746
  ...facets,
741
747
  // The list view's load-more.
742
748
  loadMore: (s) => facets.showMore(s),
@@ -18,7 +18,7 @@ import { cleanTitle } from "../_shared/himi-text.js";
18
18
  import { stashCopy, copyParam, copyTemplate } from "../_shared/himi-copy.js";
19
19
  import { isBridgeUnavailable } from "../_shared/owner-load-error.js";
20
20
  import { logBi } from "../_shared/wix-bi.js";
21
- import { isProductSaved, toggleSavedProduct } from "../_shared/himi-store-saved.js";
21
+ import { isProductSaved, syncSavedProducts, toggleSavedProduct } from "../_shared/himi-store-saved.js";
22
22
  import { openRichLink } from "../_shared/rich-content-link.js";
23
23
  import { descriptionBody } from "../_shared/rich-body.js";
24
24
  import { PRODUCT_DETAIL_FIELDS, productInfoSections, type ProductInfoSection } from "../_shared/store-product-info.js";
@@ -85,6 +85,8 @@ function productPolicyBody(product: StoreProduct, kind: "returns" | "shipping"):
85
85
  * DIFFERENT product (drop the picks) from the same product coming back (keep them). */
86
86
  let lastLoadedId: string | undefined;
87
87
  let productLoadSequence = 0;
88
+ /** Bumped by every heart tap: a load that started before one never overwrites the saved state it set. */
89
+ let saveEpoch = 0;
88
90
 
89
91
  interface OptionSlots {
90
92
  opt1Label: string; opt1Chips: OptionChip[]; opt1Selected: string[]; opt1SelectedId: string; opt1Placeholder: string; noOpt1: boolean;
@@ -537,7 +539,7 @@ const svc = onlineService<S, {
537
539
  beginAdd: (s: S, arg?: unknown) => S;
538
540
  setCartCount: (s: S, arg?: unknown) => S;
539
541
  share: (s: S) => Promise<S>;
540
- toggleSave: (s: S) => S;
542
+ toggleSave: (s: S) => Promise<S>;
541
543
  closeAddedSheet: (s: S) => S;
542
544
  /** [rico] #3372 — RichContent's on_link: `{ url }` of the tapped link. */
543
545
  openLink: (s: S, arg?: unknown) => Promise<S>;
@@ -640,9 +642,15 @@ const svc = onlineService<S, {
640
642
  // A managed refresh retains the raw product used by the still-visible snapshot.
641
643
  // Navigation and legacy loaders keep their existing reset behavior.
642
644
  if (!readOptions(arg) || id !== lastLoadedId) lastProduct = undefined;
643
- // Storage problems must not prevent browsing or buying a product.
644
- let saved = false;
645
- try { saved = isProductSaved(id); } catch { /* save action reports a retryable error */ }
645
+ // Storage problems must not prevent browsing or buying a product. A signed-in member's heart
646
+ // follows their account wishlist, read beside the product so it never holds the page.
647
+ // A failed read still answers for whoever is signed in now (nothing saved for a member whose list
648
+ // could not be read), never the flag a previous member left on this pooled worker.
649
+ const savedNow = (): boolean => { try { return isProductSaved(id); } catch { return false; } };
650
+ const epoch = saveEpoch;
651
+ const savedRead = syncSavedProducts().then(savedNow, savedNow);
652
+ // Read after the sync began: until it knows who is signed in, nothing shows as saved.
653
+ const saved = savedNow();
646
654
  s = { ...s, saved, saveHint: "",
647
655
  optionValidationTarget: "",
648
656
  ...(id !== lastLoadedId ? { adding: false, added: false, shareHint: "", addedSheetPresented: false, quantity: 1, showOptionErrors: false, optionValidationRequest: 0, galleryIndex: 0, returnPolicyExpanded: false, shippingInfoExpanded: false, infoSections: [] } : {}) };
@@ -711,9 +719,12 @@ const svc = onlineService<S, {
711
719
  }
712
720
  }
713
721
  lastLoadedId = id;
722
+ const savedFlag = await savedRead;
723
+ if (sequence !== productLoadSequence || id !== inputId()) return svc.getState() as S;
714
724
  return derive({
715
725
  ...base,
716
726
  ...keep,
727
+ ...(epoch === saveEpoch ? { saved: savedFlag } : {}),
717
728
  status: "ready",
718
729
  optionGroups,
719
730
  selection: { ...defaultSelection(optionGroups), ...carried },
@@ -859,18 +870,24 @@ const svc = onlineService<S, {
859
870
  const confirmation = copyTemplate("product.cartHintAdded", "Added {name} to cart.", { name: s.name || "product" });
860
871
  return derive({ ...s, adding: false, added: true, addedSheetPresented: true, cartHint: `${confirmation}${quantity > 1 ? ` Qty: ${quantity}` : ""}`, cartCount: count || s.cartCount });
861
872
  },
862
- toggleSave: (s) => {
863
- if (s.status !== "ready" || !s.name || !inputId()) return s;
873
+ // A member's save goes to their account wishlist.
874
+ toggleSave: async (s) => {
875
+ const id = inputId();
876
+ if (s.status !== "ready" || !s.name || !id) return s;
877
+ saveEpoch++;
878
+ let result: { saved: boolean } | undefined;
864
879
  try {
865
880
  const sale = lastProduct ? productSale(lastProduct) : { price: s.commercePrice ?? "", wasPrice: "" };
866
- const saved = toggleSavedProduct({ id: inputId(), name: s.name, price: sale.price, wasPrice: sale.wasPrice, image: s.image,
867
- swatches: s.optionGroups.flatMap(g => g.kind === "color" ? g.choices.map(c => c.colorCode).filter(Boolean) : []).slice(0, 5) });
868
- return derive({ ...s, saved, saveHint: saved
869
- ? copyParam("product.saveSuccess", "Added to wishlist.")
870
- : copyParam("product.saveRemoved", "Removed from wishlist.") });
871
- } catch {
872
- return derive({ ...s, saveHint: copyParam("product.saveError", "Could not save this change. Try again.") });
873
- }
881
+ result = { saved: await toggleSavedProduct({ id, name: s.name, price: sale.price, wasPrice: sale.wasPrice, image: s.image,
882
+ swatches: s.optionGroups.flatMap(g => g.kind === "color" ? g.choices.map(c => c.colorCode).filter(Boolean) : []).slice(0, 5) }) };
883
+ } catch { /* reported below */ }
884
+ // Build on the page as it is now: the shopper may have changed the quantity meanwhile.
885
+ const now = svc.getState() as S;
886
+ if (inputId() !== id) return now;
887
+ if (!result) return derive({ ...now, saveHint: copyParam("product.saveError", "Could not save this change. Try again.") });
888
+ return derive({ ...now, saved: result.saved, saveHint: result.saved
889
+ ? copyParam("product.saveSuccess", "Added to wishlist.")
890
+ : copyParam("product.saveRemoved", "Removed from wishlist.") });
874
891
  },
875
892
  share: async (s) => {
876
893
  if (!s.name) return s;
@@ -1,6 +1,6 @@
1
1
  import { withIapPresentation } from "../_shared/iap-presentation.js";
2
2
  import { withEmptyFlags } from "../_shared/empty-flags.js";
3
- import { readSavedProducts, removeSavedProduct, type SavedProduct } from "../_shared/himi-store-saved.js";
3
+ import { listSavedProducts, removeSavedProduct, type SavedProduct } from "../_shared/himi-store-saved.js";
4
4
  import { stashCopy, copyParam } from "../_shared/himi-copy.js";
5
5
 
6
6
  interface Row extends SavedProduct {
@@ -23,8 +23,8 @@ interface S {
23
23
  function shape(s: Pick<S, "status" | "rows" | "error">): S {
24
24
  return { ...s, isLoading: s.status === "loading", notLoading: s.status !== "loading", notErrored: s.status !== "error", noEmpty: s.status !== "ready" || s.rows.length > 0, hasRows: s.rows.length > 0, emptyText: copyParam("savedProducts.empty", "Tap the heart on a product to add it to your wishlist.") };
25
25
  }
26
- function loadRows(): Row[] {
27
- return readSavedProducts().map(row => {
26
+ function toRows(saved: SavedProduct[]): Row[] {
27
+ return saved.map(row => {
28
28
  const swatches = (row.swatches ?? []).filter(value => /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(value)).slice(0, 5);
29
29
  return { ...row, commercePrice: row.price, initial: row.name.slice(0, 1).toUpperCase(), hasImage: !!row.image, noImage: !row.image,
30
30
  detailScreenId: "himi_product", notOnSale: !row.wasPrice, wasPriceEmpty: !!row.wasPrice, noSwatches: swatches.length === 0, noTagRow: !row.wasPrice && swatches.length === 0,
@@ -45,23 +45,42 @@ const defineService = withIapPresentation<S>({
45
45
  return { ...row, price: next, wasPriceEmpty: !!row.wasPrice && !iapAdjusted, notOnSale: !row.wasPrice || iapAdjusted, noTagRow: (!row.wasPrice || iapAdjusted) && !row.swatches?.length };
46
46
  }) }),
47
47
  });
48
+ let reads = 0;
48
49
  const svc = defineService<S, {
49
- load: (s: S, arg?: unknown) => S;
50
- remove: (s: S, arg?: unknown) => S;
50
+ load: (s: S, arg?: unknown) => Promise<S | undefined>;
51
+ remove: (s: S, arg?: unknown) => Promise<S | undefined>;
51
52
  }>("himiStoreSaved", withEmptyFlags({
52
53
  state: shape({ status: "loading", rows: [], error: "" }),
53
54
  actions: {
54
- load: (s, arg) => {
55
+ // A signed-in member's list is their account wishlist; a visitor's is this device's.
56
+ // Only the latest read lands: one started before a sign-out never paints over the one after it.
57
+ load: async (s, arg) => {
55
58
  stashCopy(arg);
56
- try { return shape({ status: "ready", rows: loadRows(), error: "" }); }
57
- catch { return failed(s); }
59
+ const read = ++reads;
60
+ try {
61
+ const rows = toRows(await listSavedProducts());
62
+ return read === reads ? shape({ status: "ready", rows, error: "" }) : undefined;
63
+ }
64
+ // A failed read never keeps rows that may belong to whoever was signed in before.
65
+ catch { return read === reads ? failed(shape({ ...s, rows: [] })) : undefined; }
58
66
  },
59
- remove: (s, arg) => {
67
+ remove: async (s, arg) => {
60
68
  const id = typeof arg === "string" ? arg : String((arg as { id?: unknown } | undefined)?.id ?? "");
69
+ // A member change re-reads the list for whoever is signed in now.
70
+ let removed = true;
71
+ try { await removeSavedProduct(id); }
72
+ // Only a member change re-reads the list; a refusal for the same member is a failed remove, and says so.
73
+ catch (error) { if ((error as { name?: string } | null)?.name !== "MemberAccessChanged") return failed(s); removed = false; }
74
+ const read = ++reads;
61
75
  try {
62
- removeSavedProduct(id);
63
- return shape({ status: "ready", rows: loadRows(), error: "" });
64
- } catch { return failed(s); }
76
+ const rows = toRows(await listSavedProducts());
77
+ return read === reads ? shape({ status: "ready", rows, error: "" }) : undefined;
78
+ } catch (error) {
79
+ if (read !== reads) return undefined;
80
+ if (!removed || (error as { name?: string } | null)?.name === "MemberAccessChanged") return failed(shape({ ...s, rows: [] }));
81
+ // The remove landed: drop the row even when the list cannot be read again.
82
+ return shape({ ...s, status: "ready", rows: s.rows.filter(row => row.id !== id), error: "" });
83
+ }
65
84
  },
66
85
  },
67
86
  }, { rows: "noRows" }));