@agimon-ai/po-native-components 0.0.0-alpha.21 → 0.0.0-alpha.210

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 (195) hide show
  1. package/LICENSE +21 -149
  2. package/README.md +9 -51
  3. package/dist/components/AgentAvatar.d.mts +19 -0
  4. package/dist/components/AgentAvatar.d.mts.map +1 -0
  5. package/dist/components/AgentAvatar.mjs +88 -0
  6. package/dist/components/AgentAvatar.mjs.map +1 -0
  7. package/dist/components/AnnotationSurface.d.mts +69 -0
  8. package/dist/components/AnnotationSurface.d.mts.map +1 -0
  9. package/dist/components/AnnotationSurface.mjs +431 -0
  10. package/dist/components/AnnotationSurface.mjs.map +1 -0
  11. package/dist/components/Badge.d.mts +1 -1
  12. package/dist/components/Badge.mjs +1 -1
  13. package/dist/components/Button.mjs +3 -3
  14. package/dist/components/Button.mjs.map +1 -1
  15. package/dist/components/CodeBlock.d.mts +3 -1
  16. package/dist/components/CodeBlock.d.mts.map +1 -1
  17. package/dist/components/CodeBlock.mjs +42 -47
  18. package/dist/components/CodeBlock.mjs.map +1 -1
  19. package/dist/components/ComputerRow.d.mts +15 -0
  20. package/dist/components/ComputerRow.d.mts.map +1 -0
  21. package/dist/components/ComputerRow.mjs +107 -0
  22. package/dist/components/ComputerRow.mjs.map +1 -0
  23. package/dist/components/CopyButton.d.mts +13 -0
  24. package/dist/components/CopyButton.d.mts.map +1 -0
  25. package/dist/components/CopyButton.mjs +49 -0
  26. package/dist/components/CopyButton.mjs.map +1 -0
  27. package/dist/components/CountBadge.d.mts +15 -0
  28. package/dist/components/CountBadge.d.mts.map +1 -0
  29. package/dist/components/CountBadge.mjs +49 -0
  30. package/dist/components/CountBadge.mjs.map +1 -0
  31. package/dist/components/CtaCard.d.mts +19 -0
  32. package/dist/components/CtaCard.d.mts.map +1 -0
  33. package/dist/components/CtaCard.mjs +92 -0
  34. package/dist/components/CtaCard.mjs.map +1 -0
  35. package/dist/components/Dialog.d.mts +2 -2
  36. package/dist/components/Dialog.d.mts.map +1 -1
  37. package/dist/components/Dialog.mjs +16 -10
  38. package/dist/components/Dialog.mjs.map +1 -1
  39. package/dist/components/Dot.d.mts +1 -1
  40. package/dist/components/Dot.mjs +2 -2
  41. package/dist/components/DropdownMenu.d.mts +3 -1
  42. package/dist/components/DropdownMenu.d.mts.map +1 -1
  43. package/dist/components/DropdownMenu.mjs +21 -14
  44. package/dist/components/DropdownMenu.mjs.map +1 -1
  45. package/dist/components/EmptyState.d.mts +31 -3
  46. package/dist/components/EmptyState.d.mts.map +1 -1
  47. package/dist/components/EmptyState.mjs +303 -29
  48. package/dist/components/EmptyState.mjs.map +1 -1
  49. package/dist/components/FileList.d.mts +48 -0
  50. package/dist/components/FileList.d.mts.map +1 -0
  51. package/dist/components/FileList.mjs +737 -0
  52. package/dist/components/FileList.mjs.map +1 -0
  53. package/dist/components/FilePreview.d.mts +33 -0
  54. package/dist/components/FilePreview.d.mts.map +1 -0
  55. package/dist/components/FilePreview.mjs +102 -0
  56. package/dist/components/FilePreview.mjs.map +1 -0
  57. package/dist/components/FileViewer.d.mts +57 -0
  58. package/dist/components/FileViewer.d.mts.map +1 -0
  59. package/dist/components/FileViewer.mjs +345 -0
  60. package/dist/components/FileViewer.mjs.map +1 -0
  61. package/dist/components/HashlineLines.d.mts +13 -0
  62. package/dist/components/HashlineLines.d.mts.map +1 -0
  63. package/dist/components/HashlineLines.mjs +153 -0
  64. package/dist/components/HashlineLines.mjs.map +1 -0
  65. package/dist/components/HostFilter.d.mts +17 -0
  66. package/dist/components/HostFilter.d.mts.map +1 -0
  67. package/dist/components/HostFilter.mjs +68 -0
  68. package/dist/components/HostFilter.mjs.map +1 -0
  69. package/dist/components/HostTag.d.mts +7 -0
  70. package/dist/components/HostTag.d.mts.map +1 -0
  71. package/dist/components/HostTag.mjs +48 -0
  72. package/dist/components/HostTag.mjs.map +1 -0
  73. package/dist/components/InfoStrip.d.mts +9 -0
  74. package/dist/components/InfoStrip.d.mts.map +1 -0
  75. package/dist/components/InfoStrip.mjs +53 -0
  76. package/dist/components/InfoStrip.mjs.map +1 -0
  77. package/dist/components/Input.d.mts +3 -1
  78. package/dist/components/Input.d.mts.map +1 -1
  79. package/dist/components/Input.mjs +4 -3
  80. package/dist/components/Input.mjs.map +1 -1
  81. package/dist/components/Label.mjs +1 -1
  82. package/dist/components/LinkText.d.mts +13 -0
  83. package/dist/components/LinkText.d.mts.map +1 -0
  84. package/dist/components/LinkText.mjs +32 -0
  85. package/dist/components/LinkText.mjs.map +1 -0
  86. package/dist/components/List.d.mts.map +1 -1
  87. package/dist/components/List.mjs +50 -11
  88. package/dist/components/List.mjs.map +1 -1
  89. package/dist/components/LiveDuration.d.mts +30 -0
  90. package/dist/components/LiveDuration.d.mts.map +1 -0
  91. package/dist/components/LiveDuration.mjs +67 -0
  92. package/dist/components/LiveDuration.mjs.map +1 -0
  93. package/dist/components/LoadingState.d.mts +17 -0
  94. package/dist/components/LoadingState.d.mts.map +1 -0
  95. package/dist/components/LoadingState.mjs +90 -0
  96. package/dist/components/LoadingState.mjs.map +1 -0
  97. package/dist/components/Markdown.d.mts +24 -2
  98. package/dist/components/Markdown.d.mts.map +1 -1
  99. package/dist/components/Markdown.mjs +356 -27
  100. package/dist/components/Markdown.mjs.map +1 -1
  101. package/dist/components/MessageItem.d.mts +10 -15
  102. package/dist/components/MessageItem.d.mts.map +1 -1
  103. package/dist/components/MessageItem.mjs +94 -68
  104. package/dist/components/MessageItem.mjs.map +1 -1
  105. package/dist/components/NativeShellState.d.mts +30 -0
  106. package/dist/components/NativeShellState.d.mts.map +1 -0
  107. package/dist/components/NativeShellState.mjs +61 -0
  108. package/dist/components/NativeShellState.mjs.map +1 -0
  109. package/dist/components/RailItem.d.mts +13 -0
  110. package/dist/components/RailItem.d.mts.map +1 -0
  111. package/dist/components/RailItem.mjs +61 -0
  112. package/dist/components/RailItem.mjs.map +1 -0
  113. package/dist/components/ReferenceChip.d.mts +18 -0
  114. package/dist/components/ReferenceChip.d.mts.map +1 -0
  115. package/dist/components/ReferenceChip.mjs +38 -0
  116. package/dist/components/ReferenceChip.mjs.map +1 -0
  117. package/dist/components/SectionLabel.mjs +1 -1
  118. package/dist/components/SeekBar.d.mts +17 -0
  119. package/dist/components/SeekBar.d.mts.map +1 -0
  120. package/dist/components/SeekBar.mjs +97 -0
  121. package/dist/components/SeekBar.mjs.map +1 -0
  122. package/dist/components/Select.d.mts +39 -0
  123. package/dist/components/Select.d.mts.map +1 -0
  124. package/dist/components/Select.mjs +288 -0
  125. package/dist/components/Select.mjs.map +1 -0
  126. package/dist/components/Sheet.d.mts +17 -2
  127. package/dist/components/Sheet.d.mts.map +1 -1
  128. package/dist/components/Sheet.mjs +34 -11
  129. package/dist/components/Sheet.mjs.map +1 -1
  130. package/dist/components/SheetFrame.mjs +149 -28
  131. package/dist/components/SheetFrame.mjs.map +1 -1
  132. package/dist/components/SheetList.d.mts +14 -0
  133. package/dist/components/SheetList.d.mts.map +1 -0
  134. package/dist/components/SheetList.mjs +34 -0
  135. package/dist/components/SheetList.mjs.map +1 -0
  136. package/dist/components/ShowMore.d.mts +10 -0
  137. package/dist/components/ShowMore.d.mts.map +1 -0
  138. package/dist/components/ShowMore.mjs +44 -0
  139. package/dist/components/ShowMore.mjs.map +1 -0
  140. package/dist/components/Spinner.d.mts +1 -1
  141. package/dist/components/StatusBadge.d.mts +1 -1
  142. package/dist/components/Switch.d.mts +14 -0
  143. package/dist/components/Switch.d.mts.map +1 -0
  144. package/dist/components/Switch.mjs +37 -0
  145. package/dist/components/Switch.mjs.map +1 -0
  146. package/dist/components/SyntaxLine.d.mts +19 -0
  147. package/dist/components/SyntaxLine.d.mts.map +1 -0
  148. package/dist/components/SyntaxLine.mjs +134 -0
  149. package/dist/components/SyntaxLine.mjs.map +1 -0
  150. package/dist/components/Tabs.d.mts.map +1 -1
  151. package/dist/components/Tabs.mjs +8 -7
  152. package/dist/components/Tabs.mjs.map +1 -1
  153. package/dist/components/ToolPathLink.d.mts +10 -0
  154. package/dist/components/ToolPathLink.d.mts.map +1 -0
  155. package/dist/components/ToolPathLink.mjs +42 -0
  156. package/dist/components/ToolPathLink.mjs.map +1 -0
  157. package/dist/components/ToolResultImage.d.mts +21 -0
  158. package/dist/components/ToolResultImage.d.mts.map +1 -0
  159. package/dist/components/ToolResultImage.mjs +60 -0
  160. package/dist/components/ToolResultImage.mjs.map +1 -0
  161. package/dist/icons/IconColorContext.d.mts +2 -1
  162. package/dist/icons/IconColorContext.d.mts.map +1 -1
  163. package/dist/icons/IconColorContext.mjs.map +1 -1
  164. package/dist/icons/iconGlyphs.d.mts +132 -0
  165. package/dist/icons/iconGlyphs.d.mts.map +1 -1
  166. package/dist/icons/iconGlyphs.mjs +132 -0
  167. package/dist/icons/iconGlyphs.mjs.map +1 -1
  168. package/dist/icons/icons.d.mts +133 -1
  169. package/dist/icons/icons.d.mts.map +1 -1
  170. package/dist/icons/icons.mjs +35 -2
  171. package/dist/icons/icons.mjs.map +1 -1
  172. package/dist/index.d.mts +31 -7
  173. package/dist/index.mjs +36 -12
  174. package/dist/lib/fileKindLabel.mjs +17 -0
  175. package/dist/lib/fileKindLabel.mjs.map +1 -0
  176. package/dist/lib/fonts.d.mts +3 -1
  177. package/dist/lib/fonts.d.mts.map +1 -1
  178. package/dist/lib/fonts.mjs +4 -2
  179. package/dist/lib/fonts.mjs.map +1 -1
  180. package/dist/lib/insideSheet.d.mts +10 -0
  181. package/dist/lib/insideSheet.d.mts.map +1 -0
  182. package/dist/lib/markdown.mjs +310 -23
  183. package/dist/lib/markdown.mjs.map +1 -1
  184. package/dist/lib/reading.mjs +60 -0
  185. package/dist/lib/reading.mjs.map +1 -0
  186. package/dist/lib/useControllable.mjs +14 -6
  187. package/dist/lib/useControllable.mjs.map +1 -1
  188. package/dist/lib/useReadingPage.mjs +33 -0
  189. package/dist/lib/useReadingPage.mjs.map +1 -0
  190. package/dist/po-runtime-identity.json +1 -0
  191. package/dist/shell.d.mts +6 -0
  192. package/dist/shell.mjs +7 -0
  193. package/locales/vi.json +112 -0
  194. package/locales/zh-CN.json +112 -0
  195. package/package.json +43 -30
@@ -0,0 +1,345 @@
1
+ import { fontOf } from "../lib/fonts.mjs";
2
+ import { Button } from "./Button.mjs";
3
+ import { CloseIcon, DownloadIcon } from "../icons/icons.mjs";
4
+ import { CopyButton } from "./CopyButton.mjs";
5
+ import { EmptyState } from "./EmptyState.mjs";
6
+ import { fileKindLabel } from "../lib/fileKindLabel.mjs";
7
+ import { FilePreview } from "./FilePreview.mjs";
8
+ import { fileKind, filePreviewMode, modifiedLabel, sizeLabel } from "@agimon-ai/po-web-components/text";
9
+ import { View } from "react-native-unistyles/components/native/View";
10
+ import { Text } from "react-native-unistyles/components/native/Text";
11
+ import { StyleSheet } from "react-native-unistyles";
12
+ import { useEffect, useRef, useState } from "react";
13
+ import { jsx, jsxs } from "react/jsx-runtime";
14
+ import { useT } from "@agimon-ai/po-core/native";
15
+ import { ScrollView } from "react-native-unistyles/components/native/ScrollView";
16
+
17
+ //#region src/components/FileViewer.tsx
18
+ /** One file on the phone: header or top-bar download, the bounded preview, and the path strip. */
19
+ function FileViewer(props) {
20
+ const t = useT();
21
+ const { path, item, scopeKey, loadPreview, loadMedia, prepareSave, setTabHeader, unavailable, status } = props;
22
+ const hasStatus = status !== void 0 && status !== null;
23
+ const version = `${item?.modifiedAt ?? ""}:${item?.size ?? ""}`;
24
+ const downloadKey = `${scopeKey}:${path}`;
25
+ const key = `${downloadKey}:${version}`;
26
+ const [loaded, setLoaded] = useState();
27
+ const [attempt, setAttempt] = useState(0);
28
+ const loaders = useRef({
29
+ loadPreview,
30
+ loadMedia
31
+ });
32
+ useEffect(() => {
33
+ loaders.current = {
34
+ loadPreview,
35
+ loadMedia
36
+ };
37
+ });
38
+ const showsMedia = props.renderMediaPreview !== void 0;
39
+ useEffect(() => {
40
+ if (unavailable || hasStatus) return;
41
+ const controller = new AbortController();
42
+ loaders.current.loadPreview(controller.signal).then(async (preview) => {
43
+ if (controller.signal.aborted) return;
44
+ setLoaded({
45
+ key,
46
+ preview
47
+ });
48
+ const media = loaders.current.loadMedia;
49
+ if (filePreviewMode(path) !== "media" || !showsMedia || !media) return;
50
+ try {
51
+ const bytes = await media(controller.signal);
52
+ if (!controller.signal.aborted) setLoaded({
53
+ key,
54
+ preview,
55
+ media: bytes
56
+ });
57
+ } catch (error) {
58
+ if (!controller.signal.aborted) setLoaded({
59
+ key,
60
+ preview,
61
+ mediaError: error instanceof Error ? error.message : String(error)
62
+ });
63
+ }
64
+ }).catch((error) => {
65
+ if (!controller.signal.aborted) setLoaded({
66
+ key,
67
+ error: error instanceof Error ? error.message : String(error)
68
+ });
69
+ });
70
+ return () => controller.abort();
71
+ }, [
72
+ path,
73
+ key,
74
+ showsMedia,
75
+ unavailable,
76
+ hasStatus,
77
+ attempt
78
+ ]);
79
+ const current = loaded?.key === key ? loaded : void 0;
80
+ const downloadController = useRef(void 0);
81
+ const [download, setDownload] = useState();
82
+ const ownDownload = download?.key === downloadKey ? download : void 0;
83
+ useEffect(() => () => {
84
+ downloadController.current?.abort();
85
+ downloadController.current = void 0;
86
+ }, [downloadKey]);
87
+ const saving = ownDownload?.saving === true;
88
+ const canSave = props.nativeSaveFile !== void 0 && prepareSave !== void 0;
89
+ const save = async () => {
90
+ if (unavailable || !props.nativeSaveFile || !prepareSave || downloadController.current) return;
91
+ const controller = new AbortController();
92
+ downloadController.current = controller;
93
+ setDownload({
94
+ key: downloadKey,
95
+ saving: true,
96
+ failed: ownDownload?.failed
97
+ });
98
+ try {
99
+ const file = await prepareSave(controller.signal);
100
+ if (controller.signal.aborted || downloadController.current !== controller) return;
101
+ await props.nativeSaveFile(file);
102
+ if (!controller.signal.aborted && downloadController.current === controller) setDownload({
103
+ key: downloadKey,
104
+ note: t("nativeComponents.fileViewer.saved", "Saved.")
105
+ });
106
+ } catch (error) {
107
+ if (!controller.signal.aborted && downloadController.current === controller) setDownload({
108
+ key: downloadKey,
109
+ failed: error instanceof Error ? error.message : String(error)
110
+ });
111
+ } finally {
112
+ if (downloadController.current === controller) downloadController.current = void 0;
113
+ }
114
+ };
115
+ const cancel = () => {
116
+ downloadController.current?.abort();
117
+ downloadController.current = void 0;
118
+ setDownload({
119
+ key: downloadKey,
120
+ note: t("nativeComponents.fileViewer.cancelled", "Download cancelled.")
121
+ });
122
+ };
123
+ const handlers = useRef({
124
+ save,
125
+ cancel
126
+ });
127
+ useEffect(() => {
128
+ handlers.current = {
129
+ save,
130
+ cancel
131
+ };
132
+ });
133
+ const media = filePreviewMode(path) === "media" && showsMedia && current?.media !== void 0;
134
+ const subtitle = `${fileKindLabel(fileKind(path), t)}${item ? ` · ${sizeLabel(item.size)}` : ""}`;
135
+ const offline = unavailable !== void 0;
136
+ useEffect(() => {
137
+ if (!setTabHeader || media) return;
138
+ setTabHeader({
139
+ subtitle,
140
+ action: canSave ? /* @__PURE__ */ jsx(Button, {
141
+ variant: "ghost",
142
+ size: "icon",
143
+ disabled: offline,
144
+ accessibilityLabel: saving ? t("nativeComponents.fileViewer.cancelDownload", "Cancel download") : t("nativeComponents.fileViewer.download", "Download"),
145
+ onPress: () => saving ? handlers.current.cancel() : void handlers.current.save(),
146
+ children: saving ? /* @__PURE__ */ jsx(CloseIcon, { color: "hi" }) : /* @__PURE__ */ jsx(DownloadIcon, { color: "hi" })
147
+ }) : void 0
148
+ });
149
+ }, [
150
+ setTabHeader,
151
+ media,
152
+ subtitle,
153
+ canSave,
154
+ saving,
155
+ offline
156
+ ]);
157
+ const note = ownDownload?.failed ? /* @__PURE__ */ jsx(EmptyState, {
158
+ size: "compact",
159
+ surface: "plain",
160
+ tone: "error",
161
+ title: t("nativeComponents.fileViewer.saveFailed", "Couldn't save this file"),
162
+ description: ownDownload.failed,
163
+ action: {
164
+ label: t("nativeComponents.fileViewer.retry", "Try again"),
165
+ onAction: () => void save(),
166
+ loading: saving
167
+ }
168
+ }) : ownDownload?.note ? /* @__PURE__ */ jsx(Text, {
169
+ accessibilityLiveRegion: "polite",
170
+ style: styles.meta,
171
+ children: ownDownload.note
172
+ }) : null;
173
+ const body = hasStatus ? status : unavailable ? /* @__PURE__ */ jsx(EmptyState, { title: unavailable }) : current?.error ? /* @__PURE__ */ jsx(EmptyState, {
174
+ tone: "error",
175
+ title: t("nativeComponents.fileViewer.loadFailed", "Couldn't load this file"),
176
+ description: current.error,
177
+ action: {
178
+ label: t("nativeComponents.fileViewer.retry", "Try again"),
179
+ onAction: () => setAttempt((n) => n + 1)
180
+ }
181
+ }) : current?.preview ? /* @__PURE__ */ jsx(FilePreview, {
182
+ preview: current.preview,
183
+ scopeKey,
184
+ renderFilePreview: props.renderFilePreview,
185
+ renderMediaPreview: props.renderMediaPreview,
186
+ media: current.media,
187
+ mediaError: current.mediaError,
188
+ onOpen: props.onOpenPath
189
+ }) : /* @__PURE__ */ jsx(Text, {
190
+ style: styles.meta,
191
+ children: t("nativeComponents.fileViewer.reading", "Reading this file...")
192
+ });
193
+ return /* @__PURE__ */ jsxs(View, {
194
+ style: styles.screen,
195
+ children: [
196
+ props.actions,
197
+ props.note ? /* @__PURE__ */ jsx(Text, {
198
+ accessibilityLiveRegion: "polite",
199
+ style: styles.meta,
200
+ children: props.note
201
+ }) : null,
202
+ media ? /* @__PURE__ */ jsx(View, {
203
+ style: styles.stage,
204
+ children: body
205
+ }) : /* @__PURE__ */ jsxs(ScrollView, {
206
+ style: styles.stage,
207
+ contentContainerStyle: styles.content,
208
+ children: [
209
+ setTabHeader ? null : /* @__PURE__ */ jsx(FileViewerHeader, {
210
+ path,
211
+ size: item?.size,
212
+ saving,
213
+ canSave,
214
+ disabled: offline,
215
+ onDownload: () => void save(),
216
+ onCancel: cancel
217
+ }),
218
+ note,
219
+ body
220
+ ]
221
+ }),
222
+ /* @__PURE__ */ jsx(FilePathStrip, {
223
+ path,
224
+ modifiedAt: item?.modifiedAt
225
+ })
226
+ ]
227
+ });
228
+ }
229
+ /** Where the file lives and when it last changed, pinned under the preview. */
230
+ function FilePathStrip({ path, modifiedAt }) {
231
+ const [now] = useState(Date.now);
232
+ const t = useT();
233
+ return /* @__PURE__ */ jsxs(View, {
234
+ style: styles.strip,
235
+ children: [
236
+ /* @__PURE__ */ jsx(Text, {
237
+ selectable: true,
238
+ numberOfLines: 1,
239
+ ellipsizeMode: "middle",
240
+ style: [styles.path, styles.stripPath],
241
+ children: path
242
+ }),
243
+ /* @__PURE__ */ jsx(CopyButton, {
244
+ text: path,
245
+ label: t("nativeComponents.fileViewer.pathLabel", "path")
246
+ }),
247
+ modifiedAt === void 0 ? null : /* @__PURE__ */ jsx(Text, {
248
+ style: styles.meta,
249
+ children: modifiedLabel(modifiedAt, now)
250
+ })
251
+ ]
252
+ });
253
+ }
254
+ /** The viewer's quiet header: where the file lives, what it is, and the one action on it. */
255
+ function FileViewerHeader({ path, size, saving, canSave, disabled, onDownload, onCancel }) {
256
+ const t = useT();
257
+ return /* @__PURE__ */ jsxs(View, {
258
+ style: styles.header,
259
+ children: [
260
+ /* @__PURE__ */ jsxs(View, {
261
+ style: styles.label,
262
+ children: [/* @__PURE__ */ jsx(Text, {
263
+ selectable: true,
264
+ numberOfLines: 1,
265
+ ellipsizeMode: "middle",
266
+ style: styles.path,
267
+ children: path
268
+ }), /* @__PURE__ */ jsxs(Text, {
269
+ style: styles.meta,
270
+ children: [
271
+ fileKindLabel(fileKind(path), t),
272
+ size === void 0 ? "" : ` · ${sizeLabel(size)}`,
273
+ canSave ? "" : ` · ${t("nativeComponents.fileViewer.cannotSave", "This host cannot save downloads.")}`
274
+ ]
275
+ })]
276
+ }),
277
+ canSave && saving ? /* @__PURE__ */ jsx(Button, {
278
+ variant: "ghost",
279
+ size: "sm",
280
+ onPress: onCancel,
281
+ children: t("nativeComponents.fileViewer.cancel", "Cancel")
282
+ }) : null,
283
+ canSave ? /* @__PURE__ */ jsx(Button, {
284
+ variant: "outline",
285
+ size: "sm",
286
+ disabled: saving || disabled,
287
+ onPress: onDownload,
288
+ children: t("nativeComponents.fileViewer.download", "Download")
289
+ }) : null
290
+ ]
291
+ });
292
+ }
293
+ const styles = StyleSheet.create((theme, rt) => ({
294
+ screen: { flex: 1 },
295
+ stage: { flex: 1 },
296
+ content: {
297
+ padding: theme.spacing(4),
298
+ gap: theme.spacing(3),
299
+ uni__dependencies: [0]
300
+ },
301
+ strip: {
302
+ flexDirection: "row",
303
+ alignItems: "center",
304
+ gap: theme.spacing(2),
305
+ paddingHorizontal: theme.spacing(4),
306
+ paddingTop: theme.spacing(2),
307
+ paddingBottom: theme.spacing(2) + rt.insets.bottom,
308
+ borderTopWidth: 1,
309
+ borderTopColor: theme.colors["border-soft"],
310
+ backgroundColor: theme.colors.bg,
311
+ uni__dependencies: [0, 9]
312
+ },
313
+ stripPath: { flexShrink: 1 },
314
+ header: {
315
+ flexDirection: "row",
316
+ alignItems: "center",
317
+ gap: theme.spacing(2),
318
+ paddingBottom: theme.spacing(3),
319
+ borderBottomWidth: 1,
320
+ borderBottomColor: theme.colors["border-soft"],
321
+ uni__dependencies: [0]
322
+ },
323
+ label: {
324
+ flex: 1,
325
+ minWidth: 0,
326
+ gap: theme.spacing(.5),
327
+ uni__dependencies: [0]
328
+ },
329
+ path: {
330
+ fontFamily: fontOf(theme.fontFamily.mono),
331
+ fontSize: theme.fontSize.sm,
332
+ color: theme.colors.dim,
333
+ uni__dependencies: [0]
334
+ },
335
+ meta: {
336
+ fontFamily: fontOf(theme.fontFamily.sans),
337
+ fontSize: theme.fontSize.sm,
338
+ color: theme.colors.dim,
339
+ uni__dependencies: [0]
340
+ }
341
+ }));
342
+
343
+ //#endregion
344
+ export { FilePathStrip, FileViewer, FileViewerHeader };
345
+ //# sourceMappingURL=FileViewer.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileViewer.mjs","names":["useT","BoundedFileSource","fileKind","filePreviewMode","modifiedLabel","sizeLabel","FileTextPreview","ReactNode","useEffect","useRef","useState","StyleSheet","CloseIcon","DownloadIcon","fileKindLabel","fontOf","Button","CopyButton","EmptyState","FilePreview","FilePreviewProps","Loaded","key","preview","error","media","data","mimeType","mediaError","FileViewerProps","path","item","size","modifiedAt","scopeKey","loadPreview","signal","AbortSignal","Promise","loadMedia","prepareSave","nativeSaveFile","source","renderFilePreview","renderMediaPreview","setTabHeader","header","subtitle","action","onOpenPath","actions","note","unavailable","status","FileViewer","props","t","hasStatus","undefined","version","downloadKey","loaded","setLoaded","attempt","setAttempt","loaders","current","showsMedia","controller","AbortController","then","aborted","bytes","Error","message","String","catch","abort","downloadController","download","setDownload","saving","failed","ownDownload","canSave","save","file","cancel","handlers","offline","label","onAction","loading","styles","meta","body","n","screen","stage","content","FilePathStrip","now","Date","strip","stripPath","FileViewerHeader","disabled","onDownload","onCancel","create","theme","rt","flex","padding","spacing","gap","uni__dependencies","flexDirection","alignItems","paddingHorizontal","paddingTop","paddingBottom","insets","bottom","borderTopWidth","borderTopColor","colors","backgroundColor","bg","flexShrink","borderBottomWidth","borderBottomColor","minWidth","fontFamily","mono","fontSize","sm","color","dim","sans"],"sources":["../../src/components/FileViewer.tsx"],"sourcesContent":["import { useT } from '@agimon-ai/po-core/native';\nimport {\n type BoundedFileSource,\n fileKind,\n filePreviewMode,\n modifiedLabel,\n sizeLabel,\n type FileTextPreview,\n} from '@agimon-ai/po-web-components/text';\nimport { type ReactNode, useEffect, useRef, useState } from 'react';\nimport { ScrollView, Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { CloseIcon, DownloadIcon } from '../icons/icons';\nimport { fileKindLabel } from '../lib/fileKindLabel';\nimport { fontOf } from '../lib/fonts';\nimport { Button } from './Button';\nimport { CopyButton } from './CopyButton';\nimport { EmptyState } from './EmptyState';\nimport { FilePreview, type FilePreviewProps } from './FilePreview';\n\ninterface Loaded {\n key: string;\n preview?: FileTextPreview;\n error?: string;\n media?: { data: string; mimeType: string };\n mediaError?: string;\n}\n\nexport interface FileViewerProps {\n path: string;\n /** The listed file, for its size and modified time; changes to it reload the preview. */\n item?: { size: number; modifiedAt: number };\n /** Keeps this folder's previews and downloads apart from another folder's file with the same path. */\n scopeKey: string;\n loadPreview: (signal: AbortSignal) => Promise<FileTextPreview>;\n /** Whole small media, base64 encoded by the owner. */\n loadMedia?: (signal: AbortSignal) => Promise<{ data: string; mimeType: string }>;\n /** A bounded source the host saves; without it there is no download. */\n prepareSave?: (signal: AbortSignal) => Promise<BoundedFileSource>;\n nativeSaveFile?: (source: BoundedFileSource) => Promise<void>;\n renderFilePreview?: FilePreviewProps['renderFilePreview'];\n renderMediaPreview?: FilePreviewProps['renderMediaPreview'];\n /** The native top bar of the tab screen; absent in older hosts, where the viewer draws its own header. */\n setTabHeader?: (header: { subtitle?: string; action?: ReactNode }) => void;\n onOpenPath: (path: string) => void;\n /** Above the preview, such as the owner's move action. */\n actions?: ReactNode;\n note?: string;\n /** Shown instead of the preview when the owner cannot read files, such as an unavailable session. */\n unavailable?: string;\n /** Shown instead of the preview, such as an EmptyState for a folder, a missing file or a failed read. */\n status?: ReactNode;\n}\n\n/** One file on the phone: header or top-bar download, the bounded preview, and the path strip. */\nexport function FileViewer(props: FileViewerProps) {\n const t = useT();\n const { path, item, scopeKey, loadPreview, loadMedia, prepareSave, setTabHeader, unavailable, status } = props;\n const hasStatus = status !== undefined && status !== null;\n const version = `${item?.modifiedAt ?? ''}:${item?.size ?? ''}`;\n const downloadKey = `${scopeKey}:${path}`;\n const key = `${downloadKey}:${version}`;\n const [loaded, setLoaded] = useState<Loaded>();\n // Bumped by Try again after a failed read, so the effect reads the file once more.\n const [attempt, setAttempt] = useState(0);\n // The owner's loaders change identity each render; the effect reads the latest through a ref.\n const loaders = useRef({ loadPreview, loadMedia });\n useEffect(() => {\n loaders.current = { loadPreview, loadMedia };\n });\n const showsMedia = props.renderMediaPreview !== undefined;\n useEffect(() => {\n if (unavailable || hasStatus) return;\n const controller = new AbortController();\n void loaders.current\n .loadPreview(controller.signal)\n .then(async (preview) => {\n if (controller.signal.aborted) return;\n setLoaded({ key, preview });\n const media = loaders.current.loadMedia;\n if (filePreviewMode(path) !== 'media' || !showsMedia || !media) return;\n try {\n const bytes = await media(controller.signal);\n if (!controller.signal.aborted) setLoaded({ key, preview, media: bytes });\n } catch (error) {\n if (!controller.signal.aborted)\n setLoaded({ key, preview, mediaError: error instanceof Error ? error.message : String(error) });\n }\n })\n .catch((error: unknown) => {\n if (!controller.signal.aborted)\n setLoaded({ key, error: error instanceof Error ? error.message : String(error) });\n });\n return () => controller.abort();\n }, [path, key, showsMedia, unavailable, hasStatus, attempt]);\n const current = loaded?.key === key ? loaded : undefined;\n const downloadController = useRef<AbortController | undefined>(undefined);\n const [download, setDownload] = useState<{ key: string; saving?: boolean; note?: string; failed?: string }>();\n const ownDownload = download?.key === downloadKey ? download : undefined;\n useEffect(\n () => () => {\n downloadController.current?.abort();\n downloadController.current = undefined;\n },\n [downloadKey],\n );\n const saving = ownDownload?.saving === true;\n const canSave = props.nativeSaveFile !== undefined && prepareSave !== undefined;\n const save = async () => {\n if (unavailable || !props.nativeSaveFile || !prepareSave || downloadController.current) return;\n const controller = new AbortController();\n downloadController.current = controller;\n // A retry keeps the failure on screen with its button busy, as the approved Retrying target shows.\n setDownload({ key: downloadKey, saving: true, failed: ownDownload?.failed });\n try {\n const file = await prepareSave(controller.signal);\n if (controller.signal.aborted || downloadController.current !== controller) return;\n await props.nativeSaveFile(file);\n if (!controller.signal.aborted && downloadController.current === controller)\n setDownload({ key: downloadKey, note: t('nativeComponents.fileViewer.saved', 'Saved.') });\n } catch (error) {\n if (!controller.signal.aborted && downloadController.current === controller)\n setDownload({ key: downloadKey, failed: error instanceof Error ? error.message : String(error) });\n } finally {\n if (downloadController.current === controller) downloadController.current = undefined;\n }\n };\n const cancel = () => {\n downloadController.current?.abort();\n downloadController.current = undefined;\n setDownload({ key: downloadKey, note: t('nativeComponents.fileViewer.cancelled', 'Download cancelled.') });\n };\n // The top bar's control outlives this render; it reaches the latest handlers through a ref synced after commit.\n const handlers = useRef({ save, cancel });\n useEffect(() => {\n handlers.current = { save, cancel };\n });\n // Once the host's media view is showing, it names and saves the media in the top bar; the viewer speaks otherwise.\n const media = filePreviewMode(path) === 'media' && showsMedia && current?.media !== undefined;\n const subtitle = `${fileKindLabel(fileKind(path), t)}${item ? ` · ${sizeLabel(item.size)}` : ''}`;\n const offline = unavailable !== undefined;\n useEffect(() => {\n if (!setTabHeader || media) return;\n setTabHeader({\n subtitle,\n action: canSave ? (\n <Button\n variant=\"ghost\"\n size=\"icon\"\n disabled={offline}\n accessibilityLabel={\n saving\n ? t('nativeComponents.fileViewer.cancelDownload', 'Cancel download')\n : t('nativeComponents.fileViewer.download', 'Download')\n }\n onPress={() => (saving ? handlers.current.cancel() : void handlers.current.save())}\n >\n {saving ? <CloseIcon color=\"hi\" /> : <DownloadIcon color=\"hi\" />}\n </Button>\n ) : undefined,\n });\n }, [setTabHeader, media, subtitle, canSave, saving, offline]);\n const note = ownDownload?.failed ? (\n <EmptyState\n size=\"compact\"\n surface=\"plain\"\n tone=\"error\"\n title={t('nativeComponents.fileViewer.saveFailed', \"Couldn't save this file\")}\n description={ownDownload.failed}\n action={{\n label: t('nativeComponents.fileViewer.retry', 'Try again'),\n onAction: () => void save(),\n loading: saving,\n }}\n />\n ) : ownDownload?.note ? (\n <Text accessibilityLiveRegion=\"polite\" style={styles.meta}>\n {ownDownload.note}\n </Text>\n ) : null;\n const body = hasStatus ? (\n status\n ) : unavailable ? (\n <EmptyState title={unavailable} />\n ) : current?.error ? (\n <EmptyState\n tone=\"error\"\n title={t('nativeComponents.fileViewer.loadFailed', \"Couldn't load this file\")}\n description={current.error}\n action={{ label: t('nativeComponents.fileViewer.retry', 'Try again'), onAction: () => setAttempt((n) => n + 1) }}\n />\n ) : current?.preview ? (\n <FilePreview\n preview={current.preview}\n scopeKey={scopeKey}\n renderFilePreview={props.renderFilePreview}\n renderMediaPreview={props.renderMediaPreview}\n media={current.media}\n mediaError={current.mediaError}\n onOpen={props.onOpenPath}\n />\n ) : (\n <Text style={styles.meta}>{t('nativeComponents.fileViewer.reading', 'Reading this file...')}</Text>\n );\n return (\n <View style={styles.screen}>\n {props.actions}\n {props.note ? (\n <Text accessibilityLiveRegion=\"polite\" style={styles.meta}>\n {props.note}\n </Text>\n ) : null}\n {media ? (\n <View style={styles.stage}>{body}</View>\n ) : (\n <ScrollView style={styles.stage} contentContainerStyle={styles.content}>\n {setTabHeader ? null : (\n <FileViewerHeader\n path={path}\n size={item?.size}\n saving={saving}\n canSave={canSave}\n disabled={offline}\n onDownload={() => void save()}\n onCancel={cancel}\n />\n )}\n {note}\n {body}\n </ScrollView>\n )}\n <FilePathStrip path={path} modifiedAt={item?.modifiedAt} />\n </View>\n );\n}\n\n/** Where the file lives and when it last changed, pinned under the preview. */\nexport function FilePathStrip({ path, modifiedAt }: { path: string; modifiedAt?: number }) {\n // Read once per mount: a preview left open past midnight keeps its first label, which is still true then.\n const [now] = useState(Date.now);\n const t = useT();\n return (\n <View style={styles.strip}>\n <Text selectable numberOfLines={1} ellipsizeMode=\"middle\" style={[styles.path, styles.stripPath]}>\n {path}\n </Text>\n <CopyButton text={path} label={t('nativeComponents.fileViewer.pathLabel', 'path')} />\n {modifiedAt === undefined ? null : <Text style={styles.meta}>{modifiedLabel(modifiedAt, now)}</Text>}\n </View>\n );\n}\n\n/** The viewer's quiet header: where the file lives, what it is, and the one action on it. */\nexport function FileViewerHeader({\n path,\n size,\n saving,\n canSave,\n disabled,\n onDownload,\n onCancel,\n}: {\n path: string;\n size?: number;\n saving: boolean;\n canSave: boolean;\n disabled: boolean;\n onDownload: () => void;\n onCancel: () => void;\n}) {\n const t = useT();\n return (\n <View style={styles.header}>\n <View style={styles.label}>\n <Text selectable numberOfLines={1} ellipsizeMode=\"middle\" style={styles.path}>\n {path}\n </Text>\n <Text style={styles.meta}>\n {fileKindLabel(fileKind(path), t)}\n {size === undefined ? '' : ` · ${sizeLabel(size)}`}\n {canSave ? '' : ` · ${t('nativeComponents.fileViewer.cannotSave', 'This host cannot save downloads.')}`}\n </Text>\n </View>\n {canSave && saving ? (\n <Button variant=\"ghost\" size=\"sm\" onPress={onCancel}>\n {t('nativeComponents.fileViewer.cancel', 'Cancel')}\n </Button>\n ) : null}\n {canSave ? (\n <Button variant=\"outline\" size=\"sm\" disabled={saving || disabled} onPress={onDownload}>\n {t('nativeComponents.fileViewer.download', 'Download')}\n </Button>\n ) : null}\n </View>\n );\n}\n\nconst styles = StyleSheet.create((theme, rt) => ({\n screen: { flex: 1 },\n stage: { flex: 1 },\n content: { padding: theme.spacing(4), gap: theme.spacing(3) },\n strip: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: theme.spacing(2),\n paddingHorizontal: theme.spacing(4),\n paddingTop: theme.spacing(2),\n paddingBottom: theme.spacing(2) + rt.insets.bottom,\n borderTopWidth: 1,\n borderTopColor: theme.colors['border-soft'],\n backgroundColor: theme.colors.bg,\n },\n stripPath: { flexShrink: 1 },\n header: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: theme.spacing(2),\n paddingBottom: theme.spacing(3),\n borderBottomWidth: 1,\n borderBottomColor: theme.colors['border-soft'],\n },\n label: { flex: 1, minWidth: 0, gap: theme.spacing(0.5) },\n path: { fontFamily: fontOf(theme.fontFamily.mono), fontSize: theme.fontSize.sm, color: theme.colors.dim },\n meta: { fontFamily: fontOf(theme.fontFamily.sans), fontSize: theme.fontSize.sm, color: theme.colors.dim },\n}));\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwDA,SAAgBsD,WAAWC,OAAwB;CACjD,MAAMC,IAAIxD,KAAK;CACf,MAAM,EAAE8B,MAAMC,MAAMG,UAAUC,aAAaI,WAAWC,aAAaK,cAAcO,aAAaC,WAAWE;CACzG,MAAME,YAAYJ,WAAWK,UAAaL,WAAW;CACrD,MAAMM,UAAU,GAAG5B,MAAME,cAAc,GAAE,GAAIF,MAAMC,QAAQ;CAC3D,MAAM4B,cAAc,GAAG1B,SAAQ,GAAIJ;CACnC,MAAMR,MAAM,GAAGsC,YAAW,GAAID;CAC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AASH,MAAMI,QAAQ,CAAC;EAAGC,KAAKL,MAAMI,QAAQ,CAAC;EAACE,mBAAA,CAAA,CAAA;CAAC;CAC5Db,OAAO;EACLc,eAAe;EACfC,YAAY;EACZH,KAAKL,MAAMI,QAAQ,CAAC;EACpBK,mBAAmBT,MAAMI,QAAQ,CAAC;EAClCM,YAAYV,MAAMI,QAAQ,CAAC;EAC3BO,eAAeX,MAAMI,QAAQ,CAAC,IAAIH,GAAGW,OAAOC;EAC5CC,gBAAgB;EAChBC,gBAAgBf,MAAMgB,OAAO;EAC7BC,iBAAiBjB,MAAMgB,OAAOE;EAAEZ,mBAAA,CAAA,GAAA,CAAA;CAClC;CACAZ,WAAW,EAAEyB,YAAY,EAAE;CAC3BnF,QAAQ;EACNuE,eAAe;EACfC,YAAY;EACZH,KAAKL,MAAMI,QAAQ,CAAC;EACpBO,eAAeX,MAAMI,QAAQ,CAAC;EAC9BgB,mBAAmB;EACnBC,mBAAmBrB,MAAMgB,OAAO;EAAcV,mBAAA,CAAA,CAAA;CAChD;CACA1B,OAAO;EAAEsB,MAAM;EAAGoB,UAAU;EAAGjB,KAAKL,MAAMI,QAAQ,EAAG;EAACE,mBAAA,CAAA,CAAA;CAAC;CACvDtF,MAAM;EAAEuG,YAAYtH,OAAO+F,MAAMuB,WAAWC,IAAI;EAAGC,UAAUzB,MAAMyB,SAASC;EAAIC,OAAO3B,MAAMgB,OAAOY;EAAGtB,mBAAA,CAAA,CAAA;CAAC;CACxGtB,MAAM;EAAEuC,YAAYtH,OAAO+F,MAAMuB,WAAWM,IAAI;EAAGJ,UAAUzB,MAAMyB,SAASC;EAAIC,OAAO3B,MAAMgB,OAAOY;EAAGtB,mBAAA,CAAA,CAAA;CAAC;AAC1G,EAAE"}
@@ -0,0 +1,13 @@
1
+ import { PresentedLine } from "@agimon-ai/po-web-components/text";
2
+ import { ViewProps } from "react-native";
3
+ //#region src/components/HashlineLines.d.ts
4
+ export interface HashlineLinesProps extends Omit<ViewProps, 'children'> {
5
+ lines: readonly PresentedLine[];
6
+ /** Width of the line-number column, in characters, from `hashlineBody`. */
7
+ gutter: number;
8
+ /** The file a body of bare anchored lines came from, for highlighting. */
9
+ path?: string | undefined;
10
+ }
11
+ export declare function HashlineLines({ lines, gutter, path, style, ...props }: HashlineLinesProps): import("react").JSX.Element;
12
+ //#endregion
13
+ //# sourceMappingURL=HashlineLines.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HashlineLines.d.mts","names":[],"sources":["../../src/components/HashlineLines.tsx"],"mappings":";;;iBA8BiB,2BAA2B,KAAK;EAC/C,gBAAgB;;EAEhB;;EAEA;;wBAwCc,gBAAgB,OAAO,QAAQ,MAAM,UAAU,SAAS,qCAAkB,IAAA"}
@@ -0,0 +1,153 @@
1
+ import { fontOf } from "../lib/fonts.mjs";
2
+ import { READING } from "../lib/reading.mjs";
3
+ import { useReadingPage } from "../lib/useReadingPage.mjs";
4
+ import { ShowMore } from "./ShowMore.mjs";
5
+ import { SyntaxLine } from "./SyntaxLine.mjs";
6
+ import { detectGrammar, hashlineGroups, hashlineGroupsKey, highlightToLines } from "@agimon-ai/po-web-components/text";
7
+ import { View } from "react-native-unistyles/components/native/View";
8
+ import { Text } from "react-native-unistyles/components/native/Text";
9
+ import { StyleSheet } from "react-native-unistyles";
10
+ import { useEffect, useMemo, useState } from "react";
11
+ import { jsx, jsxs } from "react/jsx-runtime";
12
+ import { useT } from "@agimon-ai/po-core/native";
13
+
14
+ //#region src/components/HashlineLines.tsx
15
+ const NO_SPANS = /* @__PURE__ */ new Map();
16
+ /** Spans per presented-line index, kept with the body they belong to, as the web's hook. */
17
+ function useHashlineSpans(lines, path) {
18
+ const groups = useMemo(() => hashlineGroups(lines, path), [lines, path]);
19
+ const key = hashlineGroupsKey(groups);
20
+ const [done, setDone] = useState();
21
+ useEffect(() => {
22
+ let live = true;
23
+ const controller = new AbortController();
24
+ const next = /* @__PURE__ */ new Map();
25
+ const work = groups.map(async (group) => {
26
+ const grammar = detectGrammar({
27
+ path: group.path,
28
+ text: group.text
29
+ });
30
+ if (grammar === void 0) return;
31
+ const highlighted = await highlightToLines(group.text, grammar, controller.signal);
32
+ if (highlighted === void 0) return;
33
+ for (const [offset, index] of group.indices.entries()) {
34
+ const line = highlighted[offset];
35
+ if (line !== void 0) next.set(index, line);
36
+ }
37
+ });
38
+ Promise.allSettled(work).then(() => {
39
+ if (live && next.size > 0) setDone({
40
+ key,
41
+ spans: next
42
+ });
43
+ });
44
+ return () => {
45
+ live = false;
46
+ controller.abort();
47
+ };
48
+ }, [key]);
49
+ return done?.key === key ? done.spans : NO_SPANS;
50
+ }
51
+ function HashlineLines({ lines, gutter, path, style, ...props }) {
52
+ const t = useT();
53
+ const { page, reveal } = useReadingPage(`${path ?? ""}\n${lines.map((line) => JSON.stringify(line)).join("\n")}`);
54
+ const visible = useMemo(() => lines.slice(0, READING.hashlines * page), [lines, page]);
55
+ const spans = useHashlineSpans(visible, path);
56
+ return /* @__PURE__ */ jsxs(View, {
57
+ style,
58
+ ...props,
59
+ children: [visible.map((line, index) => {
60
+ if (line.type === "file") return /* @__PURE__ */ jsx(Text, {
61
+ numberOfLines: 1,
62
+ style: [
63
+ styles.mono,
64
+ styles.faint,
65
+ index > 0 && styles.fileGap
66
+ ],
67
+ children: line.path
68
+ }, index);
69
+ if (line.type === "plain") return /* @__PURE__ */ jsx(Text, {
70
+ selectable: true,
71
+ style: [styles.mono, styles.dim],
72
+ children: line.text
73
+ }, index);
74
+ const { value } = line;
75
+ const match = value.marker === "match";
76
+ return /* @__PURE__ */ jsxs(View, {
77
+ style: styles.row,
78
+ children: [
79
+ value.marker !== void 0 ? /* @__PURE__ */ jsx(Text, {
80
+ style: [styles.mono, match ? styles.marker : styles.faint],
81
+ children: match ? ">>" : " "
82
+ }) : null,
83
+ /* @__PURE__ */ jsx(Text, {
84
+ style: [styles.mono, styles.faint],
85
+ children: String(value.line).padStart(gutter)
86
+ }),
87
+ /* @__PURE__ */ jsx(SyntaxLine, {
88
+ selectable: true,
89
+ spans: spans.get(index),
90
+ text: value.content,
91
+ style: [
92
+ styles.mono,
93
+ styles.content,
94
+ match ? styles.hi : styles.text
95
+ ]
96
+ })
97
+ ]
98
+ }, index);
99
+ }), visible.length < lines.length ? /* @__PURE__ */ jsx(ShowMore, {
100
+ label: t("nativeComponents.hashline.showMore", "Show more lines"),
101
+ summary: t("nativeComponents.hashline.summary", "{shown} of {total} lines", {
102
+ shown: visible.length,
103
+ total: lines.length
104
+ }),
105
+ onPress: reveal
106
+ }) : null]
107
+ });
108
+ }
109
+ const styles = StyleSheet.create((theme) => ({
110
+ row: {
111
+ flexDirection: "row",
112
+ gap: theme.spacing(2),
113
+ uni__dependencies: [0]
114
+ },
115
+ fileGap: {
116
+ marginTop: theme.spacing(1),
117
+ uni__dependencies: [0]
118
+ },
119
+ mono: {
120
+ fontFamily: fontOf(theme.fontFamily.mono),
121
+ fontSize: theme.fontSize.sm,
122
+ lineHeight: theme.lineHeightRelaxed.sm,
123
+ uni__dependencies: [0]
124
+ },
125
+ content: {
126
+ flex: 1,
127
+ minWidth: 0
128
+ },
129
+ marker: {
130
+ color: theme.colors.blue,
131
+ uni__dependencies: [0]
132
+ },
133
+ faint: {
134
+ color: theme.colors.faint,
135
+ uni__dependencies: [0]
136
+ },
137
+ dim: {
138
+ color: theme.colors.dim,
139
+ uni__dependencies: [0]
140
+ },
141
+ text: {
142
+ color: theme.colors.text,
143
+ uni__dependencies: [0]
144
+ },
145
+ hi: {
146
+ color: theme.colors.hi,
147
+ uni__dependencies: [0]
148
+ }
149
+ }));
150
+
151
+ //#endregion
152
+ export { HashlineLines };
153
+ //# sourceMappingURL=HashlineLines.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HashlineLines.mjs","names":["useT","detectGrammar","hashlineGroups","hashlineGroupsKey","highlightToLines","PresentedLine","SyntaxSpan","useEffect","useMemo","useState","ViewProps","StyleSheet","fontOf","READING","useReadingPage","ShowMore","SyntaxLine","HashlineLinesProps","Omit","lines","gutter","path","NO_SPANS","ReadonlyMap","Map","useHashlineSpans","groups","key","done","setDone","spans","live","controller","AbortController","next","work","map","group","grammar","text","undefined","highlighted","signal","offset","index","indices","entries","line","set","Promise","allSettled","then","size","abort","HashlineLines","style","props","t","page","reveal","JSON","stringify","join","visible","slice","hashlines","type","styles","mono","faint","fileGap","dim","value","match","marker","row","String","padStart","get","content","hi","length","shown","total","create","theme","flexDirection","gap","spacing","uni__dependencies","marginTop","fontFamily","fontSize","sm","lineHeight","lineHeightRelaxed","flex","minWidth","color","colors","blue"],"sources":["../../src/components/HashlineLines.tsx"],"sourcesContent":["import { useT } from '@agimon-ai/po-core/native';\nimport {\n detectGrammar,\n hashlineGroups,\n hashlineGroupsKey,\n highlightToLines,\n type PresentedLine,\n type SyntaxSpan,\n} from '@agimon-ai/po-web-components/text';\nimport { useEffect, useMemo, useState } from 'react';\nimport { Text, View, type ViewProps } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\nimport { READING } from '../lib/reading';\nimport { useReadingPage } from '../lib/useReadingPage';\nimport { ShowMore } from './ShowMore';\nimport { SyntaxLine } from './SyntaxLine';\n\n/*\n * The anchored body shared by hashline results, as the web's HashlineLines: a\n * file heading per group, a right-aligned line-number gutter, and a `>>`\n * marker on grep matches. Mono type makes a padded number the gutter, so the\n * column needs no measuring.\n *\n * The anchored lines are coloured with the web's grammars and palette when the\n * body names a file, or when `path` names one. Colour arrives late and never\n * blocks the text: an unhighlighted body is the same body without the colours.\n */\n\nexport interface HashlineLinesProps extends Omit<ViewProps, 'children'> {\n lines: readonly PresentedLine[];\n /** Width of the line-number column, in characters, from `hashlineBody`. */\n gutter: number;\n /** The file a body of bare anchored lines came from, for highlighting. */\n path?: string | undefined;\n}\n\nconst NO_SPANS: ReadonlyMap<number, readonly SyntaxSpan[]> = new Map();\n\n/** Spans per presented-line index, kept with the body they belong to, as the web's hook. */\nfunction useHashlineSpans(lines: readonly PresentedLine[], path: string | undefined) {\n const groups = useMemo(() => hashlineGroups(lines, path), [lines, path]);\n const key = hashlineGroupsKey(groups);\n const [done, setDone] = useState<{ key: string; spans: ReadonlyMap<number, readonly SyntaxSpan[]> }>();\n\n useEffect(() => {\n let live = true;\n const controller = new AbortController();\n const next = new Map<number, readonly SyntaxSpan[]>();\n const work = groups.map(async (group) => {\n const grammar = detectGrammar({ path: group.path, text: group.text });\n if (grammar === undefined) return;\n const highlighted = await highlightToLines(group.text, grammar, controller.signal);\n if (highlighted === undefined) return;\n for (const [offset, index] of group.indices.entries()) {\n const line = highlighted[offset];\n if (line !== undefined) next.set(index, line);\n }\n });\n // A grammar that fails to load leaves its run plain: colour is decoration.\n void Promise.allSettled(work).then(() => {\n if (live && next.size > 0) setDone({ key, spans: next });\n });\n return () => {\n live = false;\n controller.abort();\n };\n // The groups are rebuilt with the lines; their key is what actually changes.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [key]);\n\n return done?.key === key ? done.spans : NO_SPANS;\n}\n\nexport function HashlineLines({ lines, gutter, path, style, ...props }: HashlineLinesProps) {\n const t = useT();\n // Whole anchored lines retain their exact content and line numbers, even above 640 characters.\n const { page, reveal } = useReadingPage(`${path ?? ''}\\n${lines.map((line) => JSON.stringify(line)).join('\\n')}`);\n const visible = useMemo(() => lines.slice(0, READING.hashlines * page), [lines, page]);\n const spans = useHashlineSpans(visible, path);\n return (\n <View style={style} {...props}>\n {visible.map((line, index) => {\n if (line.type === 'file') {\n return (\n <Text key={index} numberOfLines={1} style={[styles.mono, styles.faint, index > 0 && styles.fileGap]}>\n {line.path}\n </Text>\n );\n }\n if (line.type === 'plain') {\n return (\n <Text key={index} selectable style={[styles.mono, styles.dim]}>\n {line.text}\n </Text>\n );\n }\n const { value } = line;\n const match = value.marker === 'match';\n return (\n <View key={index} style={styles.row}>\n {value.marker !== undefined ? (\n <Text style={[styles.mono, match ? styles.marker : styles.faint]}>{match ? '>>' : ' '}</Text>\n ) : null}\n <Text style={[styles.mono, styles.faint]}>{String(value.line).padStart(gutter)}</Text>\n <SyntaxLine\n selectable\n spans={spans.get(index)}\n text={value.content}\n style={[styles.mono, styles.content, match ? styles.hi : styles.text]}\n />\n </View>\n );\n })}\n {visible.length < lines.length ? (\n <ShowMore\n label={t('nativeComponents.hashline.showMore', 'Show more lines')}\n summary={t('nativeComponents.hashline.summary', '{shown} of {total} lines', {\n shown: visible.length,\n total: lines.length,\n })}\n onPress={reveal}\n />\n ) : null}\n </View>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n row: { flexDirection: 'row', gap: theme.spacing(2) },\n fileGap: { marginTop: theme.spacing(1) },\n mono: {\n fontFamily: fontOf(theme.fontFamily.mono),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeightRelaxed.sm,\n },\n content: { flex: 1, minWidth: 0 },\n marker: { color: theme.colors.blue },\n faint: { color: theme.colors.faint },\n dim: { color: theme.colors.dim },\n text: { color: theme.colors.text },\n hi: { color: theme.colors.hi },\n}));\n"],"mappings":";;;;;;;;;;;;;;AAsCA,MAAMsB,2BAAuD,IAAIE,IAAI;;AAGrE,SAASC,iBAAiBN,OAAiCE,MAA0B;CACnF,MAAMK,SAASlB,cAAcN,eAAeiB,OAAOE,IAAI,GAAG,CAACF,OAAOE,IAAI,CAAC;CACvE,MAAMM,MAAMxB,kBAAkBuB,MAAM;CACpC,MAAM,CAACE,MAAMC,WAAWpB,SAA6E;CAErGF,gBAAgB;EACd,IAAIwB,OAAO;EACX,MAAMC,aAAa,IAAIC,gBAAgB;EACvC,MAAMC,uBAAO,IAAIV,IAAmC;EACpD,MAAMW,OAAOT,OAAOU,IAAI,OAAOC,UAAU;GACvC,MAAMC,UAAUrC,cAAc;IAAEoB,MAAMgB,MAAMhB;IAAMkB,MAAMF,MAAME;GAAK,CAAC;GACpE,IAAID,YAAYE,QAAW;GAC3B,MAAMC,cAAc,MAAMrC,iBAAiBiC,MAAME,MAAMD,SAASN,WAAWU,MAAM;GACjF,IAAID,gBAA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ACAV,SAAS;EAAEiB,MAAM;EAAGC,UAAU;CAAE;CAChCvB,QAAQ;EAAEwB,OAAOb,MAAMc,OAAOC;EAAIX,mBAAA,CAAA,CAAA;CAAC;CACnCpB,OAAO;EAAE6B,OAAOb,MAAMc,OAAO9B;EAAKoB,mBAAA,CAAA,CAAA;CAAC;CACnClB,KAAK;EAAE2B,OAAOb,MAAMc,OAAO5B;EAAGkB,mBAAA,CAAA,CAAA;CAAC;CAC/BlD,MAAM;EAAE2D,OAAOb,MAAMc,OAAO5D;EAAIkD,mBAAA,CAAA,CAAA;CAAC;CACjCT,IAAI;EAAEkB,OAAOb,MAAMc,OAAOnB;EAAES,mBAAA,CAAA,CAAA;CAAC;AAC/B,EAAE"}
@@ -0,0 +1,17 @@
1
+ //#region src/components/HostFilter.d.ts
2
+ export interface HostFilterProps {
3
+ hosts: readonly {
4
+ id: string;
5
+ label: string;
6
+ }[];
7
+ /** null means All. This is presentation only, not a transport selection. */
8
+ value: string | null;
9
+ onChange: (id: string | null) => void;
10
+ /** Off when the choice names where something lives, so exactly one computer is always chosen. */
11
+ includeAll?: boolean;
12
+ accessibilityLabel?: string;
13
+ }
14
+ /** Short names use the native segmented control; long names remain reachable by scrolling. */
15
+ export declare function HostFilter({ hosts, value, onChange, includeAll, accessibilityLabel: accessibilityLabelProp }: HostFilterProps): import("react").JSX.Element;
16
+ //#endregion
17
+ //# sourceMappingURL=HostFilter.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HostFilter.d.mts","names":[],"sources":["../../src/components/HostFilter.tsx"],"mappings":";iBAQiB;EACf;IAAkB;IAAY;;;EAE9B;EACA,WAAW;;EAEX;EACA;;;wBAOc,aACd,OACA,OACA,UACA,YACA,oBAAoB,0BACnB,kCAAe,IAAA"}