@protobase/cli 0.94.29 → 0.94.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.94.
|
|
3
|
+
"version": "0.94.31",
|
|
4
4
|
"description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@better-auth/core": "^1.7.12",
|
|
45
45
|
"@hono/node-server": "^2.1.3",
|
|
46
|
-
"@protobase/config": "0.94.
|
|
47
|
-
"@protobase/layout": "0.94.
|
|
48
|
-
"@protobase/query": "0.94.
|
|
49
|
-
"@protobase/schema": "0.94.
|
|
50
|
-
"@protobase/server": "0.94.
|
|
51
|
-
"@protobase/ui": "0.94.
|
|
52
|
-
"@protobase/workflows": "0.94.
|
|
46
|
+
"@protobase/config": "0.94.31",
|
|
47
|
+
"@protobase/layout": "0.94.31",
|
|
48
|
+
"@protobase/query": "0.94.31",
|
|
49
|
+
"@protobase/schema": "0.94.31",
|
|
50
|
+
"@protobase/server": "0.94.31",
|
|
51
|
+
"@protobase/ui": "0.94.31",
|
|
52
|
+
"@protobase/workflows": "0.94.31",
|
|
53
53
|
"@react-email/render": "^2.1.0",
|
|
54
54
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
55
55
|
"@sentry/vite-plugin": "^11.10.0",
|
|
@@ -12,6 +12,7 @@ Uploaded files and images, where they are kept and how they are served.
|
|
|
12
12
|
- [Type detection](../reference/files.md#how-the-type-is-decided): An upload's type is decided from its content, and a disguised file is refused.
|
|
13
13
|
- [Your own types](../reference/files.md#your-own-types): An app names its own media types and their extensions, and files with them are stored and served as those types.
|
|
14
14
|
- [File viewers](../reference/files.md#viewers): A plugin registers a viewer for a media type, and a file of that type opens in it in the app instead of downloading.
|
|
15
|
+
- [Image and PDF viewers](../reference/files.md#image-and-pdf-viewers): Two plugins an app can attach open stored images and PDFs in the app, loaded only when such a file opens.
|
|
15
16
|
- [Signed downloads](../reference/files.md#downloads): Private files open through short-lived links that stop working once the record no longer holds the file.
|
|
16
17
|
- [Type and size fields](../reference/files.md#type-and-size-fields): Each file's media type and size are kept in columns of their own, for lists and aggregate queries, and serving reads the type from there.
|
|
17
18
|
- [Derived fields](../reference/files.md#derived-fields): Width, height, size and type of each upload are written to other fields.
|
|
@@ -206,6 +206,7 @@ Such files download as attachments. A [viewer](#viewers) opens them in the admin
|
|
|
206
206
|
- **Public files** are served to anyone at a permanent address, `/api/files/public/<path>`, cached for a year. `publicUrl` links them from elsewhere instead, such as a CDN in front of that route.
|
|
207
207
|
- Every download is `nosniff` with `Content-Security-Policy: sandbox; default-src 'none'`. Raster images, PDF, audio and video are `inline`; everything else, SVG included, is an attachment. A private file is named as its uploader named it, with the extension matched to the type (`photo.png` holding a JPEG downloads as `photo.jpg`); a public file by its stored path. `Range` requests work.
|
|
208
208
|
- A provider in a bucket answers with a redirect to the bucket instead, after the same checks, see [S3-compatible buckets](#s3-compatible-buckets).
|
|
209
|
+
- With `?via=app` the app serves the bytes itself after the same checks, from a bucket too, so a page can read them with `fetch` without the bucket sending CORS headers. A viewer's `useFileText` reads this way, and reads a public file linked at a `publicUrl` from `/api/files/<provider>/<path>`. Such a read takes files up to 10 MB and answers a larger one with `403`.
|
|
209
210
|
|
|
210
211
|
## Viewers
|
|
211
212
|
|
|
@@ -213,6 +214,30 @@ A plugin, or the app's own `protobase.ui.tsx`, registers a viewer for a media ty
|
|
|
213
214
|
|
|
214
215
|
The viewer gets the file and its **siblings**: the record's other files, and the files of the records of the same resource that point at the same records through filterable relations, read in one list call of at most 100 records. For attachments that each point at a task, the siblings of one are the other attachments of that task, so a report can show the images it names by file name.
|
|
215
216
|
|
|
217
|
+
### Image and PDF viewers
|
|
218
|
+
|
|
219
|
+
Protobase brings no viewer of its own. Two plugins, each a package of its own, open images and PDFs in the app; an app that wants them installs them and extends its `protobase.ui.tsx` with them:
|
|
220
|
+
|
|
221
|
+
```sh
|
|
222
|
+
npm install @protobase/image-viewer @protobase/pdf-viewer
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
```tsx
|
|
226
|
+
// protobase.ui.tsx
|
|
227
|
+
import { defineUi } from '@protobase/ui'
|
|
228
|
+
import imageViewer from '@protobase/image-viewer'
|
|
229
|
+
import pdfViewer from '@protobase/pdf-viewer'
|
|
230
|
+
|
|
231
|
+
export default defineUi({ extends: [imageViewer, pdfViewer] })
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Each viewer's code is a chunk of the app's build that loads only when such a file opens, so an app that extends them loads nothing more until then. On a phone both are as wide as the screen. A file a viewer cannot draw shows the Download button in its place.
|
|
235
|
+
|
|
236
|
+
- `@protobase/image-viewer` opens PNG, JPEG, GIF, WebP, AVIF and BMP, the images downloads serve inline: fitted to the page, with its size in pixels and an **Actual size** button that shows it pixel for pixel, scrolling in its own box when it is wider than the page. SVG stays a download.
|
|
237
|
+
- `@protobase/pdf-viewer` opens PDF files with an open-source PDF renderer that runs in a web worker: the pages one under the other, as wide as the page up to 60rem, each drawn when it comes within a screen of being shown and let go again once it is further away, so a long PDF holds only the pages around the screen. Scanned pages in JPEG 2000 or JBIG2 are drawn with the renderer's decoders, which the viewer brings. The renderer reads the file with `fetch`, so a PDF served from another origin than the app's, from a [bucket](#s3-compatible-buckets) or an [external URL](#external-urls)'s host, opens only when that host allows the app's origin with CORS; otherwise the viewer shows the Download button. <gap>The PDF viewer cannot select or search a page's text because a text layer is not implemented, so the page is an image and its text is read in the download.</gap> <gap>The PDF viewer cannot draw text that uses one of the renderer's predefined CMaps, as many Chinese, Japanese and Korean PDFs do whether or not they embed the font, because bringing those CMaps is not implemented, so such text is read in the download.</gap>
|
|
238
|
+
|
|
239
|
+
Each package also exports its viewer component (`ImageViewer`, `PdfViewer`), for an app that registers it for a type of its own in `fileViewers`.
|
|
240
|
+
|
|
216
241
|
## Type and size fields
|
|
217
242
|
|
|
218
243
|
`.typeField()` and `.sizeField()` keep each file's media type and size in columns of their own, so a list can show them and SQL can count and sum by them:
|
|
@@ -176,7 +176,7 @@ The create form and the record's form pick the members of the organization the s
|
|
|
176
176
|
|
|
177
177
|
## File viewers
|
|
178
178
|
|
|
179
|
-
A file viewer shows files of one media type in the app, such as a report the app writes as JSON, instead of downloading them. A plugin registers it by the type, which the server must know: a built-in type, or one of the app's own in `files.types` (see [Your own types](files.md#your-own-types)).
|
|
179
|
+
A file viewer shows files of one media type in the app, such as a report the app writes as JSON, instead of downloading them. `@protobase/image-viewer` and `@protobase/pdf-viewer` are two such plugins for images and PDFs (see [Image and PDF viewers](files.md#image-and-pdf-viewers)). A plugin registers it by the type, which the server must know: a built-in type, or one of the app's own in `files.types` (see [Your own types](files.md#your-own-types)).
|
|
180
180
|
|
|
181
181
|
```tsx
|
|
182
182
|
// protobase.ui.tsx
|
|
@@ -203,7 +203,7 @@ export default definePlugin({ fileViewers: { 'application/vnd.example.report+jso
|
|
|
203
203
|
| `file` | The file: `name`, `type`, `size`, `url`, the link that downloads it, and `uri`, its stored value. |
|
|
204
204
|
| `siblings` | The other files of its record and of the records that point at the same records, see [Viewers](files.md#viewers). `fileNamed(siblings, 'shots/before.png')` finds one by the last segment of a relative reference, and gives none for an absolute address. |
|
|
205
205
|
|
|
206
|
-
`useFileText(file)` reads the file's text once, as a TanStack Query result kept while the file stays the same. The viewer draws on the page below the file's bar, which scrolls as the page does. The file's link is a download link served with a sandboxing CSP, so a viewer reads the file and draws it itself rather than framing it.
|
|
206
|
+
`useFileText(file)` reads the file's text once, as a TanStack Query result kept while the file stays the same. It reads through the API that serves the record, whatever store holds the file and wherever its link points, up to 10 MB. The viewer draws on the page below the file's bar, which scrolls as the page does. The file's link is a download link served with a sandboxing CSP, so a viewer reads the file and draws it itself rather than framing it.
|
|
207
207
|
|
|
208
208
|
## Building
|
|
209
209
|
|