@protobase/cli 0.55.11 → 0.56.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/bundle-mobile.js +13 -0
- package/dist/build/config-bundle.js +4 -1
- package/dist/build/deploy-bundle.js +5 -2
- package/dist/build/shell.js +10 -4
- package/dist/bundle/manifest.js +3 -1
- package/dist/cli/package.js +1 -1
- package/dist/mobile/mobile-config.js +1 -1
- package/dist/mobile/run.js +2 -2
- package/dist/mobile/web-part.js +1 -2
- package/dist/serve/app.js +2 -1
- package/dist/serve/env.js +2 -1
- package/dist/serve/mobile-release.js +1 -3
- package/dist/serve/serve-dir.js +8 -9
- package/dist/serve/served-shell.js +3 -1
- package/package.json +7 -7
- package/skills/protobase/references/features/build-and-run.md +1 -0
- package/skills/protobase/references/reference/architecture.md +1 -1
- package/skills/protobase/references/reference/cli.md +15 -1
- package/skills/protobase/references/reference/plugins.md +1 -1
- package/dist/mobile/api-origin-page.js +0 -11
- package/dist/mobile/fingerprint.js +0 -19
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { checkMobileConfig } from "../mobile/mobile-config.js";
|
|
2
|
+
//#region src/build/bundle-mobile.ts
|
|
3
|
+
/**
|
|
4
|
+
* What the manifest says of the config's `mobile` section, checked as `protobase mobile` checks it: its plugins, empty
|
|
5
|
+
* when it gives none, which a host that never runs the config fingerprints the mobile release with. `undefined`
|
|
6
|
+
* without a section, so its presence means the app has a mobile build.
|
|
7
|
+
*/
|
|
8
|
+
const bundleMobile = (section) => {
|
|
9
|
+
if (section === void 0) return;
|
|
10
|
+
return { plugins: checkMobileConfig(section).plugins ?? {} };
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { bundleMobile };
|
|
@@ -87,7 +87,10 @@ const buildConfigBundle = async ({ projectDir, outFile, bun, extensions = [], co
|
|
|
87
87
|
bun,
|
|
88
88
|
plugins
|
|
89
89
|
});
|
|
90
|
-
return
|
|
90
|
+
return {
|
|
91
|
+
native: [...native.values()],
|
|
92
|
+
mobile: config.mobile
|
|
93
|
+
};
|
|
91
94
|
};
|
|
92
95
|
//#endregion
|
|
93
96
|
export { buildConfigBundle };
|
|
@@ -5,12 +5,13 @@ import { bundleLayout, bundleMigrations, bundleNodeModules, manifestFile } from
|
|
|
5
5
|
import { buildBundlePlugins } from "./bundle-plugins.js";
|
|
6
6
|
import { copyMigrations } from "./bundle-migrations.js";
|
|
7
7
|
import { buildConfigBundle } from "./config-bundle.js";
|
|
8
|
+
import { pinnedNative } from "../mobile/pinned-packages.js";
|
|
9
|
+
import { bundleMobile } from "./bundle-mobile.js";
|
|
8
10
|
import { copyPackages } from "./packages/copy-packages.js";
|
|
9
11
|
import { buildTheme } from "./theme.js";
|
|
10
12
|
import { shellForBuild, shellManifestFile } from "./shell.js";
|
|
11
13
|
import { checkUi } from "./ui-check.js";
|
|
12
14
|
import { checkViews } from "./view-check.js";
|
|
13
|
-
import { pinnedNative } from "../mobile/pinned-packages.js";
|
|
14
15
|
import { existsSync } from "node:fs";
|
|
15
16
|
import path from "node:path";
|
|
16
17
|
import { cp, readFile, rm, writeFile } from "node:fs/promises";
|
|
@@ -50,13 +51,14 @@ const buildDeployBundle = async ({ projectDir, outDir, bun, extensions = [], sou
|
|
|
50
51
|
await removeOwnFolder(outDir, bundleNodeModules, "nodeModules");
|
|
51
52
|
await removeOwnFolder(outDir, bundleMigrations, "migrations");
|
|
52
53
|
const components = /* @__PURE__ */ new Set();
|
|
53
|
-
const native = await buildConfigBundle({
|
|
54
|
+
const { native, mobile } = await buildConfigBundle({
|
|
54
55
|
projectDir,
|
|
55
56
|
outFile: path.join(outDir, bundleLayout.server),
|
|
56
57
|
bun,
|
|
57
58
|
extensions,
|
|
58
59
|
components
|
|
59
60
|
});
|
|
61
|
+
const mobileSection = bundleMobile(mobile);
|
|
60
62
|
await checkViews(projectDir);
|
|
61
63
|
await checkUi(projectDir, extensions, components);
|
|
62
64
|
const packages = native.length > 0 ? await copyPackages(native, path.join(outDir, bundleNodeModules)) : [];
|
|
@@ -90,6 +92,7 @@ const buildDeployBundle = async ({ projectDir, outDir, bun, extensions = [], sou
|
|
|
90
92
|
shell,
|
|
91
93
|
icons,
|
|
92
94
|
native: pinnedNative,
|
|
95
|
+
...mobileSection && { mobile: mobileSection },
|
|
93
96
|
...packages.length > 0 ? { nodeModules: bundleNodeModules } : {},
|
|
94
97
|
...migrations ? { migrations } : {}
|
|
95
98
|
};
|
package/dist/build/shell.js
CHANGED
|
@@ -2,6 +2,7 @@ import { readPackageJson } from "./packages/package-dir.js";
|
|
|
2
2
|
import { adminAppDir, uiEntry, uiPackageDir } from "../project/admin-app.js";
|
|
3
3
|
import { projectUiPlugin } from "../project/project-ui.js";
|
|
4
4
|
import { sharedModulesPlugin } from "../project/shared-modules.js";
|
|
5
|
+
import { pinnedNative } from "../mobile/pinned-packages.js";
|
|
5
6
|
import { faviconLink } from "../project/favicon-link.js";
|
|
6
7
|
import { themeLink } from "../project/theme-link.js";
|
|
7
8
|
import { serviceWorkerFile } from "./service-worker-code.js";
|
|
@@ -16,7 +17,7 @@ import tailwindcss from "@tailwindcss/vite";
|
|
|
16
17
|
import react from "@vitejs/plugin-react";
|
|
17
18
|
import { tmpdir } from "node:os";
|
|
18
19
|
//#region src/build/shell.ts
|
|
19
|
-
/** What a shell folder holds beside its files: the `
|
|
20
|
+
/** What a shell folder holds beside its files: the `ShellManifest`. */
|
|
20
21
|
const shellManifestFile = "protobase.shell.json";
|
|
21
22
|
/** The shell's files, as URL paths: its page, its content-hashed assets and its service worker. */
|
|
22
23
|
const shellPaths = [
|
|
@@ -42,7 +43,7 @@ const shellIdentity = async () => {
|
|
|
42
43
|
};
|
|
43
44
|
/**
|
|
44
45
|
* The admin app as a production build, the same for every project: index.html and content-hashed files under assets/,
|
|
45
|
-
* with protobase.shell.json saying which version it is. Asset URLs are absolute, so index.html works as the answer to
|
|
46
|
+
* with protobase.shell.json saying which version it is and the native packages it runs on. Asset URLs are absolute, so index.html works as the answer to
|
|
46
47
|
* any deep link. It calls /api on its own origin and loads the project's UI, like every plugin, from what `/meta`
|
|
47
48
|
* 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
|
|
48
49
|
* their own, which index.html's import map names. With `sourceMapsDir`, each script ends with a `//# debugId=` comment
|
|
@@ -92,7 +93,11 @@ const buildShell = async (outDir, sourceMapsDir) => {
|
|
|
92
93
|
await moveSourceMaps(outDir, sourceMapsDir);
|
|
93
94
|
}
|
|
94
95
|
const shell = await shellIdentity();
|
|
95
|
-
|
|
96
|
+
const manifest = {
|
|
97
|
+
...shell,
|
|
98
|
+
native: pinnedNative
|
|
99
|
+
};
|
|
100
|
+
await writeFile(path.join(outDir, shellManifestFile), `${JSON.stringify(manifest, null, 2)}\n`);
|
|
96
101
|
return shell;
|
|
97
102
|
};
|
|
98
103
|
/** The shell in `dir`, as its protobase.shell.json describes it. */
|
|
@@ -111,10 +116,11 @@ const installedShellDir = path.extname(uiEntry) === ".js" ? prebuiltShellDir : v
|
|
|
111
116
|
const shellForBuild = async (sourceMaps) => {
|
|
112
117
|
if (installedShellDir) {
|
|
113
118
|
if (sourceMaps && !existsSync(prebuiltShellSourceMapsDir)) throw new Error(`The installed @protobase/ui ships no source maps of its shell (${prebuiltShellSourceMapsDir}); install a version that does, or build without --source-maps`);
|
|
119
|
+
const { native: _, ...shell } = await readShell(installedShellDir);
|
|
114
120
|
return {
|
|
115
121
|
dir: installedShellDir,
|
|
116
122
|
...sourceMaps && { sourceMapsDir: prebuiltShellSourceMapsDir },
|
|
117
|
-
shell
|
|
123
|
+
shell
|
|
118
124
|
};
|
|
119
125
|
}
|
|
120
126
|
const scratch = await mkdtemp(path.join(tmpdir(), "protobase-shell-"));
|
package/dist/bundle/manifest.js
CHANGED
|
@@ -24,12 +24,13 @@ const isIcons = (value) => isObject(value) && typeof value.favicon === "boolean"
|
|
|
24
24
|
const parseManifest = (value, file) => {
|
|
25
25
|
const manifest = value;
|
|
26
26
|
if (manifest?.version !== 3) throw new Error(`${file} is not a version 3 bundle manifest; rebuild it with \`protobase build\``);
|
|
27
|
-
const { server, public: publicDir, api, spa, plugins, theme, shell, icons, native, nodeModules, migrations } = manifest;
|
|
27
|
+
const { server, public: publicDir, api, spa, plugins, theme, shell, icons, native, mobile, nodeModules, migrations } = manifest;
|
|
28
28
|
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`);
|
|
29
29
|
if (!Array.isArray(plugins) || !plugins.every(isPlugin)) throw new Error(`${file} needs a plugins list, each with a name, path, api and protobase`);
|
|
30
30
|
if (!isShell(shell)) throw new Error(`${file} needs a shell with its protobase version, pluginApi and paths`);
|
|
31
31
|
if (icons !== void 0 && !isIcons(icons)) throw new Error(`${file} has icons that are not a favicon flag and a list of PNG icons`);
|
|
32
32
|
if (native !== void 0 && !isVersions(native)) throw new Error(`${file} has a native that is not a map of package names to versions`);
|
|
33
|
+
if (mobile !== void 0 && !(isObject(mobile) && isVersions(mobile.plugins))) throw new Error(`${file} has a mobile that is not { plugins } with a map of package names to versions`);
|
|
33
34
|
if (nodeModules !== void 0 && typeof nodeModules !== "string") throw new Error(`${file} has a nodeModules that is no path`);
|
|
34
35
|
if (migrations !== void 0 && typeof migrations !== "string") throw new Error(`${file} has a migrations that is no path`);
|
|
35
36
|
return {
|
|
@@ -43,6 +44,7 @@ const parseManifest = (value, file) => {
|
|
|
43
44
|
shell,
|
|
44
45
|
...icons && { icons },
|
|
45
46
|
...native && { native },
|
|
47
|
+
...mobile && { mobile },
|
|
46
48
|
...nodeModules === void 0 ? {} : { nodeModules },
|
|
47
49
|
...migrations === void 0 ? {} : { migrations }
|
|
48
50
|
};
|
package/dist/cli/package.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { pinnedProblem } from "./pinned-packages.js";
|
|
2
1
|
import { appIdProblem, isAppId } from "./app-id.js";
|
|
3
2
|
import { packageNameProblem } from "./package-name.js";
|
|
3
|
+
import { pinnedProblem } from "./pinned-packages.js";
|
|
4
4
|
//#region src/mobile/mobile-config.ts
|
|
5
5
|
const noMobileSection = "This project has no mobile section: add `mobile: { appId: 'com.example.app' }` to the default export of protobase.config.ts";
|
|
6
6
|
const unauthenticated = /^(?:http:|git:|git\+http:)/i;
|
package/dist/mobile/run.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { nativeFingerprint } from "./fingerprint.js";
|
|
2
1
|
import { checkInstalledPlugins, checkPinnedNative, pinnedNative } from "./pinned-packages.js";
|
|
2
|
+
import { checkMobileConfig } from "./mobile-config.js";
|
|
3
3
|
import { withoutAndroidSigning } from "./android-signing.js";
|
|
4
4
|
import { runChild } from "./child-process.js";
|
|
5
5
|
import { apiUrl, checkReleaseUrl, httpAllowances } from "./api-origin.js";
|
|
@@ -11,11 +11,11 @@ import { childEnv, envFileKeys, projectEnvFiles } from "./child-env.js";
|
|
|
11
11
|
import { deviceAppName } from "./device-app-name.js";
|
|
12
12
|
import { generatePlatform } from "./generate.js";
|
|
13
13
|
import { loadMobileProject } from "./load-project.js";
|
|
14
|
-
import { checkMobileConfig } from "./mobile-config.js";
|
|
15
14
|
import { signForDevelopment } from "./development-signing.js";
|
|
16
15
|
import { checkIosPlugins, checkProtobasePlugin, guardLiveUpdate } from "./protobase-plugin.js";
|
|
17
16
|
import { mobileSpec, prepareWorkspace, workspaceDir, workspacePackageJson } from "./workspace.js";
|
|
18
17
|
import path from "node:path";
|
|
18
|
+
import { nativeFingerprint } from "@protobase/server/mobile-release";
|
|
19
19
|
//#region src/mobile/run.ts
|
|
20
20
|
const prepare = async ({ projectDir, platform, api, extensions, live, release }, { run = runChild, build, fetch }) => {
|
|
21
21
|
const env = withoutAndroidSigning(childEnv({ ...process.env }, envFileKeys(projectEnvFiles(projectDir))));
|
package/dist/mobile/web-part.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { bundleLayout } from "../bundle/manifest.js";
|
|
2
|
-
import { withApiOrigin } from "./api-origin-page.js";
|
|
3
2
|
import { siteFiles } from "../serve/site-files.js";
|
|
4
3
|
import { buildDeployBundle } from "../build/deploy-bundle.js";
|
|
5
4
|
import path from "node:path";
|
|
6
5
|
import { cp, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
7
|
-
import { releaseManifest } from "@protobase/server";
|
|
8
6
|
import { releaseManifestFile } from "@protobase/schema/internal";
|
|
7
|
+
import { releaseManifest, withApiOrigin } from "@protobase/server/mobile-release";
|
|
9
8
|
const writeReleaseManifest = async (web) => {
|
|
10
9
|
const files = await Promise.all((await siteFiles({
|
|
11
10
|
publicDir: web,
|
package/dist/serve/app.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { isApiPath } from "../bundle/manifest.js";
|
|
2
2
|
import { serveStaticSite } from "./static-site.js";
|
|
3
|
-
import { jobsDrainApp,
|
|
3
|
+
import { jobsDrainApp, webauthnPath } from "@protobase/server";
|
|
4
4
|
import { Hono } from "hono";
|
|
5
|
+
import { mobileReleaseApp } from "@protobase/server/mobile-release";
|
|
5
6
|
import { logger } from "hono/logger";
|
|
6
7
|
//#region src/serve/app.ts
|
|
7
8
|
const createServeApp = ({ admin, requestLog, site, jobs, drainToken, mobile }) => {
|
package/dist/serve/env.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readTrustedProxies } from "./client-address.js";
|
|
2
|
-
import { readDbConnections
|
|
2
|
+
import { readDbConnections } from "@protobase/server";
|
|
3
|
+
import { readSigningKey } from "@protobase/server/mobile-release";
|
|
3
4
|
//#region src/serve/env.ts
|
|
4
5
|
const defaultPort = 8787;
|
|
5
6
|
const readBoolean = (env, name, fallback) => {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { nativeFingerprint } from "../mobile/fingerprint.js";
|
|
2
|
-
import { withApiOrigin } from "../mobile/api-origin-page.js";
|
|
3
1
|
import { siteFiles } from "./site-files.js";
|
|
4
2
|
import { readFile } from "node:fs/promises";
|
|
5
|
-
import { composeRelease } from "@protobase/server";
|
|
3
|
+
import { composeRelease, nativeFingerprint, withApiOrigin } from "@protobase/server/mobile-release";
|
|
6
4
|
//#region src/serve/mobile-release.ts
|
|
7
5
|
const loopback = [
|
|
8
6
|
"localhost",
|
package/dist/serve/serve-dir.js
CHANGED
|
@@ -2,21 +2,20 @@ import { readManifest } from "../bundle/manifest.js";
|
|
|
2
2
|
import { bundleSite } from "./bundle-site.js";
|
|
3
3
|
import { serveBundle } from "./serve-bundle.js";
|
|
4
4
|
import { installedShellDir } from "../build/shell.js";
|
|
5
|
-
import { pinnedNative } from "../mobile/pinned-packages.js";
|
|
6
5
|
import { servedShell, shellVariable } from "./served-shell.js";
|
|
7
6
|
import path from "node:path";
|
|
8
7
|
//#region src/serve/serve-dir.ts
|
|
9
8
|
const serveBundleDir = async (dir, env, out) => {
|
|
10
9
|
const manifest = await readManifest(dir);
|
|
11
10
|
const own = env["PROTOBASE_SHELL"] ? path.resolve(env[shellVariable]) : installedShellDir;
|
|
12
|
-
const { shell, note } = await servedShell(own);
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
};
|
|
11
|
+
const { shell, native, note } = await servedShell(own);
|
|
12
|
+
const bundled = bundleSite(dir, manifest);
|
|
13
|
+
const { native: _, ...ownSite } = bundled;
|
|
14
|
+
const site = shell ? {
|
|
15
|
+
...ownSite,
|
|
16
|
+
shell,
|
|
17
|
+
...native && { native }
|
|
18
|
+
} : bundled;
|
|
20
19
|
const server = await serveBundle(path.join(dir, manifest.server), env, out, site);
|
|
21
20
|
out(` app ${note}\n`);
|
|
22
21
|
return server;
|
|
@@ -4,7 +4,8 @@ import { readShell } from "../build/shell.js";
|
|
|
4
4
|
const shellVariable = "PROTOBASE_SHELL";
|
|
5
5
|
/**
|
|
6
6
|
* The shell a server of its own shell `ownDir` serves a bundle with: its own, so the app follows the server's version
|
|
7
|
-
* without a rebuild; without one, the
|
|
7
|
+
* without a rebuild, with the native packages it runs on in the mobile app when it names them; without one, the
|
|
8
|
+
* bundle's copy.
|
|
8
9
|
*/
|
|
9
10
|
const servedShell = async (ownDir) => {
|
|
10
11
|
if (ownDir === void 0) return { note: "the bundle's copy of the app" };
|
|
@@ -14,6 +15,7 @@ const servedShell = async (ownDir) => {
|
|
|
14
15
|
dir: ownDir,
|
|
15
16
|
paths: own.paths
|
|
16
17
|
},
|
|
18
|
+
...own.native && { native: own.native },
|
|
17
19
|
note: `the app of Protobase ${own.protobase} from ${ownDir}`
|
|
18
20
|
};
|
|
19
21
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.56.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": {
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@better-auth/core": "^1.7.12",
|
|
44
44
|
"@hono/node-server": "^2.1.3",
|
|
45
|
-
"@protobase/config": "0.
|
|
46
|
-
"@protobase/layout": "0.
|
|
47
|
-
"@protobase/query": "0.
|
|
48
|
-
"@protobase/schema": "0.
|
|
49
|
-
"@protobase/server": "0.
|
|
50
|
-
"@protobase/ui": "0.
|
|
45
|
+
"@protobase/config": "0.56.0",
|
|
46
|
+
"@protobase/layout": "0.56.0",
|
|
47
|
+
"@protobase/query": "0.56.0",
|
|
48
|
+
"@protobase/schema": "0.56.0",
|
|
49
|
+
"@protobase/server": "0.56.0",
|
|
50
|
+
"@protobase/ui": "0.56.0",
|
|
51
51
|
"@react-email/render": "^2.1.0",
|
|
52
52
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
53
53
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -24,3 +24,4 @@ Develop, build and run an app, on servers, in containers and on phones.
|
|
|
24
24
|
- [Self-hosted image](../guides/deploy.md#a-self-hosted-image): One image with the app inside that serves, migrates and creates the first admin.
|
|
25
25
|
- [Protobase Cloud deploys](../guides/deploy.md#protobase-cloud): A push to the app's GitHub branch builds it, migrates and checks its database in one transaction, and switches to the new version once it answers its health check.
|
|
26
26
|
- [Mobile apps](../guides/mobile-app.md) (beta): Runs an app on iOS and Android, also on your own iPhone, with sign-in, and builds signed store releases from a section in its config.
|
|
27
|
+
- [Mobile releases](../reference/cli.md#mobile-releases) (in development): The server offers the mobile app a newer copy of its files, signed, and any host that serves bundles can offer the same from the bundle's files without running its config.
|
|
@@ -15,7 +15,7 @@ A Bun workspace of npm packages under the `@protobase` scope, in `packages/<name
|
|
|
15
15
|
| `@protobase/query` | `packages/query` | `@protobase/query` | server | `schema` |
|
|
16
16
|
| `@protobase/client` | `packages/client` | `@protobase/client` | anywhere with `fetch` | `schema`, `layout` |
|
|
17
17
|
| `@protobase/ui` | `packages/ui` | `@protobase/ui`, `@protobase/ui/theme.css`, `@protobase/ui/styles.css`; the admin app in `src/app` | browser | `schema`, `layout`, `client` |
|
|
18
|
-
| `@protobase/server` | `packages/server` | `@protobase/server`, `@protobase/server/auth-store`, `@protobase/server/config-exports`, `@protobase/server/email`, `@protobase/server/vapid`; `@protobase/server/internal` for the other packages only | server | `schema`, `layout`, `query` |
|
|
18
|
+
| `@protobase/server` | `packages/server` | `@protobase/server`, `@protobase/server/auth-store`, `@protobase/server/config-exports`, `@protobase/server/email`, `@protobase/server/mobile-release`, `@protobase/server/vapid`; `@protobase/server/internal` for the other packages only | server | `schema`, `layout`, `query` |
|
|
19
19
|
| `@protobase/config` | `packages/config` | `@protobase/config`, `@protobase/config/schema.json` | anywhere | types of `server` only: it runs nothing besides `defineConfig` |
|
|
20
20
|
| `@protobase/cli` | `packages/cli` | the `protobase` command (`bin/protobase.mjs`), `@protobase/cli/auth`, `@protobase/cli/runner`, `@protobase/cli/scaffold` | Node and Bun | `config`, `schema`, `layout`, `query`, `server`, `ui` |
|
|
21
21
|
| `@protobase/mobile` | `packages/mobile` | none: the Capacitor packages and native plugins `protobase mobile` installs on first use | the app's iOS and Android projects | none |
|
|
@@ -211,6 +211,7 @@ By default the bundle runs on Node and on Bun. `--bun` makes it a bundle for Bun
|
|
|
211
211
|
],
|
|
212
212
|
"shell": { "protobase": "0.12.0", "pluginApi": 1, "paths": ["/index.html", "/assets", "/protobase.sw.js"] },
|
|
213
213
|
"native": { "@capacitor/core": "8.5.3", "@capacitor/ios": "8.5.3" },
|
|
214
|
+
"mobile": { "plugins": { "@capacitor/camera": "^8.0.1" } },
|
|
214
215
|
"nodeModules": "node_modules",
|
|
215
216
|
"migrations": "migrations"
|
|
216
217
|
}
|
|
@@ -221,6 +222,7 @@ By default the bundle runs on Node and on Bun. `--bun` makes it a bundle for Bun
|
|
|
221
222
|
- `plugins` are the bundle's own plugins, in the order the app merges them: the extensions', then the project's (`app`). Each names its `plugin.json`, the plugin API and Protobase versions it is built for, and the [field types](plugins.md#field-types) it registers with the storage types each shows, which the serve runtime checks the views against at startup. `/api/meta` names them to everyone, before any other plugin.
|
|
222
223
|
- `shell` is the admin app `public/` holds a copy of: its Protobase version and plugin API, and its files as URL paths. A host with a shell of its own may serve its own for those paths instead (see [The UI](#the-ui)), so the app gets that release's fixes without a rebuild.
|
|
223
224
|
- `native` is the native code, name to version, that `shell` runs on in the [mobile app](../guides/mobile-app.md): the native packages `@protobase/mobile` pins, and `@protobase/mobile` itself at its native contract, such as `native-1`, which Protobase raises when its own native code changes. The fingerprint of the bundle's [mobile release](#mobile-releases) names them. A bundle built before it serves no mobile release.
|
|
225
|
+
- `mobile` is present only when the project's config has a `mobile` section, so a host learns that the app has a mobile build without running the config: the section's `plugins`, name to the spec it gives, `{}` when it gives none, which the fingerprint of the mobile release names besides `native`. The build checks the section as `protobase mobile` does.
|
|
224
226
|
- `theme` is the project's [theme](theme.md), which the app links at `/protobase.theme.css`. It is always there, empty when the project has none.
|
|
225
227
|
- `nodeModules` is present only when the config module imports [native packages](#native-packages). It is always the `node_modules` folder beside `server`, where Bun and Node resolve the module's imports from, and holds plain packages: JavaScript, `package.json` files and native binaries for linux x64 and arm64 (glibc), which the runtime loads with `dlopen`. A host keeps it next to the server module and must not mount it `noexec` (an add-on there then fails with `failed to map segment from shared object`). Its binaries link nothing but glibc, `libstdc++.so.6`, `libgcc_s.so.1` and libraries in the bundle itself, so the run image must have those three. Without `nodeModules`, the server module is the only file the runtime reads.
|
|
226
228
|
- `migrations` is present only when the project has a `db/migrations` folder: its `.sql` files, which the runtime's `migrate` applies (see [Deploy](../guides/deploy.md)). A host never serves it.
|
|
@@ -421,11 +423,23 @@ The app's address and secret are `PROTOBASE_URL` and `PROTOBASE_SECRET` unless i
|
|
|
421
423
|
|
|
422
424
|
### Mobile releases
|
|
423
425
|
|
|
424
|
-
|
|
426
|
+
:::caution[In development]
|
|
427
|
+
<gap>The mobile app cannot install a release yet because its live updater is not implemented.</gap>
|
|
428
|
+
:::
|
|
429
|
+
|
|
430
|
+
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`. 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.
|
|
425
431
|
|
|
426
432
|
- `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.
|
|
427
433
|
- `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.
|
|
428
434
|
|
|
435
|
+
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.
|
|
436
|
+
|
|
437
|
+
- `nativeFingerprint(native, plugins)`: the release's fingerprint, from the manifest's `native` (or that of the shell the host serves) and `mobile.plugins`. It is a contract across versions: a binary one Protobase release built is matched by a host that runs another.
|
|
438
|
+
- `withApiOrigin(html, origin)`: the `spa` page naming the API origin, the app's `url`.
|
|
439
|
+
- `composeRelease(files, signingKey?)`: the release of `{ href, content }` files, every file the host serves the web with the page above in place of `spa`, with its id and the signed checksums.
|
|
440
|
+
- `readSigningKey(env)`: the signing key in `PROTOBASE_MOBILE_SIGNING_KEY` of the env object given, the app's own, never the process's.
|
|
441
|
+
- `mobileReleaseApp({ release, serverVersion })`: a Hono app answering the two routes above for `{ ...release, fingerprint, origin }`.
|
|
442
|
+
|
|
429
443
|
## `worker`
|
|
430
444
|
|
|
431
445
|
```sh
|
|
@@ -283,7 +283,7 @@ The plugin starts the session itself, with a request that sets the app's session
|
|
|
283
283
|
|
|
284
284
|
## The shell
|
|
285
285
|
|
|
286
|
-
The shell is the admin app: `index.html` and its `assets/`, the same for every project on a release. Each release ships it prebuilt in `@protobase/ui`'s `dist/shell/` and in the [protobase image](../guides/deploy.md#images) at `/opt/protobase/shell/`, with a `protobase.shell.json` naming its Protobase version and plugin API. A bundle carries a copy, so any static host can serve it, and its manifest names that copy's version and paths (`shell` in [the manifest](cli.md#the-manifest)).
|
|
286
|
+
The shell is the admin app: `index.html` and its `assets/`, the same for every project on a release. Each release ships it prebuilt in `@protobase/ui`'s `dist/shell/` and in the [protobase image](../guides/deploy.md#images) at `/opt/protobase/shell/`, with a `protobase.shell.json` naming its Protobase version and plugin API, and as `native` the native packages it runs on in the [mobile app](../guides/mobile-app.md), which the fingerprint of its [mobile release](cli.md#mobile-releases) names. A bundle carries a copy, so any static host can serve it, and its manifest names that copy's version and paths (`shell` in [the manifest](cli.md#the-manifest)).
|
|
287
287
|
|
|
288
288
|
A host that keeps the shells of its releases can serve the shell of a newer one for those paths; the app still turns off a plugin that does not load in it. The plugins, the theme and the API stay the bundle's. `protobase serve` does this with its own shell (see [serve](cli.md#serve)). The app then has the newer release's fixes with nothing rebuilt; only a change of the server config's format, a new minor below 1.0, still needs a [rebuild](versioning.md#bundles-and-runtimes).
|
|
289
289
|
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { apiOriginMeta } from "@protobase/schema/internal";
|
|
2
|
-
//#region src/mobile/api-origin-page.ts
|
|
3
|
-
const escapeAttribute = (value) => value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
4
|
-
/** The page naming the API origin the shell calls, in the `<meta>` tag the shell reads (see `apiOriginMeta`). */
|
|
5
|
-
const withApiOrigin = (html, origin) => {
|
|
6
|
-
const at = html.indexOf("</head>");
|
|
7
|
-
if (at < 0) throw new Error("The shell's index.html has no </head> to name the API origin in");
|
|
8
|
-
return `${html.slice(0, at)}<meta name="${apiOriginMeta}" content="${escapeAttribute(origin)}">${html.slice(at)}`;
|
|
9
|
-
};
|
|
10
|
-
//#endregion
|
|
11
|
-
export { withApiOrigin };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
//#region src/mobile/fingerprint.ts
|
|
3
|
-
/**
|
|
4
|
-
* Names the app's native code: what @protobase/mobile carries, name → version (`pinnedNative`: the native packages it
|
|
5
|
-
* pins and its own native contract), and the project's `mobile.plugins`, name → the spec it gives. A release of the
|
|
6
|
-
* app's files runs only on a binary of the same fingerprint. It holds no Protobase version, so a Protobase release that
|
|
7
|
-
* pins the same native packages and native contract keeps binaries on live updates. A plugin's spec counts, not the
|
|
8
|
-
* version npm installed: its floor is what the app's files need of it, so raise the floor when they start using a
|
|
9
|
-
* newer native feature, which changes the fingerprint.
|
|
10
|
-
*/
|
|
11
|
-
const nativeFingerprint = (pinned, plugins = {}) => {
|
|
12
|
-
const entries = Object.entries({
|
|
13
|
-
...pinned,
|
|
14
|
-
...plugins
|
|
15
|
-
}).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
16
|
-
return createHash("sha256").update(JSON.stringify(entries)).digest("hex").slice(0, 16);
|
|
17
|
-
};
|
|
18
|
-
//#endregion
|
|
19
|
-
export { nativeFingerprint };
|