@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
@@ -27,6 +27,21 @@ export function hasIntl(): boolean {
27
27
  return typeof Intl !== "undefined";
28
28
  }
29
29
 
30
+ /** ECMA-402's first day of the week for `locale` (1 = Monday … 7 = Sunday), or undefined where this engine has no
31
+ * `Intl.Locale` week info (QuickJS has no `Intl`; older JSC / V8 / Hermes have no week info). Callers keep a CLDR table for
32
+ * that case, so every engine starts the same week (`weekly-goal.ts` `firstWeekdayOf`). */
33
+ export function intlFirstDayOfWeek(locale: string): number | undefined {
34
+ try {
35
+ // The guard form `worker-globals:check` reads as guarded: the `Intl` use sits inside the `typeof` test's block.
36
+ if (typeof Intl !== "undefined" && typeof Intl.Locale === "function") {
37
+ const loc = new Intl.Locale(locale) as Intl.Locale & { getWeekInfo?: () => { firstDay?: number }; weekInfo?: { firstDay?: number } };
38
+ const firstDay = (typeof loc.getWeekInfo === "function" ? loc.getWeekInfo() : loc.weekInfo)?.firstDay;
39
+ if (typeof firstDay === "number" && Number.isInteger(firstDay) && firstDay >= 1 && firstDay <= 7) return firstDay;
40
+ }
41
+ } catch { /* a malformed tag */ }
42
+ return undefined;
43
+ }
44
+
30
45
  /** The device's IANA time zone, or "UTC" where this engine has no ECMA-402 or no zone data. */
31
46
  export function deviceTimeZone(): string {
32
47
  try {
@@ -536,3 +551,53 @@ export function formatTimeZoneLabel(date: Date, timeZone: string, locale = "en")
536
551
  }
537
552
  return "";
538
553
  }
554
+
555
+ // ── The first day of the week ──────────────────────────────────────────────────────────────────────────────────────────────
556
+ // 0 = Sunday … 6 = Saturday, for the app language: the one rule every weekly count and every week a screen shows uses
557
+ // (`weekly-goal.ts`, the performance tracker, the Agenda's descriptor, the one-app generator). CLDR week data: Sunday for "en" /
558
+ // "en-US", Monday for "en-GB" or "de", Saturday for "ar-EG". ECMA-402 week info where the engine has it (`intlFirstDayOfWeek`),
559
+ // a CLDR table where it has not, so iOS, Android, web and a build host agree. It lives here rather than in its own file because
560
+ // every generated template already ships this module, and the public catalog's manifest lists each template file.
561
+
562
+ /** 0 = Sunday … 6 = Saturday, as `Date.prototype.getDay`. */
563
+ export type Weekday = 0 | 1 | 2 | 3 | 4 | 5 | 6;
564
+ export const MONDAY: Weekday = 1;
565
+
566
+ // CLDR `weekData.firstDay` (supplemental data), by region: every region not listed starts on Monday.
567
+ const SUNDAY_REGIONS = new Set("AG AS BD BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP PA PE PH PK PR PT PY SA SG SV TH TT TW UM US VE VI WS YE ZA ZW".split(" "));
568
+ const SATURDAY_REGIONS = new Set("AE AF BH DJ DZ EG IQ IR JO KW LY OM QA SD SY".split(" "));
569
+ const FRIDAY_REGIONS = new Set(["MV"]);
570
+ // The region CLDR's likely subtags give a bare language, for the languages whose region does not start on Monday.
571
+ const LIKELY_REGION: Record<string, string> = {
572
+ en: "US", he: "IL", iw: "IL", ar: "EG", pt: "BR", ja: "JP", zh: "CN", ko: "KR", hi: "IN", bn: "BD", th: "TH", id: "ID",
573
+ fa: "IR", ur: "PK", my: "MM", km: "KH", lo: "LA", ne: "NP", am: "ET", mr: "IN", ta: "IN", te: "IN", gu: "IN", kn: "IN",
574
+ ml: "IN", pa: "IN", fil: "PH", tl: "PH", zu: "ZA", dz: "BT", dv: "MV", ps: "AF",
575
+ };
576
+
577
+ /** The region of a language tag ("en-GB" → "GB", "zh-Hant-TW" → "TW"), else its language's likely region, else "". */
578
+ function regionOf(locale: string): string {
579
+ const parts = locale.split(/[-_]/);
580
+ const region = parts.slice(1).find((p) => /^(?:[A-Za-z]{2}|\d{3})$/.test(p));
581
+ if (region) return region.toUpperCase();
582
+ // A script with no region: Traditional Chinese is Taiwan's.
583
+ if (parts[0]?.toLowerCase() === "zh" && parts.some((p) => p.toLowerCase() === "hant")) return "TW";
584
+ return LIKELY_REGION[(parts[0] ?? "").toLowerCase()] ?? "";
585
+ }
586
+
587
+ /** The first day of the week for `locale` (the app language by default). */
588
+ export function firstWeekdayOf(locale: string = appLocale()): Weekday {
589
+ // ECMA-402 numbers the days 1 = Monday … 7 = Sunday. A malformed tag or an engine without week info: the CLDR table below.
590
+ const firstDay = intlFirstDayOfWeek(locale);
591
+ if (firstDay !== undefined) return (firstDay % 7) as Weekday;
592
+ const region = regionOf(locale);
593
+ if (SUNDAY_REGIONS.has(region)) return 0;
594
+ if (SATURDAY_REGIONS.has(region)) return 6;
595
+ if (FRIDAY_REGIONS.has(region)) return 5;
596
+ return MONDAY;
597
+ }
598
+
599
+ /** A screen's `firstWeekday` param (0..6, or its text) when it pins one, else the app language's first day. */
600
+ export function resolveFirstWeekday(raw?: unknown, locale: string = appLocale()): Weekday {
601
+ const n = typeof raw === "number" ? raw : typeof raw === "string" && raw.trim() !== "" ? Number(raw) : NaN;
602
+ return Number.isInteger(n) && n >= 0 && n <= 6 ? (n as Weekday) : firstWeekdayOf(locale);
603
+ }
@@ -456,12 +456,12 @@ function selectedId(arg: unknown): string {
456
456
  return String((arg as { selectedId?: unknown } | undefined)?.selectedId ?? "");
457
457
  }
458
458
 
459
- /** Toggle one card's saved state in the shared saved-products store. Throws when
460
- * storage fails, so the caller keeps its state and the heart never lies. */
461
- export function toggleSaved(cards: ProductCard[], id: string): void {
459
+ /** Toggle one card's saved state in the shared saved-products store (a member's account wishlist).
460
+ * Throws when the write fails, so the caller keeps its state and the heart never lies. */
461
+ export async function toggleSaved(cards: ProductCard[], id: string): Promise<void> {
462
462
  const card = cards.find((c) => c.id === id);
463
463
  if (!card) return;
464
- toggleSavedProduct({ id: card.id, name: card.name, price: card.commercePrice || card.price, image: card.image,
464
+ await toggleSavedProduct({ id: card.id, name: card.name, price: card.commercePrice || card.price, image: card.image,
465
465
  wasPrice: card.commerceWasPrice ?? card.wasPrice,
466
466
  swatches: [card.swatch1, card.swatch2, card.swatch3, card.swatch4, card.swatch5].filter(Boolean) });
467
467
  }
@@ -1,5 +1,20 @@
1
- // Saved products use the host's durable, app-scoped KV, shared by screen workers.
1
+ // Saved products ("wishlist"). A signed-in member's list is their Wix account wishlist (eCommerce
2
+ // Wishlists, the list the Wix site and the One App show), so a product saved anywhere shows here.
3
+ // A visitor's list stays on this device in the host's durable, app-scoped KV, shared by screen workers.
4
+ // The two never mix: a member never sees the device list, and signing in copies nothing to the account.
2
5
  // Adapted from Hip Shop; a failed write must never claim that a save succeeded.
6
+ //
7
+ // Each worker keeps the member's list as last read (`syncSavedProducts`), so the synchronous readers
8
+ // (`readSavedProducts`, `isProductSaved`) answer for whoever was signed in at that read. Call
9
+ // `syncSavedProducts` in a load before reading, and `listSavedProducts` where the list is shown.
10
+ import { addWishlistItem, getDefaultWishlist, removeWishlistItem, type WixWishlist, type WixWishlistCatalogReference } from "@himalaya/wix-ecom";
11
+ import { productImage, productPrice, searchStoreProducts, type StoreProduct } from "./himi-store.js";
12
+ import { cleanTitle } from "./himi-text.js";
13
+ // The identity read is `member-access.ts`'s, inlined: that module imports @himalaya/wix-users, which node (tests
14
+ // importing shared sources) cannot resolve, so its legacy rung calls the same route through the ecom bridge.
15
+ import { dispatch } from "@himalaya/dispatch";
16
+ import { wixCall } from "@himalaya/wix-ecom";
17
+
3
18
  export interface SavedProduct {
4
19
  id: string;
5
20
  name: string;
@@ -10,13 +25,19 @@ export interface SavedProduct {
10
25
  }
11
26
  type StorageLike = { getItem(key: string): string | null; setItem(key: string, value: string): void };
12
27
  const KEY = "himi-store:saved-products:v1";
28
+ /** The Wix Stores app id. The One App and the account wishlist hold Stores products under it. */
29
+ const STORES_APP_ID = "1380b703-ce81-ff05-f115-39571d94dfcd";
30
+ /** The Stores catalog id eCommerce uses in cart and order references: a product saved under it is a Stores product too. */
31
+ const STORES_CATALOG_ID = "215238eb-22a5-4c36-9e7b-e7c08025e04e";
32
+ const STORES_APPS = new Set([STORES_APP_ID, STORES_CATALOG_ID]);
33
+
13
34
  function storage(): StorageLike {
14
35
  const host = globalThis as { himalaya?: { storage?: StorageLike }; localStorage?: StorageLike };
15
36
  const kv = host.himalaya?.storage ?? host.localStorage;
16
37
  if (!kv) throw new Error("Saved-product storage is unavailable");
17
38
  return kv;
18
39
  }
19
- export function readSavedProducts(): SavedProduct[] {
40
+ function readDeviceProducts(): SavedProduct[] {
20
41
  const raw = storage().getItem(KEY);
21
42
  if (!raw) return [];
22
43
  const parsed: unknown = JSON.parse(raw);
@@ -34,10 +55,7 @@ export function readSavedProducts(): SavedProduct[] {
34
55
  }
35
56
  return [...rows.values()];
36
57
  }
37
- export function isProductSaved(id: string): boolean {
38
- return readSavedProducts().some(row => row.id === id);
39
- }
40
- export function writeSavedProducts(rows: SavedProduct[]): void {
58
+ function writeDeviceProducts(rows: SavedProduct[]): void {
41
59
  const kv = storage();
42
60
  const value = JSON.stringify(rows);
43
61
  kv.setItem(KEY, value);
@@ -45,13 +63,257 @@ export function writeSavedProducts(rows: SavedProduct[]): void {
45
63
  // before displaying success; a missing/mismatched read is a failed save.
46
64
  if (kv.getItem(KEY) !== value) throw new Error("Saved-product write did not persist");
47
65
  }
48
- export function toggleSavedProduct(product: SavedProduct): boolean {
49
- if (!product.id.trim() || !product.name.trim()) throw new Error("No product to save");
50
- const rows = readSavedProducts();
51
- const saved = !rows.some(row => row.id === product.id);
52
- writeSavedProducts(saved ? [product, ...rows] : rows.filter(row => row.id !== product.id));
66
+
67
+ // ---- The signed-in member's account wishlist, as this worker last read it ----
68
+
69
+ interface MemberList {
70
+ /** Whose list: the site partition and the member, from `currentKey`. */
71
+ key: string;
72
+ /** Saved product ids, newest first. */
73
+ ids: string[];
74
+ /** The references each id is saved under: a variant saved on the website is its own item. */
75
+ refs: Map<string, WixWishlistCatalogReference[]>;
76
+ /** Product details for the ids, from the catalog or from the control that saved it. */
77
+ details: Map<string, SavedProduct>;
78
+ }
79
+ /** Whose list this worker answers, from its last read. Until a read says, nothing is saved: the device
80
+ * list may be a visitor's, and must never show for a member. */
81
+ let mode: "device" | "member" | undefined;
82
+ let member: MemberList | undefined;
83
+ /** Identity reads in flight. While one is, the synchronous readers answer nothing: the cached list may be
84
+ * the previous member's, or a visitor's, and a grid deriving its hearts now must not show it to whoever
85
+ * signed in since. */
86
+ let resolving = 0;
87
+ /** The newest `syncSavedProducts` call. An older read that lands after it never applies its answer. */
88
+ let syncGen = 0;
89
+ let latestSync: Promise<void> | undefined;
90
+ /** Bumped by every account write: a read that started before one never overwrites what it changed. */
91
+ let memberWrites = 0;
92
+ /** A toggle per product at a time: a second tap while the first is on the wire would read the same state. */
93
+ const toggles = new Map<string, Promise<boolean>>();
94
+
95
+ /** The error `member-access.ts`'s `memberAccessDenied` recognizes: the member changed under a read or write. */
96
+ function memberAccessChanged(): Error {
97
+ const error = new Error("Member access changed"); error.name = "MemberAccessChanged"; return error;
98
+ }
99
+ /** The member's email from the host, or "" for a visitor. A host without the identity action (an older
100
+ * binary) or one that fails it falls back, as `memberAccess` does, to the signed-in profile: only a 401 there
101
+ * says "visitor". Any other failure throws, so it is never read as a visitor and never answers the device list. */
102
+ async function signedInEmail(): Promise<{ signedIn: boolean; email: string }> {
103
+ type Identity = { status?: unknown; ok?: unknown; email?: unknown; signedIn?: unknown; payload?: { email?: unknown; signedIn?: unknown } } | null;
104
+ try {
105
+ const value = await dispatch("himi.wix.memberIdentity") as Identity;
106
+ if (value?.status === "error" || value?.ok === false) throw value;
107
+ const raw = value?.email ?? value?.payload?.email;
108
+ const email = typeof raw === "string" ? raw.trim().toLowerCase() : "";
109
+ return { signedIn: (value?.signedIn ?? value?.payload?.signedIn) === true || !!email, email };
110
+ } catch { /* the legacy rung below */ }
111
+ // No Wix bridge, no Wix session: nobody can be signed in.
112
+ if (!(globalThis as { himalaya?: { wixApi?: unknown } }).himalaya?.wixApi) return { signedIn: false, email: "" };
113
+ try {
114
+ const profile = await wixCall<{ email?: unknown; contactEmail?: unknown }>("GET", "https://users.wix.com/wix-users/v1/users/my-data?includeProfile=true");
115
+ const raw = profile?.email ?? profile?.contactEmail;
116
+ const email = typeof raw === "string" ? raw.trim().toLowerCase() : "";
117
+ return { signedIn: !!email, email };
118
+ } catch (error) {
119
+ const failure = error as { status?: unknown; statusCode?: unknown; code?: unknown; message?: unknown } | null;
120
+ const anonymous = failure?.status === 401 || failure?.statusCode === 401 || failure?.code === "UNAUTHENTICATED"
121
+ || /^HTTP\s*401\b/i.test(String(failure?.message ?? ""));
122
+ // A web bridge refuses the owner-scoped profile route outright (`webwix_owner_only`): that host cannot tell
123
+ // through this rung, as `memberAccess` reads it too, so its session is a visitor's, never an error.
124
+ const ownerOnly = failure?.code === "webwix_owner_only";
125
+ if (anonymous || ownerOnly) return { signedIn: false, email: "" };
126
+ throw new Error("Who is signed in could not be read", { cause: error });
127
+ }
128
+ }
129
+ /** Who is signed in, as a key for their list: the host's account and site partition plus the member's
130
+ * email; undefined for a visitor. Throws when it cannot tell. */
131
+ async function currentKey(): Promise<string | undefined> {
132
+ const { signedIn, email } = await signedInEmail();
133
+ if (!signedIn) return undefined;
134
+ const input = (globalThis as { himalaya?: { input?: Record<string, unknown> } }).himalaya?.input;
135
+ return JSON.stringify([input?.__himiPreferenceAccount ?? "", input?.__himiPreferenceBusiness ?? "", email]);
136
+ }
137
+ async function assertKey(key: string): Promise<void> {
138
+ if ((await currentKey()) !== key) throw memberAccessChanged();
139
+ }
140
+
141
+ function applyWishlist(key: string, wishlist: WixWishlist | undefined): void {
142
+ const items = [...(wishlist?.items ?? [])].sort((a, b) => Date.parse(b.addedDate ?? "") - Date.parse(a.addedDate ?? "") || 0);
143
+ const refs = new Map<string, WixWishlistCatalogReference[]>();
144
+ for (const item of items) {
145
+ const ref = item.catalogReference;
146
+ const id = typeof ref?.catalogItemId === "string" ? ref.catalogItemId.trim() : "";
147
+ if (!id || !STORES_APPS.has(ref?.appId ?? "")) continue;
148
+ refs.set(id, [...(refs.get(id) ?? []), ref!]);
149
+ }
150
+ const details = member?.key === key ? member.details : new Map<string, SavedProduct>();
151
+ member = { key, ids: [...refs.keys()], refs, details };
152
+ }
153
+
154
+ /**
155
+ * Resolve who is signed in and, for a member, read their account wishlist. A visitor's reads then
156
+ * answer the device list. Throws when the member's wishlist cannot be read; the synchronous readers
157
+ * then answer nothing for that member (never the device list), so a heart shows unsaved until a retry.
158
+ * A read that finishes after the member changed is read again for whoever is signed in now.
159
+ */
160
+ export function syncSavedProducts(): Promise<void> {
161
+ const gen = ++syncGen;
162
+ const run = runSync(gen);
163
+ latestSync = run;
164
+ return run;
165
+ }
166
+ async function runSync(gen: number): Promise<void> {
167
+ let memberChanged = false;
168
+ for (let attempt = 0; attempt < 3; attempt++) {
169
+ let key: string | undefined;
170
+ resolving++;
171
+ try {
172
+ // Unknown identity: nothing is answered (never the device list) until a read can tell.
173
+ try { key = await currentKey(); } catch (error) { mode = undefined; member = undefined; throw error; }
174
+ if (key === undefined) { mode = "device"; member = undefined; return; }
175
+ mode = "member";
176
+ if (member?.key !== key) member = { key, ids: [], refs: new Map(), details: new Map() };
177
+ } finally { resolving--; }
178
+ const writes = memberWrites;
179
+ const { wishlist } = await getDefaultWishlist();
180
+ // A newer read started while this one was on the wire: its answer is the newer one. Wait for it.
181
+ if (gen !== syncGen && latestSync) return latestSync;
182
+ memberChanged = (await currentKey()) !== key;
183
+ // A save that landed while this read was on the wire is newer than it: read again.
184
+ if (memberChanged || writes !== memberWrites) continue;
185
+ applyWishlist(key, wishlist);
186
+ return;
187
+ }
188
+ throw memberChanged ? memberAccessChanged() : new Error("Saved products changed while they were read");
189
+ }
190
+
191
+ function detailsOf(p: StoreProduct): SavedProduct {
192
+ const name = cleanTitle(p.name ?? "") || "Product";
193
+ return { id: p.id ?? "", name, price: productPrice(p), image: productImage(p) };
194
+ }
195
+
196
+ /** The saved list as the saved-products screen and the wishlist sections show it. A member's ids come
197
+ * from their account wishlist and the details from the catalog; a product the store no longer has is
198
+ * left out. A visitor's list is the device list. */
199
+ export async function listSavedProducts(): Promise<SavedProduct[]> {
200
+ await syncSavedProducts();
201
+ if (mode !== "member" || !member) return readDeviceProducts();
202
+ const list = member;
203
+ if (list.ids.length) {
204
+ // A wishlist holds at most 100 items: one page. Fresh details every time, so a price change shows.
205
+ const { products } = await searchStoreProducts({ ids: list.ids, limit: 100 });
206
+ await assertKey(list.key);
207
+ const found = new Map((products ?? []).map(p => [p.id ?? "", p]));
208
+ for (const id of list.ids) {
209
+ const product = found.get(id);
210
+ if (product) list.details.set(id, { ...list.details.get(id), ...detailsOf(product) });
211
+ else list.details.delete(id);
212
+ }
213
+ }
214
+ return list.ids.flatMap(id => list.details.get(id) ?? []);
215
+ }
216
+
217
+ /** The saved list as this worker last read it (see `syncSavedProducts`): empty before the first read.
218
+ * A member's product whose details were never read has an empty name: read ids from it, list with
219
+ * `listSavedProducts`. */
220
+ export function readSavedProducts(): SavedProduct[] {
221
+ if (mode === undefined || resolving > 0) return [];
222
+ if (mode === "member") {
223
+ const list = member;
224
+ if (!list) return [];
225
+ return list.ids.map(id => list.details.get(id) ?? { id, name: "", price: "", image: "" });
226
+ }
227
+ return readDeviceProducts();
228
+ }
229
+ export function isProductSaved(id: string): boolean {
230
+ if (mode === undefined || resolving > 0) return false;
231
+ if (mode === "member") return !!member?.ids.includes(id);
232
+ return readDeviceProducts().some(row => row.id === id);
233
+ }
234
+
235
+ async function memberKeyForWrite(): Promise<string | undefined> {
236
+ const key = await currentKey();
237
+ if (key === undefined) { mode = "device"; member = undefined; return undefined; }
238
+ if (mode !== "member" || member?.key !== key) await syncSavedProducts();
239
+ if (member?.key !== key) throw memberAccessChanged();
240
+ return key;
241
+ }
242
+
243
+ /** Save or unsave one product in the member's account wishlist. The control's own state is not trusted:
244
+ * an unsave removes every reference the product is saved under. Throws when the member changed during
245
+ * the write, so the caller reloads for whoever is signed in now. */
246
+ async function writeMemberProduct(key: string, product: SavedProduct, saved: boolean): Promise<void> {
247
+ const list = member!;
248
+ const refs = saved ? [{ catalogItemId: product.id, appId: STORES_APP_ID }] : list.refs.get(product.id) ?? [{ catalogItemId: product.id, appId: STORES_APP_ID }];
249
+ let wishlist: WixWishlist | undefined;
250
+ memberWrites++;
251
+ try {
252
+ for (const ref of refs) wishlist = (saved ? await addWishlistItem(ref) : await removeWishlistItem(ref)).wishlist ?? wishlist;
253
+ } catch (error) {
254
+ // A refusal that lands after the member changed is the member change, so the caller reloads for whoever
255
+ // is signed in now; for the same member it is a failed write.
256
+ if ((await currentKey().catch(() => undefined)) !== key) throw memberAccessChanged();
257
+ throw error;
258
+ }
259
+ await assertKey(key);
260
+ if (wishlist) applyWishlist(key, wishlist);
261
+ else if (saved) { list.ids = [product.id, ...list.ids.filter(id => id !== product.id)]; list.refs.set(product.id, refs); }
262
+ else { list.ids = list.ids.filter(id => id !== product.id); list.refs.delete(product.id); }
263
+ if (saved && product.name.trim()) member!.details.set(product.id, product);
264
+ }
265
+
266
+ /** Replace the whole saved list (a collection's multi-select save). A member's account wishlist gets
267
+ * only the difference; a visitor's device list is written as given. */
268
+ export async function writeSavedProducts(rows: SavedProduct[]): Promise<void> {
269
+ const key = await memberKeyForWrite();
270
+ if (key === undefined) { writeDeviceProducts(rows); return; }
271
+ const wanted = new Map(rows.map(row => [row.id, row]));
272
+ for (const id of [...member!.ids]) if (!wanted.has(id)) await writeMemberProduct(key, { id, name: "", price: "", image: "" }, false);
273
+ for (const row of [...rows].reverse()) if (!member!.ids.includes(row.id)) await writeMemberProduct(key, row, true);
274
+ }
275
+
276
+ /** Save or unsave a product; answers the new saved state. A member's save is in their account wishlist. */
277
+ export function toggleSavedProduct(product: SavedProduct): Promise<boolean> {
278
+ if (!product.id.trim() || !product.name.trim()) return Promise.reject(new Error("No product to save"));
279
+ const pending = toggles.get(product.id);
280
+ if (pending) return pending;
281
+ const toggle = toggleOnce(product).finally(() => toggles.delete(product.id));
282
+ toggles.set(product.id, toggle);
283
+ return toggle;
284
+ }
285
+ async function toggleOnce(product: SavedProduct): Promise<boolean> {
286
+ const key = await memberKeyForWrite();
287
+ if (key === undefined) {
288
+ const rows = readDeviceProducts();
289
+ const saved = !rows.some(row => row.id === product.id);
290
+ writeDeviceProducts(saved ? [product, ...rows] : rows.filter(row => row.id !== product.id));
291
+ return saved;
292
+ }
293
+ const saved = !member!.ids.includes(product.id);
294
+ await writeMemberProduct(key, product, saved);
53
295
  return saved;
54
296
  }
55
- export function removeSavedProduct(id: string): void {
56
- writeSavedProducts(readSavedProducts().filter(row => row.id !== id));
297
+ export async function removeSavedProduct(id: string): Promise<void> {
298
+ const key = await memberKeyForWrite();
299
+ if (key === undefined) { writeDeviceProducts(readDeviceProducts().filter(row => row.id !== id)); return; }
300
+ await writeMemberProduct(key, { id, name: "", price: "", image: "" }, false);
301
+ }
302
+
303
+ /** Tests only: forget the member list this worker read. */
304
+ export function __resetSavedProductsForTests(): void { mode = undefined; member = undefined; toggles.clear(); }
305
+
306
+ /** Read the saved list in the background and, when the saved ids changed, run `apply` (a grid's re-derive of
307
+ * its CURRENT state), so hearts follow the signed-in member without holding the page. A failed read leaves the
308
+ * hearts as the last read left them (unsaved for a member never read). */
309
+ export function refreshSavedThen(apply: () => unknown): void {
310
+ // Storage a host does not offer is no saved product: hearts are optional, a failure never fails the screen.
311
+ const ids = () => { try { return JSON.stringify(readSavedProducts().map(row => row.id)); } catch { return "[]"; } };
312
+ const whose = () => `${mode ?? ""}:${member?.key ?? ""}`;
313
+ // Snapshot BEFORE the sync starts: once it does, the readers answer nothing until it knows who is signed in.
314
+ const before = ids(), beforeWhose = whose();
315
+ // Re-derive whenever a grid may show something else now: the list or its owner changed, or there are saves
316
+ // (a grid that derived while the identity read was in flight drew none). Only "nothing, as before" skips it.
317
+ const settle = () => { const now = ids(); if (now !== before || whose() !== beforeWhose || now !== "[]") apply(); };
318
+ void syncSavedProducts().then(settle, settle);
57
319
  }
@@ -2,7 +2,9 @@
2
2
  // (this week's range, "N of G sessions this week", a progress ring), their weeks of meeting the goal and their sessions in total. The source
3
3
  // reads a private fitness service; this reads the same member-scoped bookings as My Bookings (himi_bookings) and counts with the
4
4
  // same rule as its "This week" card (`weekly-goal.ts`: a CONFIRMED booking that already took place; Wix attendance is owner-scoped,
5
- // so a no-show still counts), so a guest or a refused member gets the sign-in state instead of a read.
5
+ // so a no-show still counts), so a guest or a refused member gets the sign-in state instead of a read. Because no number here is
6
+ // attendance, the all-time row reads "All-time sessions", never the source's "Sessions attended in total".
7
+ // The week starts on the app language's first day (`resolveFirstWeekday`), as the source's does; a load's `firstWeekday` pins another.
6
8
  // goal -> the default weekly goal (the source's `defaultWeeklyGoal`). A member picks their own from 1 to 14 in a sheet with a number wheel, as in
7
9
  // the source; it is kept on this device under the member's key (`performance-tracker-goal.ts`), because the source's goal lives in a
8
10
  // private service a member's session cannot call. A visitor keeps the default and is asked to sign in to change it,
@@ -10,11 +12,11 @@
10
12
  // A page worker registers it under a service name; the descriptor binds `$service:<serviceName>.*` (recipe performance-tracker.json).
11
13
  import { defineService } from "@himalaya/state";
12
14
  import { hostSessionFromGlobal } from "@himalaya/iap";
13
- import { copyPlural, stashCopy } from "./himi-copy.js";
15
+ import { copyParam, copyPlural, stashCopy } from "./himi-copy.js";
14
16
  import { formatNumber } from "./engine-intl.js";
15
17
  import { fetchMemberBookings } from "./member-bookings.js";
16
18
  import { memberAccess, memberAccessDenied, memberChanged } from "./member-access.js";
17
- import { parseWeeklyGoal, weeklyGoalProgress } from "./weekly-goal.js";
19
+ import { parseWeeklyGoal, resolveFirstWeekday, weeklyGoalProgress, type Weekday } from "./weekly-goal.js";
18
20
  import { canKeepGoal, goalChoices, goalOwner, pickableGoal, readMemberGoal, saveMemberGoal, type GoalStore } from "./performance-tracker-goal.js";
19
21
  import { DEFAULT_WEEKLY_GOAL, MAX_ALL_TIME_SESSIONS, MAX_PAGES, allTimeSessions, sessionsInWeek, streakMayBeLonger, weekRange, weeklyStreak } from "./performance-tracker-weeks.js";
20
22
  import type { MemberBookingRow } from "./member-bookings.js";
@@ -32,7 +34,7 @@ export interface PerformanceTrackerState {
32
34
  status: "loading" | "ready" | "error";
33
35
  /** A guest, or a member Wix refused: the section asks to sign in instead of reading. */
34
36
  signedOut: boolean;
35
- /** "Nov 16 - Nov 22". */
37
+ /** "Nov 22 - Nov 28": the week's first to last day. */
36
38
  weekRange: string;
37
39
  /** "1 of 2 sessions this week". */
38
40
  goalLabel: string;
@@ -50,7 +52,7 @@ export interface PerformanceTrackerState {
50
52
  goalLocked: boolean; goalUnlocked: boolean;
51
53
  /** "Weeks of meeting my goal": the count, then its label ("Week of..." for one). */
52
54
  streak: string; streakLabel: string;
53
- /** "500+" past the source's cap, then "Sessions attended in total". */
55
+ /** "500+" past the source's cap, then "All-time sessions" (booked and held, not attended: no check-in is readable). */
54
56
  total: string; totalLabel: string;
55
57
  notLoading: boolean; notErrored: boolean; notSignedOut: boolean;
56
58
  /** Nothing to show yet: loading, failed or signed out. */
@@ -64,17 +66,18 @@ export function registerPerformanceTrackerSection(serviceName: string, options:
64
66
  const showTotal = options.showTotal !== false;
65
67
  const sessionsLabel = (n: number): string => copyPlural("performanceTracker.goalSessions", "{n, plural, one {# Session} other {# Sessions}}", n);
66
68
  const weeksLabel = (n: number): string => copyPlural("performanceTracker.weeksMeetingGoal", "{n, plural, one {Week of meeting my goal} other {Weeks of meeting my goal}}", n);
67
- const attendedLabel = (n: number): string => copyPlural("performanceTracker.sessionsAttended", "{n, plural, one {Session attended in total} other {Sessions attended in total}}", n);
69
+ // Not the source's "Sessions attended in total": the count is of sessions booked and held, and a member cannot read a check-in.
70
+ const totalSessionsLabel = (): string => copyParam("performanceTracker.allTimeSessions", "All-time sessions");
68
71
  const blank = {
69
72
  goalLabel: "", remainingLabel: "", progress: 0, ringText: "", streak: "", total: "",
70
73
  goalOptions: [] as GoalOption[], goalDraft: "", goalValue: "", goalSessions: "", goalOpen: false, goalLocked: false, goalUnlocked: true,
71
74
  streakLabel: "", totalLabel: "",
72
75
  };
73
- const view = (status: PerformanceTrackerState["status"], signedOut: boolean, fields: Partial<typeof blank> = {}, now?: number): PerformanceTrackerState => {
76
+ const view = (status: PerformanceTrackerState["status"], signedOut: boolean, fields: Partial<typeof blank> = {}, week?: { now: number; firstWeekday: Weekday }): PerformanceTrackerState => {
74
77
  const noContent = !(status === "ready" && !signedOut);
75
78
  return {
76
79
  // No clock read at registration (a worker boots deterministically): the range is set by the load.
77
- status, signedOut, weekRange: now === undefined ? "" : weekRange(now), ...blank, ...fields,
80
+ status, signedOut, weekRange: week === undefined ? "" : weekRange(week.now, week.firstWeekday), ...blank, ...fields,
78
81
  notLoading: status !== "loading", notErrored: status !== "error", notSignedOut: !signedOut,
79
82
  noContent, noTotal: noContent || !showTotal,
80
83
  };
@@ -85,33 +88,38 @@ export function registerPerformanceTrackerSection(serviceName: string, options:
85
88
  try { return host.himalaya?.storage ?? host.localStorage; } catch { return undefined; }
86
89
  };
87
90
  // What the last read found, so choosing a goal repaints this week's numbers without reading the bookings again.
88
- let found: { rows: MemberBookingRow[]; now: number; unreadRemain: boolean; owner: string; locked: boolean } | undefined;
91
+ let found: { rows: MemberBookingRow[]; now: number; firstWeekday: Weekday; unreadRemain: boolean; owner: string; locked: boolean } | undefined;
89
92
  const ready = (read: NonNullable<typeof found>, goal: number): PerformanceTrackerState => {
90
- const { rows, now, unreadRemain } = read;
91
- const progress = weeklyGoalProgress(sessionsInWeek(rows, now, 0), goal);
93
+ const { rows, now, firstWeekday, unreadRemain } = read;
94
+ const progress = weeklyGoalProgress(sessionsInWeek(rows, now, 0, firstWeekday), goal);
92
95
  const total = allTimeSessions(rows, now);
93
- const streak = weeklyStreak(rows, now, goal);
96
+ const streak = weeklyStreak(rows, now, goal, firstWeekday);
94
97
  return view("ready", false, {
95
98
  goalLabel: progress.label, remainingLabel: progress.remainingLabel, progress: progress.fraction,
96
99
  ringText: `${formatNumber(progress.done)}/${formatNumber(progress.goal)}`,
97
100
  goalOptions: goalChoices(progress.goal).map((n) => ({ id: String(n), label: formatNumber(n) })),
98
101
  goalDraft: String(progress.goal), goalValue: String(progress.goal), goalSessions: sessionsLabel(progress.goal),
99
102
  goalLocked: read.locked, goalUnlocked: !read.locked,
100
- streak: `${formatNumber(streak)}${streakMayBeLonger(rows, now, goal, streak, unreadRemain) ? "+" : ""}`, streakLabel: weeksLabel(streak),
103
+ streak: `${formatNumber(streak)}${streakMayBeLonger(rows, now, goal, streak, unreadRemain, firstWeekday) ? "+" : ""}`, streakLabel: weeksLabel(streak),
101
104
  total: total > MAX_ALL_TIME_SESSIONS ? `${formatNumber(MAX_ALL_TIME_SESSIONS)}+` : `${formatNumber(total)}${unreadRemain ? "+" : ""}`,
102
- totalLabel: attendedLabel(Math.min(total, MAX_ALL_TIME_SESSIONS)),
103
- }, now);
105
+ totalLabel: totalSessionsLabel(),
106
+ }, { now, firstWeekday });
104
107
  };
105
108
  // A guest, or a member Wix refused, keeps the default goal and is asked to sign in to change it.
106
109
  const signedOut = () => view("ready", true, { goalSessions: sessionsLabel(defaultGoal) });
107
110
  // Only the newest load may answer: a guest read that finishes after the member signed in must not overwrite the member's progress.
108
111
  let sequence = 0;
112
+ let pinnedFirstWeekday: unknown;
109
113
  const initial = view("loading", false);
110
114
  // The member changed: the progress already published is the previous member's, so it goes at once.
111
115
  const restart = () => { void service.clear(); void service.load(); };
112
116
  type State = PerformanceTrackerState;
113
117
  const load = async (_state: State, arg?: unknown): Promise<State | undefined> => {
114
118
  stashCopy(arg);
119
+ // A pinned first day is kept for the Refresh and sign-in reloads, which carry no params. After the copy is stashed: the app
120
+ // language it carries decides the first day otherwise.
121
+ if (arg && typeof arg === "object" && "firstWeekday" in arg) pinnedFirstWeekday = (arg as { firstWeekday?: unknown }).firstWeekday;
122
+ const firstWeekday = resolveFirstWeekday(pinnedFirstWeekday);
115
123
  const seq = ++sequence;
116
124
  let member: Awaited<ReturnType<typeof memberAccess>> | undefined;
117
125
  try {
@@ -128,7 +136,7 @@ export function registerPerformanceTrackerSection(serviceName: string, options:
128
136
  const unreadRemain = Boolean(page.nextCursor);
129
137
  if (seq !== sequence) return undefined;
130
138
  const owner = goalOwner(member);
131
- found = { rows, now, unreadRemain, owner, locked: !canKeepGoal(goalStore(), owner) };
139
+ found = { rows, now, firstWeekday, unreadRemain, owner, locked: !canKeepGoal(goalStore(), owner) };
132
140
  return ready(found, readMemberGoal(goalStore(), owner) || defaultGoal);
133
141
  } catch (error) {
134
142
  if (seq !== sequence) return undefined;
@@ -1,9 +1,13 @@
1
1
  // What a performance tracker counts, as pure functions over a member's bookings (no network, no clock read: `now` is an argument), so
2
2
  // the rules are unit-tested directly. A session is what My Bookings' "This week" card counts (`isHeldSession` in `weekly-goal.ts`):
3
- // the section and that card can never disagree.
3
+ // the section and that card can never disagree. Every week starts on `firstWeekday` (`resolveFirstWeekday` in `weekly-goal.ts`), so the
4
+ // range the section shows and the weeks it counts are the same days.
5
+ //
6
+ // A held session is not an attended one: a member's booking carries no check-in (Wix attendance is owner-scoped), so the all-time
7
+ // number is of sessions booked that already took place, and is labelled so.
4
8
  import { formatMonthDay } from "./engine-intl.js";
5
9
  import type { MemberBookingRow } from "./member-bookings.js";
6
- import { isHeldSession, weekStartMs, weeklySessionsDone } from "./weekly-goal.js";
10
+ import { isHeldSession, sessionKey, weekStartMs, weeklySessionsDone, type Weekday } from "./weekly-goal.js";
7
11
 
8
12
  /** The source's default weekly goal. */
9
13
  export const DEFAULT_WEEKLY_GOAL = 2;
@@ -14,28 +18,31 @@ export const STREAK_WEEKS = 52;
14
18
  /** 11 pages of 50 past bookings: enough to tell "500 or fewer" from "more", and to reach a year back. */
15
19
  export const MAX_PAGES = 11;
16
20
 
17
- /** Monday 00:00 local, `weeksBack` weeks before the week `now` is in (DST-safe: calendar days, not 7 * 24 h). */
18
- const weekStartBack = (now: number, weeksBack: number): number => {
19
- const d = new Date(weekStartMs(now));
21
+ /** The week's first day 00:00 local, `weeksBack` weeks before the week `now` is in (DST-safe: calendar days, not 7 * 24 h). Each
22
+ * week's start is found again from noon of a day in it: where a clock change skips midnight (Santiago, Havana, Beirut change on a
23
+ * Sunday), that week starts at 01:00, and stepping back from 01:00 would put every older week an hour late. */
24
+ const weekStartBack = (now: number, weeksBack: number, firstWeekday: Weekday): number => {
25
+ const d = new Date(weekStartMs(now, firstWeekday));
26
+ d.setHours(12, 0, 0, 0);
20
27
  d.setDate(d.getDate() - 7 * weeksBack);
21
- return d.getTime();
28
+ return weekStartMs(d.getTime(), firstWeekday);
22
29
  };
23
30
 
24
31
  /** Sessions held in the week `weeksBack` weeks before `now`'s (0 = this week, up to `now`). */
25
- export function sessionsInWeek(rows: readonly MemberBookingRow[], now: number, weeksBack: number): number {
26
- // A millisecond before the next Monday is still in that week, and `weeklySessionsDone` takes its week from the instant it is given.
27
- return weeklySessionsDone(rows, weeksBack === 0 ? now : weekStartBack(now, weeksBack - 1) - 1);
32
+ export function sessionsInWeek(rows: readonly MemberBookingRow[], now: number, weeksBack: number, firstWeekday: Weekday): number {
33
+ // A millisecond before the next week starts is still in that week, and `weeklySessionsDone` takes its week from the instant it is given.
34
+ return weeklySessionsDone(rows, weeksBack === 0 ? now : weekStartBack(now, weeksBack - 1, firstWeekday) - 1, firstWeekday);
28
35
  }
29
36
 
30
37
  /**
31
38
  * Consecutive weeks that met `goal`, newest first. The week still running counts once it has met the goal and never breaks the
32
39
  * streak while it has not: the member still has days left.
33
40
  */
34
- export function weeklyStreak(rows: readonly MemberBookingRow[], now: number, goal: number): number {
35
- const current = sessionsInWeek(rows, now, 0);
41
+ export function weeklyStreak(rows: readonly MemberBookingRow[], now: number, goal: number, firstWeekday: Weekday): number {
42
+ const current = sessionsInWeek(rows, now, 0, firstWeekday);
36
43
  let streak = 0;
37
44
  for (let back = current >= goal ? 0 : 1; back < STREAK_WEEKS; back++) {
38
- if ((back === 0 ? current : sessionsInWeek(rows, now, back)) < goal) break;
45
+ if ((back === 0 ? current : sessionsInWeek(rows, now, back, firstWeekday)) < goal) break;
39
46
  streak++;
40
47
  }
41
48
  return streak;
@@ -45,26 +52,26 @@ export function weeklyStreak(rows: readonly MemberBookingRow[], now: number, goa
45
52
  * Whether `streak` may be longer than the rows show: the read stopped at the page cap with older bookings unread, and the run of weeks
46
53
  * reaches the oldest week those rows cover (an older week the rows do not hold looks empty and would end the run early).
47
54
  */
48
- export function streakMayBeLonger(rows: readonly MemberBookingRow[], now: number, goal: number, streak: number, unreadRemain: boolean): boolean {
55
+ export function streakMayBeLonger(rows: readonly MemberBookingRow[], now: number, goal: number, streak: number, unreadRemain: boolean, firstWeekday: Weekday): boolean {
49
56
  if (!unreadRemain) return false;
50
57
  const starts = rows.map((row) => Date.parse(row.start)).filter(Number.isFinite);
51
58
  if (!starts.length) return false;
52
59
  const week = 7 * 24 * 3600 * 1000;
53
- const oldestBack = Math.round((weekStartMs(now) - weekStartMs(Math.min(...starts))) / week);
54
- const firstWeek = sessionsInWeek(rows, now, 0) >= goal ? 0 : 1;
60
+ const oldestBack = Math.round((weekStartMs(now, firstWeekday) - weekStartMs(Math.min(...starts), firstWeekday)) / week);
61
+ const firstWeek = sessionsInWeek(rows, now, 0, firstWeekday) >= goal ? 0 : 1;
55
62
  // A run that ended at the 52-week look-back ended by the source's own limit: older bookings cannot lengthen it.
56
63
  if (firstWeek + streak >= STREAK_WEEKS) return false;
57
64
  return firstWeek + streak >= oldestBack;
58
65
  }
59
66
 
60
- /** Sessions held, all time (one per booking id). */
67
+ /** Sessions booked that already took place, all time (one per booking id). NOT sessions attended: see the file header. */
61
68
  export function allTimeSessions(rows: readonly MemberBookingRow[], now: number): number {
62
- return new Set(rows.filter((row) => isHeldSession(row, now)).map((row) => row.id || `${row.start}|${row.title}`)).size;
69
+ return new Set(rows.filter((row) => isHeldSession(row, now)).map(sessionKey)).size;
63
70
  }
64
71
 
65
- /** "Nov 16 - Nov 22" (the source's `{startDate} - {endDate}`): Monday to Sunday of the week `now` is in. */
66
- export function weekRange(now: number): string {
67
- const start = new Date(weekStartMs(now));
72
+ /** "Nov 22 - Nov 28" (the source's `{startDate} - {endDate}`): the first to the last day of the week `now` is in. */
73
+ export function weekRange(now: number, firstWeekday: Weekday): string {
74
+ const start = new Date(weekStartMs(now, firstWeekday));
68
75
  const end = new Date(start);
69
76
  end.setDate(end.getDate() + 6);
70
77
  return `${formatMonthDay(start)} - ${formatMonthDay(end)}`;