@agimon-ai/po-native-components 0.0.0-alpha.223 → 0.0.0-alpha.224

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.
@@ -1,6 +1,17 @@
1
+ import { MarkdownImageLoader } from "./Markdown.mjs";
1
2
  import { FileTextPreview } from "@agimon-ai/po-web-components/text";
2
3
  import { ReactNode } from "react";
3
4
  //#region src/components/FilePreview.d.ts
5
+ export interface MediaSaveFallback {
6
+ size?: number;
7
+ kindLabel?: string;
8
+ oversized?: boolean;
9
+ canSave: boolean;
10
+ saving: boolean;
11
+ disabled?: boolean;
12
+ onSave: () => void;
13
+ onCancel: () => void;
14
+ }
4
15
  export interface FilePreviewProps {
5
16
  preview: FileTextPreview;
6
17
  /** Keeps host-rendered previews of one file apart from another folder's file with the same path. */
@@ -24,10 +35,14 @@ export interface FilePreviewProps {
24
35
  mimeType: string;
25
36
  };
26
37
  mediaError?: string;
38
+ /** When inline media cannot render (such as > 5 MiB), offers an immediate bounded save action. */
39
+ mediaSave?: MediaSaveFallback;
40
+ /** Loads relative or scoped inline images inside Markdown previews. */
41
+ loadImage?: MarkdownImageLoader;
27
42
  /** Opens a file the markdown links to, already resolved inside the same folder. */
28
43
  onOpen: (path: string) => void;
29
44
  }
30
45
  /** One file's bounded preview on the phone; the host receives only content the owner fetched through its route. */
31
- export declare function FilePreview({ preview, scopeKey, renderFilePreview, renderMediaPreview, media, mediaError, onOpen }: FilePreviewProps): import("react").JSX.Element;
46
+ export declare function FilePreview({ preview, scopeKey, renderFilePreview, renderMediaPreview, media, mediaError, mediaSave, loadImage, onOpen }: FilePreviewProps): import("react").JSX.Element;
32
47
  //#endregion
33
48
  //# sourceMappingURL=FilePreview.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FilePreview.d.mts","names":[],"sources":["../../src/components/FilePreview.tsx"],"mappings":";;;iBAUiB;EACf,SAAS;;EAET;;EAEA,qBAAqB;IAAW;IAAa;IAAc;QAAoB;;EAE/E,sBAAsB;IACpB;IACA;IACA;IACA;IACA;QACI;EACN;IAAU;IAAc;;EACxB;;EAEA,SAAS;;;wBAIK,cACd,SACA,UACA,mBACA,oBACA,OACA,YACA,UACC,mCAAgB,IAAA"}
1
+ {"version":3,"file":"FilePreview.d.mts","names":[],"sources":["../../src/components/FilePreview.tsx"],"mappings":";;;;iBAaiB;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;iBAGe;EACf,SAAS;;EAET;;EAEA,qBAAqB;IAAW;IAAa;IAAc;QAAoB;;EAE/E,sBAAsB;IACpB;IACA;IACA;IACA;IACA;QACI;EACN;IAAU;IAAc;;EACxB;;EAEA,YAAY;;EAEZ,YAAY;;EAEZ,SAAS;;;wBAIK,cACd,SACA,UACA,mBACA,oBACA,OACA,YACA,WACA,WACA,UACC,mCAAgB,IAAA"}
@@ -1,23 +1,71 @@
1
1
  import { fontOf } from "../lib/fonts.mjs";
2
+ import { Button } from "./Button.mjs";
2
3
  import { CodeBlock } from "./CodeBlock.mjs";
3
4
  import { Markdown } from "./Markdown.mjs";
4
- import { fileAssetPath, filePreviewMode } from "@agimon-ai/po-web-components/text";
5
+ import { fileAssetPath, filePreviewMode, sizeLabel } from "@agimon-ai/po-web-components/text";
5
6
  import { View } from "react-native-unistyles/components/native/View";
6
7
  import { Text } from "react-native-unistyles/components/native/Text";
7
8
  import { StyleSheet } from "react-native-unistyles";
8
- import { Fragment, jsx } from "react/jsx-runtime";
9
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
10
  import { useT } from "@agimon-ai/po-core/native";
10
11
 
11
12
  //#region src/components/FilePreview.tsx
13
+ const TOUCH_TARGET_MIN = 44;
12
14
  /** One file's bounded preview on the phone; the host receives only content the owner fetched through its route. */
13
- function FilePreview({ preview, scopeKey, renderFilePreview, renderMediaPreview, media, mediaError, onOpen }) {
15
+ function FilePreview({ preview, scopeKey, renderFilePreview, renderMediaPreview, media, mediaError, mediaSave, loadImage, onOpen }) {
14
16
  const t = useT();
15
17
  const mode = filePreviewMode(preview.path);
16
18
  if (mode === "media") {
17
- if (mediaError) return /* @__PURE__ */ jsx(Text, {
18
- accessibilityRole: "alert",
19
- style: styles.error,
20
- children: mediaError
19
+ if (mediaSave?.oversized) {
20
+ const details = [
21
+ mediaSave.kindLabel,
22
+ mediaSave.size === void 0 ? void 0 : sizeLabel(mediaSave.size),
23
+ preview.mimeType
24
+ ].filter((part) => Boolean(part)).join(" · ");
25
+ return /* @__PURE__ */ jsxs(View, {
26
+ style: styles.fallback,
27
+ children: [
28
+ /* @__PURE__ */ jsx(Text, {
29
+ style: styles.fallbackTitle,
30
+ children: t("nativeComponents.filePreview.tooLargeTitle", "Too large to preview inline")
31
+ }),
32
+ details ? /* @__PURE__ */ jsx(Text, {
33
+ style: styles.meta,
34
+ children: details
35
+ }) : null,
36
+ /* @__PURE__ */ jsx(Text, {
37
+ style: styles.meta,
38
+ children: t("nativeComponents.filePreview.tooLargeDetail", "Files over 5 MiB are saved in chunks instead of loading into memory.")
39
+ }),
40
+ mediaSave.canSave ? /* @__PURE__ */ jsx(View, {
41
+ style: styles.actions,
42
+ children: /* @__PURE__ */ jsx(Button, {
43
+ variant: "primary",
44
+ disabled: mediaSave.disabled,
45
+ onPress: mediaSave.saving ? mediaSave.onCancel : mediaSave.onSave,
46
+ style: styles.minTouch,
47
+ children: mediaSave.saving ? t("nativeComponents.fileViewer.cancelDownload", "Cancel download") : t("nativeComponents.filePreview.saveFile", "Save file")
48
+ })
49
+ }) : null
50
+ ]
51
+ });
52
+ }
53
+ if (mediaError) return /* @__PURE__ */ jsxs(View, {
54
+ style: styles.fallback,
55
+ children: [/* @__PURE__ */ jsx(Text, {
56
+ accessibilityRole: "alert",
57
+ style: styles.error,
58
+ children: mediaError
59
+ }), mediaSave?.canSave ? /* @__PURE__ */ jsx(View, {
60
+ style: styles.actions,
61
+ children: /* @__PURE__ */ jsx(Button, {
62
+ variant: "primary",
63
+ disabled: mediaSave.disabled,
64
+ onPress: mediaSave.saving ? mediaSave.onCancel : mediaSave.onSave,
65
+ style: styles.minTouch,
66
+ children: mediaSave.saving ? t("nativeComponents.fileViewer.cancelDownload", "Cancel download") : t("nativeComponents.filePreview.saveFile", "Save file")
67
+ })
68
+ }) : null]
21
69
  });
22
70
  if (!renderMediaPreview) return /* @__PURE__ */ jsx(Text, {
23
71
  style: styles.meta,
@@ -52,6 +100,7 @@ function FilePreview({ preview, scopeKey, renderFilePreview, renderMediaPreview,
52
100
  });
53
101
  if (mode === "markdown") return /* @__PURE__ */ jsx(Markdown, {
54
102
  text: preview.content,
103
+ loadImage,
55
104
  onFileLink: (path) => {
56
105
  try {
57
106
  const resolved = fileAssetPath(preview.path, path);
@@ -76,6 +125,27 @@ const styles = StyleSheet.create((theme) => ({
76
125
  minHeight: theme.spacing(90),
77
126
  uni__dependencies: [0]
78
127
  },
128
+ fallback: {
129
+ gap: theme.spacing(2),
130
+ alignItems: "flex-start",
131
+ uni__dependencies: [0]
132
+ },
133
+ fallbackTitle: {
134
+ fontFamily: fontOf(theme.fontFamily.sans),
135
+ fontSize: theme.fontSize.base,
136
+ color: theme.colors.hi,
137
+ uni__dependencies: [0]
138
+ },
139
+ actions: {
140
+ flexDirection: "row",
141
+ gap: theme.spacing(2),
142
+ paddingTop: theme.spacing(1),
143
+ uni__dependencies: [0]
144
+ },
145
+ minTouch: {
146
+ minHeight: TOUCH_TARGET_MIN,
147
+ minWidth: TOUCH_TARGET_MIN
148
+ },
79
149
  text: {
80
150
  fontFamily: fontOf(theme.fontFamily.mono),
81
151
  fontSize: theme.fontSize.sm,
@@ -1 +1 @@
1
- {"version":3,"file":"FilePreview.mjs","names":["useT","fileAssetPath","filePreviewMode","FileTextPreview","ReactNode","StyleSheet","fontOf","CodeBlock","Markdown","FilePreviewProps","preview","scopeKey","renderFilePreview","request","key","html","title","renderMediaPreview","data","mimeType","path","media","mediaError","onOpen","FilePreview","t","mode","styles","error","meta","unavailable","reason","content","resolved","undefined","split","at","text","create","theme","minHeight","spacing","uni__dependencies","fontFamily","mono","fontSize","sm","lineHeight","color","colors","sans","dim","red"],"sources":["../../src/components/FilePreview.tsx"],"sourcesContent":["import { useT } from '@agimon-ai/po-core/native';\nimport { fileAssetPath, filePreviewMode, type FileTextPreview } from '@agimon-ai/po-web-components/text';\nimport type { ReactNode } from 'react';\nimport { Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\nimport { CodeBlock } from './CodeBlock';\nimport { Markdown } from './Markdown';\n\nexport interface FilePreviewProps {\n preview: FileTextPreview;\n /** Keeps host-rendered previews of one file apart from another folder's file with the same path. */\n scopeKey: string;\n /** The host's sandboxed HTML view, when it has one. */\n renderFilePreview?: (request: { key: string; html: string; title: string }) => ReactNode;\n /** The host's media view for bounded bytes the owner fetched. */\n renderMediaPreview?: (request: {\n key: string;\n data: string;\n mimeType: string;\n title?: string;\n path?: string;\n }) => ReactNode;\n media?: { data: string; mimeType: string };\n mediaError?: string;\n /** Opens a file the markdown links to, already resolved inside the same folder. */\n onOpen: (path: string) => void;\n}\n\n/** One file's bounded preview on the phone; the host receives only content the owner fetched through its route. */\nexport function FilePreview({\n preview,\n scopeKey,\n renderFilePreview,\n renderMediaPreview,\n media,\n mediaError,\n onOpen,\n}: FilePreviewProps) {\n const t = useT();\n const mode = filePreviewMode(preview.path);\n if (mode === 'media') {\n if (mediaError)\n return (\n <Text accessibilityRole=\"alert\" style={styles.error}>\n {mediaError}\n </Text>\n );\n if (!renderMediaPreview)\n return (\n <Text style={styles.meta}>\n {t('nativeComponents.filePreview.noMedia', 'This host cannot display this media preview.')}\n </Text>\n );\n if (!media)\n return <Text style={styles.meta}>{t('nativeComponents.filePreview.loadingMedia', 'Loading media...')}</Text>;\n return (\n <>\n {renderMediaPreview({\n key: `file-media-${scopeKey}-${preview.path}`,\n title: preview.path,\n path: preview.path,\n data: media.data,\n mimeType: media.mimeType,\n })}\n </>\n );\n }\n if (preview.unavailable)\n return (\n <Text style={styles.meta}>\n {preview.reason ?? t('nativeComponents.filePreview.unavailable', 'This file cannot be previewed.')}\n </Text>\n );\n if (mode === 'html') {\n return renderFilePreview ? (\n <View style={styles.html}>\n {renderFilePreview({\n key: `file-html-${scopeKey}-${preview.path}`,\n html: preview.content,\n title: preview.path,\n })}\n </View>\n ) : (\n <Text style={styles.meta}>\n {t('nativeComponents.filePreview.noHtml', 'This host cannot display HTML previews.')}\n </Text>\n );\n }\n if (mode === 'markdown') {\n return (\n <Markdown\n text={preview.content}\n onFileLink={(path) => {\n try {\n const resolved = fileAssetPath(preview.path, path);\n return () => onOpen(resolved);\n } catch {\n // An out-of-folder or non-file link is not a file action.\n return undefined;\n }\n }}\n />\n );\n }\n if (mode === 'code') return <CodeBlock text={preview.content} language={preview.path.split('.').at(-1)} />;\n return (\n <Text selectable style={styles.text}>\n {preview.content}\n </Text>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n html: { minHeight: theme.spacing(90) },\n text: {\n fontFamily: fontOf(theme.fontFamily.mono),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n color: theme.colors.text,\n },\n meta: { fontFamily: fontOf(theme.fontFamily.sans), fontSize: theme.fontSize.sm, color: theme.colors.dim },\n error: { fontFamily: fontOf(theme.fontFamily.sans), fontSize: theme.fontSize.sm, color: theme.colors.red },\n}));\n"],"mappings":";;;;;;;;;;;;AA+BA,SAAgBwB,YAAY,EAC1Bd,SACAC,UACAC,mBACAK,oBACAI,OACAC,YACAC,UACmB;CACnB,MAAME,IAAIzB,KAAK;CACf,MAAM0B,OAAOxB,gBAAgBQ,QAAQU,IAAI;CACzC,IAAIM,SAAS,SAAS;EACpB,IAAIJ,YACF,OACE,oBAAC,MAAD;GAAM,mBAAkB;GAAQ,OAAOK,OAAOC;aAC3CN;EACG;EAEV,IAAI,CAACL,oBACH,OACE,oBAAC,MAAD;GAAM,OAAOU,OAAOE;aACjBJ,EAAE,wCAAwC,8CAA8C;EACrF;EAEV,IAA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OiC,MAAMI,WAAWC,IAAI;EACxCC,UAAUN,MAAMM,SAASC;EACzBC,YAAYR,MAAMQ,WAAWD;EAC7BE,OAAOT,MAAMU,OAAOZ;EAAIK,mBAAA,CAAA,CAAA;CAC1B;CACAb,MAAM;EAAEc,YAAYrC,OAAOiC,MAAMI,WAAWO,IAAI;EAAGL,UAAUN,MAAMM,SAASC;EAAIE,OAAOT,MAAMU,OAAOE;EAAGT,mBAAA,CAAA,CAAA;CAAC;CACxGd,OAAO;EAAEe,YAAYrC,OAAOiC,MAAMI,WAAWO,IAAI;EAAGL,UAAUN,MAAMM,SAASC;EAAIE,OAAOT,MAAMU,OAAOG;EAAGV,mBAAA,CAAA,CAAA;CAAC;AAC3G,EAAE"}
1
+ {"version":3,"file":"FilePreview.mjs","names":["useT","fileAssetPath","filePreviewMode","sizeLabel","FileTextPreview","ReactNode","StyleSheet","fontOf","Button","CodeBlock","Markdown","MarkdownImageLoader","TOUCH_TARGET_MIN","MediaSaveFallback","size","kindLabel","oversized","canSave","saving","disabled","onSave","onCancel","FilePreviewProps","preview","scopeKey","renderFilePreview","request","key","html","title","renderMediaPreview","data","mimeType","path","media","mediaError","mediaSave","loadImage","onOpen","FilePreview","t","mode","details","undefined","filter","part","Boolean","join","styles","fallback","fallbackTitle","meta","actions","minTouch","error","unavailable","reason","content","resolved","split","at","text","create","theme","minHeight","spacing","uni__dependencies","gap","alignItems","fontFamily","sans","fontSize","base","color","colors","hi","flexDirection","paddingTop","minWidth","mono","sm","lineHeight","dim","red"],"sources":["../../src/components/FilePreview.tsx"],"sourcesContent":["import { useT } from '@agimon-ai/po-core/native';\nimport { fileAssetPath, filePreviewMode, sizeLabel, type FileTextPreview } from '@agimon-ai/po-web-components/text';\nimport type { ReactNode } from 'react';\nimport { Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\nimport { Button } from './Button';\nimport { CodeBlock } from './CodeBlock';\nimport { Markdown, type MarkdownImageLoader } from './Markdown';\n\nconst TOUCH_TARGET_MIN = 44;\n\nexport interface MediaSaveFallback {\n size?: number;\n kindLabel?: string;\n oversized?: boolean;\n canSave: boolean;\n saving: boolean;\n disabled?: boolean;\n onSave: () => void;\n onCancel: () => void;\n}\n\nexport interface FilePreviewProps {\n preview: FileTextPreview;\n /** Keeps host-rendered previews of one file apart from another folder's file with the same path. */\n scopeKey: string;\n /** The host's sandboxed HTML view, when it has one. */\n renderFilePreview?: (request: { key: string; html: string; title: string }) => ReactNode;\n /** The host's media view for bounded bytes the owner fetched. */\n renderMediaPreview?: (request: {\n key: string;\n data: string;\n mimeType: string;\n title?: string;\n path?: string;\n }) => ReactNode;\n media?: { data: string; mimeType: string };\n mediaError?: string;\n /** When inline media cannot render (such as > 5 MiB), offers an immediate bounded save action. */\n mediaSave?: MediaSaveFallback;\n /** Loads relative or scoped inline images inside Markdown previews. */\n loadImage?: MarkdownImageLoader;\n /** Opens a file the markdown links to, already resolved inside the same folder. */\n onOpen: (path: string) => void;\n}\n\n/** One file's bounded preview on the phone; the host receives only content the owner fetched through its route. */\nexport function FilePreview({\n preview,\n scopeKey,\n renderFilePreview,\n renderMediaPreview,\n media,\n mediaError,\n mediaSave,\n loadImage,\n onOpen,\n}: FilePreviewProps) {\n const t = useT();\n const mode = filePreviewMode(preview.path);\n if (mode === 'media') {\n if (mediaSave?.oversized) {\n const details = [\n mediaSave.kindLabel,\n mediaSave.size === undefined ? undefined : sizeLabel(mediaSave.size),\n preview.mimeType,\n ]\n .filter((part): part is string => Boolean(part))\n .join(' · ');\n return (\n <View style={styles.fallback}>\n <Text style={styles.fallbackTitle}>\n {t('nativeComponents.filePreview.tooLargeTitle', 'Too large to preview inline')}\n </Text>\n {details ? <Text style={styles.meta}>{details}</Text> : null}\n <Text style={styles.meta}>\n {t(\n 'nativeComponents.filePreview.tooLargeDetail',\n 'Files over 5 MiB are saved in chunks instead of loading into memory.',\n )}\n </Text>\n {mediaSave.canSave ? (\n <View style={styles.actions}>\n <Button\n variant=\"primary\"\n disabled={mediaSave.disabled}\n onPress={mediaSave.saving ? mediaSave.onCancel : mediaSave.onSave}\n style={styles.minTouch}\n >\n {mediaSave.saving\n ? t('nativeComponents.fileViewer.cancelDownload', 'Cancel download')\n : t('nativeComponents.filePreview.saveFile', 'Save file')}\n </Button>\n </View>\n ) : null}\n </View>\n );\n }\n if (mediaError)\n return (\n <View style={styles.fallback}>\n <Text accessibilityRole=\"alert\" style={styles.error}>\n {mediaError}\n </Text>\n {mediaSave?.canSave ? (\n <View style={styles.actions}>\n <Button\n variant=\"primary\"\n disabled={mediaSave.disabled}\n onPress={mediaSave.saving ? mediaSave.onCancel : mediaSave.onSave}\n style={styles.minTouch}\n >\n {mediaSave.saving\n ? t('nativeComponents.fileViewer.cancelDownload', 'Cancel download')\n : t('nativeComponents.filePreview.saveFile', 'Save file')}\n </Button>\n </View>\n ) : null}\n </View>\n );\n if (!renderMediaPreview)\n return (\n <Text style={styles.meta}>\n {t('nativeComponents.filePreview.noMedia', 'This host cannot display this media preview.')}\n </Text>\n );\n if (!media)\n return <Text style={styles.meta}>{t('nativeComponents.filePreview.loadingMedia', 'Loading media...')}</Text>;\n return (\n <>\n {renderMediaPreview({\n key: `file-media-${scopeKey}-${preview.path}`,\n title: preview.path,\n path: preview.path,\n data: media.data,\n mimeType: media.mimeType,\n })}\n </>\n );\n }\n if (preview.unavailable)\n return (\n <Text style={styles.meta}>\n {preview.reason ?? t('nativeComponents.filePreview.unavailable', 'This file cannot be previewed.')}\n </Text>\n );\n if (mode === 'html') {\n return renderFilePreview ? (\n <View style={styles.html}>\n {renderFilePreview({\n key: `file-html-${scopeKey}-${preview.path}`,\n html: preview.content,\n title: preview.path,\n })}\n </View>\n ) : (\n <Text style={styles.meta}>\n {t('nativeComponents.filePreview.noHtml', 'This host cannot display HTML previews.')}\n </Text>\n );\n }\n if (mode === 'markdown') {\n return (\n <Markdown\n text={preview.content}\n loadImage={loadImage}\n onFileLink={(path) => {\n try {\n const resolved = fileAssetPath(preview.path, path);\n return () => onOpen(resolved);\n } catch {\n // An out-of-folder or non-file link is not a file action.\n return undefined;\n }\n }}\n />\n );\n }\n if (mode === 'code') return <CodeBlock text={preview.content} language={preview.path.split('.').at(-1)} />;\n return (\n <Text selectable style={styles.text}>\n {preview.content}\n </Text>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n html: { minHeight: theme.spacing(90) },\n fallback: { gap: theme.spacing(2), alignItems: 'flex-start' },\n fallbackTitle: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n color: theme.colors.hi,\n },\n actions: { flexDirection: 'row', gap: theme.spacing(2), paddingTop: theme.spacing(1) },\n minTouch: { minHeight: TOUCH_TARGET_MIN, minWidth: TOUCH_TARGET_MIN },\n text: {\n fontFamily: fontOf(theme.fontFamily.mono),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n color: theme.colors.text,\n },\n meta: { fontFamily: fontOf(theme.fontFamily.sans), fontSize: theme.fontSize.sm, color: theme.colors.dim },\n error: { fontFamily: fontOf(theme.fontFamily.sans), fontSize: theme.fontSize.sm, color: theme.colors.red },\n}));\n"],"mappings":";;;;;;;;;;;;AAWA,MAAMY,mBAAmB;;AAsCzB,SAAgB2B,YAAY,EAC1BhB,SACAC,UACAC,mBACAK,oBACAI,OACAC,YACAC,WACAC,WACAC,UACmB;CACnB,MAAME,IAAIxC,KAAK;CACf,MAAMyC,OAAOvC,gBAAgBqB,QAAQU,IAAI;CACzC,IAAIQ,SAAS,SAAS;EACpB,IAAIL,WAAWpB,WAAW;GACxB,MAAM0B,UAAU;IACdN,UAAUrB;IACVqB,UAAUtB,SAAS6B,SAAYA,SAAYxC,UAAUiC,UAAUtB,IAAI;IACnES,QAAQS;GAAQ,CACjB,CACEY,QAAQC,SAAyBC,QAAQD,IAAI,CAAC,CAAC,CAC/CE,KAAK,KAAK;GACb,OACE,qBAAC,MAAD;IAAM,OAAOC,OAAOC;cAApB;KACE,oB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A,CAAA;CACxB;CACAd,SAAS;EAAEwB,eAAe;EAAOT,KAAKJ,MAAME,QAAQ,CAAC;EAAGY,YAAYd,MAAME,QAAQ,CAAC;EAACC,mBAAA,CAAA,CAAA;CAAC;CACrFb,UAAU;EAAEW,WAAWpD;EAAkBkE,UAAUlE;CAAiB;CACpEiD,MAAM;EACJQ,YAAY9D,OAAOwD,MAAMM,WAAWU,IAAI;EACxCR,UAAUR,MAAMQ,SAASS;EACzBC,YAAYlB,MAAMkB,WAAWD;EAC7BP,OAAOV,MAAMW,OAAOb;EAAIK,mBAAA,CAAA,CAAA;CAC1B;CACAf,MAAM;EAAEkB,YAAY9D,OAAOwD,MAAMM,WAAWC,IAAI;EAAGC,UAAUR,MAAMQ,SAASS;EAAIP,OAAOV,MAAMW,OAAOQ;EAAGhB,mBAAA,CAAA,CAAA;CAAC;CACxGZ,OAAO;EAAEe,YAAY9D,OAAOwD,MAAMM,WAAWC,IAAI;EAAGC,UAAUR,MAAMQ,SAASS;EAAIP,OAAOV,MAAMW,OAAOS;EAAGjB,mBAAA,CAAA,CAAA;CAAC;AAC3G,EAAE"}
@@ -1,3 +1,4 @@
1
+ import { MarkdownImageLoader } from "./Markdown.mjs";
1
2
  import { FilePreviewProps } from "./FilePreview.mjs";
2
3
  import { BoundedFileSource, FileTextPreview } from "@agimon-ai/po-web-components/text";
3
4
  import { ReactNode } from "react";
@@ -39,6 +40,8 @@ export interface FileViewerProps {
39
40
  nativeSaveFile?: (source: BoundedFileSource) => Promise<void>;
40
41
  renderFilePreview?: FilePreviewProps['renderFilePreview'];
41
42
  renderMediaPreview?: FilePreviewProps['renderMediaPreview'];
43
+ /** Loads relative or scoped inline images inside Markdown previews. */
44
+ loadImage?: MarkdownImageLoader;
42
45
  /** The native top bar of the tab screen; absent in older hosts, where the viewer draws its own header. */
43
46
  setTabHeader?: (header: {
44
47
  subtitle?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"FileViewer.d.mts","names":[],"sources":["../../src/components/FileView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AEA;;EAEA,SAAS;;;wBAIK,WAAW,OAAO,kCAAe,IAAA;;wBAoLjC,gBAAgB,MAAM;EAAgB;EAAc;oBAAqB,IAAA;;wBAgBzE,mBACd,MACA,MACA,QACA,SACA,UACA,YACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;oBACD,IAAA"}
@@ -15,6 +15,9 @@ import { useT } from "@agimon-ai/po-core/native";
15
15
  import { ScrollView } from "react-native-unistyles/components/native/ScrollView";
16
16
 
17
17
  //#region src/components/FileViewer.tsx
18
+ /** Sealed inline media preview cap: larger files offer immediate chunked Save file handoff. */
19
+ const MAX_INLINE_MEDIA_BYTES = 5242880;
20
+ const TOUCH_TARGET_MIN = 44;
18
21
  /** Single-flight bounded save lifecycle shared by the file viewer and the selection sheet. */
19
22
  function useBoundedFileSave({ key, disabled, prepareSave, nativeSaveFile }) {
20
23
  const t = useT();
@@ -91,6 +94,7 @@ function FileViewer(props) {
91
94
  };
92
95
  });
93
96
  const showsMedia = props.renderMediaPreview !== void 0;
97
+ const oversizedMedia = filePreviewMode(path) === "media" && item !== void 0 && item.size > MAX_INLINE_MEDIA_BYTES;
94
98
  useEffect(() => {
95
99
  if (unavailable || hasStatus) return;
96
100
  const controller = new AbortController();
@@ -101,7 +105,7 @@ function FileViewer(props) {
101
105
  preview
102
106
  });
103
107
  const media = loaders.current.loadMedia;
104
- if (filePreviewMode(path) !== "media" || !showsMedia || !media) return;
108
+ if (filePreviewMode(path) !== "media" || !showsMedia || !media || oversizedMedia) return;
105
109
  try {
106
110
  const bytes = await media(controller.signal);
107
111
  if (!controller.signal.aborted) setLoaded({
@@ -127,6 +131,7 @@ function FileViewer(props) {
127
131
  path,
128
132
  key,
129
133
  showsMedia,
134
+ oversizedMedia,
130
135
  unavailable,
131
136
  hasStatus,
132
137
  attempt
@@ -165,6 +170,7 @@ function FileViewer(props) {
165
170
  variant: "ghost",
166
171
  size: "icon",
167
172
  disabled: offline,
173
+ style: styles.minTouch,
168
174
  accessibilityLabel: saving ? t("nativeComponents.fileViewer.cancelDownload", "Cancel download") : t("nativeComponents.fileViewer.download", "Download"),
169
175
  onPress: () => saving ? handlers.current.cancel() : void handlers.current.save(),
170
176
  children: saving ? /* @__PURE__ */ jsx(CloseIcon, { color: "hi" }) : /* @__PURE__ */ jsx(DownloadIcon, { color: "hi" })
@@ -209,6 +215,17 @@ function FileViewer(props) {
209
215
  renderMediaPreview: props.renderMediaPreview,
210
216
  media: current.media,
211
217
  mediaError: current.mediaError,
218
+ mediaSave: filePreviewMode(path) === "media" ? {
219
+ size: item?.size,
220
+ kindLabel: fileKindLabel(fileKind(path), t),
221
+ oversized: oversizedMedia,
222
+ canSave,
223
+ saving,
224
+ disabled: offline,
225
+ onSave: () => void save(),
226
+ onCancel: cancel
227
+ } : void 0,
228
+ loadImage: props.loadImage,
212
229
  onOpen: props.onOpenPath
213
230
  }) : /* @__PURE__ */ jsx(Text, {
214
231
  style: styles.meta,
@@ -302,6 +319,7 @@ function FileViewerHeader({ path, size, saving, canSave, disabled, onDownload, o
302
319
  variant: "ghost",
303
320
  size: "sm",
304
321
  onPress: onCancel,
322
+ style: styles.minTouch,
305
323
  children: t("nativeComponents.fileViewer.cancel", "Cancel")
306
324
  }) : null,
307
325
  canSave ? /* @__PURE__ */ jsx(Button, {
@@ -309,6 +327,7 @@ function FileViewerHeader({ path, size, saving, canSave, disabled, onDownload, o
309
327
  size: "sm",
310
328
  disabled: saving || disabled,
311
329
  onPress: onDownload,
330
+ style: styles.minTouch,
312
331
  children: t("nativeComponents.fileViewer.download", "Download")
313
332
  }) : null
314
333
  ]
@@ -361,6 +380,10 @@ const styles = StyleSheet.create((theme, rt) => ({
361
380
  fontSize: theme.fontSize.sm,
362
381
  color: theme.colors.dim,
363
382
  uni__dependencies: [0]
383
+ },
384
+ minTouch: {
385
+ minHeight: TOUCH_TARGET_MIN,
386
+ minWidth: TOUCH_TARGET_MIN
364
387
  }
365
388
  }));
366
389
 
@@ -1 +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","BoundedFileSaveOptions","key","disabled","prepareSave","signal","AbortSignal","Promise","nativeSaveFile","source","BoundedFileSaveState","canSave","saving","note","failed","save","cancel","useBoundedFileSave","t","controllerRef","AbortController","undefined","download","setDownload","own","current","abort","controller","file","aborted","error","Error","message","String","Loaded","preview","media","data","mimeType","mediaError","FileViewerProps","path","item","size","modifiedAt","scopeKey","loadPreview","loadMedia","renderFilePreview","renderMediaPreview","setTabHeader","header","subtitle","action","onOpenPath","actions","unavailable","status","FileViewer","props","hasStatus","version","downloadKey","loaded","setLoaded","attempt","setAttempt","loaders","showsMedia","then","bytes","catch","downloadNote","downloadFailed","Boolean","ownDownload","handlers","offline","label","onAction","loading","styles","meta","body","n","screen","stage","content","FilePathStrip","now","Date","strip","stripPath","FileViewerHeader","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\nexport interface BoundedFileSaveOptions {\n /** Resets status and aborts any in-flight save whenever the target file changes. */\n key: string;\n disabled?: boolean;\n prepareSave?: (signal: AbortSignal) => Promise<BoundedFileSource>;\n nativeSaveFile?: (source: BoundedFileSource) => Promise<void>;\n}\n\nexport interface BoundedFileSaveState {\n canSave: boolean;\n saving: boolean;\n note?: string;\n failed?: string;\n save: () => Promise<void>;\n cancel: () => void;\n}\n\n/** Single-flight bounded save lifecycle shared by the file viewer and the selection sheet. */\nexport function useBoundedFileSave({\n key,\n disabled,\n prepareSave,\n nativeSaveFile,\n}: BoundedFileSaveOptions): BoundedFileSaveState {\n const t = useT();\n const controllerRef = useRef<AbortController | undefined>(undefined);\n const [download, setDownload] = useState<{ key: string; saving?: boolean; note?: string; failed?: string }>();\n const own = download?.key === key ? download : undefined;\n\n useEffect(\n () => () => {\n controllerRef.current?.abort();\n controllerRef.current = undefined;\n },\n [key],\n );\n\n const canSave = nativeSaveFile !== undefined && prepareSave !== undefined;\n const saving = own?.saving === true;\n\n const save = async () => {\n if (disabled || !nativeSaveFile || !prepareSave || controllerRef.current) return;\n const controller = new AbortController();\n controllerRef.current = controller;\n // A retry keeps the failure on screen with its button busy, as the approved Retrying target shows.\n setDownload({ key, saving: true, failed: own?.failed });\n try {\n const file = await prepareSave(controller.signal);\n if (controller.signal.aborted || controllerRef.current !== controller) return;\n await nativeSaveFile(file);\n if (!controller.signal.aborted && controllerRef.current === controller)\n setDownload({ key, note: t('nativeComponents.fileViewer.saved', 'Saved.') });\n } catch (error) {\n if (!controller.signal.aborted && controllerRef.current === controller)\n setDownload({ key, failed: error instanceof Error ? error.message : String(error) });\n } finally {\n if (controllerRef.current === controller) controllerRef.current = undefined;\n }\n };\n\n const cancel = () => {\n controllerRef.current?.abort();\n controllerRef.current = undefined;\n setDownload({ key, note: t('nativeComponents.fileViewer.cancelled', 'Download cancelled.') });\n };\n\n return {\n canSave,\n saving,\n note: own?.note,\n failed: own?.failed,\n save,\n cancel,\n };\n}\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 {\n canSave,\n saving,\n note: downloadNote,\n failed: downloadFailed,\n save,\n cancel,\n } = useBoundedFileSave({\n key: downloadKey,\n disabled: Boolean(unavailable),\n prepareSave,\n nativeSaveFile: props.nativeSaveFile,\n });\n const ownDownload =\n downloadNote !== undefined || downloadFailed !== undefined || saving\n ? { key: downloadKey, saving, note: downloadNote, failed: downloadFailed }\n : undefined;\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":";;;;;;;;;;;;;;;;;;AAuCA,SAAgBqC,mBAAmB,EACjCf,KACAC,UACAC,aACAI,kBAC+C;CAC/C,MAAMU,IAAItC,KAAK;CACf,MAAMuC,gBAAgB9B,OAAoCgC,MAAS;CACnE,MAAM,CAACC,UAAUC,eAAejC,SAA4E;CAC5G,MAAMkC,MAAMF,UAAUpB,QAAQA,MAAMoB,WAAWD;CAE/CjC,sBACc;EACV+B,cAAcM,SAASC,MAAM;EAC7BP,cAAcM,UAAUJ;CAC1B,GACA,CAACnB,GAAG,CACN;CAEA,MAAMS,UAAUH,mBAAmBa,UAAajB,gBAAgBiB;CAChE,MAAMT,SAASY,KAAKZ,WAAW;CAE/B,MAAMG,OAAO,YAAY;EACvB,IAAIZ,YAAY,CAACK,kBAAkB,CAACJ,eAAee,cAAcM,SAAS;EAC1E,MAAME,aAAa,IAAIP,gBAAgB;EACvCD,cAAcM,UAAUE;EAExBJ,YAAY;GAAErB;GAAKU,QAAQ;GAAME,QAAQU,KAAKV;EAAO,CAAC;EACtD,IAAI;GACF,MAAMc,OAAO,MAAMxB,YAAYuB,WAAWtB,MAAM;GAChD,IAAIsB,WAAWtB,O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,SAAS;EAAEa,SAASH,MAAMI,QAAQ,CAAC;EAAGC,KAAKL,MAAMI,QAAQ,CAAC;EAACE,mBAAA,CAAA,CAAA;CAAC;CAC5DZ,OAAO;EACLa,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;CACAX,WAAW,EAAEwB,YAAY,EAAE;CAC3BjE,QAAQ;EACNqD,eAAe;EACfC,YAAY;EACZH,KAAKL,MAAMI,QAAQ,CAAC;EACpBO,eAAeX,MAAMI,QAAQ,CAAC;EAC9BgB,mBAAmB;EACnBC,mBAAmBrB,MAAMgB,OAAO;EAAcV,mBAAA,CAAA,CAAA;CAChD;CACAzB,OAAO;EAAEqB,MAAM;EAAGoB,UAAU;EAAGjB,KAAKL,MAAMI,QAAQ,EAAG;EAACE,mBAAA,CAAA,CAAA;CAAC;CACvD9D,MAAM;EAAE+E,YAAY7H,OAAOsG,MAAMuB,WAAWC,IAAI;EAAGC,UAAUzB,MAAMyB,SAASC;EAAIC,OAAO3B,MAAMgB,OAAOY;EAAGtB,mBAAA,CAAA,CAAA;CAAC;CACxGrB,MAAM;EAAEsC,YAAY7H,OAAOsG,MAAMuB,WAAWM,IAAI;EAAGJ,UAAUzB,MAAMyB,SAASC;EAAIC,OAAO3B,MAAMgB,OAAOY;EAAGtB,mBAAA,CAAA,CAAA;CAAC;AAC1G,EAAE"}
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","MarkdownImageLoader","MAX_INLINE_MEDIA_BYTES","TOUCH_TARGET_MIN","BoundedFileSaveOptions","key","disabled","prepareSave","signal","AbortSignal","Promise","nativeSaveFile","source","BoundedFileSaveState","canSave","saving","note","failed","save","cancel","useBoundedFileSave","t","controllerRef","AbortController","undefined","download","setDownload","own","current","abort","controller","file","aborted","error","Error","message","String","Loaded","preview","media","data","mimeType","mediaError","FileViewerProps","path","item","size","modifiedAt","scopeKey","loadPreview","loadMedia","renderFilePreview","renderMediaPreview","loadImage","setTabHeader","header","subtitle","action","onOpenPath","actions","unavailable","status","FileViewer","props","hasStatus","version","downloadKey","loaded","setLoaded","attempt","setAttempt","loaders","showsMedia","oversizedMedia","then","bytes","catch","downloadNote","downloadFailed","Boolean","ownDownload","handlers","offline","styles","minTouch","label","onAction","loading","meta","body","n","kindLabel","oversized","onSave","onCancel","screen","stage","content","FilePathStrip","now","Date","strip","stripPath","FileViewerHeader","onDownload","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","minHeight"],"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';\nimport type { MarkdownImageLoader } from './Markdown';\n\n/** Sealed inline media preview cap: larger files offer immediate chunked Save file handoff. */\nconst MAX_INLINE_MEDIA_BYTES = 5 * 1024 * 1024;\nconst TOUCH_TARGET_MIN = 44;\n\nexport interface BoundedFileSaveOptions {\n /** Resets status and aborts any in-flight save whenever the target file changes. */\n key: string;\n disabled?: boolean;\n prepareSave?: (signal: AbortSignal) => Promise<BoundedFileSource>;\n nativeSaveFile?: (source: BoundedFileSource) => Promise<void>;\n}\n\nexport interface BoundedFileSaveState {\n canSave: boolean;\n saving: boolean;\n note?: string;\n failed?: string;\n save: () => Promise<void>;\n cancel: () => void;\n}\n\n/** Single-flight bounded save lifecycle shared by the file viewer and the selection sheet. */\nexport function useBoundedFileSave({\n key,\n disabled,\n prepareSave,\n nativeSaveFile,\n}: BoundedFileSaveOptions): BoundedFileSaveState {\n const t = useT();\n const controllerRef = useRef<AbortController | undefined>(undefined);\n const [download, setDownload] = useState<{ key: string; saving?: boolean; note?: string; failed?: string }>();\n const own = download?.key === key ? download : undefined;\n\n useEffect(\n () => () => {\n controllerRef.current?.abort();\n controllerRef.current = undefined;\n },\n [key],\n );\n\n const canSave = nativeSaveFile !== undefined && prepareSave !== undefined;\n const saving = own?.saving === true;\n\n const save = async () => {\n if (disabled || !nativeSaveFile || !prepareSave || controllerRef.current) return;\n const controller = new AbortController();\n controllerRef.current = controller;\n // A retry keeps the failure on screen with its button busy, as the approved Retrying target shows.\n setDownload({ key, saving: true, failed: own?.failed });\n try {\n const file = await prepareSave(controller.signal);\n if (controller.signal.aborted || controllerRef.current !== controller) return;\n await nativeSaveFile(file);\n if (!controller.signal.aborted && controllerRef.current === controller)\n setDownload({ key, note: t('nativeComponents.fileViewer.saved', 'Saved.') });\n } catch (error) {\n if (!controller.signal.aborted && controllerRef.current === controller)\n setDownload({ key, failed: error instanceof Error ? error.message : String(error) });\n } finally {\n if (controllerRef.current === controller) controllerRef.current = undefined;\n }\n };\n\n const cancel = () => {\n controllerRef.current?.abort();\n controllerRef.current = undefined;\n setDownload({ key, note: t('nativeComponents.fileViewer.cancelled', 'Download cancelled.') });\n };\n\n return {\n canSave,\n saving,\n note: own?.note,\n failed: own?.failed,\n save,\n cancel,\n };\n}\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 /** Loads relative or scoped inline images inside Markdown previews. */\n loadImage?: MarkdownImageLoader;\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 const oversizedMedia = filePreviewMode(path) === 'media' && item !== undefined && item.size > MAX_INLINE_MEDIA_BYTES;\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 || oversizedMedia) 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, oversizedMedia, unavailable, hasStatus, attempt]);\n const current = loaded?.key === key ? loaded : undefined;\n const {\n canSave,\n saving,\n note: downloadNote,\n failed: downloadFailed,\n save,\n cancel,\n } = useBoundedFileSave({\n key: downloadKey,\n disabled: Boolean(unavailable),\n prepareSave,\n nativeSaveFile: props.nativeSaveFile,\n });\n const ownDownload =\n downloadNote !== undefined || downloadFailed !== undefined || saving\n ? { key: downloadKey, saving, note: downloadNote, failed: downloadFailed }\n : undefined;\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 style={styles.minTouch}\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 mediaSave={\n filePreviewMode(path) === 'media'\n ? {\n size: item?.size,\n kindLabel: fileKindLabel(fileKind(path), t),\n oversized: oversizedMedia,\n canSave,\n saving,\n disabled: offline,\n onSave: () => void save(),\n onCancel: cancel,\n }\n : undefined\n }\n loadImage={props.loadImage}\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} style={styles.minTouch}>\n {t('nativeComponents.fileViewer.cancel', 'Cancel')}\n </Button>\n ) : null}\n {canSave ? (\n <Button variant=\"outline\" size=\"sm\" disabled={saving || disabled} onPress={onDownload} style={styles.minTouch}>\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 minTouch: { minHeight: TOUCH_TARGET_MIN, minWidth: TOUCH_TARGET_MIN },\n}));\n"],"mappings":";;;;;;;;;;;;;;;;;;AAuBA,MAAMsB,yBAAyB;AAC/B,MAAMC,mBAAmB;;AAoBzB,SAAgBiB,mBAAmB,EACjCf,KACAC,UACAC,aACAI,kBAC+C;CAC/C,MAAMU,IAAIzC,KAAK;CACf,MAAM0C,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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;CACAV,WAAW,EAAEuB,YAAY,EAAE;CAC3BtE,QAAQ;EACN0D,eAAe;EACfC,YAAY;EACZH,KAAKL,MAAMI,QAAQ,CAAC;EACpBO,eAAeX,MAAMI,QAAQ,CAAC;EAC9BgB,mBAAmB;EACnBC,mBAAmBrB,MAAMgB,OAAO;EAAcV,mBAAA,CAAA,CAAA;CAChD;CACA3B,OAAO;EAAEuB,MAAM;EAAGoB,UAAU;EAAGjB,KAAKL,MAAMI,QAAQ,EAAG;EAACE,mBAAA,CAAA,CAAA;CAAC;CACvDpE,MAAM;EAAEqF,YAAYtI,OAAO+G,MAAMuB,WAAWC,IAAI;EAAGC,UAAUzB,MAAMyB,SAASC;EAAIC,OAAO3B,MAAMgB,OAAOY;EAAGtB,mBAAA,CAAA,CAAA;CAAC;CACxGxB,MAAM;EAAEyC,YAAYtI,OAAO+G,MAAMuB,WAAWM,IAAI;EAAGJ,UAAUzB,MAAMyB,SAASC;EAAIC,OAAO3B,MAAMgB,OAAOY;EAAGtB,mBAAA,CAAA,CAAA;CAAC;CACxG5B,UAAU;EAAEoD,WAAWrI;EAAkB6H,UAAU7H;CAAiB;AACtE,EAAE"}
@@ -1,9 +1,11 @@
1
1
  //#region src/components/InfoStrip.d.ts
2
2
  /** A quiet explanation with an optional text action, without live activity. */
3
- export declare function InfoStrip({ message, actionLabel, onAction }: {
3
+ export declare function InfoStrip({ message, actionLabel, onAction, dismissLabel, onDismiss }: {
4
4
  message: string;
5
5
  actionLabel?: string;
6
6
  onAction?: () => void;
7
+ dismissLabel?: string;
8
+ onDismiss?: () => void;
7
9
  }): import("react").JSX.Element;
8
10
  //#endregion
9
11
  //# sourceMappingURL=InfoStrip.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"InfoStrip.d.mts","names":[],"sources":["../../src/components/InfoStrip.tsx"],"mappings":";;wBASgB,YACd,SACA,aACA;EAEA;EACA;EACA;oBACD,IAAA"}
1
+ {"version":3,"file":"InfoStrip.d.mts","names":[],"sources":["../../src/components/InfoStrip.tsx"],"mappings":";;wBASgB,YACd,SACA,aACA,UACA,cACA;EAEA;EACA;EACA;EACA;EACA;oBACD,IAAA"}
@@ -8,7 +8,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
8
8
 
9
9
  //#region src/components/InfoStrip.tsx
10
10
  /** A quiet explanation with an optional text action, without live activity. */
11
- function InfoStrip({ message, actionLabel, onAction }) {
11
+ function InfoStrip({ message, actionLabel, onAction, dismissLabel, onDismiss }) {
12
12
  return /* @__PURE__ */ jsxs(Panel, {
13
13
  style: styles.strip,
14
14
  children: [
@@ -25,6 +25,12 @@ function InfoStrip({ message, actionLabel, onAction }) {
25
25
  style: styles.action,
26
26
  onPress: onAction,
27
27
  children: actionLabel
28
+ }) : null,
29
+ onDismiss && dismissLabel ? /* @__PURE__ */ jsx(Button, {
30
+ variant: "ghost",
31
+ style: styles.action,
32
+ onPress: onDismiss,
33
+ children: dismissLabel
28
34
  }) : null
29
35
  ]
30
36
  });
@@ -45,7 +51,10 @@ const styles = StyleSheet.create((theme) => ({
45
51
  color: theme.colors.dim,
46
52
  uni__dependencies: [0]
47
53
  },
48
- action: { minHeight: 44 }
54
+ action: {
55
+ minHeight: 44,
56
+ minWidth: 44
57
+ }
49
58
  }));
50
59
 
51
60
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"InfoStrip.mjs","names":["StyleSheet","AlertIcon","fontOf","Button","Panel","InfoStrip","message","actionLabel","onAction","styles","strip","text","action","create","theme","flexDirection","alignItems","gap","spacing","padding","uni__dependencies","flex","fontFamily","sans","fontSize","sm","lineHeight","color","colors","dim","minHeight"],"sources":["../../src/components/InfoStrip.tsx"],"sourcesContent":["import { Text } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { AlertIcon } from '../icons/icons';\nimport { fontOf } from '../lib/fonts';\nimport { Button } from './Button';\nimport { Panel } from './Panel';\n\n/** A quiet explanation with an optional text action, without live activity. */\nexport function InfoStrip({\n message,\n actionLabel,\n onAction,\n}: {\n message: string;\n actionLabel?: string;\n onAction?: () => void;\n}) {\n return (\n <Panel style={styles.strip}>\n <AlertIcon size={16} color=\"dim\" />\n <Text style={styles.text}>{message}</Text>\n {onAction && actionLabel ? (\n <Button variant=\"ghost\" style={styles.action} onPress={onAction}>\n {actionLabel}\n </Button>\n ) : null}\n </Panel>\n );\n}\nconst styles = StyleSheet.create((theme) => ({\n strip: { flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2), padding: theme.spacing(3) },\n text: {\n flex: 1,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n color: theme.colors.dim,\n },\n action: { minHeight: 44 },\n}));\n"],"mappings":";;;;;;;;;;AASA,SAAgBK,UAAU,EACxBC,SACAC,aACAC,YAKC;CACD,OACE,qBAAC,OAAD;EAAO,OAAOC,OAAOC;YAArB;GACE,oBAAC,WAAD;IAAW,MAAM;IAAI,OAAM;GAAK;GAChC,oBAAC,MAAD;IAAM,OAAOD,OAAOE;cAAOL;GAAc;GACxCE,YAAYD,cACX,oBAAC,QAAD;IAAQ,SAAQ;IAAQ,OAAOE,OAAOG;IAAQ,SAASJ;cACpDD;GACK,KACN;EACC;;AAEX;AACA,MAAME,SAAST,WAAWa,QAAQC,WAAW;CAC3CJ,OAAO;EAAEK,eAAe;EAAOC,YAAY;EAAUC,KAAKH,MAAMI,QAAQ,CAAC;EAAGC,SAASL,MAAMI,QAAQ,CAAC;EAACE,mBAAA,CAAA,CAAA;CAAC;CACtGT,MAAM;EACJU,MAAM;EACNC,YAAYpB,OAAOY,MAAMQ,WAAWC,IAAI;EACxCC,UAAUV,MAAMU,SAASC;EACzBC,YAAYZ,MAAMY,WAAWD;EAC7BE,OAAOb,MAAMc,OAAOC;EAAGT,mBAAA,CAAA,CAAA;CACzB;CACAR,QAAQ,EAAEkB,WAAW,GAAG;AAC1B,EAAE"}
1
+ {"version":3,"file":"InfoStrip.mjs","names":["StyleSheet","AlertIcon","fontOf","Button","Panel","InfoStrip","message","actionLabel","onAction","dismissLabel","onDismiss","styles","strip","text","action","create","theme","flexDirection","alignItems","gap","spacing","padding","uni__dependencies","flex","fontFamily","sans","fontSize","sm","lineHeight","color","colors","dim","minHeight","minWidth"],"sources":["../../src/components/InfoStrip.tsx"],"sourcesContent":["import { Text } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { AlertIcon } from '../icons/icons';\nimport { fontOf } from '../lib/fonts';\nimport { Button } from './Button';\nimport { Panel } from './Panel';\n\n/** A quiet explanation with an optional text action, without live activity. */\nexport function InfoStrip({\n message,\n actionLabel,\n onAction,\n dismissLabel,\n onDismiss,\n}: {\n message: string;\n actionLabel?: string;\n onAction?: () => void;\n dismissLabel?: string;\n onDismiss?: () => void;\n}) {\n return (\n <Panel style={styles.strip}>\n <AlertIcon size={16} color=\"dim\" />\n <Text style={styles.text}>{message}</Text>\n {onAction && actionLabel ? (\n <Button variant=\"ghost\" style={styles.action} onPress={onAction}>\n {actionLabel}\n </Button>\n ) : null}\n {onDismiss && dismissLabel ? (\n <Button variant=\"ghost\" style={styles.action} onPress={onDismiss}>\n {dismissLabel}\n </Button>\n ) : null}\n </Panel>\n );\n}\nconst styles = StyleSheet.create((theme) => ({\n strip: { flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2), padding: theme.spacing(3) },\n text: {\n flex: 1,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n color: theme.colors.dim,\n },\n action: { minHeight: 44, minWidth: 44 },\n}));\n"],"mappings":";;;;;;;;;;AASA,SAAgBK,UAAU,EACxBC,SACAC,aACAC,UACAC,cACAC,aAOC;CACD,OACE,qBAAC,OAAD;EAAO,OAAOC,OAAOC;YAArB;GACE,oBAAC,WAAD;IAAW,MAAM;IAAI,OAAM;GAAK;GAChC,oBAAC,MAAD;IAAM,OAAOD,OAAOE;cAAOP;GAAc;GACxCE,YAAYD,cACX,oBAAC,QAAD;IAAQ,SAAQ;IAAQ,OAAOI,OAAOG;IAAQ,SAASN;cACpDD;GACK,KACN;GACHG,aAAaD,eACZ,oBAAC,QAAD;IAAQ,SAAQ;IAAQ,OAAOE,OAAOG;IAAQ,SAASJ;cACpDD;GACK,KACN;EACC;;AAEX;AACA,MAAME,SAASX,WAAWe,QAAQC,WAAW;CAC3CJ,OAAO;EAAEK,eAAe;EAAOC,YAAY;EAAUC,KAAKH,MAAMI,QAAQ,CAAC;EAAGC,SAASL,MAAMI,QAAQ,CAAC;EAACE,mBAAA,CAAA,CAAA;CAAC;CACtGT,MAAM;EACJU,MAAM;EACNC,YAAYtB,OAAOc,MAAMQ,WAAWC,IAAI;EACxCC,UAAUV,MAAMU,SAASC;EACzBC,YAAYZ,MAAMY,WAAWD;EAC7BE,OAAOb,MAAMc,OAAOC;EAAGT,mBAAA,CAAA,CAAA;CACzB;CACAR,QAAQ;EAAEkB,WAAW;EAAIC,UAAU;CAAG;AACxC,EAAE"}
@@ -77,7 +77,7 @@ function InlineLink({ href, children }) {
77
77
  accessibilityRole: "link",
78
78
  onPress: () => {
79
79
  if (open !== void 0) open();
80
- else if (!isFile) Linking.openURL(href).catch(() => void 0);
80
+ else if (!isFile) Linking.openURL(href).catch(() => false);
81
81
  },
82
82
  style: styles.link,
83
83
  children
@@ -88,8 +88,8 @@ function MarkdownImage({ src, alt }) {
88
88
  const loader = useContext(ImageContext);
89
89
  const t = useT();
90
90
  const imageName = alt || t("nativeComponents.markdown.image", "Image");
91
- const source = src.startsWith("@artifact:") ? src.slice(1) : src;
92
- const path = URL_OR_ANCHOR.test(source) && !source.startsWith("artifact:") ? void 0 : decoded(source.split(/[?#]/u, 1)[0]) ?? "";
91
+ const source = src.startsWith("@artifact:") || src.startsWith("@temporary:") ? src.slice(1) : src;
92
+ const path = URL_OR_ANCHOR.test(source) && !source.startsWith("artifact:") && !source.startsWith("temporary:") ? void 0 : decoded(source.split(/[?#]/u, 1)[0]) ?? "";
93
93
  const [loaded, setLoaded] = useState();
94
94
  const [ratio, setRatio] = useState(PLACEHOLDER_RATIO);
95
95
  useEffect(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"Markdown.mjs","names":["useT","createContext","memo","ReactNode","useContext","useEffect","useMemo","useState","Linking","StyleSheet","fontOf","exactReference","MarkdownBlock","MarkdownHeadingLevel","MarkdownInline","parseMarkdown","REFERENCE_HREF_PREFIX","READING","inlineLength","inlinePrefix","useReadingPage","CodeBlock","ShowMore","FileLinkHandler","text","explicit","InitialPageContext","FileLinkContext","undefined","ReferenceRenderer","reference","options","onLongPress","ReferenceContext","MarkdownImageLoader","path","Promise","url","dispose","ImageContext","URL_OR_ANCHOR","DIRECT_IMAGE","PLACEHOLDER_RATIO","decoded","href","decodeURIComponent","InlineCode","originalText","onFileLink","renderReference","drawn","open","includes","t","target","styles","code","fileLink","InlineLink","children","startsWith","slice","length","link","isFile","test","openURL","catch","MarkdownImage","src","alt","loader","imageName","source","split","loaded","setLoaded","failed","ratio","setRatio","active","asset","Awaited","ReturnType","resolve","then","Error","result","current","uri","waiting","prose","imageState","name","nativeEvent","fit","width","height","size","Image","getSize","image","aspectRatio","renderInline","nodes","map","node","index","type","strong","em","MarkdownTable","header","rows","initialPage","rowPage","setRows","columnPage","setColumns","cellPage","setCells","visibleRows","Math","max","visibleHeader","columns","limit","cell","clipped","row","some","root","table","column","headCell","meta","shownRows","totalRows","shownColumns","totalColumns","actions","page","Blocks","blocks","quoted","revealedPage","setPage","visible","parts","block","boundBlock","hiddenParts","shown","total","Infinity","characters","remaining","items","item","next","push","reduce","sum","Block","first","heading","level","firstHeading","run","flush","list","marker","ordered","start","itemText","language","rule","quote","MarkdownProps","loadImage","Markdown","generation","HEADING_STEP","const","HEADING_SPACE","HEADING_INK","create","theme","color","colors","dim","fontFamily","sans","fontSize","sm","lineHeight","uni__dependencies","flexDirection","flexWrap","minWidth","gap","spacing","base","marginTop","letterSpacing","fontWeight","semibold","hi","fontStyle","backgroundColor","deep","green","mono","textDecorationLine","blue","paddingLeft","flexShrink","borderLeftWidth","borderLeftColor","border","borderTopWidth","borderColor","paddingHorizontal","paddingVertical","borderRightWidth","borderBottomWidth","maxHeight","borderRadius","md","borderWidth"],"sources":["../../src/components/Markdown.tsx"],"sourcesContent":["import { useT } from '@agimon-ai/po-core/native';\nimport { createContext, memo, type ReactNode, useContext, useEffect, useMemo, useState } from 'react';\nimport { Image, Linking, ScrollView, Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\nimport {\n exactReference,\n type MarkdownBlock,\n type MarkdownHeadingLevel,\n type MarkdownInline,\n parseMarkdown,\n REFERENCE_HREF_PREFIX,\n} from '../lib/markdown';\nimport { READING, inlineLength, inlinePrefix } from '../lib/reading';\nimport { useReadingPage } from '../lib/useReadingPage';\nimport { CodeBlock } from './CodeBlock';\nimport { ShowMore } from './ShowMore';\n\n/*\n * Markdown in the web component's element styles, from the package's own\n * parser: headings, paragraphs, lists, code spans and fences, bold, italic,\n * links, images, blockquotes and tables. Web links open with Linking; a file\n * path goes to the host. Raw HTML blocks are left out, as on the web.\n */\n\n/**\n * What a piece of inline code, a relative link or an `@scheme:value` reference\n * (handed over as `scheme:value`) opens, when the host knows.\n * Returning undefined leaves it as plain code or an ordinary link. The same\n * contract as the web Markdown's handler.\n */\nexport type FileLinkHandler = (text: string, explicit?: boolean) => (() => void) | undefined;\n\n/** Passed by context so the inline renderers stay module functions. */\nconst InitialPageContext = createContext(1);\n\nconst FileLinkContext = createContext<FileLinkHandler | undefined>(undefined);\n\n/**\n * How an `@scheme:value` reference (handed over as `scheme:value`) is drawn, such as a chip that\n * opens it. Undefined leaves it to `onFileLink`: a plain link when claimed, else text. The same\n * contract as the web Markdown's renderer. What it returns sits inside Text, so it must be Text.\n * `onLongPress` is the surrounding text's, such as a message's actions, for the chip to pass on.\n */\nexport type ReferenceRenderer = (reference: string, options?: { onLongPress?: () => void }) => ReactNode | undefined;\nconst ReferenceContext = createContext<ReferenceRenderer | undefined>(undefined);\n\n/** Loads a relative image path from the host; the same contract as the web Markdown's `loadImage`. */\nexport type MarkdownImageLoader = (path: string) => Promise<{ url: string; dispose(): void }>;\n\nconst ImageContext = createContext<MarkdownImageLoader | undefined>(undefined);\n\nconst URL_OR_ANCHOR = /^(?:[a-z][a-z\\d+.-]*:|\\/\\/|#|\\?)/i;\n/** Sources an Image may load as written; any other scheme stays its alt text. */\nconst DIRECT_IMAGE = /^(?:https?:|data:image\\/)/i;\n/** Until the image reports its size, it holds a landscape box rather than collapsing. */\nconst PLACEHOLDER_RATIO = 16 / 9;\n\nfunction decoded(href: string): string | undefined {\n try {\n return decodeURIComponent(href);\n } catch {\n return undefined;\n }\n}\n\nfunction InlineCode({ text, originalText = text }: { text: string; originalText?: string }) {\n const onFileLink = useContext(FileLinkContext);\n const renderReference = useContext(ReferenceContext);\n // A span that is exactly one reference draws as prose does; one the renderer declines stays code.\n const reference = renderReference === undefined ? undefined : exactReference(originalText);\n const drawn = reference === undefined ? undefined : renderReference?.(reference);\n const open = reference !== undefined || originalText.includes('\\n') ? undefined : onFileLink?.(originalText);\n const t = useT();\n if (drawn !== undefined) return drawn;\n if (open !== undefined) {\n return (\n <Text\n accessibilityRole=\"link\"\n accessibilityHint={t('nativeComponents.markdown.openHint', 'open {target}', { target: originalText })}\n onPress={open}\n style={[styles.code, styles.fileLink]}\n >\n {text}\n </Text>\n );\n }\n return <Text style={styles.code}>{text}</Text>;\n}\n\nfunction InlineLink({ href, children }: { href: string; children: ReactNode }) {\n const onFileLink = useContext(FileLinkContext);\n const renderReference = useContext(ReferenceContext);\n const t = useT();\n // A reference the host does not open stays text; it is never handed to the system as a URL.\n if (href.startsWith(REFERENCE_HREF_PREFIX)) {\n const reference = decoded(href.slice(REFERENCE_HREF_PREFIX.length));\n const drawn = reference === undefined ? undefined : renderReference?.(reference);\n if (drawn !== undefined) return drawn;\n const open = reference === undefined ? undefined : onFileLink?.(reference);\n if (open === undefined) return <Text>{children}</Text>;\n return (\n <Text\n accessibilityRole=\"link\"\n accessibilityHint={t('nativeComponents.markdown.openHint', 'open {target}', { target: reference ?? '' })}\n onPress={open}\n style={styles.link}\n >\n {children}\n </Text>\n );\n }\n const path = decoded(href);\n const isFile = path !== undefined && path !== '' && !URL_OR_ANCHOR.test(path);\n const open = isFile ? onFileLink?.(path, true) : undefined;\n return (\n <Text\n accessibilityRole=\"link\"\n onPress={() => {\n if (open !== undefined) open();\n else if (!isFile) Linking.openURL(href).catch(() => undefined);\n }}\n style={styles.link}\n >\n {children}\n </Text>\n );\n}\n\n/** One image: a file path through the host's loader, or a web or data address as written. */\nfunction MarkdownImage({ src, alt }: { src: string; alt: string }) {\n const loader = useContext(ImageContext);\n const t = useT();\n const imageName = alt || t('nativeComponents.markdown.image', 'Image');\n // An invalid encoded filename is shown as unavailable, never fetched.\n const source = src.startsWith('@artifact:') ? src.slice(1) : src;\n const path =\n URL_OR_ANCHOR.test(source) && !source.startsWith('artifact:')\n ? undefined\n : (decoded(source.split(/[?#]/u, 1)[0]!) ?? '');\n const [loaded, setLoaded] = useState<{ path: string; url?: string; failed?: boolean }>();\n const [ratio, setRatio] = useState(PLACEHOLDER_RATIO);\n useEffect(() => {\n if (loader === undefined || path === undefined) return;\n let active = true;\n let asset: Awaited<ReturnType<MarkdownImageLoader>> | undefined;\n void Promise.resolve()\n .then(() => {\n if (path === '') throw new Error('Invalid image path.');\n return loader(path);\n })\n .then((result) => {\n if (!active) return result.dispose();\n asset = result;\n setLoaded({ path, url: result.url });\n })\n .catch(() => {\n // The failure is shown in place, as the web image does.\n if (active) setLoaded({ path, failed: true });\n });\n return () => {\n active = false;\n asset?.dispose();\n };\n }, [path, loader]);\n const current = loaded?.path === path ? loaded : undefined;\n const uri = path === undefined ? (DIRECT_IMAGE.test(src) ? src : undefined) : current?.url;\n if (uri === undefined || current?.failed) {\n const waiting = path !== undefined && loader !== undefined && current === undefined;\n return (\n <Text style={[styles.prose, styles.imageState]} accessibilityRole={waiting ? 'text' : 'alert'}>\n {waiting\n ? t('nativeComponents.markdown.imageLoading', '{name} (loading\\u2026)', { name: alt || path || imageName })\n : t('nativeComponents.markdown.imageUnavailable', '{name} (unavailable)', { name: alt || path || imageName })}\n </Text>\n );\n }\n return (\n <Image\n source={{ uri }}\n accessibilityLabel={imageName}\n accessibilityIgnoresInvertColors\n resizeMode=\"contain\"\n onLoad={({ nativeEvent }) => {\n const fit = (width: number, height: number) => {\n if (width > 0 && height > 0) setRatio(width / height);\n };\n // iOS and Android report the size with the event; react-native-web does not, so it asks.\n const size = (nativeEvent as { source?: { width: number; height: number } } | undefined)?.source;\n if (size !== undefined) fit(size.width, size.height);\n else Image.getSize(uri, fit, () => undefined);\n }}\n onError={() => setLoaded({ path: path ?? src, failed: true })}\n style={[styles.image, { aspectRatio: ratio }]}\n />\n );\n}\nfunction renderInline(nodes: readonly MarkdownInline[]): ReactNode[] {\n return nodes.map((node, index) => {\n switch (node.type) {\n case 'text':\n return node.text;\n case 'code':\n return <InlineCode key={index} text={node.text} originalText={node.originalText} />;\n case 'strong':\n return (\n <Text key={index} style={styles.strong}>\n {renderInline(node.children)}\n </Text>\n );\n case 'em':\n return (\n <Text key={index} style={styles.em}>\n {renderInline(node.children)}\n </Text>\n );\n case 'link':\n return (\n <InlineLink key={index} href={node.href}>\n {renderInline(node.children)}\n </InlineLink>\n );\n case 'image':\n // Inside a heading or list item an image keeps to its alt text; paragraphs draw it.\n return node.alt;\n }\n });\n}\n\n/**\n * A table read column by column: every cell keeps to one line inside the sideways scroll, so each\n * column takes its widest cell and the rows line up without a table layout.\n */\nfunction MarkdownTable({ header, rows }: { header: MarkdownInline[][]; rows: MarkdownInline[][][] }) {\n const initialPage = useContext(InitialPageContext);\n const t = useT();\n const [rowPage, setRows] = useState(initialPage);\n const [columnPage, setColumns] = useState(initialPage);\n const [cellPage, setCells] = useState(initialPage);\n const visibleRows = rows.slice(0, READING.rows * Math.max(initialPage, rowPage));\n const visibleHeader = header.slice(0, READING.columns * Math.max(initialPage, columnPage));\n const limit = READING.cell * Math.max(initialPage, cellPage);\n const clipped = [visibleHeader, ...visibleRows.map((row) => row.slice(0, visibleHeader.length))].some((row) =>\n row.some((cell) => inlineLength(cell) > limit),\n );\n return (\n <View style={styles.root}>\n <ScrollView horizontal showsHorizontalScrollIndicator={false}>\n <View style={styles.table}>\n {visibleHeader.map((cell, column) => (\n <View key={column}>\n <Text style={[styles.prose, styles.cell, styles.headCell]}>\n {renderInline(inlinePrefix(cell, limit))}\n {inlineLength(cell) > limit ? '…' : ''}\n </Text>\n {visibleRows.map((row, index) => (\n <Text key={index} style={[styles.prose, styles.cell]}>\n {renderInline(inlinePrefix(row[column] ?? [], limit))}\n {inlineLength(row[column] ?? []) > limit ? '…' : ''}\n </Text>\n ))}\n </View>\n ))}\n </View>\n </ScrollView>\n <Text style={styles.meta}>\n {t(\n 'nativeComponents.markdown.tableSummary',\n '{shownRows} of {totalRows} rows · {shownColumns} of {totalColumns} columns',\n {\n shownRows: visibleRows.length,\n totalRows: rows.length,\n shownColumns: visibleHeader.length,\n totalColumns: header.length,\n },\n )}\n {clipped ? ` · ${t('nativeComponents.markdown.cellLimit', 'Cells: first {limit} characters', { limit })}` : ''}\n </Text>\n <View style={styles.actions}>\n {visibleRows.length < rows.length ? (\n <ShowMore\n label={t('nativeComponents.markdown.showMoreRows', 'Show more rows')}\n onPress={() => setRows((page) => page + 1)}\n />\n ) : null}\n {visibleHeader.length < header.length ? (\n <ShowMore\n label={t('nativeComponents.markdown.showMoreColumns', 'Show more columns')}\n onPress={() => setColumns((page) => page + 1)}\n />\n ) : null}\n {clipped ? (\n <ShowMore\n label={t('nativeComponents.markdown.showMoreCells', 'Show more cell text')}\n onPress={() => setCells((page) => page + 1)}\n />\n ) : null}\n </View>\n </View>\n );\n}\n\n/** One Show more for the whole document: a single tap reveals every hidden part and clipped text. */\nfunction Blocks({ blocks, quoted = false }: { blocks: MarkdownBlock[]; quoted?: boolean }) {\n const initialPage = useContext(InitialPageContext);\n const t = useT();\n const [revealedPage, setPage] = useState(initialPage);\n const page = Math.max(initialPage, revealedPage);\n const visible = blocks.slice(0, READING.parts * page).map((block) => boundBlock(block, page));\n const hiddenParts = visible.length < blocks.length;\n return (\n <InitialPageContext.Provider value={page}>\n {visible.map(({ block }, index) => (\n <View key={index} style={styles.root}>\n <Block block={block} first={index === 0} quoted={quoted} />\n </View>\n ))}\n {hiddenParts || visible.some(({ clipped }) => clipped) ? (\n <ShowMore\n label={t('nativeComponents.markdown.showMore', 'Show more')}\n summary={\n hiddenParts\n ? t('nativeComponents.markdown.partsSummary', '{shown} of {total} parts', {\n shown: visible.length,\n total: blocks.length,\n })\n : undefined\n }\n onPress={() => setPage(Infinity)}\n />\n ) : null}\n </InitialPageContext.Provider>\n );\n}\n\n/** A heading, paragraph or list cut to the page's character budget, and whether anything was cut. */\nfunction boundBlock(block: MarkdownBlock, page: number): { block: MarkdownBlock; clipped: boolean } {\n const limit = READING.characters * page;\n if (block.type === 'heading' || block.type === 'paragraph') {\n const children = inlinePrefix(block.children, limit);\n return { block: { ...block, children }, clipped: inlineLength(children) < inlineLength(block.children) };\n }\n if (block.type !== 'list') return { block, clipped: false };\n let remaining = limit;\n let shown = 0;\n const items = [];\n for (const item of block.items.slice(0, READING.parts * page)) {\n if (remaining <= 0) break;\n const next = inlinePrefix(item, remaining);\n items.push(next);\n const length = inlineLength(next);\n shown += length;\n remaining -= length;\n }\n const total = block.items.reduce((sum, item) => sum + inlineLength(item), 0);\n return { block: { ...block, items }, clipped: shown < total || items.length < block.items.length };\n}\n\nfunction Block({ block, first, quoted = false }: { block: MarkdownBlock; first: boolean; quoted?: boolean }) {\n const initialPage = useContext(InitialPageContext);\n const prose = [styles.prose, quoted && styles.quoted];\n switch (block.type) {\n case 'heading':\n return (\n <Text\n accessibilityRole=\"header\"\n style={[...prose, styles.heading(block.level), first && styles.firstHeading, quoted && styles.quoted]}\n >\n {renderInline(block.children)}\n </Text>\n );\n case 'paragraph': {\n // An image breaks the paragraph's text into runs, since an Image cannot sit inside Text.\n const parts: ReactNode[] = [];\n let run: MarkdownInline[] = [];\n const flush = () => {\n if (run.length > 0)\n parts.push(\n <Text key={parts.length} style={prose}>\n {renderInline(run)}\n </Text>,\n );\n run = [];\n };\n for (const node of block.children) {\n if (node.type !== 'image') {\n run.push(node);\n continue;\n }\n flush();\n parts.push(<MarkdownImage key={parts.length} src={node.src} alt={node.alt} />);\n }\n flush();\n return parts.length === 1 ? parts[0] : <View style={styles.root}>{parts}</View>;\n }\n case 'list':\n return (\n <View accessibilityRole=\"list\" style={styles.list}>\n {block.items.map((item, index) => (\n <View key={index} style={styles.item}>\n <Text style={[...prose, styles.marker]}>{block.ordered ? `${block.start + index}.` : '\\u2022'}</Text>\n <Text style={[...prose, styles.itemText]}>{renderInline(item)}</Text>\n </View>\n ))}\n </View>\n );\n case 'code':\n return <CodeBlock text={block.text} language={block.language} initialPage={initialPage} />;\n case 'rule':\n return <View accessible={false} style={styles.rule} />;\n case 'quote':\n return (\n <View style={[styles.root, styles.quote]}>\n <Blocks blocks={block.children} quoted />\n </View>\n );\n case 'table':\n return <MarkdownTable header={block.header} rows={block.rows} />;\n }\n}\n\nexport interface MarkdownProps {\n text: string;\n onFileLink?: FileLinkHandler;\n /** Draws `@scheme:value` references and code spans that are exactly one; without it they link plainly. */\n renderReference?: ReferenceRenderer;\n /** Loads relative image paths; without it they show as unavailable. */\n loadImage?: MarkdownImageLoader;\n /** Initial reveal pages for a restored reading position. Defaults to one. */\n initialPage?: number;\n}\n\n/** Markdown in Po's shared presentation, parsed by the package's own small parser. */\nexport const Markdown = memo(function Markdown({\n text,\n onFileLink,\n renderReference,\n loadImage,\n initialPage = 1,\n}: MarkdownProps) {\n const blocks = useMemo(() => parseMarkdown(text), [text]);\n const { generation } = useReadingPage(text);\n return (\n <InitialPageContext.Provider value={initialPage}>\n <FileLinkContext.Provider value={onFileLink}>\n <ReferenceContext.Provider value={renderReference}>\n <ImageContext.Provider value={loadImage}>\n <View style={styles.root}>\n <Blocks key={generation} blocks={blocks} />\n </View>\n </ImageContext.Provider>\n </ReferenceContext.Provider>\n </FileLinkContext.Provider>\n </InitialPageContext.Provider>\n );\n});\n\n/**\n * Headings step up from the prose and never shrink below it; h4 to h6 keep\n * the prose size and lean on weight, fading from `hi` to `dim`.\n */\nconst HEADING_STEP = { 1: '2xl', 2: 'xl', 3: 'lg', 4: 'base', 5: 'base', 6: 'base' } as const;\nconst HEADING_SPACE = { 1: 2, 2: 2, 3: 1, 4: 0, 5: 0, 6: 0 } as const;\nconst HEADING_INK = { 1: 'hi', 2: 'hi', 3: 'hi', 4: 'hi', 5: 'text', 6: 'dim' } as const;\n\nconst styles = StyleSheet.create((theme) => ({\n meta: {\n color: theme.colors.dim,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n actions: { flexDirection: 'row', flexWrap: 'wrap' },\n root: { minWidth: 0, gap: theme.spacing(2) },\n prose: {\n color: theme.colors.text,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n heading: (level: MarkdownHeadingLevel) => ({\n marginTop: theme.spacing(HEADING_SPACE[level]),\n fontSize: theme.fontSize[HEADING_STEP[level]],\n lineHeight: theme.lineHeight[HEADING_STEP[level]],\n letterSpacing: theme.letterSpacing[HEADING_STEP[level]],\n fontWeight: theme.fontWeight.semibold,\n color: theme.colors[HEADING_INK[level]],\n }),\n firstHeading: { marginTop: 0 },\n strong: { fontWeight: theme.fontWeight.semibold, color: theme.colors.hi },\n em: { fontStyle: 'italic' },\n code: {\n backgroundColor: theme.colors.deep,\n color: theme.colors.green,\n fontFamily: fontOf(theme.fontFamily.mono),\n },\n fileLink: { textDecorationLine: 'underline' },\n link: { color: theme.colors.blue, textDecorationLine: 'underline' },\n list: { gap: theme.spacing(0.5) },\n item: { flexDirection: 'row', gap: theme.spacing(2), paddingLeft: theme.spacing(1) },\n marker: { minWidth: theme.spacing(3), color: theme.colors.dim },\n itemText: { flexShrink: 1 },\n rule: { height: 1, backgroundColor: theme.colors['border-soft'] },\n // The web blockquote: a rule at the left and quieter text.\n quote: { borderLeftWidth: 2, borderLeftColor: theme.colors.border, paddingLeft: theme.spacing(3) },\n quoted: { color: theme.colors.dim },\n // The web table: bordered cells, the header on the deep surface.\n table: {\n flexDirection: 'row',\n borderTopWidth: 1,\n borderLeftWidth: 1,\n borderColor: theme.colors.border,\n },\n cell: {\n paddingHorizontal: theme.spacing(2),\n paddingVertical: theme.spacing(1),\n borderRightWidth: 1,\n borderBottomWidth: 1,\n borderColor: theme.colors.border,\n },\n headCell: { backgroundColor: theme.colors.deep, fontWeight: theme.fontWeight.semibold, color: theme.colors.hi },\n // The web image's frame: at most 480 tall, a soft border and rounded corners.\n image: {\n width: '100%',\n maxHeight: 480,\n borderRadius: theme.borderRadius.md,\n borderWidth: 1,\n borderColor: theme.colors.border,\n },\n imageState: { color: theme.colors.dim },\n}));\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmCA,MAAM0B,qBAAqBzB,cAAc,CAAC;AAE1C,MAAM0B,kBAAkB1B,cAA2C2B,MAAS;AAS5E,MAAMK,mBAAmBhC,cAA6C2B,MAAS;AAK/E,MAAMW,eAAetC,cAA+C2B,MAAS;AAE7E,MAAMY,gBAAgB;;AAEtB,MAAMC,eAAe;;AAErB,MAAMC,oBAAoB,KAAK;AAE/B,SAASC,QAAQC,MAAkC;CACjD,IAAI;EACF,OAAOC,mBAAmBD,IAAI;CAChC,QAAQ;EACN;CACF;AACF;AAEA,SAASE,WAAW,EAAEtB,MAAMuB,eAAev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AGM,mBAAA,CAAA,CAAA;CAAC;AACxC,EAAE"}
1
+ {"version":3,"file":"Markdown.mjs","names":["useT","createContext","memo","ReactNode","useContext","useEffect","useMemo","useState","Linking","StyleSheet","fontOf","exactReference","MarkdownBlock","MarkdownHeadingLevel","MarkdownInline","parseMarkdown","REFERENCE_HREF_PREFIX","READING","inlineLength","inlinePrefix","useReadingPage","CodeBlock","ShowMore","FileLinkHandler","text","explicit","InitialPageContext","FileLinkContext","undefined","ReferenceRenderer","reference","options","onLongPress","ReferenceContext","MarkdownImageLoader","path","Promise","url","dispose","ImageContext","URL_OR_ANCHOR","DIRECT_IMAGE","PLACEHOLDER_RATIO","decoded","href","decodeURIComponent","InlineCode","originalText","onFileLink","renderReference","drawn","open","includes","t","target","styles","code","fileLink","InlineLink","children","startsWith","slice","length","link","isFile","test","openURL","catch","MarkdownImage","src","alt","loader","imageName","source","split","loaded","setLoaded","failed","ratio","setRatio","active","asset","Awaited","ReturnType","resolve","then","Error","result","current","uri","waiting","prose","imageState","name","nativeEvent","fit","width","height","size","Image","getSize","image","aspectRatio","renderInline","nodes","map","node","index","type","strong","em","MarkdownTable","header","rows","initialPage","rowPage","setRows","columnPage","setColumns","cellPage","setCells","visibleRows","Math","max","visibleHeader","columns","limit","cell","clipped","row","some","root","table","column","headCell","meta","shownRows","totalRows","shownColumns","totalColumns","actions","page","Blocks","blocks","quoted","revealedPage","setPage","visible","parts","block","boundBlock","hiddenParts","shown","total","Infinity","characters","remaining","items","item","next","push","reduce","sum","Block","first","heading","level","firstHeading","run","flush","list","marker","ordered","start","itemText","language","rule","quote","MarkdownProps","loadImage","Markdown","generation","HEADING_STEP","const","HEADING_SPACE","HEADING_INK","create","theme","color","colors","dim","fontFamily","sans","fontSize","sm","lineHeight","uni__dependencies","flexDirection","flexWrap","minWidth","gap","spacing","base","marginTop","letterSpacing","fontWeight","semibold","hi","fontStyle","backgroundColor","deep","green","mono","textDecorationLine","blue","paddingLeft","flexShrink","borderLeftWidth","borderLeftColor","border","borderTopWidth","borderColor","paddingHorizontal","paddingVertical","borderRightWidth","borderBottomWidth","maxHeight","borderRadius","md","borderWidth"],"sources":["../../src/components/Markdown.tsx"],"sourcesContent":["import { useT } from '@agimon-ai/po-core/native';\nimport { createContext, memo, type ReactNode, useContext, useEffect, useMemo, useState } from 'react';\nimport { Image, Linking, ScrollView, Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\nimport {\n exactReference,\n type MarkdownBlock,\n type MarkdownHeadingLevel,\n type MarkdownInline,\n parseMarkdown,\n REFERENCE_HREF_PREFIX,\n} from '../lib/markdown';\nimport { READING, inlineLength, inlinePrefix } from '../lib/reading';\nimport { useReadingPage } from '../lib/useReadingPage';\nimport { CodeBlock } from './CodeBlock';\nimport { ShowMore } from './ShowMore';\n\n/*\n * Markdown in the web component's element styles, from the package's own\n * parser: headings, paragraphs, lists, code spans and fences, bold, italic,\n * links, images, blockquotes and tables. Web links open with Linking; a file\n * path goes to the host. Raw HTML blocks are left out, as on the web.\n */\n\n/**\n * What a piece of inline code, a relative link or an `@scheme:value` reference\n * (handed over as `scheme:value`) opens, when the host knows.\n * Returning undefined leaves it as plain code or an ordinary link. The same\n * contract as the web Markdown's handler.\n */\nexport type FileLinkHandler = (text: string, explicit?: boolean) => (() => void) | undefined;\n\n/** Passed by context so the inline renderers stay module functions. */\nconst InitialPageContext = createContext(1);\n\nconst FileLinkContext = createContext<FileLinkHandler | undefined>(undefined);\n\n/**\n * How an `@scheme:value` reference (handed over as `scheme:value`) is drawn, such as a chip that\n * opens it. Undefined leaves it to `onFileLink`: a plain link when claimed, else text. The same\n * contract as the web Markdown's renderer. What it returns sits inside Text, so it must be Text.\n * `onLongPress` is the surrounding text's, such as a message's actions, for the chip to pass on.\n */\nexport type ReferenceRenderer = (reference: string, options?: { onLongPress?: () => void }) => ReactNode | undefined;\nconst ReferenceContext = createContext<ReferenceRenderer | undefined>(undefined);\n\n/** Loads a relative image path from the host; the same contract as the web Markdown's `loadImage`. */\nexport type MarkdownImageLoader = (path: string) => Promise<{ url: string; dispose(): void }>;\n\nconst ImageContext = createContext<MarkdownImageLoader | undefined>(undefined);\n\nconst URL_OR_ANCHOR = /^(?:[a-z][a-z\\d+.-]*:|\\/\\/|#|\\?)/i;\n/** Sources an Image may load as written; any other scheme stays its alt text. */\nconst DIRECT_IMAGE = /^(?:https?:|data:image\\/)/i;\n/** Until the image reports its size, it holds a landscape box rather than collapsing. */\nconst PLACEHOLDER_RATIO = 16 / 9;\n\nfunction decoded(href: string): string | undefined {\n try {\n return decodeURIComponent(href);\n } catch {\n return undefined;\n }\n}\n\nfunction InlineCode({ text, originalText = text }: { text: string; originalText?: string }) {\n const onFileLink = useContext(FileLinkContext);\n const renderReference = useContext(ReferenceContext);\n // A span that is exactly one reference draws as prose does; one the renderer declines stays code.\n const reference = renderReference === undefined ? undefined : exactReference(originalText);\n const drawn = reference === undefined ? undefined : renderReference?.(reference);\n const open = reference !== undefined || originalText.includes('\\n') ? undefined : onFileLink?.(originalText);\n const t = useT();\n if (drawn !== undefined) return drawn;\n if (open !== undefined) {\n return (\n <Text\n accessibilityRole=\"link\"\n accessibilityHint={t('nativeComponents.markdown.openHint', 'open {target}', { target: originalText })}\n onPress={open}\n style={[styles.code, styles.fileLink]}\n >\n {text}\n </Text>\n );\n }\n return <Text style={styles.code}>{text}</Text>;\n}\n\nfunction InlineLink({ href, children }: { href: string; children: ReactNode }) {\n const onFileLink = useContext(FileLinkContext);\n const renderReference = useContext(ReferenceContext);\n const t = useT();\n // A reference the host does not open stays text; it is never handed to the system as a URL.\n if (href.startsWith(REFERENCE_HREF_PREFIX)) {\n const reference = decoded(href.slice(REFERENCE_HREF_PREFIX.length));\n const drawn = reference === undefined ? undefined : renderReference?.(reference);\n if (drawn !== undefined) return drawn;\n const open = reference === undefined ? undefined : onFileLink?.(reference);\n if (open === undefined) return <Text>{children}</Text>;\n return (\n <Text\n accessibilityRole=\"link\"\n accessibilityHint={t('nativeComponents.markdown.openHint', 'open {target}', { target: reference ?? '' })}\n onPress={open}\n style={styles.link}\n >\n {children}\n </Text>\n );\n }\n const path = decoded(href);\n const isFile = path !== undefined && path !== '' && !URL_OR_ANCHOR.test(path);\n const open = isFile ? onFileLink?.(path, true) : undefined;\n return (\n <Text\n accessibilityRole=\"link\"\n onPress={() => {\n if (open !== undefined) open();\n else if (!isFile) void Linking.openURL(href).catch(() => false); // Unsupported URL schemes stay a no-op.\n }}\n style={styles.link}\n >\n {children}\n </Text>\n );\n}\n\n/** One image: a file path through the host's loader, or a web or data address as written. */\nfunction MarkdownImage({ src, alt }: { src: string; alt: string }) {\n const loader = useContext(ImageContext);\n const t = useT();\n const imageName = alt || t('nativeComponents.markdown.image', 'Image');\n // An invalid encoded filename is shown as unavailable, never fetched.\n const source = src.startsWith('@artifact:') || src.startsWith('@temporary:') ? src.slice(1) : src;\n const path =\n URL_OR_ANCHOR.test(source) && !source.startsWith('artifact:') && !source.startsWith('temporary:')\n ? undefined\n : (decoded(source.split(/[?#]/u, 1)[0]!) ?? '');\n const [loaded, setLoaded] = useState<{ path: string; url?: string; failed?: boolean }>();\n const [ratio, setRatio] = useState(PLACEHOLDER_RATIO);\n useEffect(() => {\n if (loader === undefined || path === undefined) return;\n let active = true;\n let asset: Awaited<ReturnType<MarkdownImageLoader>> | undefined;\n void Promise.resolve()\n .then(() => {\n if (path === '') throw new Error('Invalid image path.');\n return loader(path);\n })\n .then((result) => {\n if (!active) return result.dispose();\n asset = result;\n setLoaded({ path, url: result.url });\n })\n .catch(() => {\n // The failure is shown in place, as the web image does.\n if (active) setLoaded({ path, failed: true });\n });\n return () => {\n active = false;\n asset?.dispose();\n };\n }, [path, loader]);\n const current = loaded?.path === path ? loaded : undefined;\n const uri = path === undefined ? (DIRECT_IMAGE.test(src) ? src : undefined) : current?.url;\n if (uri === undefined || current?.failed) {\n const waiting = path !== undefined && loader !== undefined && current === undefined;\n return (\n <Text style={[styles.prose, styles.imageState]} accessibilityRole={waiting ? 'text' : 'alert'}>\n {waiting\n ? t('nativeComponents.markdown.imageLoading', '{name} (loading\\u2026)', { name: alt || path || imageName })\n : t('nativeComponents.markdown.imageUnavailable', '{name} (unavailable)', { name: alt || path || imageName })}\n </Text>\n );\n }\n return (\n <Image\n source={{ uri }}\n accessibilityLabel={imageName}\n accessibilityIgnoresInvertColors\n resizeMode=\"contain\"\n onLoad={({ nativeEvent }) => {\n const fit = (width: number, height: number) => {\n if (width > 0 && height > 0) setRatio(width / height);\n };\n // iOS and Android report the size with the event; react-native-web does not, so it asks.\n const size = (nativeEvent as { source?: { width: number; height: number } } | undefined)?.source;\n if (size !== undefined) fit(size.width, size.height);\n else Image.getSize(uri, fit, () => undefined);\n }}\n onError={() => setLoaded({ path: path ?? src, failed: true })}\n style={[styles.image, { aspectRatio: ratio }]}\n />\n );\n}\nfunction renderInline(nodes: readonly MarkdownInline[]): ReactNode[] {\n return nodes.map((node, index) => {\n switch (node.type) {\n case 'text':\n return node.text;\n case 'code':\n return <InlineCode key={index} text={node.text} originalText={node.originalText} />;\n case 'strong':\n return (\n <Text key={index} style={styles.strong}>\n {renderInline(node.children)}\n </Text>\n );\n case 'em':\n return (\n <Text key={index} style={styles.em}>\n {renderInline(node.children)}\n </Text>\n );\n case 'link':\n return (\n <InlineLink key={index} href={node.href}>\n {renderInline(node.children)}\n </InlineLink>\n );\n case 'image':\n // Inside a heading or list item an image keeps to its alt text; paragraphs draw it.\n return node.alt;\n }\n });\n}\n\n/**\n * A table read column by column: every cell keeps to one line inside the sideways scroll, so each\n * column takes its widest cell and the rows line up without a table layout.\n */\nfunction MarkdownTable({ header, rows }: { header: MarkdownInline[][]; rows: MarkdownInline[][][] }) {\n const initialPage = useContext(InitialPageContext);\n const t = useT();\n const [rowPage, setRows] = useState(initialPage);\n const [columnPage, setColumns] = useState(initialPage);\n const [cellPage, setCells] = useState(initialPage);\n const visibleRows = rows.slice(0, READING.rows * Math.max(initialPage, rowPage));\n const visibleHeader = header.slice(0, READING.columns * Math.max(initialPage, columnPage));\n const limit = READING.cell * Math.max(initialPage, cellPage);\n const clipped = [visibleHeader, ...visibleRows.map((row) => row.slice(0, visibleHeader.length))].some((row) =>\n row.some((cell) => inlineLength(cell) > limit),\n );\n return (\n <View style={styles.root}>\n <ScrollView horizontal showsHorizontalScrollIndicator={false}>\n <View style={styles.table}>\n {visibleHeader.map((cell, column) => (\n <View key={column}>\n <Text style={[styles.prose, styles.cell, styles.headCell]}>\n {renderInline(inlinePrefix(cell, limit))}\n {inlineLength(cell) > limit ? '…' : ''}\n </Text>\n {visibleRows.map((row, index) => (\n <Text key={index} style={[styles.prose, styles.cell]}>\n {renderInline(inlinePrefix(row[column] ?? [], limit))}\n {inlineLength(row[column] ?? []) > limit ? '…' : ''}\n </Text>\n ))}\n </View>\n ))}\n </View>\n </ScrollView>\n <Text style={styles.meta}>\n {t(\n 'nativeComponents.markdown.tableSummary',\n '{shownRows} of {totalRows} rows · {shownColumns} of {totalColumns} columns',\n {\n shownRows: visibleRows.length,\n totalRows: rows.length,\n shownColumns: visibleHeader.length,\n totalColumns: header.length,\n },\n )}\n {clipped ? ` · ${t('nativeComponents.markdown.cellLimit', 'Cells: first {limit} characters', { limit })}` : ''}\n </Text>\n <View style={styles.actions}>\n {visibleRows.length < rows.length ? (\n <ShowMore\n label={t('nativeComponents.markdown.showMoreRows', 'Show more rows')}\n onPress={() => setRows((page) => page + 1)}\n />\n ) : null}\n {visibleHeader.length < header.length ? (\n <ShowMore\n label={t('nativeComponents.markdown.showMoreColumns', 'Show more columns')}\n onPress={() => setColumns((page) => page + 1)}\n />\n ) : null}\n {clipped ? (\n <ShowMore\n label={t('nativeComponents.markdown.showMoreCells', 'Show more cell text')}\n onPress={() => setCells((page) => page + 1)}\n />\n ) : null}\n </View>\n </View>\n );\n}\n\n/** One Show more for the whole document: a single tap reveals every hidden part and clipped text. */\nfunction Blocks({ blocks, quoted = false }: { blocks: MarkdownBlock[]; quoted?: boolean }) {\n const initialPage = useContext(InitialPageContext);\n const t = useT();\n const [revealedPage, setPage] = useState(initialPage);\n const page = Math.max(initialPage, revealedPage);\n const visible = blocks.slice(0, READING.parts * page).map((block) => boundBlock(block, page));\n const hiddenParts = visible.length < blocks.length;\n return (\n <InitialPageContext.Provider value={page}>\n {visible.map(({ block }, index) => (\n <View key={index} style={styles.root}>\n <Block block={block} first={index === 0} quoted={quoted} />\n </View>\n ))}\n {hiddenParts || visible.some(({ clipped }) => clipped) ? (\n <ShowMore\n label={t('nativeComponents.markdown.showMore', 'Show more')}\n summary={\n hiddenParts\n ? t('nativeComponents.markdown.partsSummary', '{shown} of {total} parts', {\n shown: visible.length,\n total: blocks.length,\n })\n : undefined\n }\n onPress={() => setPage(Infinity)}\n />\n ) : null}\n </InitialPageContext.Provider>\n );\n}\n\n/** A heading, paragraph or list cut to the page's character budget, and whether anything was cut. */\nfunction boundBlock(block: MarkdownBlock, page: number): { block: MarkdownBlock; clipped: boolean } {\n const limit = READING.characters * page;\n if (block.type === 'heading' || block.type === 'paragraph') {\n const children = inlinePrefix(block.children, limit);\n return { block: { ...block, children }, clipped: inlineLength(children) < inlineLength(block.children) };\n }\n if (block.type !== 'list') return { block, clipped: false };\n let remaining = limit;\n let shown = 0;\n const items = [];\n for (const item of block.items.slice(0, READING.parts * page)) {\n if (remaining <= 0) break;\n const next = inlinePrefix(item, remaining);\n items.push(next);\n const length = inlineLength(next);\n shown += length;\n remaining -= length;\n }\n const total = block.items.reduce((sum, item) => sum + inlineLength(item), 0);\n return { block: { ...block, items }, clipped: shown < total || items.length < block.items.length };\n}\n\nfunction Block({ block, first, quoted = false }: { block: MarkdownBlock; first: boolean; quoted?: boolean }) {\n const initialPage = useContext(InitialPageContext);\n const prose = [styles.prose, quoted && styles.quoted];\n switch (block.type) {\n case 'heading':\n return (\n <Text\n accessibilityRole=\"header\"\n style={[...prose, styles.heading(block.level), first && styles.firstHeading, quoted && styles.quoted]}\n >\n {renderInline(block.children)}\n </Text>\n );\n case 'paragraph': {\n // An image breaks the paragraph's text into runs, since an Image cannot sit inside Text.\n const parts: ReactNode[] = [];\n let run: MarkdownInline[] = [];\n const flush = () => {\n if (run.length > 0)\n parts.push(\n <Text key={parts.length} style={prose}>\n {renderInline(run)}\n </Text>,\n );\n run = [];\n };\n for (const node of block.children) {\n if (node.type !== 'image') {\n run.push(node);\n continue;\n }\n flush();\n parts.push(<MarkdownImage key={parts.length} src={node.src} alt={node.alt} />);\n }\n flush();\n return parts.length === 1 ? parts[0] : <View style={styles.root}>{parts}</View>;\n }\n case 'list':\n return (\n <View accessibilityRole=\"list\" style={styles.list}>\n {block.items.map((item, index) => (\n <View key={index} style={styles.item}>\n <Text style={[...prose, styles.marker]}>{block.ordered ? `${block.start + index}.` : '\\u2022'}</Text>\n <Text style={[...prose, styles.itemText]}>{renderInline(item)}</Text>\n </View>\n ))}\n </View>\n );\n case 'code':\n return <CodeBlock text={block.text} language={block.language} initialPage={initialPage} />;\n case 'rule':\n return <View accessible={false} style={styles.rule} />;\n case 'quote':\n return (\n <View style={[styles.root, styles.quote]}>\n <Blocks blocks={block.children} quoted />\n </View>\n );\n case 'table':\n return <MarkdownTable header={block.header} rows={block.rows} />;\n }\n}\n\nexport interface MarkdownProps {\n text: string;\n onFileLink?: FileLinkHandler;\n /** Draws `@scheme:value` references and code spans that are exactly one; without it they link plainly. */\n renderReference?: ReferenceRenderer;\n /** Loads relative image paths; without it they show as unavailable. */\n loadImage?: MarkdownImageLoader;\n /** Initial reveal pages for a restored reading position. Defaults to one. */\n initialPage?: number;\n}\n\n/** Markdown in Po's shared presentation, parsed by the package's own small parser. */\nexport const Markdown = memo(function Markdown({\n text,\n onFileLink,\n renderReference,\n loadImage,\n initialPage = 1,\n}: MarkdownProps) {\n const blocks = useMemo(() => parseMarkdown(text), [text]);\n const { generation } = useReadingPage(text);\n return (\n <InitialPageContext.Provider value={initialPage}>\n <FileLinkContext.Provider value={onFileLink}>\n <ReferenceContext.Provider value={renderReference}>\n <ImageContext.Provider value={loadImage}>\n <View style={styles.root}>\n <Blocks key={generation} blocks={blocks} />\n </View>\n </ImageContext.Provider>\n </ReferenceContext.Provider>\n </FileLinkContext.Provider>\n </InitialPageContext.Provider>\n );\n});\n\n/**\n * Headings step up from the prose and never shrink below it; h4 to h6 keep\n * the prose size and lean on weight, fading from `hi` to `dim`.\n */\nconst HEADING_STEP = { 1: '2xl', 2: 'xl', 3: 'lg', 4: 'base', 5: 'base', 6: 'base' } as const;\nconst HEADING_SPACE = { 1: 2, 2: 2, 3: 1, 4: 0, 5: 0, 6: 0 } as const;\nconst HEADING_INK = { 1: 'hi', 2: 'hi', 3: 'hi', 4: 'hi', 5: 'text', 6: 'dim' } as const;\n\nconst styles = StyleSheet.create((theme) => ({\n meta: {\n color: theme.colors.dim,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n actions: { flexDirection: 'row', flexWrap: 'wrap' },\n root: { minWidth: 0, gap: theme.spacing(2) },\n prose: {\n color: theme.colors.text,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n heading: (level: MarkdownHeadingLevel) => ({\n marginTop: theme.spacing(HEADING_SPACE[level]),\n fontSize: theme.fontSize[HEADING_STEP[level]],\n lineHeight: theme.lineHeight[HEADING_STEP[level]],\n letterSpacing: theme.letterSpacing[HEADING_STEP[level]],\n fontWeight: theme.fontWeight.semibold,\n color: theme.colors[HEADING_INK[level]],\n }),\n firstHeading: { marginTop: 0 },\n strong: { fontWeight: theme.fontWeight.semibold, color: theme.colors.hi },\n em: { fontStyle: 'italic' },\n code: {\n backgroundColor: theme.colors.deep,\n color: theme.colors.green,\n fontFamily: fontOf(theme.fontFamily.mono),\n },\n fileLink: { textDecorationLine: 'underline' },\n link: { color: theme.colors.blue, textDecorationLine: 'underline' },\n list: { gap: theme.spacing(0.5) },\n item: { flexDirection: 'row', gap: theme.spacing(2), paddingLeft: theme.spacing(1) },\n marker: { minWidth: theme.spacing(3), color: theme.colors.dim },\n itemText: { flexShrink: 1 },\n rule: { height: 1, backgroundColor: theme.colors['border-soft'] },\n // The web blockquote: a rule at the left and quieter text.\n quote: { borderLeftWidth: 2, borderLeftColor: theme.colors.border, paddingLeft: theme.spacing(3) },\n quoted: { color: theme.colors.dim },\n // The web table: bordered cells, the header on the deep surface.\n table: {\n flexDirection: 'row',\n borderTopWidth: 1,\n borderLeftWidth: 1,\n borderColor: theme.colors.border,\n },\n cell: {\n paddingHorizontal: theme.spacing(2),\n paddingVertical: theme.spacing(1),\n borderRightWidth: 1,\n borderBottomWidth: 1,\n borderColor: theme.colors.border,\n },\n headCell: { backgroundColor: theme.colors.deep, fontWeight: theme.fontWeight.semibold, color: theme.colors.hi },\n // The web image's frame: at most 480 tall, a soft border and rounded corners.\n image: {\n width: '100%',\n maxHeight: 480,\n borderRadius: theme.borderRadius.md,\n borderWidth: 1,\n borderColor: theme.colors.border,\n },\n imageState: { color: theme.colors.dim },\n}));\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmCA,MAAM0B,qBAAqBzB,cAAc,CAAC;AAE1C,MAAM0B,kBAAkB1B,cAA2C2B,MAAS;AAS5E,MAAMK,mBAAmBhC,cAA6C2B,MAAS;AAK/E,MAAMW,eAAetC,cAA+C2B,MAAS;AAE7E,MAAMY,gBAAgB;;AAEtB,MAAMC,eAAe;;AAErB,MAAMC,oBAAoB,KAAK;AAE/B,SAASC,QAAQC,MAAkC;CACjD,IAAI;EACF,OAAOC,mBAAmBD,IAAI;CAChC,QAAQ;EACN;CACF;AACF;AAEA,SAASE,WAAW,EAAEtB,MAAMuB,eAAevB,QAAiD;CAC1F,MAAMwB,aAAa5C,WAAWuB,eAAe;CAC7C,MAAMsB,kBAAkB7C,WAAW6B,gBAAgB;CAEnD,MAAMH,YAAYmB,oBAAoBrB,SAAYA,SAAYjB,eAAeoC,YAAY;CACzF,MAAMG,QAAQpB,cAAcF,SAAYA,SAA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;CAAC;CACnFzB,QAAQ;EAAE4B,UAAUZ,MAAMc,QAAQ,CAAC;EAAGb,OAAOD,MAAME,OAAOC;EAAGM,mBAAA,CAAA,CAAA;CAAC;CAC9DtB,UAAU,EAAE0C,YAAY,EAAE;CAC1BxC,MAAM;EAAE/E,QAAQ;EAAGgH,iBAAiBtB,MAAME,OAAO;EAAcO,mBAAA,CAAA,CAAA;CAAC;CAEhEnB,OAAO;EAAEwC,iBAAiB;EAAGC,iBAAiB/B,MAAME,OAAO8B;EAAQJ,aAAa5B,MAAMc,QAAQ,CAAC;EAACL,mBAAA,CAAA,CAAA;CAAC;CACjGpD,QAAQ;EAAE4C,OAAOD,MAAME,OAAOC;EAAGM,mBAAA,CAAA,CAAA;CAAC;CAElChE,OAAO;EACLiE,eAAe;EACfuB,gBAAgB;EAChBH,iBAAiB;EACjBI,aAAalC,MAAME,OAAO8B;EAAMvB,mBAAA,CAAA,CAAA;CAClC;CACArE,MAAM;EACJ+F,mBAAmBnC,MAAMc,QAAQ,CAAC;EAClCsB,iBAAiBpC,MAAMc,QAAQ,CAAC;EAChCuB,kBAAkB;EAClBC,mBAAmB;EACnBJ,aAAalC,MAAME,OAAO8B;EAAMvB,mBAAA,CAAA,CAAA;CAClC;CACA9D,UAAU;EAAE2E,iBAAiBtB,MAAME,OAAOqB;EAAML,YAAYlB,MAAMkB,WAAWC;EAAUlB,OAAOD,MAAME,OAAOkB;EAAEX,mBAAA,CAAA,CAAA;CAAC;CAE9G/F,OAAO;EACLL,OAAO;EACPkI,WAAW;EACXC,cAAcxC,MAAMwC,aAAaC;EACjCC,aAAa;EACbR,aAAalC,MAAME,OAAO8B;EAAMvB,mBAAA,CAAA,CAAA;CAClC;CACAxG,YAAY;EAAEgG,OAAOD,MAAME,OAAOC;EAAGM,mBAAA,CAAA,CAAA;CAAC;AACxC,EAAE"}
package/dist/index.d.mts CHANGED
@@ -16,10 +16,10 @@ import { LoadingState, LoadingStateProps, LoadingStateSize } from "./components/
16
16
  import { HashlineLines, HashlineLinesProps } from "./components/HashlineLines.mjs";
17
17
  import { FieldSize, FieldVariant, Input, InputProps } from "./components/Input.mjs";
18
18
  import { FileBrowserControls, FileList, FileListProps } from "./components/FileList.mjs";
19
+ import { FileLinkHandler, Markdown, MarkdownImageLoader, MarkdownProps, ReferenceRenderer } from "./components/Markdown.mjs";
19
20
  import { FilePreview, FilePreviewProps } from "./components/FilePreview.mjs";
20
21
  import { BoundedFileSaveOptions, BoundedFileSaveState, FilePathStrip, FileViewer, FileViewerHeader, FileViewerProps, useBoundedFileSave } from "./components/FileViewer.mjs";
21
22
  import { Label, LabelProps } from "./components/Label.mjs";
22
- import { FileLinkHandler, Markdown, MarkdownImageLoader, MarkdownProps, ReferenceRenderer } from "./components/Markdown.mjs";
23
23
  import { LinkText, LinkTextProps } from "./components/LinkText.mjs";
24
24
  import { List, ListProps, ListRow, ListRowProps } from "./components/List.mjs";
25
25
  import { ActivityIcon, AlertIcon, ArrowRightIcon, ArrowUpRightIcon, AudioLinesIcon, Back10Icon, BoxIcon, BranchIcon, CalendarIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, CloseIcon, CopyIcon, DownloadIcon, EditIcon, EraserIcon, FileIcon, FitIcon, FolderIcon, ForkIcon, Forward10Icon, GearIcon, GlobeIcon, HandIcon, HighlighterIcon, HomeIcon, IconProps, IdCardIcon, ImageIcon, KebabIcon, LanguagesIcon, LightbulbIcon, LockIcon, MenuIcon, MessageIcon, MicIcon, MinusIcon, MonitorIcon, NoteIcon, PaletteIcon, PauseIcon, PinIcon, PlayCircleIcon, PlayIcon, PlusIcon, PointerIcon, RedoIcon, RefreshIcon, SearchIcon, SendIcon, ServerIcon, ShieldIcon, SlidersIcon, SmartphoneIcon, SparklesIcon, StepBackIcon, StepForwardIcon, StopIcon, TaskIcon, TerminalIcon, TrashIcon, UndoIcon, UserIcon, UsersIcon, WorkflowIcon, WrenchIcon } from "./icons/icons.mjs";
@@ -1 +1 @@
1
- {"version":1,"platformRequirements":{},"sourceFiles":["LICENSE","README.md","llms.txt","locales/vi.json","locales/zh-CN.json","package.json","src/components/AgentAvatar.stories.tsx","src/components/AgentAvatar.tsx","src/components/AnnotationSurface.tsx","src/components/Badge.stories.tsx","src/components/Badge.tsx","src/components/Button.stories.tsx","src/components/Button.tsx","src/components/CodeBlock.stories.tsx","src/components/CodeBlock.tsx","src/components/ComputerRow.stories.tsx","src/components/ComputerRow.tsx","src/components/CopyButton.tsx","src/components/CountBadge.stories.tsx","src/components/CountBadge.tsx","src/components/CtaCard.stories.tsx","src/components/CtaCard.tsx","src/components/Dialog.stories.tsx","src/components/Dialog.tsx","src/components/Dot.stories.tsx","src/components/Dot.tsx","src/components/DropdownMenu.stories.tsx","src/components/DropdownMenu.tsx","src/components/EmptyState.stories.tsx","src/components/EmptyState.tsx","src/components/FileList.stories.tsx","src/components/FileList.tsx","src/components/FilePreview.stories.tsx","src/components/FilePreview.tsx","src/components/FileViewer.stories.tsx","src/components/FileViewer.tsx","src/components/HashlineLines.tsx","src/components/HostFilter.stories.tsx","src/components/HostFilter.tsx","src/components/HostTag.stories.tsx","src/components/HostTag.tsx","src/components/InfoStrip.stories.tsx","src/components/InfoStrip.tsx","src/components/InlineReadingDesign.stories.tsx","src/components/Input.stories.tsx","src/components/Input.tsx","src/components/Label.stories.tsx","src/components/Label.tsx","src/components/LinkText.tsx","src/components/List.stories.tsx","src/components/List.tsx","src/components/LiveDuration.tsx","src/components/LoadingState.stories.tsx","src/components/LoadingState.tsx","src/components/Markdown.stories.tsx","src/components/Markdown.tsx","src/components/MessageItem.stories.tsx","src/components/MessageItem.tsx","src/components/NativeShellState.tsx","src/components/Panel.stories.tsx","src/components/Panel.tsx","src/components/PoNativeProvider.stories.tsx","src/components/PoNativeProvider.tsx","src/components/RailItem.stories.tsx","src/components/RailItem.tsx","src/components/ReferenceChip.stories.tsx","src/components/ReferenceChip.tsx","src/components/SectionLabel.stories.tsx","src/components/SectionLabel.tsx","src/components/SeekBar.stories.tsx","src/components/SeekBar.tsx","src/components/SegmentedControl.stories.tsx","src/components/SegmentedControl.tsx","src/components/Select.stories.tsx","src/components/Select.tsx","src/components/Sheet.stories.tsx","src/components/Sheet.tsx","src/components/SheetFrame.tsx","src/components/SheetList.tsx","src/components/ShowMore.tsx","src/components/Spinner.stories.tsx","src/components/Spinner.tsx","src/components/StatusBadge.stories.tsx","src/components/StatusBadge.tsx","src/components/Switch.stories.tsx","src/components/Switch.tsx","src/components/SyntaxLine.tsx","src/components/Tabs.stories.tsx","src/components/Tabs.tsx","src/components/Textarea.stories.tsx","src/components/Textarea.tsx","src/components/ToolPathLink.tsx","src/components/ToolResultImage.tsx","src/exports/index.ts","src/exports/shell.ts","src/icons/IconColorContext.ts","src/icons/iconGlyphs.ts","src/icons/icons.stories.tsx","src/icons/icons.tsx","src/lib/fileKindLabel.ts","src/lib/fonts.ts","src/lib/haptics.ts","src/lib/insideSheet.ts","src/lib/markdown.ts","src/lib/reading.ts","src/lib/tone.ts","src/lib/useControllable.ts","src/lib/useReadingPage.ts","src/lib/wrapText.tsx","src/unistyles.ts","tsdown.config.ts"],"sourceRevision":"63098c2b896bfa10bb6f775787fa45f0","manifestRevision":"76406acf80db97da11c81814e035e7af","outputFiles":["LICENSE","README.md","dist/components/AgentAvatar.mjs","dist/components/AnnotationSurface.mjs","dist/components/Badge.mjs","dist/components/Button.mjs","dist/components/CodeBlock.mjs","dist/components/ComputerRow.mjs","dist/components/CopyButton.mjs","dist/components/CountBadge.mjs","dist/components/CtaCard.mjs","dist/components/Dialog.mjs","dist/components/Dot.mjs","dist/components/DropdownMenu.mjs","dist/components/EmptyState.mjs","dist/components/FileList.mjs","dist/components/FilePreview.mjs","dist/components/FileViewer.mjs","dist/components/HashlineLines.mjs","dist/components/HostFilter.mjs","dist/components/HostTag.mjs","dist/components/InfoStrip.mjs","dist/components/Input.mjs","dist/components/Label.mjs","dist/components/LinkText.mjs","dist/components/List.mjs","dist/components/LiveDuration.mjs","dist/components/LoadingState.mjs","dist/components/Markdown.mjs","dist/components/MessageItem.mjs","dist/components/NativeShellState.mjs","dist/components/Panel.mjs","dist/components/PoNativeProvider.mjs","dist/components/RailItem.mjs","dist/components/ReferenceChip.mjs","dist/components/SectionLabel.mjs","dist/components/SeekBar.mjs","dist/components/SegmentedControl.mjs","dist/components/Select.mjs","dist/components/Sheet.mjs","dist/components/SheetFrame.mjs","dist/components/SheetList.mjs","dist/components/ShowMore.mjs","dist/components/Spinner.mjs","dist/components/StatusBadge.mjs","dist/components/Switch.mjs","dist/components/SyntaxLine.mjs","dist/components/Tabs.mjs","dist/components/Textarea.mjs","dist/components/ToolPathLink.mjs","dist/components/ToolResultImage.mjs","dist/icons/IconColorContext.mjs","dist/icons/iconGlyphs.mjs","dist/icons/icons.mjs","dist/index.mjs","dist/lib/fileKindLabel.mjs","dist/lib/fonts.mjs","dist/lib/haptics.mjs","dist/lib/insideSheet.mjs","dist/lib/markdown.mjs","dist/lib/reading.mjs","dist/lib/tone.mjs","dist/lib/useControllable.mjs","dist/lib/useReadingPage.mjs","dist/lib/wrapText.mjs","dist/shell.mjs","llms.txt","locales/vi.json","locales/zh-CN.json"],"outputRevision":"b512420e0b23bd130e9edcb104b7b27f"}
1
+ {"version":1,"platformRequirements":{},"sourceFiles":["LICENSE","README.md","llms.txt","locales/vi.json","locales/zh-CN.json","package.json","src/components/AgentAvatar.stories.tsx","src/components/AgentAvatar.tsx","src/components/AnnotationSurface.tsx","src/components/Badge.stories.tsx","src/components/Badge.tsx","src/components/Button.stories.tsx","src/components/Button.tsx","src/components/CodeBlock.stories.tsx","src/components/CodeBlock.tsx","src/components/ComputerRow.stories.tsx","src/components/ComputerRow.tsx","src/components/CopyButton.tsx","src/components/CountBadge.stories.tsx","src/components/CountBadge.tsx","src/components/CtaCard.stories.tsx","src/components/CtaCard.tsx","src/components/Dialog.stories.tsx","src/components/Dialog.tsx","src/components/Dot.stories.tsx","src/components/Dot.tsx","src/components/DropdownMenu.stories.tsx","src/components/DropdownMenu.tsx","src/components/EmptyState.stories.tsx","src/components/EmptyState.tsx","src/components/FileList.stories.tsx","src/components/FileList.tsx","src/components/FilePreview.stories.tsx","src/components/FilePreview.tsx","src/components/FileViewer.stories.tsx","src/components/FileViewer.tsx","src/components/HashlineLines.tsx","src/components/HostFilter.stories.tsx","src/components/HostFilter.tsx","src/components/HostTag.stories.tsx","src/components/HostTag.tsx","src/components/InfoStrip.stories.tsx","src/components/InfoStrip.tsx","src/components/InlineReadingDesign.stories.tsx","src/components/Input.stories.tsx","src/components/Input.tsx","src/components/Label.stories.tsx","src/components/Label.tsx","src/components/LinkText.tsx","src/components/List.stories.tsx","src/components/List.tsx","src/components/LiveDuration.tsx","src/components/LoadingState.stories.tsx","src/components/LoadingState.tsx","src/components/Markdown.stories.tsx","src/components/Markdown.tsx","src/components/MessageItem.stories.tsx","src/components/MessageItem.tsx","src/components/NativeShellState.tsx","src/components/Panel.stories.tsx","src/components/Panel.tsx","src/components/PoNativeProvider.stories.tsx","src/components/PoNativeProvider.tsx","src/components/RailItem.stories.tsx","src/components/RailItem.tsx","src/components/ReferenceChip.stories.tsx","src/components/ReferenceChip.tsx","src/components/SectionLabel.stories.tsx","src/components/SectionLabel.tsx","src/components/SeekBar.stories.tsx","src/components/SeekBar.tsx","src/components/SegmentedControl.stories.tsx","src/components/SegmentedControl.tsx","src/components/Select.stories.tsx","src/components/Select.tsx","src/components/Sheet.stories.tsx","src/components/Sheet.tsx","src/components/SheetFrame.tsx","src/components/SheetList.tsx","src/components/ShowMore.tsx","src/components/Spinner.stories.tsx","src/components/Spinner.tsx","src/components/StatusBadge.stories.tsx","src/components/StatusBadge.tsx","src/components/Switch.stories.tsx","src/components/Switch.tsx","src/components/SyntaxLine.tsx","src/components/Tabs.stories.tsx","src/components/Tabs.tsx","src/components/Textarea.stories.tsx","src/components/Textarea.tsx","src/components/ToolPathLink.tsx","src/components/ToolResultImage.tsx","src/exports/index.ts","src/exports/shell.ts","src/icons/IconColorContext.ts","src/icons/iconGlyphs.ts","src/icons/icons.stories.tsx","src/icons/icons.tsx","src/lib/fileKindLabel.ts","src/lib/fonts.ts","src/lib/haptics.ts","src/lib/insideSheet.ts","src/lib/markdown.ts","src/lib/reading.ts","src/lib/tone.ts","src/lib/useControllable.ts","src/lib/useReadingPage.ts","src/lib/wrapText.tsx","src/unistyles.ts","tsdown.config.ts"],"sourceRevision":"85431164ff1a0ab03219859f85282244","manifestRevision":"4ad5f9e140894559e8a09e8fcb3e2904","outputFiles":["LICENSE","README.md","dist/components/AgentAvatar.mjs","dist/components/AnnotationSurface.mjs","dist/components/Badge.mjs","dist/components/Button.mjs","dist/components/CodeBlock.mjs","dist/components/ComputerRow.mjs","dist/components/CopyButton.mjs","dist/components/CountBadge.mjs","dist/components/CtaCard.mjs","dist/components/Dialog.mjs","dist/components/Dot.mjs","dist/components/DropdownMenu.mjs","dist/components/EmptyState.mjs","dist/components/FileList.mjs","dist/components/FilePreview.mjs","dist/components/FileViewer.mjs","dist/components/HashlineLines.mjs","dist/components/HostFilter.mjs","dist/components/HostTag.mjs","dist/components/InfoStrip.mjs","dist/components/Input.mjs","dist/components/Label.mjs","dist/components/LinkText.mjs","dist/components/List.mjs","dist/components/LiveDuration.mjs","dist/components/LoadingState.mjs","dist/components/Markdown.mjs","dist/components/MessageItem.mjs","dist/components/NativeShellState.mjs","dist/components/Panel.mjs","dist/components/PoNativeProvider.mjs","dist/components/RailItem.mjs","dist/components/ReferenceChip.mjs","dist/components/SectionLabel.mjs","dist/components/SeekBar.mjs","dist/components/SegmentedControl.mjs","dist/components/Select.mjs","dist/components/Sheet.mjs","dist/components/SheetFrame.mjs","dist/components/SheetList.mjs","dist/components/ShowMore.mjs","dist/components/Spinner.mjs","dist/components/StatusBadge.mjs","dist/components/Switch.mjs","dist/components/SyntaxLine.mjs","dist/components/Tabs.mjs","dist/components/Textarea.mjs","dist/components/ToolPathLink.mjs","dist/components/ToolResultImage.mjs","dist/icons/IconColorContext.mjs","dist/icons/iconGlyphs.mjs","dist/icons/icons.mjs","dist/index.mjs","dist/lib/fileKindLabel.mjs","dist/lib/fonts.mjs","dist/lib/haptics.mjs","dist/lib/insideSheet.mjs","dist/lib/markdown.mjs","dist/lib/reading.mjs","dist/lib/tone.mjs","dist/lib/useControllable.mjs","dist/lib/useReadingPage.mjs","dist/lib/wrapText.mjs","dist/shell.mjs","llms.txt","locales/vi.json","locales/zh-CN.json"],"outputRevision":"c14e3cfa2ec7224ec7ff00eca3ca2698"}
package/locales/vi.json CHANGED
@@ -64,6 +64,9 @@
64
64
  "nativeComponents.filePreview.loadingMedia": "Đang tải nội dung đa phương tiện…",
65
65
  "nativeComponents.filePreview.noHtml": "Máy chủ này không thể hiển thị bản xem trước HTML.",
66
66
  "nativeComponents.filePreview.noMedia": "Máy chủ này không thể hiển thị bản xem trước nội dung đa phương tiện này.",
67
+ "nativeComponents.filePreview.saveFile": "Lưu tệp",
68
+ "nativeComponents.filePreview.tooLargeDetail": "Tệp lớn hơn 5 MiB được lưu theo từng phần thay vì tải vào bộ nhớ.",
69
+ "nativeComponents.filePreview.tooLargeTitle": "Tệp quá lớn để xem trước tại đây",
67
70
  "nativeComponents.filePreview.unavailable": "Không thể xem trước tệp này.",
68
71
  "nativeComponents.fileViewer.cancel": "Hủy",
69
72
  "nativeComponents.fileViewer.cancelDownload": "Hủy tải xuống",
@@ -74,8 +77,8 @@
74
77
  "nativeComponents.fileViewer.pathLabel": "đường dẫn",
75
78
  "nativeComponents.fileViewer.reading": "Đang đọc tệp này…",
76
79
  "nativeComponents.fileViewer.retry": "Thử lại",
77
- "nativeComponents.fileViewer.saved": "Đã lưu.",
78
80
  "nativeComponents.fileViewer.saveFailed": "Không lưu được tệp này",
81
+ "nativeComponents.fileViewer.saved": "Đã lưu.",
79
82
  "nativeComponents.hashline.showMore": "Hiện thêm dòng",
80
83
  "nativeComponents.hashline.summary": "{shown}/{total} dòng",
81
84
  "nativeComponents.hostFilter.all": "Tất cả",
@@ -64,6 +64,9 @@
64
64
  "nativeComponents.filePreview.loadingMedia": "正在加载媒体…",
65
65
  "nativeComponents.filePreview.noHtml": "此主机无法显示 HTML 预览。",
66
66
  "nativeComponents.filePreview.noMedia": "此主机无法显示此媒体预览。",
67
+ "nativeComponents.filePreview.saveFile": "保存文件",
68
+ "nativeComponents.filePreview.tooLargeDetail": "超过 5 MiB 的文件会分块保存,而不会加载到内存中。",
69
+ "nativeComponents.filePreview.tooLargeTitle": "文件太大,无法直接预览",
67
70
  "nativeComponents.filePreview.unavailable": "无法预览此文件。",
68
71
  "nativeComponents.fileViewer.cancel": "取消",
69
72
  "nativeComponents.fileViewer.cancelDownload": "取消下载",
@@ -74,8 +77,8 @@
74
77
  "nativeComponents.fileViewer.pathLabel": "路径",
75
78
  "nativeComponents.fileViewer.reading": "正在读取此文件…",
76
79
  "nativeComponents.fileViewer.retry": "重试",
77
- "nativeComponents.fileViewer.saved": "已保存。",
78
80
  "nativeComponents.fileViewer.saveFailed": "无法保存此文件",
81
+ "nativeComponents.fileViewer.saved": "已保存。",
79
82
  "nativeComponents.hashline.showMore": "显示更多行",
80
83
  "nativeComponents.hashline.summary": "第 {shown} 行,共 {total} 行",
81
84
  "nativeComponents.hostFilter.all": "全部",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agimon-ai/po-native-components",
3
- "version": "0.0.0-alpha.223",
3
+ "version": "0.0.0-alpha.224",
4
4
  "description": "Shared React Native components for Po and its native plugins: the web component library's look and API on native parts, tuned to the Po palette.",
5
5
  "keywords": [
6
6
  "ai",
@@ -52,12 +52,12 @@
52
52
  "access": "public"
53
53
  },
54
54
  "dependencies": {
55
- "@agimon-ai/po-web-components": "0.0.0-alpha.223"
55
+ "@agimon-ai/po-web-components": "0.0.0-alpha.224"
56
56
  },
57
57
  "devDependencies": {
58
- "@agimon-ai/po-build": "0.0.0-alpha.223",
59
- "@agimon-ai/po-core": "0.0.0-alpha.223",
60
- "@agimon-ai/vibe-lint-plugin-po-web": "0.0.0-alpha.223",
58
+ "@agimon-ai/po-build": "0.0.0-alpha.224",
59
+ "@agimon-ai/po-core": "0.0.0-alpha.224",
60
+ "@agimon-ai/vibe-lint-plugin-po-web": "0.0.0-alpha.224",
61
61
  "@babel/core": "7.29.7",
62
62
  "@expo/vector-icons": "15.1.1",
63
63
  "@fontsource-variable/ibm-plex-sans": "5.3.0",
@@ -88,7 +88,7 @@
88
88
  "vitest": "5.0.4"
89
89
  },
90
90
  "peerDependencies": {
91
- "@agimon-ai/po-core": "0.0.0-alpha.223",
91
+ "@agimon-ai/po-core": "0.0.0-alpha.224",
92
92
  "@expo/vector-icons": "^15.0.0",
93
93
  "@gorhom/bottom-sheet": "^5.2.0",
94
94
  "@react-native-segmented-control/segmented-control": "^2.5.0",