@wix/himalaya-cli 0.1661.0 → 0.1663.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 (73) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/builder.d.ts +17 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/audio-record/src/index.d.ts +4 -1
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +26 -0
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/members-v1/src/index.d.ts +26 -0
  5. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +3 -0
  6. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdui.mjs +8 -0
  7. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-members.mjs +4 -0
  8. package/dist/browser-plane/assets.json +5 -5
  9. package/dist/browser-plane/preview-deferred/{fcafca348b6b973cfc2eadc938ddec3c515c641874cbca1667a43b22e1bf7a39.bin → 5fe817d61d13666ee8e6951d96a873f768ef305462735f6030cce105f1c21488.bin} +1 -1
  10. package/dist/browser-plane/sw.js +8 -8
  11. package/dist/cli.mjs +1147 -731
  12. package/dist/preview-assets.generated.bin +0 -0
  13. package/fixtures/wix-canned.json +1 -0
  14. package/guides/component-reference.json +13 -4
  15. package/guides/component-reference.md +26 -6
  16. package/guides/himi-json-output.md +8 -0
  17. package/guides/index.json +1 -1
  18. package/guides/one-app-section-mappings.md +3 -4
  19. package/guides/one-app-to-himi-app.md +20 -1
  20. package/guides/sdk-reference.json +24 -1
  21. package/package.json +2 -2
  22. package/templates/beauty-salon/recipes/announcement-card.json +72 -0
  23. package/templates/beauty-salon/tier5-src/_shared/announcement-section.ts +122 -0
  24. package/templates/beauty-salon/tier5-src/_shared/engine-intl.ts +8 -0
  25. package/templates/beauty-salon-owner/tier5-src/_shared/engine-intl.ts +8 -0
  26. package/templates/branded-lite/dev/index.ts +791 -169
  27. package/templates/branded-lite/l10n/en.json +46 -13
  28. package/templates/branded-lite/l10n/he.json +59 -7
  29. package/templates/branded-lite/recipes/announcement-card.json +72 -0
  30. package/templates/branded-lite/tier5-src/_shared/announcement-section.ts +122 -0
  31. package/templates/branded-lite/tier5-src/_shared/engine-intl.ts +8 -0
  32. package/templates/branded-lite/tier5-src/wix-spaces-member-detail/index.ts +367 -63
  33. package/templates/community-club/l10n/he.json +2 -2
  34. package/templates/community-club/recipes/announcement-card.json +72 -0
  35. package/templates/community-club/tier5-src/_shared/announcement-section.ts +122 -0
  36. package/templates/community-club/tier5-src/_shared/engine-intl.ts +8 -0
  37. package/templates/community-club-owner/tier5-src/_shared/engine-intl.ts +8 -0
  38. package/templates/conference/tier5-src/_shared/engine-intl.ts +8 -0
  39. package/templates/events-meetups/recipes/announcement-card.json +72 -0
  40. package/templates/events-meetups/tier5-src/_shared/announcement-section.ts +122 -0
  41. package/templates/events-meetups/tier5-src/_shared/engine-intl.ts +8 -0
  42. package/templates/events-meetups-owner/tier5-src/_shared/engine-intl.ts +8 -0
  43. package/templates/gym-fitness/recipes/announcement-card.json +72 -0
  44. package/templates/gym-fitness/tier5-src/_shared/announcement-section.ts +122 -0
  45. package/templates/gym-fitness/tier5-src/_shared/engine-intl.ts +8 -0
  46. package/templates/gym-fitness-owner/tier5-src/_shared/engine-intl.ts +8 -0
  47. package/templates/nonprofit-cause/recipes/announcement-card.json +72 -0
  48. package/templates/nonprofit-cause/tier5-src/_shared/announcement-section.ts +122 -0
  49. package/templates/nonprofit-cause/tier5-src/_shared/engine-intl.ts +8 -0
  50. package/templates/nonprofit-cause-owner/tier5-src/_shared/engine-intl.ts +8 -0
  51. package/templates/owner-lite/tier5-src/_shared/engine-intl.ts +8 -0
  52. package/templates/podcast-creator/recipes/announcement-card.json +72 -0
  53. package/templates/podcast-creator/tier5-src/_shared/announcement-section.ts +122 -0
  54. package/templates/podcast-creator/tier5-src/_shared/engine-intl.ts +8 -0
  55. package/templates/podcast-creator-owner/tier5-src/_shared/engine-intl.ts +8 -0
  56. package/templates/portfolio-creative/recipes/announcement-card.json +72 -0
  57. package/templates/portfolio-creative/tier5-src/_shared/announcement-section.ts +122 -0
  58. package/templates/portfolio-creative/tier5-src/_shared/engine-intl.ts +8 -0
  59. package/templates/portfolio-creative-owner/tier5-src/_shared/engine-intl.ts +8 -0
  60. package/templates/restaurant/recipes/announcement-card.json +72 -0
  61. package/templates/restaurant/tier5-src/_shared/announcement-section.ts +122 -0
  62. package/templates/restaurant/tier5-src/_shared/engine-intl.ts +8 -0
  63. package/templates/restaurant-owner/tier5-src/_shared/engine-intl.ts +8 -0
  64. package/templates/retail-store/recipes/announcement-card.json +72 -0
  65. package/templates/retail-store/tier5-src/_shared/announcement-section.ts +122 -0
  66. package/templates/retail-store/tier5-src/_shared/engine-intl.ts +8 -0
  67. package/templates/retail-store-owner/tier5-src/_shared/engine-intl.ts +8 -0
  68. package/templates/salon-spa/tier5-src/_shared/engine-intl.ts +8 -0
  69. package/templates/wholesale-store/tier5-src/_shared/engine-intl.ts +8 -0
  70. package/templates/yoga-studio/recipes/announcement-card.json +72 -0
  71. package/templates/yoga-studio/tier5-src/_shared/announcement-section.ts +122 -0
  72. package/templates/yoga-studio/tier5-src/_shared/engine-intl.ts +8 -0
  73. package/templates/yoga-studio-owner/tier5-src/_shared/engine-intl.ts +8 -0
@@ -255,6 +255,13 @@
255
255
  "key": "subscriptionDetail.accessDenied",
256
256
  "keyOrigin": "string-table"
257
257
  },
258
+ "h_10d80f2197a3": {
259
+ "source": "This member's profile isn't available.",
260
+ "kind": "EmptyState.subtitle",
261
+ "translation": "",
262
+ "key": "member.notFoundBody",
263
+ "keyOrigin": "string-table"
264
+ },
258
265
  "h_114689d00245": {
259
266
  "source": "Why are you hiding this post?",
260
267
  "kind": "Text.text",
@@ -714,13 +721,6 @@
714
721
  "key": "forumPost.notFoundTitle",
715
722
  "keyOrigin": "string-table"
716
723
  },
717
- "h_2b120576ef8e": {
718
- "source": "This member is no longer available.",
719
- "kind": "Text.text",
720
- "translation": "",
721
- "key": "member.notFoundBody",
722
- "keyOrigin": "string-table"
723
- },
724
724
  "h_2bfc736745fa": {
725
725
  "source": "Personal info",
726
726
  "kind": "Text.text",
@@ -871,6 +871,13 @@
871
871
  "key": "collection.retryPage",
872
872
  "keyOrigin": "string-table"
873
873
  },
874
+ "h_3181562695a5": {
875
+ "source": "Couldn't follow. Try again.",
876
+ "kind": "Snackbar.message",
877
+ "translation": "",
878
+ "key": "member.followError",
879
+ "keyOrigin": "string-table"
880
+ },
874
881
  "h_325fcc2da726": {
875
882
  "source": "Connecting to live updates",
876
883
  "kind": "Worker.copy",
@@ -1218,6 +1225,13 @@
1218
1225
  "key": "form.loadErrorTitle",
1219
1226
  "keyOrigin": "string-table"
1220
1227
  },
1228
+ "h_4790bd1d8215": {
1229
+ "source": "Forum posts",
1230
+ "kind": "Text.text",
1231
+ "translation": "",
1232
+ "key": "member.forumPostsTitle",
1233
+ "keyOrigin": "string-table"
1234
+ },
1221
1235
  "h_48331398e3aa": {
1222
1236
  "source": "Choose someone to message.",
1223
1237
  "kind": "Text.text",
@@ -2039,6 +2053,13 @@
2039
2053
  "key": "explore.blogBody",
2040
2054
  "keyOrigin": "string-table"
2041
2055
  },
2056
+ "h_7fef20e1cfed": {
2057
+ "source": "Blog posts",
2058
+ "kind": "Text.text",
2059
+ "translation": "",
2060
+ "key": "member.blogPostsTitle",
2061
+ "keyOrigin": "string-table"
2062
+ },
2042
2063
  "h_8048c6e22689": {
2043
2064
  "source": "Keep subscription",
2044
2065
  "kind": "Button.title",
@@ -2434,7 +2455,7 @@
2434
2455
  },
2435
2456
  "h_950a9a80ddbc": {
2436
2457
  "source": "Member not found",
2437
- "kind": "Text.text",
2458
+ "kind": "EmptyState.title",
2438
2459
  "translation": "",
2439
2460
  "key": "member.notFoundTitle",
2440
2461
  "keyOrigin": "string-table"
@@ -3455,6 +3476,13 @@
3455
3476
  "key": "notifsettings.sampleBody",
3456
3477
  "keyOrigin": "string-table"
3457
3478
  },
3479
+ "h_c87c07eeb596": {
3480
+ "source": "Couldn't unfollow. Try again.",
3481
+ "kind": "Snackbar.message",
3482
+ "translation": "",
3483
+ "key": "member.unfollowError",
3484
+ "keyOrigin": "string-table"
3485
+ },
3458
3486
  "h_c88c289ab8ec": {
3459
3487
  "source": "Follow this order",
3460
3488
  "kind": "Button.title",
@@ -4792,6 +4820,11 @@
4792
4820
  "kind": "Text.text",
4793
4821
  "translation": ""
4794
4822
  },
4823
+ "h_66587a7a62a9": {
4824
+ "source": "Follow",
4825
+ "kind": "Button.title",
4826
+ "translation": ""
4827
+ },
4795
4828
  "h_6710a08693bf": {
4796
4829
  "source": "Your gift cards and balances.",
4797
4830
  "kind": "Text.text",
@@ -4972,6 +5005,11 @@
4972
5005
  "kind": "Button.title",
4973
5006
  "translation": ""
4974
5007
  },
5008
+ "h_90eeb1008380": {
5009
+ "source": "Following",
5010
+ "kind": "Button.title",
5011
+ "translation": ""
5012
+ },
4975
5013
  "h_93c54b09342d": {
4976
5014
  "source": "This service isn't available for online booking. Contact us to book it.",
4977
5015
  "kind": "Banner.title",
@@ -5182,11 +5220,6 @@
5182
5220
  "kind": "EmptyState.title",
5183
5221
  "translation": ""
5184
5222
  },
5185
- "h_dadf25fd6fe2": {
5186
- "source": "Back to members",
5187
- "kind": "Button.title",
5188
- "translation": ""
5189
- },
5190
5223
  "h_db3f81436889": {
5191
5224
  "source": "Redeem",
5192
5225
  "kind": "Button.title",
@@ -611,11 +611,6 @@
611
611
  "key": "forumPost.notFoundTitle",
612
612
  "translation": "הפוסט לא נמצא"
613
613
  },
614
- "h_2b120576ef8e": {
615
- "source": "This member is no longer available.",
616
- "key": "member.notFoundBody",
617
- "translation": "החבר הזה אינו זמין עוד."
618
- },
619
614
  "h_2bfc736745fa": {
620
615
  "source": "Personal info",
621
616
  "key": "accountSettings.personalInfo",
@@ -3152,8 +3147,8 @@
3152
3147
  },
3153
3148
  "h_a00ed42505ab": {
3154
3149
  "source": "No collections match your search.",
3155
- "translation": "אין אוספים שתואמים לחיפוש.",
3156
- "key": "cms.searchEmptyText"
3150
+ "key": "cms.searchEmptyText",
3151
+ "translation": "אין אוספים שתואמים לחיפוש."
3157
3152
  },
3158
3153
  "h_a689a999a5e6": {
3159
3154
  "source": "Expired",
@@ -3295,6 +3290,31 @@
3295
3290
  "key": "plans.hideBenefits",
3296
3291
  "translation": "הסתרת הטבות התוכנית"
3297
3292
  },
3293
+ "h_10d80f2197a3": {
3294
+ "source": "This member's profile isn't available.",
3295
+ "key": "member.notFoundBody",
3296
+ "translation": "הפרופיל של החבר הזה אינו זמין."
3297
+ },
3298
+ "h_4790bd1d8215": {
3299
+ "source": "Forum posts",
3300
+ "key": "member.forumPostsTitle",
3301
+ "translation": "פוסטים בפורום"
3302
+ },
3303
+ "h_7fef20e1cfed": {
3304
+ "source": "Blog posts",
3305
+ "key": "member.blogPostsTitle",
3306
+ "translation": "פוסטים בבלוג"
3307
+ },
3308
+ "h_3181562695a5": {
3309
+ "source": "Couldn't follow. Try again.",
3310
+ "key": "member.followError",
3311
+ "translation": "לא הצלחנו לעקוב. נסו שוב."
3312
+ },
3313
+ "h_c87c07eeb596": {
3314
+ "source": "Couldn't unfollow. Try again.",
3315
+ "key": "member.unfollowError",
3316
+ "translation": "לא הצלחנו להפסיק לעקוב. נסו שוב."
3317
+ },
3298
3318
  "h_03e89418ffdf": {
3299
3319
  "source": "Your Home",
3300
3320
  "translation": "הבית שלך"
@@ -7113,6 +7133,38 @@
7113
7133
  "h_760205a2fb62": {
7114
7134
  "source": "One-time payment",
7115
7135
  "translation": "תשלום חד-פעמי"
7136
+ },
7137
+ "h_9d7ef006cbda": {
7138
+ "source": "Joined {month}",
7139
+ "translation": "הצטרף/ה ב{month}"
7140
+ },
7141
+ "h_0e62cb0889eb": {
7142
+ "source": "1 follower",
7143
+ "translation": "עוקב/ת אחד/ת"
7144
+ },
7145
+ "h_3d3ccf464c66": {
7146
+ "source": "{count} followers",
7147
+ "translation": "{count} עוקבים"
7148
+ },
7149
+ "h_e879e7848731": {
7150
+ "source": "{count} following",
7151
+ "translation": "עוקב/ת אחרי {count}"
7152
+ },
7153
+ "h_273179910c65": {
7154
+ "source": "Unfollow {name}?",
7155
+ "translation": "להפסיק לעקוב אחרי {name}?"
7156
+ },
7157
+ "h_e3a6fe565c7f": {
7158
+ "source": "Unfollow",
7159
+ "translation": "הפסק לעקוב"
7160
+ },
7161
+ "h_991e124bf34a": {
7162
+ "source": "{minutes} min read",
7163
+ "translation": "{minutes} דקות קריאה"
7164
+ },
7165
+ "h_f2c4f3cec324": {
7166
+ "source": "Share profile",
7167
+ "translation": "שתף פרופיל"
7116
7168
  }
7117
7169
  }
7118
7170
  }
@@ -0,0 +1,72 @@
1
+ {
2
+ "_recipe": "The business's latest announcement (title, rich body, creator and date), read at runtime. Service: registerAnnouncementSection(svc). Hidden whole while there is nothing to show.",
3
+ "_placeholders": {
4
+ "svc": "service name the page worker registered with registerAnnouncementSection",
5
+ "id": "unique node id prefix (e.g. the screen id)",
6
+ "heading": "the source section's own title when it shows one, else an empty string"
7
+ },
8
+ "node": {
9
+ "id": "{{id}}.announcement",
10
+ "body": {
11
+ "package": "himalaya",
12
+ "type": "VStack",
13
+ "props": {
14
+ "spacing": 8,
15
+ "alignment": "leading",
16
+ "children": [
17
+ {
18
+ "id": "{{id}}.heading",
19
+ "body": { "package": "himalaya", "type": "Text", "props": { "text": "{{heading}}", "style": "title3", "collapseWhenEmpty": true } }
20
+ },
21
+ {
22
+ "id": "{{id}}.title",
23
+ "body": { "package": "himalaya", "type": "Text", "props": { "text": "$service:{{svc}}.title", "style": "bodyEmphasis", "collapseWhenEmpty": true } },
24
+ "modifiers": { "hiddenPath": "$service:{{svc}}.noTitle" }
25
+ },
26
+ {
27
+ "id": "{{id}}.body_rich",
28
+ "body": {
29
+ "package": "himalaya",
30
+ "type": "RichContent",
31
+ "props": {
32
+ "documentJsonPath": "$service:{{svc}}.bodyJson",
33
+ "onLink": { "actionId": "tier5.{{svc}}.openLink" },
34
+ "fallback": { "id": "{{id}}.body_rich_fallback", "body": { "package": "himalaya", "type": "Text", "props": { "text": "$service:{{svc}}.body", "style": "body", "color": "textSecondary" } } }
35
+ }
36
+ },
37
+ "modifiers": { "hiddenPath": "$service:{{svc}}.noBodyJson" }
38
+ },
39
+ {
40
+ "id": "{{id}}.body",
41
+ "body": { "package": "himalaya", "type": "Text", "props": { "text": "$service:{{svc}}.body", "style": "body", "color": "textSecondary", "collapseWhenEmpty": true } },
42
+ "modifiers": { "hiddenPath": "$service:{{svc}}.hasBodyJson" }
43
+ },
44
+ {
45
+ "id": "{{id}}.meta",
46
+ "body": {
47
+ "package": "himalaya",
48
+ "type": "HStack",
49
+ "props": {
50
+ "spacing": 8,
51
+ "alignment": "center",
52
+ "children": [
53
+ {
54
+ "id": "{{id}}.creator",
55
+ "body": { "package": "himalaya", "type": "Text", "props": { "text": "$service:{{svc}}.creator", "style": "caption", "color": "textSecondary", "collapseWhenEmpty": true } },
56
+ "modifiers": { "hiddenPath": "$service:{{svc}}.noCreator" }
57
+ },
58
+ {
59
+ "id": "{{id}}.created",
60
+ "body": { "package": "himalaya", "type": "Text", "props": { "text": "$service:{{svc}}.created", "style": "caption", "color": "textSecondary", "collapseWhenEmpty": true } },
61
+ "modifiers": { "hiddenPath": "$service:{{svc}}.noCreated" }
62
+ }
63
+ ]
64
+ }
65
+ }
66
+ }
67
+ ]
68
+ }
69
+ },
70
+ "modifiers": { "hiddenPath": "$service:{{svc}}.noAnnouncement", "padding": { "leading": 16, "trailing": 16, "top": 16, "bottom": 16 } }
71
+ }
72
+ }
@@ -0,0 +1,122 @@
1
+ // The INLINE announcement section: the business's latest announcement, read at RUNTIME (never baked at migration time) and
2
+ // shown next to other sections. It is the call the native Branded app's announcement section makes
3
+ // (wix-one-app-member-view, Announcement/serverApiService.ts `fetchLatestAnnouncement`): one GET of the latest announcement with the
4
+ // app's own signed instance (Member when signed in, else Visitor), which the `wixApi` bridge attaches.
5
+ //
6
+ // READ-ONLY, ALWAYS: `includeReaderData` stays false (true needs the One App manage permission and answers 403), and nothing here
7
+ // ever marks an announcement as seen (`AddCurrentMemberAsReader` is a write). Known server behaviour, shared with the native app: a
8
+ // site that has no announcement yet gets its default welcome text saved once, by this very read.
9
+ // A phone sends the signed instance to this URL only because the native hosts (Android and Swift `WixApiCapability`) allow exactly this
10
+ // GET (host, path, method and the reader-data-off query) for the consumer providers; a build without that entry refuses the read and the
11
+ // section shows nothing. The local web preview has no such list.
12
+ // The `announcement-card` recipe is the card that reads it, bound as `$service:<serviceName>.*`.
13
+ import { defineService } from "@himalaya/state";
14
+ import { richBody } from "./rich-body.js";
15
+ import { formatDateMedium } from "./engine-intl.js";
16
+ import { openRichLink } from "./rich-content-link.js";
17
+
18
+ /** The one call: the latest announcement, without the reader data. */
19
+ export const LATEST_ANNOUNCEMENT_URL = "https://manage.wix.com/_api/mobile-apps-announcements/v1/announcements/latest?includeReaderData=false";
20
+
21
+ interface LatestAnnouncementResponse {
22
+ announcement?: {
23
+ title?: unknown;
24
+ /** The announcement's content: a DraftJS raw state for announcements written in the app, or a Ricos document (as a Struct). */
25
+ content?: unknown;
26
+ createdDate?: unknown;
27
+ creatorMemberProfileData?: { nickname?: unknown; imageUrl?: unknown };
28
+ };
29
+ }
30
+
31
+ export interface AnnouncementState {
32
+ status: "loading" | "ready" | "error";
33
+ hasAnnouncement: boolean; noAnnouncement: boolean;
34
+ title: string; noTitle: boolean;
35
+ /** The rich body as one document string (RichContent draws nothing for ""), and its plain text, shown when there is no document. */
36
+ bodyJson: string; hasBodyJson: boolean; noBodyJson: boolean;
37
+ body: string; noBody: boolean;
38
+ created: string; noCreated: boolean;
39
+ creator: string; noCreator: boolean;
40
+ creatorImage: string; noCreatorImage: boolean;
41
+ isLoading: boolean; notLoading: boolean;
42
+ isErrored: boolean; notErrored: boolean;
43
+ }
44
+
45
+ const text = (value: unknown): string => (typeof value === "string" ? value.trim() : "");
46
+
47
+ /** The plain text of a DraftJS raw state (`{ blocks: [{ text }], entityMap }`), which is what the service's `content` really is for
48
+ * announcements written in the app (observed on a live site, 2026-11-11), or undefined when `content` is not one. Only the blocks' own
49
+ * text is read: the entity map (links, images) is never followed. */
50
+ function draftPlainText(content: unknown): string | undefined {
51
+ let doc = content;
52
+ if (typeof doc === "string") { try { doc = JSON.parse(doc); } catch { return undefined; } }
53
+ const blocks = (doc as { blocks?: unknown } | null | undefined)?.blocks;
54
+ if (!Array.isArray(blocks)) return undefined;
55
+ return blocks.map((block) => text((block as { text?: unknown } | null)?.text)).filter(Boolean).join("\n\n");
56
+ }
57
+
58
+ function derive(status: AnnouncementState["status"], fields: { title?: string; bodyJson?: string; body?: string; created?: string; creator?: string; creatorImage?: string } = {}): AnnouncementState {
59
+ const title = fields.title ?? "", bodyJson = fields.bodyJson ?? "", body = fields.body ?? "", created = fields.created ?? "";
60
+ const creator = fields.creator ?? "", creatorImage = fields.creatorImage ?? "";
61
+ const hasAnnouncement = status === "ready" && !!(title || bodyJson || body);
62
+ return {
63
+ status, hasAnnouncement, noAnnouncement: !hasAnnouncement,
64
+ title, noTitle: !title,
65
+ bodyJson, hasBodyJson: !!bodyJson, noBodyJson: !bodyJson,
66
+ body, noBody: !body,
67
+ created, noCreated: !created,
68
+ creator, noCreator: !creator,
69
+ creatorImage, noCreatorImage: !creatorImage,
70
+ isLoading: status === "loading", notLoading: status !== "loading",
71
+ isErrored: status === "error", notErrored: status !== "error",
72
+ };
73
+ }
74
+
75
+ /** The state for a latest-announcement response: an empty or missing announcement shows nothing, never a placeholder. */
76
+ export function announcementState(response: unknown): AnnouncementState {
77
+ const announcement = (response as LatestAnnouncementResponse | undefined)?.announcement;
78
+ if (!announcement || typeof announcement !== "object") return derive("ready");
79
+ // A DraftJS body shows as its plain text; a Ricos body keeps its rich document.
80
+ const draft = draftPlainText(announcement.content);
81
+ const rich = draft !== undefined ? { bodyJson: "", bodyText: draft } : richBody(announcement.content);
82
+ const when = typeof announcement.createdDate === "string" ? new Date(announcement.createdDate) : undefined;
83
+ const image = text(announcement.creatorMemberProfileData?.imageUrl);
84
+ return derive("ready", {
85
+ title: text(announcement.title),
86
+ bodyJson: rich.bodyJson, body: rich.bodyText,
87
+ created: when && !Number.isNaN(when.getTime()) ? formatDateMedium(when) : "",
88
+ creator: text(announcement.creatorMemberProfileData?.nickname),
89
+ // An avatar is shown only from an https URL.
90
+ creatorImage: /^https:\/\//i.test(image) ? image : "",
91
+ });
92
+ }
93
+
94
+ /** `options` is the generator's uniform second argument; the section has no settings of its own, so nothing is read from it. */
95
+ export function registerAnnouncementSection(serviceName: string, _options: object = {}) {
96
+ // The failure path reads the CURRENT state, not the snapshot the call began with: a refresh that fails after another load already
97
+ // showed an announcement must not erase it.
98
+ let current: () => AnnouncementState = () => derive("loading");
99
+ const handle = defineService<AnnouncementState, { load: (state: AnnouncementState) => Promise<AnnouncementState>; openLink: (state: AnnouncementState, arg?: unknown) => Promise<AnnouncementState> }>(serviceName, {
100
+ state: derive("loading"),
101
+ actions: {
102
+ load: async () => {
103
+ // A failed refresh (offline, a 5xx) keeps an announcement that is already showing: only a screen with nothing to show goes to error.
104
+ const failed = (): AnnouncementState => { const now = current(); return now.hasAnnouncement ? now : derive("error"); };
105
+ try {
106
+ const api = (globalThis as { himalaya?: { wixApi?: { call: (method: string, path: string) => Promise<unknown> } } }).himalaya?.wixApi;
107
+ if (!api) return failed();
108
+ return announcementState(await api.call("GET", LATEST_ANNOUNCEMENT_URL));
109
+ } catch {
110
+ return failed();
111
+ }
112
+ },
113
+ // A link tapped inside the rich body: only http(s), mailto and tel links open (the shared rich-link rule).
114
+ openLink: async (state, arg) => {
115
+ await openRichLink(arg);
116
+ return state;
117
+ },
118
+ },
119
+ });
120
+ current = () => handle.getState() as AnnouncementState;
121
+ return handle;
122
+ }
@@ -94,6 +94,14 @@ export function formatDateMedium(date: Date, locale = appLocale(), timeZone?: st
94
94
  return `${MONTHS_SHORT[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`;
95
95
  }
96
96
 
97
+ /** `{ month: "short", year: "numeric" }` — "Jan 2026". */
98
+ export function formatMonthYear(date: Date, locale = "en-US", timeZone?: string): string {
99
+ if (hasIntl()) {
100
+ return dateFormat(locale, { month: "short", year: "numeric" }, timeZone).format(date);
101
+ }
102
+ return `${MONTHS_SHORT[date.getMonth()]} ${date.getFullYear()}`;
103
+ }
104
+
97
105
  /** `{ month: "short", day: "numeric" }` — "Jan 5". */
98
106
  export function formatMonthDay(date: Date, locale = appLocale(), timeZone?: string): string {
99
107
  if (hasIntl()) {