@agimon-ai/po-native-components 0.0.0-alpha.13 → 0.0.0-alpha.130

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/LICENSE +149 -22
  2. package/dist/components/AgentAvatar.d.mts +14 -0
  3. package/dist/components/AgentAvatar.d.mts.map +1 -0
  4. package/dist/components/AgentAvatar.mjs +87 -0
  5. package/dist/components/AgentAvatar.mjs.map +1 -0
  6. package/dist/components/AnnotationSurface.d.mts +69 -0
  7. package/dist/components/AnnotationSurface.d.mts.map +1 -0
  8. package/dist/components/AnnotationSurface.mjs +426 -0
  9. package/dist/components/AnnotationSurface.mjs.map +1 -0
  10. package/dist/components/Badge.d.mts +1 -1
  11. package/dist/components/Badge.mjs +1 -1
  12. package/dist/components/Button.mjs +3 -3
  13. package/dist/components/Button.mjs.map +1 -1
  14. package/dist/components/CodeBlock.d.mts +3 -1
  15. package/dist/components/CodeBlock.d.mts.map +1 -1
  16. package/dist/components/CodeBlock.mjs +35 -47
  17. package/dist/components/CodeBlock.mjs.map +1 -1
  18. package/dist/components/CopyButton.d.mts +13 -0
  19. package/dist/components/CopyButton.d.mts.map +1 -0
  20. package/dist/components/CopyButton.mjs +43 -0
  21. package/dist/components/CopyButton.mjs.map +1 -0
  22. package/dist/components/CountBadge.d.mts +15 -0
  23. package/dist/components/CountBadge.d.mts.map +1 -0
  24. package/dist/components/CountBadge.mjs +49 -0
  25. package/dist/components/CountBadge.mjs.map +1 -0
  26. package/dist/components/Dialog.d.mts.map +1 -1
  27. package/dist/components/Dialog.mjs +9 -8
  28. package/dist/components/Dialog.mjs.map +1 -1
  29. package/dist/components/Dot.d.mts +1 -1
  30. package/dist/components/Dot.mjs +2 -2
  31. package/dist/components/DropdownMenu.d.mts +3 -1
  32. package/dist/components/DropdownMenu.d.mts.map +1 -1
  33. package/dist/components/DropdownMenu.mjs +21 -14
  34. package/dist/components/DropdownMenu.mjs.map +1 -1
  35. package/dist/components/HashlineLines.d.mts +13 -0
  36. package/dist/components/HashlineLines.d.mts.map +1 -0
  37. package/dist/components/HashlineLines.mjs +148 -0
  38. package/dist/components/HashlineLines.mjs.map +1 -0
  39. package/dist/components/HostFilter.d.mts +17 -0
  40. package/dist/components/HostFilter.d.mts.map +1 -0
  41. package/dist/components/HostFilter.mjs +66 -0
  42. package/dist/components/HostFilter.mjs.map +1 -0
  43. package/dist/components/HostTag.d.mts +7 -0
  44. package/dist/components/HostTag.d.mts.map +1 -0
  45. package/dist/components/HostTag.mjs +47 -0
  46. package/dist/components/HostTag.mjs.map +1 -0
  47. package/dist/components/InfoStrip.d.mts +9 -0
  48. package/dist/components/InfoStrip.d.mts.map +1 -0
  49. package/dist/components/InfoStrip.mjs +53 -0
  50. package/dist/components/InfoStrip.mjs.map +1 -0
  51. package/dist/components/Input.d.mts +3 -1
  52. package/dist/components/Input.d.mts.map +1 -1
  53. package/dist/components/Input.mjs +4 -3
  54. package/dist/components/Input.mjs.map +1 -1
  55. package/dist/components/Label.mjs +1 -1
  56. package/dist/components/List.d.mts.map +1 -1
  57. package/dist/components/List.mjs +38 -6
  58. package/dist/components/List.mjs.map +1 -1
  59. package/dist/components/LiveDuration.d.mts +30 -0
  60. package/dist/components/LiveDuration.d.mts.map +1 -0
  61. package/dist/components/LiveDuration.mjs +67 -0
  62. package/dist/components/LiveDuration.mjs.map +1 -0
  63. package/dist/components/Markdown.d.mts +10 -1
  64. package/dist/components/Markdown.d.mts.map +1 -1
  65. package/dist/components/Markdown.mjs +335 -26
  66. package/dist/components/Markdown.mjs.map +1 -1
  67. package/dist/components/MessageItem.d.mts +10 -15
  68. package/dist/components/MessageItem.d.mts.map +1 -1
  69. package/dist/components/MessageItem.mjs +72 -63
  70. package/dist/components/MessageItem.mjs.map +1 -1
  71. package/dist/components/NativeShellState.d.mts +30 -0
  72. package/dist/components/NativeShellState.d.mts.map +1 -0
  73. package/dist/components/NativeShellState.mjs +61 -0
  74. package/dist/components/NativeShellState.mjs.map +1 -0
  75. package/dist/components/SectionLabel.mjs +1 -1
  76. package/dist/components/Select.d.mts +33 -0
  77. package/dist/components/Select.d.mts.map +1 -0
  78. package/dist/components/Select.mjs +222 -0
  79. package/dist/components/Select.mjs.map +1 -0
  80. package/dist/components/Sheet.d.mts +9 -1
  81. package/dist/components/Sheet.d.mts.map +1 -1
  82. package/dist/components/Sheet.mjs +27 -10
  83. package/dist/components/Sheet.mjs.map +1 -1
  84. package/dist/components/SheetFrame.mjs +143 -28
  85. package/dist/components/SheetFrame.mjs.map +1 -1
  86. package/dist/components/SheetList.d.mts +14 -0
  87. package/dist/components/SheetList.d.mts.map +1 -0
  88. package/dist/components/SheetList.mjs +34 -0
  89. package/dist/components/SheetList.mjs.map +1 -0
  90. package/dist/components/ShowMore.d.mts +10 -0
  91. package/dist/components/ShowMore.d.mts.map +1 -0
  92. package/dist/components/ShowMore.mjs +44 -0
  93. package/dist/components/ShowMore.mjs.map +1 -0
  94. package/dist/components/Spinner.d.mts +1 -1
  95. package/dist/components/StatusBadge.d.mts +1 -1
  96. package/dist/components/Switch.d.mts +14 -0
  97. package/dist/components/Switch.d.mts.map +1 -0
  98. package/dist/components/Switch.mjs +37 -0
  99. package/dist/components/Switch.mjs.map +1 -0
  100. package/dist/components/SyntaxLine.d.mts +19 -0
  101. package/dist/components/SyntaxLine.d.mts.map +1 -0
  102. package/dist/components/SyntaxLine.mjs +134 -0
  103. package/dist/components/SyntaxLine.mjs.map +1 -0
  104. package/dist/components/Tabs.d.mts.map +1 -1
  105. package/dist/components/Tabs.mjs +8 -7
  106. package/dist/components/Tabs.mjs.map +1 -1
  107. package/dist/components/ToolPathLink.d.mts +10 -0
  108. package/dist/components/ToolPathLink.d.mts.map +1 -0
  109. package/dist/components/ToolPathLink.mjs +40 -0
  110. package/dist/components/ToolPathLink.mjs.map +1 -0
  111. package/dist/components/ToolResultImage.d.mts +12 -0
  112. package/dist/components/ToolResultImage.d.mts.map +1 -0
  113. package/dist/components/ToolResultImage.mjs +48 -0
  114. package/dist/components/ToolResultImage.mjs.map +1 -0
  115. package/dist/icons/iconGlyphs.d.mts +60 -0
  116. package/dist/icons/iconGlyphs.d.mts.map +1 -1
  117. package/dist/icons/iconGlyphs.mjs +60 -0
  118. package/dist/icons/iconGlyphs.mjs.map +1 -1
  119. package/dist/icons/icons.d.mts +61 -1
  120. package/dist/icons/icons.d.mts.map +1 -1
  121. package/dist/icons/icons.mjs +17 -2
  122. package/dist/icons/icons.mjs.map +1 -1
  123. package/dist/index.d.mts +20 -6
  124. package/dist/index.mjs +21 -7
  125. package/dist/lib/fonts.d.mts +3 -1
  126. package/dist/lib/fonts.d.mts.map +1 -1
  127. package/dist/lib/fonts.mjs +4 -2
  128. package/dist/lib/fonts.mjs.map +1 -1
  129. package/dist/lib/insideSheet.d.mts +10 -0
  130. package/dist/lib/insideSheet.d.mts.map +1 -0
  131. package/dist/lib/markdown.mjs +172 -23
  132. package/dist/lib/markdown.mjs.map +1 -1
  133. package/dist/lib/reading.mjs +60 -0
  134. package/dist/lib/reading.mjs.map +1 -0
  135. package/dist/lib/useControllable.mjs +14 -6
  136. package/dist/lib/useControllable.mjs.map +1 -1
  137. package/dist/lib/useReadingPage.mjs +33 -0
  138. package/dist/lib/useReadingPage.mjs.map +1 -0
  139. package/dist/shell.d.mts +6 -0
  140. package/dist/shell.mjs +7 -0
  141. package/package.json +37 -28
@@ -1 +1 @@
1
- {"version":3,"file":"List.mjs","names":["FlashList","ReactElement","ReactNode","Platform","StyleProp","ViewStyle","StyleSheet","ChevronRightIcon","fontOf","MIN_ROW_HEIGHT","DISABLED_OPACITY","PIN_THRESHOLD","ListProps","data","T","renderItem","item","index","keyExtractor","startAtBottom","separators","empty","header","footer","onEndReached","accessibilityLabel","style","contentPadding","Separator","styles","separator","List","frame","undefined","padding","startRenderingFromBottom","autoscrollToBottomThreshold","ListRowProps","title","description","leading","trailing","selected","disabled","onPress","disclosure","ListRow","chevron","OS","content","text","titleSelected","row","pressed","create","theme","flex","minHeight","height","hairlineWidth","marginLeft","spacing","backgroundColor","colors","uni__dependencies","flexDirection","alignItems","gap","paddingHorizontal","paddingVertical","panel","opacity","minWidth","color","hi","fontFamily","sans","fontSize","base","lineHeight","fontWeight","medium","green","semibold","faint","sm"],"sources":["../../src/components/List.tsx"],"sourcesContent":["import { FlashList } from '@shopify/flash-list';\nimport type { ReactElement, ReactNode } from 'react';\nimport { Platform, Pressable, type StyleProp, Text, View, type ViewStyle } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { ChevronRightIcon } from '../icons/icons';\nimport { fontOf } from '../lib/fonts';\n\n/*\n * A virtualised list on FlashList: sessions, devices, a transcript. Rows\n * recycle, separators are hairlines, and a chat list can start at the bottom\n * and stay pinned there as rows arrive. The public props are this package's\n * own, so FlashList's types never reach a caller.\n */\n\nconst MIN_ROW_HEIGHT = 44;\nconst DISABLED_OPACITY = 0.4;\n/** How close to the bottom a reader must be for a new row to keep the list pinned, as a fraction of the visible height. */\nconst PIN_THRESHOLD = 0.1;\n\nexport interface ListProps<T> {\n data: readonly T[];\n renderItem: (item: T, index: number) => ReactElement | null;\n /** A stable key per row; FlashList recycles views by it. */\n keyExtractor: (item: T, index: number) => string;\n /**\n * A chat list: render from the bottom and keep the newest row in view as\n * rows arrive, while the reader is near the bottom.\n */\n startAtBottom?: boolean;\n /** Hairline separators between rows. On by default. */\n separators?: boolean;\n /** Shown when `data` is empty. */\n empty?: ReactNode;\n header?: ReactNode;\n footer?: ReactNode;\n onEndReached?: () => void;\n accessibilityLabel?: string;\n /** The list's frame; give it a height or a flex parent, since a virtualised list needs bounds. */\n style?: StyleProp<ViewStyle>;\n /** Padding around the rows. */\n contentPadding?: number;\n}\n\nfunction Separator() {\n return <View style={styles.separator} />;\n}\n\nexport function List<T>({\n data,\n renderItem,\n keyExtractor,\n startAtBottom = false,\n separators = true,\n empty,\n header,\n footer,\n onEndReached,\n accessibilityLabel,\n style,\n contentPadding,\n}: ListProps<T>) {\n return (\n <View style={[styles.frame, style]} accessibilityLabel={accessibilityLabel}>\n <FlashList\n data={data}\n renderItem={({ item, index }) => renderItem(item, index)}\n keyExtractor={keyExtractor}\n ItemSeparatorComponent={separators ? Separator : null}\n ListEmptyComponent={empty === undefined ? null : <>{empty}</>}\n ListHeaderComponent={header === undefined ? null : <>{header}</>}\n ListFooterComponent={footer === undefined ? null : <>{footer}</>}\n onEndReached={onEndReached}\n // Lets UIKit inset the rows under a translucent or large-title header instead of drawing beneath it.\n contentInsetAdjustmentBehavior=\"automatic\"\n contentContainerStyle={contentPadding === undefined ? undefined : { padding: contentPadding }}\n maintainVisibleContentPosition={\n startAtBottom ? { startRenderingFromBottom: true, autoscrollToBottomThreshold: PIN_THRESHOLD } : undefined\n }\n />\n </View>\n );\n}\n\nexport interface ListRowProps {\n title: ReactNode;\n /** A second, quieter line under the title. */\n description?: ReactNode;\n /** Before the text: a Dot, an icon. */\n leading?: ReactNode;\n /** After the text: a Badge, a ghost button, a count. */\n trailing?: ReactNode;\n /** Selected rows sit on a green tint. */\n selected?: boolean;\n disabled?: boolean;\n onPress?: () => void;\n /** The iOS disclosure chevron. Defaults to on for a pressable row on iOS, where rows that navigate wear one. */\n disclosure?: boolean;\n accessibilityLabel?: string;\n style?: StyleProp<ViewStyle>;\n}\n\n/** One list row: 44pt tall, optional leading and trailing slots, pressable when it navigates. */\nexport function ListRow({\n title,\n description,\n leading,\n trailing,\n selected = false,\n disabled = false,\n onPress,\n disclosure,\n accessibilityLabel,\n style,\n}: ListRowProps) {\n const chevron = disclosure ?? (onPress !== undefined && Platform.OS === 'ios');\n const content = (\n <>\n {leading}\n <View style={styles.text}>\n {typeof title === 'string' ? (\n <Text numberOfLines={1} style={[styles.title, selected && styles.titleSelected]}>\n {title}\n </Text>\n ) : (\n title\n )}\n {typeof description === 'string' ? (\n <Text numberOfLines={2} style={styles.description}>\n {description}\n </Text>\n ) : (\n description\n )}\n </View>\n {trailing}\n {chevron ? <ChevronRightIcon size={14} color=\"faint\" /> : null}\n </>\n );\n if (onPress === undefined) {\n return (\n <View\n accessibilityLabel={accessibilityLabel}\n accessibilityState={{ selected, disabled }}\n style={[styles.row, selected && styles.selected, disabled && styles.disabled, style]}\n >\n {content}\n </View>\n );\n }\n return (\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel={accessibilityLabel}\n accessibilityState={{ selected, disabled }}\n disabled={disabled}\n onPress={onPress}\n style={({ pressed }) => [\n styles.row,\n selected && styles.selected,\n pressed && styles.pressed,\n disabled && styles.disabled,\n style,\n ]}\n >\n {content}\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n frame: { flex: 1, minHeight: 0 },\n separator: {\n height: StyleSheet.hairlineWidth,\n marginLeft: theme.spacing(4),\n backgroundColor: theme.colors['border-soft'],\n },\n row: {\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(2),\n },\n selected: { backgroundColor: theme.colors['tint-green'] },\n pressed: { backgroundColor: theme.colors.panel },\n disabled: { opacity: DISABLED_OPACITY },\n text: { flex: 1, minWidth: 0, gap: theme.spacing(0.5) },\n title: {\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.medium,\n },\n titleSelected: { color: theme.colors.green, fontWeight: theme.fontWeight.semibold },\n description: {\n color: theme.colors.faint,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n}));\n"],"mappings":";;;;;;;;;;;AAeA,MAAMS,iBAAiB;AACvB,MAAMC,mBAAmB;;AAEzB,MAAMC,gBAAgB;AA0BtB,SAASiB,YAAY;CACnB,OAAO,oBAAC,MAAD,EAAM,OAAOC,OAAOC,UAAU;AACvC;AAEA,SAAgBC,KAAQ,EACtBlB,MACAE,YAC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jB,mBAAA,CAAA,CAAA;CACrC;CACAb,eAAe;EAAEsB,OAAOlB,MAAMQ,OAAOmB;EAAOF,YAAYzB,MAAMyB,WAAWG;EAAQnB,mBAAA,CAAA,CAAA;CAAC;CAClFzB,aAAa;EACXkC,OAAOlB,MAAMQ,OAAOqB;EACpBT,YAAYnE,OAAO+C,MAAMoB,WAAWC,IAAI;EACxCC,UAAUtB,MAAMsB,SAASQ;EACzBN,YAAYxB,MAAMwB,WAAWM;EAAErB,mBAAA,CAAA,CAAA;CACjC;AACF,EAAE"}
1
+ {"version":3,"file":"List.mjs","names":["FlashList","FlashListRef","ReactElement","ReactNode","useCallback","useRef","useState","NativeScrollEvent","NativeSyntheticEvent","Platform","StyleProp","ViewStyle","StyleSheet","ChevronDownIcon","ChevronRightIcon","fontOf","Button","MIN_ROW_HEIGHT","DISABLED_OPACITY","PIN_THRESHOLD","JUMP_THRESHOLD","ListProps","data","T","renderItem","item","index","keyExtractor","startAtBottom","separators","empty","header","footer","onEndReached","accessibilityLabel","style","contentPadding","Separator","styles","separator","List","renderRow","listRef","awayFromBottom","setAwayFromBottom","onScroll","nativeEvent","contentOffset","contentSize","layoutMeasurement","distance","height","y","frame","undefined","OS","padding","startRenderingFromBottom","autoscrollToBottomThreshold","current","scrollToEnd","animated","jump","ListRowProps","title","description","leading","trailing","selected","disabled","onPress","disclosure","ListRow","chevron","content","text","titleSelected","row","pressed","create","theme","flex","minHeight","position","bottom","spacing","alignSelf","borderRadius","full","borderColor","colors","border","uni__dependencies","hairlineWidth","marginLeft","backgroundColor","flexDirection","alignItems","gap","paddingHorizontal","paddingVertical","panel","opacity","minWidth","color","hi","fontFamily","sans","fontSize","base","lineHeight","fontWeight","medium","green","semibold","faint","sm"],"sources":["../../src/components/List.tsx"],"sourcesContent":["import { FlashList, type FlashListRef } from '@shopify/flash-list';\nimport { type ReactElement, type ReactNode, useCallback, useRef, useState } from 'react';\nimport {\n type NativeScrollEvent,\n type NativeSyntheticEvent,\n Platform,\n Pressable,\n type StyleProp,\n Text,\n View,\n type ViewStyle,\n} from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { ChevronDownIcon, ChevronRightIcon } from '../icons/icons';\nimport { fontOf } from '../lib/fonts';\nimport { Button } from './Button';\n/*\n * A virtualised list on FlashList: sessions, devices, a transcript. Rows\n * recycle, separators are hairlines, and a chat list can start at the bottom\n * and stay pinned there as rows arrive. The public props are this package's\n * own, so FlashList's types never reach a caller.\n */\n\nconst MIN_ROW_HEIGHT = 44;\nconst DISABLED_OPACITY = 0.4;\n/** How close to the bottom a reader must be for a new row to keep the list pinned, as a fraction of the visible height. */\nconst PIN_THRESHOLD = 0.1;\n/** How far above the bottom, in visible heights, a chat reader must scroll before the jump-to-latest button shows. */\nconst JUMP_THRESHOLD = 1;\n\nexport interface ListProps<T> {\n data: readonly T[];\n renderItem: (item: T, index: number) => ReactElement | null;\n /** A stable key per row; FlashList recycles views by it. */\n keyExtractor: (item: T, index: number) => string;\n /**\n * A chat list: render from the bottom and keep the newest row in view as\n * rows arrive, while the reader is near the bottom.\n */\n startAtBottom?: boolean;\n /** Hairline separators between rows. On by default. */\n separators?: boolean;\n /** Shown when `data` is empty. */\n empty?: ReactNode;\n header?: ReactNode;\n footer?: ReactNode;\n onEndReached?: () => void;\n accessibilityLabel?: string;\n /** The list's frame; give it a height or a flex parent, since a virtualised list needs bounds. */\n style?: StyleProp<ViewStyle>;\n /** Padding around the rows. */\n contentPadding?: number;\n}\n\nfunction Separator() {\n return <View style={styles.separator} />;\n}\n\nexport function List<T>({\n data,\n renderItem,\n keyExtractor,\n startAtBottom = false,\n separators = true,\n empty,\n header,\n footer,\n onEndReached,\n accessibilityLabel,\n style,\n contentPadding,\n}: ListProps<T>) {\n const renderRow = useCallback(({ item, index }: { item: T; index: number }) => renderItem(item, index), [renderItem]);\n const listRef = useRef<FlashListRef<T>>(null);\n const [awayFromBottom, setAwayFromBottom] = useState(false);\n const onScroll = useCallback(({ nativeEvent }: NativeSyntheticEvent<NativeScrollEvent>) => {\n const { contentOffset, contentSize, layoutMeasurement } = nativeEvent;\n const distance = contentSize.height - layoutMeasurement.height - contentOffset.y;\n setAwayFromBottom(distance > layoutMeasurement.height * JUMP_THRESHOLD);\n }, []);\n return (\n <View style={[styles.frame, style]} accessibilityLabel={accessibilityLabel}>\n <FlashList\n ref={listRef}\n onScroll={startAtBottom ? onScroll : undefined}\n scrollEventThrottle={startAtBottom ? 100 : undefined}\n data={data}\n renderItem={renderRow}\n keyExtractor={keyExtractor}\n ItemSeparatorComponent={separators ? Separator : null}\n ListEmptyComponent={empty === undefined ? null : <>{empty}</>}\n ListHeaderComponent={header === undefined ? null : <>{header}</>}\n ListFooterComponent={footer === undefined ? null : <>{footer}</>}\n onEndReached={onEndReached}\n // Dragging the rows pulls the keyboard down with the finger, as in Messages.\n keyboardDismissMode={Platform.OS === 'ios' ? 'interactive' : 'on-drag'}\n // A chat's rows are mostly pressable (long-press bubbles, tool groups), so any tap there hides the keyboard\n // first, as in Messages; other lists let a tap on a row land.\n keyboardShouldPersistTaps={startAtBottom ? 'never' : 'handled'}\n // Lets UIKit inset the rows under a translucent or large-title header instead of drawing beneath it.\n contentInsetAdjustmentBehavior=\"automatic\"\n contentContainerStyle={contentPadding === undefined ? undefined : { padding: contentPadding }}\n maintainVisibleContentPosition={\n startAtBottom ? { startRenderingFromBottom: true, autoscrollToBottomThreshold: PIN_THRESHOLD } : undefined\n }\n />\n {startAtBottom && awayFromBottom ? (\n <Button\n variant=\"subtle\"\n size=\"icon-md\"\n accessibilityLabel=\"Jump to latest\"\n onPress={() => listRef.current?.scrollToEnd({ animated: true })}\n style={styles.jump}\n >\n <ChevronDownIcon size={18} />\n </Button>\n ) : null}\n </View>\n );\n}\n\nexport interface ListRowProps {\n title: ReactNode;\n /** A second, quieter line under the title. */\n description?: ReactNode;\n /** Before the text: a Dot, an icon. */\n leading?: ReactNode;\n /** After the text: a Badge, a ghost button, a count. */\n trailing?: ReactNode;\n /** Selected rows sit on a green tint. */\n selected?: boolean;\n disabled?: boolean;\n onPress?: () => void;\n /** The iOS disclosure chevron. Defaults to on for a pressable row on iOS, where rows that navigate wear one. */\n disclosure?: boolean;\n accessibilityLabel?: string;\n style?: StyleProp<ViewStyle>;\n}\n\n/** One list row: 44pt tall, optional leading and trailing slots, pressable when it navigates. */\nexport function ListRow({\n title,\n description,\n leading,\n trailing,\n selected = false,\n disabled = false,\n onPress,\n disclosure,\n accessibilityLabel,\n style,\n}: ListRowProps) {\n const chevron = disclosure ?? (onPress !== undefined && Platform.OS === 'ios');\n const content = (\n <>\n {leading}\n <View style={styles.text}>\n {typeof title === 'string' ? (\n <Text numberOfLines={1} style={[styles.title, selected && styles.titleSelected]}>\n {title}\n </Text>\n ) : (\n title\n )}\n {typeof description === 'string' ? (\n <Text numberOfLines={2} style={styles.description}>\n {description}\n </Text>\n ) : (\n description\n )}\n </View>\n {trailing}\n {chevron ? <ChevronRightIcon size={14} color=\"faint\" /> : null}\n </>\n );\n if (onPress === undefined) {\n return (\n <View\n accessibilityLabel={accessibilityLabel}\n accessibilityState={{ selected, disabled }}\n style={[styles.row, selected && styles.selected, disabled && styles.disabled, style]}\n >\n {content}\n </View>\n );\n }\n return (\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel={accessibilityLabel}\n accessibilityState={{ selected, disabled }}\n disabled={disabled}\n onPress={onPress}\n style={({ pressed }) => [\n styles.row,\n selected && styles.selected,\n pressed && styles.pressed,\n disabled && styles.disabled,\n style,\n ]}\n >\n {content}\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n frame: { flex: 1, minHeight: 0 },\n jump: {\n position: 'absolute',\n bottom: theme.spacing(3),\n alignSelf: 'center',\n borderRadius: theme.borderRadius.full,\n borderColor: theme.colors.border,\n },\n separator: {\n height: StyleSheet.hairlineWidth,\n marginLeft: theme.spacing(4),\n backgroundColor: theme.colors['border-soft'],\n },\n row: {\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(2),\n },\n selected: { backgroundColor: theme.colors['tint-green'] },\n pressed: { backgroundColor: theme.colors.panel },\n disabled: { opacity: DISABLED_OPACITY },\n text: { flex: 1, minWidth: 0, gap: theme.spacing(0.5) },\n title: {\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.medium,\n },\n titleSelected: { color: theme.colors.green, fontWeight: theme.fontWeight.semibold },\n description: {\n color: theme.colors.faint,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n}));\n"],"mappings":";;;;;;;;;;;;;AAwBA,MAAMiB,iBAAiB;AACvB,MAAMC,mBAAmB;;AAEzB,MAAMC,gBAAgB;;AAEtB,MAAMC,iBAAiB;AA0BvB,SAASiB,YAAY;CACnB,OAAO,oBAAC,MAAD,EAAM,OAAOC,OAAOC,UAAU;AACvC;AAEA,SAAgBC,KAAQ,EACtBlB,MACAE,YACAG,cACAC,gBAAgB,OAChBC,aAAa,MACbC,OACAC,QACAC,QACAC,cACAC,oBACAC,OACAC,kBACe;CACf,MAAMK,YAAYrC,aAAa,EAAEqB,MAAMC,YAAwCF,WAAWC,MAAMC,KAAK,GAAG,CAACF,UAAU,CAAC;CACpH,MAAMkB,UAAUrC,OAAwB,IAAI;CAC5C,MAAM,CAACsC,gBAAgBC,qBAAqBtC,SAAS,KAAK;CAC1D,MAAMuC,WAAWzC,aAAa,EAAE0C,kBAA2D;EACzF,MAAM,EAAEC,eAAeC,aAAaC,sBAAsBH;EAC1D,MAAMI,WAAWF,YAAYG,SAASF,kBAAkBE,SAASJ,cAAcK;EAC/ER,kBAAkBM,WAAWD,kBAAkBE,SAAS/B,cAAc;CACxE,GAAG,CAAA,CAAE;CACL,OACE,qBAAC,MAAD;EA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AAC;CACxDd,SAAS;EAAEiB,iBAAiBf,MAAMU,OAAOW;EAAKT,mBAAA,CAAA,CAAA;CAAC;CAC/CvB,UAAU,EAAEiC,SAASpF,iBAAiB;CACtCyD,MAAM;EAAEM,MAAM;EAAGsB,UAAU;EAAGL,KAAKlB,MAAMK,QAAQ,EAAG;EAACO,mBAAA,CAAA,CAAA;CAAC;CACtD5B,OAAO;EACLwC,OAAOxB,MAAMU,OAAOe;EACpBC,YAAY3F,OAAOiE,MAAM0B,WAAWC,IAAI;EACxCC,UAAU5B,MAAM4B,SAASC;EACzBC,YAAY9B,MAAM8B,WAAWD;EAC7BE,YAAY/B,MAAM+B,WAAWC;EAAMpB,mBAAA,CAAA,CAAA;CACrC;CACAhB,eAAe;EAAE4B,OAAOxB,MAAMU,OAAOuB;EAAOF,YAAY/B,MAAM+B,WAAWG;EAAQtB,mBAAA,CAAA,CAAA;CAAC;CAClF3B,aAAa;EACXuC,OAAOxB,MAAMU,OAAOyB;EACpBT,YAAY3F,OAAOiE,MAAM0B,WAAWC,IAAI;EACxCC,UAAU5B,MAAM4B,SAASQ;EACzBN,YAAY9B,MAAM8B,WAAWM;EAAExB,mBAAA,CAAA,CAAA;CACjC;AACF,EAAE"}
@@ -0,0 +1,30 @@
1
+ import { StyleProp, TextStyle } from "react-native";
2
+ //#region src/components/LiveDuration.d.ts
3
+ /** What a custom clock shows at `now`, and how long until it changes; no `nextMs` freezes it. */
4
+ export interface LiveDurationReading {
5
+ text: string;
6
+ nextMs?: number;
7
+ }
8
+ export type LiveDurationProps = {
9
+ style?: StyleProp<TextStyle>;
10
+ } & ({
11
+ /** The copy before the elapsed time, such as "running". */
12
+ label: string;
13
+ /** Epoch milliseconds the clock counts from. */
14
+ since: number;
15
+ clock?: undefined;
16
+ } | {
17
+ /** A custom format; keep it stable (useCallback), since a new function restarts the clock. */
18
+ clock: (now: number) => LiveDurationReading;
19
+ label?: undefined;
20
+ since?: undefined;
21
+ });
22
+ /**
23
+ * "running · 12m" that ages by itself, or any `clock` format. Each change writes a shared value the UI thread
24
+ * draws, so a list of running work re-renders nothing to keep its clocks current. It sleeps while the app is in
25
+ * the background and catches up on return. Read-only and not focusable: it sits inside a row whose own label
26
+ * speaks for it.
27
+ */
28
+ export declare function LiveDuration({ label, since, clock, style }: LiveDurationProps): import("react").JSX.Element;
29
+ //#endregion
30
+ //# sourceMappingURL=LiveDuration.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LiveDuration.d.mts","names":[],"sources":["../../src/components/LiveDuration.tsx"],"mappings":";;;iBASiB;EACf;EACA;;YAGU;EACV,QAAQ,UAAU;;;EAId;;EAEA;EACA;;;EAIA,QAAQ,gBAAgB;EACxB;EACA;;;;;;;;wBAUU,eAAe,OAAO,OAAO,OAAO,SAAS,oCAAiB,IAAA"}
@@ -0,0 +1,67 @@
1
+ import { clockRefreshMs, clockText } from "@agimon-ai/po-web-components/text";
2
+ import { StyleSheet } from "react-native-unistyles";
3
+ import { AppState } from "react-native";
4
+ import { useEffect, useState } from "react";
5
+ import { jsx } from "react/jsx-runtime";
6
+ import { TextInput as TextInput$1 } from "react-native-unistyles/components/native/TextInput";
7
+ import Animated, { useAnimatedProps, useSharedValue } from "react-native-reanimated";
8
+
9
+ //#region src/components/LiveDuration.tsx
10
+ const AnimatedTextInput = Animated.createAnimatedComponent(TextInput$1);
11
+ /**
12
+ * "running · 12m" that ages by itself, or any `clock` format. Each change writes a shared value the UI thread
13
+ * draws, so a list of running work re-renders nothing to keep its clocks current. It sleeps while the app is in
14
+ * the background and catches up on return. Read-only and not focusable: it sits inside a row whose own label
15
+ * speaks for it.
16
+ */
17
+ function LiveDuration({ label, since, clock, style }) {
18
+ const read = (now) => clock ? clock(now) : {
19
+ text: clockText({
20
+ label,
21
+ since
22
+ }, now),
23
+ nextMs: clockRefreshMs(since, now)
24
+ };
25
+ const [initial] = useState(() => read(Date.now()).text);
26
+ const text = useSharedValue(initial);
27
+ useEffect(() => {
28
+ let timer;
29
+ const tick = () => {
30
+ clearTimeout(timer);
31
+ timer = void 0;
32
+ if (AppState.currentState !== "active") return;
33
+ const reading = read(Date.now());
34
+ text.value = reading.text;
35
+ if (reading.nextMs !== void 0) timer = setTimeout(tick, Math.max(1, reading.nextMs));
36
+ };
37
+ const subscription = AppState.addEventListener("change", tick);
38
+ tick();
39
+ return () => {
40
+ clearTimeout(timer);
41
+ subscription.remove();
42
+ };
43
+ }, [
44
+ label,
45
+ since,
46
+ clock,
47
+ text
48
+ ]);
49
+ const animatedProps = useAnimatedProps(() => ({ text: text.value }));
50
+ return /* @__PURE__ */ jsx(AnimatedTextInput, {
51
+ editable: false,
52
+ focusable: false,
53
+ pointerEvents: "none",
54
+ underlineColorAndroid: "transparent",
55
+ defaultValue: initial,
56
+ animatedProps,
57
+ style: [styles.text, style]
58
+ });
59
+ }
60
+ const styles = StyleSheet.create({ text: {
61
+ padding: 0,
62
+ margin: 0
63
+ } });
64
+
65
+ //#endregion
66
+ export { LiveDuration };
67
+ //# sourceMappingURL=LiveDuration.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LiveDuration.mjs","names":["clockRefreshMs","clockText","useEffect","useState","AppState","StyleProp","TextInputProps","TextStyle","Animated","useAnimatedProps","useSharedValue","StyleSheet","AnimatedTextInput","createAnimatedComponent","TextInput","LiveDurationReading","text","nextMs","LiveDurationProps","style","label","since","clock","now","LiveDuration","read","initial","Date","timer","ReturnType","setTimeout","tick","clearTimeout","undefined","currentState","reading","value","Math","max","subscription","addEventListener","remove","animatedProps","styles","create","padding","margin","TextInput"],"sources":["../../src/components/LiveDuration.tsx"],"sourcesContent":["import { clockRefreshMs, clockText } from '@agimon-ai/po-web-components/text';\nimport { useEffect, useState } from 'react';\nimport { AppState, type StyleProp, TextInput, type TextInputProps, type TextStyle } from 'react-native';\nimport Animated, { useAnimatedProps, useSharedValue } from 'react-native-reanimated';\nimport { StyleSheet } from 'react-native-unistyles';\n\nconst AnimatedTextInput = Animated.createAnimatedComponent(TextInput);\n\n/** What a custom clock shows at `now`, and how long until it changes; no `nextMs` freezes it. */\nexport interface LiveDurationReading {\n text: string;\n nextMs?: number;\n}\n\nexport type LiveDurationProps = {\n style?: StyleProp<TextStyle>;\n} & (\n | {\n /** The copy before the elapsed time, such as \"running\". */\n label: string;\n /** Epoch milliseconds the clock counts from. */\n since: number;\n clock?: undefined;\n }\n | {\n /** A custom format; keep it stable (useCallback), since a new function restarts the clock. */\n clock: (now: number) => LiveDurationReading;\n label?: undefined;\n since?: undefined;\n }\n);\n\n/**\n * \"running · 12m\" that ages by itself, or any `clock` format. Each change writes a shared value the UI thread\n * draws, so a list of running work re-renders nothing to keep its clocks current. It sleeps while the app is in\n * the background and catches up on return. Read-only and not focusable: it sits inside a row whose own label\n * speaks for it.\n */\nexport function LiveDuration({ label, since, clock, style }: LiveDurationProps) {\n const read = (now: number): LiveDurationReading =>\n clock ? clock(now) : { text: clockText({ label, since }, now), nextMs: clockRefreshMs(since, now) };\n // The first paint's text; the effect below keeps it current from then on.\n const [initial] = useState(() => read(Date.now()).text);\n const text = useSharedValue(initial);\n useEffect(() => {\n let timer: ReturnType<typeof setTimeout> | undefined;\n const tick = (): void => {\n clearTimeout(timer);\n timer = undefined;\n if (AppState.currentState !== 'active') return;\n const reading = read(Date.now());\n text.value = reading.text;\n if (reading.nextMs !== undefined) timer = setTimeout(tick, Math.max(1, reading.nextMs));\n };\n const subscription = AppState.addEventListener('change', tick);\n tick();\n return () => {\n clearTimeout(timer);\n subscription.remove();\n };\n // read is rebuilt each render from exactly these inputs.\n // oxlint-disable-next-line react-hooks/exhaustive-deps\n }, [label, since, clock, text]);\n const animatedProps = useAnimatedProps(() => ({ text: text.value }) as TextInputProps);\n return (\n <AnimatedTextInput\n editable={false}\n focusable={false}\n pointerEvents=\"none\"\n underlineColorAndroid=\"transparent\"\n defaultValue={initial}\n animatedProps={animatedProps}\n style={[styles.text, style]}\n />\n );\n}\n\nconst styles = StyleSheet.create({\n // A TextInput pads itself on Android; a status line sits fl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}
@@ -5,11 +5,20 @@
5
5
  * contract as the web Markdown's handler.
6
6
  */
7
7
  export type FileLinkHandler = (text: string, explicit?: boolean) => (() => void) | undefined;
8
+ /** Loads a relative image path from the host; the same contract as the web Markdown's `loadImage`. */
9
+ export type MarkdownImageLoader = (path: string) => Promise<{
10
+ url: string;
11
+ dispose(): void;
12
+ }>;
8
13
  export interface MarkdownProps {
9
14
  text: string;
10
15
  onFileLink?: FileLinkHandler;
16
+ /** Loads relative image paths; without it they show as unavailable. */
17
+ loadImage?: MarkdownImageLoader;
18
+ /** Initial reveal pages for a restored reading position. Defaults to one. */
19
+ initialPage?: number;
11
20
  }
12
21
  /** Markdown in Po's shared presentation, parsed by the package's own small parser. */
13
- export declare function Markdown({ text, onFileLink }: MarkdownProps): import("react").JSX.Element;
22
+ export declare const Markdown: import("react").MemoExoticComponent<({ text, onFileLink, loadImage, initialPage }: MarkdownProps) => import("react").JSX.Element>;
14
23
  //#endregion
15
24
  //# sourceMappingURL=Markdown.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Markdown.d.mts","names":[],"sources":["../../src/components/Markdown.tsx"],"mappings":";;;;;;YAqBY,mBAAmB,cAAc;iBAgH5B;EACf;EACA,aAAa;;;wBAIC,WAAW,MAAM,cAAc,gCAAa,IAAA"}
1
+ {"version":3,"file":"Markdown.d.mts","names":[],"sources":["../../src/components/Markdown.tsx"],"mappings":";;;;;;YAuBY,mBAAmB,cAAc;;YAQjC,uBAAuB,iBAAiB;EAAU;EAAa;;iBAyU1D;EACf;EACA,aAAa;;EAEb,YAAY;;EAEZ;;;qBAIW,0BAAQ,uBAAA,MAAA,YAAA,WAAA,eAA4E,kCAAa,IAAA"}
@@ -1,17 +1,28 @@
1
1
  import { fontOf } from "../lib/fonts.mjs";
2
+ import { READING, inlineLength, inlinePrefix } from "../lib/reading.mjs";
3
+ import { useReadingPage } from "../lib/useReadingPage.mjs";
4
+ import { ShowMore } from "./ShowMore.mjs";
2
5
  import { CodeBlock } from "./CodeBlock.mjs";
3
6
  import { parseMarkdown } from "../lib/markdown.mjs";
4
7
  import { View } from "react-native-unistyles/components/native/View";
8
+ import { Text } from "react-native-unistyles/components/native/Text";
5
9
  import { StyleSheet } from "react-native-unistyles";
6
10
  import { Linking } from "react-native";
7
- import { Text } from "react-native-unistyles/components/native/Text";
8
- import { createContext, useContext, useMemo } from "react";
11
+ import { createContext, memo, useContext, useEffect, useMemo, useState } from "react";
9
12
  import { jsx, jsxs } from "react/jsx-runtime";
13
+ import { ScrollView } from "react-native-unistyles/components/native/ScrollView";
14
+ import { Image } from "react-native-unistyles/components/native/Image";
10
15
 
11
16
  //#region src/components/Markdown.tsx
12
17
  /** Passed by context so the inline renderers stay module functions. */
18
+ const InitialPageContext = createContext(1);
13
19
  const FileLinkContext = createContext(void 0);
20
+ const ImageContext = createContext(void 0);
14
21
  const URL_OR_ANCHOR = /^(?:[a-z][a-z\d+.-]*:|\/\/|#|\?)/i;
22
+ /** Sources an Image may load as written; any other scheme stays its alt text. */
23
+ const DIRECT_IMAGE = /^(?:https?:|data:image\/)/i;
24
+ /** Until the image reports its size, it holds a landscape box rather than collapsing. */
25
+ const PLACEHOLDER_RATIO = 16 / 9;
15
26
  function decoded(href) {
16
27
  try {
17
28
  return decodeURIComponent(href);
@@ -19,12 +30,12 @@ function decoded(href) {
19
30
  return;
20
31
  }
21
32
  }
22
- function InlineCode({ text }) {
33
+ function InlineCode({ text, originalText = text }) {
23
34
  const onFileLink = useContext(FileLinkContext);
24
- const open = text.includes("\n") ? void 0 : onFileLink?.(text);
35
+ const open = originalText.includes("\n") ? void 0 : onFileLink?.(originalText);
25
36
  if (open !== void 0) return /* @__PURE__ */ jsx(Text, {
26
37
  accessibilityRole: "link",
27
- accessibilityHint: `open ${text}`,
38
+ accessibilityHint: `open ${originalText}`,
28
39
  onPress: open,
29
40
  style: [styles.code, styles.fileLink],
30
41
  children: text
@@ -49,11 +60,81 @@ function InlineLink({ href, children }) {
49
60
  children
50
61
  });
51
62
  }
63
+ /** One image: a file path through the host's loader, or a web or data address as written. */
64
+ function MarkdownImage({ src, alt }) {
65
+ const loader = useContext(ImageContext);
66
+ const source = src.startsWith("@artifact:") ? src.slice(1) : src;
67
+ const path = URL_OR_ANCHOR.test(source) && !source.startsWith("artifact:") ? void 0 : decoded(source.split(/[?#]/u, 1)[0]) ?? "";
68
+ const [loaded, setLoaded] = useState();
69
+ const [ratio, setRatio] = useState(PLACEHOLDER_RATIO);
70
+ useEffect(() => {
71
+ if (loader === void 0 || path === void 0) return;
72
+ let active = true;
73
+ let asset;
74
+ Promise.resolve().then(() => {
75
+ if (path === "") throw new Error("Invalid image path.");
76
+ return loader(path);
77
+ }).then((result) => {
78
+ if (!active) return result.dispose();
79
+ asset = result;
80
+ setLoaded({
81
+ path,
82
+ url: result.url
83
+ });
84
+ }).catch(() => {
85
+ if (active) setLoaded({
86
+ path,
87
+ failed: true
88
+ });
89
+ });
90
+ return () => {
91
+ active = false;
92
+ asset?.dispose();
93
+ };
94
+ }, [path, loader]);
95
+ const current = loaded?.path === path ? loaded : void 0;
96
+ const uri = path === void 0 ? DIRECT_IMAGE.test(src) ? src : void 0 : current?.url;
97
+ if (uri === void 0 || current?.failed) {
98
+ const waiting = path !== void 0 && loader !== void 0 && current === void 0;
99
+ return /* @__PURE__ */ jsxs(Text, {
100
+ style: [styles.prose, styles.imageState],
101
+ accessibilityRole: waiting ? "text" : "alert",
102
+ children: [
103
+ alt || path || "Image",
104
+ " (",
105
+ waiting ? "loading…" : "unavailable",
106
+ ")"
107
+ ]
108
+ });
109
+ }
110
+ return /* @__PURE__ */ jsx(Image, {
111
+ source: { uri },
112
+ accessibilityLabel: alt || "Image",
113
+ accessibilityIgnoresInvertColors: true,
114
+ resizeMode: "contain",
115
+ onLoad: ({ nativeEvent }) => {
116
+ const fit = (width, height) => {
117
+ if (width > 0 && height > 0) setRatio(width / height);
118
+ };
119
+ const size = nativeEvent?.source;
120
+ if (size !== void 0) fit(size.width, size.height);
121
+ else Image.getSize(uri, fit, () => void 0);
122
+ },
123
+ onError: () => setLoaded({
124
+ path: path ?? src,
125
+ failed: true
126
+ }),
127
+ style: [styles.image, { aspectRatio: ratio }]
128
+ });
129
+ }
52
130
  function renderInline(nodes) {
53
131
  return nodes.map((node, index) => {
54
132
  switch (node.type) {
55
133
  case "text": return node.text;
56
- case "code": return /* @__PURE__ */ jsx(InlineCode, { text: node.text }, index);
134
+ case "code": return /* @__PURE__ */ jsx(InlineCode, {
135
+ text: node.text,
136
+ originalText: node.originalText
137
+ }, index);
57
138
  case "strong": return /* @__PURE__ */ jsx(Text, {
58
139
  style: styles.strong,
59
140
  children: renderInline(node.children)
@@ -66,62 +147,236 @@ function renderInline(nodes) {
66
147
  href: node.href,
67
148
  children: renderInline(node.children)
68
149
  }, index);
150
+ case "image": return node.alt;
151
+ }
152
+ });
153
+ }
154
+ /**
155
+ * A table read column by column: every cell keeps to one line inside the sideways scroll, so each
156
+ * column takes its widest cell and the rows line up without a table layout.
157
+ */
158
+ function MarkdownTable({ header, rows }) {
159
+ const initialPage = useContext(InitialPageContext);
160
+ const [rowPage, setRows] = useState(initialPage);
161
+ const [columnPage, setColumns] = useState(initialPage);
162
+ const [cellPage, setCells] = useState(initialPage);
163
+ const visibleRows = rows.slice(0, READING.rows * Math.max(initialPage, rowPage));
164
+ const visibleHeader = header.slice(0, READING.columns * Math.max(initialPage, columnPage));
165
+ const limit = READING.cell * Math.max(initialPage, cellPage);
166
+ const clipped = [visibleHeader, ...visibleRows.map((row) => row.slice(0, visibleHeader.length))].some((row) => row.some((cell) => inlineLength(cell) > limit));
167
+ return /* @__PURE__ */ jsxs(View, {
168
+ style: styles.root,
169
+ children: [
170
+ /* @__PURE__ */ jsx(ScrollView, {
171
+ horizontal: true,
172
+ showsHorizontalScrollIndicator: false,
173
+ children: /* @__PURE__ */ jsx(View, {
174
+ style: styles.table,
175
+ children: visibleHeader.map((cell, column) => /* @__PURE__ */ jsxs(View, { children: [/* @__PURE__ */ jsxs(Text, {
176
+ style: [
177
+ styles.prose,
178
+ styles.cell,
179
+ styles.headCell
180
+ ],
181
+ children: [renderInline(inlinePrefix(cell, limit)), inlineLength(cell) > limit ? "…" : ""]
182
+ }), visibleRows.map((row, index) => /* @__PURE__ */ jsxs(Text, {
183
+ style: [styles.prose, styles.cell],
184
+ children: [renderInline(inlinePrefix(row[column] ?? [], limit)), inlineLength(row[column] ?? []) > limit ? "…" : ""]
185
+ }, index))] }, column))
186
+ })
187
+ }),
188
+ /* @__PURE__ */ jsxs(Text, {
189
+ style: styles.meta,
190
+ children: [
191
+ visibleRows.length,
192
+ " of ",
193
+ rows.length,
194
+ " rows · ",
195
+ visibleHeader.length,
196
+ " of ",
197
+ header.length,
198
+ " columns",
199
+ clipped ? ` · Cells: first ${limit} characters` : ""
200
+ ]
201
+ }),
202
+ /* @__PURE__ */ jsxs(View, {
203
+ style: styles.actions,
204
+ children: [
205
+ visibleRows.length < rows.length ? /* @__PURE__ */ jsx(ShowMore, {
206
+ label: "Show more rows",
207
+ onPress: () => setRows((page) => page + 1)
208
+ }) : null,
209
+ visibleHeader.length < header.length ? /* @__PURE__ */ jsx(ShowMore, {
210
+ label: "Show more columns",
211
+ onPress: () => setColumns((page) => page + 1)
212
+ }) : null,
213
+ clipped ? /* @__PURE__ */ jsx(ShowMore, {
214
+ label: "Show more cell text",
215
+ onPress: () => setCells((page) => page + 1)
216
+ }) : null
217
+ ]
218
+ })
219
+ ]
220
+ });
221
+ }
222
+ function Blocks({ blocks, quoted = false }) {
223
+ const initialPage = useContext(InitialPageContext);
224
+ const [page, setPage] = useState(initialPage);
225
+ const visible = blocks.slice(0, READING.parts * Math.max(initialPage, page));
226
+ return /* @__PURE__ */ jsxs(InitialPageContext.Provider, {
227
+ value: Math.max(initialPage, page),
228
+ children: [visible.map((block, index) => /* @__PURE__ */ jsx(BoundedBlock, {
229
+ block,
230
+ first: index === 0,
231
+ quoted
232
+ }, index)), visible.length < blocks.length ? /* @__PURE__ */ jsx(ShowMore, {
233
+ label: "Show more",
234
+ summary: `${visible.length} of ${blocks.length} parts`,
235
+ onPress: () => setPage(Infinity)
236
+ }) : null]
237
+ });
238
+ }
239
+ function BoundedBlock({ block, ...props }) {
240
+ const initialPage = useContext(InitialPageContext);
241
+ const [revealedPage, setPage] = useState(initialPage);
242
+ const page = Math.max(initialPage, revealedPage);
243
+ const limit = READING.characters * page;
244
+ let visible = block;
245
+ let total = 0;
246
+ let shown = 0;
247
+ if (block.type === "heading" || block.type === "paragraph") {
248
+ total = inlineLength(block.children);
249
+ const children = inlinePrefix(block.children, limit);
250
+ shown = inlineLength(children);
251
+ visible = {
252
+ ...block,
253
+ children
254
+ };
255
+ } else if (block.type === "list") {
256
+ total = block.items.reduce((sum, item) => sum + inlineLength(item), 0);
257
+ let remaining = limit;
258
+ const items = [];
259
+ for (const item of block.items.slice(0, READING.parts * page)) {
260
+ if (remaining <= 0) break;
261
+ const next = inlinePrefix(item, remaining);
262
+ items.push(next);
263
+ const length = inlineLength(next);
264
+ shown += length;
265
+ remaining -= length;
69
266
  }
267
+ visible = {
268
+ ...block,
269
+ items
270
+ };
271
+ }
272
+ const more = shown < total || block.type === "list" && visible.type === "list" && visible.items.length < block.items.length;
273
+ return /* @__PURE__ */ jsxs(View, {
274
+ style: styles.root,
275
+ children: [/* @__PURE__ */ jsx(Block, {
276
+ block: visible,
277
+ ...props
278
+ }), more ? /* @__PURE__ */ jsx(ShowMore, {
279
+ label: "Show more text",
280
+ summary: `${shown} of ${total} characters`,
281
+ onPress: () => setPage(Infinity)
282
+ }) : null]
70
283
  });
71
284
  }
72
- function Block({ block, first }) {
285
+ function Block({ block, first, quoted = false }) {
286
+ const initialPage = useContext(InitialPageContext);
287
+ const prose = [styles.prose, quoted && styles.quoted];
73
288
  switch (block.type) {
74
289
  case "heading": return /* @__PURE__ */ jsx(Text, {
75
290
  accessibilityRole: "header",
76
291
  style: [
77
- styles.prose,
292
+ ...prose,
78
293
  styles.heading(block.level),
79
- first && styles.firstHeading
294
+ first && styles.firstHeading,
295
+ quoted && styles.quoted
80
296
  ],
81
297
  children: renderInline(block.children)
82
298
  });
83
- case "paragraph": return /* @__PURE__ */ jsx(Text, {
84
- style: styles.prose,
85
- children: renderInline(block.children)
86
- });
299
+ case "paragraph": {
300
+ const parts = [];
301
+ let run = [];
302
+ const flush = () => {
303
+ if (run.length > 0) parts.push(/* @__PURE__ */ jsx(Text, {
304
+ style: prose,
305
+ children: renderInline(run)
306
+ }, parts.length));
307
+ run = [];
308
+ };
309
+ for (const node of block.children) {
310
+ if (node.type !== "image") {
311
+ run.push(node);
312
+ continue;
313
+ }
314
+ flush();
315
+ parts.push(/* @__PURE__ */ jsx(MarkdownImage, {
316
+ src: node.src,
317
+ alt: node.alt
318
+ }, parts.length));
319
+ }
320
+ flush();
321
+ return parts.length === 1 ? parts[0] : /* @__PURE__ */ jsx(View, {
322
+ style: styles.root,
323
+ children: parts
324
+ });
325
+ }
87
326
  case "list": return /* @__PURE__ */ jsx(View, {
88
327
  accessibilityRole: "list",
89
328
  style: styles.list,
90
329
  children: block.items.map((item, index) => /* @__PURE__ */ jsxs(View, {
91
330
  style: styles.item,
92
331
  children: [/* @__PURE__ */ jsx(Text, {
93
- style: [styles.prose, styles.marker],
332
+ style: [...prose, styles.marker],
94
333
  children: block.ordered ? `${block.start + index}.` : "•"
95
334
  }), /* @__PURE__ */ jsx(Text, {
96
- style: [styles.prose, styles.itemText],
335
+ style: [...prose, styles.itemText],
97
336
  children: renderInline(item)
98
337
  })]
99
338
  }, index))
100
339
  });
101
340
  case "code": return /* @__PURE__ */ jsx(CodeBlock, {
102
341
  text: block.text,
103
- language: block.language
342
+ language: block.language,
343
+ initialPage
104
344
  });
105
345
  case "rule": return /* @__PURE__ */ jsx(View, {
106
346
  accessible: false,
107
347
  style: styles.rule
108
348
  });
349
+ case "quote": return /* @__PURE__ */ jsx(View, {
350
+ style: [styles.root, styles.quote],
351
+ children: /* @__PURE__ */ jsx(Blocks, {
352
+ blocks: block.children,
353
+ quoted: true
354
+ })
355
+ });
356
+ case "table": return /* @__PURE__ */ jsx(MarkdownTable, {
357
+ header: block.header,
358
+ rows: block.rows
359
+ });
109
360
  }
110
361
  }
111
362
  /** Markdown in Po's shared presentation, parsed by the package's own small parser. */
112
- function Markdown({ text, onFileLink }) {
363
+ const Markdown = memo(function Markdown({ text, onFileLink, loadImage, initialPage = 1 }) {
113
364
  const blocks = useMemo(() => parseMarkdown(text), [text]);
114
- return /* @__PURE__ */ jsx(FileLinkContext.Provider, {
115
- value: onFileLink,
116
- children: /* @__PURE__ */ jsx(View, {
117
- style: styles.root,
118
- children: blocks.map((block, index) => /* @__PURE__ */ jsx(Block, {
119
- block,
120
- first: index === 0
121
- }, index))
365
+ const { generation } = useReadingPage(text);
366
+ return /* @__PURE__ */ jsx(InitialPageContext.Provider, {
367
+ value: initialPage,
368
+ children: /* @__PURE__ */ jsx(FileLinkContext.Provider, {
369
+ value: onFileLink,
370
+ children: /* @__PURE__ */ jsx(ImageContext.Provider, {
371
+ value: loadImage,
372
+ children: /* @__PURE__ */ jsx(View, {
373
+ style: styles.root,
374
+ children: /* @__PURE__ */ jsx(Blocks, { blocks }, generation)
375
+ })
376
+ })
122
377
  })
123
378
  });
124
- }
379
+ });
125
380
  /**
126
381
  * Headings step up from the prose and never shrink below it; h4 to h6 keep
127
382
  * the prose size and lean on weight, fading from `hi` to `dim`.
@@ -151,6 +406,17 @@ const HEADING_INK = {
151
406
  6: "dim"
152
407
  };
153
408
  const styles = StyleSheet.create((theme) => ({
409
+ meta: {
410
+ color: theme.colors.dim,
411
+ fontFamily: fontOf(theme.fontFamily.sans),
412
+ fontSize: theme.fontSize.sm,
413
+ lineHeight: theme.lineHeight.sm,
414
+ uni__dependencies: [0]
415
+ },
416
+ actions: {
417
+ flexDirection: "row",
418
+ flexWrap: "wrap"
419
+ },
154
420
  root: {
155
421
  minWidth: 0,
156
422
  gap: theme.spacing(2),
@@ -211,6 +477,49 @@ const styles = StyleSheet.create((theme) => ({
211
477
  height: 1,
212
478
  backgroundColor: theme.colors["border-soft"],
213
479
  uni__dependencies: [0]
480
+ },
481
+ quote: {
482
+ borderLeftWidth: 2,
483
+ borderLeftColor: theme.colors.border,
484
+ paddingLeft: theme.spacing(3),
485
+ uni__dependencies: [0]
486
+ },
487
+ quoted: {
488
+ color: theme.colors.dim,
489
+ uni__dependencies: [0]
490
+ },
491
+ table: {
492
+ flexDirection: "row",
493
+ borderTopWidth: 1,
494
+ borderLeftWidth: 1,
495
+ borderColor: theme.colors.border,
496
+ uni__dependencies: [0]
497
+ },
498
+ cell: {
499
+ paddingHorizontal: theme.spacing(2),
500
+ paddingVertical: theme.spacing(1),
501
+ borderRightWidth: 1,
502
+ borderBottomWidth: 1,
503
+ borderColor: theme.colors.border,
504
+ uni__dependencies: [0]
505
+ },
506
+ headCell: {
507
+ backgroundColor: theme.colors.deep,
508
+ fontWeight: theme.fontWeight.semibold,
509
+ color: theme.colors.hi,
510
+ uni__dependencies: [0]
511
+ },
512
+ image: {
513
+ width: "100%",
514
+ maxHeight: 480,
515
+ borderRadius: theme.borderRadius.md,
516
+ borderWidth: 1,
517
+ borderColor: theme.colors.border,
518
+ uni__dependencies: [0]
519
+ },
520
+ imageState: {
521
+ color: theme.colors.dim,
522
+ uni__dependencies: [0]
214
523
  }
215
524
  }));
216
525