@wix/himalaya-cli 0.1588.0 → 0.1590.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 (220) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/sdk-types/src/capabilities.generated.d.ts +2 -1
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/torch/src/index.d.ts +39 -0
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/webview-page/src/capabilities.generated.d.ts +2 -0
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/define-app.d.ts +13 -2
  5. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/groups/src/extensions.d.ts +28 -0
  6. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/members-v1/src/index.d.ts +9 -5
  7. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/audio-record.mjs +1 -0
  8. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/calendar.mjs +1 -0
  9. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/calls.mjs +1 -0
  10. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/contacts.mjs +1 -0
  11. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/location.mjs +1 -0
  12. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/motion.mjs +1 -0
  13. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/photos.mjs +1 -0
  14. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdk-types.mjs +1 -0
  15. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/tasks.mjs +1 -0
  16. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/torch.mjs +78 -0
  17. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-groups.mjs +14 -0
  18. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-members.mjs +9 -8
  19. package/dist/authoring-runtime/node_modules/@wix/himalaya/package.json +4 -0
  20. package/dist/cli.mjs +121 -50
  21. package/dist/preview-assets.generated.bin +0 -0
  22. package/fixtures/wix-canned.json +16 -0
  23. package/guides/app-config.md +1 -1
  24. package/guides/importable-sdks.md +1 -0
  25. package/guides/one-app-to-himi-app.md +18 -4
  26. package/guides/qa-builds.md +12 -0
  27. package/guides/sdk-reference.json +101 -2
  28. package/guides/web-page-sdk-reference.md +1 -0
  29. package/package.json +2 -2
  30. package/templates/beauty-salon/tier5-src/_shared/app-locale.ts +61 -0
  31. package/templates/beauty-salon/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  32. package/templates/beauty-salon/tier5-src/_shared/engine-intl.ts +5 -3
  33. package/templates/beauty-salon/tier5-src/_shared/group-member-count.ts +15 -0
  34. package/templates/beauty-salon/tier5-src/_shared/himi-bookings.ts +54 -13
  35. package/templates/beauty-salon/tier5-src/_shared/himi-copy.ts +10 -2
  36. package/templates/beauty-salon/tier5-src/_shared/himi-restaurants.ts +2 -2
  37. package/templates/beauty-salon/tier5-src/_shared/restaurant-ordering.ts +1 -1
  38. package/templates/beauty-salon/tier5-src/_shared/wix-service-price.ts +2 -2
  39. package/templates/beauty-salon/tier5-src/himi-booking-services/index.ts +8 -3
  40. package/templates/beauty-salon/tier5-src/himi-branded-lite-cart/index.ts +1 -1
  41. package/templates/beauty-salon/tier5-src/himi-branded-lite-home/index.ts +2 -1
  42. package/templates/beauty-salon/tier5-src/himi-branded-lite-plans/index.ts +1 -1
  43. package/templates/beauty-salon-owner/tier5-src/_shared/app-locale.ts +61 -0
  44. package/templates/beauty-salon-owner/tier5-src/_shared/engine-intl.ts +5 -3
  45. package/templates/beauty-salon-owner/tier5-src/_shared/himi-copy.ts +10 -2
  46. package/templates/branded-lite/config.ts +7 -0
  47. package/templates/branded-lite/dev/index.ts +469 -0
  48. package/templates/branded-lite/himalaya.content.json +3 -0
  49. package/templates/branded-lite/tier5-src/_shared/app-locale.ts +61 -0
  50. package/templates/branded-lite/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  51. package/templates/branded-lite/tier5-src/_shared/engine-intl.ts +5 -3
  52. package/templates/branded-lite/tier5-src/_shared/group-member-count.ts +15 -0
  53. package/templates/branded-lite/tier5-src/_shared/himi-bookings.ts +54 -13
  54. package/templates/branded-lite/tier5-src/_shared/himi-copy.ts +10 -2
  55. package/templates/branded-lite/tier5-src/_shared/himi-restaurants.ts +2 -2
  56. package/templates/branded-lite/tier5-src/_shared/restaurant-ordering.ts +1 -1
  57. package/templates/branded-lite/tier5-src/_shared/wix-service-price.ts +2 -2
  58. package/templates/branded-lite/tier5-src/himi-booking-services/index.ts +8 -3
  59. package/templates/branded-lite/tier5-src/himi-branded-lite-cart/index.ts +1 -1
  60. package/templates/branded-lite/tier5-src/himi-branded-lite-group/index.ts +9 -3
  61. package/templates/branded-lite/tier5-src/himi-branded-lite-group-about/index.ts +2 -1
  62. package/templates/branded-lite/tier5-src/himi-branded-lite-groups/index.ts +6 -2
  63. package/templates/branded-lite/tier5-src/himi-branded-lite-home/index.ts +2 -1
  64. package/templates/branded-lite/tier5-src/himi-branded-lite-loyalty/index.ts +3 -2
  65. package/templates/branded-lite/tier5-src/himi-branded-lite-my-groups/index.ts +237 -0
  66. package/templates/branded-lite/tier5-src/himi-branded-lite-plans/index.ts +1 -1
  67. package/templates/branded-lite/tier5-src/himi-branded-lite-program/index.ts +1 -1
  68. package/templates/branded-lite/tier5-src/himi-events-detail/index.ts +5 -5
  69. package/templates/branded-lite/tier5-src/wix-spaces-member-detail/index.ts +5 -1
  70. package/templates/brandy/tier5-src/_shared/app-locale.ts +61 -0
  71. package/templates/brandy/tier5-src/_shared/himi-copy.ts +10 -2
  72. package/templates/community-club/config.ts +7 -0
  73. package/templates/community-club/dev/index.ts +469 -0
  74. package/templates/community-club/himalaya.content.json +3 -0
  75. package/templates/community-club/tier5-src/_shared/app-locale.ts +61 -0
  76. package/templates/community-club/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  77. package/templates/community-club/tier5-src/_shared/engine-intl.ts +5 -3
  78. package/templates/community-club/tier5-src/_shared/group-member-count.ts +15 -0
  79. package/templates/community-club/tier5-src/_shared/himi-copy.ts +10 -2
  80. package/templates/community-club/tier5-src/_shared/himi-restaurants.ts +2 -2
  81. package/templates/community-club/tier5-src/_shared/wix-service-price.ts +2 -2
  82. package/templates/community-club/tier5-src/himi-branded-lite-group/index.ts +9 -3
  83. package/templates/community-club/tier5-src/himi-branded-lite-group-about/index.ts +2 -1
  84. package/templates/community-club/tier5-src/himi-branded-lite-groups/index.ts +6 -2
  85. package/templates/community-club/tier5-src/himi-branded-lite-home/index.ts +2 -1
  86. package/templates/community-club/tier5-src/himi-branded-lite-my-groups/index.ts +237 -0
  87. package/templates/community-club/tier5-src/himi-events-detail/index.ts +5 -5
  88. package/templates/community-club-owner/tier5-src/_shared/app-locale.ts +61 -0
  89. package/templates/community-club-owner/tier5-src/_shared/engine-intl.ts +5 -3
  90. package/templates/community-club-owner/tier5-src/_shared/himi-copy.ts +10 -2
  91. package/templates/events-meetups/config.ts +7 -0
  92. package/templates/events-meetups/dev/index.ts +469 -0
  93. package/templates/events-meetups/himalaya.content.json +3 -0
  94. package/templates/events-meetups/tier5-src/_shared/app-locale.ts +61 -0
  95. package/templates/events-meetups/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  96. package/templates/events-meetups/tier5-src/_shared/engine-intl.ts +5 -3
  97. package/templates/events-meetups/tier5-src/_shared/group-member-count.ts +15 -0
  98. package/templates/events-meetups/tier5-src/_shared/himi-copy.ts +10 -2
  99. package/templates/events-meetups/tier5-src/_shared/himi-restaurants.ts +2 -2
  100. package/templates/events-meetups/tier5-src/_shared/wix-service-price.ts +2 -2
  101. package/templates/events-meetups/tier5-src/himi-branded-lite-group/index.ts +9 -3
  102. package/templates/events-meetups/tier5-src/himi-branded-lite-group-about/index.ts +2 -1
  103. package/templates/events-meetups/tier5-src/himi-branded-lite-groups/index.ts +6 -2
  104. package/templates/events-meetups/tier5-src/himi-branded-lite-home/index.ts +2 -1
  105. package/templates/events-meetups/tier5-src/himi-branded-lite-my-groups/index.ts +237 -0
  106. package/templates/events-meetups/tier5-src/himi-events-detail/index.ts +5 -5
  107. package/templates/events-meetups-owner/tier5-src/_shared/app-locale.ts +61 -0
  108. package/templates/events-meetups-owner/tier5-src/_shared/engine-intl.ts +5 -3
  109. package/templates/events-meetups-owner/tier5-src/_shared/himi-copy.ts +10 -2
  110. package/templates/gym-fitness/tier5-src/_shared/app-locale.ts +61 -0
  111. package/templates/gym-fitness/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  112. package/templates/gym-fitness/tier5-src/_shared/engine-intl.ts +5 -3
  113. package/templates/gym-fitness/tier5-src/_shared/group-member-count.ts +15 -0
  114. package/templates/gym-fitness/tier5-src/_shared/himi-bookings.ts +54 -13
  115. package/templates/gym-fitness/tier5-src/_shared/himi-copy.ts +10 -2
  116. package/templates/gym-fitness/tier5-src/_shared/himi-restaurants.ts +2 -2
  117. package/templates/gym-fitness/tier5-src/_shared/restaurant-ordering.ts +1 -1
  118. package/templates/gym-fitness/tier5-src/_shared/wix-service-price.ts +2 -2
  119. package/templates/gym-fitness/tier5-src/himi-booking-services/index.ts +8 -3
  120. package/templates/gym-fitness/tier5-src/himi-branded-lite-cart/index.ts +1 -1
  121. package/templates/gym-fitness/tier5-src/himi-branded-lite-home/index.ts +2 -1
  122. package/templates/gym-fitness/tier5-src/himi-branded-lite-plans/index.ts +1 -1
  123. package/templates/gym-fitness/tier5-src/himi-events-detail/index.ts +5 -5
  124. package/templates/gym-fitness-owner/tier5-src/_shared/app-locale.ts +61 -0
  125. package/templates/gym-fitness-owner/tier5-src/_shared/engine-intl.ts +5 -3
  126. package/templates/gym-fitness-owner/tier5-src/_shared/himi-copy.ts +10 -2
  127. package/templates/himi-chat/tier5-src/_shared/app-locale.ts +61 -0
  128. package/templates/himi-chat/tier5-src/_shared/himi-copy.ts +10 -2
  129. package/templates/nonprofit-cause/config.ts +7 -0
  130. package/templates/nonprofit-cause/dev/index.ts +469 -0
  131. package/templates/nonprofit-cause/himalaya.content.json +3 -0
  132. package/templates/nonprofit-cause/tier5-src/_shared/app-locale.ts +61 -0
  133. package/templates/nonprofit-cause/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  134. package/templates/nonprofit-cause/tier5-src/_shared/engine-intl.ts +5 -3
  135. package/templates/nonprofit-cause/tier5-src/_shared/group-member-count.ts +15 -0
  136. package/templates/nonprofit-cause/tier5-src/_shared/himi-copy.ts +10 -2
  137. package/templates/nonprofit-cause/tier5-src/_shared/himi-restaurants.ts +2 -2
  138. package/templates/nonprofit-cause/tier5-src/_shared/wix-service-price.ts +2 -2
  139. package/templates/nonprofit-cause/tier5-src/himi-branded-lite-group/index.ts +9 -3
  140. package/templates/nonprofit-cause/tier5-src/himi-branded-lite-group-about/index.ts +2 -1
  141. package/templates/nonprofit-cause/tier5-src/himi-branded-lite-groups/index.ts +6 -2
  142. package/templates/nonprofit-cause/tier5-src/himi-branded-lite-home/index.ts +2 -1
  143. package/templates/nonprofit-cause/tier5-src/himi-branded-lite-my-groups/index.ts +237 -0
  144. package/templates/nonprofit-cause/tier5-src/himi-branded-lite-plans/index.ts +1 -1
  145. package/templates/nonprofit-cause/tier5-src/himi-events-detail/index.ts +5 -5
  146. package/templates/nonprofit-cause-owner/tier5-src/_shared/app-locale.ts +61 -0
  147. package/templates/nonprofit-cause-owner/tier5-src/_shared/engine-intl.ts +5 -3
  148. package/templates/nonprofit-cause-owner/tier5-src/_shared/himi-copy.ts +10 -2
  149. package/templates/owner-lite/tier5-src/_shared/app-locale.ts +61 -0
  150. package/templates/owner-lite/tier5-src/_shared/engine-intl.ts +5 -3
  151. package/templates/owner-lite/tier5-src/_shared/himi-copy.ts +10 -2
  152. package/templates/podcast-creator/tier5-src/_shared/app-locale.ts +61 -0
  153. package/templates/podcast-creator/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  154. package/templates/podcast-creator/tier5-src/_shared/engine-intl.ts +5 -3
  155. package/templates/podcast-creator/tier5-src/_shared/group-member-count.ts +15 -0
  156. package/templates/podcast-creator/tier5-src/_shared/himi-copy.ts +10 -2
  157. package/templates/podcast-creator/tier5-src/_shared/himi-restaurants.ts +2 -2
  158. package/templates/podcast-creator/tier5-src/_shared/wix-service-price.ts +2 -2
  159. package/templates/podcast-creator/tier5-src/himi-branded-lite-home/index.ts +2 -1
  160. package/templates/podcast-creator/tier5-src/himi-branded-lite-plans/index.ts +1 -1
  161. package/templates/podcast-creator/tier5-src/himi-events-detail/index.ts +5 -5
  162. package/templates/podcast-creator-owner/tier5-src/_shared/app-locale.ts +61 -0
  163. package/templates/podcast-creator-owner/tier5-src/_shared/engine-intl.ts +5 -3
  164. package/templates/podcast-creator-owner/tier5-src/_shared/himi-copy.ts +10 -2
  165. package/templates/portfolio-creative/tier5-src/_shared/app-locale.ts +61 -0
  166. package/templates/portfolio-creative/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  167. package/templates/portfolio-creative/tier5-src/_shared/engine-intl.ts +5 -3
  168. package/templates/portfolio-creative/tier5-src/_shared/group-member-count.ts +15 -0
  169. package/templates/portfolio-creative/tier5-src/_shared/himi-copy.ts +10 -2
  170. package/templates/portfolio-creative/tier5-src/_shared/himi-restaurants.ts +2 -2
  171. package/templates/portfolio-creative/tier5-src/_shared/restaurant-ordering.ts +1 -1
  172. package/templates/portfolio-creative/tier5-src/_shared/wix-service-price.ts +2 -2
  173. package/templates/portfolio-creative/tier5-src/himi-branded-lite-cart/index.ts +1 -1
  174. package/templates/portfolio-creative/tier5-src/himi-branded-lite-home/index.ts +2 -1
  175. package/templates/portfolio-creative/tier5-src/himi-events-detail/index.ts +5 -5
  176. package/templates/portfolio-creative-owner/tier5-src/_shared/app-locale.ts +61 -0
  177. package/templates/portfolio-creative-owner/tier5-src/_shared/engine-intl.ts +5 -3
  178. package/templates/portfolio-creative-owner/tier5-src/_shared/himi-copy.ts +10 -2
  179. package/templates/restaurant/tier5-src/_shared/app-locale.ts +61 -0
  180. package/templates/restaurant/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  181. package/templates/restaurant/tier5-src/_shared/engine-intl.ts +5 -3
  182. package/templates/restaurant/tier5-src/_shared/group-member-count.ts +15 -0
  183. package/templates/restaurant/tier5-src/_shared/himi-copy.ts +10 -2
  184. package/templates/restaurant/tier5-src/_shared/himi-restaurants.ts +2 -2
  185. package/templates/restaurant/tier5-src/_shared/restaurant-ordering.ts +1 -1
  186. package/templates/restaurant/tier5-src/_shared/wix-service-price.ts +2 -2
  187. package/templates/restaurant/tier5-src/himi-branded-lite-home/index.ts +2 -1
  188. package/templates/restaurant/tier5-src/himi-events-detail/index.ts +5 -5
  189. package/templates/restaurant-owner/tier5-src/_shared/app-locale.ts +61 -0
  190. package/templates/restaurant-owner/tier5-src/_shared/engine-intl.ts +5 -3
  191. package/templates/restaurant-owner/tier5-src/_shared/himi-copy.ts +10 -2
  192. package/templates/retail-store/tier5-src/_shared/app-locale.ts +61 -0
  193. package/templates/retail-store/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  194. package/templates/retail-store/tier5-src/_shared/engine-intl.ts +5 -3
  195. package/templates/retail-store/tier5-src/_shared/group-member-count.ts +15 -0
  196. package/templates/retail-store/tier5-src/_shared/himi-copy.ts +10 -2
  197. package/templates/retail-store/tier5-src/_shared/himi-restaurants.ts +2 -2
  198. package/templates/retail-store/tier5-src/_shared/restaurant-ordering.ts +1 -1
  199. package/templates/retail-store/tier5-src/_shared/wix-service-price.ts +2 -2
  200. package/templates/retail-store/tier5-src/himi-branded-lite-cart/index.ts +1 -1
  201. package/templates/retail-store/tier5-src/himi-branded-lite-home/index.ts +2 -1
  202. package/templates/retail-store-owner/tier5-src/_shared/app-locale.ts +61 -0
  203. package/templates/retail-store-owner/tier5-src/_shared/engine-intl.ts +5 -3
  204. package/templates/retail-store-owner/tier5-src/_shared/himi-copy.ts +10 -2
  205. package/templates/yoga-studio/tier5-src/_shared/app-locale.ts +61 -0
  206. package/templates/yoga-studio/tier5-src/_shared/branded-lite-hosted.ts +1 -0
  207. package/templates/yoga-studio/tier5-src/_shared/engine-intl.ts +5 -3
  208. package/templates/yoga-studio/tier5-src/_shared/group-member-count.ts +15 -0
  209. package/templates/yoga-studio/tier5-src/_shared/himi-bookings.ts +54 -13
  210. package/templates/yoga-studio/tier5-src/_shared/himi-copy.ts +10 -2
  211. package/templates/yoga-studio/tier5-src/_shared/himi-restaurants.ts +2 -2
  212. package/templates/yoga-studio/tier5-src/_shared/wix-service-price.ts +2 -2
  213. package/templates/yoga-studio/tier5-src/himi-booking-services/index.ts +8 -3
  214. package/templates/yoga-studio/tier5-src/himi-branded-lite-home/index.ts +2 -1
  215. package/templates/yoga-studio/tier5-src/himi-branded-lite-plans/index.ts +1 -1
  216. package/templates/yoga-studio/tier5-src/himi-branded-lite-program/index.ts +1 -1
  217. package/templates/yoga-studio/tier5-src/himi-events-detail/index.ts +5 -5
  218. package/templates/yoga-studio-owner/tier5-src/_shared/app-locale.ts +61 -0
  219. package/templates/yoga-studio-owner/tier5-src/_shared/engine-intl.ts +5 -3
  220. package/templates/yoga-studio-owner/tier5-src/_shared/himi-copy.ts +10 -2
@@ -0,0 +1,237 @@
1
+ import { defineService } from "@himalaya/state";
2
+ import { getGroup, listMemberships, type WixGroup, type WixGroupMembership } from "@himalaya/wix-groups";
3
+ import { getMyMember } from "@himalaya/wix-members";
4
+ import { copyParam, stashCopy } from "../_shared/himi-copy.js";
5
+ import { groupMemberCount } from "../_shared/group-member-count.js";
6
+ import { groupImage } from "../_shared/himi-media.js";
7
+ import { memberAccess, memberAccessDenied, type MemberAccess } from "../_shared/member-access.js";
8
+
9
+ // The groups the SIGNED-IN member belongs to (the One App "My groups" list). Two reads, both as the
10
+ // member: the memberships (GET /social-groups-proxy/members/v2/members/{id}/memberships, which Wix
11
+ // answers for the caller's own id only) and then one getGroup per membership, because a membership
12
+ // carries a group id and a role, never the group's name or cover.
13
+ //
14
+ // A visitor makes ZERO calls: the screen shows its sign-in card. The member id is the current
15
+ // member's (`getMyMember`), never taken from input. Read-only and online-only.
16
+
17
+ type Failure = "forbidden" | "failed";
18
+
19
+ /** Memberships read in one page. A member with more is told so, not shown a silently short list. */
20
+ const PAGE_LIMIT = 50;
21
+ const DETAIL_SCREEN = "himi_group";
22
+
23
+ interface MyGroupRow {
24
+ id: string;
25
+ title: string;
26
+ /** "Admin", "Member" or "Pending request" — the member's standing in the group. */
27
+ statusLabel: string;
28
+ meta: string;
29
+ image: string;
30
+ initial: string;
31
+ hasImage: boolean;
32
+ noImage: boolean;
33
+ detailScreenId: string;
34
+ }
35
+
36
+ interface State {
37
+ status: "loading" | "ready" | "error" | "signedOut";
38
+ rows: MyGroupRow[];
39
+ emptyText: string;
40
+ errorText: string;
41
+ /** Some groups could not be read, or the member has more than one page: said above the list. */
42
+ partialText: string;
43
+ notLoading: boolean;
44
+ notErrored: boolean;
45
+ noRows: boolean;
46
+ noEmpty: boolean;
47
+ noPartial: boolean;
48
+ needsSignIn: boolean;
49
+ noSignIn: boolean;
50
+ }
51
+
52
+ const initial: State = {
53
+ status: "loading",
54
+ rows: [],
55
+ emptyText: "",
56
+ errorText: "",
57
+ partialText: "",
58
+ notLoading: false,
59
+ notErrored: true,
60
+ noRows: true,
61
+ noEmpty: true,
62
+ noPartial: true,
63
+ needsSignIn: false,
64
+ noSignIn: true,
65
+ };
66
+
67
+ /** Bumped by every load, so a response that arrives after a newer load began is dropped. */
68
+ let loadSeq = 0;
69
+
70
+ const signedOutState: State = { ...initial, status: "signedOut", notLoading: true, needsSignIn: true, noSignIn: false };
71
+
72
+ function errorState(failure: Failure): State {
73
+ return {
74
+ ...initial,
75
+ status: "error",
76
+ notLoading: true,
77
+ notErrored: false,
78
+ errorText: failure === "forbidden"
79
+ ? copyParam("myGroups.forbiddenText", "Your groups are unavailable for this account. Sign in again.")
80
+ : copyParam("myGroups.errorText", "Your groups could not be loaded."),
81
+ };
82
+ }
83
+
84
+ function failureOf(error: unknown): Failure {
85
+ return memberAccessDenied(error) ? "forbidden" : "failed";
86
+ }
87
+
88
+ function isNotFound(error: unknown): boolean {
89
+ return /HTTP 404\b/.test(String((error as Error)?.message ?? error));
90
+ }
91
+
92
+ function statusLabelOf(membership: WixGroupMembership): string {
93
+ if ((membership.status ?? "").toUpperCase() === "PENDING") return copyParam("myGroups.status.pending", "Pending request");
94
+ return (membership.role?.value ?? "").toUpperCase() === "ADMIN"
95
+ ? copyParam("myGroups.status.admin", "Admin")
96
+ : copyParam("myGroups.status.member", "Member");
97
+ }
98
+
99
+ function rowOf(group: WixGroup, membership: WixGroupMembership): MyGroupRow {
100
+ const title = (group.name || copyParam("groups.groupFallbackName", "Group")).trim();
101
+ const count = group.membersCount ?? group.memberCount;
102
+ const image = groupImage(group);
103
+ return {
104
+ id: String(membership.groupId),
105
+ title,
106
+ statusLabel: statusLabelOf(membership),
107
+ meta: typeof count === "number" ? groupMemberCount(count) : "",
108
+ image,
109
+ initial: (title[0] || "G").toUpperCase(),
110
+ hasImage: Boolean(image),
111
+ noImage: !image,
112
+ detailScreenId: DETAIL_SCREEN,
113
+ };
114
+ }
115
+
116
+ /** JOINED and PENDING memberships with a group id; an UNKNOWN status is not a membership to show. */
117
+ function shownMemberships(response: unknown): WixGroupMembership[] | undefined {
118
+ const memberships = (response as { memberships?: unknown } | null | undefined)?.memberships;
119
+ if (!Array.isArray(memberships)) return undefined;
120
+ const seen = new Set<string>();
121
+ return (memberships as WixGroupMembership[]).filter((m) => {
122
+ const status = (m?.status ?? "").toUpperCase();
123
+ if (typeof m?.groupId !== "string" || !m.groupId || (status !== "JOINED" && status !== "PENDING") || seen.has(m.groupId)) return false;
124
+ seen.add(m.groupId);
125
+ return true;
126
+ });
127
+ }
128
+
129
+ function readyState(rows: MyGroupRow[], partialText: string): State {
130
+ return {
131
+ ...initial,
132
+ status: "ready",
133
+ rows,
134
+ emptyText: copyParam("myGroups.emptyText", "You haven’t joined any groups yet."),
135
+ partialText,
136
+ notLoading: true,
137
+ noRows: rows.length === 0,
138
+ noEmpty: rows.length > 0,
139
+ noPartial: !partialText,
140
+ };
141
+ }
142
+
143
+ const sameMember = (a: MemberAccess, b: MemberAccess) => a.email === b.email && a.scope === b.scope;
144
+
145
+ /** Whose groups the rows on screen are. A load for anybody else clears them first. */
146
+ let rowsOwner: MemberAccess | undefined;
147
+
148
+ /** The sign-in card is what the screen shows. A load that finds a member now (they signed in and came back)
149
+ * shows the loading state at once instead of leaving the card up over the network calls. A module flag, not
150
+ * a read of the state: the reload this starts must not see the card again and restart forever. */
151
+ let showingSignIn = false;
152
+
153
+ /** The member changed while this load ran or the rows were on screen: show the loading state at once,
154
+ * so the previous member's group names and standing are never on screen, and load for the current one. */
155
+ function restart(): State {
156
+ rowsOwner = undefined;
157
+ showingSignIn = false;
158
+ loadSeq++;
159
+ void svc.load();
160
+ return { ...initial };
161
+ }
162
+
163
+ /** An error for THIS member, unless a newer load began or the member left meanwhile: then it is stale. */
164
+ async function failureFor(seq: number, access: MemberAccess, failure: Failure): Promise<State | undefined> {
165
+ if (seq !== loadSeq) return undefined;
166
+ const now = await memberAccess();
167
+ // A newer load began while the identity was read: its answer is the fresher one.
168
+ if (seq !== loadSeq) return undefined;
169
+ if (!sameMember(access, now)) return restart();
170
+ return errorState(failure);
171
+ }
172
+
173
+ async function loadOnce(access: MemberAccess): Promise<State | undefined> {
174
+ const seq = ++loadSeq;
175
+ if (!access.email) { showingSignIn = true; return signedOutState; }
176
+ try {
177
+ const me = await getMyMember();
178
+ const memberId = String(me?.member?.id ?? "");
179
+ if (!memberId) return failureFor(seq, access, "failed");
180
+ const response = await listMemberships(memberId, { limit: PAGE_LIMIT });
181
+ const memberships = shownMemberships(response);
182
+ if (!memberships) return failureFor(seq, access, "failed");
183
+ const reads = await Promise.allSettled(memberships.map((m) => getGroup(String(m.groupId))));
184
+ // Another load began, or the member signed out / switched account while these reads were in
185
+ // flight: these rows belong to somebody else now.
186
+ if (seq !== loadSeq) return undefined;
187
+ const now = await memberAccess();
188
+ // Re-checked after the await: a newer load may have committed while the identity was read.
189
+ if (seq !== loadSeq) return undefined;
190
+ if (!sameMember(access, now)) return restart();
191
+ const rows: MyGroupRow[] = [];
192
+ let failed = 0;
193
+ let firstFailure: unknown;
194
+ reads.forEach((read, index) => {
195
+ if (read.status === "fulfilled") {
196
+ // Social Groups wraps the entity as `{ group }`; the typed signature claims a bare group.
197
+ const group = ((read.value as unknown as { group?: WixGroup }).group ?? read.value) as WixGroup;
198
+ if (group && typeof group === "object") { rows.push(rowOf(group, memberships[index])); return; }
199
+ }
200
+ // A group deleted since the membership was listed is gone, not a failed read.
201
+ if (read.status === "rejected" && isNotFound(read.reason)) return;
202
+ failed++;
203
+ firstFailure ??= read.status === "rejected" ? read.reason : undefined;
204
+ });
205
+ // Memberships exist but not one group could be shown: that is unreadable (a pending request on a
206
+ // private group answers 404 until approved) or gone, never "you have no groups".
207
+ if (memberships.length > 0 && rows.length === 0) return errorState(failed > 0 ? failureOf(firstFailure) : "failed");
208
+ // Wix omits `total` when it is too many to count, and says so in `tooManyToCount`.
209
+ const truncated = response.metadata?.tooManyToCount === true || Number(response.metadata?.total ?? 0) > PAGE_LIMIT;
210
+ const partialText = [
211
+ failed > 0 ? copyParam("myGroups.partialText", "Some of your groups could not be loaded.") : "",
212
+ truncated ? copyParam("myGroups.truncatedText", "Showing your first groups only.") : "",
213
+ ].filter(Boolean).join(" ");
214
+ rowsOwner = access;
215
+ return readyState(rows, partialText);
216
+ } catch (error) {
217
+ // A request that rejects because the member left is the old member's error, not the current one's.
218
+ return failureFor(seq, access, failureOf(error));
219
+ }
220
+ }
221
+
222
+ const svc = defineService<State, {
223
+ load: (state: State, arg?: unknown) => Promise<State | undefined>;
224
+ }>("himiBrandedMyGroups", {
225
+ state: initial,
226
+ actions: {
227
+ load: async (_state, arg) => {
228
+ stashCopy(arg);
229
+ const access = await memberAccess();
230
+ if ((rowsOwner && !sameMember(rowsOwner, access)) || (showingSignIn && access.email)) return restart();
231
+ return loadOnce(access);
232
+ },
233
+ },
234
+ });
235
+
236
+ svc.load();
237
+ export { svc };
@@ -82,7 +82,7 @@ function money(plan: WixPlan): string {
82
82
  const raw = price?.value;
83
83
  if (raw == null || raw === "" || Number.isNaN(Number(raw))) return "";
84
84
  try {
85
- return formatCurrency(Number(raw), price?.currency || "USD", "en");
85
+ return formatCurrency(Number(raw), price?.currency || "USD");
86
86
  } catch {
87
87
  return `${raw}`;
88
88
  }
@@ -147,7 +147,7 @@ function priceOf(p: WixProgram): string {
147
147
  if (raw == null || raw === "" || Number.isNaN(Number(raw))) return "";
148
148
  if (Number(raw) === 0) return "";
149
149
  try {
150
- return formatCurrency(Number(raw), price?.currency || "USD", "en");
150
+ return formatCurrency(Number(raw), price?.currency || "USD");
151
151
  } catch {
152
152
  return `${raw}`;
153
153
  }
@@ -243,7 +243,7 @@ function tierPrice(t: WixAvailableTicket): string {
243
243
  // as "25" — a price that reads as a quantity, and nothing downstream could tell it was a
244
244
  // formatting failure. `formatCurrency` uses real Intl where it exists and a symbol-carrying
245
245
  // fallback where it does not, diffed against ECMA-402 in engine-intl-fallback.test.ts.
246
- return formatCurrency(Number(raw), t.price?.currency || "USD", "en");
246
+ return formatCurrency(Number(raw), t.price?.currency || "USD");
247
247
  }
248
248
 
249
249
  function tierAvailable(t: WixAvailableTicket): boolean {
@@ -286,7 +286,7 @@ function tierRows(defs: WixAvailableTicket[], selectedId: string): TicketTierRow
286
286
  priceAmount: Number(t.price?.amount ?? 0),
287
287
  ...(isGuestPrice ? { priceLine: detailCopy("event.payWhatYouWant", "Pay what you want") } : {}),
288
288
  ...(isGuestPrice ? { priceAmount: minPrice, isGuestPrice: true } : {}),
289
- ...(isGuestPrice ? { minimumPriceLabel: detailCopy("event.minPrice", "Minimum {price}").replace("{price}", formatCurrency(minPrice, t.price?.currency || "USD", "en")) } : {}),
289
+ ...(isGuestPrice ? { minimumPriceLabel: detailCopy("event.minPrice", "Minimum {price}").replace("{price}", formatCurrency(minPrice, t.price?.currency || "USD")) } : {}),
290
290
  };
291
291
  });
292
292
  }
@@ -399,7 +399,7 @@ function derive(s: S): S {
399
399
  noFooterCaption: !s.footerCaption,
400
400
  hideFooter: s.status !== "ready" || s.errored || !s.footerLabel || s.rsvpState !== "none",
401
401
  checkoutDisabled: count === 0 || count > s.ticketLimitPerOrder || ticketCheckoutInFlight || !ticketCheckoutAllowed || s.ticketTiers.some((row) => row.isGuestPrice && (row.quantity ?? 0) > 0 && (!String(row.guestPrice ?? "").trim() || Number(row.guestPrice) < (row.minPrice ?? 0) || !Number.isFinite(Number(row.guestPrice)))) || s.ticketTiers.some((row) => (row.quantity ?? 0) > (row.maxQuantity ?? 99)),
402
- ticketTotal: formatCurrency(total, s.ticketCurrency || "USD", "en"),
402
+ ticketTotal: formatCurrency(total, s.ticketCurrency || "USD"),
403
403
  ticketCountLabel: copyParam("event.ticketCount", "{n} tickets, plus fees").replace("{n}", String(count)),
404
404
  noSchedule: s.schedule.length === 0,
405
405
  noFullSchedule: s.fullSchedule.length === 0,
@@ -494,7 +494,7 @@ function detailMoney(money?: EventDetailMoney): string {
494
494
  if (money?.formattedValue) return money.formattedValue;
495
495
  const value = money?.value;
496
496
  if (value == null || String(value).trim() === "" || !money?.currency || !Number.isFinite(Number(value))) return "";
497
- return formatCurrency(Number(value), money.currency, "en");
497
+ return formatCurrency(Number(value), money.currency);
498
498
  }
499
499
 
500
500
  function detailPlace(e: WixEvent): { value: string; mapUrl: string; hideMapTap: boolean; icon: string } {
@@ -617,7 +617,7 @@ const svc: ReturnType<typeof defineService<S, DetailActions>> = defineService<S,
617
617
  ticketSheetOpen: false,
618
618
  rsvpActionsOpen: false,
619
619
  cancelConfirmOpen: false,
620
- ticketTotal: formatCurrency(0, "USD", "en"),
620
+ ticketTotal: formatCurrency(0, "USD"),
621
621
  ticketCountLabel: copyParam("event.ticketCount", "{n} tickets, plus fees").replace("{n}", "0"),
622
622
  checkoutDisabled: true,
623
623
  schedule: [],
@@ -42,8 +42,12 @@ function name(m: WixMember): string {
42
42
  function followLabelFor(isFollowing: boolean): string {
43
43
  return isFollowing ? "Following ✓" : "Follow";
44
44
  }
45
+ /** Each counter on its own: a missing one is hidden, never shown as 0, and an explicit 0 stays visible. */
45
46
  function followCountFor(followers: number | null, following: number | null): string {
46
- return followers === null || following === null ? "" : followers + " Followers · " + following + " Following";
47
+ return [
48
+ followers === null ? "" : followers + (followers === 1 ? " Follower" : " Followers"),
49
+ following === null ? "" : following + " Following",
50
+ ].filter(Boolean).join(" · ");
47
51
  }
48
52
 
49
53
  const INITIAL: S = {
@@ -0,0 +1,61 @@
1
+ // The language a worker formats numbers, money and plurals in, and the business's time zone. A worker has no host locale to read,
2
+ // so the screen's `onAppear` hands it over: `appear()` adds `locale` to the load params when the app
3
+ // pins its language, and `stashCopy` stores it here. Absent, every formatter stays on "en" — the
4
+ // house pattern every English app was approved with — so an unpinned app is unchanged.
5
+ //
6
+ // The business time zone comes the same way, from the app's provisioning (`businessTimeZone`, collected
7
+ // at migration time while the site's properties are readable): a worker cannot read it itself, because
8
+ // the site-properties route is owner-scoped. Absent, it is "" and no worker guesses one.
9
+ //
10
+ // Pure, no host globals: bundled into every worker that formats, copied into generated templates.
11
+
12
+ const TAG = /^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/;
13
+ let tag = "en";
14
+
15
+ /** Set from a load argument's `locale`; anything that is not a language tag resets to "en". */
16
+ export function setAppLocale(value: unknown): void {
17
+ tag = typeof value === "string" && TAG.test(value) ? value : "en";
18
+ }
19
+
20
+ export function appLocale(): string {
21
+ return tag;
22
+ }
23
+
24
+ /** An IANA zone such as "Asia/Jerusalem" (or "UTC") that this engine knows. A bare offset, a lowercase
25
+ * alias or an engine without ECMA-402 is not one: a zone is never guessed. */
26
+ export function isIanaTimeZone(value: unknown): value is string {
27
+ if (typeof value !== "string" || !/^(?:UTC|[A-Za-z]+(?:\/[A-Za-z0-9_+-]+)+)$/.test(value)) return false;
28
+ // An engine without ECMA-402 has no zone database: nothing it holds is a zone it knows.
29
+ if (typeof Intl === "object" && typeof Intl.DateTimeFormat === "function") {
30
+ try {
31
+ new Intl.DateTimeFormat("en-US", { timeZone: value });
32
+ return true;
33
+ } catch {
34
+ return false;
35
+ }
36
+ }
37
+ return false;
38
+ }
39
+
40
+ let zone = "";
41
+
42
+ /** Set from a load argument's `businessTimeZone`; anything that is not an IANA zone clears it. */
43
+ export function setBusinessTimeZone(value: unknown): void {
44
+ zone = isIanaTimeZone(value) ? value : "";
45
+ }
46
+
47
+ /** The business's IANA zone, or "" when the app has none provisioned. */
48
+ export function businessTimeZone(): string {
49
+ return zone;
50
+ }
51
+
52
+ /** Does `count` take the singular form in the app language? CLDR plural rules, so French "0 point"
53
+ * and "1,5 point" are singular and Hebrew "2" is not. An engine without PluralRules keeps the
54
+ * English rule (exactly one). */
55
+ export function isSingular(count: number, locale = appLocale()): boolean {
56
+ try {
57
+ // An engine without ECMA-402 has no `Intl` at all: it keeps the English rule.
58
+ if (typeof Intl === "object" && typeof Intl.PluralRules === "function") return new Intl.PluralRules(locale).select(count) === "one";
59
+ } catch { /* malformed tag — use the English rule */ }
60
+ return count === 1;
61
+ }
@@ -12,10 +12,12 @@
12
12
  // and every read returns `fallback` verbatim — routing a worker string through
13
13
  // copyParam is byte-for-byte behavior-preserving.
14
14
  //
15
- // Pure + Hermes-safe (no host globals, no Node APIs, no imports): bundled into
15
+ // Pure + Hermes-safe (no host globals, no Node APIs; its only import is the pure `app-locale` sibling): bundled into
16
16
  // every worker that emits user-facing copy, and copied verbatim into the
17
17
  // generated templates' tier5-src/_shared/.
18
18
 
19
+ import { isSingular, setAppLocale, setBusinessTimeZone } from "./app-locale.js";
20
+
19
21
  /** Customer strings override every read; translated stock is valid only for its
20
22
  * original English fallback. Some existing keys serve more than one message. */
21
23
  export type CopyPackValue = string | { source: string; translation: string };
@@ -29,6 +31,12 @@ let copyReceived = false;
29
31
  * stock fallbacks keep rendering. */
30
32
  export function stashCopy(arg: unknown): void {
31
33
  if (!arg || typeof arg !== "object") return;
34
+ // A param-carrying dispatch names the app language and business zone too (absent: the English house
35
+ // pattern, and no zone).
36
+ if ("copy" in arg || "locale" in arg || "businessTimeZone" in arg) {
37
+ setAppLocale((arg as Record<string, unknown>).locale);
38
+ setBusinessTimeZone((arg as Record<string, unknown>).businessTimeZone);
39
+ }
32
40
  const raw = (arg as Record<string, unknown>).copy;
33
41
  if (typeof raw !== "string" || !raw) return;
34
42
  try {
@@ -77,5 +85,5 @@ export function copyPlural(key: string, fallback: string, count: number): string
77
85
  const pattern = copyParam(key, fallback);
78
86
  const match = /^\{n, plural, one \{([^{}]*)\} other \{([^{}]*)\}\}$/.exec(pattern);
79
87
  if (!match) return copyTemplate(key, fallback, { n: count });
80
- return (count === 1 ? match[1] : match[2])!.replace(/#/g, String(count));
88
+ return (isSingular(count) ? match[1] : match[2])!.replace(/#/g, String(count));
81
89
  }
@@ -231,6 +231,13 @@ export default defineApp({
231
231
  "parentScreenId": "himi_group",
232
232
  "tabId": "groups"
233
233
  },
234
+ {
235
+ "screenId": "himi_my_groups",
236
+ "isPublic": true,
237
+ "paramKeys": [],
238
+ "parentScreenId": "himi_groups",
239
+ "tabId": "groups"
240
+ },
234
241
  {
235
242
  "screenId": "himi_cms",
236
243
  "isPublic": true,