@protobase/cli 0.23.6 → 0.23.8
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/build/service-worker-code.js +52 -0
- package/dist/build/shell.js +10 -3
- package/dist/doctor/view-shapes.js +2 -2
- package/dist/package.js +1 -1
- package/dist/project/service-worker.js +46 -0
- package/package.json +6 -6
- package/skills/protobase/SKILL.md +1 -0
- package/skills/protobase/references/reference/auth.md +1 -1
- package/skills/protobase/references/reference/cli.md +4 -3
- package/skills/protobase/references/reference/client.md +1 -1
- package/skills/protobase/references/reference/custom-components.md +1 -1
- package/skills/protobase/references/reference/installable-app.md +36 -0
- package/skills/protobase/references/reference/ui-config.md +14 -3
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { faviconFile } from "./favicon.js";
|
|
2
|
+
import { themeFile } from "./theme.js";
|
|
3
|
+
//#region src/build/service-worker-code.ts
|
|
4
|
+
/** The service worker's file in the shell, at the root so it may answer the whole origin. */
|
|
5
|
+
const serviceWorkerFile = "protobase.sw.js";
|
|
6
|
+
/**
|
|
7
|
+
* The shell's service worker, which makes the admin app open without a network and then say the API is unreachable;
|
|
8
|
+
* data is never cached. A build of the shell names its own `version`, so a new shell's worker replaces the old one and
|
|
9
|
+
* drops its cache. `precache` is what the page loads first: the page itself and the assets it links.
|
|
10
|
+
*
|
|
11
|
+
* - A navigation goes to the network, and only when that fails gets the cached page, so an online app is always the
|
|
12
|
+
* server's.
|
|
13
|
+
* - The content-hashed assets under /assets come from the cache, filled as the app loads them.
|
|
14
|
+
* - The project's theme and favicon go to the network, the cached copy standing in when it fails.
|
|
15
|
+
* - Everything else, the API above all, never reaches the worker's cache.
|
|
16
|
+
*/
|
|
17
|
+
const serviceWorkerCode = ({ version, precache }) => `const cacheName = ${JSON.stringify(`protobase-shell-${version}`)}
|
|
18
|
+
const precache = ${JSON.stringify(precache)}
|
|
19
|
+
const revalidated = ${JSON.stringify([`/${themeFile}`, `/${faviconFile}`])}
|
|
20
|
+
|
|
21
|
+
const fromCache = (request) =>
|
|
22
|
+
caches.match(request).then((cached) => cached || fetch(request).then((response) => {
|
|
23
|
+
if (response.ok) caches.open(cacheName).then((cache) => cache.put(request, response.clone()))
|
|
24
|
+
return response
|
|
25
|
+
}))
|
|
26
|
+
|
|
27
|
+
const fromNetwork = (request, fallback) =>
|
|
28
|
+
fetch(request).then((response) => {
|
|
29
|
+
if (response.ok && fallback === request) caches.open(cacheName).then((cache) => cache.put(request, response.clone()))
|
|
30
|
+
return response
|
|
31
|
+
}, (error) => caches.match(fallback).then((cached) => cached || Promise.reject(error)))
|
|
32
|
+
|
|
33
|
+
self.addEventListener('install', (event) => {
|
|
34
|
+
event.waitUntil(caches.open(cacheName).then((cache) => cache.addAll(precache.map((url) => new Request(url, { cache: 'reload' })))).then(() => self.skipWaiting()))
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
self.addEventListener('activate', (event) => {
|
|
38
|
+
const old = (key) => key.startsWith('protobase-shell-') && key !== cacheName
|
|
39
|
+
event.waitUntil(caches.keys().then((keys) => Promise.all(keys.filter(old).map((key) => caches.delete(key)))).then(() => self.clients.claim()))
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
self.addEventListener('fetch', (event) => {
|
|
43
|
+
const request = event.request
|
|
44
|
+
const url = new URL(request.url)
|
|
45
|
+
if (request.method !== 'GET' || url.origin !== self.location.origin) return
|
|
46
|
+
if (request.mode === 'navigate') event.respondWith(fromNetwork(request, '/index.html'))
|
|
47
|
+
else if (url.pathname.startsWith('/assets/')) event.respondWith(fromCache(request))
|
|
48
|
+
else if (revalidated.includes(url.pathname)) event.respondWith(fromNetwork(request, request))
|
|
49
|
+
})
|
|
50
|
+
`;
|
|
51
|
+
//#endregion
|
|
52
|
+
export { serviceWorkerCode, serviceWorkerFile };
|
package/dist/build/shell.js
CHANGED
|
@@ -4,6 +4,8 @@ import { adminAppDir, uiEntry, uiPackageDir } from "../project/admin-app.js";
|
|
|
4
4
|
import { sharedModulesPlugin } from "../project/shared-modules.js";
|
|
5
5
|
import { faviconLink } from "../project/favicon-link.js";
|
|
6
6
|
import { themeLink } from "../project/theme-link.js";
|
|
7
|
+
import { serviceWorkerFile } from "./service-worker-code.js";
|
|
8
|
+
import { serviceWorker } from "../project/service-worker.js";
|
|
7
9
|
import { existsSync } from "node:fs";
|
|
8
10
|
import path from "node:path";
|
|
9
11
|
import { build } from "vite";
|
|
@@ -14,8 +16,12 @@ import { tmpdir } from "node:os";
|
|
|
14
16
|
//#region src/build/shell.ts
|
|
15
17
|
/** What a shell folder holds beside its files: the `BundleShell` a bundle's manifest copies. */
|
|
16
18
|
const shellManifestFile = "protobase.shell.json";
|
|
17
|
-
/** The shell's files, as URL paths: its page
|
|
18
|
-
const shellPaths = [
|
|
19
|
+
/** The shell's files, as URL paths: its page, its content-hashed assets and its service worker. */
|
|
20
|
+
const shellPaths = [
|
|
21
|
+
"/index.html",
|
|
22
|
+
"/assets",
|
|
23
|
+
`/${serviceWorkerFile}`
|
|
24
|
+
];
|
|
19
25
|
/** Where @protobase/ui's package ships its prebuilt shell, which `protobase build` copies and `protobase serve` serves. */
|
|
20
26
|
const prebuiltShellDir = path.join(uiPackageDir, "dist", "shell");
|
|
21
27
|
const shellIdentity = async () => {
|
|
@@ -31,7 +37,7 @@ const shellIdentity = async () => {
|
|
|
31
37
|
* The admin app as a production build, the same for every project: index.html and content-hashed files under assets/,
|
|
32
38
|
* with protobase.shell.json saying which version it is. Asset URLs are absolute, so index.html works as the answer to
|
|
33
39
|
* any deep link. It calls /api on its own origin and loads the project's UI, like every plugin, from what `/meta`
|
|
34
|
-
* names, and links the project's theme at /protobase.theme.css and its favicon at /protobase.favicon.svg. The modules plugins share with it have entries of
|
|
40
|
+
* names, and links the project's theme at /protobase.theme.css and its favicon at /protobase.favicon.svg, and registers its service worker. The modules plugins share with it have entries of
|
|
35
41
|
* their own, which index.html's import map names.
|
|
36
42
|
*/
|
|
37
43
|
const buildShell = async (outDir) => {
|
|
@@ -49,6 +55,7 @@ const buildShell = async (outDir) => {
|
|
|
49
55
|
projectUiPlugin(void 0),
|
|
50
56
|
themeLink(),
|
|
51
57
|
faviconLink(),
|
|
58
|
+
serviceWorker(),
|
|
52
59
|
react(),
|
|
53
60
|
tailwindcss()
|
|
54
61
|
],
|
|
@@ -139,7 +139,7 @@ const displayShapes = (model, view, models) => (view.list?.displays ?? []).flatM
|
|
|
139
139
|
}
|
|
140
140
|
}];
|
|
141
141
|
}
|
|
142
|
-
if (display.kind === "calendar") {
|
|
142
|
+
if (display.kind === "calendar" || display.kind === "timeline") {
|
|
143
143
|
const start = model.fields[display.start];
|
|
144
144
|
if (!start) return [];
|
|
145
145
|
const end = display.end === void 0 ? void 0 : model.fields[display.end];
|
|
@@ -150,7 +150,7 @@ const displayShapes = (model, view, models) => (view.list?.displays ?? []).flatM
|
|
|
150
150
|
return [{
|
|
151
151
|
resource: model.name,
|
|
152
152
|
request: request(model.name, text, sort),
|
|
153
|
-
from: `the
|
|
153
|
+
from: `the ${display.kind} display "${display.name}"`,
|
|
154
154
|
query: {
|
|
155
155
|
filter,
|
|
156
156
|
sort
|
package/dist/package.js
CHANGED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { faviconFile } from "../build/favicon.js";
|
|
2
|
+
import { themeFile } from "../build/theme.js";
|
|
3
|
+
import { serviceWorkerCode, serviceWorkerFile } from "../build/service-worker-code.js";
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
//#region src/project/service-worker.ts
|
|
6
|
+
const linkedAssets = (html) => [...new Set([...html.matchAll(/["'](\/assets\/[^"']+)["']/g)].map((match) => match[1]))];
|
|
7
|
+
/**
|
|
8
|
+
* Gives a production build of the app its service worker (see `serviceWorkerCode`) at `/protobase.sw.js`, which the
|
|
9
|
+
* page registers. The worker's version hashes the build's file names, which hash their contents.
|
|
10
|
+
*/
|
|
11
|
+
const serviceWorker = () => ({
|
|
12
|
+
name: "protobase-service-worker",
|
|
13
|
+
apply: "build",
|
|
14
|
+
transformIndexHtml: {
|
|
15
|
+
order: "post",
|
|
16
|
+
handler: () => [{
|
|
17
|
+
tag: "script",
|
|
18
|
+
children: `if ('serviceWorker' in navigator) navigator.serviceWorker.register('/${serviceWorkerFile}')`,
|
|
19
|
+
injectTo: "body"
|
|
20
|
+
}]
|
|
21
|
+
},
|
|
22
|
+
generateBundle: {
|
|
23
|
+
order: "post",
|
|
24
|
+
handler(_options, bundle) {
|
|
25
|
+
const page = bundle["index.html"];
|
|
26
|
+
if (page?.type !== "asset") throw new Error("The app build has no index.html to give a service worker");
|
|
27
|
+
const version = createHash("sha256").update(Object.keys(bundle).sort().join("\n")).digest("hex").slice(0, 16);
|
|
28
|
+
const precache = [
|
|
29
|
+
"/index.html",
|
|
30
|
+
...linkedAssets(String(page.source)),
|
|
31
|
+
`/${themeFile}`,
|
|
32
|
+
`/${faviconFile}`
|
|
33
|
+
];
|
|
34
|
+
this.emitFile({
|
|
35
|
+
type: "asset",
|
|
36
|
+
fileName: serviceWorkerFile,
|
|
37
|
+
source: serviceWorkerCode({
|
|
38
|
+
version,
|
|
39
|
+
precache
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
//#endregion
|
|
46
|
+
export { serviceWorker };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.8",
|
|
4
4
|
"description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@hono/node-server": "^2.1.3",
|
|
37
37
|
"@hono/vite-dev-server": "^0.26.1",
|
|
38
|
-
"@protobase/layout": "0.23.
|
|
39
|
-
"@protobase/query": "0.23.
|
|
40
|
-
"@protobase/schema": "0.23.
|
|
41
|
-
"@protobase/server": "0.23.
|
|
42
|
-
"@protobase/ui": "0.23.
|
|
38
|
+
"@protobase/layout": "0.23.8",
|
|
39
|
+
"@protobase/query": "0.23.8",
|
|
40
|
+
"@protobase/schema": "0.23.8",
|
|
41
|
+
"@protobase/server": "0.23.8",
|
|
42
|
+
"@protobase/ui": "0.23.8",
|
|
43
43
|
"@react-email/render": "^2.1.0",
|
|
44
44
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
45
45
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -80,6 +80,7 @@ Reference:
|
|
|
80
80
|
- When using resources another Protobase API serves → read [Remote resources](references/reference/remote-resources.md)
|
|
81
81
|
- When setting the app's tokens, colors and fonts → read [Theme](references/reference/theme.md)
|
|
82
82
|
- When showing the app's screens in Dutch → read [Languages](references/reference/languages.md)
|
|
83
|
+
- When installing the app on a phone or computer, or asking what it does offline → read [Installable app](references/reference/installable-app.md)
|
|
83
84
|
- When grouping sidebar entries or listing recent records → read [Sidebar](references/reference/sidebar.md)
|
|
84
85
|
- When changing the user menu → read [User menu](references/reference/user-menu.md)
|
|
85
86
|
- When adding tabs along the bottom of a phone → read [Bottom bar](references/reference/bottom-bar.md)
|
|
@@ -63,7 +63,7 @@ Upgrading from 0.5 or earlier, where `auth:migrate` created the tables, goes thr
|
|
|
63
63
|
- Cookies are `SameSite=Lax`, and `Secure` when `BETTER_AUTH_URL` is https.
|
|
64
64
|
- Sign-in is rate limited (5 password attempts per minute and client by default, `signInPerMinute`, which also limits [sign-up](#open-sign-up) requests; 3 per minute for emailed codes); the limiter keys on `x-forwarded-for`, so run behind a proxy that sets it.
|
|
65
65
|
- Passwords need at least 12 characters.
|
|
66
|
-
- `appName` is the app's name: authenticator apps and passkey prompts show it, the admin app's sidebar shows it at the top beside Protobase's mark (Protobase's wordmark when it is `Protobase`), every browser tab of the admin app ends its title with it, the [auth emails](email.md#protobases-own-mail)) name the app with it, and the platform's mailer sends them as it (the sender's display name). Default `PROTOBASE_APP_NAME`, when set, and `Protobase` otherwise, then without a display name.
|
|
66
|
+
- `appName` is the app's name: authenticator apps and passkey prompts show it, the admin app's sidebar shows it at the top beside Protobase's mark (Protobase's wordmark when it is `Protobase`), every browser tab of the admin app ends its title with it, the [installed app](installable-app.md)) is called by it, the [auth emails](email.md#protobases-own-mail)) name the app with it, and the platform's mailer sends them as it (the sender's display name). Default `PROTOBASE_APP_NAME`, when set, and `Protobase` otherwise, then without a display name.
|
|
67
67
|
|
|
68
68
|
## First run
|
|
69
69
|
|
|
@@ -178,6 +178,7 @@ dist/
|
|
|
178
178
|
node_modules/ the packages it loads from disk, only when it imports native add-ons
|
|
179
179
|
public/
|
|
180
180
|
index.html, assets/ the admin app: the shell, the same for every project
|
|
181
|
+
protobase.sw.js the shell's service worker (see Installable app)
|
|
181
182
|
plugins/app/ the project's protobase.ui.tsx, built as a plugin
|
|
182
183
|
plugins/<extension>/ each --extend folder's protobase.ui.tsx, built as a plugin
|
|
183
184
|
protobase.theme.css the project's theme, checked and minified; empty without one
|
|
@@ -215,7 +216,7 @@ By default the bundle runs on Node and on Bun. `--bun` makes it a bundle for Bun
|
|
|
215
216
|
"plugins": [
|
|
216
217
|
{ "name": "app", "path": "plugins/app/plugin.json", "api": 1, "protobase": ">=0.12.0", "fields": { "steps": ["enum"] } }
|
|
217
218
|
],
|
|
218
|
-
"shell": { "protobase": "0.12.0", "pluginApi": 1, "paths": ["/index.html", "/assets"] },
|
|
219
|
+
"shell": { "protobase": "0.12.0", "pluginApi": 1, "paths": ["/index.html", "/assets", "/protobase.sw.js"] },
|
|
219
220
|
"nodeModules": "node_modules"
|
|
220
221
|
}
|
|
221
222
|
```
|
|
@@ -235,7 +236,7 @@ By default the bundle runs on Node and on Bun. `--bun` makes it a bundle for Bun
|
|
|
235
236
|
|
|
236
237
|
`public/` holds two parts that are built apart.
|
|
237
238
|
|
|
238
|
-
- **The shell**, `index.html` and `
|
|
239
|
+
- **The shell**, `index.html`, `assets/` and `protobase.sw.js`: the admin app, a production build of `@protobase/ui`'s `src/app` with no project code in it, the same for every project on a release. `@protobase/ui`'s package ships it prebuilt in `dist/shell/` and the [protobase image](../guides/deploy.md#images)) at `/opt/protobase/shell/`; the build copies it. It calls the API on its own origin under `/api`, so the same bundle works under any hostname, and reads everything else at runtime: the resources, views, pages and roles from `/api/meta`, sign-in from `/api/auth`, the project's UI from its plugins and its look from `/protobase.theme.css`, which it links after its own stylesheets, its tab icon from `/protobase.favicon.svg`, and its [web app manifest](installable-app.md)) from `/api/manifest.webmanifest`.
|
|
239
240
|
- **The plugins**, `plugins/<name>/`: the project's `protobase.ui.tsx` as the plugin `app`, and each [extension](#extensions)'s, each built as [`build-plugin`](#build-plugin) builds one, against the `@protobase/ui` installed in the project. `/api/meta` names them, and the shell loads them as it loads any [plugin](plugins.md)). A component or field type the config declares but no `protobase.ui.tsx` exports fails the build (see [Components](custom-components.md#components))).
|
|
240
241
|
|
|
241
242
|
The modules the app shares with plugins, `react`, `react/jsx-runtime`, `react-dom` and `@protobase/ui`, are entries of their own, `/assets/shared-<name>-<hash>.js`, each exporting every name of its module. `index.html` maps the four names to them with an import map, ahead of every script, so a plugin's imports of them run on the app's copies.
|
|
@@ -359,7 +360,7 @@ Serves the API of a bundle from `protobase build` and owns the process around it
|
|
|
359
360
|
| `REQUEST_LOG` | `true` logs every request; default `false` |
|
|
360
361
|
| `PROTOBASE_SMTP_URL` | the SMTP server for password-reset mail, emailed sign-in and two-factor codes and the app's own [email](email.md)), credential included: `smtp://user:password@host:587` (STARTTLS when offered) or `smtps://...:465`; without it they are off ([Password reset](auth.md#password-reset)), [Emailed sign-in codes](auth.md#emailed-sign-in-codes))) |
|
|
361
362
|
| `PROTOBASE_MAIL_FROM` | the sender of that mail, a plain address such as `noreply@admin.example.com`; set with `PROTOBASE_SMTP_URL` or not at all |
|
|
362
|
-
| `PROTOBASE_APP_NAME` | the app's name, such as `Property Finder`: what its auth emails, its sidebar
|
|
363
|
+
| `PROTOBASE_APP_NAME` | the app's name, such as `Property Finder`: what its auth emails, its sidebar, its browser tabs and the [installed app](installable-app.md)) call it, and the sender's display name of its mail ([`appName`](auth.md#configuration))) |
|
|
363
364
|
| `PROTOBASE_SIGN_IN_ISSUER`, `PROTOBASE_SIGN_IN_CLIENT_ID`, `PROTOBASE_SIGN_IN_CLIENT_SECRET` | an OpenID Connect provider people who have an account can sign in with; all three or none. `PROTOBASE_SIGN_IN_PROVIDER` and `PROTOBASE_SIGN_IN_NAME` are optional ([Platform sign-in provider](auth.md#platform-sign-in-provider))) |
|
|
364
365
|
| `PROTOBASE_OPERATOR_ISSUER`, `PROTOBASE_OPERATOR_CLIENT_ID`, `PROTOBASE_OPERATOR_CLIENT_SECRET` | the OpenID Connect provider of the operator's staff, for [staff sign-in](auth.md#staff-sign-in)) as people of the app; all three or none. `PROTOBASE_OPERATOR_NAME` and `PROTOBASE_OPERATOR_GROUP` are optional ([Operator provider](auth.md#operator-provider))) |
|
|
365
366
|
| `PROTOBASE_ORIGINS`, `PROTOBASE_PASSKEY_DOMAIN` | the other origins the app is served on, comma separated, and the host new passkeys are made for ([Several origins](auth.md#several-origins))) |
|
|
@@ -23,7 +23,7 @@ With an absolute `baseUrl`, such as another app's `https://desk.example.com/api/
|
|
|
23
23
|
|
|
24
24
|
## The admin app
|
|
25
25
|
|
|
26
|
-
`<App baseUrl="/api/v1" />` renders the shell from `/api/meta` (beside the API, so `createClient` derives it from `baseUrl`) and routes `/:page` ([composed pages](layouts.md))), `/:resource` (list) and `/:resource/:key` (record); it opens on the first page, or the first resource. Its own pages sit under `/-/`, which no page or resource name takes: `/-/account` (the user's passkeys and two-factor authentication) and `/-/sign-in-policy` (admins: the policy, and the log of staff sign-ins). Before the shell, it signs in on its sign-in route, `/-/sign-in`, with the methods the server offers and asks for what the [sign-in policy](auth.md#sign-in-policy)) requires. Someone signed out goes there from any page, with that page in `?next=`, and signing in comes back to it; each step (a forgotten password, an emailed code, making an account) adds `?step=`, so the browser's Back returns to the step before; `?staff-sign-in` opens the [staff sign-in](auth.md#staff-sign-in)) page instead, and a staff session gets a banner above the shell. `createAuthSession` from `@protobase/client` is that session (`signIn`, `signInWithCode`, `signInWithPasskey`, `verifyTwoFactor`, `account`, `signInPolicy`, `staff`). `ui` takes the project's [custom components and action handlers](custom-components.md)). The list state lives in the URL: `?filter=` (AIP-160), `?order_by=`, `?layout=panel`, `?calendar=month,2026-10-01`, the month or week a [calendar](ui-config.md#calendars)) shows, and `?saved_search=`, the [saved search](ui-config.md#saved-searches)) the list was opened from. Views come from `examples/*/config/*/ui.ts`. The sidebar's recent-record groups and the user menu are configured there too: see [Sidebar](sidebar.md)), [User menu](user-menu.md)) and [Bottom bar](bottom-bar.md)).
|
|
26
|
+
`<App baseUrl="/api/v1" />` renders the shell from `/api/meta` (beside the API, so `createClient` derives it from `baseUrl`) and routes `/:page` ([composed pages](layouts.md))), `/:resource` (list) and `/:resource/:key` (record); it opens on the first page, or the first resource. Its own pages sit under `/-/`, which no page or resource name takes: `/-/account` (the user's passkeys and two-factor authentication) and `/-/sign-in-policy` (admins: the policy, and the log of staff sign-ins). Before the shell, it signs in on its sign-in route, `/-/sign-in`, with the methods the server offers and asks for what the [sign-in policy](auth.md#sign-in-policy)) requires. Someone signed out goes there from any page, with that page in `?next=`, and signing in comes back to it; each step (a forgotten password, an emailed code, making an account) adds `?step=`, so the browser's Back returns to the step before; `?staff-sign-in` opens the [staff sign-in](auth.md#staff-sign-in)) page instead, and a staff session gets a banner above the shell. `createAuthSession` from `@protobase/client` is that session (`signIn`, `signInWithCode`, `signInWithPasskey`, `verifyTwoFactor`, `account`, `signInPolicy`, `staff`). `ui` takes the project's [custom components and action handlers](custom-components.md)). The list state lives in the URL: `?filter=` (AIP-160), `?order_by=`, `?layout=panel`, `?calendar=month,2026-10-01`, the month or week a [calendar](ui-config.md#calendars)) shows, `?timeline=quarter,2026-10-01`, the week, month or quarter a [timeline](ui-config.md#timelines)) shows, and `?saved_search=`, the [saved search](ui-config.md#saved-searches)) the list was opened from. Views come from `examples/*/config/*/ui.ts`. The sidebar's recent-record groups and the user menu are configured there too: see [Sidebar](sidebar.md)), [User menu](user-menu.md)) and [Bottom bar](bottom-bar.md)).
|
|
27
27
|
|
|
28
28
|
## Global search
|
|
29
29
|
|
|
@@ -87,7 +87,7 @@ A prop that names a field is a field reference, `fieldRef('plan.name')` from `@p
|
|
|
87
87
|
|
|
88
88
|
## List displays
|
|
89
89
|
|
|
90
|
-
A list can show its rows with a component of the project's own, declared in the view with [`d.custom`](ui-config.md#list-displays)). The list page loads the rows, with the filter, search and order of the address, and the component draws them: `useListDisplay()` gives them, `RecordLink` opens one. A board in columns of an enum field, with cards dragged between them, is built in as [`d.board`](ui-config.md#boards)),
|
|
90
|
+
A list can show its rows with a component of the project's own, declared in the view with [`d.custom`](ui-config.md#list-displays)). The list page loads the rows, with the filter, search and order of the address, and the component draws them: `useListDisplay()` gives them, `RecordLink` opens one. A board in columns of an enum field, with cards dragged between them, is built in as [`d.board`](ui-config.md#boards)), a month or week calendar of a date field as [`d.calendar`](ui-config.md#calendars)), and a Gantt-style timeline of bars from a start to an end date as [`d.timeline`](ui-config.md#timelines)); the board below draws its own.
|
|
91
91
|
|
|
92
92
|
```tsx
|
|
93
93
|
// components/repair-board.tsx, exported from protobase.ui.tsx: export { RepairBoard } from './components/repair-board'
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/reference/installable-app.md: run `bun run docs:skill`, do not edit. -->
|
|
2
|
+
|
|
3
|
+
# Installable app
|
|
4
|
+
|
|
5
|
+
The admin app installs as an app of its own on phones and computers, named for the app, and opens without a network to say the server is out of reach.
|
|
6
|
+
|
|
7
|
+
Every app built with `protobase build` can be installed from the browser, as a Progressive Web App: Chrome and Edge offer **Install** in the address bar, Android's browsers **Add to home screen**, and Safari on iPhone and iPad **Share > Add to Home Screen**. The installed app opens in a window of its own, without the browser's toolbars, at the app's home page.
|
|
8
|
+
|
|
9
|
+
There is nothing to set up. The app installs under its name, `appName` or `PROTOBASE_APP_NAME` (see [auth configuration](auth.md#configuration))), with its favicon, `protobase.favicon.svg` (see [Logo and favicon](theme.md#logo-and-favicon))), as its icon. Safari takes no SVG icon and shows a picture of the page on the home screen instead.
|
|
10
|
+
|
|
11
|
+
## The manifest
|
|
12
|
+
|
|
13
|
+
The app's page links its web app manifest at `/api/manifest.webmanifest`, which the server answers to anyone, without a token:
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"name": "Property Finder",
|
|
18
|
+
"short_name": "Property Finder",
|
|
19
|
+
"id": "/",
|
|
20
|
+
"start_url": "/",
|
|
21
|
+
"scope": "/",
|
|
22
|
+
"display": "standalone",
|
|
23
|
+
"icons": [{ "src": "/protobase.favicon.svg", "sizes": "any", "type": "image/svg+xml" }]
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Without a network
|
|
28
|
+
|
|
29
|
+
The data stays online: the installed app reads and writes through the API as the browser tab does, and nothing works offline. The page registers a service worker, `/protobase.sw.js` in the bundle's `public/`, which keeps only the app itself, so the app still opens without a network and says it cannot reach the server.
|
|
30
|
+
|
|
31
|
+
- A page always comes from the server while it answers, and from the cache only when the network fails.
|
|
32
|
+
- The files under `/assets`, named by their content, come from the cache once loaded. The page and what it loads first are cached when the worker installs.
|
|
33
|
+
- The theme and the favicon come from the server, with the cached copy used when the network fails.
|
|
34
|
+
- Nothing else is cached: the API, the plugins and other sites go to the network as without the worker.
|
|
35
|
+
|
|
36
|
+
Each build of the app has its own worker, which replaces the previous one and drops its cache on the next visit. `protobase dev` registers no worker, so the dev server's changes always show.
|
|
@@ -267,7 +267,7 @@ It can show the list's records per value of a field instead, such as orders per
|
|
|
267
267
|
|
|
268
268
|
## List displays
|
|
269
269
|
|
|
270
|
-
Besides its table, a list can show as cards, on a map, as a board in columns of its status, on a calendar of a date, or as a component of the project's own. The list stays at `/<resource>`, read through the list API, with its search, filters, chart, order and New button; only the way the rows are drawn changes.
|
|
270
|
+
Besides its table, a list can show as cards, on a map, as a board in columns of its status, on a calendar of a date, as a timeline of bars from a start to an end date, or as a component of the project's own. The list stays at `/<resource>`, read through the list API, with its search, filters, chart, order and New button; only the way the rows are drawn changes.
|
|
271
271
|
|
|
272
272
|
```ts title="docs-examples/reference/workshop.ts"
|
|
273
273
|
import { component } from '@protobase/layout'
|
|
@@ -306,11 +306,12 @@ export const repairsView = daily
|
|
|
306
306
|
| `d.map({ latitude, longitude, approximate?, exact?, radius?, area? }, { name?, label?, icon?, cards?, defaultRadius? })` | The matching records in the map's view, with how many there are below it; it asks again as it pans and zooms, through the list API's [`:map`](api.md#maps)). From far out it shows a count for each part of the map, which zooms in when chosen; close in, or with few records in view, the records themselves. Nearby records share a marker with their count; choosing one shows the record's card at the map's bottom, with arrows through the marker's records, and choosing the map elsewhere or closing the card clears it. The card is the one of the cards display `cards` names, else the list's first cards display, else the record's title. A record at an approximate position has a hollow marker and the area around it; see [Approximate positions](#approximate-positions). Named `map` unless `name` says otherwise. See [Maps](#maps). |
|
|
307
307
|
| `d.board({ by, title?, subtitle?, badge?, meta? }, { name?, label?, icon? })` | A column per value of the enum field `by`, each with how many records have it, and a card per record that opens it: `title` (default: the view's `.title`) over `subtitle`, with `badge` and a few small `meta` fields, as the built-in card of `d.cards` draws them. Dragging a card to another column, or moving it with the keyboard, saves the record with that column's value. Within a column, cards are reordered when the resource has a `.position()`. Named `board` unless `name` says otherwise. See [Boards](#boards). |
|
|
308
308
|
| `d.calendar({ start, end?, title? }, { name?, label?, icon? })` | The records on the days from their date or timestamp field `start` to `end`, or on their start day alone, in a month grid or a week grid, each event a link to its record showing `title` (default: the view's `.title`). Dragging an event to another day, or moving it with the keyboard, saves the record with `start` and `end` moved by the same days. Named `calendar` unless `name` says otherwise. See [Calendars](#calendars). |
|
|
309
|
+
| `d.timeline({ start, end?, group?, title? }, { name?, label?, icon? })` | A Gantt-style timeline: each record a row with a bar from its date or timestamp field `start` to `end`, or on its start day alone, over a week, a month or a quarter, in lanes by the values of `group`. Each bar is a link to its record showing `title` (default: the view's `.title`). Dragging a bar along its row, or moving it with the keyboard, saves the record with `start` and `end` moved by the same days. Named `timeline` unless `name` says otherwise. See [Timelines](#timelines). |
|
|
309
310
|
| `d.custom(Component, { name, label, fields, props?, icon? })` | The rows drawn by a [custom component](custom-components.md#list-displays)). `fields` are the fields it shows, loaded with the names of the records relations point at; `props` are plain data, with `r.field` where it takes a field. |
|
|
310
311
|
|
|
311
|
-
With displays, the list page has a switch at the right of its title: the table first, then each display by its `label`, with its `icon` (`table`, `cards`, `kanban`, `board`, `list` or `
|
|
312
|
+
With displays, the list page has a switch at the right of its title: the table first, then each display by its `label`, with its `icon` (`table`, `cards`, `kanban`, `board`, `list`, `calendar` or `timeline`). Below the `md` breakpoint (768px) the switch is a menu of the same choices. The choice is in the address, `/repairs?display=cards`, so a reload, a bookmark or a shared link opens the same display; `default` names the display `/repairs` opens in, the table when it is left out. On a phone, below Tailwind's `sm` breakpoint (640px), a list with a cards display opens in it instead: the `default` when that is a cards display, else the first. A list without one opens in a built-in **List** there: a row per record with its `.title`, the first enum column as a badge on its right, and the next two columns but booleans on a muted line below, at `?display=rows`. The display menu offers the table beside it. A `?display=` in the address wins on any screen. A display without column headers has a sort menu over the sortable fields it shows, beside the filters, or below `md` in the filters sheet, whose button sits left of the search box. Selecting rows, deleting them in bulk and the row menu stay on the table, which every list keeps.
|
|
312
313
|
|
|
313
|
-
The table, the cards, a board and a
|
|
314
|
+
The table, the cards, a board, a calendar and a timeline scroll with the page, which is as tall as all their rows, with the browser's own scrolling: only the rows and cards in view are drawn and loaded, so a list of any length scrolls at once, and Back returns to the same ones. The table's header stays below the top bar while the page scrolls. Every card is as tall as the tallest one drawn at that width. A custom display scrolls with the page as well, as every other page of the app does; the map fills the screen between the top bar and a phone's bottom bar instead, and does not scroll. Where scrollbars take room, as on Windows, the page keeps room for one even while it fits, so the cards keep their width as the scrollbar comes and goes.
|
|
314
315
|
|
|
315
316
|
Display names are checked when the config loads: unique, not `table`, and `default` names one. Their fields are checked when the server starts, and may not be [sensitive](data-config.md#sensitive-fields)). In `/api/meta`, a user's displays lose the fields they cannot read, and a custom display whose `props` name one is left out; the list then opens in the table when its default display went.
|
|
316
317
|
|
|
@@ -359,6 +360,16 @@ An event moves to another day by dragging it, by a long press and drag on a touc
|
|
|
359
360
|
|
|
360
361
|
`start` must be a filterable date or timestamp field, and `end` a filterable field of the same type, checked when the config loads and when the server starts. [`protobase doctor`](cli.md#doctor)) checks that indexes serve the days' filter on `start`, and on `end` when it is set. In `/api/meta`, a user who cannot read `start` gets the list without the calendar, opening in the table when it was the default, and one who cannot read `end` or `title` gets the calendar without them.
|
|
361
362
|
|
|
363
|
+
### Timelines
|
|
364
|
+
|
|
365
|
+
`d.timeline({ start: r.starts_on, end: r.ends_on, group: r.crew_id, title: r.number })` shows the list's records as a Gantt chart: a row per record, its title on the left (above its bar on a phone), and a bar over the days from its `start` through its `end`, or its start day alone without an `end`. Days, weeks and a timestamp `end` work as on a [calendar](#calendars). The timeline shows a week of seven days from Monday, a month, or a quarter from January, April, July or October, today's day shaded; a bar that starts before the days shown or ends after them is cut square at that edge. With `group`, the rows are in lanes, one for each value a record shown has, each headed by the value and its count: an enum's lanes in the order the field lists its values, headed by their value labels; a relation's by the names of the records it points at; others by value; and last the records without a value, under **No** and the field's label. Within a lane the rows are in start order.
|
|
366
|
+
|
|
367
|
+
The period is in the address, `/jobs?display=timeline&timeline=quarter,2026-10-01`, or `timeline=week,2026-10-12` or `month,2026-10-01`, and the previous, today's and next period, and Week, Month and Quarter, are links to it; without it the timeline shows this month. Switching the scale opens the period holding today when the one shown holds it, else the one holding its first day. An embedded list keeps its timeline's period to itself. It reads the days it shows as a calendar does, through the list API with the list's filter and search, the same 500 records at most and no sort menu.
|
|
368
|
+
|
|
369
|
+
A bar moves along its row by dragging it, by a long press and drag on a touch screen, or from the keyboard: Space on a bar picks it up, the left and right arrow keys move it a day, Space or Enter drops it and Escape puts it back; a screen reader is told the day it starts on. The move saves the record as a calendar's does, with `start` and `end` moved by the same days, so the resource's access rules and `validate` decide, and a refused move puts the bar back with the server's reason. A bar keeps its length; to change it, edit `end` on the record.
|
|
370
|
+
|
|
371
|
+
`start` and `end` are checked as a calendar's are, and `group` may be any field the view may show. `protobase doctor` checks the indexes of its filter as it does a calendar's. In `/api/meta`, a user who cannot read `start` gets the list without the timeline, and one who cannot read `end`, `group` or `title` gets the timeline without them, in one lane when it is `group`.
|
|
372
|
+
|
|
362
373
|
### Card photos
|
|
363
374
|
|
|
364
375
|
`photos: { resource, field, image, sort? }` names where a card's further photos come from: the records of `resource` whose relation `field` points at the card's record, in `sort` order, each shown by its file field `image`. The card's picture snaps photo by photo as it is swiped on a touch screen, and shows a left and a right arrow while the pointer is over it. The photos come with the list's records, in the same request through the list API's [`photos`](api.md#card-photos)), so every card on the page has them from the start, and a map's card too. The card's own `image` comes first and is not shown twice when it is among the photos too, and a card steps through ten pictures at most, its own among them; the arrows wrap around at both ends, dots under the picture mark the photo shown, and a card with no further photos has no arrows. Swiping or pressing an arrow does not open the record; tapping the picture does. In a row that scrolls sideways, as an embedded list shows its cards on a phone, a swipe scrolls the row instead, and the arrows show at all times on a touch screen. A card drawn by a `card` component has no arrows.
|