mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-11 10:57:07 +00:00
fix(plugins): file events are objects, deletion is a typed error, DocumentFrame owns its fallback
- watch listeners receive { type: "changed" } | { type: "deleted" }, so later
versions can add fields without breaking them.
- PluginFileDeletedError joins PluginFileConflictError. The read hooks report a
deleted file with it, and a write over a deleted file rejects with it; Source
shows that as the deleted notice. PluginFileConflictError now means only
"changed on disk".
- DocumentFrame on Android shows Paseo's "<TYPE> files can't be shown on this
device" message for documents its WebView cannot display, so the PDF example
is useFileUrl + Loading + DocumentFrame with no platform branch.
This commit is contained in:
@@ -4,8 +4,8 @@ Requires Paseo 0.13.0 or later. Install this directory with
|
||||
`paseo plugin install /absolute/path/to/plugin-examples/pdf-panel`, then open a `.pdf` in Files.
|
||||
|
||||
The panel resolves the file's local URL with `useFileUrl`, shows `Loading` until it does, and passes
|
||||
it to `DocumentFrame` on web and iOS. Android shows the filename, size, and a message that inline
|
||||
PDF rendering is unavailable. The plugin does not construct daemon URLs.
|
||||
it to `DocumentFrame`. Where a platform cannot show a PDF inline (Android), `DocumentFrame` says so.
|
||||
The plugin does not construct daemon URLs.
|
||||
|
||||
See the [file panel reference](https://paseo.sh/docs/plugins/reference#file-panels).
|
||||
|
||||
|
||||
@@ -10,12 +10,7 @@ const messageStyle = {
|
||||
padding: 24,
|
||||
} as const;
|
||||
|
||||
export function PdfPanel(props: PluginFilePanelProps) {
|
||||
if (props.layout.platform === "android") return <AndroidPdf {...props} />;
|
||||
return <InlinePdf {...props} />;
|
||||
}
|
||||
|
||||
function InlinePdf({ file, theme }: PluginFilePanelProps) {
|
||||
export function PdfPanel({ file, theme }: PluginFilePanelProps) {
|
||||
const url = useFileUrl(file);
|
||||
const textStyle = useMemo(() => ({ color: theme.colors.statusDanger }), [theme]);
|
||||
if (url.status === "loading") return <Loading />;
|
||||
@@ -28,14 +23,3 @@ function InlinePdf({ file, theme }: PluginFilePanelProps) {
|
||||
}
|
||||
return <DocumentFrame url={url.url} testID="pdf-panel" />;
|
||||
}
|
||||
|
||||
function AndroidPdf({ file, theme }: PluginFilePanelProps) {
|
||||
const textStyle = useMemo(() => ({ color: theme.colors.foregroundMuted }), [theme]);
|
||||
return (
|
||||
<View style={messageStyle}>
|
||||
<Text style={textStyle}>
|
||||
{file.name} ({Math.round(file.size / 1024)} KB). Android cannot render PDF inline.
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user