@buoy-gg/ask-buoy 7.0.35 → 7.0.38

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 (286) hide show
  1. package/README.md +73 -15
  2. package/lib/commonjs/blocks/AskBlocks.js +1 -338
  3. package/lib/commonjs/blocks/BlockRenderer.js +1 -250
  4. package/lib/commonjs/blocks/ChromePrototypes.js +1 -514
  5. package/lib/commonjs/blocks/DataBlocks.js +1 -688
  6. package/lib/commonjs/blocks/ExtraBlocks.js +1 -1854
  7. package/lib/commonjs/blocks/MediaBlocks.js +1 -140
  8. package/lib/commonjs/blocks/ReceiptBlocks.js +1 -586
  9. package/lib/commonjs/blocks/blockText.js +1 -0
  10. package/lib/commonjs/blocks/blockText.test.js +1 -0
  11. package/lib/commonjs/blocks/context.js +1 -42
  12. package/lib/commonjs/blocks/icons.js +1 -96
  13. package/lib/commonjs/blocks/index.js +1 -95
  14. package/lib/commonjs/blocks/listRow.test.js +1 -55
  15. package/lib/commonjs/blocks/pageState.js +1 -34
  16. package/lib/commonjs/blocks/pageState.test.js +1 -57
  17. package/lib/commonjs/blocks/primitives.js +1 -401
  18. package/lib/commonjs/blocks/primitivesIndex.js +1 -62
  19. package/lib/commonjs/components/ApprovalCard.js +1 -140
  20. package/lib/commonjs/components/AskBuoyHeader.js +1 -164
  21. package/lib/commonjs/components/AskBuoyIcon.js +1 -19
  22. package/lib/commonjs/components/AskBuoyModal.js +1 -353
  23. package/lib/commonjs/components/AskBuoySettings.js +1 -69
  24. package/lib/commonjs/components/ChangesBar.js +1 -211
  25. package/lib/commonjs/components/Composer.js +1 -175
  26. package/lib/commonjs/components/EmptyState.js +1 -154
  27. package/lib/commonjs/components/KeyboardPad.js +1 -0
  28. package/lib/commonjs/components/Markdown.js +1 -252
  29. package/lib/commonjs/components/MessageList.js +1 -683
  30. package/lib/commonjs/components/QueuedMessages.js +1 -0
  31. package/lib/commonjs/components/ThinkingStrip.js +1 -223
  32. package/lib/commonjs/components/TypingDots.js +1 -63
  33. package/lib/commonjs/components/markdownParse.js +1 -0
  34. package/lib/commonjs/components/markdownParse.test.js +1 -0
  35. package/lib/commonjs/components/useCopyAction.js +1 -50
  36. package/lib/commonjs/index.js +1 -252
  37. package/lib/commonjs/preset.js +1 -90
  38. package/lib/commonjs/store/activityGroups.js +1 -0
  39. package/lib/commonjs/store/activityGroups.test.js +1 -0
  40. package/lib/commonjs/store/askBuoySettings.js +1 -67
  41. package/lib/commonjs/store/askBuoyStore.js +1 -365
  42. package/lib/commonjs/store/blockPlacement.js +1 -0
  43. package/lib/commonjs/store/blockPlacement.test.js +1 -0
  44. package/lib/commonjs/store/queue.test.js +1 -0
  45. package/lib/commonjs/store/resetConversation.js +1 -0
  46. package/lib/commonjs/store/restorePending.test.js +1 -0
  47. package/lib/commonjs/store/restoredIds.test.js +1 -47
  48. package/lib/commonjs/store/suggestions.js +1 -0
  49. package/lib/commonjs/store/suggestions.test.js +1 -0
  50. package/lib/commonjs/store/systemLine.test.js +1 -0
  51. package/lib/commonjs/store/ticketPrompt.js +1 -0
  52. package/lib/commonjs/store/traceText.js +1 -81
  53. package/lib/commonjs/store/traceText.test.js +1 -112
  54. package/lib/commonjs/store/transcriptPersistence.js +1 -208
  55. package/lib/commonjs/store/transcriptPersistence.test.js +1 -185
  56. package/lib/commonjs/store/turnRendering.test.js +1 -0
  57. package/lib/commonjs/store/useAskBuoy.js +1 -400
  58. package/lib/commonjs/store/useAskBuoySettings.js +1 -14
  59. package/lib/commonjs/sync/askBuoySyncAdapter.js +1 -119
  60. package/lib/commonjs/sync/askBuoySyncAdapter.test.js +1 -141
  61. package/lib/commonjs/sync/wire.js +1 -58
  62. package/lib/commonjs/types.js +1 -6
  63. package/lib/module/blocks/AskBlocks.js +1 -331
  64. package/lib/module/blocks/BlockRenderer.js +1 -245
  65. package/lib/module/blocks/ChromePrototypes.js +1 -503
  66. package/lib/module/blocks/DataBlocks.js +1 -674
  67. package/lib/module/blocks/ExtraBlocks.js +1 -1827
  68. package/lib/module/blocks/MediaBlocks.js +1 -135
  69. package/lib/module/blocks/ReceiptBlocks.js +1 -574
  70. package/lib/module/blocks/blockText.js +1 -0
  71. package/lib/module/blocks/blockText.test.js +1 -0
  72. package/lib/module/blocks/context.js +1 -35
  73. package/lib/module/blocks/icons.js +1 -91
  74. package/lib/module/blocks/index.js +1 -8
  75. package/lib/module/blocks/listRow.test.js +1 -56
  76. package/lib/module/blocks/pageState.js +1 -30
  77. package/lib/module/blocks/pageState.test.js +1 -56
  78. package/lib/module/blocks/primitives.js +1 -389
  79. package/lib/module/blocks/primitivesIndex.js +1 -5
  80. package/lib/module/components/ApprovalCard.js +1 -135
  81. package/lib/module/components/AskBuoyHeader.js +1 -161
  82. package/lib/module/components/AskBuoyIcon.js +1 -8
  83. package/lib/module/components/AskBuoyModal.js +1 -348
  84. package/lib/module/components/AskBuoySettings.js +1 -64
  85. package/lib/module/components/ChangesBar.js +1 -206
  86. package/lib/module/components/Composer.js +1 -170
  87. package/lib/module/components/EmptyState.js +1 -149
  88. package/lib/module/components/KeyboardPad.js +1 -0
  89. package/lib/module/components/Markdown.js +1 -246
  90. package/lib/module/components/MessageList.js +1 -677
  91. package/lib/module/components/QueuedMessages.js +1 -0
  92. package/lib/module/components/ThinkingStrip.js +1 -218
  93. package/lib/module/components/TypingDots.js +1 -58
  94. package/lib/module/components/markdownParse.js +1 -0
  95. package/lib/module/components/markdownParse.test.js +1 -0
  96. package/lib/module/components/useCopyAction.js +1 -46
  97. package/lib/module/index.js +1 -34
  98. package/lib/module/preset.js +1 -73
  99. package/lib/module/store/activityGroups.js +1 -0
  100. package/lib/module/store/activityGroups.test.js +1 -0
  101. package/lib/module/store/askBuoySettings.js +1 -62
  102. package/lib/module/store/askBuoyStore.js +1 -361
  103. package/lib/module/store/blockPlacement.js +1 -0
  104. package/lib/module/store/blockPlacement.test.js +1 -0
  105. package/lib/module/store/queue.test.js +1 -0
  106. package/lib/module/store/resetConversation.js +1 -0
  107. package/lib/module/store/restorePending.test.js +1 -0
  108. package/lib/module/store/restoredIds.test.js +1 -46
  109. package/lib/module/store/suggestions.js +1 -0
  110. package/lib/module/store/suggestions.test.js +1 -0
  111. package/lib/module/store/systemLine.test.js +1 -0
  112. package/lib/module/store/ticketPrompt.js +1 -0
  113. package/lib/module/store/traceText.js +1 -75
  114. package/lib/module/store/traceText.test.js +1 -111
  115. package/lib/module/store/transcriptPersistence.js +1 -198
  116. package/lib/module/store/transcriptPersistence.test.js +1 -184
  117. package/lib/module/store/turnRendering.test.js +1 -0
  118. package/lib/module/store/useAskBuoy.js +1 -394
  119. package/lib/module/store/useAskBuoySettings.js +1 -9
  120. package/lib/module/sync/askBuoySyncAdapter.js +1 -114
  121. package/lib/module/sync/askBuoySyncAdapter.test.js +1 -140
  122. package/lib/module/sync/wire.js +1 -47
  123. package/lib/module/types.js +1 -4
  124. package/lib/typescript/blocks/DataBlocks.d.ts +11 -0
  125. package/lib/typescript/blocks/ExtraBlocks.d.ts +18 -2
  126. package/lib/typescript/blocks/blockText.d.ts +14 -0
  127. package/lib/typescript/blocks/blockText.test.d.ts +2 -0
  128. package/lib/typescript/blocks/primitives.d.ts +16 -1
  129. package/lib/typescript/components/ApprovalCard.d.ts +9 -1
  130. package/lib/typescript/components/AskBuoyHeader.d.ts +31 -1
  131. package/lib/typescript/components/Composer.d.ts +16 -1
  132. package/lib/typescript/components/EmptyState.d.ts +5 -1
  133. package/lib/typescript/components/KeyboardPad.d.ts +33 -0
  134. package/lib/typescript/components/Markdown.d.ts +0 -10
  135. package/lib/typescript/components/MessageList.d.ts +7 -2
  136. package/lib/typescript/components/QueuedMessages.d.ts +10 -0
  137. package/lib/typescript/components/markdownParse.d.ts +49 -0
  138. package/lib/typescript/components/markdownParse.test.d.ts +2 -0
  139. package/lib/typescript/preset.d.ts +4 -2
  140. package/lib/typescript/store/activityGroups.d.ts +29 -0
  141. package/lib/typescript/store/activityGroups.test.d.ts +2 -0
  142. package/lib/typescript/store/askBuoySettings.d.ts +22 -0
  143. package/lib/typescript/store/askBuoyStore.d.ts +174 -9
  144. package/lib/typescript/store/blockPlacement.d.ts +30 -0
  145. package/lib/typescript/store/blockPlacement.test.d.ts +2 -0
  146. package/lib/typescript/store/queue.test.d.ts +2 -0
  147. package/lib/typescript/store/resetConversation.d.ts +38 -0
  148. package/lib/typescript/store/restorePending.test.d.ts +2 -0
  149. package/lib/typescript/store/suggestions.d.ts +32 -0
  150. package/lib/typescript/store/suggestions.test.d.ts +2 -0
  151. package/lib/typescript/store/systemLine.test.d.ts +2 -0
  152. package/lib/typescript/store/ticketPrompt.d.ts +11 -0
  153. package/lib/typescript/store/transcriptPersistence.d.ts +41 -2
  154. package/lib/typescript/store/turnRendering.test.d.ts +2 -0
  155. package/lib/typescript/store/useAskBuoy.d.ts +26 -3
  156. package/lib/typescript/sync/askBuoySyncAdapter.d.ts +29 -6
  157. package/package.json +10 -10
  158. package/lib/commonjs/blocks/AskBlocks.js.map +0 -1
  159. package/lib/commonjs/blocks/BlockRenderer.js.map +0 -1
  160. package/lib/commonjs/blocks/ChromePrototypes.js.map +0 -1
  161. package/lib/commonjs/blocks/DataBlocks.js.map +0 -1
  162. package/lib/commonjs/blocks/ExtraBlocks.js.map +0 -1
  163. package/lib/commonjs/blocks/MediaBlocks.js.map +0 -1
  164. package/lib/commonjs/blocks/ReceiptBlocks.js.map +0 -1
  165. package/lib/commonjs/blocks/context.js.map +0 -1
  166. package/lib/commonjs/blocks/icons.js.map +0 -1
  167. package/lib/commonjs/blocks/index.js.map +0 -1
  168. package/lib/commonjs/blocks/listRow.test.js.map +0 -1
  169. package/lib/commonjs/blocks/pageState.js.map +0 -1
  170. package/lib/commonjs/blocks/pageState.test.js.map +0 -1
  171. package/lib/commonjs/blocks/primitives.js.map +0 -1
  172. package/lib/commonjs/blocks/primitivesIndex.js.map +0 -1
  173. package/lib/commonjs/components/ApprovalCard.js.map +0 -1
  174. package/lib/commonjs/components/AskBuoyHeader.js.map +0 -1
  175. package/lib/commonjs/components/AskBuoyIcon.js.map +0 -1
  176. package/lib/commonjs/components/AskBuoyModal.js.map +0 -1
  177. package/lib/commonjs/components/AskBuoySettings.js.map +0 -1
  178. package/lib/commonjs/components/ChangesBar.js.map +0 -1
  179. package/lib/commonjs/components/Composer.js.map +0 -1
  180. package/lib/commonjs/components/EmptyState.js.map +0 -1
  181. package/lib/commonjs/components/Markdown.js.map +0 -1
  182. package/lib/commonjs/components/MessageList.js.map +0 -1
  183. package/lib/commonjs/components/ThinkingStrip.js.map +0 -1
  184. package/lib/commonjs/components/TypingDots.js.map +0 -1
  185. package/lib/commonjs/components/useCopyAction.js.map +0 -1
  186. package/lib/commonjs/index.js.map +0 -1
  187. package/lib/commonjs/preset.js.map +0 -1
  188. package/lib/commonjs/store/askBuoySettings.js.map +0 -1
  189. package/lib/commonjs/store/askBuoyStore.js.map +0 -1
  190. package/lib/commonjs/store/restoredIds.test.js.map +0 -1
  191. package/lib/commonjs/store/traceText.js.map +0 -1
  192. package/lib/commonjs/store/traceText.test.js.map +0 -1
  193. package/lib/commonjs/store/transcriptPersistence.js.map +0 -1
  194. package/lib/commonjs/store/transcriptPersistence.test.js.map +0 -1
  195. package/lib/commonjs/store/useAskBuoy.js.map +0 -1
  196. package/lib/commonjs/store/useAskBuoySettings.js.map +0 -1
  197. package/lib/commonjs/sync/askBuoySyncAdapter.js.map +0 -1
  198. package/lib/commonjs/sync/askBuoySyncAdapter.test.js.map +0 -1
  199. package/lib/commonjs/sync/wire.js.map +0 -1
  200. package/lib/commonjs/types.js.map +0 -1
  201. package/lib/module/blocks/AskBlocks.js.map +0 -1
  202. package/lib/module/blocks/BlockRenderer.js.map +0 -1
  203. package/lib/module/blocks/ChromePrototypes.js.map +0 -1
  204. package/lib/module/blocks/DataBlocks.js.map +0 -1
  205. package/lib/module/blocks/ExtraBlocks.js.map +0 -1
  206. package/lib/module/blocks/MediaBlocks.js.map +0 -1
  207. package/lib/module/blocks/ReceiptBlocks.js.map +0 -1
  208. package/lib/module/blocks/context.js.map +0 -1
  209. package/lib/module/blocks/icons.js.map +0 -1
  210. package/lib/module/blocks/index.js.map +0 -1
  211. package/lib/module/blocks/listRow.test.js.map +0 -1
  212. package/lib/module/blocks/pageState.js.map +0 -1
  213. package/lib/module/blocks/pageState.test.js.map +0 -1
  214. package/lib/module/blocks/primitives.js.map +0 -1
  215. package/lib/module/blocks/primitivesIndex.js.map +0 -1
  216. package/lib/module/components/ApprovalCard.js.map +0 -1
  217. package/lib/module/components/AskBuoyHeader.js.map +0 -1
  218. package/lib/module/components/AskBuoyIcon.js.map +0 -1
  219. package/lib/module/components/AskBuoyModal.js.map +0 -1
  220. package/lib/module/components/AskBuoySettings.js.map +0 -1
  221. package/lib/module/components/ChangesBar.js.map +0 -1
  222. package/lib/module/components/Composer.js.map +0 -1
  223. package/lib/module/components/EmptyState.js.map +0 -1
  224. package/lib/module/components/Markdown.js.map +0 -1
  225. package/lib/module/components/MessageList.js.map +0 -1
  226. package/lib/module/components/ThinkingStrip.js.map +0 -1
  227. package/lib/module/components/TypingDots.js.map +0 -1
  228. package/lib/module/components/useCopyAction.js.map +0 -1
  229. package/lib/module/index.js.map +0 -1
  230. package/lib/module/preset.js.map +0 -1
  231. package/lib/module/store/askBuoySettings.js.map +0 -1
  232. package/lib/module/store/askBuoyStore.js.map +0 -1
  233. package/lib/module/store/restoredIds.test.js.map +0 -1
  234. package/lib/module/store/traceText.js.map +0 -1
  235. package/lib/module/store/traceText.test.js.map +0 -1
  236. package/lib/module/store/transcriptPersistence.js.map +0 -1
  237. package/lib/module/store/transcriptPersistence.test.js.map +0 -1
  238. package/lib/module/store/useAskBuoy.js.map +0 -1
  239. package/lib/module/store/useAskBuoySettings.js.map +0 -1
  240. package/lib/module/sync/askBuoySyncAdapter.js.map +0 -1
  241. package/lib/module/sync/askBuoySyncAdapter.test.js.map +0 -1
  242. package/lib/module/sync/wire.js.map +0 -1
  243. package/lib/module/types.js.map +0 -1
  244. package/lib/typescript/blocks/AskBlocks.d.ts.map +0 -1
  245. package/lib/typescript/blocks/BlockRenderer.d.ts.map +0 -1
  246. package/lib/typescript/blocks/ChromePrototypes.d.ts.map +0 -1
  247. package/lib/typescript/blocks/DataBlocks.d.ts.map +0 -1
  248. package/lib/typescript/blocks/ExtraBlocks.d.ts.map +0 -1
  249. package/lib/typescript/blocks/MediaBlocks.d.ts.map +0 -1
  250. package/lib/typescript/blocks/ReceiptBlocks.d.ts.map +0 -1
  251. package/lib/typescript/blocks/context.d.ts.map +0 -1
  252. package/lib/typescript/blocks/icons.d.ts.map +0 -1
  253. package/lib/typescript/blocks/index.d.ts.map +0 -1
  254. package/lib/typescript/blocks/listRow.test.d.ts.map +0 -1
  255. package/lib/typescript/blocks/pageState.d.ts.map +0 -1
  256. package/lib/typescript/blocks/pageState.test.d.ts.map +0 -1
  257. package/lib/typescript/blocks/primitives.d.ts.map +0 -1
  258. package/lib/typescript/blocks/primitivesIndex.d.ts.map +0 -1
  259. package/lib/typescript/components/ApprovalCard.d.ts.map +0 -1
  260. package/lib/typescript/components/AskBuoyHeader.d.ts.map +0 -1
  261. package/lib/typescript/components/AskBuoyIcon.d.ts.map +0 -1
  262. package/lib/typescript/components/AskBuoyModal.d.ts.map +0 -1
  263. package/lib/typescript/components/AskBuoySettings.d.ts.map +0 -1
  264. package/lib/typescript/components/ChangesBar.d.ts.map +0 -1
  265. package/lib/typescript/components/Composer.d.ts.map +0 -1
  266. package/lib/typescript/components/EmptyState.d.ts.map +0 -1
  267. package/lib/typescript/components/Markdown.d.ts.map +0 -1
  268. package/lib/typescript/components/MessageList.d.ts.map +0 -1
  269. package/lib/typescript/components/ThinkingStrip.d.ts.map +0 -1
  270. package/lib/typescript/components/TypingDots.d.ts.map +0 -1
  271. package/lib/typescript/components/useCopyAction.d.ts.map +0 -1
  272. package/lib/typescript/index.d.ts.map +0 -1
  273. package/lib/typescript/preset.d.ts.map +0 -1
  274. package/lib/typescript/store/askBuoySettings.d.ts.map +0 -1
  275. package/lib/typescript/store/askBuoyStore.d.ts.map +0 -1
  276. package/lib/typescript/store/restoredIds.test.d.ts.map +0 -1
  277. package/lib/typescript/store/traceText.d.ts.map +0 -1
  278. package/lib/typescript/store/traceText.test.d.ts.map +0 -1
  279. package/lib/typescript/store/transcriptPersistence.d.ts.map +0 -1
  280. package/lib/typescript/store/transcriptPersistence.test.d.ts.map +0 -1
  281. package/lib/typescript/store/useAskBuoy.d.ts.map +0 -1
  282. package/lib/typescript/store/useAskBuoySettings.d.ts.map +0 -1
  283. package/lib/typescript/sync/askBuoySyncAdapter.d.ts.map +0 -1
  284. package/lib/typescript/sync/askBuoySyncAdapter.test.d.ts.map +0 -1
  285. package/lib/typescript/sync/wire.d.ts.map +0 -1
  286. package/lib/typescript/types.d.ts.map +0 -1
@@ -1,688 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Chart = Chart;
7
- exports.Code = Code;
8
- exports.Diff = Diff;
9
- exports.Finding = Finding;
10
- exports.KeyValue = KeyValue;
11
- exports.List = List;
12
- exports.Notice = Notice;
13
- exports.Steps = Steps;
14
- exports.Table = Table;
15
- exports.listRowBehaviour = listRowBehaviour;
16
- var _react = require("react");
17
- var _reactNative = require("react-native");
18
- var _sharedUi = require("@buoy-gg/shared-ui");
19
- var _dataViewer = require("@buoy-gg/shared-ui/dataViewer");
20
- var _agentCore = require("@buoy-gg/agent-core");
21
- var _primitivesIndex = require("./primitivesIndex");
22
- var _Markdown = require("../components/Markdown");
23
- var _icons = require("./icons");
24
- var _jsxRuntime = require("react/jsx-runtime");
25
- /**
26
- * Show blocks — data the user should see rather than read.
27
- * Every one honours a cap and says "+N more" rather than growing the page.
28
- */
29
-
30
- function fmt(v) {
31
- if (v === undefined) return "—";
32
- if (v === null) return "null";
33
- if (typeof v === "string") return v;
34
- if (typeof v === "number" || typeof v === "boolean") return String(v);
35
- try {
36
- const s = JSON.stringify(v);
37
- return s.length > 120 ? `${s.slice(0, 117)}…` : s;
38
- } catch {
39
- return String(v);
40
- }
41
- }
42
- function Table({
43
- block
44
- }) {
45
- const paged = (0, _primitivesIndex.usePaged)(block.rows, _agentCore.CAPS.tableRows);
46
- const {
47
- visible
48
- } = paged;
49
- const cols = block.columns.slice(0, 4);
50
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_primitivesIndex.Card, {
51
- title: block.title,
52
- source: block.source,
53
- testID: `buoy-block-table-${block.id}`,
54
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
55
- style: styles.tableHead,
56
- children: cols.map((c, i) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
57
- style: [styles.th, i === 0 && styles.firstCol],
58
- numberOfLines: 1,
59
- children: c
60
- }, c))
61
- }), visible.map((row, r) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
62
- style: [styles.tr, r > 0 && _primitivesIndex.blockStyles.rowDivider],
63
- children: cols.map((_, i) => {
64
- const cell = row[i];
65
- const text = typeof cell === "string" ? cell : cell?.text ?? "";
66
- const tone = typeof cell === "string" ? undefined : cell?.tone;
67
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
68
- style: [styles.td, i === 0 && styles.firstCol, i === 0 && styles.tdFirst, tone && {
69
- color: (0, _primitivesIndex.toneColor)(tone)
70
- }],
71
- numberOfLines: 2,
72
- children: (0, _Markdown.renderInline)(text, styles.td)
73
- }, i);
74
- })
75
- }, r)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_primitivesIndex.More, {
76
- paged: paged
77
- })]
78
- });
79
- }
80
- function KeyValue({
81
- block
82
- }) {
83
- const paged = (0, _primitivesIndex.usePaged)(block.pairs, _agentCore.CAPS.keyValuePairs);
84
- const {
85
- visible
86
- } = paged;
87
- const [open, setOpen] = (0, _react.useState)(null);
88
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_primitivesIndex.Card, {
89
- title: block.title,
90
- source: block.source,
91
- testID: `buoy-block-keyvalue-${block.id}`,
92
- children: [visible.map((p, i) => {
93
- const long = typeof p.value === "object" && p.value !== null;
94
- const isOpen = open === p.key;
95
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Pressable, {
96
- onPress: long ? () => setOpen(isOpen ? null : p.key) : undefined,
97
- style: [styles.kvRow, i > 0 && _primitivesIndex.blockStyles.rowDivider],
98
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
99
- style: styles.kvKey,
100
- numberOfLines: 1,
101
- children: p.key
102
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
103
- style: [styles.kvValue, isOpen && _primitivesIndex.blockStyles.mono],
104
- numberOfLines: isOpen ? undefined : 2,
105
- selectable: true,
106
- children: isOpen ? JSON.stringify(p.value, null, 2) : fmt(p.value)
107
- })]
108
- }, p.key);
109
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_primitivesIndex.More, {
110
- paged: paged
111
- })]
112
- });
113
- }
114
-
115
- /**
116
- * Keys carry the index as well as the id.
117
- *
118
- * The ids in here come from the app's own data, and app data is not required
119
- * to be unique — a Poké Mart bag in this repo holds two lines sharing one
120
- * `lineId`, which is a bug in that app but must not be one in a devtool
121
- * rendering it. Paging made it visible: the duplicate sat past the initial cap,
122
- * so React only saw the collision on the first "Show more".
123
- */
124
- /**
125
- * What a tapped list row does.
126
- *
127
- * A row can carry a picture and an action, and they want the same gesture. The
128
- * picture wins the row body — looking at a thing must not fire it — and the
129
- * action keeps its label as its own control. A row with no picture is
130
- * unchanged: the whole row runs the action, which is what it did before rows
131
- * could open.
132
- */
133
- function listRowBehaviour(item) {
134
- const canExpand = Boolean(item.image);
135
- return {
136
- canExpand,
137
- rowRunsAction: Boolean(item.action) && !canExpand,
138
- actionIsOwnControl: Boolean(item.action) && canExpand
139
- };
140
- }
141
- function List({
142
- block
143
- }) {
144
- const h = (0, _primitivesIndex.useBlockHandlers)();
145
- const paged = (0, _primitivesIndex.usePaged)(block.items, _agentCore.CAPS.listItems);
146
- const {
147
- visible
148
- } = paged;
149
- // One row open at a time, keyed the same way the row is — the list can hold
150
- // duplicate ids (see the note above), so the index is part of the key.
151
- const [open, setOpen] = (0, _react.useState)(null);
152
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_primitivesIndex.Card, {
153
- title: block.title,
154
- source: block.source,
155
- testID: `buoy-block-list-${block.id}`,
156
- children: [visible.map((it, i) => {
157
- const key = `${it.id ?? it.title}-${i}`;
158
- const expanded = open === key;
159
- // A row with a picture opens it; a row without one keeps the old
160
- // behaviour, where the whole row runs its action. When an item has
161
- // BOTH, the body toggles the image and the action label becomes its
162
- // own control — otherwise the two gestures would sit on one target and
163
- // looking at a thing would fire it.
164
- const {
165
- canExpand,
166
- rowRunsAction,
167
- actionIsOwnControl
168
- } = listRowBehaviour(it);
169
- const Row = canExpand || rowRunsAction ? _reactNative.Pressable : _reactNative.View;
170
- const rowProps = canExpand ? {
171
- onPress: () => setOpen(expanded ? null : key),
172
- accessibilityRole: "button",
173
- accessibilityState: {
174
- expanded
175
- },
176
- accessibilityLabel: `${it.title}, ${expanded ? "hide" : "show"} picture`,
177
- testID: `buoy-block-list-row-${key}`
178
- } : rowRunsAction ? {
179
- onPress: () => void h.runAction(it.action, block.id),
180
- accessibilityRole: "button"
181
- } : {};
182
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
183
- style: i > 0 ? _primitivesIndex.blockStyles.rowDivider : undefined,
184
- children: [expanded && it.image ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
185
- onPress: () => setOpen(null),
186
- accessibilityRole: "button",
187
- accessibilityLabel: `Hide ${it.title}`,
188
- testID: `buoy-block-list-hero-${key}`,
189
- style: styles.listHero,
190
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
191
- source: {
192
- uri: it.image
193
- },
194
- style: styles.listHeroImage,
195
- resizeMode: "contain",
196
- accessibilityLabel: it.title
197
- })
198
- }) : null, /*#__PURE__*/(0, _jsxRuntime.jsxs)(Row, {
199
- ...rowProps,
200
- style: _primitivesIndex.blockStyles.row,
201
- children: [it.image && !expanded ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
202
- source: {
203
- uri: it.image
204
- },
205
- style: styles.thumb,
206
- resizeMode: "contain",
207
- accessibilityLabel: it.title
208
- }) : it.icon ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.BlockIcon, {
209
- name: it.icon
210
- }) : null, /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
211
- style: styles.flex,
212
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
213
- style: [_primitivesIndex.blockStyles.rowTitle, it.tone && {
214
- color: (0, _primitivesIndex.toneColor)(it.tone)
215
- }],
216
- numberOfLines: expanded ? undefined : 2,
217
- children: (0, _Markdown.renderInline)(it.title, _primitivesIndex.blockStyles.rowTitle)
218
- }), it.subtitle ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
219
- style: _primitivesIndex.blockStyles.rowSub,
220
- numberOfLines: expanded ? undefined : 2,
221
- children: (0, _Markdown.renderInline)(it.subtitle, _primitivesIndex.blockStyles.rowSub)
222
- }) : null]
223
- }), it.trailing ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
224
- style: [_primitivesIndex.blockStyles.rowTrailing, it.tone && {
225
- color: (0, _primitivesIndex.toneColor)(it.tone)
226
- }],
227
- numberOfLines: 1,
228
- children: it.trailing
229
- }) : null, it.action ? actionIsOwnControl ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
230
- onPress: () => void h.runAction(it.action, block.id),
231
- accessibilityRole: "button",
232
- accessibilityLabel: it.action.label,
233
- hitSlop: 8,
234
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
235
- style: styles.rowAction,
236
- children: it.action.label
237
- })
238
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
239
- style: styles.rowAction,
240
- children: it.action.label
241
- }) : null]
242
- })]
243
- }, key);
244
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_primitivesIndex.More, {
245
- paged: paged
246
- })]
247
- });
248
- }
249
- function Diff({
250
- block
251
- }) {
252
- const paged = (0, _primitivesIndex.usePaged)(block.changes, _agentCore.CAPS.keyValuePairs);
253
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_primitivesIndex.Card, {
254
- title: block.title ?? "What changed",
255
- source: block.source,
256
- testID: `buoy-block-diff-${block.id}`,
257
- children: [paged.visible.map((c, i) => {
258
- const added = c.before === undefined && c.after !== undefined;
259
- const removed = c.after === undefined && c.before !== undefined;
260
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
261
- style: [styles.diffRow, i > 0 && _primitivesIndex.blockStyles.rowDivider],
262
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
263
- style: styles.diffPath,
264
- numberOfLines: 1,
265
- children: c.path
266
- }), !added ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
267
- style: styles.diffLine,
268
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
269
- style: [styles.diffMark, {
270
- color: _sharedUi.night.color.danger
271
- }],
272
- children: "\u2212"
273
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
274
- style: [styles.diffValue, {
275
- color: _sharedUi.night.color.danger
276
- }],
277
- numberOfLines: 3,
278
- selectable: true,
279
- children: fmt(c.before)
280
- })]
281
- }) : null, !removed ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
282
- style: styles.diffLine,
283
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
284
- style: [styles.diffMark, {
285
- color: _sharedUi.night.color.accent
286
- }],
287
- children: "+"
288
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
289
- style: [styles.diffValue, {
290
- color: _sharedUi.night.color.accent
291
- }],
292
- numberOfLines: 3,
293
- selectable: true,
294
- children: fmt(c.after)
295
- })]
296
- }) : null]
297
- }, `${c.path}-${i}`);
298
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_primitivesIndex.More, {
299
- paged: paged
300
- })]
301
- });
302
- }
303
- function Chart({
304
- block
305
- }) {
306
- const bars = block.bars.slice(0, _agentCore.CAPS.chartBars);
307
- const max = block.max ?? Math.max(1, ...bars.map(x => x.value));
308
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_primitivesIndex.Card, {
309
- title: block.title,
310
- source: block.source,
311
- testID: `buoy-block-chart-${block.id}`,
312
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
313
- style: styles.chart,
314
- children: bars.map((x, i) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
315
- style: styles.barRow,
316
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
317
- style: styles.barLabel,
318
- numberOfLines: 1,
319
- children: x.label
320
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
321
- style: styles.barTrack,
322
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
323
- style: [styles.bar, {
324
- width: `${Math.max(2, Math.round(x.value / max * 100))}%`,
325
- backgroundColor: (0, _primitivesIndex.toneColor)(x.tone ?? "accent")
326
- }]
327
- })
328
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, {
329
- style: styles.barValue,
330
- numberOfLines: 1,
331
- children: [x.value, x.unit ? ` ${x.unit}` : ""]
332
- })]
333
- }, `${x.label}-${i}`))
334
- })
335
- });
336
- }
337
- function Steps({
338
- block
339
- }) {
340
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_primitivesIndex.Card, {
341
- title: block.title,
342
- testID: `buoy-block-steps-${block.id}`,
343
- children: block.steps.map((s, i) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
344
- style: [styles.step, i > 0 && _primitivesIndex.blockStyles.rowDivider],
345
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
346
- style: [styles.stepMark, s.state === "done" && styles.stepDone, s.state === "failed" && styles.stepFailed],
347
- children: s.state === "done" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.Check, {
348
- size: 10,
349
- color: _sharedUi.night.color.onAccent
350
- }) : s.state === "failed" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.X, {
351
- size: 10,
352
- color: _sharedUi.night.color.text
353
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
354
- style: styles.stepNum,
355
- children: i + 1
356
- })
357
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
358
- style: [_primitivesIndex.blockStyles.rowTitle, s.state === "done" && styles.stepTextDone],
359
- children: s.text
360
- })]
361
- }, i))
362
- });
363
- }
364
-
365
- /**
366
- * Parsed JSON, or `undefined` when the payload is not JSON at all.
367
- *
368
- * A bare string, number or boolean parses fine and is deliberately rejected:
369
- * `"hello"` is valid JSON and a tree of one leaf is a worse way to read it
370
- * than the line itself.
371
- */
372
- function parseJson(text) {
373
- try {
374
- const value = JSON.parse(text);
375
- return value !== null && typeof value === "object" ? value : undefined;
376
- } catch {
377
- return undefined;
378
- }
379
- }
380
-
381
- /**
382
- * A JSON payload, in the same explorer Storage and Network use.
383
- *
384
- * Worth the weight over a pretty-printed string: it collapses, it types its
385
- * values, and the thing you are usually hunting — one wrong field deep in a
386
- * response body — is findable instead of buried in forty lines of monospace.
387
- * The explorer's own lists run `scrollEnabled={false}` and grow to their
388
- * content, so nothing nests a scroller inside the transcript.
389
- */
390
- function JsonCode({
391
- block,
392
- value
393
- }) {
394
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_primitivesIndex.Card, {
395
- title: block.title,
396
- testID: `buoy-block-code-${block.id}`,
397
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
398
- style: styles.viewer,
399
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_dataViewer.DataViewer, {
400
- title: block.title ?? "Payload",
401
- data: value,
402
- initialExpanded: true,
403
- showTypeFilter: false,
404
- testIDPrefix: `buoy-block-code-${block.id}`
405
- })
406
- })
407
- });
408
- }
409
-
410
- /** Anything that is not a JSON object: a log line, a stack, a snippet. */
411
- function TextCode({
412
- block
413
- }) {
414
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_primitivesIndex.Card, {
415
- title: block.title,
416
- testID: `buoy-block-code-${block.id}`,
417
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
418
- style: [_primitivesIndex.blockStyles.mono, styles.code],
419
- selectable: true,
420
- children: block.text
421
- })
422
- });
423
- }
424
-
425
- /**
426
- * Router, per rule4: two specialised components rather than one that changes
427
- * shape. A `cond ? <A/> : <B/>` inside a single component is the Fabric
428
- * view-index hazard, and these two subtrees have nothing in common.
429
- */
430
- function Code({
431
- block
432
- }) {
433
- const value = parseJson(block.text);
434
- if (value === undefined) return /*#__PURE__*/(0, _jsxRuntime.jsx)(TextCode, {
435
- block: block
436
- });
437
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(JsonCode, {
438
- block: block,
439
- value: value
440
- });
441
- }
442
- function Notice({
443
- block
444
- }) {
445
- const color = block.tone === "danger" ? _sharedUi.night.color.danger : block.tone === "warning" ? _sharedUi.night.color.warning : _sharedUi.night.color.info;
446
- const Icon = block.tone === "info" ? _sharedUi.Info : _sharedUi.AlertTriangle;
447
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_primitivesIndex.Card, {
448
- tone: block.tone,
449
- testID: `buoy-block-notice-${block.id}`,
450
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
451
- style: styles.noticeRow,
452
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Icon, {
453
- size: 14,
454
- color: color
455
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
456
- style: styles.noticeText,
457
- children: block.text
458
- })]
459
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_primitivesIndex.ActionRow, {
460
- actions: block.actions,
461
- blockId: block.id
462
- })]
463
- });
464
- }
465
- function Finding({
466
- block
467
- }) {
468
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_primitivesIndex.Card, {
469
- title: block.title,
470
- source: block.source,
471
- testID: `buoy-block-finding-${block.id}`,
472
- tone: "warning",
473
- children: [block.evidence.map((e, i) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
474
- style: [styles.kvRow, i > 0 && _primitivesIndex.blockStyles.rowDivider],
475
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
476
- style: styles.kvKey,
477
- numberOfLines: 1,
478
- children: e.label
479
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
480
- style: [styles.kvValue, e.tone && {
481
- color: (0, _primitivesIndex.toneColor)(e.tone)
482
- }],
483
- numberOfLines: 3,
484
- children: e.value
485
- })]
486
- }, `${e.label}-${i}`)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_primitivesIndex.ActionRow, {
487
- actions: block.actions,
488
- blockId: block.id
489
- })]
490
- });
491
- }
492
- const styles = _reactNative.StyleSheet.create({
493
- flex: {
494
- flex: 1
495
- },
496
- tableHead: {
497
- flexDirection: "row",
498
- paddingHorizontal: 12,
499
- paddingVertical: 6,
500
- gap: 8,
501
- backgroundColor: _sharedUi.night.color.fill
502
- },
503
- th: {
504
- flex: 1,
505
- color: _sharedUi.night.color.textTertiary,
506
- fontSize: _sharedUi.night.font.micro,
507
- fontWeight: "700",
508
- letterSpacing: 0.6,
509
- textTransform: "uppercase"
510
- },
511
- tr: {
512
- flexDirection: "row",
513
- paddingHorizontal: 12,
514
- paddingVertical: 8,
515
- gap: 8,
516
- alignItems: "center"
517
- },
518
- td: {
519
- flex: 1,
520
- color: _sharedUi.night.color.textSecondary,
521
- fontSize: _sharedUi.night.font.caption,
522
- lineHeight: 17
523
- },
524
- tdFirst: {
525
- color: _sharedUi.night.color.text,
526
- fontWeight: "500"
527
- },
528
- firstCol: {
529
- flex: 1.4
530
- },
531
- kvRow: {
532
- flexDirection: "row",
533
- gap: 12,
534
- paddingHorizontal: 12,
535
- paddingVertical: 8,
536
- alignItems: "flex-start"
537
- },
538
- kvKey: {
539
- width: 110,
540
- color: _sharedUi.night.color.textSecondary,
541
- fontSize: _sharedUi.night.font.caption,
542
- paddingTop: 1
543
- },
544
- kvValue: {
545
- flex: 1,
546
- color: _sharedUi.night.color.text,
547
- fontSize: _sharedUi.night.font.caption,
548
- lineHeight: 17
549
- },
550
- thumb: {
551
- width: 40,
552
- height: 40,
553
- borderRadius: 8,
554
- backgroundColor: _sharedUi.night.color.fill
555
- },
556
- // The enlarged picture, sitting above the row it belongs to. Same height and
557
- // fitting as `imageGrid`'s hero so the two blocks enlarge alike.
558
- listHero: {
559
- paddingHorizontal: 12,
560
- paddingTop: 12
561
- },
562
- listHeroImage: {
563
- width: "100%",
564
- height: 240,
565
- borderRadius: _sharedUi.night.radius.row,
566
- backgroundColor: _sharedUi.night.color.fill
567
- },
568
- rowAction: {
569
- color: _sharedUi.night.color.accent,
570
- fontSize: _sharedUi.night.font.caption,
571
- fontWeight: "600"
572
- },
573
- diffRow: {
574
- paddingHorizontal: 12,
575
- paddingVertical: 8,
576
- gap: 3
577
- },
578
- diffPath: {
579
- color: _sharedUi.night.color.textSecondary,
580
- fontSize: _sharedUi.night.font.micro,
581
- fontWeight: "600",
582
- letterSpacing: 0.3
583
- },
584
- diffLine: {
585
- flexDirection: "row",
586
- gap: 8,
587
- alignItems: "flex-start"
588
- },
589
- diffMark: {
590
- fontFamily: "Menlo",
591
- fontSize: 12,
592
- width: 10
593
- },
594
- diffValue: {
595
- flex: 1,
596
- fontFamily: "Menlo",
597
- fontSize: 12,
598
- lineHeight: 16
599
- },
600
- chart: {
601
- paddingHorizontal: 12,
602
- paddingVertical: 10,
603
- gap: 8
604
- },
605
- barRow: {
606
- flexDirection: "row",
607
- alignItems: "center",
608
- gap: 8
609
- },
610
- barLabel: {
611
- width: 96,
612
- color: _sharedUi.night.color.textSecondary,
613
- fontSize: _sharedUi.night.font.caption
614
- },
615
- barTrack: {
616
- flex: 1,
617
- height: 10,
618
- borderRadius: 5,
619
- backgroundColor: _sharedUi.night.color.fill,
620
- overflow: "hidden"
621
- },
622
- bar: {
623
- height: 10,
624
- borderRadius: 5
625
- },
626
- barValue: {
627
- width: 72,
628
- textAlign: "right",
629
- color: _sharedUi.night.color.text,
630
- fontSize: _sharedUi.night.font.caption,
631
- fontWeight: "600"
632
- },
633
- step: {
634
- flexDirection: "row",
635
- alignItems: "center",
636
- gap: 10,
637
- paddingHorizontal: 12,
638
- paddingVertical: 9
639
- },
640
- stepMark: {
641
- width: 20,
642
- height: 20,
643
- borderRadius: 10,
644
- backgroundColor: _sharedUi.night.color.fillTertiary,
645
- alignItems: "center",
646
- justifyContent: "center"
647
- },
648
- stepDone: {
649
- backgroundColor: _sharedUi.night.color.accent
650
- },
651
- stepFailed: {
652
- backgroundColor: _sharedUi.night.color.danger
653
- },
654
- stepNum: {
655
- color: _sharedUi.night.color.text,
656
- fontSize: _sharedUi.night.font.micro,
657
- fontWeight: "700"
658
- },
659
- stepTextDone: {
660
- color: _sharedUi.night.color.textSecondary
661
- },
662
- // The explorer draws its own rows; this is only the inset that keeps them
663
- // off the card's edge, matching every other block's 12pt gutter.
664
- viewer: {
665
- paddingHorizontal: 4,
666
- paddingBottom: 8
667
- },
668
- code: {
669
- paddingHorizontal: 12,
670
- paddingVertical: 10,
671
- lineHeight: 17
672
- },
673
- noticeRow: {
674
- flexDirection: "row",
675
- alignItems: "flex-start",
676
- gap: 8,
677
- paddingHorizontal: 12,
678
- paddingTop: 10,
679
- paddingBottom: 4
680
- },
681
- noticeText: {
682
- flex: 1,
683
- color: _sharedUi.night.color.text,
684
- fontSize: _sharedUi.night.font.caption,
685
- lineHeight: 18
686
- }
687
- });
688
- //# sourceMappingURL=DataBlocks.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Chart=Chart,exports.Code=Code,exports.Diff=Diff,exports.Finding=Finding,exports.KeyValue=KeyValue,exports.List=List,exports.Notice=Notice,exports.Steps=Steps,exports.Table=Table,exports.listRowBehaviour=listRowBehaviour;var _react=require("react"),_reactNative=require("react-native"),_sharedUi=require("@buoy-gg/shared-ui"),_dataViewer=require("@buoy-gg/shared-ui/dataViewer"),_agentCore=require("@buoy-gg/agent-core"),_primitivesIndex=require("./primitivesIndex"),_Markdown=require("../components/Markdown"),_useCopyAction=require("../components/useCopyAction"),_blockText=require("./blockText"),_icons=require("./icons"),_jsxRuntime=require("react/jsx-runtime");function fmt(e){if(void 0===e)return"—";if(null===e)return"null";if("string"==typeof e)return e;if("number"==typeof e||"boolean"==typeof e)return String(e);try{const t=JSON.stringify(e);return t.length>120?`${t.slice(0,117)}…`:t}catch{return String(e)}}function Table({block:e}){const t=(0,_primitivesIndex.usePaged)(e.rows,_agentCore.CAPS.tableRows),{visible:i}=t,s=e.columns.slice(0,4);return(0,_jsxRuntime.jsxs)(_primitivesIndex.Card,{title:e.title,source:e.source,testID:`buoy-block-table-${e.id}`,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.tableHead,children:s.map((e,t)=>(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.th,0===t&&styles.firstCol],numberOfLines:1,children:e},e))}),i.map((e,t)=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.tr,t>0&&_primitivesIndex.blockStyles.rowDivider],children:s.map((t,i)=>{const s=e[i],r="string"==typeof s?s:s?.text??"",n="string"==typeof s?void 0:s?.tone;return(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.td,0===i&&styles.firstCol,0===i&&styles.tdFirst,n&&{color:(0,_primitivesIndex.toneColor)(n)}],numberOfLines:2,children:(0,_Markdown.renderInline)(r,styles.td)},i)})},t)),(0,_jsxRuntime.jsx)(_primitivesIndex.More,{paged:t})]})}function KeyValue({block:e}){const t=(0,_primitivesIndex.usePaged)(e.pairs,_agentCore.CAPS.keyValuePairs),{visible:i}=t,[s,r]=(0,_react.useState)(null);return(0,_jsxRuntime.jsxs)(_primitivesIndex.Card,{title:e.title,source:e.source,testID:`buoy-block-keyvalue-${e.id}`,children:[i.map((e,t)=>{const i="object"==typeof e.value&&null!==e.value,n=s===e.key;return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:i?()=>r(n?null:e.key):void 0,style:[styles.kvRow,t>0&&_primitivesIndex.blockStyles.rowDivider],children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.kvKey,numberOfLines:1,children:e.key}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.kvValue,n&&_primitivesIndex.blockStyles.mono],numberOfLines:n?void 0:2,selectable:!0,children:n?JSON.stringify(e.value,null,2):fmt(e.value)})]},e.key)}),(0,_jsxRuntime.jsx)(_primitivesIndex.More,{paged:t})]})}function listRowBehaviour(e){const t=Boolean(e.image);return{canExpand:t,rowRunsAction:Boolean(e.action)&&!t,actionIsOwnControl:Boolean(e.action)&&t}}function List({block:e}){const t=(0,_primitivesIndex.useBlockHandlers)(),i=(0,_primitivesIndex.usePaged)(e.items,_agentCore.CAPS.listItems),{visible:s}=i,[r,n]=(0,_react.useState)(null);return(0,_jsxRuntime.jsxs)(_primitivesIndex.Card,{title:e.title,source:e.source,testID:`buoy-block-list-${e.id}`,children:[s.map((i,s)=>{const o=`${i.id??i.title}-${s}`,l=r===o,{canExpand:a,rowRunsAction:c,actionIsOwnControl:d}=listRowBehaviour(i),u=a||c?_reactNative.Pressable:_reactNative.View,x=a?{onPress:()=>n(l?null:o),accessibilityRole:"button",accessibilityState:{expanded:l},accessibilityLabel:`${i.title}, ${l?"hide":"show"} picture`,testID:`buoy-block-list-row-${o}`}:c?{onPress:()=>{t.runAction(i.action,e.id)},accessibilityRole:"button"}:{};return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:s>0?_primitivesIndex.blockStyles.rowDivider:void 0,children:[l&&i.image?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>n(null),accessibilityRole:"button",accessibilityLabel:`Hide ${i.title}`,testID:`buoy-block-list-hero-${o}`,style:styles.listHero,children:(0,_jsxRuntime.jsx)(_reactNative.Image,{source:{uri:i.image},style:styles.listHeroImage,resizeMode:"contain",accessibilityLabel:i.title})}):null,(0,_jsxRuntime.jsxs)(u,{...x,style:_primitivesIndex.blockStyles.row,children:[i.image&&!l?(0,_jsxRuntime.jsx)(_reactNative.Image,{source:{uri:i.image},style:styles.thumb,resizeMode:"contain",accessibilityLabel:i.title}):i.icon?(0,_jsxRuntime.jsx)(_icons.BlockIcon,{name:i.icon}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.flex,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[_primitivesIndex.blockStyles.rowTitle,i.tone&&{color:(0,_primitivesIndex.toneColor)(i.tone)}],numberOfLines:l?void 0:2,children:(0,_Markdown.renderInline)(i.title,_primitivesIndex.blockStyles.rowTitle)}),i.subtitle?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:_primitivesIndex.blockStyles.rowSub,numberOfLines:l?void 0:2,children:(0,_Markdown.renderInline)(i.subtitle,_primitivesIndex.blockStyles.rowSub)}):null]}),i.trailing?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[_primitivesIndex.blockStyles.rowTrailing,i.tone&&{color:(0,_primitivesIndex.toneColor)(i.tone)}],numberOfLines:1,children:i.trailing}):null,i.action?d?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>{t.runAction(i.action,e.id)},accessibilityRole:"button",accessibilityLabel:i.action.label,hitSlop:8,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowAction,children:i.action.label})}):(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowAction,children:i.action.label}):null]})]},o)}),(0,_jsxRuntime.jsx)(_primitivesIndex.More,{paged:i})]})}function isStructured(e){return null!==e&&"object"==typeof e}function diffSummary(e){const t=e.map(e=>e.path),i=t.slice(0,3).join(", "),s=t.length-3;return`${1===t.length?"1 field":`${t.length} fields`} · ${i}${s>0?`, +${s}`:""}`}function Diff({block:e}){const t=(0,_primitivesIndex.usePaged)(e.changes,_agentCore.CAPS.keyValuePairs);return(0,_jsxRuntime.jsxs)(_primitivesIndex.Card,{title:e.title??"What changed",source:e.source,testID:`buoy-block-diff-${e.id}`,collapsible:!0,summary:diffSummary(e.changes),children:[t.visible.map((e,t)=>{const i=void 0===e.before&&void 0!==e.after,s=void 0===e.after&&void 0!==e.before;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.diffRow,t>0&&_primitivesIndex.blockStyles.rowDivider],children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.diffPath,numberOfLines:1,children:e.path}),isStructured(e.before)||isStructured(e.after)?(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.diffTree,children:(0,_jsxRuntime.jsx)(_dataViewer.TreeDiffViewer,{oldValue:e.before,newValue:e.after,showUnchanged:!1,scrollEnabled:!1})}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[i?null:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.diffLine,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.diffMark,{color:_sharedUi.night.color.danger}],children:"−"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.diffValue,{color:_sharedUi.night.color.danger}],numberOfLines:3,selectable:!0,children:fmt(e.before)})]}),s?null:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.diffLine,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.diffMark,{color:_sharedUi.night.color.accent}],children:"+"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.diffValue,{color:_sharedUi.night.color.accent}],numberOfLines:3,selectable:!0,children:fmt(e.after)})]})]})]},`${e.path}-${t}`)}),(0,_jsxRuntime.jsx)(_primitivesIndex.More,{paged:t})]})}function Chart({block:e}){const t=e.bars.slice(0,_agentCore.CAPS.chartBars),i=e.max??Math.max(1,...t.map(e=>e.value));return(0,_jsxRuntime.jsx)(_primitivesIndex.Card,{title:e.title,source:e.source,testID:`buoy-block-chart-${e.id}`,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.chart,children:t.map((e,t)=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.barRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.barLabel,numberOfLines:1,children:e.label}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.barTrack,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.bar,{width:`${Math.max(2,Math.round(e.value/i*100))}%`,backgroundColor:(0,_primitivesIndex.toneColor)(e.tone??"accent")}]})}),(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.barValue,numberOfLines:1,children:[e.value,e.unit?` ${e.unit}`:""]})]},`${e.label}-${t}`))})})}function Steps({block:e}){return(0,_jsxRuntime.jsx)(_primitivesIndex.Card,{title:e.title,testID:`buoy-block-steps-${e.id}`,children:e.steps.map((e,t)=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.step,t>0&&_primitivesIndex.blockStyles.rowDivider],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.stepMark,"done"===e.state&&styles.stepDone,"failed"===e.state&&styles.stepFailed],children:"done"===e.state?(0,_jsxRuntime.jsx)(_sharedUi.Check,{size:10,color:_sharedUi.night.color.onAccent}):"failed"===e.state?(0,_jsxRuntime.jsx)(_sharedUi.X,{size:10,color:_sharedUi.night.color.text}):(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.stepNum,children:t+1})}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[_primitivesIndex.blockStyles.rowTitle,"done"===e.state&&styles.stepTextDone],children:e.text})]},t))})}function parseJson(e){try{const t=JSON.parse(e);return null!==t&&"object"==typeof t?t:void 0}catch{return}}function JsonCode({block:e,value:t}){return(0,_jsxRuntime.jsx)(_primitivesIndex.Card,{title:e.title,testID:`buoy-block-code-${e.id}`,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.viewer,children:(0,_jsxRuntime.jsx)(_dataViewer.DataViewer,{title:e.title??"Payload",data:t,initialExpanded:!0,showTypeFilter:!1,testIDPrefix:`buoy-block-code-${e.id}`})})})}function TextCode({block:e}){return(0,_jsxRuntime.jsx)(_primitivesIndex.Card,{title:e.title,testID:`buoy-block-code-${e.id}`,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[_primitivesIndex.blockStyles.mono,styles.code],selectable:!0,children:e.text})})}function Code({block:e}){const t=parseJson(e.text);return void 0===t?(0,_jsxRuntime.jsx)(TextCode,{block:e}):(0,_jsxRuntime.jsx)(JsonCode,{block:e,value:t})}function Notice({block:e}){const t="danger"===e.tone?_sharedUi.night.color.danger:"warning"===e.tone?_sharedUi.night.color.warning:_sharedUi.night.color.info,i="info"===e.tone?_sharedUi.Info:_sharedUi.AlertTriangle;return(0,_jsxRuntime.jsxs)(_primitivesIndex.Card,{tone:e.tone,testID:`buoy-block-notice-${e.id}`,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.noticeRow,children:[(0,_jsxRuntime.jsx)(i,{size:14,color:t}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.noticeText,children:e.text})]}),(0,_jsxRuntime.jsx)(_primitivesIndex.ActionRow,{actions:e.actions,blockId:e.id})]})}function Finding({block:e}){const{copied:t,copy:i}=(0,_useCopyAction.useCopyAction)(()=>(0,_blockText.blockToText)(e)??e.title);return(0,_jsxRuntime.jsxs)(_primitivesIndex.Card,{title:e.title,source:e.source,testID:`buoy-block-finding-${e.id}`,tone:"warning",children:[e.evidence.map((e,t)=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.kvRow,t>0&&_primitivesIndex.blockStyles.rowDivider],children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.kvKey,numberOfLines:1,children:e.label}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.kvValue,e.tone&&{color:(0,_primitivesIndex.toneColor)(e.tone)}],selectable:!0,children:e.value})]},`${e.label}-${t}`)),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.findingFoot,children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{testID:`buoy-block-finding-copy-${e.id}`,accessibilityRole:"button",accessibilityLabel:t?"Copied":"Copy this finding",onPress:i,style:({pressed:e})=>[styles.findingCopy,e&&{opacity:.7}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.findingCopyText,t&&{color:_sharedUi.night.color.accent}],children:t?"Copied":"Copy finding"})})}),(0,_jsxRuntime.jsx)(_primitivesIndex.ActionRow,{actions:e.actions,blockId:e.id})]})}const styles=_reactNative.StyleSheet.create({flex:{flex:1},tableHead:{flexDirection:"row",paddingHorizontal:12,paddingVertical:6,gap:8,backgroundColor:_sharedUi.night.color.fill},th:{flex:1,color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.micro,fontWeight:"700",letterSpacing:.6,textTransform:"uppercase"},tr:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,gap:8,alignItems:"center"},td:{flex:1,color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.caption,lineHeight:17},tdFirst:{color:_sharedUi.night.color.text,fontWeight:"500"},firstCol:{flex:1.4},kvRow:{flexDirection:"row",gap:12,paddingHorizontal:12,paddingVertical:8,alignItems:"flex-start"},kvKey:{width:110,color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.caption,paddingTop:1},kvValue:{flex:1,color:_sharedUi.night.color.text,fontSize:_sharedUi.night.font.caption,lineHeight:17},findingFoot:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,borderTopWidth:_reactNative.StyleSheet.hairlineWidth,borderTopColor:_sharedUi.night.color.separator},findingCopy:{paddingHorizontal:10,paddingVertical:5,borderRadius:_sharedUi.night.radius.badge,backgroundColor:_sharedUi.night.color.fill},findingCopyText:{color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.micro,fontWeight:"600"},thumb:{width:40,height:40,borderRadius:8,backgroundColor:_sharedUi.night.color.fill},listHero:{paddingHorizontal:12,paddingTop:12},listHeroImage:{width:"100%",height:240,borderRadius:_sharedUi.night.radius.row,backgroundColor:_sharedUi.night.color.fill},rowAction:{color:_sharedUi.night.color.accent,fontSize:_sharedUi.night.font.caption,fontWeight:"600"},diffRow:{paddingHorizontal:12,paddingVertical:8,gap:3},diffPath:{color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.micro,fontWeight:"600",letterSpacing:.3},diffLine:{flexDirection:"row",gap:8,alignItems:"flex-start"},diffMark:{fontFamily:"Menlo",fontSize:12,width:10},diffValue:{flex:1,fontFamily:"Menlo",fontSize:12,lineHeight:16},diffTree:{borderRadius:_sharedUi.night.radius.row,overflow:"hidden"},chart:{paddingHorizontal:12,paddingVertical:10,gap:8},barRow:{flexDirection:"row",alignItems:"center",gap:8},barLabel:{width:96,color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.caption},barTrack:{flex:1,height:10,borderRadius:5,backgroundColor:_sharedUi.night.color.fill,overflow:"hidden"},bar:{height:10,borderRadius:5},barValue:{width:72,textAlign:"right",color:_sharedUi.night.color.text,fontSize:_sharedUi.night.font.caption,fontWeight:"600"},step:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},stepMark:{width:20,height:20,borderRadius:10,backgroundColor:_sharedUi.night.color.fillTertiary,alignItems:"center",justifyContent:"center"},stepDone:{backgroundColor:_sharedUi.night.color.accent},stepFailed:{backgroundColor:_sharedUi.night.color.danger},stepNum:{color:_sharedUi.night.color.text,fontSize:_sharedUi.night.font.micro,fontWeight:"700"},stepTextDone:{color:_sharedUi.night.color.textSecondary},viewer:{paddingHorizontal:4,paddingBottom:8},code:{paddingHorizontal:12,paddingVertical:10,lineHeight:17},noticeRow:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:12,paddingTop:10,paddingBottom:4},noticeText:{flex:1,color:_sharedUi.night.color.text,fontSize:_sharedUi.night.font.caption,lineHeight:18}});