@protobase/cli 0.113.1 → 0.115.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.
- package/dist/build/shell-chunks.js +27 -17
- package/dist/build/shell.js +1 -1
- package/dist/cli/package.js +1 -1
- package/dist/project/shared-modules.js +1 -1
- package/package.json +8 -8
- package/skills/protobase/references/reference/installable-app.md +5 -5
- package/skills/protobase/references/reference/plugins.md +9 -0
- package/skills/protobase/references/reference/sidebar.md +2 -0
|
@@ -15,10 +15,11 @@ const reactPackages = /* @__PURE__ */ new Set([
|
|
|
15
15
|
/** Whether a module goes in the `react` chunk. */
|
|
16
16
|
const isReactModule = (id) => reactPackages.has(npmPackage(id) ?? "");
|
|
17
17
|
/**
|
|
18
|
-
* Whether a module goes in
|
|
19
|
-
* since the app picks up a new one on many releases, which would change
|
|
18
|
+
* Whether a module goes in `vendor` or its package's `lib-` chunk: a third-party one but React's and the icons'. The
|
|
19
|
+
* icons stay with the code that draws them, since the app picks up a new one on many releases, which would change the
|
|
20
|
+
* chunk they are in and every chunk that imports it.
|
|
20
21
|
*/
|
|
21
|
-
const
|
|
22
|
+
const isLibModule = (id) => {
|
|
22
23
|
const name = npmPackage(id);
|
|
23
24
|
return name !== void 0 && !reactPackages.has(name) && name !== "lucide-react";
|
|
24
25
|
};
|
|
@@ -27,34 +28,43 @@ const workflowsDir = path.resolve(path.dirname(createRequire(uiEntry).resolve("@
|
|
|
27
28
|
const slashed = (file) => file.replaceAll("\\", "/");
|
|
28
29
|
/** Whether a module is one of the workflow engine's, which go in the `workflows` chunk: inside its folder, not beside it. */
|
|
29
30
|
const isWorkflowsModule = (id, dir = workflowsDir) => slashed(id).startsWith(`${slashed(dir).replace(/\/$/, "")}/`);
|
|
30
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Whether a module is the app's own code: no third-party one, no virtual module, page, stylesheet or workflow engine's.
|
|
33
|
+
* index.html's own script stays in its entry chunk, which then only imports `app`.
|
|
34
|
+
*/
|
|
35
|
+
const isAppModule = (id) => npmPackage(id) === void 0 && !id.startsWith("\0") && !/\.(css|html)(\?|$)/.test(id) && !isWorkflowsModule(id);
|
|
36
|
+
/** The chunk name of a third-party module: its package's, such as `lib-xyflow-react`. */
|
|
31
37
|
const libChunkName = (id) => `lib-${npmPackage(id).replace("@", "").replace("/", "-")}`;
|
|
32
38
|
/**
|
|
33
|
-
* The shell build's `output.codeSplitting
|
|
34
|
-
* dependency of the libraries it holds, and lazy chunks would import it from there.
|
|
39
|
+
* The shell build's `output.codeSplitting`, by priority. `react` comes first: without it, `vendor` would take React in
|
|
40
|
+
* as a dependency of the libraries it holds, and lazy chunks would import it from there. `$initial` is what an entry
|
|
41
|
+
* imports statically. A `lib-` chunk takes in none of its package's dependencies, which may be another package's too:
|
|
42
|
+
* the charts' would otherwise hold a module the table's library imports, and a list would load the charts.
|
|
35
43
|
*/
|
|
36
44
|
const shellCodeSplitting = { groups: [
|
|
37
45
|
{
|
|
38
46
|
name: "react",
|
|
39
47
|
test: isReactModule,
|
|
40
|
-
priority:
|
|
48
|
+
priority: 3
|
|
41
49
|
},
|
|
42
50
|
{
|
|
43
51
|
name: "vendor",
|
|
44
|
-
test: (id) =>
|
|
52
|
+
test: (id) => isLibModule(id) || id === preloadHelper,
|
|
45
53
|
tags: ["$initial"],
|
|
46
|
-
priority:
|
|
54
|
+
priority: 2
|
|
47
55
|
},
|
|
48
56
|
{
|
|
49
|
-
name:
|
|
50
|
-
|
|
51
|
-
|
|
57
|
+
name: "app",
|
|
58
|
+
test: isAppModule,
|
|
59
|
+
tags: ["$initial"],
|
|
60
|
+
priority: 2
|
|
52
61
|
},
|
|
53
62
|
{
|
|
54
|
-
name:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
priority: 1
|
|
63
|
+
name: libChunkName,
|
|
64
|
+
debugName: "lib",
|
|
65
|
+
test: isLibModule,
|
|
66
|
+
priority: 1,
|
|
67
|
+
includeDependenciesRecursively: false
|
|
58
68
|
},
|
|
59
69
|
{
|
|
60
70
|
name: "workflows",
|
|
@@ -62,4 +72,4 @@ const shellCodeSplitting = { groups: [
|
|
|
62
72
|
}
|
|
63
73
|
] };
|
|
64
74
|
//#endregion
|
|
65
|
-
export {
|
|
75
|
+
export { isAppModule, isLibModule, isReactModule, isWorkflowsModule, libChunkName, npmPackage, shellCodeSplitting };
|
package/dist/build/shell.js
CHANGED
|
@@ -50,7 +50,7 @@ const shellIdentity = async () => {
|
|
|
50
50
|
* 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
|
|
51
51
|
* their own, which index.html's import map names. With `sourceMapsDir`, each script ends with a `//# debugId=` comment
|
|
52
52
|
* and names no map, and its source map, carrying the same debug id, goes to the same place under `sourceMapsDir`. The
|
|
53
|
-
*
|
|
53
|
+
* start loads react, vendor and app chunks and the pages load lazily (./shell-chunks), so an update mostly downloads only the app's code.
|
|
54
54
|
*/
|
|
55
55
|
const buildShell = async (outDir, sourceMapsDir) => {
|
|
56
56
|
const sourceMaps = sourceMapsDir !== void 0;
|
package/dist/cli/package.js
CHANGED
|
@@ -66,7 +66,7 @@ const sharedModulesPlugin = () => {
|
|
|
66
66
|
index: path.join(root, "index.html"),
|
|
67
67
|
...Object.fromEntries(sharedModules.map((name) => [entryName(name), facadeId(name)]))
|
|
68
68
|
},
|
|
69
|
-
preserveEntrySignatures: "
|
|
69
|
+
preserveEntrySignatures: "allow-extension"
|
|
70
70
|
} } };
|
|
71
71
|
},
|
|
72
72
|
configResolved: (config) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.115.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.
|
|
47
|
-
"@protobase/layout": "0.
|
|
48
|
-
"@protobase/query": "0.
|
|
49
|
-
"@protobase/schema": "0.
|
|
50
|
-
"@protobase/server": "0.
|
|
51
|
-
"@protobase/ui": "0.
|
|
52
|
-
"@protobase/workflows": "0.
|
|
46
|
+
"@protobase/config": "0.115.0",
|
|
47
|
+
"@protobase/layout": "0.115.0",
|
|
48
|
+
"@protobase/query": "0.115.0",
|
|
49
|
+
"@protobase/schema": "0.115.0",
|
|
50
|
+
"@protobase/server": "0.115.0",
|
|
51
|
+
"@protobase/ui": "0.115.0",
|
|
52
|
+
"@protobase/workflows": "0.115.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.
|
|
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
|
|
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
|
-
###
|
|
57
|
+
### When the UI is ready
|
|
58
58
|
|
|
59
|
-
|
|
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.
|
|
@@ -387,6 +395,7 @@ From `@protobase/ui`:
|
|
|
387
395
|
| `RouteLink`, `RouteTarget` | An ordinary link to a target's `href`, which a plain click follows in the app, as `useComponentSelect().linkTo(key)` gives it. |
|
|
388
396
|
| `FieldBadge`, `ToneEdge` | A record's value of a field as a badge in its view's words and colour, and a card's left edge in that colour, as the app's related cards draw them. |
|
|
389
397
|
| `AuthLayout`, `CodeForm`, `ResendCodeButton`, `Button`, `buttonClass`, `Input`, `Spinner`, `LogoMark` | The pieces of the app's sign-in pages, for a page of a plugin or a host's own that looks like them. Outside the app, `@protobase/ui/styles.css` is the stylesheet that draws them, for a Vite build with Tailwind. |
|
|
398
|
+
| `showTextsIn(locale)` | Loads the app's built-in texts in a language (`'en'` or `'nl'`), each language its own download, and draws the pieces above in it. A host's own page that draws them outside the app awaits it before it renders them; the app picks its language itself. |
|
|
390
399
|
| `isFramed`, `useArmedAfterFocus`, `useGuardedPress`, `allowDelayMs` | The connect page's guard against clickjacking and click-through, for a host's own consent screen: it refuses to render when `isFramed()`, and its Allow button spreads `useGuardedPress(armed, onAllow)`, so a press counts only once the page has been in front for `allowDelayMs`, and a press anywhere on the page before then starts that wait again. |
|
|
391
400
|
| `pluginApi` | The plugin API of the app's `@protobase/ui`. |
|
|
392
401
|
| `protobaseVersion` | The Protobase version of the app's `@protobase/ui`. |
|
|
@@ -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()
|