@protobase/cli 0.27.0 → 0.28.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/app-icons.js +51 -0
- package/dist/build/deploy-bundle.js +4 -3
- package/dist/bundle/manifest.js +5 -1
- package/dist/cli/package.js +1 -1
- package/dist/dev/entry.js +7 -1
- package/dist/project/favicon-link.js +24 -2
- package/dist/project/project-admin.js +4 -2
- package/dist/serve/bundle-ui.js +2 -1
- package/package.json +6 -6
- package/skills/protobase/SKILL.md +1 -0
- package/skills/protobase/references/guides/deploy.md +2 -1
- package/skills/protobase/references/guides/plugin-build.md +2 -1
- package/skills/protobase/references/reference/app-identity.md +54 -0
- package/skills/protobase/references/reference/auth.md +2 -2
- package/skills/protobase/references/reference/cli.md +3 -2
- package/skills/protobase/references/reference/custom-components.md +1 -1
- package/skills/protobase/references/reference/email.md +1 -1
- package/skills/protobase/references/reference/installable-app.md +11 -2
- package/skills/protobase/references/reference/theme.md +2 -2
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { buildFavicon, faviconFile } from "./favicon.js";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { copyFile, readFile } from "node:fs/promises";
|
|
5
|
+
import { pngIcons } from "@protobase/server";
|
|
6
|
+
//#region src/build/app-icons.ts
|
|
7
|
+
const pngSignature = Buffer.from([
|
|
8
|
+
137,
|
|
9
|
+
80,
|
|
10
|
+
78,
|
|
11
|
+
71,
|
|
12
|
+
13,
|
|
13
|
+
10,
|
|
14
|
+
26,
|
|
15
|
+
10
|
|
16
|
+
]);
|
|
17
|
+
/** The width and height of a PNG, from its signature and IHDR chunk; `undefined` for a file that is no PNG. */
|
|
18
|
+
const pngSize = (head) => {
|
|
19
|
+
if (head.length < 24 || !head.subarray(0, 8).equals(pngSignature) || head.toString("latin1", 12, 16) !== "IHDR") return void 0;
|
|
20
|
+
return {
|
|
21
|
+
width: head.readUInt32BE(16),
|
|
22
|
+
height: head.readUInt32BE(20)
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
const checkPng = async (projectDir, icon) => {
|
|
26
|
+
const { file, size } = pngIcons[icon];
|
|
27
|
+
const found = pngSize(await readFile(path.join(projectDir, file)));
|
|
28
|
+
if (!found) throw new Error(`${file} is no PNG`);
|
|
29
|
+
if (found.width !== size || found.height !== size) throw new Error(`${file} is ${found.width}x${found.height} pixels; it must be ${size}x${size}`);
|
|
30
|
+
};
|
|
31
|
+
/** The icons the project in `projectDir` has of its own: its protobase.favicon.svg and the PNGs beside it (see `pngIcons`). */
|
|
32
|
+
const projectIcons = (projectDir) => ({
|
|
33
|
+
favicon: existsSync(path.join(projectDir, faviconFile)),
|
|
34
|
+
png: Object.keys(pngIcons).filter((icon) => existsSync(path.join(projectDir, pngIcons[icon].file)))
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* Writes the app's icons into `publicDir`: the favicon, the project's or Protobase's (see `buildFavicon`), and the PNGs
|
|
38
|
+
* the project has, each checked to be its size. Says which are the project's own, which the server's manifest names.
|
|
39
|
+
*/
|
|
40
|
+
const buildIcons = async ({ projectDir, publicDir }) => {
|
|
41
|
+
const icons = projectIcons(projectDir);
|
|
42
|
+
for (const icon of icons.png) await checkPng(projectDir, icon);
|
|
43
|
+
await buildFavicon({
|
|
44
|
+
projectDir,
|
|
45
|
+
outFile: path.join(publicDir, faviconFile)
|
|
46
|
+
});
|
|
47
|
+
await Promise.all(icons.png.map((icon) => copyFile(path.join(projectDir, pngIcons[icon].file), path.join(publicDir, pngIcons[icon].file))));
|
|
48
|
+
return icons;
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
51
|
+
export { buildIcons, pngSize, projectIcons };
|
|
@@ -3,9 +3,9 @@ import { buildBundlePlugins } from "./bundle-plugins.js";
|
|
|
3
3
|
import { buildConfigBundle } from "./config-bundle.js";
|
|
4
4
|
import { protobaseVersion } from "../version/version.js";
|
|
5
5
|
import { copyPackages } from "./packages/copy-packages.js";
|
|
6
|
-
import { buildFavicon, faviconFile } from "./favicon.js";
|
|
7
6
|
import { buildTheme } from "./theme.js";
|
|
8
7
|
import { shellForBuild, shellManifestFile } from "./shell.js";
|
|
8
|
+
import { buildIcons } from "./app-icons.js";
|
|
9
9
|
import { checkUi } from "./ui-check.js";
|
|
10
10
|
import { checkViews } from "./view-check.js";
|
|
11
11
|
import { protobaseFolder } from "../project/protobase-folder.js";
|
|
@@ -67,9 +67,9 @@ const buildDeployBundle = async ({ projectDir, outDir, bun, extensions = [], onW
|
|
|
67
67
|
projectDir,
|
|
68
68
|
outFile: path.join(publicDir, bundleLayout.theme)
|
|
69
69
|
})) onWarning?.(warning);
|
|
70
|
-
await
|
|
70
|
+
const icons = await buildIcons({
|
|
71
71
|
projectDir,
|
|
72
|
-
|
|
72
|
+
publicDir
|
|
73
73
|
});
|
|
74
74
|
const manifest = {
|
|
75
75
|
version: 3,
|
|
@@ -78,6 +78,7 @@ const buildDeployBundle = async ({ projectDir, outDir, bun, extensions = [], onW
|
|
|
78
78
|
api: [...bundleLayout.api],
|
|
79
79
|
plugins,
|
|
80
80
|
shell,
|
|
81
|
+
icons,
|
|
81
82
|
...packages.length > 0 ? { nodeModules: bundleNodeModules } : {}
|
|
82
83
|
};
|
|
83
84
|
await writeFile(path.join(outDir, manifestFile), `${JSON.stringify(manifest, null, 2)}\n`);
|
package/dist/bundle/manifest.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { pngIcons } from "@protobase/server";
|
|
3
4
|
//#region src/bundle/manifest.ts
|
|
4
5
|
const manifestFile = "protobase.bundle.json";
|
|
5
6
|
const isApiPath = (api, pathname) => api.some((prefix) => pathname === prefix || pathname.startsWith(`${prefix}/`));
|
|
@@ -17,13 +18,15 @@ const isObject = (value) => typeof value === "object" && value !== null && !Arra
|
|
|
17
18
|
const isFieldTypes = (value) => isObject(value) && Object.values(value).every(isStringList);
|
|
18
19
|
const isPlugin = (value) => isObject(value) && typeof value.name === "string" && typeof value.path === "string" && Number.isInteger(value.api) && typeof value.protobase === "string" && (value.fields === void 0 || isFieldTypes(value.fields));
|
|
19
20
|
const isShell = (value) => isObject(value) && typeof value.protobase === "string" && Number.isInteger(value.pluginApi) && isStringList(value.paths);
|
|
21
|
+
const isIcons = (value) => isObject(value) && typeof value.favicon === "boolean" && isStringList(value.png) && value.png.every((icon) => icon in pngIcons);
|
|
20
22
|
const parseManifest = (value, file) => {
|
|
21
23
|
const manifest = value;
|
|
22
24
|
if (manifest?.version !== 3) throw new Error(`${file} is not a version 3 bundle manifest; rebuild it with \`protobase build\``);
|
|
23
|
-
const { server, public: publicDir, api, spa, plugins, theme, shell, nodeModules } = manifest;
|
|
25
|
+
const { server, public: publicDir, api, spa, plugins, theme, shell, icons, nodeModules } = manifest;
|
|
24
26
|
if (typeof server !== "string" || typeof publicDir !== "string" || typeof spa !== "string" || typeof theme !== "string" || !isStringList(api)) throw new Error(`${file} needs server, public, spa and theme paths and an api list`);
|
|
25
27
|
if (!Array.isArray(plugins) || !plugins.every(isPlugin)) throw new Error(`${file} needs a plugins list, each with a name, path, api and protobase`);
|
|
26
28
|
if (!isShell(shell)) throw new Error(`${file} needs a shell with its protobase version, pluginApi and paths`);
|
|
29
|
+
if (icons !== void 0 && !isIcons(icons)) throw new Error(`${file} has icons that are not a favicon flag and a list of PNG icons`);
|
|
27
30
|
if (nodeModules !== void 0 && typeof nodeModules !== "string") throw new Error(`${file} has a nodeModules that is no path`);
|
|
28
31
|
return {
|
|
29
32
|
version: 3,
|
|
@@ -34,6 +37,7 @@ const parseManifest = (value, file) => {
|
|
|
34
37
|
plugins,
|
|
35
38
|
theme,
|
|
36
39
|
shell,
|
|
40
|
+
...icons && { icons },
|
|
37
41
|
...nodeModules === void 0 ? {} : { nodeModules }
|
|
38
42
|
};
|
|
39
43
|
};
|
package/dist/cli/package.js
CHANGED
package/dist/dev/entry.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { projectIcons } from "../build/app-icons.js";
|
|
1
2
|
import { devJobs } from "./dev-jobs.js";
|
|
2
3
|
import { projectErrorReporter } from "../project/error-reporter.js";
|
|
3
4
|
import { projectAdmin } from "../project/project-admin.js";
|
|
@@ -27,10 +28,15 @@ checkAi({
|
|
|
27
28
|
});
|
|
28
29
|
if (project.webhooks) await checkWebhooksSchema(db, project.webhooks);
|
|
29
30
|
const reporter = await projectErrorReporter(project, process.env);
|
|
31
|
+
const ui = {
|
|
32
|
+
plugins: [],
|
|
33
|
+
fieldTypes: {},
|
|
34
|
+
icons: projectIcons(projectDir)
|
|
35
|
+
};
|
|
30
36
|
const { admin, jobs } = projectAdmin({
|
|
31
37
|
...project,
|
|
32
38
|
authenticate: project.authenticate
|
|
33
|
-
}, project.exports, db,
|
|
39
|
+
}, project.exports, db, ui, reporter, upgradeWebSocket);
|
|
34
40
|
await devJobs(db, jobs);
|
|
35
41
|
var entry_default = new Hono().route("/", admin);
|
|
36
42
|
if (project.auth && !store.__protobaseNoUsersShown) {
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { faviconFile, projectFavicon } from "../build/favicon.js";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
2
4
|
import { readFile } from "node:fs/promises";
|
|
5
|
+
import { pngIcons } from "@protobase/server";
|
|
3
6
|
//#region src/project/favicon-link.ts
|
|
4
7
|
/**
|
|
5
|
-
* Links the project's favicon at `/protobase.favicon.svg` in the app's page
|
|
6
|
-
*
|
|
8
|
+
* Links the project's favicon at `/protobase.favicon.svg` in the app's page, and its Apple touch icon at
|
|
9
|
+
* `/protobase.apple-touch-icon.png`, which Safari takes for the home screen as it takes no SVG. A bundle always has
|
|
10
|
+
* the favicon (see `buildFavicon`) and the touch icon when the project has one (see `buildIcons`); without it Safari
|
|
11
|
+
* shows a picture of the page instead. The dev server answers them from the project's files, the favicon Protobase's
|
|
12
|
+
* without one, and the project's other PNG icons the same way.
|
|
7
13
|
*/
|
|
8
14
|
const faviconLink = (projectDir) => {
|
|
9
15
|
let base = "/";
|
|
@@ -20,6 +26,15 @@ const faviconLink = (projectDir) => {
|
|
|
20
26
|
response.end(body);
|
|
21
27
|
}, next);
|
|
22
28
|
});
|
|
29
|
+
for (const { file } of Object.values(pngIcons)) server.middlewares.use(`/${file}`, (_request, response, next) => {
|
|
30
|
+
const own = projectDir === void 0 ? void 0 : path.join(projectDir, file);
|
|
31
|
+
if (!own || !existsSync(own)) return next();
|
|
32
|
+
readFile(own).then((body) => {
|
|
33
|
+
response.setHeader("content-type", "image/png");
|
|
34
|
+
response.setHeader("cache-control", "no-cache");
|
|
35
|
+
response.end(body);
|
|
36
|
+
}, next);
|
|
37
|
+
});
|
|
23
38
|
},
|
|
24
39
|
transformIndexHtml: {
|
|
25
40
|
order: "post",
|
|
@@ -31,6 +46,13 @@ const faviconLink = (projectDir) => {
|
|
|
31
46
|
href: `${base}${faviconFile}`
|
|
32
47
|
},
|
|
33
48
|
injectTo: "head"
|
|
49
|
+
}, {
|
|
50
|
+
tag: "link",
|
|
51
|
+
attrs: {
|
|
52
|
+
rel: "apple-touch-icon",
|
|
53
|
+
href: `${base}${pngIcons.appleTouch.file}`
|
|
54
|
+
},
|
|
55
|
+
injectTo: "head"
|
|
34
56
|
}]
|
|
35
57
|
}
|
|
36
58
|
};
|
|
@@ -2,8 +2,8 @@ import { configExports, createAdmin, jobDefinitions } from "@protobase/server";
|
|
|
2
2
|
//#region src/project/project-admin.ts
|
|
3
3
|
/**
|
|
4
4
|
* The admin API of a project over `db`, as `dev`, `serve` and `worker` build it: its config module's resources, views,
|
|
5
|
-
* pages and subscriptions, and the rest of its config; served from a bundle, the plugins it carries
|
|
6
|
-
* types. `jobs` are the project's own and the delivery of its events and history. With a `reporter`, every error the API turns
|
|
5
|
+
* pages and subscriptions, and the rest of its config; served from a bundle, the plugins it carries, their field
|
|
6
|
+
* types and which icons are the project's own (`protobase dev` passes the project's icons alone). `jobs` are the project's own and the delivery of its events and history. With a `reporter`, every error the API turns
|
|
7
7
|
* into a 500 goes to the error tracker too, besides the project's `onUnhandledError` or the console. With the host's
|
|
8
8
|
* `upgradeWebSocket`, it serves `/realtime/v1` too.
|
|
9
9
|
*/
|
|
@@ -26,6 +26,8 @@ const projectAdmin = (project, config, db, ui, reporter, upgradeWebSocket) => {
|
|
|
26
26
|
...project.history && { history: project.history },
|
|
27
27
|
...project.webhooks && { webhooks: project.webhooks },
|
|
28
28
|
...project.mobile && { mobile: project.mobile },
|
|
29
|
+
...project.app && { app: project.app },
|
|
30
|
+
...ui?.icons && { icons: ui.icons },
|
|
29
31
|
jobs: own,
|
|
30
32
|
subscriptions,
|
|
31
33
|
...ui && {
|
package/dist/serve/bundle-ui.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
//#region src/serve/bundle-ui.ts
|
|
2
2
|
const bundleUi = (manifest) => ({
|
|
3
3
|
plugins: manifest.plugins.map((plugin) => `/${plugin.path}`),
|
|
4
|
-
fieldTypes: Object.fromEntries(manifest.plugins.flatMap((plugin) => Object.entries(plugin.fields ?? {})))
|
|
4
|
+
fieldTypes: Object.fromEntries(manifest.plugins.flatMap((plugin) => Object.entries(plugin.fields ?? {}))),
|
|
5
|
+
...manifest.icons && { icons: manifest.icons }
|
|
5
6
|
});
|
|
6
7
|
//#endregion
|
|
7
8
|
export { bundleUi };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.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": {
|
|
@@ -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.
|
|
39
|
-
"@protobase/query": "0.
|
|
40
|
-
"@protobase/schema": "0.
|
|
41
|
-
"@protobase/server": "0.
|
|
42
|
-
"@protobase/ui": "0.
|
|
38
|
+
"@protobase/layout": "0.28.0",
|
|
39
|
+
"@protobase/query": "0.28.0",
|
|
40
|
+
"@protobase/schema": "0.28.0",
|
|
41
|
+
"@protobase/server": "0.28.0",
|
|
42
|
+
"@protobase/ui": "0.28.0",
|
|
43
43
|
"@react-email/render": "^2.1.0",
|
|
44
44
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
45
45
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -82,6 +82,7 @@ Reference:
|
|
|
82
82
|
- When building or loading plugins → read [Plugins](references/reference/plugins.md)
|
|
83
83
|
- When using resources another Protobase API serves → read [Remote resources](references/reference/remote-resources.md)
|
|
84
84
|
- When setting the app's tokens, colors and fonts → read [Theme](references/reference/theme.md)
|
|
85
|
+
- When setting the app's name, icon, home-screen icons or install colours → read [App identity](references/reference/app-identity.md)
|
|
85
86
|
- When showing the app's screens in Dutch → read [Languages](references/reference/languages.md)
|
|
86
87
|
- When installing the app on a phone or computer, or asking what it does offline → read [Installable app](references/reference/installable-app.md)
|
|
87
88
|
- When grouping sidebar entries or listing recent records → read [Sidebar](references/reference/sidebar.md)
|
|
@@ -21,7 +21,8 @@ dist/
|
|
|
21
21
|
protobase.config.js the config module, run by the serve runtime
|
|
22
22
|
node_modules/ only with native add-ons: those packages, with linux x64 and arm64 binaries
|
|
23
23
|
public/ the admin app (index.html and content-hashed assets/), the project's UI as plugins in
|
|
24
|
-
plugins/, its theme, protobase.theme.css, and its
|
|
24
|
+
plugins/, its theme, protobase.theme.css, and its icons, protobase.favicon.svg
|
|
25
|
+
and the PNGs the project has
|
|
25
26
|
protobase.bundle.json the manifest: which paths go to the server, which Protobase version built it, the
|
|
26
27
|
plugins and the app's version
|
|
27
28
|
```
|
|
@@ -29,6 +29,7 @@ dist/
|
|
|
29
29
|
plugins/app/ protobase.ui.tsx, as the plugin app
|
|
30
30
|
protobase.theme.css empty until the project has a theme
|
|
31
31
|
protobase.favicon.svg Protobase's until the project has its own
|
|
32
|
+
protobase.*.png the project's PNG icons, when it has them
|
|
32
33
|
protobase.bundle.json version 3, naming the plugins and the app's version
|
|
33
34
|
```
|
|
34
35
|
|
|
@@ -52,7 +53,7 @@ Each `--extend` folder's `protobase.ui.tsx` becomes a plugin of its own, `plugin
|
|
|
52
53
|
|
|
53
54
|
A host that serves `public/` as before keeps working: `index.html` for navigations, files for the rest. Two things are new:
|
|
54
55
|
|
|
55
|
-
- The plugins' `assets/` folders, `public/plugins/<name>/assets/`, are named by their content like `public/assets/`: serve them as immutable too. `plugin.json`, `protobase.theme.css
|
|
56
|
+
- The plugins' `assets/` folders, `public/plugins/<name>/assets/`, are named by their content like `public/assets/`: serve them as immutable too. `plugin.json`, `protobase.theme.css`, `protobase.favicon.svg` and the PNG icons are served with `no-cache`.
|
|
56
57
|
- A host that keeps the prebuilt app of newer releases may serve it for the manifest's `shell.paths`, so the app gets that release's fixes without a rebuild (see [the shell](../reference/plugins.md#the-shell))). `protobase serve` does so with its own when every plugin of the bundle loads in it.
|
|
57
58
|
|
|
58
59
|
## 6. protobase dev
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/reference/app-identity.md: run `bun run docs:skill`, do not edit. -->
|
|
2
|
+
|
|
3
|
+
# App identity
|
|
4
|
+
|
|
5
|
+
The app's name, icon and colours, which its sidebar logo, browser tabs, home-screen icon, web manifest and mail all follow.
|
|
6
|
+
|
|
7
|
+
An app looks like its own everywhere from three things in its project: its name, its icon and its colours. The sidebar's logo, the browser tab, the icon on a phone's home screen, the [installed app](installable-app.md)) and the auth mail all follow them, with no component to write.
|
|
8
|
+
|
|
9
|
+
| What | Where | Used by |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| Name | `appName` of `createAuth` ([auth configuration](auth.md#configuration))), overridden at run time by `PROTOBASE_APP_NAME` | the sidebar's logo, the end of every tab title, the installed app's name, passkey and authenticator prompts, auth mail and its sender's name |
|
|
12
|
+
| Icon | `protobase.favicon.svg` at the project's root | the browser tab, the sidebar's logo, the installed app's icon |
|
|
13
|
+
| Raster icons | optional PNGs beside the SVG, below | the iPhone home screen and Android launchers, which take no SVG |
|
|
14
|
+
| Colours | `app` in `protobase.config.ts` | the installed app's title bar and its start screen |
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
// protobase.config.ts
|
|
18
|
+
export default defineConfig({
|
|
19
|
+
config,
|
|
20
|
+
auth,
|
|
21
|
+
authenticate,
|
|
22
|
+
app: { themeColor: '#0d9488', backgroundColor: '#ffffff' },
|
|
23
|
+
})
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`createAuth` takes the name because the sign-in it builds needs it, so keep the name in a constant both `auth/auth.ts` and anything else that shows it import, if you want it written once.
|
|
27
|
+
|
|
28
|
+
## The name
|
|
29
|
+
|
|
30
|
+
`appName` names the app; `PROTOBASE_APP_NAME`, when a deployment sets it, overrides it, so a deployment can rename an app without a new build. Without either the app is called `Protobase`.
|
|
31
|
+
|
|
32
|
+
## The icons
|
|
33
|
+
|
|
34
|
+
`protobase.favicon.svg` is the one source of the app's icon: the tab shows it, the [web manifest](installable-app.md#the-manifest)) names it, and with it the sidebar's logo draws it beside the app's name in place of Protobase's mark and wordmark. A project's own [`shell.logo`](custom-components.md#shell-slots)) still wins.
|
|
35
|
+
|
|
36
|
+
Some platforms take no SVG, so a project may put PNGs of the same icon beside it, each square at its size:
|
|
37
|
+
|
|
38
|
+
| File | Size | Used by |
|
|
39
|
+
| --- | --- | --- |
|
|
40
|
+
| `protobase.apple-touch-icon.png` | 180 × 180 | the iPhone and iPad home screen, linked by the app's page |
|
|
41
|
+
| `protobase.icon-192.png` | 192 × 192 | the web manifest, for Android launchers |
|
|
42
|
+
| `protobase.icon-512.png` | 512 × 512 | the web manifest, for Android's install screens |
|
|
43
|
+
| `protobase.icon-maskable.png` | 512 × 512 | the web manifest's maskable icon, which Android crops to its own shape: keep the mark within the middle 80% |
|
|
44
|
+
|
|
45
|
+
Each is optional, and none is made from the SVG: without the touch icon an iPhone's home screen shows a picture of the page. `protobase build` copies the ones the project has to the bundle's `public/`, and fails on a file that is no PNG or not its size; `protobase dev` serves them from the project's root.
|
|
46
|
+
|
|
47
|
+
## The colours
|
|
48
|
+
|
|
49
|
+
`app` takes any CSS colour for each, and the web manifest carries the ones set:
|
|
50
|
+
|
|
51
|
+
- `themeColor`: the installed app's title bar and the browser's toolbar around it (`theme_color`).
|
|
52
|
+
- `backgroundColor`: the screen the installed app shows while it starts (`background_color`).
|
|
53
|
+
|
|
54
|
+
The app's own colours, its buttons and surfaces, are the [theme](theme.md))'s.
|
|
@@ -77,14 +77,14 @@ The columns Better Auth needs that the table lacks, filled from what the other s
|
|
|
77
77
|
| `PROTOBASE_PASSKEY_DOMAIN` | the host new [passkeys](#passkeys) are made for, passed by the platform; default the host of `BETTER_AUTH_URL` |
|
|
78
78
|
| `PROTOBASE_CORS_ORIGINS` | other websites whose browser code may call the API, `*` or comma separated http and https origins, passed by the platform; see [CORS](api.md#cors)) |
|
|
79
79
|
| `PROTOBASE_SMTP_URL`, `PROTOBASE_MAIL_FROM` | the mail server and sender for [password reset](#password-reset), [emailed sign-in codes](#emailed-sign-in-codes), emailed [two-factor](#two-factor-authentication) codes and [open sign-up](#open-sign-up), passed by the platform; all four are off without them |
|
|
80
|
-
| `PROTOBASE_APP_NAME` | the app's name, passed by the platform:
|
|
80
|
+
| `PROTOBASE_APP_NAME` | the app's name, passed by the platform: it overrides `appName` |
|
|
81
81
|
| `PROTOBASE_SIGN_IN_ISSUER`, `PROTOBASE_SIGN_IN_CLIENT_ID`, `PROTOBASE_SIGN_IN_CLIENT_SECRET` | the [platform sign-in provider](#platform-sign-in-provider) for people who have an account, passed by the platform; off without them. `PROTOBASE_SIGN_IN_PROVIDER` and `PROTOBASE_SIGN_IN_NAME` are optional |
|
|
82
82
|
| `PROTOBASE_OPERATOR_ISSUER`, `PROTOBASE_OPERATOR_CLIENT_ID`, `PROTOBASE_OPERATOR_CLIENT_SECRET` | the [operator provider](#operator-provider) its staff sign in with to sign in as people, passed by the platform; staff sign-in is off without them. `PROTOBASE_OPERATOR_NAME` and `PROTOBASE_OPERATOR_GROUP` are optional |
|
|
83
83
|
|
|
84
84
|
- Cookies are `SameSite=Lax`, and `Secure` when `BETTER_AUTH_URL` is https.
|
|
85
85
|
- 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.
|
|
86
86
|
- New passwords need at least 12 characters.
|
|
87
|
-
- `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).
|
|
87
|
+
- `appName` is the app's name: authenticator apps and passkey prompts show it, the admin app's sidebar shows it at the top beside the app's [icon](app-identity.md#the-icons)), else 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). `PROTOBASE_APP_NAME`, when set, overrides it; without either it is `Protobase`, then without a display name. See [App identity](app-identity.md)).
|
|
88
88
|
|
|
89
89
|
## First run
|
|
90
90
|
|
|
@@ -125,7 +125,7 @@ One process, one port: Vite serves the admin app from `@protobase/ui`'s `src/app
|
|
|
125
125
|
|
|
126
126
|
`defineConfig` from `@protobase/server` types it, and its `extends` merges other configs in (see [Extending a config](#extending-a-config)).
|
|
127
127
|
- **Project UI:** the app imports `protobase.ui.tsx` from the project root, with hot reload, when it exists (see [Custom components](custom-components.md))): the same contract as the plugin `protobase build` makes of it, built into the dev page instead. Layout files are checked as they load, as `protobase build` checks them.
|
|
128
|
-
- **Theme:** the page links `/protobase.theme.css`, which the dev server answers from the project's [theme](theme.md)), checked as the build checks it, on every request, so an edit shows on the next reload. It links `/protobase.favicon.svg` too, the project's [favicon](theme.md#logo-and-favicon)) or Protobase's.
|
|
128
|
+
- **Theme:** the page links `/protobase.theme.css`, which the dev server answers from the project's [theme](theme.md)), checked as the build checks it, on every request, so an edit shows on the next reload. It links `/protobase.favicon.svg` too, the project's [favicon](theme.md#logo-and-favicon)) or Protobase's, and `/protobase.apple-touch-icon.png`, which it answers with the PNG [icons](app-identity.md#the-icons)) the project has.
|
|
129
129
|
- **Extensions:** `--extend <dir>` merges an extension in, its UI built into the dev page beside the project's, to try one out; its files reload like the project's.
|
|
130
130
|
- **Hot reload:** server code, data configs, `ui.ts` views, layouts and `protobase.config.ts` are loaded through Vite's SSR module graph. A change inside the project (or, in this repository, in `packages/server`, `packages/query`, `packages/schema`) rebuilds the API on the next request without a restart; `/meta` and `X-Meta-Version` change, so open tabs refetch. The database pool survives reloads. Newly added `ui.ts` files appear after the next change inside the project.
|
|
131
131
|
|
|
@@ -183,6 +183,7 @@ dist/
|
|
|
183
183
|
plugins/<extension>/ each --extend folder's protobase.ui.tsx, built as a plugin
|
|
184
184
|
protobase.theme.css the project's theme, checked and minified; empty without one
|
|
185
185
|
protobase.favicon.svg the project's favicon; Protobase's without one
|
|
186
|
+
protobase.*.png the project's PNG icons, the ones it has (see App identity)
|
|
186
187
|
protobase.bundle.json the manifest
|
|
187
188
|
```
|
|
188
189
|
|
|
@@ -361,7 +362,7 @@ Serves the API of a bundle from `protobase build` and owns the process around it
|
|
|
361
362
|
| `REQUEST_LOG` | `true` logs every request; default `false` |
|
|
362
363
|
| `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))) |
|
|
363
364
|
| `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 |
|
|
364
|
-
| `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
|
|
365
|
+
| `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, over [`appName`](auth.md#configuration)) |
|
|
365
366
|
| `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))) |
|
|
366
367
|
| `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))) |
|
|
367
368
|
| `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))) |
|
|
@@ -266,7 +266,7 @@ export default defineUi({ shell: { actions: NotesButton, rightPanel: Notes } })
|
|
|
266
266
|
|
|
267
267
|
When the app has an [assistant](assistant.md)), its button follows the project's actions and its dock the project's panel.
|
|
268
268
|
|
|
269
|
-
`logo` replaces Protobase's logo at the top of the sidebar with the app's own. It gets `compact`, true when the sidebar shows only icons, so it draws a mark alone, `workspace`, the name of the user's organization that Protobase's logo shows under it,
|
|
269
|
+
`logo` replaces Protobase's logo at the top of the sidebar with the app's own. It gets `compact`, true when the sidebar shows only icons, so it draws a mark alone, `workspace`, the name of the user's organization that Protobase's logo shows under it, `appName`, the app's [name](auth.md#configuration)), which Protobase's logo shows beside its mark, and `appIcon`, the path of the project's own [icon](app-identity.md#the-icons)) when it has one (`ShellLogoProps`). Its colors follow the [theme](theme.md)), and a `dark:` class gives dark its own. When it throws, Protobase's logo shows instead. The tab's icon is [the favicon](theme.md#logo-and-favicon)).
|
|
270
270
|
|
|
271
271
|
```tsx
|
|
272
272
|
import { defineUi, type ShellLogoProps } from '@protobase/ui'
|
|
@@ -12,7 +12,7 @@ An app sends mail through one SMTP server: Protobase's own mail ([password reset
|
|
|
12
12
|
| --- | --- |
|
|
13
13
|
| `PROTOBASE_SMTP_URL` | The SMTP server, credential included: `smtp://user:password@host:587` (STARTTLS when the server offers it) or `smtps://user:password@host:465` (TLS from the start). |
|
|
14
14
|
| `PROTOBASE_MAIL_FROM` | The sender, a plain address such as `noreply@shop.example.com`. The client greets the server with its domain; a `?name=` on the URL overrides that. |
|
|
15
|
-
| `PROTOBASE_APP_NAME` | Optional: the app's name, such as `Shop`, which mail clients show as the sender's name (`Shop <noreply@shop.example.com>`). [`createAuth`'s `appName`](auth.md#configuration))
|
|
15
|
+
| `PROTOBASE_APP_NAME` | Optional: the app's name, such as `Shop`, which mail clients show as the sender's name (`Shop <noreply@shop.example.com>`). It overrides [`createAuth`'s `appName`](auth.md#configuration)). Without either the sender has no name. |
|
|
16
16
|
|
|
17
17
|
Set both or neither. One without the other, a URL that is not `smtp://` or `smtps://`, or a sender that is not a plain address stops the app at startup. Without them mail is off: password reset and emailed codes are not offered, a job's `mail` is `undefined`, and sending an app's email rejects.
|
|
18
18
|
|
|
@@ -6,7 +6,7 @@ The admin app installs as an app of its own on phones and computers, named for t
|
|
|
6
6
|
|
|
7
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
8
|
|
|
9
|
-
There is nothing to set up. The app installs under its name, `
|
|
9
|
+
There is nothing to set up. The app installs under its name, `PROTOBASE_APP_NAME` or `appName`, with its favicon, `protobase.favicon.svg`, as its icon, and the colours of `app` in `protobase.config.ts` (see [App identity](app-identity.md))). Safari takes no SVG icon: give the project a `protobase.apple-touch-icon.png`, or it shows a picture of the page on the home screen instead.
|
|
10
10
|
|
|
11
11
|
## The manifest
|
|
12
12
|
|
|
@@ -20,10 +20,19 @@ The app's page links its web app manifest at `/api/manifest.webmanifest`, which
|
|
|
20
20
|
"start_url": "/",
|
|
21
21
|
"scope": "/",
|
|
22
22
|
"display": "standalone",
|
|
23
|
-
"
|
|
23
|
+
"theme_color": "#0d9488",
|
|
24
|
+
"background_color": "#ffffff",
|
|
25
|
+
"icons": [
|
|
26
|
+
{ "src": "/protobase.favicon.svg", "sizes": "any", "type": "image/svg+xml" },
|
|
27
|
+
{ "src": "/protobase.icon-192.png", "sizes": "192x192", "type": "image/png" },
|
|
28
|
+
{ "src": "/protobase.icon-512.png", "sizes": "512x512", "type": "image/png" },
|
|
29
|
+
{ "src": "/protobase.icon-maskable.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" }
|
|
30
|
+
]
|
|
24
31
|
}
|
|
25
32
|
```
|
|
26
33
|
|
|
34
|
+
The colours and each PNG are there only when the project has them.
|
|
35
|
+
|
|
27
36
|
## Without a network
|
|
28
37
|
|
|
29
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.
|
|
@@ -123,9 +123,9 @@ The list is `packages/ui/src/tokens.css`, and a test fails when one of its token
|
|
|
123
123
|
|
|
124
124
|
## Logo and favicon
|
|
125
125
|
|
|
126
|
-
The sidebar shows Protobase's logo, its mark alone when the sidebar shows only icons
|
|
126
|
+
The sidebar shows Protobase's logo, its mark alone when the sidebar shows only icons, or, for a project with its own favicon, that icon and the app's name ([App identity](app-identity.md))). A project draws something else with `shell.logo` in `protobase.ui.tsx`, a component drawn in its place ([Shell slots](custom-components.md#shell-slots))); it draws with these tokens like the rest of the app.
|
|
127
127
|
|
|
128
|
-
The browser tab shows Protobase's mark. A project shows its own with a `protobase.favicon.svg` at its root, beside `protobase.theme.css`: the app's `index.html` links `/protobase.favicon.svg`, which `protobase build` writes to the bundle's `public/`, the project's file or Protobase's without one, and which `protobase dev` serves the same way. An SVG can follow the system's light or dark with a `prefers-color-scheme` media query inside it, as Protobase's does.
|
|
128
|
+
The browser tab shows Protobase's mark. A project shows its own with a `protobase.favicon.svg` at its root, beside `protobase.theme.css`: the app's `index.html` links `/protobase.favicon.svg`, which `protobase build` writes to the bundle's `public/`, the project's file or Protobase's without one, and which `protobase dev` serves the same way. An SVG can follow the system's light or dark with a `prefers-color-scheme` media query inside it, as Protobase's does. PNGs beside it serve the platforms that take no SVG, such as an iPhone's home screen ([App identity](app-identity.md#the-icons))).
|
|
129
129
|
|
|
130
130
|
## In a plugin
|
|
131
131
|
|