@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.
- package/README.md +73 -15
- package/lib/commonjs/blocks/AskBlocks.js +1 -338
- package/lib/commonjs/blocks/BlockRenderer.js +1 -250
- package/lib/commonjs/blocks/ChromePrototypes.js +1 -514
- package/lib/commonjs/blocks/DataBlocks.js +1 -688
- package/lib/commonjs/blocks/ExtraBlocks.js +1 -1854
- package/lib/commonjs/blocks/MediaBlocks.js +1 -140
- package/lib/commonjs/blocks/ReceiptBlocks.js +1 -586
- package/lib/commonjs/blocks/blockText.js +1 -0
- package/lib/commonjs/blocks/blockText.test.js +1 -0
- package/lib/commonjs/blocks/context.js +1 -42
- package/lib/commonjs/blocks/icons.js +1 -96
- package/lib/commonjs/blocks/index.js +1 -95
- package/lib/commonjs/blocks/listRow.test.js +1 -55
- package/lib/commonjs/blocks/pageState.js +1 -34
- package/lib/commonjs/blocks/pageState.test.js +1 -57
- package/lib/commonjs/blocks/primitives.js +1 -401
- package/lib/commonjs/blocks/primitivesIndex.js +1 -62
- package/lib/commonjs/components/ApprovalCard.js +1 -140
- package/lib/commonjs/components/AskBuoyHeader.js +1 -164
- package/lib/commonjs/components/AskBuoyIcon.js +1 -19
- package/lib/commonjs/components/AskBuoyModal.js +1 -353
- package/lib/commonjs/components/AskBuoySettings.js +1 -69
- package/lib/commonjs/components/ChangesBar.js +1 -211
- package/lib/commonjs/components/Composer.js +1 -175
- package/lib/commonjs/components/EmptyState.js +1 -154
- package/lib/commonjs/components/KeyboardPad.js +1 -0
- package/lib/commonjs/components/Markdown.js +1 -252
- package/lib/commonjs/components/MessageList.js +1 -683
- package/lib/commonjs/components/QueuedMessages.js +1 -0
- package/lib/commonjs/components/ThinkingStrip.js +1 -223
- package/lib/commonjs/components/TypingDots.js +1 -63
- package/lib/commonjs/components/markdownParse.js +1 -0
- package/lib/commonjs/components/markdownParse.test.js +1 -0
- package/lib/commonjs/components/useCopyAction.js +1 -50
- package/lib/commonjs/index.js +1 -252
- package/lib/commonjs/preset.js +1 -90
- package/lib/commonjs/store/activityGroups.js +1 -0
- package/lib/commonjs/store/activityGroups.test.js +1 -0
- package/lib/commonjs/store/askBuoySettings.js +1 -67
- package/lib/commonjs/store/askBuoyStore.js +1 -365
- package/lib/commonjs/store/blockPlacement.js +1 -0
- package/lib/commonjs/store/blockPlacement.test.js +1 -0
- package/lib/commonjs/store/queue.test.js +1 -0
- package/lib/commonjs/store/resetConversation.js +1 -0
- package/lib/commonjs/store/restorePending.test.js +1 -0
- package/lib/commonjs/store/restoredIds.test.js +1 -47
- package/lib/commonjs/store/suggestions.js +1 -0
- package/lib/commonjs/store/suggestions.test.js +1 -0
- package/lib/commonjs/store/systemLine.test.js +1 -0
- package/lib/commonjs/store/ticketPrompt.js +1 -0
- package/lib/commonjs/store/traceText.js +1 -81
- package/lib/commonjs/store/traceText.test.js +1 -112
- package/lib/commonjs/store/transcriptPersistence.js +1 -208
- package/lib/commonjs/store/transcriptPersistence.test.js +1 -185
- package/lib/commonjs/store/turnRendering.test.js +1 -0
- package/lib/commonjs/store/useAskBuoy.js +1 -400
- package/lib/commonjs/store/useAskBuoySettings.js +1 -14
- package/lib/commonjs/sync/askBuoySyncAdapter.js +1 -119
- package/lib/commonjs/sync/askBuoySyncAdapter.test.js +1 -141
- package/lib/commonjs/sync/wire.js +1 -58
- package/lib/commonjs/types.js +1 -6
- package/lib/module/blocks/AskBlocks.js +1 -331
- package/lib/module/blocks/BlockRenderer.js +1 -245
- package/lib/module/blocks/ChromePrototypes.js +1 -503
- package/lib/module/blocks/DataBlocks.js +1 -674
- package/lib/module/blocks/ExtraBlocks.js +1 -1827
- package/lib/module/blocks/MediaBlocks.js +1 -135
- package/lib/module/blocks/ReceiptBlocks.js +1 -574
- package/lib/module/blocks/blockText.js +1 -0
- package/lib/module/blocks/blockText.test.js +1 -0
- package/lib/module/blocks/context.js +1 -35
- package/lib/module/blocks/icons.js +1 -91
- package/lib/module/blocks/index.js +1 -8
- package/lib/module/blocks/listRow.test.js +1 -56
- package/lib/module/blocks/pageState.js +1 -30
- package/lib/module/blocks/pageState.test.js +1 -56
- package/lib/module/blocks/primitives.js +1 -389
- package/lib/module/blocks/primitivesIndex.js +1 -5
- package/lib/module/components/ApprovalCard.js +1 -135
- package/lib/module/components/AskBuoyHeader.js +1 -161
- package/lib/module/components/AskBuoyIcon.js +1 -8
- package/lib/module/components/AskBuoyModal.js +1 -348
- package/lib/module/components/AskBuoySettings.js +1 -64
- package/lib/module/components/ChangesBar.js +1 -206
- package/lib/module/components/Composer.js +1 -170
- package/lib/module/components/EmptyState.js +1 -149
- package/lib/module/components/KeyboardPad.js +1 -0
- package/lib/module/components/Markdown.js +1 -246
- package/lib/module/components/MessageList.js +1 -677
- package/lib/module/components/QueuedMessages.js +1 -0
- package/lib/module/components/ThinkingStrip.js +1 -218
- package/lib/module/components/TypingDots.js +1 -58
- package/lib/module/components/markdownParse.js +1 -0
- package/lib/module/components/markdownParse.test.js +1 -0
- package/lib/module/components/useCopyAction.js +1 -46
- package/lib/module/index.js +1 -34
- package/lib/module/preset.js +1 -73
- package/lib/module/store/activityGroups.js +1 -0
- package/lib/module/store/activityGroups.test.js +1 -0
- package/lib/module/store/askBuoySettings.js +1 -62
- package/lib/module/store/askBuoyStore.js +1 -361
- package/lib/module/store/blockPlacement.js +1 -0
- package/lib/module/store/blockPlacement.test.js +1 -0
- package/lib/module/store/queue.test.js +1 -0
- package/lib/module/store/resetConversation.js +1 -0
- package/lib/module/store/restorePending.test.js +1 -0
- package/lib/module/store/restoredIds.test.js +1 -46
- package/lib/module/store/suggestions.js +1 -0
- package/lib/module/store/suggestions.test.js +1 -0
- package/lib/module/store/systemLine.test.js +1 -0
- package/lib/module/store/ticketPrompt.js +1 -0
- package/lib/module/store/traceText.js +1 -75
- package/lib/module/store/traceText.test.js +1 -111
- package/lib/module/store/transcriptPersistence.js +1 -198
- package/lib/module/store/transcriptPersistence.test.js +1 -184
- package/lib/module/store/turnRendering.test.js +1 -0
- package/lib/module/store/useAskBuoy.js +1 -394
- package/lib/module/store/useAskBuoySettings.js +1 -9
- package/lib/module/sync/askBuoySyncAdapter.js +1 -114
- package/lib/module/sync/askBuoySyncAdapter.test.js +1 -140
- package/lib/module/sync/wire.js +1 -47
- package/lib/module/types.js +1 -4
- package/lib/typescript/blocks/DataBlocks.d.ts +11 -0
- package/lib/typescript/blocks/ExtraBlocks.d.ts +18 -2
- package/lib/typescript/blocks/blockText.d.ts +14 -0
- package/lib/typescript/blocks/blockText.test.d.ts +2 -0
- package/lib/typescript/blocks/primitives.d.ts +16 -1
- package/lib/typescript/components/ApprovalCard.d.ts +9 -1
- package/lib/typescript/components/AskBuoyHeader.d.ts +31 -1
- package/lib/typescript/components/Composer.d.ts +16 -1
- package/lib/typescript/components/EmptyState.d.ts +5 -1
- package/lib/typescript/components/KeyboardPad.d.ts +33 -0
- package/lib/typescript/components/Markdown.d.ts +0 -10
- package/lib/typescript/components/MessageList.d.ts +7 -2
- package/lib/typescript/components/QueuedMessages.d.ts +10 -0
- package/lib/typescript/components/markdownParse.d.ts +49 -0
- package/lib/typescript/components/markdownParse.test.d.ts +2 -0
- package/lib/typescript/preset.d.ts +4 -2
- package/lib/typescript/store/activityGroups.d.ts +29 -0
- package/lib/typescript/store/activityGroups.test.d.ts +2 -0
- package/lib/typescript/store/askBuoySettings.d.ts +22 -0
- package/lib/typescript/store/askBuoyStore.d.ts +174 -9
- package/lib/typescript/store/blockPlacement.d.ts +30 -0
- package/lib/typescript/store/blockPlacement.test.d.ts +2 -0
- package/lib/typescript/store/queue.test.d.ts +2 -0
- package/lib/typescript/store/resetConversation.d.ts +38 -0
- package/lib/typescript/store/restorePending.test.d.ts +2 -0
- package/lib/typescript/store/suggestions.d.ts +32 -0
- package/lib/typescript/store/suggestions.test.d.ts +2 -0
- package/lib/typescript/store/systemLine.test.d.ts +2 -0
- package/lib/typescript/store/ticketPrompt.d.ts +11 -0
- package/lib/typescript/store/transcriptPersistence.d.ts +41 -2
- package/lib/typescript/store/turnRendering.test.d.ts +2 -0
- package/lib/typescript/store/useAskBuoy.d.ts +26 -3
- package/lib/typescript/sync/askBuoySyncAdapter.d.ts +29 -6
- package/package.json +10 -10
- package/lib/commonjs/blocks/AskBlocks.js.map +0 -1
- package/lib/commonjs/blocks/BlockRenderer.js.map +0 -1
- package/lib/commonjs/blocks/ChromePrototypes.js.map +0 -1
- package/lib/commonjs/blocks/DataBlocks.js.map +0 -1
- package/lib/commonjs/blocks/ExtraBlocks.js.map +0 -1
- package/lib/commonjs/blocks/MediaBlocks.js.map +0 -1
- package/lib/commonjs/blocks/ReceiptBlocks.js.map +0 -1
- package/lib/commonjs/blocks/context.js.map +0 -1
- package/lib/commonjs/blocks/icons.js.map +0 -1
- package/lib/commonjs/blocks/index.js.map +0 -1
- package/lib/commonjs/blocks/listRow.test.js.map +0 -1
- package/lib/commonjs/blocks/pageState.js.map +0 -1
- package/lib/commonjs/blocks/pageState.test.js.map +0 -1
- package/lib/commonjs/blocks/primitives.js.map +0 -1
- package/lib/commonjs/blocks/primitivesIndex.js.map +0 -1
- package/lib/commonjs/components/ApprovalCard.js.map +0 -1
- package/lib/commonjs/components/AskBuoyHeader.js.map +0 -1
- package/lib/commonjs/components/AskBuoyIcon.js.map +0 -1
- package/lib/commonjs/components/AskBuoyModal.js.map +0 -1
- package/lib/commonjs/components/AskBuoySettings.js.map +0 -1
- package/lib/commonjs/components/ChangesBar.js.map +0 -1
- package/lib/commonjs/components/Composer.js.map +0 -1
- package/lib/commonjs/components/EmptyState.js.map +0 -1
- package/lib/commonjs/components/Markdown.js.map +0 -1
- package/lib/commonjs/components/MessageList.js.map +0 -1
- package/lib/commonjs/components/ThinkingStrip.js.map +0 -1
- package/lib/commonjs/components/TypingDots.js.map +0 -1
- package/lib/commonjs/components/useCopyAction.js.map +0 -1
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/preset.js.map +0 -1
- package/lib/commonjs/store/askBuoySettings.js.map +0 -1
- package/lib/commonjs/store/askBuoyStore.js.map +0 -1
- package/lib/commonjs/store/restoredIds.test.js.map +0 -1
- package/lib/commonjs/store/traceText.js.map +0 -1
- package/lib/commonjs/store/traceText.test.js.map +0 -1
- package/lib/commonjs/store/transcriptPersistence.js.map +0 -1
- package/lib/commonjs/store/transcriptPersistence.test.js.map +0 -1
- package/lib/commonjs/store/useAskBuoy.js.map +0 -1
- package/lib/commonjs/store/useAskBuoySettings.js.map +0 -1
- package/lib/commonjs/sync/askBuoySyncAdapter.js.map +0 -1
- package/lib/commonjs/sync/askBuoySyncAdapter.test.js.map +0 -1
- package/lib/commonjs/sync/wire.js.map +0 -1
- package/lib/commonjs/types.js.map +0 -1
- package/lib/module/blocks/AskBlocks.js.map +0 -1
- package/lib/module/blocks/BlockRenderer.js.map +0 -1
- package/lib/module/blocks/ChromePrototypes.js.map +0 -1
- package/lib/module/blocks/DataBlocks.js.map +0 -1
- package/lib/module/blocks/ExtraBlocks.js.map +0 -1
- package/lib/module/blocks/MediaBlocks.js.map +0 -1
- package/lib/module/blocks/ReceiptBlocks.js.map +0 -1
- package/lib/module/blocks/context.js.map +0 -1
- package/lib/module/blocks/icons.js.map +0 -1
- package/lib/module/blocks/index.js.map +0 -1
- package/lib/module/blocks/listRow.test.js.map +0 -1
- package/lib/module/blocks/pageState.js.map +0 -1
- package/lib/module/blocks/pageState.test.js.map +0 -1
- package/lib/module/blocks/primitives.js.map +0 -1
- package/lib/module/blocks/primitivesIndex.js.map +0 -1
- package/lib/module/components/ApprovalCard.js.map +0 -1
- package/lib/module/components/AskBuoyHeader.js.map +0 -1
- package/lib/module/components/AskBuoyIcon.js.map +0 -1
- package/lib/module/components/AskBuoyModal.js.map +0 -1
- package/lib/module/components/AskBuoySettings.js.map +0 -1
- package/lib/module/components/ChangesBar.js.map +0 -1
- package/lib/module/components/Composer.js.map +0 -1
- package/lib/module/components/EmptyState.js.map +0 -1
- package/lib/module/components/Markdown.js.map +0 -1
- package/lib/module/components/MessageList.js.map +0 -1
- package/lib/module/components/ThinkingStrip.js.map +0 -1
- package/lib/module/components/TypingDots.js.map +0 -1
- package/lib/module/components/useCopyAction.js.map +0 -1
- package/lib/module/index.js.map +0 -1
- package/lib/module/preset.js.map +0 -1
- package/lib/module/store/askBuoySettings.js.map +0 -1
- package/lib/module/store/askBuoyStore.js.map +0 -1
- package/lib/module/store/restoredIds.test.js.map +0 -1
- package/lib/module/store/traceText.js.map +0 -1
- package/lib/module/store/traceText.test.js.map +0 -1
- package/lib/module/store/transcriptPersistence.js.map +0 -1
- package/lib/module/store/transcriptPersistence.test.js.map +0 -1
- package/lib/module/store/useAskBuoy.js.map +0 -1
- package/lib/module/store/useAskBuoySettings.js.map +0 -1
- package/lib/module/sync/askBuoySyncAdapter.js.map +0 -1
- package/lib/module/sync/askBuoySyncAdapter.test.js.map +0 -1
- package/lib/module/sync/wire.js.map +0 -1
- package/lib/module/types.js.map +0 -1
- package/lib/typescript/blocks/AskBlocks.d.ts.map +0 -1
- package/lib/typescript/blocks/BlockRenderer.d.ts.map +0 -1
- package/lib/typescript/blocks/ChromePrototypes.d.ts.map +0 -1
- package/lib/typescript/blocks/DataBlocks.d.ts.map +0 -1
- package/lib/typescript/blocks/ExtraBlocks.d.ts.map +0 -1
- package/lib/typescript/blocks/MediaBlocks.d.ts.map +0 -1
- package/lib/typescript/blocks/ReceiptBlocks.d.ts.map +0 -1
- package/lib/typescript/blocks/context.d.ts.map +0 -1
- package/lib/typescript/blocks/icons.d.ts.map +0 -1
- package/lib/typescript/blocks/index.d.ts.map +0 -1
- package/lib/typescript/blocks/listRow.test.d.ts.map +0 -1
- package/lib/typescript/blocks/pageState.d.ts.map +0 -1
- package/lib/typescript/blocks/pageState.test.d.ts.map +0 -1
- package/lib/typescript/blocks/primitives.d.ts.map +0 -1
- package/lib/typescript/blocks/primitivesIndex.d.ts.map +0 -1
- package/lib/typescript/components/ApprovalCard.d.ts.map +0 -1
- package/lib/typescript/components/AskBuoyHeader.d.ts.map +0 -1
- package/lib/typescript/components/AskBuoyIcon.d.ts.map +0 -1
- package/lib/typescript/components/AskBuoyModal.d.ts.map +0 -1
- package/lib/typescript/components/AskBuoySettings.d.ts.map +0 -1
- package/lib/typescript/components/ChangesBar.d.ts.map +0 -1
- package/lib/typescript/components/Composer.d.ts.map +0 -1
- package/lib/typescript/components/EmptyState.d.ts.map +0 -1
- package/lib/typescript/components/Markdown.d.ts.map +0 -1
- package/lib/typescript/components/MessageList.d.ts.map +0 -1
- package/lib/typescript/components/ThinkingStrip.d.ts.map +0 -1
- package/lib/typescript/components/TypingDots.d.ts.map +0 -1
- package/lib/typescript/components/useCopyAction.d.ts.map +0 -1
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/preset.d.ts.map +0 -1
- package/lib/typescript/store/askBuoySettings.d.ts.map +0 -1
- package/lib/typescript/store/askBuoyStore.d.ts.map +0 -1
- package/lib/typescript/store/restoredIds.test.d.ts.map +0 -1
- package/lib/typescript/store/traceText.d.ts.map +0 -1
- package/lib/typescript/store/traceText.test.d.ts.map +0 -1
- package/lib/typescript/store/transcriptPersistence.d.ts.map +0 -1
- package/lib/typescript/store/transcriptPersistence.test.d.ts.map +0 -1
- package/lib/typescript/store/useAskBuoy.d.ts.map +0 -1
- package/lib/typescript/store/useAskBuoySettings.d.ts.map +0 -1
- package/lib/typescript/sync/askBuoySyncAdapter.d.ts.map +0 -1
- package/lib/typescript/sync/askBuoySyncAdapter.test.d.ts.map +0 -1
- package/lib/typescript/sync/wire.d.ts.map +0 -1
- package/lib/typescript/types.d.ts.map +0 -1
|
@@ -1,252 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Markdown = Markdown;
|
|
7
|
-
exports.renderInline = renderInline;
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
|
-
var _sharedUi = require("@buoy-gg/shared-ui");
|
|
10
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
-
/**
|
|
12
|
-
* Just enough Markdown for a chat answer.
|
|
13
|
-
*
|
|
14
|
-
* Models write `**bold**`, bullet lists and `code` whether or not the prompt
|
|
15
|
-
* asks for prose, and the asterisks rendered raw made every answer look like
|
|
16
|
-
* a broken template. This handles the subset a chat actually receives —
|
|
17
|
-
* paragraphs, `-`/`*`/`1.` lists, `#` headings (rendered bold, not huge),
|
|
18
|
-
* bold, italics and inline code — with no dependency and no HTML. Anything it
|
|
19
|
-
* does not understand falls through as plain text, never as a blank.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
const isTableRow = l => /^\s*\|.*\|\s*$/.test(l);
|
|
23
|
-
const isTableRule = l => /^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/.test(l);
|
|
24
|
-
const splitRow = l => l.trim().replace(/^\|/, "").replace(/\|$/, "").split("|").map(c => c.trim());
|
|
25
|
-
function parseBlocks(source) {
|
|
26
|
-
const blocks = [];
|
|
27
|
-
let para = [];
|
|
28
|
-
const flush = () => {
|
|
29
|
-
if (para.length) blocks.push({
|
|
30
|
-
kind: "p",
|
|
31
|
-
text: para.join(" ")
|
|
32
|
-
});
|
|
33
|
-
para = [];
|
|
34
|
-
};
|
|
35
|
-
const lines = source.split("\n");
|
|
36
|
-
for (let li = 0; li < lines.length; li++) {
|
|
37
|
-
const raw = lines[li];
|
|
38
|
-
const line = raw.replace(/\s+$/, "");
|
|
39
|
-
if (!line.trim()) {
|
|
40
|
-
flush();
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
// A pipe table: header row, a rule row, then body rows.
|
|
44
|
-
if (isTableRow(line) && lines[li + 1] && isTableRule(lines[li + 1])) {
|
|
45
|
-
flush();
|
|
46
|
-
const header = splitRow(line);
|
|
47
|
-
const rows = [];
|
|
48
|
-
let j = li + 2;
|
|
49
|
-
while (j < lines.length && isTableRow(lines[j])) {
|
|
50
|
-
rows.push(splitRow(lines[j]));
|
|
51
|
-
j++;
|
|
52
|
-
}
|
|
53
|
-
blocks.push({
|
|
54
|
-
kind: "table",
|
|
55
|
-
header,
|
|
56
|
-
rows
|
|
57
|
-
});
|
|
58
|
-
li = j - 1;
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
const heading = /^#{1,6}\s+(.*)$/.exec(line);
|
|
62
|
-
if (heading) {
|
|
63
|
-
flush();
|
|
64
|
-
blocks.push({
|
|
65
|
-
kind: "h",
|
|
66
|
-
text: heading[1]
|
|
67
|
-
});
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
const bullet = /^(\s*)([-*•]|\d+[.)])\s+(.*)$/.exec(line);
|
|
71
|
-
if (bullet) {
|
|
72
|
-
flush();
|
|
73
|
-
const depth = Math.min(2, Math.floor(bullet[1].length / 2));
|
|
74
|
-
const marker = /^\d/.test(bullet[2]) ? bullet[2].replace(")", ".") : "•";
|
|
75
|
-
blocks.push({
|
|
76
|
-
kind: "li",
|
|
77
|
-
text: bullet[3],
|
|
78
|
-
marker,
|
|
79
|
-
depth
|
|
80
|
-
});
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
para.push(line.trim());
|
|
84
|
-
}
|
|
85
|
-
flush();
|
|
86
|
-
return blocks;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* `**bold**`, `*italic*` / `_italic_`, `` `code` `` → styled spans. Links and
|
|
91
|
-
* images collapse to their text: a phone chat has nowhere to open a URL, and
|
|
92
|
-
* `` printed raw is
|
|
93
|
-
* three lines of noise for one word of meaning.
|
|
94
|
-
*/
|
|
95
|
-
function renderInline(source, base) {
|
|
96
|
-
const text = source.replace(/!?\[([^\]]*)\]\([^)]*\)/g, "$1");
|
|
97
|
-
const out = [];
|
|
98
|
-
const re = /(\*\*[^*]+\*\*|`[^`]+`|\*[^*\s][^*]*\*|_[^_\s][^_]*_)/g;
|
|
99
|
-
let last = 0;
|
|
100
|
-
let m;
|
|
101
|
-
let i = 0;
|
|
102
|
-
while (m = re.exec(text)) {
|
|
103
|
-
if (m.index > last) out.push(text.slice(last, m.index));
|
|
104
|
-
const tok = m[0];
|
|
105
|
-
if (tok.startsWith("**")) {
|
|
106
|
-
out.push(/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
107
|
-
style: [base, styles.bold],
|
|
108
|
-
children: tok.slice(2, -2)
|
|
109
|
-
}, i++));
|
|
110
|
-
} else if (tok.startsWith("`")) {
|
|
111
|
-
out.push(/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
112
|
-
style: [base, styles.code],
|
|
113
|
-
children: tok.slice(1, -1)
|
|
114
|
-
}, i++));
|
|
115
|
-
} else {
|
|
116
|
-
out.push(/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
117
|
-
style: [base, styles.italic],
|
|
118
|
-
children: tok.slice(1, -1)
|
|
119
|
-
}, i++));
|
|
120
|
-
}
|
|
121
|
-
last = m.index + tok.length;
|
|
122
|
-
}
|
|
123
|
-
if (last < text.length) out.push(text.slice(last));
|
|
124
|
-
return out;
|
|
125
|
-
}
|
|
126
|
-
function Markdown({
|
|
127
|
-
text,
|
|
128
|
-
style
|
|
129
|
-
}) {
|
|
130
|
-
const blocks = parseBlocks(text);
|
|
131
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
132
|
-
style: styles.wrap,
|
|
133
|
-
children: blocks.map((b, i) => {
|
|
134
|
-
if (b.kind === "table") {
|
|
135
|
-
const cols = b.header.slice(0, 4);
|
|
136
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
137
|
-
style: styles.table,
|
|
138
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
139
|
-
style: styles.tableHead,
|
|
140
|
-
children: cols.map((c, k) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
141
|
-
style: [styles.th, k === 0 && styles.firstCol],
|
|
142
|
-
numberOfLines: 1,
|
|
143
|
-
children: c.replace(/\*\*/g, "")
|
|
144
|
-
}, k))
|
|
145
|
-
}), b.rows.slice(0, 12).map((r, ri) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
146
|
-
style: [styles.tr, ri > 0 && styles.trDivider],
|
|
147
|
-
children: cols.map((_, k) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
148
|
-
style: [styles.td, k === 0 && styles.firstCol, k === 0 && styles.tdFirst],
|
|
149
|
-
numberOfLines: 2,
|
|
150
|
-
children: renderInline((r[k] ?? "").replace(/!?\[([^\]]*)\]\([^)]*\)/g, "$1"), styles.td)
|
|
151
|
-
}, k))
|
|
152
|
-
}, ri))]
|
|
153
|
-
}, i);
|
|
154
|
-
}
|
|
155
|
-
if (b.kind === "li") {
|
|
156
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
157
|
-
style: [styles.li, {
|
|
158
|
-
paddingLeft: 4 + b.depth * 14
|
|
159
|
-
}],
|
|
160
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
161
|
-
style: [style, styles.marker],
|
|
162
|
-
children: b.marker
|
|
163
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
164
|
-
style: [style, styles.liText],
|
|
165
|
-
selectable: true,
|
|
166
|
-
children: renderInline(b.text, style)
|
|
167
|
-
})]
|
|
168
|
-
}, i);
|
|
169
|
-
}
|
|
170
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
171
|
-
style: [style, b.kind === "h" && styles.bold],
|
|
172
|
-
selectable: true,
|
|
173
|
-
children: renderInline(b.text, style)
|
|
174
|
-
}, i);
|
|
175
|
-
})
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
const styles = _reactNative.StyleSheet.create({
|
|
179
|
-
wrap: {
|
|
180
|
-
gap: 8
|
|
181
|
-
},
|
|
182
|
-
bold: {
|
|
183
|
-
fontWeight: "600"
|
|
184
|
-
},
|
|
185
|
-
italic: {
|
|
186
|
-
fontStyle: "italic"
|
|
187
|
-
},
|
|
188
|
-
code: {
|
|
189
|
-
fontFamily: "Menlo",
|
|
190
|
-
fontSize: 13,
|
|
191
|
-
color: _sharedUi.night.color.accent,
|
|
192
|
-
backgroundColor: _sharedUi.night.color.fill
|
|
193
|
-
},
|
|
194
|
-
li: {
|
|
195
|
-
flexDirection: "row",
|
|
196
|
-
gap: 8
|
|
197
|
-
},
|
|
198
|
-
table: {
|
|
199
|
-
borderRadius: _sharedUi.night.radius.row,
|
|
200
|
-
borderWidth: _reactNative.StyleSheet.hairlineWidth,
|
|
201
|
-
borderColor: _sharedUi.night.color.border,
|
|
202
|
-
backgroundColor: _sharedUi.night.color.surface,
|
|
203
|
-
overflow: "hidden"
|
|
204
|
-
},
|
|
205
|
-
tableHead: {
|
|
206
|
-
flexDirection: "row",
|
|
207
|
-
paddingHorizontal: 10,
|
|
208
|
-
paddingVertical: 6,
|
|
209
|
-
gap: 8,
|
|
210
|
-
backgroundColor: _sharedUi.night.color.fill
|
|
211
|
-
},
|
|
212
|
-
th: {
|
|
213
|
-
flex: 1,
|
|
214
|
-
color: _sharedUi.night.color.textTertiary,
|
|
215
|
-
fontSize: _sharedUi.night.font.micro,
|
|
216
|
-
fontWeight: "700",
|
|
217
|
-
letterSpacing: 0.6,
|
|
218
|
-
textTransform: "uppercase"
|
|
219
|
-
},
|
|
220
|
-
tr: {
|
|
221
|
-
flexDirection: "row",
|
|
222
|
-
paddingHorizontal: 10,
|
|
223
|
-
paddingVertical: 7,
|
|
224
|
-
gap: 8
|
|
225
|
-
},
|
|
226
|
-
trDivider: {
|
|
227
|
-
borderTopWidth: _reactNative.StyleSheet.hairlineWidth,
|
|
228
|
-
borderTopColor: _sharedUi.night.color.separator
|
|
229
|
-
},
|
|
230
|
-
td: {
|
|
231
|
-
flex: 1,
|
|
232
|
-
color: _sharedUi.night.color.textSecondary,
|
|
233
|
-
fontSize: _sharedUi.night.font.caption,
|
|
234
|
-
lineHeight: 17
|
|
235
|
-
},
|
|
236
|
-
tdFirst: {
|
|
237
|
-
color: _sharedUi.night.color.text,
|
|
238
|
-
fontWeight: "500"
|
|
239
|
-
},
|
|
240
|
-
firstCol: {
|
|
241
|
-
flex: 1.3
|
|
242
|
-
},
|
|
243
|
-
marker: {
|
|
244
|
-
color: _sharedUi.night.color.textSecondary,
|
|
245
|
-
minWidth: 14,
|
|
246
|
-
textAlign: "right"
|
|
247
|
-
},
|
|
248
|
-
liText: {
|
|
249
|
-
flex: 1
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
//# sourceMappingURL=Markdown.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Markdown=Markdown,exports.renderInline=renderInline;var _react=require("react"),_reactNative=require("react-native"),_sharedUi=require("@buoy-gg/shared-ui"),_markdownParse=require("./markdownParse"),_jsxRuntime=require("react/jsx-runtime");function renderInline(e,t){const r=e.replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1"),i=[],s=/(\*\*[^*]+\*\*|`[^`]+`|\*[^*\s][^*]*\*|_[^_\s][^_]*_)/g;let l,o=0,n=0;for(;l=s.exec(r);){l.index>o&&i.push(r.slice(o,l.index));const e=l[0];e.startsWith("**")?i.push((0,_jsxRuntime.jsx)(_reactNative.Text,{style:[t,styles.bold],children:e.slice(2,-2)},n++)):e.startsWith("`")?i.push((0,_jsxRuntime.jsx)(_reactNative.Text,{style:[t,styles.code],children:e.slice(1,-1)},n++)):i.push((0,_jsxRuntime.jsx)(_reactNative.Text,{style:[t,styles.italic],children:e.slice(1,-1)},n++)),o=l.index+e.length}return o<r.length&&i.push(r.slice(o)),i}const stripLinks=e=>e.replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1");function MarkdownTable({header:e,rows:t}){const[r,i]=(0,_react.useState)(!1),s=(0,_markdownParse.tableTruncation)(e,t),l=r?e:e.slice(0,_markdownParse.TABLE_PREVIEW_COLS),o=r?t:t.slice(0,_markdownParse.TABLE_PREVIEW_ROWS),n=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:r&&styles.tableWide,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.tableHead,children:l.map((e,t)=>(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.th,0===t&&styles.firstCol,r&&styles.colFixed],numberOfLines:1,children:e.replace(/\*\*/g,"")},t))}),o.map((e,t)=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.tr,t>0&&styles.trDivider],children:l.map((t,i)=>(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.td,0===i&&styles.firstCol,0===i&&styles.tdFirst,r&&styles.colFixed],numberOfLines:r?3:2,children:renderInline(stripLinks(e[i]??""),styles.td)},i))},t))]});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.table,testID:"buoy-ask-buoy-md-table",children:[r?(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{style:styles.tableScrollV,nestedScrollEnabled:!0,children:(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!0,children:n})}):n,s?(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{testID:"buoy-ask-buoy-md-table-toggle",accessibilityRole:"button",accessibilityLabel:r?"Show fewer rows":"Show all rows and columns",onPress:()=>i(e=>!e),style:({pressed:e})=>[styles.tfoot,e&&styles.pressed],children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.tfootText,children:r?`All ${t.length} rows · ${e.length} columns`:s}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.tfootAction,children:r?"Show fewer":"Show all"})]}):null]})}function Markdown({text:e,style:t}){const r=(0,_markdownParse.parseBlocks)(e);return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.wrap,children:r.map((e,r)=>"table"===e.kind?(0,_jsxRuntime.jsx)(MarkdownTable,{header:e.header,rows:e.rows},r):"code"===e.kind?(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{horizontal:!0,style:styles.codeBlock,contentContainerStyle:styles.codeBlockContent,testID:"buoy-ask-buoy-md-code",children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.codeText,selectable:!0,children:e.text})},r):"li"===e.kind?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.li,{paddingLeft:4+14*e.depth}],children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[t,styles.marker],children:e.marker}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[t,styles.liText],selectable:!0,children:renderInline(e.text,t)})]},r):(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[t,"h"===e.kind&&styles.bold],selectable:!0,children:renderInline(e.text,t)},r))})}const styles=_reactNative.StyleSheet.create({wrap:{gap:8},bold:{fontWeight:"600"},italic:{fontStyle:"italic"},code:{fontFamily:"Menlo",fontSize:13,color:_sharedUi.night.color.accent,backgroundColor:_sharedUi.night.color.fill},codeBlock:{borderRadius:_sharedUi.night.radius.row,borderWidth:_reactNative.StyleSheet.hairlineWidth,borderColor:_sharedUi.night.color.border,backgroundColor:_sharedUi.night.color.surface},codeBlockContent:{paddingHorizontal:12,paddingVertical:10},codeText:{fontFamily:"Menlo",fontSize:12,lineHeight:18,color:_sharedUi.night.color.text},li:{flexDirection:"row",gap:8},table:{borderRadius:_sharedUi.night.radius.row,borderWidth:_reactNative.StyleSheet.hairlineWidth,borderColor:_sharedUi.night.color.border,backgroundColor:_sharedUi.night.color.surface,overflow:"hidden"},tableWide:{minWidth:"100%"},tableScrollV:{maxHeight:320},tableHead:{flexDirection:"row",paddingHorizontal:10,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:10,paddingVertical:7,gap:8},trDivider:{borderTopWidth:_reactNative.StyleSheet.hairlineWidth,borderTopColor:_sharedUi.night.color.separator},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.3},colFixed:{flex:0,width:110},tfoot:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingHorizontal:10,paddingVertical:8,borderTopWidth:_reactNative.StyleSheet.hairlineWidth,borderTopColor:_sharedUi.night.color.border},tfootText:{color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.micro},tfootAction:{color:_sharedUi.night.color.accent,fontSize:_sharedUi.night.font.micro,fontWeight:"600"},pressed:{opacity:.7},marker:{color:_sharedUi.night.color.textSecondary,minWidth:14,textAlign:"right"},liText:{flex:1}});
|