@protobase/cli 0.96.11 → 0.96.12

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,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.96.11";
2
+ var version = "0.96.12";
3
3
  //#endregion
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.96.11",
3
+ "version": "0.96.12",
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.96.11",
47
- "@protobase/layout": "0.96.11",
48
- "@protobase/query": "0.96.11",
49
- "@protobase/schema": "0.96.11",
50
- "@protobase/server": "0.96.11",
51
- "@protobase/ui": "0.96.11",
52
- "@protobase/workflows": "0.96.11",
46
+ "@protobase/config": "0.96.12",
47
+ "@protobase/layout": "0.96.12",
48
+ "@protobase/query": "0.96.12",
49
+ "@protobase/schema": "0.96.12",
50
+ "@protobase/server": "0.96.12",
51
+ "@protobase/ui": "0.96.12",
52
+ "@protobase/workflows": "0.96.12",
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
+ - [HTML file viewer](../reference/files.md#html-files) (beta): Uploaded HTML files open in place in a sandboxed frame, with their images, videos and links resolved to the files stored beside them on the same record.
15
16
  - [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.
16
17
  - [Signed downloads](../reference/files.md#downloads): Private files open through short-lived links that stop working once the record no longer holds the file.
17
18
  - [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.
@@ -16,7 +16,7 @@ To see whether Protobase is of use before setting anything up, paste this line i
16
16
  powershell -c "irm https://docs.protobase.net/try.ps1|iex"
17
17
  ```
18
18
 
19
- It downloads `protobase-try.exe` from the latest release, about 45 MB, and PostgreSQL 18, about 40 MB, once, and starts the [automations](#start-an-app) preset with [workflows](reference/workflows.md) on, on this computer alone. It prints the address, `http://localhost:3000` unless that port is taken, and an admin's email and password, adds a sample workflow, "Say hello", and opens the browser. Nothing is installed and nothing needs Git, Node or Bun: the program, the database and the app's files stay in `%LOCALAPPDATA%\Protobase\automations`, with the password in `sign-in.txt` there. Ctrl+C or closing the window stops it; the line starts it again, and takes the newer program when a release is out. To remove everything, stop it and delete that folder. It is a trial of a finished app, not a project to change: [Start an app](#start-an-app) makes one.
19
+ It downloads `protobase-try.exe` from the latest release, about 60 MB, and PostgreSQL 18, about 40 MB, once, and starts the [automations](#start-an-app) preset with [workflows](reference/workflows.md) on, on this computer alone. It prints the address, `http://localhost:3000` unless that port is taken, and an admin's email and password, adds a sample workflow, "Say hello", and opens the browser. Nothing is installed and nothing needs Git, Node or Bun: the program, the database and the app's files stay in `%LOCALAPPDATA%\Protobase\automations`, with the password in `sign-in.txt` there. Ctrl+C or closing the window stops it; the line starts it again, and takes the newer program when a release is out. To remove everything, stop it and delete that folder. It is a trial of a finished app, not a project to change: [Start an app](#start-an-app) makes one.
20
20
 
21
21
  ## Start an app
22
22
 
@@ -181,10 +181,10 @@ An upload carries three hints: what the **content** is (C, from its magic bytes)
181
181
  | Content | Type used | When the hints disagree |
182
182
  | --- | --- | --- |
183
183
  | Recognized: images, PDF, archives, Office files, audio, video, executables, ... | C | C wins and the answer reports `corrected: { from, to }`: a JPEG sent as `photo.png` is `image/jpeg`, and an executable named `invoice.pdf` is refused by `accept: ['application/pdf']`. |
184
- | Not recognized, and text (UTF-8 without NUL bytes) | E when it is a text type (`csv`, `tsv`, `txt`, `md`, `json`); H when there is no extension; else `text/plain` | E wins over H: HTML named `.csv` is stored as `text/csv`. HTML and SVG are never taken as images. |
184
+ | Not recognized, and text (UTF-8 without NUL bytes) | E when it is a text type (`csv`, `tsv`, `txt`, `md`, `html`, `json`); H when there is no extension; else `text/plain` | E wins over H: HTML named `.csv` is stored as `text/csv`. HTML and SVG are never taken as images. |
185
185
  | Not recognized, and binary | E, only when `accept` lists that type exactly and H does not disagree; else `application/octet-stream` | Any disagreement gives `application/octet-stream`, which passes only an `accept` that names it. |
186
186
 
187
- The decided type picks the stored extension, and downloads are served by that extension, so nothing posing as a PDF is ever served as something else, and nothing is served as HTML.
187
+ The decided type picks the stored extension, and downloads are served by that extension, so nothing posing as a PDF is ever served as something else. An HTML file is stored as `text/html` but always downloads as an attachment that never renders on the app's origin; the admin app opens it in its [HTML viewer](#html-files).
188
188
 
189
189
  ### Your own types
190
190
 
@@ -210,13 +210,53 @@ Such files download as attachments. A [viewer](#viewers) opens them in the admin
210
210
 
211
211
  ## Viewers
212
212
 
213
- A plugin, or the app's own `protobase.ui.tsx`, registers a viewer for a media type (see [File viewers](plugins.md#file-viewers)). A file field's link to a file of that type, on the record page and its form, then opens the viewer on the record's address with `?file=<field>`, such as `/attachments/7?file=file`, in place of a download: a bar with the way back to the record, the file's name and size and a Download button, and the viewer below it. A file without a viewer links to its download as before.
213
+ A plugin, or the app's own `protobase.ui.tsx`, registers a viewer for a media type (see [File viewers](plugins.md#file-viewers)). A file field's link to a file of that type, on the record page and its form, then opens the viewer on the record's address with `?file=<field>`, such as `/attachments/7?file=file`, in place of a download: a bar with the way back to the record, the file's name and size and a Download button, and the viewer below it. A file without a viewer links to its download as before; its own address with `?file=<field>`, such as a page's link to it, shows the bar and says there is no preview.
214
214
 
215
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.
216
216
 
217
+ ### HTML files
218
+
219
+ :::caution[Beta]
220
+ Scripts in uploaded HTML files do not run.
221
+ :::
222
+
223
+ HTML files open in a sandboxed frame that cannot reach your app. Relative images, videos and links resolve to the record's other files. Your own viewer can draw the HTML it generates in the same frame and use the same link resolution.
224
+
225
+ Protobase brings this viewer itself, for `text/html`, the type an upload named `.html` or `.htm` is stored as; an app or plugin that registers its own `text/html` viewer replaces it. The page shows below the file's bar, as tall as its content, so the app's page scrolls:
226
+
227
+ - The frame has an opaque origin: the page cannot read the app's cookies or storage, call its API as the signed-in user, or navigate the app's window. It loads nothing from the network, so an image or stylesheet from another site stays blank, and it submits no forms.
228
+ - A relative `src`, `poster`, `srcset` candidate, `<link href>` or CSS `url()` in a `style` attribute or `<style>` element that names a sibling by its file name, such as `shots/before.png` or `./clip.webm`, shows that sibling. The admin app reads each such sibling once, with the signed-in user's rights, and hands it to the page as its bytes. A name with escapes, such as `my%20chart.png`, matches `my chart.png`. A reference to no sibling, a path from the root or one that climbs out with `..` stays as written, so it shows nothing, and such a link becomes plain text.
229
+ - A link to a sibling opens it on its record's address with `?file=<field>`, the address the link shows: in its viewer, such as another HTML page, or beside its Download button when it has none. A middle or modified click opens it in a new tab. A link to an `http` or `https` address opens it in a new tab that cannot reach back to the app. A link to a place on the page, such as `#results`, scrolls the app's page to it and moves the focus there. Any other link, such as `javascript:`, does nothing.
230
+
231
+ <gap>An HTML file's siblings over 10 MB, such as a long video, cannot show in its page because reading larger files in the app is not implemented.</gap> <gap>A `url()` inside a linked stylesheet cannot name a sibling because rewriting stylesheet files is not implemented.</gap>
232
+
233
+ Your own viewer draws a page in the same frame with `HtmlFrame`, and resolves its references with `useSiblingPage`, such as for a page it builds from a template and a JSON file:
234
+
235
+ ```tsx
236
+ import { HtmlFrame, useFileText, useSiblingPage, type FileViewerProps } from '@protobase/ui'
237
+
238
+ // renderReport is your own template: the report's JSON in, a page out.
239
+ const ReportViewer = ({ file, siblings }: FileViewerProps) => {
240
+ const read = useFileText(file)
241
+ const page = useSiblingPage(read.data && renderReport(JSON.parse(read.data)), siblings)
242
+ if (!page) return null
243
+ return <HtmlFrame html={page.html} title={file.name} links={page.links} onLink={(link) => link.kind === 'external' && window.open(link.url, '_blank', 'noopener,noreferrer')} />
244
+ }
245
+ ```
246
+
247
+ | `HtmlFrame` props | |
248
+ | --- | --- |
249
+ | `html` | The page, a whole document or a fragment. |
250
+ | `title` | The frame's accessible name, such as the file's name. |
251
+ | `links` | The targets of the page's links, as `useSiblingPage` gives them: `{ kind: 'file', file }` for a sibling, `{ kind: 'external', url }` for an `http` or `https` address. |
252
+ | `onLink` | `(link, { newTab })`, called when the page's link to `link` is clicked; `newTab` for a middle or modified click. Nothing else in the page navigates. |
253
+ | `scripts` | `'bridge'` (the default) runs none of the page's scripts. `'trusted-page'` runs its inline scripts, for a page your viewer generates itself; the frame keeps its opaque origin and still loads nothing from the network. |
254
+
255
+ `useSiblingPage(html, siblings, address?)` gives `{ html, links }` once `html` is there and the siblings it names are read, and `undefined` until then. `address(link)` gives the address each link shows, for the browser's link preview and copy link, such as the sibling's own viewer address; without one a link keeps the address its page gave it. `siblingPage(html, siblings, contents, address?)` does the same rewriting without reading, with each sibling's `data:` URL in `contents` by its `uri`.
256
+
217
257
  ### Image and PDF viewers
218
258
 
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:
259
+ Beside its HTML viewer, 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
260
 
221
261
  ```sh
222
262
  npm install @protobase/image-viewer @protobase/pdf-viewer
@@ -257,7 +297,7 @@ select attachment_type, count(*), sum(attachment_size) from attachments group by
257
297
  - An **external URL** writes the type its extension names, the app's [own types](#your-own-types) included, and `null` when the table knows no such extension. Its size field stays `null`, since Protobase never fetches it.
258
298
  - An **import** that writes rows itself may write both beside the value, such as the type of a file stored under a name with no extension. Leave a field `null` when the source does not say; never guess.
259
299
  - **Responses** and [viewers](#viewers) take the file's `type` and `size` from these fields when the row holds them, else from the value.
260
- - A **private download** is served as the type field's type when that is a type the app's table knows, so a file is never served as HTML; any other value is served by the path's extension. A public file has no row to read, so it is served by its path, and a bucket serves it with the type its upload was decided to be.
300
+ - A **private download** is served as the type field's type when that is a type the app's table knows, and HTML only ever as an attachment; any other value is served by the path's extension. A public file has no row to read, so it is served by its path, and a bucket serves it with the type its upload was decided to be.
261
301
 
262
302
  Files stored before a field declared them keep `null` until they are uploaded again or an import fills them.
263
303
 
@@ -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. 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.
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; a page of HTML it draws in an [`HtmlFrame`](files.md#html-files).
207
207
 
208
208
  ## Building
209
209