@wix/himalaya-cli 0.2008.0 → 0.2010.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 (57) hide show
  1. package/dist/cli.mjs +175 -46
  2. package/guides/one-app-section-mappings.md +1 -1
  3. package/guides/one-app-to-himi-app.md +4 -1
  4. package/package.json +2 -2
  5. package/templates/beauty-salon/tier5-src/_shared/himi-store-facets.ts +2 -7
  6. package/templates/beauty-salon/tier5-src/_shared/store-ribbon.ts +11 -0
  7. package/templates/branded-lite/l10n/ar.json +30 -0
  8. package/templates/branded-lite/l10n/cs.json +30 -0
  9. package/templates/branded-lite/l10n/da.json +30 -0
  10. package/templates/branded-lite/l10n/de.json +30 -0
  11. package/templates/branded-lite/l10n/el.json +30 -0
  12. package/templates/branded-lite/l10n/es.json +30 -0
  13. package/templates/branded-lite/l10n/fi.json +30 -0
  14. package/templates/branded-lite/l10n/fr.json +30 -0
  15. package/templates/branded-lite/l10n/he.json +26 -0
  16. package/templates/branded-lite/l10n/hu.json +30 -0
  17. package/templates/branded-lite/l10n/id.json +30 -0
  18. package/templates/branded-lite/l10n/it.json +30 -0
  19. package/templates/branded-lite/l10n/ja.json +30 -0
  20. package/templates/branded-lite/l10n/ko.json +30 -0
  21. package/templates/branded-lite/l10n/lt.json +30 -0
  22. package/templates/branded-lite/l10n/nl.json +30 -0
  23. package/templates/branded-lite/l10n/no.json +30 -0
  24. package/templates/branded-lite/l10n/pl.json +30 -0
  25. package/templates/branded-lite/l10n/pt.json +30 -0
  26. package/templates/branded-lite/l10n/ru.json +30 -0
  27. package/templates/branded-lite/l10n/sv.json +30 -0
  28. package/templates/branded-lite/l10n/th.json +30 -0
  29. package/templates/branded-lite/l10n/tr.json +30 -0
  30. package/templates/branded-lite/l10n/uk.json +30 -0
  31. package/templates/branded-lite/l10n/vi.json +30 -0
  32. package/templates/branded-lite/l10n/zh.json +30 -0
  33. package/templates/branded-lite/recipes/group-feed.json +135 -5
  34. package/templates/branded-lite/recipes/groups-newsfeed.json +241 -95
  35. package/templates/branded-lite/recipes/members-carousel.json +55 -3
  36. package/templates/branded-lite/recipes/plans-card.json +630 -3
  37. package/templates/branded-lite/recipes/products-carousel.json +74 -10
  38. package/templates/branded-lite/recipes/products-grid.json +74 -10
  39. package/templates/branded-lite/recipes/programs-filters.json +51 -2
  40. package/templates/branded-lite/tier5-src/_shared/group-feed-section.ts +131 -17
  41. package/templates/branded-lite/tier5-src/_shared/groups-newsfeed-section.ts +8 -5
  42. package/templates/branded-lite/tier5-src/_shared/groups-section.ts +7 -1
  43. package/templates/branded-lite/tier5-src/_shared/himi-store-facets.ts +2 -7
  44. package/templates/branded-lite/tier5-src/_shared/member-row-extras.ts +18 -17
  45. package/templates/branded-lite/tier5-src/_shared/members-directory-view.ts +12 -0
  46. package/templates/branded-lite/tier5-src/_shared/members-directory.ts +26 -13
  47. package/templates/branded-lite/tier5-src/_shared/plan-facts.ts +15 -6
  48. package/templates/branded-lite/tier5-src/_shared/plans-section.ts +32 -6
  49. package/templates/branded-lite/tier5-src/_shared/products-section.ts +5 -0
  50. package/templates/branded-lite/tier5-src/_shared/programs-section.ts +19 -16
  51. package/templates/branded-lite/tier5-src/_shared/store-ribbon.ts +11 -0
  52. package/templates/gym-fitness/tier5-src/_shared/himi-store-facets.ts +2 -7
  53. package/templates/gym-fitness/tier5-src/_shared/store-ribbon.ts +11 -0
  54. package/templates/portfolio-creative/tier5-src/_shared/himi-store-facets.ts +2 -7
  55. package/templates/portfolio-creative/tier5-src/_shared/store-ribbon.ts +11 -0
  56. package/templates/retail-store/tier5-src/_shared/himi-store-facets.ts +2 -7
  57. package/templates/retail-store/tier5-src/_shared/store-ribbon.ts +11 -0
@@ -1,5 +1,5 @@
1
1
  {
2
- "_recipe": "A rail of a collection's products, scrolling sideways. Tiles: image (initials when none), name, price; a tap opens the product. ONE node, always mounted. Service: registerProductsSection(svc, { categoryId, limit }); the section's See All button is placed beside it by the generator.",
2
+ "_recipe": "A rail of a collection's products, scrolling sideways. Tiles: image (initials when none) with the merchant's ribbon on its top corner when the product has one, name, price; a tap opens the product. ONE node, always mounted. Service: registerProductsSection(svc, { categoryId, limit }); the section's See All button is placed beside it by the generator.",
3
3
  "_placeholders": {
4
4
  "svc": "service name the page worker registered with registerProductsSection",
5
5
  "id": "unique node id prefix for this section"
@@ -52,18 +52,82 @@
52
52
  "alignment": "leading",
53
53
  "children": [
54
54
  {
55
- "id": "",
55
+ "id": "{{id}}.media",
56
56
  "body": {
57
57
  "package": "himalaya",
58
- "type": "Image",
58
+ "type": "ZStack",
59
59
  "props": {
60
- "url": "$item.image",
61
- "initials": "$item.initial",
62
- "fillWidth": true,
63
- "contentMode": "fill",
64
- "contentDescription": "$item.name",
65
- "aspectRatio": 1,
66
- "shape": "rect"
60
+ "alignment": "leading",
61
+ "verticalAlignment": "top",
62
+ "children": [
63
+ {
64
+ "id": "",
65
+ "body": {
66
+ "package": "himalaya",
67
+ "type": "Image",
68
+ "props": {
69
+ "url": "$item.image",
70
+ "initials": "$item.initial",
71
+ "fillWidth": true,
72
+ "contentMode": "fill",
73
+ "contentDescription": "$item.name",
74
+ "aspectRatio": 1,
75
+ "shape": "rect"
76
+ }
77
+ },
78
+ "modifiers": {
79
+ "fillMaxWidth": true
80
+ }
81
+ },
82
+ {
83
+ "id": "{{id}}.ribbonBox",
84
+ "body": {
85
+ "package": "himalaya",
86
+ "type": "VStack",
87
+ "props": {
88
+ "spacing": 0,
89
+ "alignment": "leading",
90
+ "children": [
91
+ {
92
+ "id": "{{id}}.ribbon",
93
+ "body": {
94
+ "package": "himalaya",
95
+ "type": "Text",
96
+ "props": {
97
+ "text": "$item.ribbon",
98
+ "style": "caption",
99
+ "color": "accentPrimary",
100
+ "maxLines": 1
101
+ }
102
+ },
103
+ "modifiers": {
104
+ "background": {
105
+ "token": "accentSurface"
106
+ },
107
+ "cornerRadius": 6,
108
+ "padding": {
109
+ "leading": 6,
110
+ "trailing": 6,
111
+ "top": 2,
112
+ "bottom": 2
113
+ },
114
+ "hiddenPath": "$item.noRibbon"
115
+ }
116
+ }
117
+ ]
118
+ }
119
+ },
120
+ "modifiers": {
121
+ "padding": {
122
+ "leading": 8,
123
+ "trailing": 8,
124
+ "top": 8,
125
+ "bottom": 8
126
+ },
127
+ "hiddenPath": "$item.noRibbon"
128
+ }
129
+ }
130
+ ]
67
131
  }
68
132
  },
69
133
  "modifiers": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "_recipe": "A two-column grid of a collection's first products. Tiles: image (initials when none), name, price; a tap opens the product. ONE node, always mounted. Service: registerProductsSection(svc, { categoryId, limit }); the section's See All button is placed beside it by the generator.",
2
+ "_recipe": "A two-column grid of a collection's first products. Tiles: image (initials when none) with the merchant's ribbon on its top corner when the product has one, name, price; a tap opens the product. ONE node, always mounted. Service: registerProductsSection(svc, { categoryId, limit }); the section's See All button is placed beside it by the generator.",
3
3
  "_placeholders": {
4
4
  "svc": "service name the page worker registered with registerProductsSection",
5
5
  "id": "unique node id prefix for this section"
@@ -54,18 +54,82 @@
54
54
  "alignment": "leading",
55
55
  "children": [
56
56
  {
57
- "id": "",
57
+ "id": "{{id}}.media",
58
58
  "body": {
59
59
  "package": "himalaya",
60
- "type": "Image",
60
+ "type": "ZStack",
61
61
  "props": {
62
- "url": "$item.image",
63
- "initials": "$item.initial",
64
- "fillWidth": true,
65
- "contentMode": "fill",
66
- "contentDescription": "$item.name",
67
- "aspectRatio": 1,
68
- "shape": "rect"
62
+ "alignment": "leading",
63
+ "verticalAlignment": "top",
64
+ "children": [
65
+ {
66
+ "id": "",
67
+ "body": {
68
+ "package": "himalaya",
69
+ "type": "Image",
70
+ "props": {
71
+ "url": "$item.image",
72
+ "initials": "$item.initial",
73
+ "fillWidth": true,
74
+ "contentMode": "fill",
75
+ "contentDescription": "$item.name",
76
+ "aspectRatio": 1,
77
+ "shape": "rect"
78
+ }
79
+ },
80
+ "modifiers": {
81
+ "fillMaxWidth": true
82
+ }
83
+ },
84
+ {
85
+ "id": "{{id}}.ribbonBox",
86
+ "body": {
87
+ "package": "himalaya",
88
+ "type": "VStack",
89
+ "props": {
90
+ "spacing": 0,
91
+ "alignment": "leading",
92
+ "children": [
93
+ {
94
+ "id": "{{id}}.ribbon",
95
+ "body": {
96
+ "package": "himalaya",
97
+ "type": "Text",
98
+ "props": {
99
+ "text": "$item.ribbon",
100
+ "style": "caption",
101
+ "color": "accentPrimary",
102
+ "maxLines": 1
103
+ }
104
+ },
105
+ "modifiers": {
106
+ "background": {
107
+ "token": "accentSurface"
108
+ },
109
+ "cornerRadius": 6,
110
+ "padding": {
111
+ "leading": 6,
112
+ "trailing": 6,
113
+ "top": 2,
114
+ "bottom": 2
115
+ },
116
+ "hiddenPath": "$item.noRibbon"
117
+ }
118
+ }
119
+ ]
120
+ }
121
+ },
122
+ "modifiers": {
123
+ "padding": {
124
+ "leading": 8,
125
+ "trailing": 8,
126
+ "top": 8,
127
+ "bottom": 8
128
+ },
129
+ "hiddenPath": "$item.noRibbon"
130
+ }
131
+ }
132
+ ]
69
133
  }
70
134
  },
71
135
  "modifiers": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "_recipe": "The programs list's two filters: the participant-status segmented control (All programs / Programs I joined; hidden for a guest) and the category chips (All categories first; hidden when the site has no categories). Service: registerProgramsSection(svc,{layout:'list'}); the worker owns the options and hides a control the source turns off (options.filters). Also the list's empty line (a category or the joined filter with no programs), hidden while there are cards.",
2
+ "_recipe": "The programs list's two filters, shown to a guest too and with a single program, as on the source: the participant-status segmented control (All programs / Programs I joined) and the category chips (All categories first, alone when the site has no categories). Service: registerProgramsSection(svc,{layout:'list'}); the worker owns the options and hides a control the source turns off (options.filters). Also the list's empty line (a category or the joined filter with no programs), hidden while there are cards, and a guest's sign-in prompt on Programs I joined.",
3
3
  "_placeholders": {
4
4
  "svc": "service name the page worker registered with registerProgramsSection",
5
5
  "id": "unique node id prefix (e.g. the screen id)",
@@ -7,7 +7,8 @@
7
7
  "categoryLabel": "accessibility label of the category chips",
8
8
  "allProgramsLabel": "fallback label of the first status option",
9
9
  "joinedLabel": "fallback label of the second status option",
10
- "allCategoriesLabel": "fallback label of the first category chip"
10
+ "allCategoriesLabel": "fallback label of the first category chip",
11
+ "signInScreen": "the screen a guest's Sign in button opens, himi_sign_in"
11
12
  },
12
13
  "node": {
13
14
  "id": "{{id}}.filters",
@@ -86,6 +87,54 @@
86
87
  "modifiers": {
87
88
  "hiddenPath": "$service:{{svc}}.noEmpty"
88
89
  }
90
+ },
91
+ {
92
+ "id": "{{id}}.signin",
93
+ "body": {
94
+ "package": "himalaya",
95
+ "type": "VStack",
96
+ "props": {
97
+ "spacing": 12,
98
+ "alignment": "leading",
99
+ "children": [
100
+ {
101
+ "id": "{{id}}.signin.text",
102
+ "body": {
103
+ "package": "himalaya",
104
+ "type": "Text",
105
+ "props": {
106
+ "text": "$service:{{svc}}.emptyText",
107
+ "style": "body",
108
+ "color": "textSecondary"
109
+ }
110
+ }
111
+ },
112
+ {
113
+ "id": "{{id}}.signin.button",
114
+ "body": {
115
+ "package": "himalaya",
116
+ "type": "Button",
117
+ "props": {
118
+ "title": "$service:{{svc}}.signInLabel",
119
+ "style": "primary",
120
+ "size": "md",
121
+ "fullWidth": true,
122
+ "action": {
123
+ "actionId": "himi.open",
124
+ "params": {
125
+ "screenId": "{{signInScreen}}",
126
+ "mode": "signin"
127
+ }
128
+ }
129
+ }
130
+ }
131
+ }
132
+ ]
133
+ }
134
+ },
135
+ "modifiers": {
136
+ "hiddenPath": "$service:{{svc}}.noSignIn"
137
+ }
89
138
  }
90
139
  ]
91
140
  }
@@ -4,15 +4,21 @@
4
4
  // A group that is not public is shown the way the group screen shows it to someone who is not a member: its name, its privacy and the
5
5
  // invitation message, and the feed is never read, so no post of a private group reaches the page. A public group whose feed Wix refuses
6
6
  // the viewer (401/403: the feed read is a member scope) shows the same state with its own sentence.
7
- // Each post has the source's Like and Share, as the feed read's permissions allow the viewer: a visitor, or a member the group does not
8
- // let react, gets no Like, and the section shows a sign-in or join gate instead (`noSignInGate` / `noJoinGate`).
7
+ // Each post has the source's Like, Comment and Share. The feed read's permissions decide what a tap does, never whether the control shows:
8
+ // the One App shows Like and Comment to a visitor and to a member outside the group too, and asks them to sign in or join first. So a
9
+ // viewer the read lets react likes in place, one it lets comment opens a comment field under the post (the comment goes to the post
10
+ // through the Comments API's Groups scope), and a viewer the read refuses is sent to sign in (a visitor) or to the group to join it (a
11
+ // member). The section also shows a sign-in or join gate (`noSignInGate` / `noJoinGate`) when the viewer may neither like nor comment.
12
+ // A read that names no permissions grants nothing and gates nothing: no Like, no Comment, no Share.
9
13
  // A page worker registers it under a service name; the descriptor binds `$service:<serviceName>.*` (recipe group-feed.json).
10
- import { defineService } from "@himalaya/state";
14
+ import { defineService, navigate } from "@himalaya/state";
11
15
  import { hostSessionFromGlobal } from "@himalaya/iap";
12
16
  import { share as shareSheet } from "@himalaya/share";
13
17
  import { memberAccess } from "./member-access.js";
14
18
  import { getGroup, type WixGroup } from "@himalaya/wix-groups";
15
19
  import { DEFAULT_REACTION, listFeedItems, reactToFeedItem, unreactFeedItem, type WixFeedItem, type WixFeedItemPermissions, type WixFeedProfile, type WixListFeedItemsResponse } from "@himalaya/wix-social-feed";
20
+ import { createGroupPostComment } from "@himalaya/wix-comments";
21
+ import { memberScreenNav } from "./member-screen.js";
16
22
  import { copyParam, stashCopy } from "./himi-copy.js";
17
23
  import { initials } from "./himi-text.js";
18
24
  import { groupPrivacyLabel } from "./group-privacy.js";
@@ -37,20 +43,34 @@ export interface GroupFeedRow {
37
43
  likes?: number; likeLabel: string;
38
44
  /** The viewer has liked the post: the next tap removes the like. */
39
45
  liked: boolean;
40
- /** The viewer may not react to the post: the like is hidden. */
46
+ /** The viewer may react to the post: a tap likes it. Otherwise a tap on the Like signs in or opens the group to join it. */
47
+ mayLike: boolean;
48
+ /** The read named no permissions for the post: the like is hidden (nothing says what a tap would do). */
41
49
  noLike: boolean;
42
- /** The read named the viewer's permissions and they refuse the like: the post counts toward the sign-in or join gate. */
50
+ /** The post's comment count as the feed gives it, and Comment's label ("Comment", "Comment · 2"). */
51
+ comments?: number; commentLabel: string;
52
+ /** The viewer may comment on the post: a tap opens the comment field. Otherwise a tap signs in or opens the group to join it. */
53
+ mayComment: boolean;
54
+ /** The read named no permissions for the post: Comment is hidden. */
55
+ noComment: boolean;
56
+ /** The comment field under the post is closed (it opens on the viewer's Comment tap, one post at a time). */
57
+ noComposer: boolean;
58
+ /** The read named the viewer's permissions and they refuse both the like and the comment: the post counts toward the sign-in or join gate. */
43
59
  gated: boolean;
44
60
  /** The viewer may not share the post: the share is hidden. */
45
61
  noShare: boolean;
46
- /** Neither Like nor Share: the post's action row is hidden. */
62
+ /** Neither Like, Comment nor Share: the post's action row is hidden. */
47
63
  noActions: boolean;
48
64
  }
49
65
 
66
+ /** The comment field the sections share: what is typed in it, and what the last send did ("" when nothing to say). */
67
+ export interface CommentFields { commentText: string; commentMessage: string; noCommentMessage: boolean }
68
+ export const commentIdle = (message = ""): CommentFields => ({ commentText: "", commentMessage: message, noCommentMessage: !message });
69
+
50
70
  /** Which gate shows instead of the posts' Like: none while the viewer may react (or there is no post). */
51
71
  export interface FeedGates { noSignInGate: boolean; noJoinGate: boolean }
52
72
 
53
- export interface GroupFeedState extends FeedGates {
73
+ export interface GroupFeedState extends FeedGates, CommentFields {
54
74
  status: "loading" | "ready" | "error";
55
75
  rows: GroupFeedRow[];
56
76
  /** The group's name and privacy label, shown with the restricted state. */
@@ -92,15 +112,24 @@ const likeFields = (liked: boolean, count: number | undefined): Pick<GroupFeedRo
92
112
  return { liked, likes: count, likeLabel: `\u{1F44D} ${verb}${count === undefined ? "" : ` · ${count}`}` };
93
113
  };
94
114
 
115
+ /** Comment's label: the app's one "Comment" key, with the feed's count once there is a comment. */
116
+ const commentFields = (count: number | undefined): Pick<GroupFeedRow, "comments" | "commentLabel"> => {
117
+ const verb = copyParam("forum.commentCta", "Comment");
118
+ return { comments: count, commentLabel: count ? `${verb} · ${count}` : verb };
119
+ };
120
+
95
121
  /** What the viewer may do to a feed read's posts: anyone's (`all`) and their own (`own`); `undefined` when the read names none. */
96
122
  export type FeedPermissions = { all?: WixFeedItemPermissions; own?: WixFeedItemPermissions } | undefined;
97
123
  export const feedPermissions = (feed: WixListFeedItemsResponse): FeedPermissions =>
98
124
  feed.permissions ? { all: feed.permissions.allFeedItemPermissions, own: feed.permissions.ownFeedItemPermissions } : undefined;
99
125
 
100
- /** Whether the viewer's member id is worth reading: only a signed-in viewer who may like some post of the read can have liked one. */
126
+ /** Whether the viewer's member id is worth reading: only a signed-in viewer who may like or comment on some post of the read needs it,
127
+ * to find their own like and to apply the own-post permissions (`own`) to their own posts. A viewer whose own posts take comments but
128
+ * no reaction needs it too, or their own posts would follow the everyone-else permissions. */
101
129
  export const mayLikeAny = (feed: WixListFeedItemsResponse, signedIn: boolean): boolean => {
102
130
  const permissions = feedPermissions(feed);
103
- return signedIn && (permissions?.all?.canReact === true || permissions?.own?.canReact === true || (feed.feedItems ?? []).some((item) => item.permissions?.canReact === true));
131
+ const acts = (granted: WixFeedItemPermissions | undefined) => granted?.canReact === true || granted?.canAddComment === true;
132
+ return signedIn && (acts(permissions?.all) || acts(permissions?.own) || (feed.feedItems ?? []).some((item) => acts(item.permissions)));
104
133
  };
105
134
 
106
135
  /** The signed-in member's id, to find their own reaction and posts ("" when not `wanted` — see mayLikeAny — or when it cannot be read).
@@ -112,26 +141,43 @@ export async function viewerMemberId(wanted: boolean): Promise<string> {
112
141
  }
113
142
 
114
143
  /** A post's row. The feed's permissions apply (its `own` set to the viewer's own post), and the post's own fields override them one by
115
- * one; with none at all the post grants nothing: no Like, no Share, and no gate. */
144
+ * one; with none at all the post grants nothing: no Like, no Comment, no Share, and no gate. With some, Like and Comment always show
145
+ * (as the One App shows them), and the permissions say whether a tap acts or asks the viewer to sign in or join first. */
116
146
  export function postRow(item: WixFeedItem, profiles: WixFeedProfile[], now: number, groupId: string, permissions: FeedPermissions, viewerId = ""): GroupFeedRow {
117
147
  const { name, avatar } = authorOf(item, profiles);
118
148
  const mine = !!viewerId && item.author?.id === viewerId;
119
149
  const feedLevel = mine ? permissions?.own ?? permissions?.all : permissions?.all;
120
150
  const named = feedLevel || item.permissions ? { ...feedLevel, ...item.permissions } : undefined;
121
151
  const granted: WixFeedItemPermissions = named ?? {};
122
- const noLike = granted.canReact !== true, noShare = granted.canShare !== true;
152
+ const mayLike = granted.canReact === true, mayComment = granted.canAddComment === true;
153
+ const noLike = !mayLike && named === undefined, noComment = !mayComment && named === undefined, noShare = granted.canShare !== true;
123
154
  // The section's Like is the 👍 reaction: another reaction the member left is not this like.
124
155
  const liked = !!viewerId && (item.reactionsList ?? []).some((reaction) => reaction.userId === viewerId && reaction.reaction === DEFAULT_REACTION);
156
+ const count = typeof item.commentsCount === "number" && item.commentsCount >= 0 ? item.commentsCount : undefined;
125
157
  return {
126
158
  id: item.feedItemId || "", author: name, initials: initials(name),
127
159
  avatar,
128
160
  text: postText(item), timeLabel: relativeTime(item.created ?? item.createdAt, now),
129
- groupId, ...likeFields(liked, undefined),
130
- noLike, noShare, noActions: noLike && noShare, gated: named !== undefined && granted.canReact !== true,
161
+ groupId, ...likeFields(liked, undefined), ...commentFields(count),
162
+ mayLike, noLike, mayComment, noComment, noComposer: true, noShare, noActions: noLike && noComment && noShare,
163
+ gated: named !== undefined && !mayLike && !mayComment,
131
164
  };
132
165
  }
133
166
 
134
- /** The gate that replaces the Like when no post may be liked: sign in for a visitor, join the group for a member. Only posts whose read
167
+ /**
168
+ * A refused Like or Comment: the One App's gated control. A visitor signs in and comes back to the group; a member is taken to the group,
169
+ * where its Join (or Request to join) is. The session is read at the tap. The recipe names both screens (`screenId`, `signInScreenId`).
170
+ */
171
+ async function gatedTap<S extends object>(state: S, row: GroupFeedRow, arg: unknown): Promise<S | undefined> {
172
+ const field = (key: string): string => { const v = (arg as Record<string, unknown> | undefined)?.[key]; return typeof v === "string" ? v : ""; };
173
+ const screenId = field("screenId");
174
+ if (!screenId) return undefined;
175
+ const viewer = await memberAccess();
176
+ const nav = memberScreenNav({ screenId, id: row.groupId, signInScreenId: field("signInScreenId") }, viewer.signedIn === true ? viewer.email || "signed-in" : viewer.email);
177
+ return nav ? navigate(state, nav) : undefined;
178
+ }
179
+
180
+ /** The gate shown when no post may be liked or commented on: sign in for a visitor, join the group for a member. Only posts whose read
135
181
  * named the viewer's permissions count (`gated`): a read without them shows no gate, so a member is never asked to join. */
136
182
  export const feedGates = (rows: GroupFeedRow[], signedIn: boolean): FeedGates => {
137
183
  const gated = rows.length > 0 && rows.every((row) => row.gated);
@@ -141,7 +187,8 @@ export const feedGates = (rows: GroupFeedRow[], signedIn: boolean): FeedGates =>
141
187
  /**
142
188
  * The sections' `like` action: the first tap likes the post, the next one removes that like, as the source's Like toggles. A tap while
143
189
  * the post's last one is still out is ignored. An answer that arrives after the section loaded again (`generation` moved: a refresh, or
144
- * another viewer signed in) is dropped, so it never marks the next viewer's post. A failed call leaves the post as it was.
190
+ * another viewer signed in) is dropped, so it never marks the next viewer's post. A failed call leaves the post as it was. A viewer the
191
+ * read does not let react is sent to sign in or to the group instead (`gatedTap`): nothing is sent to Wix for them.
145
192
  */
146
193
  export function likeAction<R extends GroupFeedRow, S extends { rows: R[] }>(current: () => S, generation: () => number) {
147
194
  const pending = new Set<string>();
@@ -149,6 +196,7 @@ export function likeAction<R extends GroupFeedRow, S extends { rows: R[] }>(curr
149
196
  const row = state.rows.find((candidate) => candidate.id === idOf(arg));
150
197
  const key = row ? `${row.groupId}/${row.id}` : "";
151
198
  if (!row || row.noLike || pending.has(key)) return undefined;
199
+ if (!row.mayLike) return gatedTap(current(), row, arg);
152
200
  pending.add(key);
153
201
  const started = generation();
154
202
  try {
@@ -174,6 +222,71 @@ export async function sharePost<R extends GroupFeedRow>(rows: R[], arg: unknown,
174
222
  try { await shareSheet({ subject: groupName(row), text: `${row.author}: ${row.text}` }); } catch { /* the sheet is best-effort */ }
175
223
  }
176
224
 
225
+ const textOf = (arg: unknown): string => {
226
+ if (typeof arg === "string") return arg;
227
+ const value = (arg as { value?: unknown; text?: unknown } | undefined)?.value ?? (arg as { text?: unknown } | undefined)?.text;
228
+ return typeof value === "string" ? value : "";
229
+ };
230
+
231
+ /**
232
+ * The sections' comment actions. `comment` is the post's Comment tap: a viewer the read lets comment opens (or closes) the field under that
233
+ * post, one post at a time; any other viewer is sent to sign in or to the group (`gatedTap`). `sendComment` posts what was typed to the
234
+ * post through the Comments API (`createGroupPostComment`: the Groups scope, the group as context and the post as resource). A send in
235
+ * flight for the post ignores a second tap, and an answer after the section loaded again (`generation` moved) is dropped. A failed send
236
+ * keeps the text and says so.
237
+ */
238
+ export type CommentActions<S> = {
239
+ comment: (state: S, arg?: unknown) => Promise<S | undefined>;
240
+ setComment: (state: S, arg?: unknown) => S;
241
+ cancelComment: (state: S) => S;
242
+ sendComment: (state: S, arg?: unknown) => Promise<S | undefined>;
243
+ };
244
+ export function commentActions<R extends GroupFeedRow, S extends { rows: R[] } & CommentFields>(current: () => S, generation: () => number): CommentActions<S> {
245
+ const sending = new Set<string>();
246
+ const close = (rows: R[]): R[] => rows.map((row) => (row.noComposer ? row : { ...row, noComposer: true }));
247
+ return {
248
+ comment: async (state: S, arg: unknown): Promise<S | undefined> => {
249
+ const row = state.rows.find((candidate) => candidate.id === idOf(arg));
250
+ if (!row || row.noComment) return undefined;
251
+ if (!row.mayComment) return gatedTap(current(), row, arg);
252
+ const now = current();
253
+ const opening = row.noComposer;
254
+ return { ...now, ...commentIdle(), rows: now.rows.map((candidate) => ({ ...candidate, noComposer: !(opening && candidate.id === row.id && candidate.groupId === row.groupId) })) };
255
+ },
256
+ setComment: (state: S, arg: unknown): S => ({ ...state, commentText: textOf(arg) }),
257
+ cancelComment: (state: S): S => ({ ...state, ...commentIdle(), rows: close(state.rows) }),
258
+ sendComment: async (state: S, arg: unknown): Promise<S | undefined> => {
259
+ const row = state.rows.find((candidate) => candidate.id === idOf(arg));
260
+ const text = state.commentText.trim();
261
+ const key = row ? `${row.groupId}/${row.id}` : "";
262
+ if (!row || !row.mayComment || row.noComposer || !text || sending.has(key)) return undefined;
263
+ sending.add(key);
264
+ const started = generation();
265
+ try {
266
+ await createGroupPostComment(row.groupId, row.id, text);
267
+ if (generation() !== started) return undefined;
268
+ const now = current();
269
+ const posted = copyParam("groupFeed.commentPostedMessage", "Your comment was posted.");
270
+ const counted = (rows: R[]): R[] => rows.map((candidate) => candidate.id === row.id && candidate.groupId === row.groupId
271
+ // A count the feed gave moves by one; an unknown one stays unknown (the reader's own comment is not the post's total).
272
+ ? { ...candidate, ...commentFields(candidate.comments === undefined ? undefined : candidate.comments + 1) } : candidate);
273
+ // The field closes and empties only while it still holds this send: this post's field, with the text that was sent. A reader
274
+ // who moved on to another post's field, or typed something new, while this send was out keeps that field and their text.
275
+ const stillOpen = now.rows.some((candidate) => candidate.id === row.id && candidate.groupId === row.groupId && !candidate.noComposer);
276
+ if (!stillOpen || now.commentText.trim() !== text) return { ...now, commentMessage: posted, noCommentMessage: false, rows: counted(now.rows) };
277
+ return { ...now, ...commentIdle(posted), rows: counted(close(now.rows)) };
278
+ } catch (error) {
279
+ if (generation() !== started) return undefined;
280
+ console.warn("group feed: the comment could not be sent", error);
281
+ const message = copyParam("groupFeed.commentFailedMessage", "The comment could not be posted. Try again.");
282
+ return { ...current(), commentMessage: message, noCommentMessage: false };
283
+ } finally {
284
+ sending.delete(key);
285
+ }
286
+ },
287
+ };
288
+ }
289
+
177
290
  const idOf = (arg: unknown): string => typeof arg === "string" ? arg : String((arg as { id?: unknown } | undefined)?.id ?? "");
178
291
 
179
292
  /** The feed read is a member scope: Wix answers a viewer it will not show with `HTTP 401` / `HTTP 403`. */
@@ -187,7 +300,7 @@ export function registerGroupFeedSection(serviceName: string, options: GroupFeed
187
300
  emptyText: status === "ready" && !rows.length && !restrictedText ? copyParam("groupFeed.emptyText", "No posts in this group yet.") : "",
188
301
  notLoading: status !== "loading", notErrored: status !== "error",
189
302
  noRows: !rows.length, noEmpty: !(status === "ready" && !rows.length && !restrictedText), noRestricted: !restrictedText,
190
- ...feedGates(rows, parts.signedIn === true), noShortcuts: status !== "ready",
303
+ ...feedGates(rows, parts.signedIn === true), noShortcuts: status !== "ready", ...commentIdle(),
191
304
  };
192
305
  };
193
306
  const session = hostSessionFromGlobal();
@@ -198,7 +311,7 @@ export function registerGroupFeedSection(serviceName: string, options: GroupFeed
198
311
  const service = defineService<GroupFeedState, {
199
312
  load: (state: GroupFeedState, arg?: unknown) => Promise<GroupFeedState | undefined>; clear: () => Promise<GroupFeedState>;
200
313
  like: (state: GroupFeedState, arg?: unknown) => Promise<GroupFeedState | undefined>; share: (state: GroupFeedState, arg?: unknown) => Promise<GroupFeedState | undefined>;
201
- }>(serviceName, {
314
+ } & CommentActions<GroupFeedState>>(serviceName, {
202
315
  state: view("loading"),
203
316
  // A group's posts are member-scoped: never written to disk and restored for the next person on the device.
204
317
  notHydrated: Object.keys(view("loading")) as Array<keyof GroupFeedState>,
@@ -241,6 +354,7 @@ export function registerGroupFeedSection(serviceName: string, options: GroupFeed
241
354
  },
242
355
  like: likeAction((): GroupFeedState => service.getState(), () => sequence),
243
356
  share: async (state, arg) => { await sharePost(state.rows, arg, () => state.groupName); return undefined; },
357
+ ...commentActions((): GroupFeedState => service.getState(), () => sequence),
244
358
  },
245
359
  });
246
360
  // Signing in or out on another screen changes who the feed is read for.
@@ -4,7 +4,9 @@
4
4
  // It is the single-group feed (group-feed-section.ts) read for several groups and merged: the same post rows, and the same rule that a group
5
5
  // which is not public is never read, so no post of a private group reaches the page. A public group whose feed Wix refuses the viewer
6
6
  // (401/403: the feed read is a member scope) adds nothing; when every group refuses, the section says posts are for members.
7
- // A post has the Like and Share its own group's feed allows the viewer; when no post may be liked, a sign-in or join gate shows instead.
7
+ // A post has the Like, Comment and Share of the single-group feed, read against its own group's feed permissions: a refused Like or
8
+ // Comment still shows and sends the viewer to sign in or to the post's group to join it; when no post may be liked or commented on, a
9
+ // sign-in or join gate shows too.
8
10
  // A page worker registers it under a service name; the descriptor binds `$service:<serviceName>.*` (recipe groups-newsfeed.json).
9
11
  import { defineService } from "@himalaya/state";
10
12
  import { hostSessionFromGlobal } from "@himalaya/iap";
@@ -12,7 +14,7 @@ import { memberAccess } from "./member-access.js";
12
14
  import { queryGroups, type WixGroup } from "@himalaya/wix-groups";
13
15
  import { listFeedItems } from "@himalaya/wix-social-feed";
14
16
  import { copyParam, stashCopy } from "./himi-copy.js";
15
- import { feedGates, feedPermissions, isRefusal, likeAction, mayLikeAny, postRow, viewerMemberId, sharePost, type FeedGates, type GroupFeedRow } from "./group-feed-section.js";
17
+ import { commentActions, commentIdle, feedGates, feedPermissions, isRefusal, likeAction, mayLikeAny, postRow, viewerMemberId, sharePost, type CommentActions, type CommentFields, type FeedGates, type GroupFeedRow } from "./group-feed-section.js";
16
18
 
17
19
  export interface GroupsNewsfeedOptions {
18
20
  /** Show only these groups' posts. */
@@ -26,7 +28,7 @@ export interface NewsfeedRow extends GroupFeedRow {
26
28
  groupName: string;
27
29
  }
28
30
 
29
- export interface GroupsNewsfeedState extends FeedGates {
31
+ export interface GroupsNewsfeedState extends FeedGates, CommentFields {
30
32
  status: "loading" | "ready" | "error";
31
33
  rows: NewsfeedRow[];
32
34
  /** Why the posts are not shown ("" when they are): every group's feed refused the viewer. */
@@ -51,7 +53,7 @@ export function registerGroupsNewsfeedSection(serviceName: string, options: Grou
51
53
  return {
52
54
  status, rows, restrictedText, emptyText: empty ? copyParam("feed.emptyText", "Nothing has been posted yet — start the conversation.") : "",
53
55
  notLoading: status !== "loading", notErrored: status !== "error", noRows: !rows.length, noEmpty: !empty, noRestricted: !restrictedText,
54
- ...feedGates(rows, parts.signedIn === true),
56
+ ...feedGates(rows, parts.signedIn === true), ...commentIdle(),
55
57
  };
56
58
  };
57
59
  const session = hostSessionFromGlobal();
@@ -62,7 +64,7 @@ export function registerGroupsNewsfeedSection(serviceName: string, options: Grou
62
64
  const service = defineService<GroupsNewsfeedState, {
63
65
  load: (state: GroupsNewsfeedState, arg?: unknown) => Promise<GroupsNewsfeedState | undefined>; clear: () => Promise<GroupsNewsfeedState>;
64
66
  like: (state: GroupsNewsfeedState, arg?: unknown) => Promise<GroupsNewsfeedState | undefined>; share: (state: GroupsNewsfeedState, arg?: unknown) => Promise<GroupsNewsfeedState | undefined>;
65
- }>(serviceName, {
67
+ } & CommentActions<GroupsNewsfeedState>>(serviceName, {
66
68
  state: view("loading"),
67
69
  // The posts are member-scoped: never written to disk and restored for the next person on the device.
68
70
  notHydrated: Object.keys(view("loading")) as Array<keyof GroupsNewsfeedState>,
@@ -105,6 +107,7 @@ export function registerGroupsNewsfeedSection(serviceName: string, options: Grou
105
107
  },
106
108
  like: likeAction((): GroupsNewsfeedState => service.getState(), () => sequence),
107
109
  share: async (state, arg) => { await sharePost(state.rows, arg, (row) => row.groupName); return undefined; },
110
+ ...commentActions((): GroupsNewsfeedState => service.getState(), () => sequence),
108
111
  },
109
112
  });
110
113
  // Signing in or out on another screen changes who the feed is read for.
@@ -7,6 +7,7 @@
7
7
  // confirmed public call that submits a join request: the group screen is where its policy is explained);
8
8
  // a group the member joined or asked to join -> "Joined" / "Pending request", a status rather than a control.
9
9
  // A visitor's tap signs in first and then opens the group (the shared member-screen opener). A secret group is listed only to its members.
10
+ // Each row's line under the name is the One App's "Public · 2 members": the group's visibility and its member count.
10
11
  // The list's header Search (the source's `groups.openGroupsListSearch`) opens a search field in the section: it finds a group by name or
11
12
  // teaser among every group the section may show, not only the first `limit` (himi_groups hides its own search on a short list).
12
13
  // A page worker registers it under a service name; the descriptor binds `$service:<serviceName>.*` (recipes groups-list.json, groups-cards.json).
@@ -17,6 +18,7 @@ import { getMyMember } from "@himalaya/wix-members";
17
18
  import { groupImage } from "./himi-media.js";
18
19
  import { copyParam, stashCopy } from "./himi-copy.js";
19
20
  import { groupMemberCount } from "./group-member-count.js";
21
+ import { groupPrivacyLabel } from "./group-privacy.js";
20
22
  import { descriptionBody } from "./rich-body.js";
21
23
  import { memberIdentity } from "./himi-account.js";
22
24
  import { CONTINUATION_BUDGET_MS, memberScreenNav, within } from "./member-screen.js";
@@ -170,7 +172,11 @@ function groupRow(group: WixGroup, cards: boolean, membership: string | undefine
170
172
  const image = groupImage(group, cards ? GROUP_CARD : GROUP_THUMB);
171
173
  const teaser = descriptionBody(group.teaser).bodyText;
172
174
  const body = descriptionBody(group.description, teaser).bodyText;
173
- const meta = count == null ? "" : groupMemberCount(count);
175
+ // The One App's line under the name: the group's visibility and its member count ("Public · 2 members"), either one alone when the
176
+ // other is unknown. A status Wix did not send (or sent as UNKNOWN) adds no label.
177
+ const status = privacyOf(group);
178
+ const privacy = status && status !== "UNKNOWN" ? groupPrivacyLabel(status) : "";
179
+ const meta = [privacy, count == null ? "" : groupMemberCount(count)].filter(Boolean).join(" · ");
174
180
  return {
175
181
  id: group.id || title, title,
176
182
  subtitle: snippet(teaser) || snippet(body) || copyParam("groups.subtitleFallback", "Join the conversation."),