@wix/himalaya-cli 0.1407.0 → 0.1408.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 (51) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/builder.d.ts +1 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +4 -0
  3. package/dist/cli.mjs +41 -30
  4. package/dist/preview-assets.generated.bin +0 -0
  5. package/guides/component-reference.json +1 -1
  6. package/guides/component-reference.md +4 -0
  7. package/package.json +2 -2
  8. package/templates/beauty-salon-owner/dev/index.ts +49 -30
  9. package/templates/beauty-salon-owner/tier5-src/_shared/aria-chat.ts +8 -6
  10. package/templates/beauty-salon-owner/tier5-src/_shared/aria-widget-model.ts +84 -1
  11. package/templates/beauty-salon-owner/tier5-src/_shared/aria-widget-view.ts +34 -13
  12. package/templates/community-club-owner/dev/index.ts +49 -30
  13. package/templates/community-club-owner/tier5-src/_shared/aria-chat.ts +8 -6
  14. package/templates/community-club-owner/tier5-src/_shared/aria-widget-model.ts +84 -1
  15. package/templates/community-club-owner/tier5-src/_shared/aria-widget-view.ts +34 -13
  16. package/templates/events-meetups-owner/dev/index.ts +49 -30
  17. package/templates/events-meetups-owner/tier5-src/_shared/aria-chat.ts +8 -6
  18. package/templates/events-meetups-owner/tier5-src/_shared/aria-widget-model.ts +84 -1
  19. package/templates/events-meetups-owner/tier5-src/_shared/aria-widget-view.ts +34 -13
  20. package/templates/gym-fitness-owner/dev/index.ts +49 -30
  21. package/templates/gym-fitness-owner/tier5-src/_shared/aria-chat.ts +8 -6
  22. package/templates/gym-fitness-owner/tier5-src/_shared/aria-widget-model.ts +84 -1
  23. package/templates/gym-fitness-owner/tier5-src/_shared/aria-widget-view.ts +34 -13
  24. package/templates/nonprofit-cause-owner/dev/index.ts +49 -30
  25. package/templates/nonprofit-cause-owner/tier5-src/_shared/aria-chat.ts +8 -6
  26. package/templates/nonprofit-cause-owner/tier5-src/_shared/aria-widget-model.ts +84 -1
  27. package/templates/nonprofit-cause-owner/tier5-src/_shared/aria-widget-view.ts +34 -13
  28. package/templates/owner-lite/dev/index.ts +49 -30
  29. package/templates/owner-lite/tier5-src/_shared/aria-chat.ts +8 -6
  30. package/templates/owner-lite/tier5-src/_shared/aria-widget-model.ts +84 -1
  31. package/templates/owner-lite/tier5-src/_shared/aria-widget-view.ts +34 -13
  32. package/templates/podcast-creator-owner/dev/index.ts +49 -30
  33. package/templates/podcast-creator-owner/tier5-src/_shared/aria-chat.ts +8 -6
  34. package/templates/podcast-creator-owner/tier5-src/_shared/aria-widget-model.ts +84 -1
  35. package/templates/podcast-creator-owner/tier5-src/_shared/aria-widget-view.ts +34 -13
  36. package/templates/portfolio-creative-owner/dev/index.ts +49 -30
  37. package/templates/portfolio-creative-owner/tier5-src/_shared/aria-chat.ts +8 -6
  38. package/templates/portfolio-creative-owner/tier5-src/_shared/aria-widget-model.ts +84 -1
  39. package/templates/portfolio-creative-owner/tier5-src/_shared/aria-widget-view.ts +34 -13
  40. package/templates/restaurant-owner/dev/index.ts +49 -30
  41. package/templates/restaurant-owner/tier5-src/_shared/aria-chat.ts +8 -6
  42. package/templates/restaurant-owner/tier5-src/_shared/aria-widget-model.ts +84 -1
  43. package/templates/restaurant-owner/tier5-src/_shared/aria-widget-view.ts +34 -13
  44. package/templates/retail-store-owner/dev/index.ts +49 -30
  45. package/templates/retail-store-owner/tier5-src/_shared/aria-chat.ts +8 -6
  46. package/templates/retail-store-owner/tier5-src/_shared/aria-widget-model.ts +84 -1
  47. package/templates/retail-store-owner/tier5-src/_shared/aria-widget-view.ts +34 -13
  48. package/templates/yoga-studio-owner/dev/index.ts +49 -30
  49. package/templates/yoga-studio-owner/tier5-src/_shared/aria-chat.ts +8 -6
  50. package/templates/yoga-studio-owner/tier5-src/_shared/aria-widget-model.ts +84 -1
  51. package/templates/yoga-studio-owner/tier5-src/_shared/aria-widget-view.ts +34 -13
@@ -57677,7 +57677,7 @@ const SCREENS = runtimeSetting({
57677
57677
  "height": 44,
57678
57678
  "shape": "rounded",
57679
57679
  "contentMode": "fill",
57680
- "contentDescription": "$item.title"
57680
+ "contentDescription": "$item.label"
57681
57681
  }
57682
57682
  },
57683
57683
  "modifiers": {
@@ -57685,6 +57685,7 @@ const SCREENS = runtimeSetting({
57685
57685
  }
57686
57686
  },
57687
57687
  "title": "$item.title",
57688
+ "markdown": true,
57688
57689
  "subtitle": "$item.subtitle",
57689
57690
  "trailing": {
57690
57691
  "id": "himi_owner_lite_aria.widget.SINGLE_SELECT.pick_$item.id",
@@ -57949,7 +57950,7 @@ const SCREENS = runtimeSetting({
57949
57950
  }
57950
57951
  },
57951
57952
  "modifiers": {
57952
- "accessibilityLabel": "$item.title"
57953
+ "accessibilityLabel": "$item.label"
57953
57954
  }
57954
57955
  },
57955
57956
  {
@@ -57963,7 +57964,7 @@ const SCREENS = runtimeSetting({
57963
57964
  "height": 36,
57964
57965
  "shape": "rounded",
57965
57966
  "contentMode": "fill",
57966
- "contentDescription": "$item.title"
57967
+ "contentDescription": "$item.label"
57967
57968
  }
57968
57969
  },
57969
57970
  "modifiers": {
@@ -57986,7 +57987,8 @@ const SCREENS = runtimeSetting({
57986
57987
  "props": {
57987
57988
  "text": "$item.title",
57988
57989
  "style": "body",
57989
- "maxLines": 2
57990
+ "maxLines": 2,
57991
+ "markdown": true
57990
57992
  }
57991
57993
  }
57992
57994
  },
@@ -57999,7 +58001,8 @@ const SCREENS = runtimeSetting({
57999
58001
  "text": "$item.subtitle",
58000
58002
  "style": "footnote",
58001
58003
  "color": "textSecondary",
58002
- "maxLines": 2
58004
+ "maxLines": 2,
58005
+ "markdown": true
58003
58006
  }
58004
58007
  },
58005
58008
  "modifiers": {
@@ -58067,7 +58070,7 @@ const SCREENS = runtimeSetting({
58067
58070
  "aspectRatio": 1,
58068
58071
  "shape": "rounded",
58069
58072
  "contentMode": "fill",
58070
- "contentDescription": "$item.title"
58073
+ "contentDescription": "$item.label"
58071
58074
  }
58072
58075
  },
58073
58076
  "modifiers": {
@@ -58099,7 +58102,7 @@ const SCREENS = runtimeSetting({
58099
58102
  }
58100
58103
  },
58101
58104
  "modifiers": {
58102
- "accessibilityLabel": "$item.title"
58105
+ "accessibilityLabel": "$item.label"
58103
58106
  }
58104
58107
  },
58105
58108
  {
@@ -58118,7 +58121,8 @@ const SCREENS = runtimeSetting({
58118
58121
  "props": {
58119
58122
  "text": "$item.title",
58120
58123
  "style": "body",
58121
- "maxLines": 2
58124
+ "maxLines": 2,
58125
+ "markdown": true
58122
58126
  }
58123
58127
  }
58124
58128
  },
@@ -58131,7 +58135,8 @@ const SCREENS = runtimeSetting({
58131
58135
  "text": "$item.subtitle",
58132
58136
  "style": "footnote",
58133
58137
  "color": "textSecondary",
58134
- "maxLines": 2
58138
+ "maxLines": 2,
58139
+ "markdown": true
58135
58140
  }
58136
58141
  },
58137
58142
  "modifiers": {
@@ -58582,7 +58587,7 @@ const SCREENS = runtimeSetting({
58582
58587
  }
58583
58588
  },
58584
58589
  "modifiers": {
58585
- "accessibilityLabel": "$item.title"
58590
+ "accessibilityLabel": "$item.label"
58586
58591
  }
58587
58592
  },
58588
58593
  {
@@ -58596,7 +58601,7 @@ const SCREENS = runtimeSetting({
58596
58601
  "height": 36,
58597
58602
  "shape": "rounded",
58598
58603
  "contentMode": "fill",
58599
- "contentDescription": "$item.title"
58604
+ "contentDescription": "$item.label"
58600
58605
  }
58601
58606
  },
58602
58607
  "modifiers": {
@@ -58619,7 +58624,8 @@ const SCREENS = runtimeSetting({
58619
58624
  "props": {
58620
58625
  "text": "$item.title",
58621
58626
  "style": "body",
58622
- "maxLines": 2
58627
+ "maxLines": 2,
58628
+ "markdown": true
58623
58629
  }
58624
58630
  }
58625
58631
  },
@@ -58632,7 +58638,8 @@ const SCREENS = runtimeSetting({
58632
58638
  "text": "$item.subtitle",
58633
58639
  "style": "footnote",
58634
58640
  "color": "textSecondary",
58635
- "maxLines": 2
58641
+ "maxLines": 2,
58642
+ "markdown": true
58636
58643
  }
58637
58644
  },
58638
58645
  "modifiers": {
@@ -58871,7 +58878,8 @@ const SCREENS = runtimeSetting({
58871
58878
  "props": {
58872
58879
  "text": "$item.title",
58873
58880
  "style": "bodyEmphasis",
58874
- "maxLines": 2
58881
+ "maxLines": 2,
58882
+ "markdown": true
58875
58883
  }
58876
58884
  }
58877
58885
  },
@@ -58883,7 +58891,8 @@ const SCREENS = runtimeSetting({
58883
58891
  "props": {
58884
58892
  "text": "$item.subtitle",
58885
58893
  "style": "title3",
58886
- "maxLines": 1
58894
+ "maxLines": 1,
58895
+ "markdown": true
58887
58896
  }
58888
58897
  },
58889
58898
  "modifiers": {
@@ -58968,7 +58977,8 @@ const SCREENS = runtimeSetting({
58968
58977
  "props": {
58969
58978
  "text": "$item.text",
58970
58979
  "style": "footnote",
58971
- "maxLines": 8
58980
+ "maxLines": 8,
58981
+ "markdown": true
58972
58982
  }
58973
58983
  },
58974
58984
  "modifiers": {
@@ -59413,7 +59423,7 @@ const SCREENS = runtimeSetting({
59413
59423
  "fillWidth": true,
59414
59424
  "aspectRatio": 1.5,
59415
59425
  "contentMode": "fill",
59416
- "contentDescription": "$item.title"
59426
+ "contentDescription": "$item.label"
59417
59427
  }
59418
59428
  },
59419
59429
  "modifiers": {
@@ -59474,7 +59484,8 @@ const SCREENS = runtimeSetting({
59474
59484
  "type": "Text",
59475
59485
  "props": {
59476
59486
  "text": "$item.title",
59477
- "style": "bodyEmphasis"
59487
+ "style": "bodyEmphasis",
59488
+ "markdown": true
59478
59489
  }
59479
59490
  }
59480
59491
  },
@@ -59486,7 +59497,8 @@ const SCREENS = runtimeSetting({
59486
59497
  "props": {
59487
59498
  "text": "$item.subtitle",
59488
59499
  "style": "body",
59489
- "color": "textSecondary"
59500
+ "color": "textSecondary",
59501
+ "markdown": true
59490
59502
  }
59491
59503
  },
59492
59504
  "modifiers": {
@@ -59500,7 +59512,8 @@ const SCREENS = runtimeSetting({
59500
59512
  "type": "Text",
59501
59513
  "props": {
59502
59514
  "text": "$item.text",
59503
- "style": "body"
59515
+ "style": "body",
59516
+ "markdown": true
59504
59517
  }
59505
59518
  },
59506
59519
  "modifiers": {
@@ -59514,7 +59527,8 @@ const SCREENS = runtimeSetting({
59514
59527
  "type": "Text",
59515
59528
  "props": {
59516
59529
  "text": "$item.listText",
59517
- "style": "body"
59530
+ "style": "body",
59531
+ "markdown": true
59518
59532
  }
59519
59533
  },
59520
59534
  "modifiers": {
@@ -59722,7 +59736,7 @@ const SCREENS = runtimeSetting({
59722
59736
  "height": 36,
59723
59737
  "shape": "rounded",
59724
59738
  "contentMode": "fill",
59725
- "contentDescription": "$item.title"
59739
+ "contentDescription": "$item.label"
59726
59740
  }
59727
59741
  },
59728
59742
  "modifiers": {
@@ -59730,6 +59744,7 @@ const SCREENS = runtimeSetting({
59730
59744
  }
59731
59745
  },
59732
59746
  "title": "$item.title",
59747
+ "markdown": true,
59733
59748
  "subtitle": "$item.subtitle",
59734
59749
  "onTap": {
59735
59750
  "actionId": "tier5.himiOwnerLiteAria.widgetPick",
@@ -59973,7 +59988,7 @@ const SCREENS = runtimeSetting({
59973
59988
  }
59974
59989
  },
59975
59990
  "modifiers": {
59976
- "accessibilityLabel": "$item.title"
59991
+ "accessibilityLabel": "$item.label"
59977
59992
  }
59978
59993
  },
59979
59994
  {
@@ -59987,7 +60002,7 @@ const SCREENS = runtimeSetting({
59987
60002
  "height": 36,
59988
60003
  "shape": "rounded",
59989
60004
  "contentMode": "fill",
59990
- "contentDescription": "$item.title"
60005
+ "contentDescription": "$item.label"
59991
60006
  }
59992
60007
  },
59993
60008
  "modifiers": {
@@ -60331,7 +60346,7 @@ const SCREENS = runtimeSetting({
60331
60346
  }
60332
60347
  },
60333
60348
  "modifiers": {
60334
- "accessibilityLabel": "$item.title"
60349
+ "accessibilityLabel": "$item.label"
60335
60350
  }
60336
60351
  },
60337
60352
  {
@@ -60350,7 +60365,8 @@ const SCREENS = runtimeSetting({
60350
60365
  "props": {
60351
60366
  "text": "$item.title",
60352
60367
  "style": "body",
60353
- "maxLines": 2
60368
+ "maxLines": 2,
60369
+ "markdown": true
60354
60370
  }
60355
60371
  }
60356
60372
  },
@@ -60363,7 +60379,8 @@ const SCREENS = runtimeSetting({
60363
60379
  "text": "$item.subtitle",
60364
60380
  "style": "footnote",
60365
60381
  "color": "textSecondary",
60366
- "maxLines": 2
60382
+ "maxLines": 2,
60383
+ "markdown": true
60367
60384
  }
60368
60385
  },
60369
60386
  "modifiers": {
@@ -60427,7 +60444,7 @@ const SCREENS = runtimeSetting({
60427
60444
  }
60428
60445
  },
60429
60446
  "modifiers": {
60430
- "accessibilityLabel": "$item.title"
60447
+ "accessibilityLabel": "$item.label"
60431
60448
  }
60432
60449
  },
60433
60450
  {
@@ -60446,7 +60463,8 @@ const SCREENS = runtimeSetting({
60446
60463
  "props": {
60447
60464
  "text": "$item.title",
60448
60465
  "style": "body",
60449
- "maxLines": 2
60466
+ "maxLines": 2,
60467
+ "markdown": true
60450
60468
  }
60451
60469
  }
60452
60470
  },
@@ -60459,7 +60477,8 @@ const SCREENS = runtimeSetting({
60459
60477
  "text": "$item.subtitle",
60460
60478
  "style": "footnote",
60461
60479
  "color": "textSecondary",
60462
- "maxLines": 2
60480
+ "maxLines": 2,
60481
+ "markdown": true
60463
60482
  }
60464
60483
  },
60465
60484
  "modifiers": {
@@ -77,7 +77,7 @@ import type { FileHandle } from "@himalaya/sdk-types";
77
77
  import { createAriaUploadQueue } from "./aria-upload-queue.js";
78
78
  import { runClientToolExchange, type AriaClientTools, type ConsentMemory } from "./aria-client-tools.js";
79
79
  import { proseOfParts, scanEnvelopes, stripHidden } from "./aria-widgets.js";
80
- import { isWebUrl, stripMarkdown } from "./aria-widget-model.js";
80
+ import { drawnText, isWebUrl, stripMarkdown } from "./aria-widget-model.js";
81
81
  import {
82
82
  DEFAULT_QUESTIONNAIRE_COPY,
83
83
  NO_WIDGET,
@@ -86,6 +86,7 @@ import {
86
86
  questionnaireAnswers,
87
87
  questionnaireSynced,
88
88
  sameQuestionnaire,
89
+ withLabels,
89
90
  type QuestionnaireCopy,
90
91
  type SubtreeSlot,
91
92
  type WidgetOptionRow,
@@ -2573,7 +2574,7 @@ export function createAriaChat(o: AriaChatOptions): AriaChatCore {
2573
2574
  const withWidgetQuery = (w: WidgetView, query: string): WidgetView => {
2574
2575
  const needle = query.toLowerCase();
2575
2576
  const suggestions = !needle ? w.options : w.options.filter((option) =>
2576
- `${option.title} ${option.subtitle} ${option.text}`.toLowerCase().includes(needle));
2577
+ [option.title, option.subtitle, option.text].map(drawnText).join(" ").toLowerCase().includes(needle));
2577
2578
  return { ...w, query, suggestions, suggestionsEmpty: suggestions.length === 0,
2578
2579
  noMatches: !!needle && suggestions.length === 0 };
2579
2580
  };
@@ -2693,7 +2694,7 @@ export function createAriaChat(o: AriaChatOptions): AriaChatCore {
2693
2694
  options = items.map((item, i) => {
2694
2695
  const pictureUrl = isWixMediaHost(hostOf(item.imageUrl)) ? item.imageUrl : "";
2695
2696
  return {
2696
- id: `o${i}`, value: item.id, title: item.title, subtitle: item.subtitle,
2697
+ id: `o${i}`, value: item.id, title: item.title, label: item.title, subtitle: item.subtitle,
2697
2698
  subtitleHidden: !item.subtitle, text: "", textHidden: true, badge: "", badgeHidden: true,
2698
2699
  pictureUrl, pictureHidden: !pictureUrl, buttonLabel: "", buttonHidden: true,
2699
2700
  listText: "", benefits: [], listHidden: true, selected: false, respondText: "",
@@ -3599,7 +3600,8 @@ export function createAriaChat(o: AriaChatOptions): AriaChatCore {
3599
3600
  // Transcript scroll — a conversation rehydrated with no send token (state persisted
3600
3601
  // before tokens existed) still opens at its latest turn.
3601
3602
  const opened = s.scrollSend || isGreetingOnly(messages) ? {} : openedAtLatest(s, messages);
3602
- const reused: AriaChatState = { ...s, status: "ready", messages, prompts: promptsFor(messages, chipsOf(s)), ...opened };
3603
+ const reused: AriaChatState = { ...s, status: "ready", messages, prompts: promptsFor(messages, chipsOf(s)), ...opened,
3604
+ ...(s.widget ? { widget: withLabels(s.widget) } : {}) };
3603
3605
  // A persisted state can be waiting on a fetch that died with the previous
3604
3606
  // process; nothing would ever settle it, so ask again. And one minted by a
3605
3607
  // bundle from before the suggestions existed never asked at all — the
@@ -4081,8 +4083,8 @@ export function createAriaChat(o: AriaChatOptions): AriaChatCore {
4081
4083
  : questionnaire
4082
4084
  ? [questionnaireAnswers(w)].filter(Boolean)
4083
4085
  : option && !option.selected
4084
- ? [option.title || option.value]
4085
- : w.options.filter((o) => o.selected).map((o) => o.title || o.value);
4086
+ ? [option.label || option.title || option.value]
4087
+ : w.options.filter((o) => o.selected).map((o) => o.label || o.title || o.value);
4086
4088
  const content = substituteSelection(template, selected).trim();
4087
4089
  if (!content) return s;
4088
4090
  if (duplicate(s, content)) return s;
@@ -210,6 +210,88 @@ export function stripMarkdown(src: string): string {
210
210
  return t.trim();
211
211
  }
212
212
 
213
+ /** A literal `*` in prose drawn with `markdown: true`. Web and Android pair any two
214
+ * asterisks (`2*4 *Pine*` would italicise `4 `) and neither honours a backslash
215
+ * escape, so a star that is not part of emphasis is drawn as U+2217, which looks
216
+ * the same and parses as nothing. `drawnText` maps it back. The trailing word
217
+ * joiner (invisible) is what tells it apart from a U+2217 the prose already had:
218
+ * `emphasisMarkdown` drops a joiner that follows one in its input, so only a
219
+ * sentinel carries it. */
220
+ const LITERAL_STAR = "\u2217\u2060";
221
+ /** An underscore inside a code span, parked until emphasis has been read. */
222
+ const CODE_UNDERSCORE = "\u0005";
223
+
224
+ /** `stripMarkdown`, keeping inline emphasis.
225
+ *
226
+ * Option prose is drawn by `Text(markdown: true)` / `ListItem(markdown: true)`,
227
+ * so bold and italic can survive — everything else is stripped as `stripMarkdown`
228
+ * strips it. Emphasis is re-emitted as `**x**` / `*x*` only: web's parser has no
229
+ * underscore syntax and Android's needs word boundaries, so one spelling is the
230
+ * only one every renderer agrees on. Nested emphasis keeps its outer run only,
231
+ * because neither of those parsers pairs `***x***`.
232
+ *
233
+ * Nothing a renderer would turn into a link survives: links and images are
234
+ * unwrapped until none is left (a nested `[[a](x)](tel:…)` would otherwise
235
+ * rebuild one) and `<scheme:…>` autolinks lose their brackets. Every asterisk
236
+ * left over is a `LITERAL_STAR`, so no marker the renderers could mis-pair is
237
+ * ever emitted. `drawnText` of the result is the text the row shows. */
238
+ export function emphasisMarkdown(src: string): string {
239
+ if (!stripMarkdown(src)) return "";
240
+ const BOLD_OPEN = "\u0001", BOLD_CLOSE = "\u0002", EM_OPEN = "\u0003", EM_CLOSE = "\u0004";
241
+ // Inside a run, a paired nested marker is dropped (the outer run wins) and a lone star
242
+ // is content — it survives as a literal one. Double before single, or the inner
243
+ // `*x*` of `_**x**_` is read as the italic and its outer stars are left over.
244
+ const flat = (inner: string) => inner.replace(/[\u0001-\u0004]/g, "")
245
+ .replace(/\*\*([^*\n]+)\*\*/g, "$1").replace(/\*([^*\n]+)\*/g, "$1");
246
+ const bold = (inner: string) => `${BOLD_OPEN}${flat(inner)}${BOLD_CLOSE}`;
247
+ const em = (inner: string) => `${EM_OPEN}${flat(inner)}${EM_CLOSE}`;
248
+ let t = src.replace(/[\u0001-\u0005]/g, "").replace(/\u2217\u2060/g, "\u2217");
249
+ t = t.replace(/```[a-zA-Z0-9]*\n?/g, "").replace(/```/g, "");
250
+ // A code span is never read as emphasis: its paired markers are dropped, as
251
+ // `stripMarkdown` drops them, and whatever is left is parked so no prose marker
252
+ // can pair with it.
253
+ t = t.replace(/`([^`]+)`/g, (_, x: string) => x
254
+ .replace(/\*\*([^*]+)\*\*/g, "$1").replace(/\*([^*]+)\*/g, "$1")
255
+ .replace(/__([^_]+)__/g, "$1").replace(/_([^_]+)_/g, "$1")
256
+ .replace(/\*/g, LITERAL_STAR).replace(/_/g, CODE_UNDERSCORE));
257
+ for (let prev = ""; prev !== t;) {
258
+ prev = t;
259
+ t = t.replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/\[([^\]]+)\]\([^)]*\)/g, "$1");
260
+ }
261
+ t = t.replace(/<([a-zA-Z][a-zA-Z0-9+.-]*:[^>\s]*)>/g, "$1");
262
+ // Line-level markup first, so a bullet's or a rule's `*` is gone before emphasis is read.
263
+ t = t.replace(/^#{1,6}\s+/gm, "");
264
+ t = t.replace(/^>\s?/gm, "");
265
+ t = t.replace(/^\s*([-*_])\1{2,}\s*$/gm, "");
266
+ t = t.replace(/^\s*[-*+]\s+/gm, "• ");
267
+ // Emphasis, strictly delimited (no space just inside a marker), parked behind control
268
+ // characters. Bold may contain single stars — an inner italic — which it drops.
269
+ // Underscores first, so an asterisk run around them absorbs them. Only at word
270
+ // boundaries, as CommonMark reads them: an identifier like `snake_case_name` is
271
+ // not italic.
272
+ // An underscore between two word characters is content, so `_foo_bar_` is one run.
273
+ t = t.replace(/(^|[^\w])__(?=\S)((?:[^_\n]|(?<=\w)_(?=\w))*?[^\s_])__(?!\w)/g, (_, pre, x) => pre + bold(x));
274
+ t = t.replace(/(^|[^\w])_(?=\S)((?:[^_\n]|(?<=\w)_(?=\w))*?[^\s_])_(?!\w)/g, (_, pre, x) => pre + em(x));
275
+ t = t.replace(/\*\*\*(?=\S)([^*\n]*?\S)\*\*\*/g, (_, x) => bold(x));
276
+ t = t.replace(/\*\*(?=[^\s*])((?:[^*\n]|\*(?!\*))*?[^\s*])\*\*/g, (_, x) => bold(x));
277
+ t = t.replace(/(^|[^\w*])\*(?=[^\s*])([^*\n]*?[^\s*])\*(?![\w*])/g, (_, pre, x) => pre + em(x));
278
+ t = t.replace(/\n{3,}/g, "\n\n");
279
+ t = t.replace(/\*/g, LITERAL_STAR).replace(new RegExp(CODE_UNDERSCORE, "g"), "_");
280
+ t = t.replace(/\u0001([^\u0002]*)\u0002/g, "**$1**").replace(/\u0003([^\u0004]*)\u0004/g, "*$1*");
281
+ // (A literal star inside a run was converted with the rest, before the run's own
282
+ // markers were written back.)
283
+ return t.trim();
284
+ }
285
+
286
+ /** What a row drawn with `markdown: true` shows for `emphasisMarkdown` output: the
287
+ * text with its `**x**` / `*x*` markers removed and literal stars restored. The
288
+ * accessibility name and the search haystack use this, so they say exactly what
289
+ * is on screen. */
290
+ export function drawnText(s: string): string {
291
+ return (s || "").replace(/\*\*([^*\n]+)\*\*/g, "$1").replace(/\*([^*\n]+)\*/g, "$1")
292
+ .replace(new RegExp(LITERAL_STAR, "g"), "*");
293
+ }
294
+
213
295
  /** A display string, whether the wire wrote it bare or wrapped.
214
296
  *
215
297
  * QUESTIONNAIRE writes every label as `{ text: "…" }` — question titles,
@@ -323,7 +405,8 @@ export function optionsOf(o: Record<string, unknown> | null): WidgetOption[] {
323
405
  const color = stringAt(spec, "color");
324
406
  const hex = /^#[0-9a-f]{6}$/i.test(color);
325
407
  const tint = hex ? "accentPrimary" : !name || name === "Confirm" ? "success" : "textPrimary";
326
- return { text: stripMarkdown(textOf(entry)),
408
+ // Drawn with `markdown: true`, like the option prose above it.
409
+ return { text: emphasisMarkdown(textOf(entry)),
327
410
  icon: name === "Gift" ? "gift" : name === "Send" ? "paper_plane" : "check",
328
411
  color: tint, colorHex: hex ? color : "",
329
412
  successHidden: tint !== "success", plainHidden: tint !== "textPrimary", customHidden: tint !== "accentPrimary" };
@@ -13,7 +13,7 @@
13
13
  // the transcript bubbles already use for their three link slots.
14
14
 
15
15
  import type { NormalizedWidget, WidgetBenefit, WidgetKind, WidgetOption } from "./aria-widget-model.js";
16
- import { SELECTED_TOKEN, VALUES_TOKEN, isWebUrl, stripMarkdown } from "./aria-widget-model.js";
16
+ import { SELECTED_TOKEN, VALUES_TOKEN, drawnText, emphasisMarkdown, isWebUrl, stripMarkdown } from "./aria-widget-model.js";
17
17
  import { oauthView } from "./aria-widget-oauth.js";
18
18
  import { composeGenericCard } from "./aria-generic-widget.js";
19
19
  import { formatNumber } from "./engine-intl.js";
@@ -81,7 +81,11 @@ export interface WidgetRow {
81
81
  export interface WidgetOptionRow {
82
82
  id: string;
83
83
  value: string;
84
+ /** Drawn prose: inline emphasis kept (`**x**` / `*x*`), parsed by `markdown: true`. */
84
85
  title: string;
86
+ /** `title` stripped to plain text — the accessibility name, the search haystack,
87
+ * and anything echoed back as text. */
88
+ label: string;
85
89
  subtitle: string;
86
90
  subtitleHidden: boolean;
87
91
  text: string;
@@ -400,7 +404,7 @@ export const DEFAULT_QUESTIONNAIRE_COPY: QuestionnaireCopy = {
400
404
  /** A question's answer as the owner would say it: the chosen choices' titles,
401
405
  * then anything typed. Empty when unanswered. */
402
406
  function answerOf(q: WidgetQuestion): string {
403
- const parts = q.choices.filter((c) => c.selected).map((c) => c.title || c.value);
407
+ const parts = q.choices.filter((c) => c.selected).map((c) => c.label || c.title || c.value);
404
408
  const typed = q.freeText.trim();
405
409
  if (typed) parts.push(typed);
406
410
  return parts.join(", ");
@@ -648,23 +652,26 @@ function optionRow(
648
652
  // raw `text` is still exported below for anything that wants both.
649
653
  // "Has a title" is judged on the STRIPPED title: a title of pure markup (`***`) falls back
650
654
  // to the option's other prose exactly as a missing one does.
651
- const strippedTitle = stripMarkdown(o.title);
652
- const hasTitle = !!strippedTitle;
653
- const rowTitle = hasTitle ? strippedTitle : stripMarkdown(o.text || o.subtitle);
654
- const rowSubtitle = hasTitle
655
- ? stripMarkdown(o.subtitle || o.text)
656
- : stripMarkdown(o.text && o.subtitle ? o.subtitle : "");
657
- // Every `*Hidden` flag follows the STRIPPED value: prose that is only markup
658
- // (`---`, `***`, an image with empty alt) strips to "" and must not paint an
659
- // empty node.
660
- const text = stripMarkdown(o.text);
661
- const listText = stripMarkdown(o.listText);
655
+ const hasTitle = !!stripMarkdown(o.title);
656
+ const titleSrc = hasTitle ? o.title : (o.text || o.subtitle);
657
+ const subtitleSrc = hasTitle ? (o.subtitle || o.text) : (o.text && o.subtitle ? o.subtitle : "");
658
+ // The drawn prose keeps its inline emphasis (`**three**` is bold on
659
+ // every renderer, as in the native reference); the descriptor parses it with
660
+ // `markdown: true`. Every `*Hidden` flag and the accessibility `label` follow
661
+ // the STRIPPED value: prose that is only markup (`---`, `***`, an image with
662
+ // empty alt) strips to "" and must not paint an empty node, and a screen
663
+ // reader must not read `**`.
664
+ const rowTitle = emphasisMarkdown(titleSrc);
665
+ const rowSubtitle = emphasisMarkdown(subtitleSrc);
666
+ const text = emphasisMarkdown(o.text);
667
+ const listText = emphasisMarkdown(o.listText);
662
668
  const benefits = (o.benefits ?? []).filter((b) => b.text);
663
669
  const badge = stripMarkdown(o.badge || "");
664
670
  return {
665
671
  id: `o${i}`,
666
672
  value: o.value,
667
673
  title: rowTitle,
674
+ label: drawnText(rowTitle),
668
675
  subtitle: rowSubtitle, subtitleHidden: !rowSubtitle,
669
676
  text, textHidden: !text,
670
677
  pictureUrl, pictureHidden: !pictureUrl,
@@ -693,6 +700,20 @@ function isDisclosedSame(disclose: Disclose, url: string): boolean {
693
700
  return disclose({ label: probe, url }) === probe;
694
701
  }
695
702
 
703
+ /** A widget persisted by a bundle that predates `WidgetOptionRow.label` — rows carry
704
+ * plain titles and no label. Rehydrating one as saved would leave every row's
705
+ * accessibility name empty, so its label is backfilled from the title. */
706
+ export function withLabels(w: WidgetView): WidgetView {
707
+ const fill = (rows: WidgetOptionRow[] | undefined) =>
708
+ rows?.map((o) => (typeof o.label === "string" ? o : { ...o, label: drawnText(o.title) }));
709
+ return {
710
+ ...w,
711
+ options: fill(w.options) ?? w.options,
712
+ suggestions: fill(w.suggestions) ?? w.suggestions,
713
+ questions: w.questions?.map((q) => ({ ...q, choices: fill(q.choices) ?? q.choices })) ?? w.questions,
714
+ };
715
+ }
716
+
696
717
  /** Re-derive an ASYNC_TOOL widget for a new job state.
697
718
  *
698
719
  * Separate from `viewOf` because it runs on a LIVE widget rather than a fresh