@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
@@ -57526,7 +57526,7 @@ const SCREENS = runtimeSetting({
57526
57526
  "height": 44,
57527
57527
  "shape": "rounded",
57528
57528
  "contentMode": "fill",
57529
- "contentDescription": "$item.title"
57529
+ "contentDescription": "$item.label"
57530
57530
  }
57531
57531
  },
57532
57532
  "modifiers": {
@@ -57534,6 +57534,7 @@ const SCREENS = runtimeSetting({
57534
57534
  }
57535
57535
  },
57536
57536
  "title": "$item.title",
57537
+ "markdown": true,
57537
57538
  "subtitle": "$item.subtitle",
57538
57539
  "trailing": {
57539
57540
  "id": "himi_owner_lite_aria.widget.SINGLE_SELECT.pick_$item.id",
@@ -57798,7 +57799,7 @@ const SCREENS = runtimeSetting({
57798
57799
  }
57799
57800
  },
57800
57801
  "modifiers": {
57801
- "accessibilityLabel": "$item.title"
57802
+ "accessibilityLabel": "$item.label"
57802
57803
  }
57803
57804
  },
57804
57805
  {
@@ -57812,7 +57813,7 @@ const SCREENS = runtimeSetting({
57812
57813
  "height": 36,
57813
57814
  "shape": "rounded",
57814
57815
  "contentMode": "fill",
57815
- "contentDescription": "$item.title"
57816
+ "contentDescription": "$item.label"
57816
57817
  }
57817
57818
  },
57818
57819
  "modifiers": {
@@ -57835,7 +57836,8 @@ const SCREENS = runtimeSetting({
57835
57836
  "props": {
57836
57837
  "text": "$item.title",
57837
57838
  "style": "body",
57838
- "maxLines": 2
57839
+ "maxLines": 2,
57840
+ "markdown": true
57839
57841
  }
57840
57842
  }
57841
57843
  },
@@ -57848,7 +57850,8 @@ const SCREENS = runtimeSetting({
57848
57850
  "text": "$item.subtitle",
57849
57851
  "style": "footnote",
57850
57852
  "color": "textSecondary",
57851
- "maxLines": 2
57853
+ "maxLines": 2,
57854
+ "markdown": true
57852
57855
  }
57853
57856
  },
57854
57857
  "modifiers": {
@@ -57916,7 +57919,7 @@ const SCREENS = runtimeSetting({
57916
57919
  "aspectRatio": 1,
57917
57920
  "shape": "rounded",
57918
57921
  "contentMode": "fill",
57919
- "contentDescription": "$item.title"
57922
+ "contentDescription": "$item.label"
57920
57923
  }
57921
57924
  },
57922
57925
  "modifiers": {
@@ -57948,7 +57951,7 @@ const SCREENS = runtimeSetting({
57948
57951
  }
57949
57952
  },
57950
57953
  "modifiers": {
57951
- "accessibilityLabel": "$item.title"
57954
+ "accessibilityLabel": "$item.label"
57952
57955
  }
57953
57956
  },
57954
57957
  {
@@ -57967,7 +57970,8 @@ const SCREENS = runtimeSetting({
57967
57970
  "props": {
57968
57971
  "text": "$item.title",
57969
57972
  "style": "body",
57970
- "maxLines": 2
57973
+ "maxLines": 2,
57974
+ "markdown": true
57971
57975
  }
57972
57976
  }
57973
57977
  },
@@ -57980,7 +57984,8 @@ const SCREENS = runtimeSetting({
57980
57984
  "text": "$item.subtitle",
57981
57985
  "style": "footnote",
57982
57986
  "color": "textSecondary",
57983
- "maxLines": 2
57987
+ "maxLines": 2,
57988
+ "markdown": true
57984
57989
  }
57985
57990
  },
57986
57991
  "modifiers": {
@@ -58431,7 +58436,7 @@ const SCREENS = runtimeSetting({
58431
58436
  }
58432
58437
  },
58433
58438
  "modifiers": {
58434
- "accessibilityLabel": "$item.title"
58439
+ "accessibilityLabel": "$item.label"
58435
58440
  }
58436
58441
  },
58437
58442
  {
@@ -58445,7 +58450,7 @@ const SCREENS = runtimeSetting({
58445
58450
  "height": 36,
58446
58451
  "shape": "rounded",
58447
58452
  "contentMode": "fill",
58448
- "contentDescription": "$item.title"
58453
+ "contentDescription": "$item.label"
58449
58454
  }
58450
58455
  },
58451
58456
  "modifiers": {
@@ -58468,7 +58473,8 @@ const SCREENS = runtimeSetting({
58468
58473
  "props": {
58469
58474
  "text": "$item.title",
58470
58475
  "style": "body",
58471
- "maxLines": 2
58476
+ "maxLines": 2,
58477
+ "markdown": true
58472
58478
  }
58473
58479
  }
58474
58480
  },
@@ -58481,7 +58487,8 @@ const SCREENS = runtimeSetting({
58481
58487
  "text": "$item.subtitle",
58482
58488
  "style": "footnote",
58483
58489
  "color": "textSecondary",
58484
- "maxLines": 2
58490
+ "maxLines": 2,
58491
+ "markdown": true
58485
58492
  }
58486
58493
  },
58487
58494
  "modifiers": {
@@ -58720,7 +58727,8 @@ const SCREENS = runtimeSetting({
58720
58727
  "props": {
58721
58728
  "text": "$item.title",
58722
58729
  "style": "bodyEmphasis",
58723
- "maxLines": 2
58730
+ "maxLines": 2,
58731
+ "markdown": true
58724
58732
  }
58725
58733
  }
58726
58734
  },
@@ -58732,7 +58740,8 @@ const SCREENS = runtimeSetting({
58732
58740
  "props": {
58733
58741
  "text": "$item.subtitle",
58734
58742
  "style": "title3",
58735
- "maxLines": 1
58743
+ "maxLines": 1,
58744
+ "markdown": true
58736
58745
  }
58737
58746
  },
58738
58747
  "modifiers": {
@@ -58817,7 +58826,8 @@ const SCREENS = runtimeSetting({
58817
58826
  "props": {
58818
58827
  "text": "$item.text",
58819
58828
  "style": "footnote",
58820
- "maxLines": 8
58829
+ "maxLines": 8,
58830
+ "markdown": true
58821
58831
  }
58822
58832
  },
58823
58833
  "modifiers": {
@@ -59262,7 +59272,7 @@ const SCREENS = runtimeSetting({
59262
59272
  "fillWidth": true,
59263
59273
  "aspectRatio": 1.5,
59264
59274
  "contentMode": "fill",
59265
- "contentDescription": "$item.title"
59275
+ "contentDescription": "$item.label"
59266
59276
  }
59267
59277
  },
59268
59278
  "modifiers": {
@@ -59323,7 +59333,8 @@ const SCREENS = runtimeSetting({
59323
59333
  "type": "Text",
59324
59334
  "props": {
59325
59335
  "text": "$item.title",
59326
- "style": "bodyEmphasis"
59336
+ "style": "bodyEmphasis",
59337
+ "markdown": true
59327
59338
  }
59328
59339
  }
59329
59340
  },
@@ -59335,7 +59346,8 @@ const SCREENS = runtimeSetting({
59335
59346
  "props": {
59336
59347
  "text": "$item.subtitle",
59337
59348
  "style": "body",
59338
- "color": "textSecondary"
59349
+ "color": "textSecondary",
59350
+ "markdown": true
59339
59351
  }
59340
59352
  },
59341
59353
  "modifiers": {
@@ -59349,7 +59361,8 @@ const SCREENS = runtimeSetting({
59349
59361
  "type": "Text",
59350
59362
  "props": {
59351
59363
  "text": "$item.text",
59352
- "style": "body"
59364
+ "style": "body",
59365
+ "markdown": true
59353
59366
  }
59354
59367
  },
59355
59368
  "modifiers": {
@@ -59363,7 +59376,8 @@ const SCREENS = runtimeSetting({
59363
59376
  "type": "Text",
59364
59377
  "props": {
59365
59378
  "text": "$item.listText",
59366
- "style": "body"
59379
+ "style": "body",
59380
+ "markdown": true
59367
59381
  }
59368
59382
  },
59369
59383
  "modifiers": {
@@ -59571,7 +59585,7 @@ const SCREENS = runtimeSetting({
59571
59585
  "height": 36,
59572
59586
  "shape": "rounded",
59573
59587
  "contentMode": "fill",
59574
- "contentDescription": "$item.title"
59588
+ "contentDescription": "$item.label"
59575
59589
  }
59576
59590
  },
59577
59591
  "modifiers": {
@@ -59579,6 +59593,7 @@ const SCREENS = runtimeSetting({
59579
59593
  }
59580
59594
  },
59581
59595
  "title": "$item.title",
59596
+ "markdown": true,
59582
59597
  "subtitle": "$item.subtitle",
59583
59598
  "onTap": {
59584
59599
  "actionId": "tier5.himiOwnerLiteAria.widgetPick",
@@ -59822,7 +59837,7 @@ const SCREENS = runtimeSetting({
59822
59837
  }
59823
59838
  },
59824
59839
  "modifiers": {
59825
- "accessibilityLabel": "$item.title"
59840
+ "accessibilityLabel": "$item.label"
59826
59841
  }
59827
59842
  },
59828
59843
  {
@@ -59836,7 +59851,7 @@ const SCREENS = runtimeSetting({
59836
59851
  "height": 36,
59837
59852
  "shape": "rounded",
59838
59853
  "contentMode": "fill",
59839
- "contentDescription": "$item.title"
59854
+ "contentDescription": "$item.label"
59840
59855
  }
59841
59856
  },
59842
59857
  "modifiers": {
@@ -60180,7 +60195,7 @@ const SCREENS = runtimeSetting({
60180
60195
  }
60181
60196
  },
60182
60197
  "modifiers": {
60183
- "accessibilityLabel": "$item.title"
60198
+ "accessibilityLabel": "$item.label"
60184
60199
  }
60185
60200
  },
60186
60201
  {
@@ -60199,7 +60214,8 @@ const SCREENS = runtimeSetting({
60199
60214
  "props": {
60200
60215
  "text": "$item.title",
60201
60216
  "style": "body",
60202
- "maxLines": 2
60217
+ "maxLines": 2,
60218
+ "markdown": true
60203
60219
  }
60204
60220
  }
60205
60221
  },
@@ -60212,7 +60228,8 @@ const SCREENS = runtimeSetting({
60212
60228
  "text": "$item.subtitle",
60213
60229
  "style": "footnote",
60214
60230
  "color": "textSecondary",
60215
- "maxLines": 2
60231
+ "maxLines": 2,
60232
+ "markdown": true
60216
60233
  }
60217
60234
  },
60218
60235
  "modifiers": {
@@ -60276,7 +60293,7 @@ const SCREENS = runtimeSetting({
60276
60293
  }
60277
60294
  },
60278
60295
  "modifiers": {
60279
- "accessibilityLabel": "$item.title"
60296
+ "accessibilityLabel": "$item.label"
60280
60297
  }
60281
60298
  },
60282
60299
  {
@@ -60295,7 +60312,8 @@ const SCREENS = runtimeSetting({
60295
60312
  "props": {
60296
60313
  "text": "$item.title",
60297
60314
  "style": "body",
60298
- "maxLines": 2
60315
+ "maxLines": 2,
60316
+ "markdown": true
60299
60317
  }
60300
60318
  }
60301
60319
  },
@@ -60308,7 +60326,8 @@ const SCREENS = runtimeSetting({
60308
60326
  "text": "$item.subtitle",
60309
60327
  "style": "footnote",
60310
60328
  "color": "textSecondary",
60311
- "maxLines": 2
60329
+ "maxLines": 2,
60330
+ "markdown": true
60312
60331
  }
60313
60332
  },
60314
60333
  "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