@protobase/cli 0.95.14 → 0.96.0

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.95.14";
2
+ var version = "0.96.0";
3
3
  //#endregion
4
4
  export { version };
@@ -6,6 +6,7 @@ import { capacitorOrigin } from "@protobase/schema/internal";
6
6
  const protobasePlugin = "@protobase/mobile";
7
7
  const keyboardPlugin = "@capacitor/keyboard";
8
8
  const liveUpdatePlugin = "@capawesome/capacitor-live-update";
9
+ const splashPlugin = "@capacitor/splash-screen";
9
10
  const pushPresentation = [
10
11
  "badge",
11
12
  "sound",
@@ -16,9 +17,9 @@ const readyTimeout = 3e4;
16
17
  * The app's `capacitor.config.json`, every key it sets named here. It never sets `server.url`, the hostname or the
17
18
  * schemes (the API's CORS list names Capacitor's default origins). WebView debugging is off in an iOS release by name:
18
19
  * Capacitor's prebuilt simulator framework is a Debug build, so its default lists a Release app in Safari's Develop menu.
19
- * `plugins` configures ProtobaseAuth, the keyboard plugin and, with the live updater, what its guard needs: the key
20
- * releases are signed with, where they come from, the binary's fingerprint, shell version and the order of its own
21
- * files, background updates off, a rolled-back bundle blocked and `readyTimeout`, within which the shell must call
20
+ * `plugins` configures ProtobaseAuth, the keyboard plugin, the splash screen, which stays up until the shell hides it,
21
+ * and, with the live updater, what its guard needs: the key releases are signed with, where they come from, the
22
+ * binary's fingerprint, shell version and the order of its own files, background updates off, a rolled-back bundle blocked and `readyTimeout`, within which the shell must call
22
23
  * ready() or the app goes back to its own files. CapacitorHttp and CapacitorCookies stay off; the keyboard plugin
23
24
  * resizes natively, its default, and fills the space beside the keyboard's rounded corners with the page's background
24
25
  * instead of black. With `push`, Capacitor's push plugin is compiled in and shows a push while the app is open, and on
@@ -38,6 +39,7 @@ const capacitorConfig = ({ appId, appName, fingerprint, shellVersion, plugins, l
38
39
  ...liveUpdate ? [liveUpdatePlugin] : [],
39
40
  ...push ? [pushPlugin] : [],
40
41
  keyboardPlugin,
42
+ splashPlugin,
41
43
  protobasePlugin
42
44
  ],
43
45
  plugins: {
@@ -46,6 +48,7 @@ const capacitorConfig = ({ appId, appName, fingerprint, shellVersion, plugins, l
46
48
  origin: capacitorOrigin[platform]
47
49
  },
48
50
  Keyboard: { autoBackdropColor: "dom" },
51
+ SplashScreen: { launchAutoHide: false },
49
52
  ...push && { PushNotifications: { presentationOptions: pushPresentation } },
50
53
  ...apnsEnvironment && { ProtobasePush: { environment: apnsEnvironment } },
51
54
  ...liveUpdate && { LiveUpdate: {
@@ -1,6 +1,6 @@
1
1
  //#region ../mobile/package.json
2
2
  var name = "@protobase/mobile";
3
- var nativeContract = 12;
3
+ var nativeContract = 13;
4
4
  var dependencies = {
5
5
  "@capacitor/android": "8.5.3",
6
6
  "@capacitor/app": "8.1.2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.95.14",
3
+ "version": "0.96.0",
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.95.14",
47
- "@protobase/layout": "0.95.14",
48
- "@protobase/query": "0.95.14",
49
- "@protobase/schema": "0.95.14",
50
- "@protobase/server": "0.95.14",
51
- "@protobase/ui": "0.95.14",
52
- "@protobase/workflows": "0.95.14",
46
+ "@protobase/config": "0.96.0",
47
+ "@protobase/layout": "0.96.0",
48
+ "@protobase/query": "0.96.0",
49
+ "@protobase/schema": "0.96.0",
50
+ "@protobase/server": "0.96.0",
51
+ "@protobase/ui": "0.96.0",
52
+ "@protobase/workflows": "0.96.0",
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 @@ The app's colours, name, icon, language and installation.
12
12
  - [Named icons](../reference/layouts.md#named-actions): Actions, key facts and card meta show an icon picked by name from a set, such as `play`, `bed` or `cpu`.
13
13
  - [English and Dutch](../reference/languages.md): The built-in screens come in English and Dutch, with numbers and dates written to match.
14
14
  - [Installable app](../reference/installable-app.md): The admin installs as an app on phones and computers, and says when the server cannot be reached.
15
+ - [Start from the last pages seen](../reference/installable-app.md#starting-from-the-last-pages-seen): Someone signed in opens the app on what it showed last time, muted with a spinner by the title until it is refreshed in the background.
15
16
 
16
17
  ## Accessibility
17
18
 
@@ -150,7 +150,7 @@ mobile: {
150
150
  },
151
151
  ```
152
152
 
153
- Build the binary again. Each deploy of the app then reaches it: it downloads the files that changed in the background and runs them at its next start, or when it comes back to the foreground after 5 minutes or more away, on the page it showed and still signed in. It never switches while in use, within 5 minutes of leaving it, or over unsaved changes on the page, and it asks nobody to reload. A release that fails to start goes back to the files the binary carries. Releases come from a server of the same Protobase minor as the binary (below 1.0); a newer minor needs a store release. See [the live updater](../reference/cli.md#the-live-updater).
153
+ Build the binary again. Each deploy of the app then reaches it: it downloads the files that changed in the background and runs them at its next start, or when it comes back to the foreground after 5 minutes or more away, on the page it showed and still signed in, behind its splash screen. Right after someone signs in, it switches before the app opens. It never switches while in use, within 5 minutes of leaving it, or over unsaved changes on the page, and it asks nobody to reload. A release that fails to start goes back to the files the binary carries. Releases come from a server of the same Protobase minor as the binary (below 1.0) and the same native code; a newer minor, or a Protobase release that changes the native code, needs a store release. See [the live updater](../reference/cli.md#the-live-updater).
154
154
 
155
155
  ## 8. What the stores accept
156
156
 
@@ -477,20 +477,22 @@ Mobile releases and the live updater are in development.
477
477
 
478
478
  With a `mobile` section, the server serves the [mobile app](../guides/mobile-app.md) a newer copy of its files, for its live updater, so the app gets UI changes without a store release. The release is what the server serves the web, composed at startup: every file of `public/`, with the server's own shell where `protobase serve` uses it, and `index.html` naming the API origin, the app's `url` (https, or plain http to `localhost`, `127.0.0.1` or `[::1]`). There is none when the server serves the API alone, has no such `url`, or the bundle names no `native`, and with `PROTOBASE_MOBILE_SIGNING_KEY` none for a bundle that names no build time (one built before Protobase recorded it: build it again). Where `protobase serve` serves its own shell, the release's fingerprint names the `native` of that shell's `protobase.shell.json`, and there is none when it names none.
479
479
 
480
- - `GET /api/mobile/release?fingerprint=<native fingerprint>&shell_version=<x.y.z>` answers `{ "bundleId", "url", "required" }`: the release's id, a hash of its files, and its absolute base URL, both `null` when the release does not run on the asking binary, whose native fingerprint must equal the release's. `required` is true when the shell the app runs no longer works with the server's API: below 1.0 another minor, from 1.0 another major. A missing fingerprint or a shell version that is no x.y.z version gets 400.
480
+ - `GET /api/mobile/release?fingerprint=<native fingerprint>&shell_version=<x.y.z>` answers `{ "bundleId", "url", "required" }`: the release's id, a hash of its files, and its absolute base URL, both `null` when the release does not run on the asking binary, whose native fingerprint must equal the release's, or when the update is required, since the binary refuses a release of another shell version. `required` is true when the shell the app runs no longer works with the server's API: below 1.0 another minor, from 1.0 another major. A missing fingerprint or a shell version that is no x.y.z version gets 400.
481
481
  - `GET /api/mobile/releases/<bundleId>?href=<file>` serves the release's file `<file>`, such as `assets/index-abc123.js`, and with `href=capawesome-live-update-manifest.json` its manifest, a JSON array of `{ "href", "checksum", "sizeInBytes" }`. Each comes with its sha256 in hex in `X-Checksum` and, with `PROTOBASE_MOBILE_SIGNING_KEY`, its signature in `X-Signature`. Any other file, or another release's id, gets 404.
482
482
  - Signed, a release also serves `href=protobase-release.json`, its statement: `{ "payload", "signature" }`, the payload the hex of the JSON `{ "manifest", "order", "appId", "fingerprint", "shellVersion" }` and the signature the hex of its SHA256withRSA over the line `protobase-mobile-release` and the payload. It binds the manifest's sha256 to the release's order, when the bundle was built and then when the server's own shell it serves was built (0 with the bundle's copy), to the app id and native fingerprint of the binaries it runs on, and to the server's Protobase version. Its id is then a hash of the statement and the public key, so the same files built again get another id. A file of the app may not be named like the statement or start with that line.
483
483
  - The app, on Android and iOS alike, downloads a release itself and takes it only when its statement is signed with the key the binary pins, names the release's id, this app, this binary and a server its shell works with, and its order is not below the highest it downloaded; then every file must hash to what the manifest lists, under a path inside the release, before any file is written. It follows no redirect and reads no file past the size its manifest lists. It runs a downloaded release only above the running one's order and holding nothing but the files its manifest lists. It never takes a release at or below the order of its own files, which `protobase mobile` records in the binary as the server would order the same bundle with its copy of the shell, so a reinstalled app is not taken below them, and a release built before the binary is not taken. <gap>A phone cannot take a rollback of the bundle or of the server's shell before a later build, because ordering releases by an explicit release number is not implemented.</gap> <gap>An app with no download recorded, such as after a reinstall, cannot refuse a genuine signed release older than the latest but newer than its own files, because a signed answer naming the latest release is not implemented.</gap>
484
484
 
485
485
  #### The live updater
486
486
 
487
- An Android or iOS app built with `mobile.publicKey` updates itself from the server it calls. The shell asks `GET /api/mobile/release` when the app starts and each time it comes back to the foreground, in the background, and downloads a release it does not run, only the files that changed, then runs it at the next cold start. The session stays in the device's cookie store, so the user stays signed in across the switch.
487
+ An Android or iOS app built with `mobile.publicKey` updates itself from the server it calls, and never shows that it does. Launch waits on nothing: the app starts on the release it set next earlier, or its own files. The shell asks `GET /api/mobile/release` in the background each time the app comes back to the foreground and, while someone is signed in, once the app has drawn, every 15 minutes while it is in view and when the server's Protobase version changes under an open page. It downloads a release it does not run, only the files that changed, and runs it at the next cold start. The session stays in the device's cookie store, so the user stays signed in across the switch.
488
488
 
489
- - Coming back to the foreground after 5 minutes or more away, the app reloads into a release it downloaded, then returns to the page and scroll position it showed. It does not while a guard holds unsaved changes on the page, or when it was away for less. The app shows no prompt that it was updated: a reload would only start the files it runs again, so it checks for the server's release instead.
489
+ - The splash screen stays up from launch until the shell has drawn, and covers each reload into a release until the release has drawn.
490
+ - Right after someone signs in on the app, before it opens, the app takes the server's release and reloads into it, on the same page. Past 20 seconds it opens on the files it runs, and the download goes on for a later start or return.
491
+ - Coming back to the foreground after 5 minutes or more away, the app reloads into a release it downloaded, then returns to the page and scroll position it showed. It does not while a guard holds unsaved changes on the page, or when it was away for less. The app shows no prompt that it was updated: a reload would only start the files it runs again, so it checks for the server's release instead. A push tapped while the app reloads opens its page once the release has drawn.
490
492
 
491
493
  - Once the shell has drawn, it tells the updater the release started. A release that does not within 30 seconds goes back to the app's own files at once and is never taken again.
492
494
  - No answer, any status but 200, a body that is not the answer, or an answer naming no release changes nothing: the app keeps the files it runs, and never goes back to its own files because of the answer, which is not signed.
493
- - At launch, a required update holds the app with a notice while the release downloads, then reloads into it; a refused release, a failed download or a minute without one lets the app go on with the files it runs. <gap>A required update across a Protobase minor below 1.0, or a major, cannot reach a phone by live update because taking a release of another shell version than the binary's is not implemented, so such a fix, a security fix included, reaches it only through a store release.</gap>
495
+ - A required update offers no release, so the app goes on with the files it runs. <gap>A required update across a Protobase minor below 1.0, or a major, cannot reach a phone by live update because taking a release of another shell version than the binary's is not implemented, so such a fix, a security fix included, reaches it only through a store release.</gap>
494
496
  - The binary pins the public key: a new key needs a new store release, and a server whose `PROTOBASE_MOBILE_SIGNING_KEY` is not its private half serves releases the app refuses.
495
497
 
496
498
  A host that serves bundles without running their config, such as a router in front of many apps or a static host, serves the same release from the files it already serves with `@protobase/server/mobile-release`, which loads none of the rest of the server: `protobase serve` composes its own release with the same exports.
@@ -35,11 +35,21 @@ The colours and each PNG are there only when the project has them.
35
35
 
36
36
  ## Without a network
37
37
 
38
- 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.
38
+ The data stays online: the installed app reads and writes through the API as the browser tab does, and nothing can be changed offline. Someone signed in sees the pages they opened last, from the [start cache](#starting-from-the-last-pages-seen), with a warning beside the title that they could not be refreshed. 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.
39
39
 
40
40
  - A page always comes from the server while it answers, and from the cache only when the network fails.
41
41
  - 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.
42
42
  - The theme and the favicon come from the server, with the cached copy used when the network fails.
43
- - Nothing else is cached: the API, the plugins and other sites go to the network as without the worker.
43
+ - Nothing else is cached by the worker: the API, the plugins and other sites go to the network as without the worker.
44
44
 
45
45
  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.
46
+
47
+ ## Starting from the last pages seen
48
+
49
+ The app keeps what someone signed in last saw, from the moment they sign in, and opens on it the next time, in the browser tab, the installed app and the iOS and Android app alike. The first screen draws from this start cache as soon as the app's plugins have loaded, which the browser usually has cached, and everything on it is fetched again behind it:
50
+
51
+ - While the page shows cached data, its content is muted and pulses as a skeleton does, so it never passes for up to date, and a small spinner sits beside the page's title.
52
+ - When the fresh data lands it replaces the cached data in place, and nothing moves.
53
+ - When the refresh fails, such as without a network, the cached data stays muted and a warning replaces the spinner.
54
+
55
+ The start cache holds who is signed in, the app's `/meta` and the latest answer of each query the app read. It has no time limit, only a soft limit of 4 MB: once the answers pass it, those used least recently are dropped, oldest first, until they are back under it. Who is signed in and `/meta` are never dropped. It lives in the browser's IndexedDB for the app's origin, or in the app's own storage on a phone. It is emptied when someone signs out, when the session ends and the API answers 401, and when a new Protobase version of the app opens. Visitors and staff signed in as someone keep nothing.