@wix/himalaya-cli 0.2009.0 → 0.2011.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 (52) hide show
  1. package/dist/cli.mjs +144 -53
  2. package/guides/one-app-section-mappings.md +1 -1
  3. package/guides/one-app-to-himi-app.md +3 -0
  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 +20 -0
  8. package/templates/branded-lite/l10n/cs.json +20 -0
  9. package/templates/branded-lite/l10n/da.json +20 -0
  10. package/templates/branded-lite/l10n/de.json +20 -0
  11. package/templates/branded-lite/l10n/el.json +20 -0
  12. package/templates/branded-lite/l10n/es.json +20 -0
  13. package/templates/branded-lite/l10n/fi.json +20 -0
  14. package/templates/branded-lite/l10n/fr.json +20 -0
  15. package/templates/branded-lite/l10n/he.json +16 -0
  16. package/templates/branded-lite/l10n/hu.json +20 -0
  17. package/templates/branded-lite/l10n/id.json +20 -0
  18. package/templates/branded-lite/l10n/it.json +20 -0
  19. package/templates/branded-lite/l10n/ja.json +20 -0
  20. package/templates/branded-lite/l10n/ko.json +20 -0
  21. package/templates/branded-lite/l10n/lt.json +20 -0
  22. package/templates/branded-lite/l10n/nl.json +20 -0
  23. package/templates/branded-lite/l10n/no.json +20 -0
  24. package/templates/branded-lite/l10n/pl.json +20 -0
  25. package/templates/branded-lite/l10n/pt.json +20 -0
  26. package/templates/branded-lite/l10n/ru.json +20 -0
  27. package/templates/branded-lite/l10n/sv.json +20 -0
  28. package/templates/branded-lite/l10n/th.json +20 -0
  29. package/templates/branded-lite/l10n/tr.json +20 -0
  30. package/templates/branded-lite/l10n/uk.json +20 -0
  31. package/templates/branded-lite/l10n/vi.json +20 -0
  32. package/templates/branded-lite/l10n/zh.json +20 -0
  33. package/templates/branded-lite/recipes/members-carousel.json +55 -3
  34. package/templates/branded-lite/recipes/plans-card.json +630 -3
  35. package/templates/branded-lite/recipes/products-carousel.json +74 -10
  36. package/templates/branded-lite/recipes/products-grid.json +74 -10
  37. package/templates/branded-lite/recipes/programs-filters.json +51 -2
  38. package/templates/branded-lite/tier5-src/_shared/himi-store-facets.ts +2 -7
  39. package/templates/branded-lite/tier5-src/_shared/member-row-extras.ts +18 -17
  40. package/templates/branded-lite/tier5-src/_shared/members-directory-view.ts +12 -0
  41. package/templates/branded-lite/tier5-src/_shared/members-directory.ts +26 -13
  42. package/templates/branded-lite/tier5-src/_shared/plan-facts.ts +15 -6
  43. package/templates/branded-lite/tier5-src/_shared/plans-section.ts +32 -6
  44. package/templates/branded-lite/tier5-src/_shared/products-section.ts +5 -0
  45. package/templates/branded-lite/tier5-src/_shared/programs-section.ts +19 -16
  46. package/templates/branded-lite/tier5-src/_shared/store-ribbon.ts +11 -0
  47. package/templates/gym-fitness/tier5-src/_shared/himi-store-facets.ts +2 -7
  48. package/templates/gym-fitness/tier5-src/_shared/store-ribbon.ts +11 -0
  49. package/templates/portfolio-creative/tier5-src/_shared/himi-store-facets.ts +2 -7
  50. package/templates/portfolio-creative/tier5-src/_shared/store-ribbon.ts +11 -0
  51. package/templates/retail-store/tier5-src/_shared/himi-store-facets.ts +2 -7
  52. 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
  }
@@ -11,6 +11,7 @@
11
11
  // retitles them like any other worker string.
12
12
  import { normalizeFormattedPrice, productImage, productOptions, productPrice, type StoreProduct } from "./himi-store.js";
13
13
  import { readSavedProducts, toggleSavedProduct } from "./himi-store-saved.js";
14
+ import { ribbonText } from "./store-ribbon.js";
14
15
  import { cleanTitle, initials } from "./himi-text.js";
15
16
  import { copyParam, copyTemplate } from "./himi-copy.js";
16
17
  import { formatCurrency } from "./engine-intl.js";
@@ -185,13 +186,7 @@ function swatchFields(hexes: string[], onSale: boolean) {
185
186
  };
186
187
  }
187
188
 
188
- /** The ribbon the merchant set, whichever catalog answered: V3 `{ id, name }`, V1 a plain string. Read through a
189
- * local type, not a `StoreProduct` member: other workers already extend that type with their own `ribbon`. */
190
- export function ribbonText(p: StoreProduct): string {
191
- const ribbon = (p as { ribbon?: unknown }).ribbon;
192
- const name = typeof ribbon === "string" ? ribbon : typeof (ribbon as { name?: unknown } | null | undefined)?.name === "string" ? (ribbon as { name: string }).name : "";
193
- return name.trim();
194
- }
189
+ export { ribbonText };
195
190
 
196
191
  /** What the tag row (Sale tag, ribbon, swatches) shows. One rule for every screen that rebuilds it, including
197
192
  * after the App Store presentation changes `onSale`: the ribbon wins over the Sale tag, so a product never
@@ -6,6 +6,7 @@ import { getMyMember, listFollowedMembers, queryMemberActivity } from "@himalaya
6
6
  import { compareIso } from "./engine-intl.js";
7
7
  import { copyParam } from "./himi-copy.js";
8
8
  import { activityText } from "./member-activity.js";
9
+ import { roleLabel } from "./members-directory-view.js";
9
10
  import type { ReadAccess } from "./member-read.js";
10
11
 
11
12
  /** The One App row draws ONE badge chip and a "+N" chip for the rest. */
@@ -17,9 +18,8 @@ const ASSIGNMENT_PAGES = 10;
17
18
  const MIN_CONTRAST = 3;
18
19
 
19
20
  export interface MemberRowExtras {
20
- /** Role line, then the last-active line when there is one. The role line reads "Member" for everyone: the activity route
21
- * also answers a role (an admin's is "ADMIN"), but the One App's wording for the other roles is not recorded here,
22
- * so none is guessed. */
21
+ /** Role line, then the last-active line when there is one. The role is the One App members service's ("Owner", "Admin",
22
+ * "Member", by `roleLabel`); a member it did not answer for, or a role it has no wording for, shows none rather than a guess. */
23
23
  subtitle: string;
24
24
  badgeTitle: string; badgeColor: string; noBadge: boolean;
25
25
  badgeMore: string; noBadgeMore: boolean;
@@ -108,23 +108,23 @@ async function readBadges(ids: string[], tenant: string): Promise<Map<string, Ba
108
108
  return result;
109
109
  }
110
110
 
111
- /** memberId → "Active 11h ago" etc., for the members the One App service knows and has something to say about.
112
- * An older native build refuses the route; that leaves the activity line out and nothing else. */
113
- export async function readActivity(ids: string[]): Promise<Map<string, string>> {
114
- return (await readMemberActivity(ids)).texts;
115
- }
116
-
117
- /** The same read, plus the members the service answered for: one it answered for with nothing to say (never opened the app) is
118
- * known and shows no line, which is different from one it did not answer for at all. */
119
- export async function readMemberActivity(ids: string[]): Promise<{ texts: Map<string, string>; known: Set<string> }> {
111
+ /** memberId → "Active 11h ago" etc. (`texts`), for the members the One App service knows and has something to say about. An older
112
+ * native build refuses the route; that leaves the activity line and the role out, and nothing else. Also the members the service
113
+ * answered for: one it answered for with nothing to say (never opened the app) is
114
+ * known and shows no line, which is different from one it did not answer for at all. `roles` is the role line's word for each
115
+ * member the service named a role for ("Owner", "Admin", "Member"); a member with none, or one it did not answer for, has no entry. */
116
+ export async function readMemberActivity(ids: string[]): Promise<{ texts: Map<string, string>; known: Set<string>; roles: Map<string, string> }> {
120
117
  const texts = new Map<string, string>();
121
118
  const known = new Set<string>();
119
+ const roles = new Map<string, string>();
122
120
  for (const activity of await queryMemberActivity(ids)) {
123
121
  known.add(activity.id);
124
122
  const text = activityText(activity);
125
123
  if (text) texts.set(activity.id, text);
124
+ const role = roleLabel(activity.role);
125
+ if (role) roles.set(activity.id, role);
126
126
  }
127
- return { texts, known };
127
+ return { texts, known, roles };
128
128
  }
129
129
 
130
130
  async function readFollowed(ids: string[], access: ReadAccess): Promise<Set<string>> {
@@ -134,7 +134,9 @@ async function readFollowed(ids: string[], access: ReadAccess): Promise<Set<stri
134
134
 
135
135
  let selfScope = "";
136
136
  let selfId = "";
137
- async function ownMemberId(access: ReadAccess): Promise<string> {
137
+ /** The signed-in member's own id ("" for a Visitor, or when it cannot be read), remembered per site and member: a list hides Follow on
138
+ * the reader's own row. */
139
+ export async function ownMemberId(access: ReadAccess): Promise<string> {
138
140
  if (!access.member.email) return "";
139
141
  const scope = JSON.stringify([access.tenant, access.member.email]);
140
142
  if (selfScope !== scope) {
@@ -154,18 +156,17 @@ const attempt = async <T>(read: Promise<T>, fallback: T): Promise<T> => { try {
154
156
  export async function memberRowExtras(ids: string[], access: ReadAccess): Promise<(id: string) => MemberRowExtras> {
155
157
  const [badges, activity, followed, self] = await Promise.all([
156
158
  attempt(readBadges(ids, access.tenant), new Map<string, BadgeInfo[]>()),
157
- attempt(readActivity(ids), new Map<string, string>()),
159
+ attempt(readMemberActivity(ids), { texts: new Map<string, string>(), known: new Set<string>(), roles: new Map<string, string>() }),
158
160
  attempt(readFollowed(ids, access), new Set<string>()),
159
161
  attempt(ownMemberId(access), ""),
160
162
  ]);
161
163
  const visitor = !access.member.email;
162
- const role = copyParam("members.roleMember", "Member");
163
164
  return (id) => {
164
165
  const held = badges.get(id) ?? [];
165
166
  const more = held.length - MAX_BADGE_CHIPS;
166
167
  const isFollowing = followed.has(id);
167
168
  return {
168
- subtitle: [role, activity.get(id)].filter(Boolean).join(" · "),
169
+ subtitle: [activity.roles.get(id), activity.texts.get(id)].filter(Boolean).join(" · "),
169
170
  badgeTitle: held[0]?.title ?? "", badgeColor: held[0]?.color ?? "", noBadge: !held.length,
170
171
  badgeMore: more > 0 ? `+${more}` : "", noBadgeMore: more <= 0,
171
172
  followLabel: followLabel(isFollowing), isFollowing,
@@ -27,6 +27,18 @@ export function badgeToken(hex: string | undefined): string {
27
27
  return best[0];
28
28
  }
29
29
 
30
+ /** The role line's word for a member's site role, as the One App members list words it ("Owner", "Admin", "Member"). The role comes
31
+ * from the One App members service; a role it did not answer (the route refused, an older native build, a member it does not know)
32
+ * or one this list has no wording for is "", so the row shows no role rather than a guessed "Member". */
33
+ export function roleLabel(role: string | undefined): string {
34
+ switch ((role ?? "").trim().toUpperCase()) {
35
+ case "OWNER": return copyParam("members.roleOwner", "Owner");
36
+ case "ADMIN": return copyParam("members.roleAdmin", "Admin");
37
+ case "MEMBER": return copyParam("members.roleMember", "Member");
38
+ default: return "";
39
+ }
40
+ }
41
+
30
42
  /** "Active 11h ago" within a day, "Last seen <date>" after; "" with no login date (or one in the future). */
31
43
  export function activityLine(lastLogin: string | undefined, now: number): string {
32
44
  const at = lastLogin ? Date.parse(lastLogin) : NaN;
@@ -10,13 +10,13 @@ import { createCollectionQuery } from "./collection-query.js";
10
10
  import { readAccess, assertReadAccess, readAccessDenied, type ReadAccess } from "./member-read.js";
11
11
  import { memberAccessChanged } from "./member-access.js";
12
12
  // The paged badge-assignments read (POST /badges/v4/assignments/query; the generated listMembersBadgeIds route answers 404 live).
13
- import { badgesByMember, readMemberActivity } from "./member-row-extras.js";
13
+ import { badgesByMember, ownMemberId, readMemberActivity } from "./member-row-extras.js";
14
14
  import { withEmptyFlags } from "./empty-flags.js";
15
15
  import { stashCopy, copyParam, copyTemplate, copyPlural } from "./himi-copy.js";
16
16
  import { activityLine, badgeToken } from "./members-directory-view.js";
17
17
 
18
18
  export interface MembersDirectoryOptions {
19
- /** "Member" under the name. */
19
+ /** The member's role under the name ("Owner", "Admin", "Member"), as the One App members service names it; none when it names none. */
20
20
  showRole?: boolean;
21
21
  /** "Active 11h ago" / "Last seen <date>", from the member's last login. */
22
22
  showActivity?: boolean;
@@ -40,7 +40,7 @@ const BADGE_PAGES = 5;
40
40
  interface Chip { id: string; label: string; token: string }
41
41
  interface Row {
42
42
  id: string; name: string; subtitle: string; initial: string; photo: string; sectionTitle: string;
43
- role: string; hasRole: boolean; activity: string; hasActivity: boolean; roleLine: string; hasRoleLine: boolean; noRoleLine: boolean;
43
+ role: string; hasRole: boolean; activity: string; hasActivity: boolean; noActivity: boolean; roleLine: string; hasRoleLine: boolean; noRoleLine: boolean;
44
44
  badges: Chip[]; hasBadges: boolean; noBadges: boolean; badgeOverflow: string; hasOverflow: boolean; noOverflow: boolean;
45
45
  badge1Label: string; badge1Token: string; hasBadge1: boolean; noBadge1: boolean;
46
46
  canFollow: boolean; noFollow: boolean; isFollowing: boolean; followLabel: string;
@@ -64,7 +64,13 @@ function name(m: WixMember): string {
64
64
  }
65
65
 
66
66
  /** What the page's extra reads found: unknown stays absent. */
67
- interface Extras { badges: Map<string, Chip[]>; following: Set<string> | undefined; /** "Active 4h ago" / "Last seen …" per member from the One App members service, and the members it answered for. */ activity: { texts: Map<string, string>; known: Set<string> } | undefined }
67
+ interface Extras {
68
+ badges: Map<string, Chip[]>; following: Set<string> | undefined;
69
+ /** "Active 4h ago" / "Last seen …" and the role word per member from the One App members service, and the members it answered for. */
70
+ activity: { texts: Map<string, string>; known: Set<string>; roles: Map<string, string> } | undefined;
71
+ /** The signed-in reader's own member id: their own row has no Follow. "" for a Visitor or when it cannot be read. */
72
+ self: string;
73
+ }
68
74
 
69
75
  export function registerMembersDirectory(serviceName: string, options: MembersDirectoryOptions = {}) {
70
76
  const rail = options.rail;
@@ -98,13 +104,15 @@ export function registerMembersDirectory(serviceName: string, options: MembersDi
98
104
  return badgeCatalog;
99
105
  }
100
106
 
101
- async function extrasFor(members: WixMember[], member: boolean): Promise<Extras> {
107
+ async function extrasFor(members: WixMember[], access: ReadAccess, member: boolean): Promise<Extras> {
102
108
  const ids = members.map((m) => m.id);
103
109
  const badges = new Map<string, Chip[]>();
104
- const [badgeRead, followRead, activityRead] = await Promise.allSettled([
110
+ const [badgeRead, followRead, activityRead, selfRead] = await Promise.allSettled([
105
111
  options.showBadges ? Promise.all([badgeDefinitions(), badgesByMember(ids)]) : Promise.resolve(undefined),
106
112
  options.showFollow && member ? getMyFollowing(ids) : Promise.resolve(undefined),
107
- options.showActivity ? readMemberActivity(ids) : Promise.resolve(undefined),
113
+ // The One App members service answers both the activity line and the role.
114
+ options.showActivity || options.showRole ? readMemberActivity(ids) : Promise.resolve(undefined),
115
+ options.showFollow && member ? ownMemberId(access) : Promise.resolve(""),
108
116
  ]);
109
117
  // A badge or follow read that fails leaves its chips off the rows; the list itself still loads.
110
118
  if (badgeRead.status === "rejected") console.warn("members_directory: the badges could not be read", badgeRead.reason);
@@ -117,12 +125,15 @@ export function registerMembersDirectory(serviceName: string, options: MembersDi
117
125
  if (chips.length) badges.set(memberId, chips);
118
126
  }
119
127
  }
120
- return { badges, following: followRead.status === "fulfilled" ? followRead.value : undefined, activity: activityRead.status === "fulfilled" ? activityRead.value : undefined };
128
+ return { badges, following: followRead.status === "fulfilled" ? followRead.value : undefined, activity: activityRead.status === "fulfilled" ? activityRead.value : undefined,
129
+ self: selfRead.status === "fulfilled" ? selfRead.value : "" };
121
130
  }
122
131
 
123
132
  function row(m: WixMember, extras: Extras, now: number): Row {
124
133
  const n = name(m);
125
- const role = options.showRole ? copyParam("members.roleMember", "Member") : "";
134
+ // The role the One App members service names ("Owner" for the site owner). A member it did not answer for has no known role, and
135
+ // the row says nothing rather than calling the owner a "Member".
136
+ const role = options.showRole ? extras.activity?.roles.get(m.id) ?? "" : "";
126
137
  // The One App members service answers "Active 4h ago" / "Last seen …" for the page. A member it answered for with nothing to say shows no line;
127
138
  // the login date is only for a member it did not answer for (an older native build refuses the route).
128
139
  const activity = !options.showActivity ? "" : extras.activity?.known.has(m.id) ? extras.activity.texts.get(m.id) ?? "" : activityLine(m.lastLoginDate, now);
@@ -133,14 +144,16 @@ export function registerMembersDirectory(serviceName: string, options: MembersDi
133
144
  const slot = (i: number) => ({ label: shown[i]?.label ?? "", token: shown[i]?.token ?? "textSecondary", has: !!shown[i] });
134
145
  const b1 = slot(0);
135
146
  const isFollowing = followed.get(m.id) ?? extras.following?.has(m.id) ?? false;
147
+ // A member never follows themself: the reader's own row has no Follow.
148
+ const follows = !!options.showFollow && m.id !== extras.self;
136
149
  // Login emails are not directory subtitles. Only public profile content is presented.
137
150
  return {
138
151
  id: m.id, name: n, subtitle: "", initial: (n[0] || "#").toUpperCase(), photo: wixMediaUrl(m.profile?.photo?.url, AVATAR_IMAGE) || wixMediaUrl(m.profile?.photo?.id, AVATAR_IMAGE) || "", sectionTitle: "",
139
- role, hasRole: !!role, activity, hasActivity: !!activity, roleLine, hasRoleLine: !!roleLine, noRoleLine: !roleLine,
152
+ role, hasRole: !!role, activity, hasActivity: !!activity, noActivity: !activity, roleLine, hasRoleLine: !!roleLine, noRoleLine: !roleLine,
140
153
  badges: chips, hasBadges: chips.length > 0, noBadges: chips.length === 0, badgeOverflow: overflow, hasOverflow: !!overflow, noOverflow: !overflow,
141
154
  badge1Label: b1.label, badge1Token: b1.token, hasBadge1: b1.has, noBadge1: !b1.has,
142
- canFollow: !!options.showFollow, noFollow: !options.showFollow, isFollowing,
143
- followLabel: options.showFollow ? isFollowing ? copyParam("members.following", "Following") : copyParam("members.follow", "Follow") : "",
155
+ canFollow: follows, noFollow: !follows, isFollowing,
156
+ followLabel: follows ? isFollowing ? copyParam("members.following", "Following") : copyParam("members.follow", "Follow") : "",
144
157
  };
145
158
  }
146
159
 
@@ -191,7 +204,7 @@ export function registerMembersDirectory(serviceName: string, options: MembersDi
191
204
  const next = offset + response.members.length;
192
205
  if (!response.members.length && total !== undefined && total > next) throw new Error("Incomplete member page");
193
206
  signedIn = !!access.member.email;
194
- const extras = await extrasFor(response.members, signedIn);
207
+ const extras = await extrasFor(response.members, access, signedIn);
195
208
  const now = Date.now();
196
209
  const rows = response.members.map(member => row(member, extras, now));
197
210
  // A rail shows the first few matching members of this one page: it never pages, and a badge filter cannot see past the page read.
@@ -4,8 +4,8 @@
4
4
  //
5
5
  // Each duration phrase is ONE plural key per unit, so a translation fits the whole phrase ("por 10 años") instead of
6
6
  // gluing translated words around English ones. Its English fallback is the wording the workers always had. The cadence
7
- // ("one-time", "per month") and the validity ("for 10 years", "Unlimited duration") are separate lines: "one-time" says
8
- // how the plan is paid, never how long it lasts.
7
+ // ("one-time", "per month", "Free plan") and the validity ("for 10 years", "Until canceled") are separate lines: "one-time"
8
+ // says how the plan is paid, never how long it lasts.
9
9
  import type { WixPlan } from "@himalaya/wix-pricing-plans";
10
10
  import { copyParam, copyPlural, copyTemplate } from "./himi-copy.js";
11
11
 
@@ -47,10 +47,19 @@ export function every(count: number, unit: string): string {
47
47
  return copyPlural(`plans.every${unitKey(known)}`, EVERY[known], count);
48
48
  }
49
49
 
50
+ /** The plan states a price, and it is zero. A plan with no price (or one that is not a number) is not called free. */
51
+ export function isFreePlan(plan: WixPlan): boolean {
52
+ const raw = plan.pricing?.price?.value;
53
+ return raw != null && String(raw).trim() !== "" && Number(raw) === 0;
54
+ }
55
+
50
56
  /** How the plan is paid, under its price: "per month" / "every 3 months" for a subscription, "one-time" for a single
51
57
  * payment; "" when the plan names neither. How long access lasts is `planValidityLine`, never this line. */
52
58
  export function planPeriodLine(plan: WixPlan): string {
53
59
  const pricing = plan.pricing;
60
+ // A plan that costs nothing reads "Free plan" beside its price, as the One App card does: a payment cadence would describe a
61
+ // payment the member never makes. How long it lasts is still `planValidityLine`.
62
+ if (isFreePlan(plan)) return copyParam("plans.freePlan", "Free plan");
54
63
  // A single payment wins over a stray `subscription` stub: the pricing kinds are exclusive, and "recurring" beside
55
64
  // "Unlimited duration" would contradict itself.
56
65
  if (pricing?.singlePaymentForDuration || pricing?.singlePaymentUnlimited) return copyParam("plans.oneTimeFact", "one-time");
@@ -62,12 +71,12 @@ export function planPeriodLine(plan: WixPlan): string {
62
71
  return "";
63
72
  }
64
73
 
65
- /** How long the plan's access lasts: "Unlimited duration" (paid once, never ends), "Until canceled" (renews with no end),
66
- * "for 10 years" (a fixed span, or a subscription's cycles × cycle length); "" when the plan does not say. The open-ended
67
- * wording is the plans screen's (`planDuration`); a fixed span keeps the per-unit plural keys. */
74
+ /** How long the plan's access lasts: "Until canceled" (paid once and never ends, or renews with no end), "for 10 years" (a
75
+ * fixed span, or a subscription's cycles × cycle length); "" when the plan does not say. A single payment with unlimited
76
+ * validity reads "Until canceled", as the One App's plan card words it; a fixed span keeps the per-unit plural keys. */
68
77
  export function planValidityLine(plan: WixPlan): string {
69
78
  const pricing = plan.pricing;
70
- if (pricing?.singlePaymentUnlimited) return copyParam("plans.unlimited", "Unlimited duration");
79
+ if (pricing?.singlePaymentUnlimited) return copyParam("plans.untilCanceled", "Until canceled");
71
80
  const single = pricing?.singlePaymentForDuration;
72
81
  const cycle = single ? undefined : pricing?.subscription;
73
82
  if (cycle && !cycle.cycleCount) return copyParam("plans.untilCanceled", "Until canceled");