@protobase/cli 0.113.0 → 0.114.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.113.0";
2
+ var version = "0.114.0";
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.113.0",
3
+ "version": "0.114.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.113.0",
47
- "@protobase/layout": "0.113.0",
48
- "@protobase/query": "0.113.0",
49
- "@protobase/schema": "0.113.0",
50
- "@protobase/server": "0.113.0",
51
- "@protobase/ui": "0.113.0",
52
- "@protobase/workflows": "0.113.0",
46
+ "@protobase/config": "0.114.0",
47
+ "@protobase/layout": "0.114.0",
48
+ "@protobase/query": "0.114.0",
49
+ "@protobase/schema": "0.114.0",
50
+ "@protobase/server": "0.114.0",
51
+ "@protobase/ui": "0.114.0",
52
+ "@protobase/workflows": "0.114.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",
@@ -46,14 +46,14 @@ Each build of the app has its own worker, which replaces the previous one and dr
46
46
 
47
47
  ## Starting from the last pages seen
48
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:
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. Before it draws, the app reads this start cache and loads the plugins its `/meta` names, which the browser usually has cached, at most 10 seconds; then its first frame is the whole page, drawn from the cache: a list with its rows, a record with its fields, a page with its blocks, with no skeleton or spinner in place of anything the cache holds. Everything on it is fetched again behind it:
50
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.
51
+ - While the cached data is fetched again, a small spinner sits beside the page's title. The page itself stays as it was drawn.
52
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.
53
+ - When the refresh fails, such as without a network, the cached data stays, muted, and a warning replaces the spinner.
54
54
 
55
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, `/meta` and the answers of the page on screen when it saves are never dropped, so the next start draws that page whole: the cache can pass 4 MB by that one page. A table embedded in a page reads only the fields it shows, which keeps the page small, unless its actions run on selected rows: those get whole records. 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.
56
56
 
57
- ### A host's snapshot of the page
57
+ ### When the UI is ready
58
58
 
59
- A host that serves the app's `index.html` itself, such as Protobase's official app on a switch back to an app, can show the page someone saw last before the app has drawn anything. The page's start screen, which covers the app from the first paint until it has drawn its first page, carries one empty placeholder, `<div id="pb-snapshot"></div>` (`snapshotPlaceholder`). The host replaces exactly that text with the markup it kept of the page, a plain string replace. The snapshot then shows in place of the spinner, inert, and the start screen also waits until the first page has its first data, at most 4 seconds, so the screen changes once, from the snapshot to the page as it stays. With the placeholder empty, the start is as before. The host decides when a snapshot no longer fits, such as after a sign-out, for another user or another Protobase version, and then leaves the placeholder empty.
59
+ Once the app has drawn its first page, as it takes its start screen away, and the browser has painted that frame, it dispatches a `protobase:ui-ready` event on `window` (`uiReadyEvent` of `@protobase/ui`). With a warm start cache that is the app's first commit. A host that loads the app out of sight shows it then, so the page appears whole instead of blank: Protobase's official app loads a workspace behind the one on screen and swaps them on this event.
@@ -289,6 +289,14 @@ The plugins are merged in the order listed. Two of them cannot define one name:
289
289
 
290
290
  The components a [remote resource](remote-resources.md#custom-components)'s view names are drawn from the same plugins, by name, so whoever runs a source lists the plugin that provides them with it. Inside one, `useList` and `useRecord` read the source for its resources, and `useResourceClient(resource)` gives the client of the API that serves a resource.
291
291
 
292
+ ## Reloaded while the app runs
293
+
294
+ A plugin can be replaced while the app runs, and must expect to be. When a host dispatches a `protobase:plugins-changed` event on `window` (`pluginsChangedEvent` of `@protobase/ui`), the app loads its plugins again, each from its `plugin.json`. Meanwhile it keeps showing what it shows, then swaps the new code in with one render. Protobase's official app does this when it finds a workspace's plugin changed on the server. What that means for a plugin:
295
+
296
+ - Its components mount afresh from the new module, so their local state starts over. Keep what must survive in the app's data or in the URL.
297
+ - Its module is evaluated again, once per load. The old module stays in memory, as a browser cannot unload one, so code that runs when the module is evaluated must not start timers, add listeners or change globals that the old copy would keep acting on. Start them in a component's effect, which stops them as it unmounts.
298
+ - Its stylesheet, a new file name with each build, is added beside the old one, so rules must not rely on being the only copy.
299
+
292
300
  ## Before sign-in
293
301
 
294
302
  Plugins load once someone has signed in, or for a visitor of a project whose anonymous role reads a resource, so no plugin code runs for someone signed out: they get the sign-in page. A plugin listed with `beforeSignIn: true`, or in `PROTOBASE_PLUGINS_BEFORE_SIGN_IN`, loads before that. The sign-in status (`GET /api/auth/status`) names it to everyone, as `plugins`, and the app loads it first and waits for it, as it waits for the others. Its `beforeSignIn` component is drawn around what someone signed out sees: the sign-in page, or the app a visitor browses. Once they are in, it is no longer drawn, and the plugin stays loaded: `/api/meta` names it to everyone, and the app merges its other parts as any plugin's, without loading it again.
@@ -12,6 +12,8 @@ Below the `md` breakpoint (768px) the sidebar is a drawer, which the top bar's m
12
12
 
13
13
  The sidebar's top shows the app's logo, Protobase's or a plugin's [`shell.logo`](custom-components.md#shell-slots). It has no action of its own. A tap on it dispatches a cancelable `protobase:logo-tap` event on `window` (`logoTapEvent` of `@protobase/ui`), so a plugin, or a host app that embeds the shell, can take the tap: it calls `preventDefault()` and does its own thing, such as opening a switcher. When the page is shown in a frame, the shell also posts `{ type: 'protobase:logo-tap' }` to the page that frames it.
14
14
 
15
+ On a phone the sidebar is a drawer over the page. A host or a plugin closes it by dispatching a `protobase:close-sidebar` event on `window` (`closeSidebarEvent` of `@protobase/ui`), such as an app that opens its own switcher on a tap on the logo: `window.dispatchEvent(new Event('protobase:close-sidebar'))`. Where the sidebar sits beside the page, the event does nothing. A tap on the logo alone never closes it.
16
+
15
17
  ```ts
16
18
  window.addEventListener('protobase:logo-tap', (event) => {
17
19
  event.preventDefault()