@agimon-ai/po-native-components 0.0.0-alpha.13 → 0.0.0-alpha.131
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/LICENSE +149 -22
- package/dist/components/AgentAvatar.d.mts +14 -0
- package/dist/components/AgentAvatar.d.mts.map +1 -0
- package/dist/components/AgentAvatar.mjs +87 -0
- package/dist/components/AgentAvatar.mjs.map +1 -0
- package/dist/components/AnnotationSurface.d.mts +69 -0
- package/dist/components/AnnotationSurface.d.mts.map +1 -0
- package/dist/components/AnnotationSurface.mjs +426 -0
- package/dist/components/AnnotationSurface.mjs.map +1 -0
- package/dist/components/Badge.d.mts +1 -1
- package/dist/components/Badge.mjs +1 -1
- package/dist/components/Button.mjs +3 -3
- package/dist/components/Button.mjs.map +1 -1
- package/dist/components/CodeBlock.d.mts +3 -1
- package/dist/components/CodeBlock.d.mts.map +1 -1
- package/dist/components/CodeBlock.mjs +35 -47
- package/dist/components/CodeBlock.mjs.map +1 -1
- package/dist/components/CopyButton.d.mts +13 -0
- package/dist/components/CopyButton.d.mts.map +1 -0
- package/dist/components/CopyButton.mjs +43 -0
- package/dist/components/CopyButton.mjs.map +1 -0
- package/dist/components/CountBadge.d.mts +15 -0
- package/dist/components/CountBadge.d.mts.map +1 -0
- package/dist/components/CountBadge.mjs +49 -0
- package/dist/components/CountBadge.mjs.map +1 -0
- package/dist/components/Dialog.d.mts.map +1 -1
- package/dist/components/Dialog.mjs +9 -8
- package/dist/components/Dialog.mjs.map +1 -1
- package/dist/components/Dot.d.mts +1 -1
- package/dist/components/Dot.mjs +2 -2
- package/dist/components/DropdownMenu.d.mts +3 -1
- package/dist/components/DropdownMenu.d.mts.map +1 -1
- package/dist/components/DropdownMenu.mjs +21 -14
- package/dist/components/DropdownMenu.mjs.map +1 -1
- package/dist/components/HashlineLines.d.mts +13 -0
- package/dist/components/HashlineLines.d.mts.map +1 -0
- package/dist/components/HashlineLines.mjs +148 -0
- package/dist/components/HashlineLines.mjs.map +1 -0
- package/dist/components/HostFilter.d.mts +17 -0
- package/dist/components/HostFilter.d.mts.map +1 -0
- package/dist/components/HostFilter.mjs +66 -0
- package/dist/components/HostFilter.mjs.map +1 -0
- package/dist/components/HostTag.d.mts +7 -0
- package/dist/components/HostTag.d.mts.map +1 -0
- package/dist/components/HostTag.mjs +47 -0
- package/dist/components/HostTag.mjs.map +1 -0
- package/dist/components/InfoStrip.d.mts +9 -0
- package/dist/components/InfoStrip.d.mts.map +1 -0
- package/dist/components/InfoStrip.mjs +53 -0
- package/dist/components/InfoStrip.mjs.map +1 -0
- package/dist/components/Input.d.mts +3 -1
- package/dist/components/Input.d.mts.map +1 -1
- package/dist/components/Input.mjs +4 -3
- package/dist/components/Input.mjs.map +1 -1
- package/dist/components/Label.mjs +1 -1
- package/dist/components/List.d.mts.map +1 -1
- package/dist/components/List.mjs +38 -6
- package/dist/components/List.mjs.map +1 -1
- package/dist/components/LiveDuration.d.mts +30 -0
- package/dist/components/LiveDuration.d.mts.map +1 -0
- package/dist/components/LiveDuration.mjs +67 -0
- package/dist/components/LiveDuration.mjs.map +1 -0
- package/dist/components/Markdown.d.mts +10 -1
- package/dist/components/Markdown.d.mts.map +1 -1
- package/dist/components/Markdown.mjs +335 -26
- package/dist/components/Markdown.mjs.map +1 -1
- package/dist/components/MessageItem.d.mts +10 -15
- package/dist/components/MessageItem.d.mts.map +1 -1
- package/dist/components/MessageItem.mjs +72 -63
- package/dist/components/MessageItem.mjs.map +1 -1
- package/dist/components/NativeShellState.d.mts +30 -0
- package/dist/components/NativeShellState.d.mts.map +1 -0
- package/dist/components/NativeShellState.mjs +61 -0
- package/dist/components/NativeShellState.mjs.map +1 -0
- package/dist/components/SectionLabel.mjs +1 -1
- package/dist/components/Select.d.mts +33 -0
- package/dist/components/Select.d.mts.map +1 -0
- package/dist/components/Select.mjs +222 -0
- package/dist/components/Select.mjs.map +1 -0
- package/dist/components/Sheet.d.mts +9 -1
- package/dist/components/Sheet.d.mts.map +1 -1
- package/dist/components/Sheet.mjs +27 -10
- package/dist/components/Sheet.mjs.map +1 -1
- package/dist/components/SheetFrame.mjs +143 -28
- package/dist/components/SheetFrame.mjs.map +1 -1
- package/dist/components/SheetList.d.mts +14 -0
- package/dist/components/SheetList.d.mts.map +1 -0
- package/dist/components/SheetList.mjs +34 -0
- package/dist/components/SheetList.mjs.map +1 -0
- package/dist/components/ShowMore.d.mts +10 -0
- package/dist/components/ShowMore.d.mts.map +1 -0
- package/dist/components/ShowMore.mjs +44 -0
- package/dist/components/ShowMore.mjs.map +1 -0
- package/dist/components/Spinner.d.mts +1 -1
- package/dist/components/StatusBadge.d.mts +1 -1
- package/dist/components/Switch.d.mts +14 -0
- package/dist/components/Switch.d.mts.map +1 -0
- package/dist/components/Switch.mjs +37 -0
- package/dist/components/Switch.mjs.map +1 -0
- package/dist/components/SyntaxLine.d.mts +19 -0
- package/dist/components/SyntaxLine.d.mts.map +1 -0
- package/dist/components/SyntaxLine.mjs +134 -0
- package/dist/components/SyntaxLine.mjs.map +1 -0
- package/dist/components/Tabs.d.mts.map +1 -1
- package/dist/components/Tabs.mjs +8 -7
- package/dist/components/Tabs.mjs.map +1 -1
- package/dist/components/ToolPathLink.d.mts +10 -0
- package/dist/components/ToolPathLink.d.mts.map +1 -0
- package/dist/components/ToolPathLink.mjs +40 -0
- package/dist/components/ToolPathLink.mjs.map +1 -0
- package/dist/components/ToolResultImage.d.mts +12 -0
- package/dist/components/ToolResultImage.d.mts.map +1 -0
- package/dist/components/ToolResultImage.mjs +48 -0
- package/dist/components/ToolResultImage.mjs.map +1 -0
- package/dist/icons/iconGlyphs.d.mts +60 -0
- package/dist/icons/iconGlyphs.d.mts.map +1 -1
- package/dist/icons/iconGlyphs.mjs +60 -0
- package/dist/icons/iconGlyphs.mjs.map +1 -1
- package/dist/icons/icons.d.mts +61 -1
- package/dist/icons/icons.d.mts.map +1 -1
- package/dist/icons/icons.mjs +17 -2
- package/dist/icons/icons.mjs.map +1 -1
- package/dist/index.d.mts +20 -6
- package/dist/index.mjs +21 -7
- package/dist/lib/fonts.d.mts +3 -1
- package/dist/lib/fonts.d.mts.map +1 -1
- package/dist/lib/fonts.mjs +4 -2
- package/dist/lib/fonts.mjs.map +1 -1
- package/dist/lib/insideSheet.d.mts +10 -0
- package/dist/lib/insideSheet.d.mts.map +1 -0
- package/dist/lib/markdown.mjs +172 -23
- package/dist/lib/markdown.mjs.map +1 -1
- package/dist/lib/reading.mjs +60 -0
- package/dist/lib/reading.mjs.map +1 -0
- package/dist/lib/useControllable.mjs +14 -6
- package/dist/lib/useControllable.mjs.map +1 -1
- package/dist/lib/useReadingPage.mjs +33 -0
- package/dist/lib/useReadingPage.mjs.map +1 -0
- package/dist/shell.d.mts +6 -0
- package/dist/shell.mjs +7 -0
- package/package.json +37 -28
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Markdown.mjs","names":["createContext","ReactNode","useContext","useMemo","Linking","StyleSheet","fontOf","MarkdownBlock","MarkdownHeadingLevel","MarkdownInline","parseMarkdown","CodeBlock","FileLinkHandler","text","explicit","FileLinkContext","undefined","URL_OR_ANCHOR","decoded","href","decodeURIComponent","InlineCode","onFileLink","open","includes","styles","code","fileLink","InlineLink","children","path","isFile","test","openURL","catch","link","renderInline","nodes","map","node","index","type","strong","em","Block","block","first","prose","heading","level","firstHeading","list","items","item","marker","ordered","start","itemText","language","rule","MarkdownProps","Markdown","blocks","root","HEADING_STEP","const","HEADING_SPACE","HEADING_INK","create","theme","minWidth","gap","spacing","uni__dependencies","color","colors","fontFamily","sans","fontSize","base","lineHeight","marginTop","letterSpacing","fontWeight","semibold","hi","fontStyle","backgroundColor","deep","green","mono","textDecorationLine","blue","flexDirection","paddingLeft","dim","flexShrink","height"],"sources":["../../src/components/Markdown.tsx"],"sourcesContent":["import { createContext, type ReactNode, useContext, useMemo } from 'react';\nimport { Linking, Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\nimport { type MarkdownBlock, type MarkdownHeadingLevel, type MarkdownInline, parseMarkdown } from '../lib/markdown';\nimport { CodeBlock } from './CodeBlock';\n\n/*\n * Markdown in the web component's element styles, from the package's own\n * parser: headings, paragraphs, lists, code spans and fences, bold, italic\n * and links. Web links open with Linking; a file path goes to the host.\n *\n * ponytail: no tables, images or blockquotes yet; their source shows as text.\n */\n\n/**\n * What a piece of inline code or a relative link opens, when the host knows.\n * Returning undefined leaves it as plain code or an ordinary link. The same\n * contract as the web Markdown's handler.\n */\nexport type FileLinkHandler = (text: string, explicit?: boolean) => (() => void) | undefined;\n\n/** Passed by context so the inline renderers stay module functions. */\nconst FileLinkContext = createContext<FileLinkHandler | undefined>(undefined);\n\nconst URL_OR_ANCHOR = /^(?:[a-z][a-z\\d+.-]*:|\\/\\/|#|\\?)/i;\n\nfunction decoded(href: string): string | undefined {\n try {\n return decodeURIComponent(href);\n } catch {\n return undefined;\n }\n}\n\nfunction InlineCode({ text }: { text: string }) {\n const onFileLink = useContext(FileLinkContext);\n const open = text.includes('\\n') ? undefined : onFileLink?.(text);\n if (open !== undefined) {\n return (\n <Text\n accessibilityRole=\"link\"\n accessibilityHint={`open ${text}`}\n onPress={open}\n style={[styles.code, styles.fileLink]}\n >\n {text}\n </Text>\n );\n }\n return <Text style={styles.code}>{text}</Text>;\n}\n\nfunction InlineLink({ href, children }: { href: string; children: ReactNode }) {\n const onFileLink = useContext(FileLinkContext);\n const path = decoded(href);\n const isFile = path !== undefined && path !== '' && !URL_OR_ANCHOR.test(path);\n const open = isFile ? onFileLink?.(path, true) : undefined;\n return (\n <Text\n accessibilityRole=\"link\"\n onPress={() => {\n if (open !== undefined) open();\n else if (!isFile) Linking.openURL(href).catch(() => undefined);\n }}\n style={styles.link}\n >\n {children}\n </Text>\n );\n}\n\nfunction renderInline(nodes: readonly MarkdownInline[]): ReactNode[] {\n return nodes.map((node, index) => {\n switch (node.type) {\n case 'text':\n return node.text;\n case 'code':\n return <InlineCode key={index} text={node.text} />;\n case 'strong':\n return (\n <Text key={index} style={styles.strong}>\n {renderInline(node.children)}\n </Text>\n );\n case 'em':\n return (\n <Text key={index} style={styles.em}>\n {renderInline(node.children)}\n </Text>\n );\n case 'link':\n return (\n <InlineLink key={index} href={node.href}>\n {renderInline(node.children)}\n </InlineLink>\n );\n }\n });\n}\n\nfunction Block({ block, first }: { block: MarkdownBlock; first: boolean }) {\n switch (block.type) {\n case 'heading':\n return (\n <Text\n accessibilityRole=\"header\"\n style={[styles.prose, styles.heading(block.level), first && styles.firstHeading]}\n >\n {renderInline(block.children)}\n </Text>\n );\n case 'paragraph':\n return <Text style={styles.prose}>{renderInline(block.children)}</Text>;\n case 'list':\n return (\n <View accessibilityRole=\"list\" style={styles.list}>\n {block.items.map((item, index) => (\n <View key={index} style={styles.item}>\n <Text style={[styles.prose, styles.marker]}>{block.ordered ? `${block.start + index}.` : '\\u2022'}</Text>\n <Text style={[styles.prose, styles.itemText]}>{renderInline(item)}</Text>\n </View>\n ))}\n </View>\n );\n case 'code':\n return <CodeBlock text={block.text} language={block.language} />;\n case 'rule':\n return <View accessible={false} style={styles.rule} />;\n }\n}\n\nexport interface MarkdownProps {\n text: string;\n onFileLink?: FileLinkHandler;\n}\n\n/** Markdown in Po's shared presentation, parsed by the package's own small parser. */\nexport function Markdown({ text, onFileLink }: MarkdownProps) {\n const blocks = useMemo(() => parseMarkdown(text), [text]);\n return (\n <FileLinkContext.Provider value={onFileLink}>\n <View style={styles.root}>\n {blocks.map((block, index) => (\n <Block key={index} block={block} first={index === 0} />\n ))}\n </View>\n </FileLinkContext.Provider>\n );\n}\n\n/**\n * Headings step up from the prose and never shrink below it; h4 to h6 keep\n * the prose size and lean on weight, fading from `hi` to `dim`.\n */\nconst HEADING_STEP = { 1: '2xl', 2: 'xl', 3: 'lg', 4: 'base', 5: 'base', 6: 'base' } as const;\nconst HEADING_SPACE = { 1: 2, 2: 2, 3: 1, 4: 0, 5: 0, 6: 0 } as const;\nconst HEADING_INK = { 1: 'hi', 2: 'hi', 3: 'hi', 4: 'hi', 5: 'text', 6: 'dim' } as const;\n\nconst styles = StyleSheet.create((theme) => ({\n root: { minWidth: 0, gap: theme.spacing(2) },\n prose: {\n color: theme.colors.text,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n heading: (level: MarkdownHeadingLevel) => ({\n marginTop: theme.spacing(HEADING_SPACE[level]),\n fontSize: theme.fontSize[HEADING_STEP[level]],\n lineHeight: theme.lineHeight[HEADING_STEP[level]],\n letterSpacing: theme.letterSpacing[HEADING_STEP[level]],\n fontWeight: theme.fontWeight.semibold,\n color: theme.colors[HEADING_INK[level]],\n }),\n firstHeading: { marginTop: 0 },\n strong: { fontWeight: theme.fontWeight.semibold, color: theme.colors.hi },\n em: { fontStyle: 'italic' },\n code: {\n backgroundColor: theme.colors.deep,\n color: theme.colors.green,\n fontFamily: fontOf(theme.fontFamily.mono),\n },\n fileLink: { textDecorationLine: 'underline' },\n link: { color: theme.colors.blue, textDecorationLine: 'underline' },\n list: { gap: theme.spacing(0.5) },\n item: { flexDirection: 'row', gap: theme.spacing(2), paddingLeft: theme.spacing(1) },\n marker: { minWidth: theme.spacing(3), color: theme.colors.dim },\n itemText: { flexShrink: 1 },\n rule: { height: 1, backgroundColor: theme.colors['border-soft'] },\n}));\n"],"mappings":";;;;;;;;;;;;AAwBA,MAAMe,kBAAkBf,cAA2CgB,MAAS;AAE5E,MAAMC,gBAAgB;AAEtB,SAASC,QAAQC,MAAkC;CACjD,IAAI;EACF,OAAOC,mBAAmBD,IAAI;CAChC,QAAQ;EACN;CACF;AACF;AAEA,SAASE,WAAW,EAAER,QAA0B;CAC9C,MAAMS,aAAapB,WAAWa,eAAe;CAC7C,MAAMQ,OAAOV,KAAKW,SAAS,IAAI,IAAIR,SAAYM,aAAaT,IAAI;CAChE,IAAIU,SAASP,QACX,OACE,oBAAC,MAAD;EACE,mBAAkB;EAClB,mBA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AAEuC,OAAOL,MAAMM,OAAOiB;EAAMD,oBAAoB;EAAWlB,mBAAA,CAAA,CAAA;CAAC;CAClEtB,MAAM;EAAEoB,KAAKF,MAAMG,QAAQ,EAAG;EAACC,mBAAA,CAAA,CAAA;CAAC;CAChCpB,MAAM;EAAEwC,eAAe;EAAOtB,KAAKF,MAAMG,QAAQ,CAAC;EAAGsB,aAAazB,MAAMG,QAAQ,CAAC;EAACC,mBAAA,CAAA,CAAA;CAAC;CACnFnB,QAAQ;EAAEgB,UAAUD,MAAMG,QAAQ,CAAC;EAAGE,OAAOL,MAAMM,OAAOoB;EAAGtB,mBAAA,CAAA,CAAA;CAAC;CAC9DhB,UAAU,EAAEuC,YAAY,EAAE;CAC1BrC,MAAM;EAAEsC,QAAQ;EAAGV,iBAAiBlB,MAAMM,OAAO;EAAcF,mBAAA,CAAA,CAAA;CAAC;AAClE,EAAE"}
|
|
1
|
+
{"version":3,"file":"Markdown.mjs","names":["createContext","memo","ReactNode","useContext","useEffect","useMemo","useState","Linking","StyleSheet","fontOf","MarkdownBlock","MarkdownHeadingLevel","MarkdownInline","parseMarkdown","READING","inlineLength","inlinePrefix","useReadingPage","CodeBlock","ShowMore","FileLinkHandler","text","explicit","InitialPageContext","FileLinkContext","undefined","MarkdownImageLoader","path","Promise","url","dispose","ImageContext","URL_OR_ANCHOR","DIRECT_IMAGE","PLACEHOLDER_RATIO","decoded","href","decodeURIComponent","InlineCode","originalText","onFileLink","open","includes","styles","code","fileLink","InlineLink","children","isFile","test","openURL","catch","link","MarkdownImage","src","alt","loader","source","startsWith","slice","split","loaded","setLoaded","failed","ratio","setRatio","active","asset","Awaited","ReturnType","resolve","then","Error","result","current","uri","waiting","prose","imageState","nativeEvent","fit","width","height","size","Image","getSize","image","aspectRatio","renderInline","nodes","map","node","index","type","strong","em","MarkdownTable","header","rows","initialPage","rowPage","setRows","columnPage","setColumns","cellPage","setCells","visibleRows","Math","max","visibleHeader","columns","limit","cell","clipped","row","length","some","root","table","column","headCell","meta","actions","page","Blocks","blocks","quoted","setPage","visible","parts","block","Infinity","BoundedBlock","props","first","revealedPage","characters","total","shown","items","reduce","sum","item","remaining","next","push","more","Block","heading","level","firstHeading","run","flush","list","marker","ordered","start","itemText","language","rule","quote","MarkdownProps","loadImage","Markdown","generation","HEADING_STEP","const","HEADING_SPACE","HEADING_INK","create","theme","color","colors","dim","fontFamily","sans","fontSize","sm","lineHeight","uni__dependencies","flexDirection","flexWrap","minWidth","gap","spacing","base","marginTop","letterSpacing","fontWeight","semibold","hi","fontStyle","backgroundColor","deep","green","mono","textDecorationLine","blue","paddingLeft","flexShrink","borderLeftWidth","borderLeftColor","border","borderTopWidth","borderColor","paddingHorizontal","paddingVertical","borderRightWidth","borderBottomWidth","maxHeight","borderRadius","md","borderWidth"],"sources":["../../src/components/Markdown.tsx"],"sourcesContent":["import { createContext, memo, type ReactNode, useContext, useEffect, useMemo, useState } from 'react';\nimport { Image, Linking, ScrollView, Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\nimport { type MarkdownBlock, type MarkdownHeadingLevel, type MarkdownInline, parseMarkdown } from '../lib/markdown';\nimport { READING, inlineLength, inlinePrefix } from '../lib/reading';\nimport { useReadingPage } from '../lib/useReadingPage';\nimport { CodeBlock } from './CodeBlock';\nimport { ShowMore } from './ShowMore';\n\n/*\n * Markdown in the web component's element styles, from the package's own\n * parser: headings, paragraphs, lists, code spans and fences, bold, italic,\n * links, images, blockquotes and tables. Web links open with Linking; a file\n * path goes to the host. Raw HTML blocks are left out, as on the web.\n */\n\n/**\n * What a piece of inline code or a relative link opens, when the host knows.\n * Returning undefined leaves it as plain code or an ordinary link. The same\n * contract as the web Markdown's handler.\n */\nexport type FileLinkHandler = (text: string, explicit?: boolean) => (() => void) | undefined;\n\n/** Passed by context so the inline renderers stay module functions. */\nconst InitialPageContext = createContext(1);\n\nconst FileLinkContext = createContext<FileLinkHandler | undefined>(undefined);\n\n/** Loads a relative image path from the host; the same contract as the web Markdown's `loadImage`. */\nexport type MarkdownImageLoader = (path: string) => Promise<{ url: string; dispose(): void }>;\n\nconst ImageContext = createContext<MarkdownImageLoader | undefined>(undefined);\n\nconst URL_OR_ANCHOR = /^(?:[a-z][a-z\\d+.-]*:|\\/\\/|#|\\?)/i;\n/** Sources an Image may load as written; any other scheme stays its alt text. */\nconst DIRECT_IMAGE = /^(?:https?:|data:image\\/)/i;\n/** Until the image reports its size, it holds a landscape box rather than collapsing. */\nconst PLACEHOLDER_RATIO = 16 / 9;\n\nfunction decoded(href: string): string | undefined {\n try {\n return decodeURIComponent(href);\n } catch {\n return undefined;\n }\n}\n\nfunction InlineCode({ text, originalText = text }: { text: string; originalText?: string }) {\n const onFileLink = useContext(FileLinkContext);\n const open = originalText.includes('\\n') ? undefined : onFileLink?.(originalText);\n if (open !== undefined) {\n return (\n <Text\n accessibilityRole=\"link\"\n accessibilityHint={`open ${originalText}`}\n onPress={open}\n style={[styles.code, styles.fileLink]}\n >\n {text}\n </Text>\n );\n }\n return <Text style={styles.code}>{text}</Text>;\n}\n\nfunction InlineLink({ href, children }: { href: string; children: ReactNode }) {\n const onFileLink = useContext(FileLinkContext);\n const path = decoded(href);\n const isFile = path !== undefined && path !== '' && !URL_OR_ANCHOR.test(path);\n const open = isFile ? onFileLink?.(path, true) : undefined;\n return (\n <Text\n accessibilityRole=\"link\"\n onPress={() => {\n if (open !== undefined) open();\n else if (!isFile) Linking.openURL(href).catch(() => undefined);\n }}\n style={styles.link}\n >\n {children}\n </Text>\n );\n}\n\n/** One image: a file path through the host's loader, or a web or data address as written. */\nfunction MarkdownImage({ src, alt }: { src: string; alt: string }) {\n const loader = useContext(ImageContext);\n // An invalid encoded filename is shown as unavailable, never fetched.\n const source = src.startsWith('@artifact:') ? src.slice(1) : src;\n const path =\n URL_OR_ANCHOR.test(source) && !source.startsWith('artifact:')\n ? undefined\n : (decoded(source.split(/[?#]/u, 1)[0]!) ?? '');\n const [loaded, setLoaded] = useState<{ path: string; url?: string; failed?: boolean }>();\n const [ratio, setRatio] = useState(PLACEHOLDER_RATIO);\n useEffect(() => {\n if (loader === undefined || path === undefined) return;\n let active = true;\n let asset: Awaited<ReturnType<MarkdownImageLoader>> | undefined;\n void Promise.resolve()\n .then(() => {\n if (path === '') throw new Error('Invalid image path.');\n return loader(path);\n })\n .then((result) => {\n if (!active) return result.dispose();\n asset = result;\n setLoaded({ path, url: result.url });\n })\n .catch(() => {\n // The failure is shown in place, as the web image does.\n if (active) setLoaded({ path, failed: true });\n });\n return () => {\n active = false;\n asset?.dispose();\n };\n }, [path, loader]);\n const current = loaded?.path === path ? loaded : undefined;\n const uri = path === undefined ? (DIRECT_IMAGE.test(src) ? src : undefined) : current?.url;\n if (uri === undefined || current?.failed) {\n const waiting = path !== undefined && loader !== undefined && current === undefined;\n return (\n <Text style={[styles.prose, styles.imageState]} accessibilityRole={waiting ? 'text' : 'alert'}>\n {alt || path || 'Image'} ({waiting ? 'loading\\u2026' : 'unavailable'})\n </Text>\n );\n }\n return (\n <Image\n source={{ uri }}\n accessibilityLabel={alt || 'Image'}\n accessibilityIgnoresInvertColors\n resizeMode=\"contain\"\n onLoad={({ nativeEvent }) => {\n const fit = (width: number, height: number) => {\n if (width > 0 && height > 0) setRatio(width / height);\n };\n // iOS and Android report the size with the event; react-native-web does not, so it asks.\n const size = (nativeEvent as { source?: { width: number; height: number } } | undefined)?.source;\n if (size !== undefined) fit(size.width, size.height);\n else Image.getSize(uri, fit, () => undefined);\n }}\n onError={() => setLoaded({ path: path ?? src, failed: true })}\n style={[styles.image, { aspectRatio: ratio }]}\n />\n );\n}\nfunction renderInline(nodes: readonly MarkdownInline[]): ReactNode[] {\n return nodes.map((node, index) => {\n switch (node.type) {\n case 'text':\n return node.text;\n case 'code':\n return <InlineCode key={index} text={node.text} originalText={node.originalText} />;\n case 'strong':\n return (\n <Text key={index} style={styles.strong}>\n {renderInline(node.children)}\n </Text>\n );\n case 'em':\n return (\n <Text key={index} style={styles.em}>\n {renderInline(node.children)}\n </Text>\n );\n case 'link':\n return (\n <InlineLink key={index} href={node.href}>\n {renderInline(node.children)}\n </InlineLink>\n );\n case 'image':\n // Inside a heading or list item an image keeps to its alt text; paragraphs draw it.\n return node.alt;\n }\n });\n}\n\n/**\n * A table read column by column: every cell keeps to one line inside the sideways scroll, so each\n * column takes its widest cell and the rows line up without a table layout.\n */\nfunction MarkdownTable({ header, rows }: { header: MarkdownInline[][]; rows: MarkdownInline[][][] }) {\n const initialPage = useContext(InitialPageContext);\n const [rowPage, setRows] = useState(initialPage);\n const [columnPage, setColumns] = useState(initialPage);\n const [cellPage, setCells] = useState(initialPage);\n const visibleRows = rows.slice(0, READING.rows * Math.max(initialPage, rowPage));\n const visibleHeader = header.slice(0, READING.columns * Math.max(initialPage, columnPage));\n const limit = READING.cell * Math.max(initialPage, cellPage);\n const clipped = [visibleHeader, ...visibleRows.map((row) => row.slice(0, visibleHeader.length))].some((row) =>\n row.some((cell) => inlineLength(cell) > limit),\n );\n return (\n <View style={styles.root}>\n <ScrollView horizontal showsHorizontalScrollIndicator={false}>\n <View style={styles.table}>\n {visibleHeader.map((cell, column) => (\n <View key={column}>\n <Text style={[styles.prose, styles.cell, styles.headCell]}>\n {renderInline(inlinePrefix(cell, limit))}\n {inlineLength(cell) > limit ? '…' : ''}\n </Text>\n {visibleRows.map((row, index) => (\n <Text key={index} style={[styles.prose, styles.cell]}>\n {renderInline(inlinePrefix(row[column] ?? [], limit))}\n {inlineLength(row[column] ?? []) > limit ? '…' : ''}\n </Text>\n ))}\n </View>\n ))}\n </View>\n </ScrollView>\n <Text style={styles.meta}>\n {visibleRows.length} of {rows.length} rows · {visibleHeader.length} of {header.length} columns\n {clipped ? ` · Cells: first ${limit} characters` : ''}\n </Text>\n <View style={styles.actions}>\n {visibleRows.length < rows.length ? (\n <ShowMore label=\"Show more rows\" onPress={() => setRows((page) => page + 1)} />\n ) : null}\n {visibleHeader.length < header.length ? (\n <ShowMore label=\"Show more columns\" onPress={() => setColumns((page) => page + 1)} />\n ) : null}\n {clipped ? <ShowMore label=\"Show more cell text\" onPress={() => setCells((page) => page + 1)} /> : null}\n </View>\n </View>\n );\n}\n\nfunction Blocks({ blocks, quoted = false }: { blocks: MarkdownBlock[]; quoted?: boolean }) {\n const initialPage = useContext(InitialPageContext);\n const [page, setPage] = useState(initialPage);\n const visible = blocks.slice(0, READING.parts * Math.max(initialPage, page));\n return (\n <InitialPageContext.Provider value={Math.max(initialPage, page)}>\n {visible.map((block, index) => (\n <BoundedBlock key={index} block={block} first={index === 0} quoted={quoted} />\n ))}\n {visible.length < blocks.length ? (\n <ShowMore\n label=\"Show more\"\n summary={`${visible.length} of ${blocks.length} parts`}\n onPress={() => setPage(Infinity)}\n />\n ) : null}\n </InitialPageContext.Provider>\n );\n}\n\nfunction BoundedBlock({ block, ...props }: { block: MarkdownBlock; first: boolean; quoted?: boolean }) {\n const initialPage = useContext(InitialPageContext);\n const [revealedPage, setPage] = useState(initialPage);\n const page = Math.max(initialPage, revealedPage);\n const limit = READING.characters * page;\n let visible = block;\n let total = 0;\n let shown = 0;\n if (block.type === 'heading' || block.type === 'paragraph') {\n total = inlineLength(block.children);\n const children = inlinePrefix(block.children, limit);\n shown = inlineLength(children);\n visible = { ...block, children };\n } else if (block.type === 'list') {\n total = block.items.reduce((sum, item) => sum + inlineLength(item), 0);\n let remaining = limit;\n const items = [];\n for (const item of block.items.slice(0, READING.parts * page)) {\n if (remaining <= 0) break;\n const next = inlinePrefix(item, remaining);\n items.push(next);\n const length = inlineLength(next);\n shown += length;\n remaining -= length;\n }\n visible = { ...block, items };\n }\n const more =\n shown < total || (block.type === 'list' && visible.type === 'list' && visible.items.length < block.items.length);\n return (\n <View style={styles.root}>\n <Block block={visible} {...props} />\n {more ? (\n <ShowMore\n label=\"Show more text\"\n summary={`${shown} of ${total} characters`}\n onPress={() => setPage(Infinity)}\n />\n ) : null}\n </View>\n );\n}\n\nfunction Block({ block, first, quoted = false }: { block: MarkdownBlock; first: boolean; quoted?: boolean }) {\n const initialPage = useContext(InitialPageContext);\n const prose = [styles.prose, quoted && styles.quoted];\n switch (block.type) {\n case 'heading':\n return (\n <Text\n accessibilityRole=\"header\"\n style={[...prose, styles.heading(block.level), first && styles.firstHeading, quoted && styles.quoted]}\n >\n {renderInline(block.children)}\n </Text>\n );\n case 'paragraph': {\n // An image breaks the paragraph's text into runs, since an Image cannot sit inside Text.\n const parts: ReactNode[] = [];\n let run: MarkdownInline[] = [];\n const flush = () => {\n if (run.length > 0)\n parts.push(\n <Text key={parts.length} style={prose}>\n {renderInline(run)}\n </Text>,\n );\n run = [];\n };\n for (const node of block.children) {\n if (node.type !== 'image') {\n run.push(node);\n continue;\n }\n flush();\n parts.push(<MarkdownImage key={parts.length} src={node.src} alt={node.alt} />);\n }\n flush();\n return parts.length === 1 ? parts[0] : <View style={styles.root}>{parts}</View>;\n }\n case 'list':\n return (\n <View accessibilityRole=\"list\" style={styles.list}>\n {block.items.map((item, index) => (\n <View key={index} style={styles.item}>\n <Text style={[...prose, styles.marker]}>{block.ordered ? `${block.start + index}.` : '\\u2022'}</Text>\n <Text style={[...prose, styles.itemText]}>{renderInline(item)}</Text>\n </View>\n ))}\n </View>\n );\n case 'code':\n return <CodeBlock text={block.text} language={block.language} initialPage={initialPage} />;\n case 'rule':\n return <View accessible={false} style={styles.rule} />;\n case 'quote':\n return (\n <View style={[styles.root, styles.quote]}>\n <Blocks blocks={block.children} quoted />\n </View>\n );\n case 'table':\n return <MarkdownTable header={block.header} rows={block.rows} />;\n }\n}\n\nexport interface MarkdownProps {\n text: string;\n onFileLink?: FileLinkHandler;\n /** Loads relative image paths; without it they show as unavailable. */\n loadImage?: MarkdownImageLoader;\n /** Initial reveal pages for a restored reading position. Defaults to one. */\n initialPage?: number;\n}\n\n/** Markdown in Po's shared presentation, parsed by the package's own small parser. */\nexport const Markdown = memo(function Markdown({ text, onFileLink, loadImage, initialPage = 1 }: MarkdownProps) {\n const blocks = useMemo(() => parseMarkdown(text), [text]);\n const { generation } = useReadingPage(text);\n return (\n <InitialPageContext.Provider value={initialPage}>\n <FileLinkContext.Provider value={onFileLink}>\n <ImageContext.Provider value={loadImage}>\n <View style={styles.root}>\n <Blocks key={generation} blocks={blocks} />\n </View>\n </ImageContext.Provider>\n </FileLinkContext.Provider>\n </InitialPageContext.Provider>\n );\n});\n\n/**\n * Headings step up from the prose and never shrink below it; h4 to h6 keep\n * the prose size and lean on weight, fading from `hi` to `dim`.\n */\nconst HEADING_STEP = { 1: '2xl', 2: 'xl', 3: 'lg', 4: 'base', 5: 'base', 6: 'base' } as const;\nconst HEADING_SPACE = { 1: 2, 2: 2, 3: 1, 4: 0, 5: 0, 6: 0 } as const;\nconst HEADING_INK = { 1: 'hi', 2: 'hi', 3: 'hi', 4: 'hi', 5: 'text', 6: 'dim' } as const;\n\nconst styles = StyleSheet.create((theme) => ({\n meta: {\n color: theme.colors.dim,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n actions: { flexDirection: 'row', flexWrap: 'wrap' },\n root: { minWidth: 0, gap: theme.spacing(2) },\n prose: {\n color: theme.colors.text,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n heading: (level: MarkdownHeadingLevel) => ({\n marginTop: theme.spacing(HEADING_SPACE[level]),\n fontSize: theme.fontSize[HEADING_STEP[level]],\n lineHeight: theme.lineHeight[HEADING_STEP[level]],\n letterSpacing: theme.letterSpacing[HEADING_STEP[level]],\n fontWeight: theme.fontWeight.semibold,\n color: theme.colors[HEADING_INK[level]],\n }),\n firstHeading: { marginTop: 0 },\n strong: { fontWeight: theme.fontWeight.semibold, color: theme.colors.hi },\n em: { fontStyle: 'italic' },\n code: {\n backgroundColor: theme.colors.deep,\n color: theme.colors.green,\n fontFamily: fontOf(theme.fontFamily.mono),\n },\n fileLink: { textDecorationLine: 'underline' },\n link: { color: theme.colors.blue, textDecorationLine: 'underline' },\n list: { gap: theme.spacing(0.5) },\n item: { flexDirection: 'row', gap: theme.spacing(2), paddingLeft: theme.spacing(1) },\n marker: { minWidth: theme.spacing(3), color: theme.colors.dim },\n itemText: { flexShrink: 1 },\n rule: { height: 1, backgroundColor: theme.colors['border-soft'] },\n // The web blockquote: a rule at the left and quieter text.\n quote: { borderLeftWidth: 2, borderLeftColor: theme.colors.border, paddingLeft: theme.spacing(3) },\n quoted: { color: theme.colors.dim },\n // The web table: bordered cells, the header on the deep surface.\n table: {\n flexDirection: 'row',\n borderTopWidth: 1,\n borderLeftWidth: 1,\n borderColor: theme.colors.border,\n },\n cell: {\n paddingHorizontal: theme.spacing(2),\n paddingVertical: theme.spacing(1),\n borderRightWidth: 1,\n borderBottomWidth: 1,\n borderColor: theme.colors.border,\n },\n headCell: { backgroundColor: theme.colors.deep, fontWeight: theme.fontWeight.semibold, color: theme.colors.hi },\n // The web image's frame: at most 480 tall, a soft border and rounded corners.\n image: {\n width: '100%',\n maxHeight: 480,\n borderRadius: theme.borderRadius.md,\n borderWidth: 1,\n borderColor: theme.colors.border,\n },\n imageState: { color: theme.colors.dim },\n}));\n"],"mappings":";;;;;;;;;;;;;;;;;AA0BA,MAAMuB,qBAAqBvB,cAAc,CAAC;AAE1C,MAAMwB,kBAAkBxB,cAA2CyB,MAAS;AAK5E,MAAMM,eAAe/B,cAA+CyB,MAAS;AAE7E,MAAMO,gBAAgB;;AAEtB,MAAMC,eAAe;;AAErB,MAAMC,oBAAoB,KAAK;AAE/B,SAASC,QAAQC,MAAkC;CACjD,IAAI;EACF,OAAOC,mBAAmBD,IAAI;CAChC,QAAQ;EACN;CACF;AACF;AAEA,SAASE,WAAW,EAAEjB,MAAMkB,eAAelB,QAAiD;CAC1F,MAAMmB,aAAarC,WAAWqB,eAAe;CAC7C,MAAMiB,OAAOF,aAAaG,SAAS,IAAI,IAAIjB,SAAYe,aAAaD,YAAY;CAChF,IAAIE,SAAShB,QACX,OAC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,8 @@
|
|
|
1
1
|
import { StatusTone } from "./StatusBadge.mjs";
|
|
2
2
|
import { StyleProp, TextProps, ViewProps, ViewStyle } from "react-native";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
|
+
import { MessageItemState, MessageItemState as MessageItemState$1 } from "@agimon-ai/po-native-components/shell";
|
|
4
5
|
//#region src/components/MessageItem.d.ts
|
|
5
|
-
export interface MessageItemState {
|
|
6
|
-
tone: StatusTone;
|
|
7
|
-
/** Whether the header offers the toggle; an item that hides nothing offers none. */
|
|
8
|
-
expandable: boolean;
|
|
9
|
-
expanded: boolean;
|
|
10
|
-
toggle: () => void;
|
|
11
|
-
}
|
|
12
6
|
/** The enclosing item's state, for a part that lives deeper than the item's render prop. */
|
|
13
7
|
export declare function useMessageItem(): MessageItemState;
|
|
14
8
|
/** The tone a tool call's item wears: running while the tool runs, then its outcome. */
|
|
@@ -35,19 +29,19 @@ export interface MessageItemProps extends Omit<ViewProps, 'children' | 'style'>
|
|
|
35
29
|
export declare function MessageItem({ tone, expandable, defaultExpanded, expanded, onExpandedChange, children, style, ...props }: MessageItemProps): import("react").JSX.Element;
|
|
36
30
|
export interface MessageItemGroupProps extends Omit<ViewProps, 'children' | 'style'> {
|
|
37
31
|
tone?: StatusTone;
|
|
38
|
-
/** The bold label at the left of the group header
|
|
32
|
+
/** The bold label at the left of the group header, such as "7 tool calls". */
|
|
39
33
|
title: ReactNode;
|
|
40
|
-
/** The line beside it, such as
|
|
34
|
+
/** The line beside it, such as which tools the group holds. */
|
|
41
35
|
summary?: ReactNode;
|
|
42
|
-
/** The
|
|
36
|
+
/** The outcome's label; defaults to the tone's label, null hides the outcome. */
|
|
43
37
|
badge?: ReactNode | null;
|
|
44
38
|
children?: ReactNode;
|
|
45
39
|
style?: StyleProp<ViewStyle>;
|
|
46
40
|
}
|
|
47
41
|
/**
|
|
48
|
-
* One frame around a run of items that belong together.
|
|
49
|
-
* becomes a row
|
|
50
|
-
* an edge down its left side.
|
|
42
|
+
* One frame around a run of items that belong together. It stays open: each
|
|
43
|
+
* item inside becomes a row with its own name, outcome and expand, no card of
|
|
44
|
+
* its own, and its tone an edge down its left side.
|
|
51
45
|
*/
|
|
52
46
|
export declare function MessageItemGroup({ tone, title, summary, badge, children, style, ...props }: MessageItemGroupProps): import("react").JSX.Element;
|
|
53
47
|
export interface MessageItemHeaderProps extends Omit<ViewProps, 'children' | 'style'> {
|
|
@@ -60,9 +54,9 @@ export interface MessageItemHeaderProps extends Omit<ViewProps, 'children' | 'st
|
|
|
60
54
|
style?: StyleProp<ViewStyle>;
|
|
61
55
|
}
|
|
62
56
|
/**
|
|
63
|
-
* The title row: label, summary, the tone's
|
|
57
|
+
* The title row: label, summary, the tone's outcome and, when the item is
|
|
64
58
|
* expandable, a chevron; the whole row is the toggle. A row inside a group
|
|
65
|
-
*
|
|
59
|
+
* keeps its name but drops the chip and caption the group header carries.
|
|
66
60
|
*/
|
|
67
61
|
export declare function MessageItemHeader({ title, badge, children, style, ...props }: MessageItemHeaderProps): import("react").JSX.Element;
|
|
68
62
|
export interface MessageItemPartProps extends Omit<ViewProps, 'children' | 'style'> {
|
|
@@ -84,4 +78,5 @@ export interface MessageItemStatusProps extends Omit<TextProps, 'children'> {
|
|
|
84
78
|
/** The one-line status under a body: `running`, `failed`, `done`, or the hint that more is hidden. */
|
|
85
79
|
export declare function MessageItemStatus({ tone, glyph, expands, children, containerStyle, style, ...props }: MessageItemStatusProps): import("react").JSX.Element;
|
|
86
80
|
//#endregion
|
|
81
|
+
export type { MessageItemState$1 as MessageItemState };
|
|
87
82
|
//# sourceMappingURL=MessageItem.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageItem.d.mts","names":[],"sources":["../../src/components/MessageItem.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"MessageItem.d.mts","names":[],"sources":["../../src/components/MessageItem.tsx"],"mappings":";;;;;;wBAqCgB,kBAAkB;;wBAKlB,SAAS;EAAS;EAAkB;IAAqB;;qBAK5D,cAAc,SAAS,OAAO;;qBAU9B,cAAc,SAAS,OAAO;iBAmB1B,yBAAyB,KAAK;EAC7C,OAAO;;EAEP;EACA;;EAEA;EACA,oBAAoB;;EAEpB,WAAW,cAAc,OAAO,qBAAqB;EACrD,QAAQ,UAAU;;wBAGJ,cACd,MACA,YACA,iBACA,UACA,kBACA,UACA,UACG,SACF,mCAAgB,IAAA;iBA2FF,8BAA8B,KAAK;EAClD,OAAO;;EAEP,OAAO;;EAEP,UAAU;;EAEV,QAAQ;EACR,WAAW;EACX,QAAQ,UAAU;;;;;;;wBAQJ,mBACd,MACA,OACA,SACA,OACA,UACA,UACG,SACF,wCAAqB,IAAA;iBAmBP,+BAA+B,KAAK;;EAEnD,OAAO;;EAEP,QAAQ;;EAER,WAAW;EACX,QAAQ,UAAU;;;;;;;wBAQJ,oBAAoB,OAAO,OAAO,UAAU,UAAU,SAAS,yCAAsB,IAAA;iBAoCpF,6BAA6B,KAAK;EACjD,WAAW;EACX,QAAQ,UAAU;;;wBAIJ,kBAAkB,UAAU,UAAU,SAAS,uCAAoB,IAAA;iBAQlE,+BAA+B,KAAK;EACnD,OAAO;;EAEP;;EAEA;EACA,WAAW;;EAEX,iBAAiB,UAAU;;;wBAIb,oBACd,MACA,OACA,SACA,UACA,gBACA,UACG,SACF,yCAAsB,IAAA"}
|
|
@@ -7,28 +7,27 @@ import { AlertIcon, CheckIcon, ChevronDownIcon, ChevronRightIcon, WrenchIcon } f
|
|
|
7
7
|
import { useControllable } from "../lib/useControllable.mjs";
|
|
8
8
|
import { STATUS_EDGE, StatusBadge } from "./StatusBadge.mjs";
|
|
9
9
|
import { View } from "react-native-unistyles/components/native/View";
|
|
10
|
-
import { StyleSheet } from "react-native-unistyles";
|
|
11
10
|
import { Text } from "react-native-unistyles/components/native/Text";
|
|
12
|
-
import {
|
|
11
|
+
import { StyleSheet } from "react-native-unistyles";
|
|
12
|
+
import { useContext, useMemo } from "react";
|
|
13
13
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { Pressable } from "react-native-unistyles/components/native/Pressable";
|
|
15
|
+
import { MessageItemContext, MessageItemGroupContext } from "@agimon-ai/po-native-components/shell";
|
|
15
16
|
|
|
16
17
|
//#region src/components/MessageItem.tsx
|
|
18
|
+
/** Tones whose outcome reads as an icon alone; the rest keep their worded badge. */
|
|
19
|
+
const ICON_TONES = /* @__PURE__ */ new Set([
|
|
20
|
+
"running",
|
|
21
|
+
"ok",
|
|
22
|
+
"error"
|
|
23
|
+
]);
|
|
17
24
|
const MIN_ROW_HEIGHT = 44;
|
|
18
25
|
const LEAD_CHIP = 36;
|
|
19
26
|
const ROW_EDGE_WIDTH = 2;
|
|
20
|
-
const MessageItemContext = createContext({
|
|
21
|
-
tone: "neutral",
|
|
22
|
-
expandable: false,
|
|
23
|
-
expanded: false,
|
|
24
|
-
toggle: () => void 0
|
|
25
|
-
});
|
|
26
27
|
/** The enclosing item's state, for a part that lives deeper than the item's render prop. */
|
|
27
28
|
function useMessageItem() {
|
|
28
29
|
return useContext(MessageItemContext);
|
|
29
30
|
}
|
|
30
|
-
/** The group an item is a row of, or null for an item that is a card of its own. */
|
|
31
|
-
const MessageItemGroupContext = createContext(null);
|
|
32
31
|
/** The tone a tool call's item wears: running while the tool runs, then its outcome. */
|
|
33
32
|
function toolTone(state) {
|
|
34
33
|
return state.running ? "running" : state.isError ? "error" : "ok";
|
|
@@ -89,91 +88,102 @@ function Summary({ children }) {
|
|
|
89
88
|
});
|
|
90
89
|
}
|
|
91
90
|
/** The card's lead: the tool chip, the "Tool call" caption, then the name and its summary on one line. */
|
|
92
|
-
function ToolCallLead({ title, children }) {
|
|
91
|
+
function ToolCallLead({ title, caption = "Tool call", children }) {
|
|
93
92
|
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(View, {
|
|
94
93
|
accessible: false,
|
|
95
94
|
style: styles.chip,
|
|
96
95
|
children: /* @__PURE__ */ jsx(WrenchIcon, { size: 16 })
|
|
97
96
|
}), /* @__PURE__ */ jsxs(View, {
|
|
98
97
|
style: styles.lead,
|
|
99
|
-
children: [/* @__PURE__ */ jsx(Text, {
|
|
98
|
+
children: [caption === null ? null : /* @__PURE__ */ jsx(Text, {
|
|
100
99
|
style: styles.caption,
|
|
101
|
-
children:
|
|
100
|
+
children: caption
|
|
102
101
|
}), /* @__PURE__ */ jsxs(View, {
|
|
103
102
|
style: styles.titleLine,
|
|
104
103
|
children: [wrapText(title, styles.title), /* @__PURE__ */ jsx(Summary, { children })]
|
|
105
104
|
})]
|
|
106
105
|
})] });
|
|
107
106
|
}
|
|
108
|
-
/**
|
|
109
|
-
function
|
|
107
|
+
/** A row's lead inside a group: the name and its summary, no chip or caption, since the group header carries them. */
|
|
108
|
+
function RowLead({ title, children }) {
|
|
109
|
+
return /* @__PURE__ */ jsxs(View, {
|
|
110
|
+
style: [styles.lead, styles.titleLine],
|
|
111
|
+
children: [wrapText(title, styles.title), /* @__PURE__ */ jsx(Summary, { children })]
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/** The outcome: an icon for running, done and failed, announced by its label; a worded badge for other tones. */
|
|
115
|
+
function Outcome({ tone, children }) {
|
|
110
116
|
const ink = STATUS_COLORS[tone].ink;
|
|
111
|
-
return /* @__PURE__ */ jsxs(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
117
|
+
if (ICON_TONES.has(tone)) return /* @__PURE__ */ jsxs(View, {
|
|
118
|
+
accessible: true,
|
|
119
|
+
accessibilityRole: "image",
|
|
120
|
+
accessibilityLabel: typeof children === "string" ? children : STATUS_LABEL[tone],
|
|
121
|
+
style: styles.outcomeIcon,
|
|
115
122
|
children: [
|
|
116
123
|
tone === "running" ? /* @__PURE__ */ jsx(Spinner, { color: ink }) : null,
|
|
117
124
|
tone === "ok" ? /* @__PURE__ */ jsx(CheckIcon, {
|
|
118
|
-
size:
|
|
125
|
+
size: 14,
|
|
119
126
|
color: ink
|
|
120
127
|
}) : null,
|
|
121
128
|
tone === "error" ? /* @__PURE__ */ jsx(AlertIcon, {
|
|
122
|
-
size:
|
|
129
|
+
size: 14,
|
|
123
130
|
color: ink
|
|
124
|
-
}) : null
|
|
125
|
-
children
|
|
131
|
+
}) : null
|
|
126
132
|
]
|
|
127
133
|
});
|
|
134
|
+
return /* @__PURE__ */ jsx(StatusBadge, {
|
|
135
|
+
tone,
|
|
136
|
+
size: "md",
|
|
137
|
+
style: styles.outcome,
|
|
138
|
+
children
|
|
139
|
+
});
|
|
128
140
|
}
|
|
129
141
|
/**
|
|
130
|
-
* One frame around a run of items that belong together.
|
|
131
|
-
* becomes a row
|
|
132
|
-
* an edge down its left side.
|
|
142
|
+
* One frame around a run of items that belong together. It stays open: each
|
|
143
|
+
* item inside becomes a row with its own name, outcome and expand, no card of
|
|
144
|
+
* its own, and its tone an edge down its left side.
|
|
133
145
|
*/
|
|
134
146
|
function MessageItemGroup({ tone = "neutral", title, summary, badge, children, style, ...props }) {
|
|
135
147
|
const label = badge === void 0 ? STATUS_LABEL[tone] : badge;
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}), /* @__PURE__ */ jsx(View, { children })]
|
|
156
|
-
})
|
|
148
|
+
const group = useMemo(() => ({ tone }), [tone]);
|
|
149
|
+
return /* @__PURE__ */ jsxs(MessageItem, {
|
|
150
|
+
tone,
|
|
151
|
+
style,
|
|
152
|
+
...props,
|
|
153
|
+
children: [/* @__PURE__ */ jsxs(View, {
|
|
154
|
+
style: styles.header,
|
|
155
|
+
children: [/* @__PURE__ */ jsx(ToolCallLead, {
|
|
156
|
+
title,
|
|
157
|
+
caption: null,
|
|
158
|
+
children: summary
|
|
159
|
+
}), label !== null && label !== "" ? /* @__PURE__ */ jsx(Outcome, {
|
|
160
|
+
tone,
|
|
161
|
+
children: label
|
|
162
|
+
}) : null]
|
|
163
|
+
}), /* @__PURE__ */ jsx(MessageItemGroupContext.Provider, {
|
|
164
|
+
value: group,
|
|
165
|
+
children: /* @__PURE__ */ jsx(View, { children })
|
|
166
|
+
})]
|
|
157
167
|
});
|
|
158
168
|
}
|
|
159
|
-
/** Inside a group these two are the quiet outcome: the group's header has already said it. */
|
|
160
|
-
const SILENT_IN_GROUP = /* @__PURE__ */ new Set(["ok", "neutral"]);
|
|
161
169
|
/**
|
|
162
|
-
* The title row: label, summary, the tone's
|
|
170
|
+
* The title row: label, summary, the tone's outcome and, when the item is
|
|
163
171
|
* expandable, a chevron; the whole row is the toggle. A row inside a group
|
|
164
|
-
*
|
|
172
|
+
* keeps its name but drops the chip and caption the group header carries.
|
|
165
173
|
*/
|
|
166
174
|
function MessageItemHeader({ title, badge, children, style, ...props }) {
|
|
167
175
|
const { tone, expandable, expanded, toggle } = useMessageItem();
|
|
168
176
|
const group = useContext(MessageItemGroupContext);
|
|
169
|
-
const
|
|
170
|
-
const label = badge === void 0 ? defaultLabel : badge;
|
|
177
|
+
const label = badge === void 0 ? STATUS_LABEL[tone] : badge;
|
|
171
178
|
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
172
179
|
group === null ? /* @__PURE__ */ jsx(ToolCallLead, {
|
|
173
180
|
title,
|
|
174
181
|
children
|
|
175
|
-
}) : /* @__PURE__ */ jsx(
|
|
176
|
-
|
|
182
|
+
}) : /* @__PURE__ */ jsx(RowLead, {
|
|
183
|
+
title,
|
|
184
|
+
children
|
|
185
|
+
}),
|
|
186
|
+
label !== null && label !== "" ? /* @__PURE__ */ jsx(Outcome, {
|
|
177
187
|
tone,
|
|
178
188
|
children: label
|
|
179
189
|
}) : null,
|
|
@@ -315,18 +325,17 @@ const styles = StyleSheet.create((theme) => ({
|
|
|
315
325
|
lineHeight: theme.lineHeight.base,
|
|
316
326
|
uni__dependencies: [0]
|
|
317
327
|
},
|
|
318
|
-
faint: {
|
|
319
|
-
flexShrink: 1,
|
|
320
|
-
color: theme.colors.faint,
|
|
321
|
-
fontFamily: fontOf(theme.fontFamily.sans),
|
|
322
|
-
fontSize: theme.fontSize.base,
|
|
323
|
-
lineHeight: theme.lineHeight.base,
|
|
324
|
-
uni__dependencies: [0]
|
|
325
|
-
},
|
|
326
328
|
outcome: {
|
|
327
329
|
gap: theme.spacing(1),
|
|
328
330
|
uni__dependencies: [0]
|
|
329
331
|
},
|
|
332
|
+
outcomeIcon: {
|
|
333
|
+
alignItems: "center",
|
|
334
|
+
justifyContent: "center",
|
|
335
|
+
width: 20,
|
|
336
|
+
height: 20,
|
|
337
|
+
flexShrink: 0
|
|
338
|
+
},
|
|
330
339
|
body: {
|
|
331
340
|
gap: theme.spacing(1),
|
|
332
341
|
borderTopWidth: 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageItem.mjs","names":["NativeColorToken","createContext","ReactNode","useContext","StyleProp","TextProps","ViewProps","ViewStyle","StyleSheet","AlertIcon","CheckIcon","ChevronDownIcon","ChevronRightIcon","WrenchIcon","fontOf","STATUS_COLORS","useControllable","wrapText","Button","Spinner","STATUS_EDGE","StatusBadge","StatusTone","MIN_ROW_HEIGHT","LEAD_CHIP","ROW_EDGE_WIDTH","MessageItemState","tone","expandable","expanded","toggle","MessageItemContext","undefined","useMessageItem","MessageItemGroupContext","toolTone","state","running","isError","STATUS_LABEL","Readonly","Record","neutral","ok","error","info","accent","STATUS_GLYPH","cardEdge","rowEdge","MessageItemProps","Omit","defaultExpanded","onExpandedChange","children","style","MessageItem","props","current","setExpanded","group","styles","Summary","summary","summaryText","ToolCallLead","title","chip","lead","caption","titleLine","OutcomeBadge","ink","outcome","MessageItemGroupProps","badge","MessageItemGroup","label","header","faint","MessageItemHeaderProps","SILENT_IN_GROUP","ReadonlySet","Set","MessageItemHeader","defaultLabel","has","content","pressed","headerPressed","MessageItemPartProps","MessageItemBody","body","bodyText","MessageItemStatusProps","glyph","expands","containerStyle","MessageItemStatus","line","status","more","create","theme","token","overflow","borderRadius","lg","borderWidth","borderColor","colors","uni__dependencies","borderTopWidth","borderTopColor","borderLeftWidth","borderLeftColor","flexDirection","alignItems","gap","spacing","minHeight","paddingHorizontal","paddingVertical","backgroundColor","panel","justifyContent","width","height","flexShrink","full","rail","flex","minWidth","color","dim","fontFamily","sans","fontSize","sm","lineHeight","hi","base","fontWeight","semibold","alignSelf"],"sources":["../../src/components/MessageItem.tsx"],"sourcesContent":["import type { NativeColorToken } from '@agimon-ai/po-web-components/nativeTheme';\nimport { createContext, type ReactNode, useContext } from 'react';\nimport { Pressable, type StyleProp, Text, type TextProps, View, type ViewProps, type ViewStyle } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { AlertIcon, CheckIcon, ChevronDownIcon, ChevronRightIcon, WrenchIcon } from '../icons/icons';\nimport { fontOf } from '../lib/fonts';\nimport { STATUS_COLORS } from '../lib/tone';\nimport { useControllable } from '../lib/useControllable';\nimport { wrapText } from '../lib/wrapText';\nimport { Button } from './Button';\nimport { Spinner } from './Spinner';\nimport { STATUS_EDGE, StatusBadge, type StatusTone } from './StatusBadge';\n\n/*\n * The message item: the timeline card a tool call, a run or a notice sits in.\n * The item owns its outcome tone and its expand state; the header, body and\n * status parts read both from it, so a card composes the parts and never\n * threads `expanded` by hand. The header is one Pressable that expands the\n * item, the native stand-in for the web's small chevron button.\n */\n\nconst MIN_ROW_HEIGHT = 44;\nconst LEAD_CHIP = 36;\nconst ROW_EDGE_WIDTH = 2;\n\nexport interface MessageItemState {\n tone: StatusTone;\n /** Whether the header offers the toggle; an item that hides nothing offers none. */\n expandable: boolean;\n expanded: boolean;\n toggle: () => void;\n}\n\nconst MessageItemContext = createContext<MessageItemState>({\n tone: 'neutral',\n expandable: false,\n expanded: false,\n toggle: () => undefined,\n});\n\n/** The enclosing item's state, for a part that lives deeper than the item's render prop. */\nexport function useMessageItem(): MessageItemState {\n return useContext(MessageItemContext);\n}\n\n/** The group an item is a row of, or null for an item that is a card of its own. */\nconst MessageItemGroupContext = createContext<{ tone: StatusTone } | null>(null);\n\n/** The tone a tool call's item wears: running while the tool runs, then its outcome. */\nexport function toolTone(state: { running: boolean; isError: boolean }): StatusTone {\n return state.running ? 'running' : state.isError ? 'error' : 'ok';\n}\n\n/** The badge text a tone reads as when the header is not told otherwise; empty hides the badge. */\nexport const STATUS_LABEL: Readonly<Record<StatusTone, string>> = {\n neutral: '',\n running: 'Running',\n ok: 'Completed',\n error: 'Failed',\n info: 'Info',\n accent: 'Note',\n};\n\n/** The glyph a tone reads as in a status line. */\nexport const STATUS_GLYPH: Readonly<Record<StatusTone, string>> = {\n neutral: '\\u2026',\n running: '\\u25d0',\n ok: '\\u2713',\n error: '\\u2717',\n info: '\\u25cf',\n accent: '\\u25cf',\n};\n\n/** A settled OK is the calm default and keeps the soft border; only work in flight or a failure colours the edge. */\nfunction cardEdge(tone: StatusTone): NativeColorToken {\n return tone === 'ok' ? 'border-soft' : STATUS_EDGE[tone];\n}\n\n/** As a row, a settled or neutral item keeps a quiet edge. */\nfunction rowEdge(tone: StatusTone): NativeColorToken | undefined {\n return tone === 'ok' || tone === 'neutral' ? undefined : STATUS_EDGE[tone];\n}\n\nexport interface MessageItemProps extends Omit<ViewProps, 'children' | 'style'> {\n tone?: StatusTone;\n /** Whether the header offers the expand toggle. A toggle that reveals nothing reads as broken, so the card decides. */\n expandable?: boolean;\n defaultExpanded?: boolean;\n /** Controlled mode; pair with onExpandedChange. Omit it and the item keeps its own state. */\n expanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n /** Plain content, or a function of the item's state for a card that picks its lines by `expanded`. */\n children?: ReactNode | ((state: MessageItemState) => ReactNode);\n style?: StyleProp<ViewStyle>;\n}\n\nexport function MessageItem({\n tone = 'neutral',\n expandable = false,\n defaultExpanded = false,\n expanded,\n onExpandedChange,\n children,\n style,\n ...props\n}: MessageItemProps) {\n const [current, setExpanded] = useControllable(expanded, defaultExpanded, onExpandedChange);\n const group = useContext(MessageItemGroupContext);\n const state: MessageItemState = { tone, expandable, expanded: current, toggle: () => setExpanded(!current) };\n return (\n <MessageItemContext.Provider value={state}>\n <View\n style={[group === null ? styles.cardEdge(cardEdge(tone)) : styles.rowEdge(rowEdge(tone)), style]}\n {...props}\n >\n {typeof children === 'function' ? children(state) : children}\n </View>\n </MessageItemContext.Provider>\n );\n}\n\n/** The line beside the title; a bare string stays on one line and truncates, as the web's `truncate`. */\nfunction Summary({ children }: { children?: ReactNode }) {\n return (\n <View style={styles.summary}>\n {typeof children === 'string' ? (\n <Text numberOfLines={1} style={styles.summaryText}>\n {children}\n </Text>\n ) : (\n wrapText(children, styles.summaryText)\n )}\n </View>\n );\n}\n\n/** The card's lead: the tool chip, the \"Tool call\" caption, then the name and its summary on one line. */\nfunction ToolCallLead({ title, children }: { title: ReactNode; children?: ReactNode }) {\n return (\n <>\n <View accessible={false} style={styles.chip}>\n <WrenchIcon size={16} />\n </View>\n <View style={styles.lead}>\n <Text style={styles.caption}>Tool call</Text>\n <View style={styles.titleLine}>\n {wrapText(title, styles.title)}\n <Summary>{children}</Summary>\n </View>\n </View>\n </>\n );\n}\n\n/** The sentence-case outcome pill, led by the tone's icon. */\nfunction OutcomeBadge({ tone, children }: { tone: StatusTone; children: ReactNode }) {\n const ink = STATUS_COLORS[tone].ink;\n return (\n <StatusBadge tone={tone} size=\"md\" style={styles.outcome}>\n {tone === 'running' ? <Spinner color={ink} /> : null}\n {tone === 'ok' ? <CheckIcon size={12} color={ink} /> : null}\n {tone === 'error' ? <AlertIcon size={12} color={ink} /> : null}\n {children}\n </StatusBadge>\n );\n}\n\nexport interface MessageItemGroupProps extends Omit<ViewProps, 'children' | 'style'> {\n tone?: StatusTone;\n /** The bold label at the left of the group header: the tool the run belongs to. */\n title: ReactNode;\n /** The line beside it, such as how many calls the group holds. */\n summary?: ReactNode;\n /** The badge text; defaults to the tone's label, null hides the badge. */\n badge?: ReactNode | null;\n children?: ReactNode;\n style?: StyleProp<ViewStyle>;\n}\n\n/**\n * One frame around a run of items that belong together. Each item inside\n * becomes a row: same header, same expand, no card of its own, and its tone\n * an edge down its left side.\n */\nexport function MessageItemGroup({\n tone = 'neutral',\n title,\n summary,\n badge,\n children,\n style,\n ...props\n}: MessageItemGroupProps) {\n const label = badge === undefined ? STATUS_LABEL[tone] : badge;\n return (\n <MessageItemGroupContext.Provider value={{ tone }}>\n <View style={[styles.cardEdge(cardEdge(tone)), style]} {...props}>\n <View accessibilityRole=\"header\" style={styles.header}>\n <ToolCallLead title={title}>\n {typeof summary === 'string' ? (\n <Text numberOfLines={1} style={styles.faint}>\n {summary}\n </Text>\n ) : (\n summary\n )}\n </ToolCallLead>\n {label !== null && label !== '' ? <OutcomeBadge tone={tone}>{label}</OutcomeBadge> : null}\n </View>\n <View>{children}</View>\n </View>\n </MessageItemGroupContext.Provider>\n );\n}\n\nexport interface MessageItemHeaderProps extends Omit<ViewProps, 'children' | 'style'> {\n /** The bold label at the left: the tool name. */\n title: ReactNode;\n /** The badge text; defaults to the tone's label, null hides the badge. */\n badge?: ReactNode | null;\n /** The summary beside the title; it gets the remaining width. */\n children?: ReactNode;\n style?: StyleProp<ViewStyle>;\n}\n\n/** Inside a group these two are the quiet outcome: the group's header has already said it. */\nconst SILENT_IN_GROUP: ReadonlySet<StatusTone> = new Set<StatusTone>(['ok', 'neutral']);\n\n/**\n * The title row: label, summary, the tone's badge and, when the item is\n * expandable, a chevron; the whole row is the toggle. A row inside a group\n * drops its title and speaks up only when something failed or is running.\n */\nexport function MessageItemHeader({ title, badge, children, style, ...props }: MessageItemHeaderProps) {\n const { tone, expandable, expanded, toggle } = useMessageItem();\n const group = useContext(MessageItemGroupContext);\n const defaultLabel = group !== null && SILENT_IN_GROUP.has(tone) ? null : STATUS_LABEL[tone];\n const label = badge === undefined ? defaultLabel : badge;\n const content = (\n <>\n {group === null ? <ToolCallLead title={title}>{children}</ToolCallLead> : <Summary>{children}</Summary>}\n {label !== null && label !== '' ? <OutcomeBadge tone={tone}>{label}</OutcomeBadge> : null}\n {expandable ? expanded ? <ChevronDownIcon size={16} /> : <ChevronRightIcon size={16} /> : null}\n </>\n );\n if (!expandable) {\n return (\n <View style={[styles.header, style]} {...props}>\n {content}\n </View>\n );\n }\n return (\n <Pressable\n accessibilityRole=\"button\"\n accessibilityState={{ expanded }}\n accessibilityHint={expanded ? 'collapse' : 'expand'}\n onPress={toggle}\n style={({ pressed }) => [styles.header, pressed && styles.headerPressed, style]}\n {...props}\n >\n {content}\n </Pressable>\n );\n}\n\nexport interface MessageItemPartProps extends Omit<ViewProps, 'children' | 'style'> {\n children?: ReactNode;\n style?: StyleProp<ViewStyle>;\n}\n\n/** The body under the header, on the card's own surface. */\nexport function MessageItemBody({ children, style, ...props }: MessageItemPartProps) {\n return (\n <View style={[styles.body, style]} {...props}>\n {wrapText(children, styles.bodyText)}\n </View>\n );\n}\n\nexport interface MessageItemStatusProps extends Omit<TextProps, 'children'> {\n tone?: StatusTone;\n /** Replaces the tone's glyph. */\n glyph?: string;\n /** Renders as a button that expands the item: the \"N more line(s)\" hint. */\n expands?: boolean;\n children?: ReactNode;\n /** Applied to the row; with `expands`, to the button. */\n containerStyle?: StyleProp<ViewStyle>;\n}\n\n/** The one-line status under a body: `running`, `failed`, `done`, or the hint that more is hidden. */\nexport function MessageItemStatus({\n tone = 'neutral',\n glyph,\n expands = false,\n children,\n containerStyle,\n style,\n ...props\n}: MessageItemStatusProps) {\n const { toggle } = useMessageItem();\n const line = (\n <Text style={[styles.status, style]} {...props}>\n <Text style={styles.glyph(tone)}>{glyph ?? STATUS_GLYPH[tone]}</Text> {children}\n </Text>\n );\n if (expands) {\n return (\n <Button variant=\"ghost\" size=\"xs\" onPress={toggle} style={[styles.more, containerStyle]}>\n {line}\n </Button>\n );\n }\n return <View style={containerStyle}>{line}</View>;\n}\n\nconst styles = StyleSheet.create((theme) => ({\n cardEdge: (token: NativeColorToken) => ({\n overflow: 'hidden',\n borderRadius: theme.borderRadius.lg,\n borderWidth: 1,\n borderColor: theme.colors[token],\n }),\n // A row's top rule is the group's separator; its left edge carries the tone.\n rowEdge: (token: NativeColorToken | undefined) => ({\n overflow: 'hidden',\n borderTopWidth: 1,\n borderTopColor: theme.colors['border-soft'],\n borderLeftWidth: ROW_EDGE_WIDTH,\n borderLeftColor: token === undefined ? 'transparent' : theme.colors[token],\n }),\n header: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: theme.spacing(3),\n minHeight: MIN_ROW_HEIGHT,\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(3),\n },\n headerPressed: { backgroundColor: theme.colors.panel },\n chip: {\n alignItems: 'center',\n justifyContent: 'center',\n width: LEAD_CHIP,\n height: LEAD_CHIP,\n flexShrink: 0,\n borderRadius: theme.borderRadius.full,\n backgroundColor: theme.colors.rail,\n },\n lead: { flex: 1, minWidth: 0 },\n caption: {\n color: theme.colors.dim,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n titleLine: { flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2), minWidth: 0 },\n title: {\n flexShrink: 0,\n color: theme.colors.hi,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n fontWeight: theme.fontWeight.semibold,\n },\n summary: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2), minWidth: 0 },\n summaryText: {\n flexShrink: 1,\n color: theme.colors.faint,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n faint: {\n flexShrink: 1,\n color: theme.colors.faint,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n outcome: { gap: theme.spacing(1) },\n body: {\n gap: theme.spacing(1),\n borderTopWidth: 1,\n borderTopColor: theme.colors['border-soft'],\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(3),\n },\n bodyText: {\n color: theme.colors.dim,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n status: {\n color: theme.colors.faint,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n glyph: (tone: StatusTone) => ({ color: theme.colors[STATUS_COLORS[tone].ink] }),\n more: { alignSelf: 'flex-start' },\n}));\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,MAAMuB,iBAAiB;AACvB,MAAMC,YAAY;AAClB,MAAMC,iBAAiB;AAUvB,MAAMM,qBAAqB9B,cAAgC;CACzD0B,MAAM;CACNC,YAAY;CACZC,UAAU;CACVC,cAAcE;AAChB,CAAC;;AAGD,SAAgBC,iBAAmC;CACjD,OAAO9B,WAAW4B,kBAAkB;AACtC;;AAGA,MAAMG,0BAA0BjC,cAA2C,IAAI;;AAG/E,SAAgBkC,SAASC,OAA2D;CAClF,OAAOA,MAAMC,UAAU,YAAYD,MAAME,UAAU,UAAU;AAC/D;;AAGA,MAAaC,eAAqD;CAChEG,SAAS;CACTL,SAAS;CACTM,IAAI;CACJC,OAAO;CACPC,MAAM;CACNC,QAAQ;AACV;;AAGA,MAAaC,eAAqD;CAChEL,SAAS;CACTL,SAAS;CACTM,IAAI;CACJC,OAAO;CACPC,MAAM;CACNC,QAAQ;AACV;;AAGA,SAASE,SAASrB,MAAoC;CACpD,OAAOA,SAAS,OAAO,gBAAgBP,YAAYO;AACrD;;AAGA,SAASsB,QAAQtB,MAAgD;CAC/D,OAAOA,SAAS,QAAQA,SAAS,YAAYK,SAAYZ,YAAYO;AACvE;AAeA,SAAgB6B,YAAY,EAC1B7B,OAAO,WACPC,aAAa,OACbwB,kBAAkB,OAClBvB,UACAwB,kBACAC,UAC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AAWC,IAAI;EACxCC,UAAUlC,MAAMkC,SAASI;EACzBF,YAAYpC,MAAMoC,WAAWE;EAAI9B,mBAAA,CAAA,CAAA;CACnC;CACAX,QAAQ;EACNiC,OAAO9B,MAAMO,OAAO/B;EACpBwD,YAAYzH,OAAOyF,MAAMgC,WAAWC,IAAI;EACxCC,UAAUlC,MAAMkC,SAASC;EACzBC,YAAYpC,MAAMoC,WAAWD;EAAE3B,mBAAA,CAAA,CAAA;CACjC;CACAhB,QAAQpE,UAAsB;EAAE0G,OAAO9B,MAAMO,OAAO/F,cAAcY,KAAK,CAAC6C;EAAIuC,mBAAA,CAAA,CAAA;CAAC;CAC7EV,MAAM,EAAE2C,WAAW,aAAa;AAClC,EAAE"}
|
|
1
|
+
{"version":3,"file":"MessageItem.mjs","names":["MessageItemContext","MessageItemGroupContext","MessageItemState","NativeColorToken","ReactNode","useContext","useMemo","StyleProp","TextProps","ViewProps","ViewStyle","StyleSheet","AlertIcon","CheckIcon","ChevronDownIcon","ChevronRightIcon","WrenchIcon","fontOf","STATUS_COLORS","useControllable","wrapText","Button","Spinner","STATUS_EDGE","StatusBadge","StatusTone","ICON_TONES","ReadonlySet","Set","MIN_ROW_HEIGHT","LEAD_CHIP","ROW_EDGE_WIDTH","useMessageItem","toolTone","state","running","isError","STATUS_LABEL","Readonly","Record","neutral","ok","error","info","accent","STATUS_GLYPH","cardEdge","tone","rowEdge","undefined","MessageItemProps","Omit","expandable","defaultExpanded","expanded","onExpandedChange","children","style","MessageItem","props","current","setExpanded","group","toggle","styles","Summary","summary","summaryText","ToolCallLead","title","caption","chip","lead","titleLine","RowLead","Outcome","ink","has","outcomeIcon","outcome","MessageItemGroupProps","badge","MessageItemGroup","label","header","MessageItemHeaderProps","MessageItemHeader","content","pressed","headerPressed","MessageItemPartProps","MessageItemBody","body","bodyText","MessageItemStatusProps","glyph","expands","containerStyle","MessageItemStatus","line","status","more","create","theme","token","overflow","borderRadius","lg","borderWidth","borderColor","colors","uni__dependencies","borderTopWidth","borderTopColor","borderLeftWidth","borderLeftColor","flexDirection","alignItems","gap","spacing","minHeight","paddingHorizontal","paddingVertical","backgroundColor","panel","justifyContent","width","height","flexShrink","full","rail","flex","minWidth","color","dim","fontFamily","sans","fontSize","sm","lineHeight","hi","base","fontWeight","semibold","faint","alignSelf"],"sources":["../../src/components/MessageItem.tsx"],"sourcesContent":["import {\n MessageItemContext,\n MessageItemGroupContext,\n type MessageItemState,\n} from '@agimon-ai/po-native-components/shell';\nimport type { NativeColorToken } from '@agimon-ai/po-web-components/nativeTheme';\nimport { type ReactNode, useContext, useMemo } from 'react';\nimport { Pressable, type StyleProp, Text, type TextProps, View, type ViewProps, type ViewStyle } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { AlertIcon, CheckIcon, ChevronDownIcon, ChevronRightIcon, WrenchIcon } from '../icons/icons';\nimport { fontOf } from '../lib/fonts';\nimport { STATUS_COLORS } from '../lib/tone';\nimport { useControllable } from '../lib/useControllable';\nimport { wrapText } from '../lib/wrapText';\nimport { Button } from './Button';\nimport { Spinner } from './Spinner';\nimport { STATUS_EDGE, StatusBadge, type StatusTone } from './StatusBadge';\n\n/** Tones whose outcome reads as an icon alone; the rest keep their worded badge. */\nconst ICON_TONES: ReadonlySet<StatusTone> = new Set<StatusTone>(['running', 'ok', 'error']);\n\n/*\n * The message item: the timeline card a tool call, a run or a notice sits in.\n * The item owns its outcome tone and its expand state; the header, body and\n * status parts read both from it, so a card composes the parts and never\n * threads `expanded` by hand. The header is one Pressable that expands the\n * item, the native stand-in for the web's small chevron button.\n */\n\nconst MIN_ROW_HEIGHT = 44;\nconst LEAD_CHIP = 36;\nconst ROW_EDGE_WIDTH = 2;\n\nexport type { MessageItemState } from '@agimon-ai/po-native-components/shell';\n\n/** The enclosing item's state, for a part that lives deeper than the item's render prop. */\nexport function useMessageItem(): MessageItemState {\n return useContext(MessageItemContext);\n}\n\n/** The tone a tool call's item wears: running while the tool runs, then its outcome. */\nexport function toolTone(state: { running: boolean; isError: boolean }): StatusTone {\n return state.running ? 'running' : state.isError ? 'error' : 'ok';\n}\n\n/** The badge text a tone reads as when the header is not told otherwise; empty hides the badge. */\nexport const STATUS_LABEL: Readonly<Record<StatusTone, string>> = {\n neutral: '',\n running: 'Running',\n ok: 'Completed',\n error: 'Failed',\n info: 'Info',\n accent: 'Note',\n};\n\n/** The glyph a tone reads as in a status line. */\nexport const STATUS_GLYPH: Readonly<Record<StatusTone, string>> = {\n neutral: '\\u2026',\n running: '\\u25d0',\n ok: '\\u2713',\n error: '\\u2717',\n info: '\\u25cf',\n accent: '\\u25cf',\n};\n\n/** A settled OK is the calm default and keeps the soft border; only work in flight or a failure colours the edge. */\nfunction cardEdge(tone: StatusTone): NativeColorToken {\n return tone === 'ok' ? 'border-soft' : STATUS_EDGE[tone];\n}\n\n/** As a row, a settled or neutral item keeps a quiet edge. */\nfunction rowEdge(tone: StatusTone): NativeColorToken | undefined {\n return tone === 'ok' || tone === 'neutral' ? undefined : STATUS_EDGE[tone];\n}\n\nexport interface MessageItemProps extends Omit<ViewProps, 'children' | 'style'> {\n tone?: StatusTone;\n /** Whether the header offers the expand toggle. A toggle that reveals nothing reads as broken, so the card decides. */\n expandable?: boolean;\n defaultExpanded?: boolean;\n /** Controlled mode; pair with onExpandedChange. Omit it and the item keeps its own state. */\n expanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n /** Plain content, or a function of the item's state for a card that picks its lines by `expanded`. */\n children?: ReactNode | ((state: MessageItemState) => ReactNode);\n style?: StyleProp<ViewStyle>;\n}\n\nexport function MessageItem({\n tone = 'neutral',\n expandable = false,\n defaultExpanded = false,\n expanded,\n onExpandedChange,\n children,\n style,\n ...props\n}: MessageItemProps) {\n const [current, setExpanded] = useControllable(expanded, defaultExpanded, onExpandedChange);\n const group = useContext(MessageItemGroupContext);\n const state: MessageItemState = { tone, expandable, expanded: current, toggle: () => setExpanded(!current) };\n return (\n <MessageItemContext.Provider value={state}>\n <View\n style={[group === null ? styles.cardEdge(cardEdge(tone)) : styles.rowEdge(rowEdge(tone)), style]}\n {...props}\n >\n {typeof children === 'function' ? children(state) : children}\n </View>\n </MessageItemContext.Provider>\n );\n}\n\n/** The line beside the title; a bare string stays on one line and truncates, as the web's `truncate`. */\nfunction Summary({ children }: { children?: ReactNode }) {\n return (\n <View style={styles.summary}>\n {typeof children === 'string' ? (\n <Text numberOfLines={1} style={styles.summaryText}>\n {children}\n </Text>\n ) : (\n wrapText(children, styles.summaryText)\n )}\n </View>\n );\n}\n\n/** The card's lead: the tool chip, the \"Tool call\" caption, then the name and its summary on one line. */\nfunction ToolCallLead({\n title,\n caption = 'Tool call',\n children,\n}: {\n title: ReactNode;\n caption?: string | null;\n children?: ReactNode;\n}) {\n return (\n <>\n <View accessible={false} style={styles.chip}>\n <WrenchIcon size={16} />\n </View>\n <View style={styles.lead}>\n {caption === null ? null : <Text style={styles.caption}>{caption}</Text>}\n <View style={styles.titleLine}>\n {wrapText(title, styles.title)}\n <Summary>{children}</Summary>\n </View>\n </View>\n </>\n );\n}\n\n/** A row's lead inside a group: the name and its summary, no chip or caption, since the group header carries them. */\nfunction RowLead({ title, children }: { title: ReactNode; children?: ReactNode }) {\n return (\n <View style={[styles.lead, styles.titleLine]}>\n {wrapText(title, styles.title)}\n <Summary>{children}</Summary>\n </View>\n );\n}\n\n/** The outcome: an icon for running, done and failed, announced by its label; a worded badge for other tones. */\nfunction Outcome({ tone, children }: { tone: StatusTone; children: ReactNode }) {\n const ink = STATUS_COLORS[tone].ink;\n if (ICON_TONES.has(tone)) {\n return (\n <View\n accessible\n accessibilityRole=\"image\"\n accessibilityLabel={typeof children === 'string' ? children : STATUS_LABEL[tone]}\n style={styles.outcomeIcon}\n >\n {tone === 'running' ? <Spinner color={ink} /> : null}\n {tone === 'ok' ? <CheckIcon size={14} color={ink} /> : null}\n {tone === 'error' ? <AlertIcon size={14} color={ink} /> : null}\n </View>\n );\n }\n return (\n <StatusBadge tone={tone} size=\"md\" style={styles.outcome}>\n {children}\n </StatusBadge>\n );\n}\n\nexport interface MessageItemGroupProps extends Omit<ViewProps, 'children' | 'style'> {\n tone?: StatusTone;\n /** The bold label at the left of the group header, such as \"7 tool calls\". */\n title: ReactNode;\n /** The line beside it, such as which tools the group holds. */\n summary?: ReactNode;\n /** The outcome's label; defaults to the tone's label, null hides the outcome. */\n badge?: ReactNode | null;\n children?: ReactNode;\n style?: StyleProp<ViewStyle>;\n}\n\n/**\n * One frame around a run of items that belong together. It stays open: each\n * item inside becomes a row with its own name, outcome and expand, no card of\n * its own, and its tone an edge down its left side.\n */\nexport function MessageItemGroup({\n tone = 'neutral',\n title,\n summary,\n badge,\n children,\n style,\n ...props\n}: MessageItemGroupProps) {\n const label = badge === undefined ? STATUS_LABEL[tone] : badge;\n // A stable value, so a group re-render does not re-render every memoised row's item.\n const group = useMemo(() => ({ tone }), [tone]);\n return (\n <MessageItem tone={tone} style={style} {...props}>\n <View style={styles.header}>\n <ToolCallLead title={title} caption={null}>\n {summary}\n </ToolCallLead>\n {label !== null && label !== '' ? <Outcome tone={tone}>{label}</Outcome> : null}\n </View>\n <MessageItemGroupContext.Provider value={group}>\n <View>{children}</View>\n </MessageItemGroupContext.Provider>\n </MessageItem>\n );\n}\n\nexport interface MessageItemHeaderProps extends Omit<ViewProps, 'children' | 'style'> {\n /** The bold label at the left: the tool name. */\n title: ReactNode;\n /** The badge text; defaults to the tone's label, null hides the badge. */\n badge?: ReactNode | null;\n /** The summary beside the title; it gets the remaining width. */\n children?: ReactNode;\n style?: StyleProp<ViewStyle>;\n}\n\n/**\n * The title row: label, summary, the tone's outcome and, when the item is\n * expandable, a chevron; the whole row is the toggle. A row inside a group\n * keeps its name but drops the chip and caption the group header carries.\n */\nexport function MessageItemHeader({ title, badge, children, style, ...props }: MessageItemHeaderProps) {\n const { tone, expandable, expanded, toggle } = useMessageItem();\n const group = useContext(MessageItemGroupContext);\n const label = badge === undefined ? STATUS_LABEL[tone] : badge;\n const content = (\n <>\n {group === null ? (\n <ToolCallLead title={title}>{children}</ToolCallLead>\n ) : (\n <RowLead title={title}>{children}</RowLead>\n )}\n {label !== null && label !== '' ? <Outcome tone={tone}>{label}</Outcome> : null}\n {expandable ? expanded ? <ChevronDownIcon size={16} /> : <ChevronRightIcon size={16} /> : null}\n </>\n );\n if (!expandable) {\n return (\n <View style={[styles.header, style]} {...props}>\n {content}\n </View>\n );\n }\n return (\n <Pressable\n accessibilityRole=\"button\"\n accessibilityState={{ expanded }}\n accessibilityHint={expanded ? 'collapse' : 'expand'}\n onPress={toggle}\n style={({ pressed }) => [styles.header, pressed && styles.headerPressed, style]}\n {...props}\n >\n {content}\n </Pressable>\n );\n}\n\nexport interface MessageItemPartProps extends Omit<ViewProps, 'children' | 'style'> {\n children?: ReactNode;\n style?: StyleProp<ViewStyle>;\n}\n\n/** The body under the header, on the card's own surface. */\nexport function MessageItemBody({ children, style, ...props }: MessageItemPartProps) {\n return (\n <View style={[styles.body, style]} {...props}>\n {wrapText(children, styles.bodyText)}\n </View>\n );\n}\n\nexport interface MessageItemStatusProps extends Omit<TextProps, 'children'> {\n tone?: StatusTone;\n /** Replaces the tone's glyph. */\n glyph?: string;\n /** Renders as a button that expands the item: the \"N more line(s)\" hint. */\n expands?: boolean;\n children?: ReactNode;\n /** Applied to the row; with `expands`, to the button. */\n containerStyle?: StyleProp<ViewStyle>;\n}\n\n/** The one-line status under a body: `running`, `failed`, `done`, or the hint that more is hidden. */\nexport function MessageItemStatus({\n tone = 'neutral',\n glyph,\n expands = false,\n children,\n containerStyle,\n style,\n ...props\n}: MessageItemStatusProps) {\n const { toggle } = useMessageItem();\n const line = (\n <Text style={[styles.status, style]} {...props}>\n <Text style={styles.glyph(tone)}>{glyph ?? STATUS_GLYPH[tone]}</Text> {children}\n </Text>\n );\n if (expands) {\n return (\n <Button variant=\"ghost\" size=\"xs\" onPress={toggle} style={[styles.more, containerStyle]}>\n {line}\n </Button>\n );\n }\n return <View style={containerStyle}>{line}</View>;\n}\n\nconst styles = StyleSheet.create((theme) => ({\n cardEdge: (token: NativeColorToken) => ({\n overflow: 'hidden',\n borderRadius: theme.borderRadius.lg,\n borderWidth: 1,\n borderColor: theme.colors[token],\n }),\n // A row's top rule is the group's separator; its left edge carries the tone.\n rowEdge: (token: NativeColorToken | undefined) => ({\n overflow: 'hidden',\n borderTopWidth: 1,\n borderTopColor: theme.colors['border-soft'],\n borderLeftWidth: ROW_EDGE_WIDTH,\n borderLeftColor: token === undefined ? 'transparent' : theme.colors[token],\n }),\n header: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: theme.spacing(3),\n minHeight: MIN_ROW_HEIGHT,\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(3),\n },\n headerPressed: { backgroundColor: theme.colors.panel },\n chip: {\n alignItems: 'center',\n justifyContent: 'center',\n width: LEAD_CHIP,\n height: LEAD_CHIP,\n flexShrink: 0,\n borderRadius: theme.borderRadius.full,\n backgroundColor: theme.colors.rail,\n },\n lead: { flex: 1, minWidth: 0 },\n caption: {\n color: theme.colors.dim,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n titleLine: { flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2), minWidth: 0 },\n title: {\n flexShrink: 0,\n color: theme.colors.hi,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n fontWeight: theme.fontWeight.semibold,\n },\n summary: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2), minWidth: 0 },\n summaryText: {\n flexShrink: 1,\n color: theme.colors.faint,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n outcome: { gap: theme.spacing(1) },\n outcomeIcon: { alignItems: 'center', justifyContent: 'center', width: 20, height: 20, flexShrink: 0 },\n body: {\n gap: theme.spacing(1),\n borderTopWidth: 1,\n borderTopColor: theme.colors['border-soft'],\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(3),\n },\n bodyText: {\n color: theme.colors.dim,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n status: {\n color: theme.colors.faint,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n glyph: (tone: StatusTone) => ({ color: theme.colors[STATUS_COLORS[tone].ink] }),\n more: { alignSelf: 'flex-start' },\n}));\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoBA,MAAM0B,6BAAsC,IAAIE,IAAgB;CAAC;CAAW;CAAM;AAAO,CAAC;AAU1F,MAAMC,iBAAiB;AACvB,MAAMC,YAAY;AAClB,MAAMC,iBAAiB;;AAKvB,SAAgBC,iBAAmC;CACjD,OAAO3B,WAAWL,kBAAkB;AACtC;;AAGA,SAAgBiC,SAASC,OAA2D;CAClF,OAAOA,MAAMC,UAAU,YAAYD,MAAME,UAAU,UAAU;AAC/D;;AAGA,MAAaC,eAAqD;CAChEG,SAAS;CACTL,SAAS;CACTM,IAAI;CACJC,OAAO;CACPC,MAAM;CACNC,QAAQ;AACV;;AAGA,MAAaC,eAAqD;CAChEL,SAAS;CACTL,SAAS;CACTM,IAAI;CACJC,OAAO;CACPC,MAAM;CACNC,QAAQ;AACV;;AAGA,SAASE,SAASC,MAAoC;CACpD,OAAOA,SAAS,OAAO,gBAAgBxB,YAAYwB;AACrD;;AAGA,SAASC,QAAQD,MAAgD;CAC/D,OAAOA,SAAS,QAAQA,SAAS,YAAYE,SAAY1B,YAAYwB;AACvE;AAeA,SAAgBW,YAAY,EAC1BX,OAAO,WACPK,aAAa,OACbC,kBAAkB,OAClBC,UACAC,kBACAC,UACAC,OACA,GAAGE,SACgB;CACnB,MAAM,CAACC,SAASC,eAAe1C,gBAAgBmC,UAAUD,iBAAiBE,gBAAgB;CAC1F,MAAMO,QAAQz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EACzBF,YAAYpC,MAAMoC,WAAWE;EAAI9B,mBAAA,CAAA,CAAA;CACnC;CACAX,QAAQ;EACNiC,OAAO9B,MAAMO,OAAOkC;EACpBT,YAAYtH,OAAOsF,MAAMgC,WAAWC,IAAI;EACxCC,UAAUlC,MAAMkC,SAASC;EACzBC,YAAYpC,MAAMoC,WAAWD;EAAE3B,mBAAA,CAAA,CAAA;CACjC;CACAhB,QAAQhD,UAAsB;EAAEsF,OAAO9B,MAAMO,OAAO5F,cAAc6B,KAAK,CAAC6B;EAAImC,mBAAA,CAAA,CAAA;CAAC;CAC7EV,MAAM,EAAE4C,WAAW,aAAa;AAClC,EAAE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { StatusTone } from "./StatusBadge.mjs";
|
|
2
|
+
//#region src/components/NativeShellState.d.ts
|
|
3
|
+
/** State shared by shell-rendered timeline frames and downloaded tool content. */
|
|
4
|
+
export interface MessageItemState {
|
|
5
|
+
tone: StatusTone;
|
|
6
|
+
expandable: boolean;
|
|
7
|
+
expanded: boolean;
|
|
8
|
+
toggle: () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const MessageItemContext: import("react").Context<MessageItemState>;
|
|
11
|
+
export declare const MessageItemGroupContext: import("react").Context<{
|
|
12
|
+
tone: StatusTone;
|
|
13
|
+
} | null>;
|
|
14
|
+
export interface OpenSheet {
|
|
15
|
+
keep: () => boolean;
|
|
16
|
+
close: () => void;
|
|
17
|
+
setNote: (note: string | undefined) => void;
|
|
18
|
+
}
|
|
19
|
+
/** Closing sheets still occlude their canvas until native dismissal or unmount. */
|
|
20
|
+
export declare function hasPresentedSheets(): boolean;
|
|
21
|
+
export declare function subscribePresentedSheets(listener: () => void): () => void;
|
|
22
|
+
export declare function registerSheet(sheet: OpenSheet): void;
|
|
23
|
+
export declare function dismissSheet(sheet: OpenSheet): void;
|
|
24
|
+
export declare function unregisterSheet(sheet: OpenSheet): void;
|
|
25
|
+
/** A prompt holds the screen, so sheets must not open over it without a person's action. */
|
|
26
|
+
export declare function sheetsYielded(): boolean;
|
|
27
|
+
/** Close top-down until unsaved work keeps a sheet open; undefined only clears the note. */
|
|
28
|
+
export declare function yieldSheets(note: string | undefined): void;
|
|
29
|
+
//#endregion
|
|
30
|
+
//# sourceMappingURL=NativeShellState.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeShellState.d.mts","names":[],"sources":["../../src/components/NativeShellState.tsx"],"mappings":";;;iBAKiB;EACf,MAAM;EACN;EACA;EACA;;qBAGW,oCAAkB,QAAA;qBAOlB,yCAAuB;EAAyB,MAAA;;iBAE5C;EACf;EACA;EACA,UAAU;;;wBAUI;wBAIA,yBAAyB;wBAOzB,cAAc,OAAO;wBAOrB,aAAa,OAAO;wBAIpB,gBAAgB,OAAO;;wBAMvB;;wBAKA,YAAY"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createContext } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/components/NativeShellState.tsx
|
|
4
|
+
const MessageItemContext = createContext({
|
|
5
|
+
tone: "neutral",
|
|
6
|
+
expandable: false,
|
|
7
|
+
expanded: false,
|
|
8
|
+
toggle: () => void 0
|
|
9
|
+
});
|
|
10
|
+
const MessageItemGroupContext = createContext(null);
|
|
11
|
+
/** One shell-owned list across every downloaded UI module, oldest sheet first. */
|
|
12
|
+
const openSheets = [];
|
|
13
|
+
const presentedSheets = /* @__PURE__ */ new Set();
|
|
14
|
+
const sheetListeners = /* @__PURE__ */ new Set();
|
|
15
|
+
let yielded = false;
|
|
16
|
+
/** Closing sheets still occlude their canvas until native dismissal or unmount. */
|
|
17
|
+
function hasPresentedSheets() {
|
|
18
|
+
return presentedSheets.size > 0;
|
|
19
|
+
}
|
|
20
|
+
function subscribePresentedSheets(listener) {
|
|
21
|
+
sheetListeners.add(listener);
|
|
22
|
+
return () => {
|
|
23
|
+
sheetListeners.delete(listener);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function registerSheet(sheet) {
|
|
27
|
+
if (!openSheets.includes(sheet)) openSheets.push(sheet);
|
|
28
|
+
if (presentedSheets.has(sheet)) return;
|
|
29
|
+
presentedSheets.add(sheet);
|
|
30
|
+
for (const listener of sheetListeners) listener();
|
|
31
|
+
}
|
|
32
|
+
function dismissSheet(sheet) {
|
|
33
|
+
if (presentedSheets.delete(sheet)) for (const listener of sheetListeners) listener();
|
|
34
|
+
}
|
|
35
|
+
function unregisterSheet(sheet) {
|
|
36
|
+
const index = openSheets.indexOf(sheet);
|
|
37
|
+
if (index >= 0) openSheets.splice(index, 1);
|
|
38
|
+
}
|
|
39
|
+
/** A prompt holds the screen, so sheets must not open over it without a person's action. */
|
|
40
|
+
function sheetsYielded() {
|
|
41
|
+
return yielded;
|
|
42
|
+
}
|
|
43
|
+
/** Close top-down until unsaved work keeps a sheet open; undefined only clears the note. */
|
|
44
|
+
function yieldSheets(note) {
|
|
45
|
+
yielded = note !== void 0;
|
|
46
|
+
if (note === void 0) {
|
|
47
|
+
for (const sheet of openSheets) sheet.setNote(void 0);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
for (let index = openSheets.length - 1; index >= 0; index -= 1) {
|
|
51
|
+
if (openSheets[index].keep()) {
|
|
52
|
+
for (const sheet of openSheets.slice(0, index + 1)) sheet.setNote(note);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
openSheets[index].close();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
export { MessageItemContext, MessageItemGroupContext, dismissSheet, hasPresentedSheets, registerSheet, sheetsYielded, subscribePresentedSheets, unregisterSheet, yieldSheets };
|
|
61
|
+
//# sourceMappingURL=NativeShellState.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeShellState.mjs","names":[],"sources":["../../src/components/NativeShellState.tsx"],"sourcesContent":["import { createContext } from 'react';\n\nimport type { StatusTone } from './StatusBadge';\n\n/** State shared by shell-rendered timeline frames and downloaded tool content. */\nexport interface MessageItemState {\n tone: StatusTone;\n expandable: boolean;\n expanded: boolean;\n toggle: () => void;\n}\n\nexport const MessageItemContext = createContext<MessageItemState>({\n tone: 'neutral',\n expandable: false,\n expanded: false,\n toggle: () => undefined,\n});\n\nexport const MessageItemGroupContext = createContext<{ tone: StatusTone } | null>(null);\n\nexport interface OpenSheet {\n keep: () => boolean;\n close: () => void;\n setNote: (note: string | undefined) => void;\n}\n\n/** One shell-owned list across every downloaded UI module, oldest sheet first. */\nconst openSheets: OpenSheet[] = [];\nconst presentedSheets = new Set<OpenSheet>();\nconst sheetListeners = new Set<() => void>();\nlet yielded = false;\n\n/** Closing sheets still occlude their canvas until native dismissal or unmount. */\nexport function hasPresentedSheets(): boolean {\n return presentedSheets.size > 0;\n}\n\nexport function subscribePresentedSheets(listener: () => void): () => void {\n sheetListeners.add(listener);\n return () => {\n sheetListeners.delete(listener);\n };\n}\n\nexport function registerSheet(sheet: OpenSheet): void {\n if (!openSheets.includes(sheet)) openSheets.push(sheet);\n if (presentedSheets.has(sheet)) return;\n presentedSheets.add(sheet);\n for (const listener of sheetListeners) listener();\n}\n\nexport function dismissSheet(sheet: OpenSheet): void {\n if (presentedSheets.delete(sheet)) for (const listener of sheetListeners) listener();\n}\n\nexport function unregisterSheet(sheet: OpenSheet): void {\n const index = openSheets.indexOf(sheet);\n if (index >= 0) openSheets.splice(index, 1);\n}\n\n/** A prompt holds the screen, so sheets must not open over it without a person's action. */\nexport function sheetsYielded(): boolean {\n return yielded;\n}\n\n/** Close top-down until unsaved work keeps a sheet open; undefined only clears the note. */\nexport function yieldSheets(note: string | undefined): void {\n yielded = note !== undefined;\n if (note === undefined) {\n for (const sheet of openSheets) sheet.setNote(undefined);\n return;\n }\n for (let index = openSheets.length - 1; index >= 0; index -= 1) {\n if (openSheets[index].keep()) {\n for (const sheet of openSheets.slice(0, index + 1)) sheet.setNote(note);\n return;\n }\n openSheets[index].close();\n }\n}\n"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