@protobase/cli 0.119.5 → 0.120.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-plugins.js +1 -1
- package/dist/build/plugin-build.js +15 -8
- package/dist/build/{plugin-fields.js → plugin-config.js} +28 -19
- package/dist/build/shared-imports.js +35 -0
- package/dist/bundle/manifest.js +2 -2
- package/dist/cli/package.js +1 -1
- package/dist/main.js +1 -1
- package/package.json +8 -8
- package/skills/protobase/references/features/record-pages.md +2 -1
- package/skills/protobase/references/features/your-own-code.md +2 -1
- package/skills/protobase/references/guides/first-plugin.md +5 -4
- package/skills/protobase/references/guides/plugin-build.md +1 -1
- package/skills/protobase/references/reference/cli.md +3 -3
- package/skills/protobase/references/reference/plugins.md +21 -12
- package/skills/protobase/references/reference/ui-config.md +48 -0
- package/skills/protobase/references/reference/versioning.md +1 -1
|
@@ -56,7 +56,7 @@ const buildBundlePlugins = async ({ projectDir, publicDir, extensions, styles =
|
|
|
56
56
|
name: manifest.name,
|
|
57
57
|
path: `${folder}/${pluginManifestFile}`,
|
|
58
58
|
api: manifest.api,
|
|
59
|
-
protobase: manifest.protobase,
|
|
59
|
+
...manifest.protobase && { protobase: manifest.protobase },
|
|
60
60
|
...manifest.fields && { fields: manifest.fields }
|
|
61
61
|
});
|
|
62
62
|
}
|
|
@@ -4,7 +4,8 @@ import { uiPackageDir } from "../project/admin-app.js";
|
|
|
4
4
|
import { extensionImports } from "../project/extensions.js";
|
|
5
5
|
import { bundledImports } from "../project/bundled-imports.js";
|
|
6
6
|
import { sharedModules } from "../project/shared-modules.js";
|
|
7
|
-
import {
|
|
7
|
+
import { readPluginConfig } from "./plugin-config.js";
|
|
8
|
+
import { sharedImports } from "./shared-imports.js";
|
|
8
9
|
import { layerPluginUtilities } from "./plugin-styles.js";
|
|
9
10
|
import { firstPartyCode } from "./first-party-code.js";
|
|
10
11
|
import { createRequire } from "node:module";
|
|
@@ -26,9 +27,9 @@ const targetUiDir = (pluginDir, projectDir, bundled) => {
|
|
|
26
27
|
return findPackageDirSync("@protobase/ui", pluginDir) ?? (projectDir === void 0 ? void 0 : findPackageDirSync("@protobase/ui", projectDir)) ?? uiPackageDir;
|
|
27
28
|
};
|
|
28
29
|
/**
|
|
29
|
-
* What the plugin is built for, from its @protobase/ui (see `targetUiDir`): its plugin API, and Protobase
|
|
30
|
-
*
|
|
31
|
-
*
|
|
30
|
+
* What the plugin is built for, from its @protobase/ui (see `targetUiDir`): its plugin API, and the Protobase versions
|
|
31
|
+
* the plugin's package.json names in `engines.protobase`, if any. Also that version's theme, which the plugin's
|
|
32
|
+
* stylesheet draws with, and its folder.
|
|
32
33
|
*/
|
|
33
34
|
const pluginTarget = async (pluginDir, own, projectDir, bundled) => {
|
|
34
35
|
const uiDir = targetUiDir(pluginDir, projectDir, bundled);
|
|
@@ -36,8 +37,8 @@ const pluginTarget = async (pluginDir, own, projectDir, bundled) => {
|
|
|
36
37
|
const api = ui.protobase?.pluginApi;
|
|
37
38
|
const theme = ui.exports?.["./theme.css"];
|
|
38
39
|
if (api === void 0 || typeof theme !== "string") throw new Error(`@protobase/ui ${ui.version} loads no plugins; install a version that does`);
|
|
39
|
-
const protobase = own.engines?.protobase
|
|
40
|
-
if (inRange(ui.version ?? "", protobase) === void 0) throw new Error(`engines.protobase "${protobase}" is not a range the app reads; write comparators such as >=0.12.0 <1.0.0`);
|
|
40
|
+
const protobase = own.engines?.protobase;
|
|
41
|
+
if (protobase !== void 0 && inRange(ui.version ?? "", protobase) === void 0) throw new Error(`engines.protobase "${protobase}" is not a range the app reads; write comparators such as >=0.12.0 <1.0.0`);
|
|
41
42
|
return {
|
|
42
43
|
api,
|
|
43
44
|
protobase,
|
|
@@ -153,18 +154,24 @@ const buildPlugin = async ({ pluginDir, outDir, name, projectDir, ignore = [], s
|
|
|
153
154
|
const module = output.find((file) => file.type === "chunk" && file.isEntry && file.facadeModuleId === entry);
|
|
154
155
|
const css = output.find((file) => file.type === "asset" && file.fileName.endsWith(".css"));
|
|
155
156
|
if (!module || !css) throw new Error("The plugin build wrote no module or no stylesheet");
|
|
156
|
-
const fields = stylesOnly ? {
|
|
157
|
+
const { fields, extensionPoints } = stylesOnly ? {
|
|
158
|
+
fields: {},
|
|
159
|
+
extensionPoints: []
|
|
160
|
+
} : await readPluginConfig({
|
|
157
161
|
pluginDir,
|
|
158
162
|
entry,
|
|
159
163
|
uiDir: target.uiDir,
|
|
160
164
|
projectDir,
|
|
161
165
|
bundled
|
|
162
166
|
});
|
|
167
|
+
const chunks = output.flatMap((file) => file.type === "chunk" ? [file] : []);
|
|
163
168
|
const manifest = {
|
|
164
169
|
name: pluginName,
|
|
165
170
|
...own.version && { version: own.version },
|
|
166
171
|
api: target.api,
|
|
167
|
-
protobase: target.protobase,
|
|
172
|
+
...target.protobase !== void 0 && { protobase: target.protobase },
|
|
173
|
+
imports: sharedImports(chunks),
|
|
174
|
+
extensionPoints,
|
|
168
175
|
entry: module.fileName,
|
|
169
176
|
css: css.fileName,
|
|
170
177
|
...Object.keys(fields).length > 0 && { fields }
|
|
@@ -7,41 +7,46 @@ import path from "node:path";
|
|
|
7
7
|
import { pathToFileURL } from "node:url";
|
|
8
8
|
import { mkdtemp, rm } from "node:fs/promises";
|
|
9
9
|
import { tmpdir } from "node:os";
|
|
10
|
-
//#region src/build/plugin-
|
|
11
|
-
const
|
|
10
|
+
//#region src/build/plugin-config.ts
|
|
11
|
+
const configCode = (entry) => [
|
|
12
12
|
`import * as ui from ${JSON.stringify(entry)}`,
|
|
13
|
-
`import
|
|
14
|
-
"const
|
|
15
|
-
"
|
|
13
|
+
`import * as protobaseUi from '@protobase/ui'`,
|
|
14
|
+
"const merged = protobaseUi.mergeUi(protobaseUi.uiFromModule(ui))",
|
|
15
|
+
"const { fields = {} } = merged",
|
|
16
|
+
"export default {",
|
|
17
|
+
" fields: Object.fromEntries(Object.entries(fields).map(([name, type]) => [name, type.of])),",
|
|
18
|
+
" extensionPoints: protobaseUi.extensionPointsOf?.(merged),",
|
|
19
|
+
"}",
|
|
16
20
|
""
|
|
17
21
|
].join("\n");
|
|
18
|
-
const
|
|
19
|
-
name: "protobase-plugin-
|
|
22
|
+
const configEntry = (file, code) => ({
|
|
23
|
+
name: "protobase-plugin-config",
|
|
20
24
|
resolveId: (id) => id === file ? `\0${file}` : void 0,
|
|
21
25
|
load: (id) => id === `\0${file}` ? code : void 0
|
|
22
26
|
});
|
|
23
27
|
const sharedFromUi = (uiDir) => {
|
|
24
28
|
const require = createRequire(path.join(uiDir, "package.json"));
|
|
25
29
|
return {
|
|
26
|
-
name: "protobase-plugin-
|
|
30
|
+
name: "protobase-plugin-config-shared",
|
|
27
31
|
enforce: "pre",
|
|
28
32
|
resolveId: (id) => id === "@protobase/ui" || !sharedModules.includes(id) ? void 0 : require.resolve(id)
|
|
29
33
|
};
|
|
30
34
|
};
|
|
31
|
-
const
|
|
35
|
+
const isNames = (value) => Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
32
36
|
/**
|
|
33
37
|
* The field types a plugin registers (`definePlugin({ fields })`), each with the storage types it shows (`of`), which
|
|
34
|
-
* the server checks the views against at startup
|
|
38
|
+
* the server checks the views against at startup, and the extension points it fills, which the app checks it has
|
|
39
|
+
* before it loads the plugin (see `extensionPointsOf` in @protobase/ui). The plugin's module is loaded once in Node, everything bundled into
|
|
35
40
|
* a scratch file, as `protobase build` loads a project's UI to check its names; nothing is rendered. A plugin of a
|
|
36
41
|
* bundled project imports the CLI's @protobase packages, as its build does.
|
|
37
42
|
*/
|
|
38
|
-
const
|
|
39
|
-
const file = path.join(pluginDir, "protobase-plugin-
|
|
40
|
-
const scratch = await mkdtemp(path.join(tmpdir(), "protobase-plugin-
|
|
41
|
-
const outFile = path.join(scratch, "
|
|
43
|
+
const readPluginConfig = async ({ pluginDir, entry, uiDir, projectDir, bundled = false }) => {
|
|
44
|
+
const file = path.join(pluginDir, "protobase-plugin-config.js");
|
|
45
|
+
const scratch = await mkdtemp(path.join(tmpdir(), "protobase-plugin-config-"));
|
|
46
|
+
const outFile = path.join(scratch, "config.mjs");
|
|
42
47
|
try {
|
|
43
48
|
const plugins = [
|
|
44
|
-
|
|
49
|
+
configEntry(file, configCode(entry)),
|
|
45
50
|
sharedFromUi(uiDir),
|
|
46
51
|
...bundled && projectDir !== void 0 ? [bundledImports([projectDir, pluginDir])] : [],
|
|
47
52
|
...projectDir === void 0 ? [] : [extensionImports(projectDir, [{ dir: pluginDir }])]
|
|
@@ -53,10 +58,14 @@ const pluginFieldTypes = async ({ pluginDir, entry, uiDir, projectDir, bundled =
|
|
|
53
58
|
plugins,
|
|
54
59
|
logLevel: "error"
|
|
55
60
|
});
|
|
56
|
-
const fields = (await import(pathToFileURL(outFile).href)).default;
|
|
57
|
-
const wrong = Object.entries(fields).find(([, of]) => !
|
|
61
|
+
const { fields, extensionPoints } = (await import(pathToFileURL(outFile).href)).default;
|
|
62
|
+
const wrong = Object.entries(fields).find(([, of]) => !isNames(of));
|
|
58
63
|
if (wrong) throw new Error(`The field type "${wrong[0]}" names no storage types it shows; give it of: ['integer'] or the like`);
|
|
59
|
-
|
|
64
|
+
if (!isNames(extensionPoints)) throw new Error(`The @protobase/ui in ${uiDir} does not name the extension points a plugin fills; install a version that does`);
|
|
65
|
+
return {
|
|
66
|
+
fields,
|
|
67
|
+
extensionPoints
|
|
68
|
+
};
|
|
60
69
|
} finally {
|
|
61
70
|
await rm(scratch, {
|
|
62
71
|
recursive: true,
|
|
@@ -65,4 +74,4 @@ const pluginFieldTypes = async ({ pluginDir, entry, uiDir, projectDir, bundled =
|
|
|
65
74
|
}
|
|
66
75
|
};
|
|
67
76
|
//#endregion
|
|
68
|
-
export {
|
|
77
|
+
export { readPluginConfig };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { sharedModules } from "../project/shared-modules.js";
|
|
2
|
+
import { parseAst } from "vite";
|
|
3
|
+
//#region src/build/shared-imports.ts
|
|
4
|
+
const isShared = (source) => typeof source === "string" && sharedModules.includes(source);
|
|
5
|
+
const takenName = (specifier) => {
|
|
6
|
+
if (specifier.type === "ImportDefaultSpecifier") return "default";
|
|
7
|
+
if (specifier.type === "ImportNamespaceSpecifier") return "*";
|
|
8
|
+
const taken = specifier.type === "ExportSpecifier" ? specifier.local : specifier.imported;
|
|
9
|
+
return taken?.name ?? taken?.value ?? "*";
|
|
10
|
+
};
|
|
11
|
+
const byNameOnly = "@protobase/ui";
|
|
12
|
+
/**
|
|
13
|
+
* The names a plugin's built chunks take from each module shared with plugins, sorted: what is left once the build
|
|
14
|
+
* has dropped unused code, from its imports, re-exports and `export *`, and `*` for a whole module it imports with
|
|
15
|
+
* `import * as` or `import()`. Taking @protobase/ui whole fails the build, since the app could not tell whether it
|
|
16
|
+
* has the names the plugin reads.
|
|
17
|
+
*/
|
|
18
|
+
const sharedImports = (chunks) => {
|
|
19
|
+
const taken = /* @__PURE__ */ new Map();
|
|
20
|
+
const take = (module, name) => taken.set(module, (taken.get(module) ?? /* @__PURE__ */ new Set()).add(name));
|
|
21
|
+
for (const chunk of chunks) {
|
|
22
|
+
for (const module of chunk.dynamicImports.filter(isShared)) take(module, "*");
|
|
23
|
+
for (const node of parseAst(chunk.code).body) {
|
|
24
|
+
if (node.type !== "ImportDeclaration" && node.type !== "ExportNamedDeclaration" && node.type !== "ExportAllDeclaration") continue;
|
|
25
|
+
const source = node.source?.value;
|
|
26
|
+
if (!isShared(source)) continue;
|
|
27
|
+
if (node.type === "ExportAllDeclaration") take(source, "*");
|
|
28
|
+
else for (const specifier of node.specifiers) take(source, takenName(specifier));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (taken.get(byNameOnly)?.has("*")) throw new Error(`The plugin takes all of ${byNameOnly} (import * as, export * or import()), so an app cannot check that it has what the plugin uses: import the names it uses instead, as in import { useList } from '${byNameOnly}'`);
|
|
32
|
+
return Object.fromEntries([...taken].sort(([a], [b]) => a < b ? -1 : 1).map(([module, names]) => [module, [...names].sort()]));
|
|
33
|
+
};
|
|
34
|
+
//#endregion
|
|
35
|
+
export { sharedImports };
|
package/dist/bundle/manifest.js
CHANGED
|
@@ -17,7 +17,7 @@ const bundleMigrations = "migrations";
|
|
|
17
17
|
const isStringList = (value) => Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
18
18
|
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19
19
|
const isFieldTypes = (value) => isObject(value) && Object.values(value).every(isStringList);
|
|
20
|
-
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));
|
|
20
|
+
const isPlugin = (value) => isObject(value) && typeof value.name === "string" && typeof value.path === "string" && Number.isInteger(value.api) && (value.protobase === void 0 || typeof value.protobase === "string") && (value.fields === void 0 || isFieldTypes(value.fields));
|
|
21
21
|
const isShell = (value) => isObject(value) && typeof value.protobase === "string" && Number.isInteger(value.pluginApi) && isStringList(value.paths) && (value.builtAt === void 0 || isTime(value.builtAt));
|
|
22
22
|
const isTime = (value) => Number.isSafeInteger(value) && value >= 0;
|
|
23
23
|
const isVersions = (value) => isObject(value) && Object.values(value).every((item) => typeof item === "string");
|
|
@@ -27,7 +27,7 @@ const parseManifest = (value, file) => {
|
|
|
27
27
|
if (manifest?.version !== 3) throw new Error(`${file} is not a version 3 bundle manifest; rebuild it with \`protobase build\``);
|
|
28
28
|
const { builtAt, server, public: publicDir, api, spa, plugins, theme, shell, icons, native, mobile, nodeModules, migrations } = manifest;
|
|
29
29
|
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`);
|
|
30
|
-
if (!Array.isArray(plugins) || !plugins.every(isPlugin)) throw new Error(`${file} needs a plugins list, each with a name, path
|
|
30
|
+
if (!Array.isArray(plugins) || !plugins.every(isPlugin)) throw new Error(`${file} needs a plugins list, each with a name, path and api`);
|
|
31
31
|
if (!isShell(shell)) throw new Error(`${file} needs a shell with its protobase version, pluginApi and paths`);
|
|
32
32
|
if (builtAt !== void 0 && !isTime(builtAt)) throw new Error(`${file} has a builtAt that is no time in ms`);
|
|
33
33
|
if (icons !== void 0 && !isIcons(icons)) throw new Error(`${file} has icons that are not a favicon flag and a list of PNG icons`);
|
package/dist/cli/package.js
CHANGED
package/dist/main.js
CHANGED
|
@@ -147,7 +147,7 @@ program.command("build-plugin").description("Build a plugin the admin app loads
|
|
|
147
147
|
...opts.name && { name: opts.name }
|
|
148
148
|
});
|
|
149
149
|
const shown = path.relative(process.cwd(), outDir);
|
|
150
|
-
out(`built ${shown.startsWith("..") ? outDir : shown || "."}: ${pluginManifestFile}, ${manifest.entry} and ${manifest.css} (${manifest.name}, plugin API ${manifest.api}
|
|
150
|
+
out(`built ${shown.startsWith("..") ? outDir : shown || "."}: ${pluginManifestFile}, ${manifest.entry} and ${manifest.css} (${manifest.name}, plugin API ${manifest.api}${manifest.protobase ? `, Protobase ${manifest.protobase}` : ""})\n`);
|
|
151
151
|
});
|
|
152
152
|
program.command("build-shell", { hidden: true }).description("Build the admin app every bundle shares, as @protobase/ui's package and the protobase image ship it").argument("<out>", "output folder").option("--source-maps <dir>", "end each script with a //# debugId= comment and write its source map, carrying the same id, to this folder").action(async (outDir, opts) => {
|
|
153
153
|
const { buildShell } = await import("./build/shell.js");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.120.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.120.0",
|
|
47
|
+
"@protobase/layout": "0.120.0",
|
|
48
|
+
"@protobase/query": "0.120.0",
|
|
49
|
+
"@protobase/schema": "0.120.0",
|
|
50
|
+
"@protobase/server": "0.120.0",
|
|
51
|
+
"@protobase/ui": "0.120.0",
|
|
52
|
+
"@protobase/workflows": "0.120.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",
|
|
@@ -11,10 +11,11 @@ The page of one record, with its sections, related records, galleries, charts an
|
|
|
11
11
|
- [Record pages that open another](../reference/ui-config.md#a-record-page-that-opens-another): A record's page opens another address built from its fields in its place, such as a workflow run opening its workflow's page with the run shown.
|
|
12
12
|
- [Record page opens elsewhere](../reference/ui-config.md#open-elsewhere) (beta): A view can send its record's address to another page its fields name, such as a message opening in its conversation, so search results and links land where the record is read.
|
|
13
13
|
- [Full-area record pages](../reference/ui-config.md#full-area-record-pages) (beta): A view draws its record pages with a component of its own that fills the area beside the sidebar and under the top bar, such as a chat channel, and links to the standard page.
|
|
14
|
+
- [Conversation pages](../reference/ui-config.md#conversation-pages) (beta): A record's page is its conversation, configured with no component of your own: a header with its title, topic and details, its messages grouped by day and author with mentions and edits shown, and a box that sends one, opening on a New messages line at the reader's place, on the web and at mobile width.
|
|
14
15
|
- [Read view and edit](../reference/ui-config.md#read-view-and-edit): A record opens as a read-only fact sheet or a form, and Edit opens the form at its own address.
|
|
15
16
|
- [Unsaved edits](../reference/ui-config.md#editing-a-record): Unsaved changes to a record stay in the browser and can be resumed, and leaving a form, a dialog or a comment with changes asks first.
|
|
16
17
|
- [Record forms](../reference/ui-config.md#editing-a-record): Relations are picked from a list that narrows as you type, numbers are read as the browser's language writes them, and a refused save says under each field what is wrong.
|
|
17
|
-
- [Titles per reader](../reference/ui-config.md#titles-per-reader): A record without a name of its own, such as a direct message, is titled for each reader from its fields, such as after the other members, in the sidebar, heading, browser tab, relation links, list columns, relation pickers, filters and search.
|
|
18
|
+
- [Titles per reader](../reference/ui-config.md#titles-per-reader): A record without a name of its own, such as a direct message, is titled for each reader from its fields, such as after the other members with the built-in `members` rule, in the sidebar, heading, browser tab, relation links, list columns, relation pickers, filters and search.
|
|
18
19
|
- [JSON fields on forms](../reference/plugins.md#json) (beta): A JSON field, such as a workflow run's input, is edited on forms as JSON text and shown written out on several lines.
|
|
19
20
|
- [Member fields](../reference/plugins.md#members): A field that holds a list of people, such as a private channel's members, picks the organization's members by name on forms and shows them by avatar and name.
|
|
20
21
|
- [Save feedback](../reference/ui-config.md#the-record-page): A view shows saving on the Save button instead of in a toast.
|
|
@@ -23,7 +23,8 @@ React components, field types, pages and handlers of your own, loaded as plugins
|
|
|
23
23
|
- [Shell slots](../reference/custom-components.md#shell-slots): Your own components in the top bar, in a panel beside every page, or as the sidebar logo.
|
|
24
24
|
- [Plugins](../reference/plugins.md#how-a-plugin-stays-working): Your React code is a plugin that the app loads at start and that keeps working across Protobase releases without changes.
|
|
25
25
|
- [Plugin settings](../reference/plugins.md#loading): Plugins are loaded from the config, limited to roles and given settings.
|
|
26
|
-
- [
|
|
26
|
+
- [Plugins load where the app has what they use](../reference/plugins.md#versions): The plugin build records the Protobase exports and extension points a plugin needs, and an app turns a plugin off when one is missing, naming it, rather than for its version; the plugin API and a range the plugin names itself still count.
|
|
27
|
+
- [Plugin fallbacks](../reference/plugins.md#when-a-plugin-is-off): A plugin that fails or does not fit the app is turned off alone, and admins see why.
|
|
27
28
|
- [Before sign-in](../reference/plugins.md#before-sign-in): A plugin can run around the sign-in page, for example to sign someone in from a link.
|
|
28
29
|
- [Unstable modules](../reference/plugins.md#the-unstable-entry): UI with its own build imports any module of the app's UI, without a promise that it stays the same, instead of copying it.
|
|
29
30
|
- [Focus page parts](../reference/custom-components.md#focus-pages) (beta): Fill a focus page's bar, notice and side panels from your own surface or component, with the record's draft and Save from the framework.
|
|
@@ -77,17 +77,18 @@ bun run protobase build-plugin
|
|
|
77
77
|
```
|
|
78
78
|
|
|
79
79
|
```
|
|
80
|
-
built dist: plugin.json, assets/index-DDnoullN.js and assets/styles-CToS5pKa.css (sales-tools, plugin API 1
|
|
80
|
+
built dist: plugin.json, assets/index-DDnoullN.js and assets/styles-CToS5pKa.css (sales-tools, plugin API 1)
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
-
`dist/assets/index-<hash>.js` is the plugin's module: its own code, with `react`, `react/jsx-runtime`, `react-dom` and `@protobase/ui` left as imports for the app to supply. `styles-<hash>.css` holds the utilities its classes use, and nothing else. `plugin.json` names both, the plugin API they are built for and the
|
|
83
|
+
`dist/assets/index-<hash>.js` is the plugin's module: its own code, with `react`, `react/jsx-runtime`, `react-dom` and `@protobase/ui` left as imports for the app to supply. `styles-<hash>.css` holds the utilities its classes use, and nothing else. `plugin.json` names both, the plugin API they are built for and what the plugin uses from the app, which the app checks it has before it loads the plugin:
|
|
84
84
|
|
|
85
85
|
```json
|
|
86
86
|
{
|
|
87
87
|
"name": "sales-tools",
|
|
88
88
|
"version": "1.0.0",
|
|
89
89
|
"api": 1,
|
|
90
|
-
"protobase": "
|
|
90
|
+
"imports": { "@protobase/ui": ["RecordLink", "definePlugin", "useList", "usePlugin"], "react/jsx-runtime": ["jsx", "jsxs"] },
|
|
91
|
+
"extensionPoints": ["components"],
|
|
91
92
|
"entry": "assets/index-DDnoullN.js",
|
|
92
93
|
"css": "assets/styles-CToS5pKa.css"
|
|
93
94
|
}
|
|
@@ -163,4 +164,4 @@ Put `dist/` on a static host, and list its `plugin.json` in the deployed app's `
|
|
|
163
164
|
|
|
164
165
|
The app updates to a new release of Protobase. Nothing happens to the plugin: within plugin API 1, every release keeps what the plugin imports, and the plugin runs on the newer `@protobase/ui` it is handed, its fixes included.
|
|
165
166
|
|
|
166
|
-
If the app
|
|
167
|
+
If the app lacked something the plugin uses, such as an export of `@protobase/ui` from a newer release, it would not load the plugin at all. Its admins would see a notice below the top bar naming what is missing, such as "The plugin sales-tools is off: it uses what this app does not have: useList from @protobase/ui.", and the card would show a warning in place of the drafts, while the rest of the app works as before. [Versions](../reference/plugins.md#versions) has the rules.
|
|
@@ -62,4 +62,4 @@ Nothing changes: `protobase dev` builds `protobase.ui.tsx` into its page with ho
|
|
|
62
62
|
|
|
63
63
|
## After the move
|
|
64
64
|
|
|
65
|
-
From now on, a release of Protobase within the same minor needs no rebuild of the project's UI: the app it runs in is the release's, and the plugin keeps working within its [plugin API](../reference/plugins.md#versions). The server config runs on the runtime the project is pinned to (see [Bundles and runtimes](../reference/versioning.md#bundles-and-runtimes)), so moving the pin to a new minor below 1.0 is still a rebuild.
|
|
65
|
+
From now on, a release of Protobase within the same minor needs no rebuild of the project's UI: the app it runs in is the release's, and the plugin keeps working within its [plugin API](../reference/plugins.md#versions). A plugin built on a newer release also loads in an app on an older one, as long as that app is on the plugin's plugin API, has every export and extension point the plugin uses, and is in the `engines.protobase` range of the plugin's `package.json` when it names one. The server config runs on the runtime the project is pinned to (see [Bundles and runtimes](../reference/versioning.md#bundles-and-runtimes)), so moving the pin to a new minor below 1.0 is still a rebuild.
|
|
@@ -282,7 +282,7 @@ By default the bundle runs on Node and on Bun. `--bun` makes it a bundle for Bun
|
|
|
282
282
|
"api": ["/api", "/.well-known/oauth-authorization-server", "/.well-known/oauth-protected-resource", "/.well-known/openid-configuration"],
|
|
283
283
|
"theme": "protobase.theme.css",
|
|
284
284
|
"plugins": [
|
|
285
|
-
{ "name": "app", "path": "plugins/app/plugin.json", "api": 1, "
|
|
285
|
+
{ "name": "app", "path": "plugins/app/plugin.json", "api": 1, "fields": { "steps": ["enum"] } }
|
|
286
286
|
],
|
|
287
287
|
"shell": { "protobase": "0.12.0", "pluginApi": 1, "paths": ["/index.html", "/assets", "/protobase.sw.js"] },
|
|
288
288
|
"native": { "@capacitor/core": "8.5.3", "@capacitor/ios": "8.5.3" },
|
|
@@ -294,7 +294,7 @@ By default the bundle runs on Node and on Bun. `--bun` makes it a bundle for Bun
|
|
|
294
294
|
|
|
295
295
|
- `protobase` is the Protobase version of the copies the build used: the building CLI's own in a bundled project, and in a locked one the `@protobase` packages its lockfile installed, whichever CLI built the bundle. A host serves the bundle on the runtime of that version (see [Versioning](versioning.md#bundles-and-runtimes)). A bundled project needs nothing installed; a locked one fails without its `@protobase` packages installed.
|
|
296
296
|
- `server`, `public`, `nodeModules` and `migrations` are relative to the bundle folder; `spa`, `theme` and each plugin's `path` to `public`.
|
|
297
|
-
- `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
|
|
297
|
+
- `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 it is built for, the Protobase versions it is limited to only when its `package.json` names some, 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.
|
|
298
298
|
- `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.
|
|
299
299
|
- `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.
|
|
300
300
|
- `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 `appId`, which the statement of a signed mobile release binds, its `plugins`, name to the spec it gives, `{}` when it gives none, and `push`, whether the config has [`notifications()`](notifications.md), with which the binaries compile native push in; the fingerprint of the mobile release names both besides `native`. A bundle built before it names no `appId`, and one built before `push` none, which counts as `false`. The build checks the section as `protobase mobile` does.
|
|
@@ -422,7 +422,7 @@ dist/
|
|
|
422
422
|
- The output folder is emptied first, so it must not be the plugin's folder or hold it.
|
|
423
423
|
- The module is `protobase.ui.tsx` with everything it imports bundled, except the four modules the app shares (`react`, `react/jsx-runtime`, `react-dom`, `@protobase/ui`), which stay imports by those names. Any other module of those packages, such as `react-dom/client`, fails the build. React's production build and JSX runtime are used, whatever `NODE_ENV` says, and every export of `protobase.ui.tsx` is kept.
|
|
424
424
|
- The stylesheet is Tailwind's utilities for the classes in the plugin's folder: no reset, no theme values. Each utility reads the theme of the app that loads it, with Tailwind's default as the fallback (`text-sm` is `font-size: var(--text-sm, 0.875rem)`).
|
|
425
|
-
- `plugin.json` names the plugin (`--name`, else its `package.json`'s `name`, else its folder's), its own `version`, the plugin API (`api`) and the Protobase versions
|
|
425
|
+
- `plugin.json` names the plugin (`--name`, else its `package.json`'s `name`, else its folder's), its own `version`, the plugin API it is built for (`api`), what it uses (`imports` and `extensionPoints`), the Protobase versions its `package.json` names in `engines.protobase`, if any (`protobase`), the module (`entry`) and stylesheet (`css`), relative to it, and the [field types](plugins.md#field-types) it registers (`fields`), each with the storage types it shows. `api` and the extension points come from the `@protobase/ui` installed for the plugin, else for the project it extends, else the CLI's own (see [Plugins](plugins.md#versions)).
|
|
426
426
|
- `--source-maps` ends each script with a `//# debugId=<uuid>` comment, naming no map, and writes its source map, `<script>.js.map` carrying the same `debugId`, beside it, for an error tracker to read the browser's stack frames with.
|
|
427
427
|
|
|
428
428
|
To read its field types, the build loads the plugin's module once in Node, with everything bundled; nothing is rendered, but code at the top level of its modules runs, so keep browser-only work (`window`, `document`) inside components and handlers. The app loads it from wherever `plugin.json` is served, listed in `PROTOBASE_PLUGINS` or the config's `plugins` (see [loading](plugins.md#loading)).
|
|
@@ -25,7 +25,7 @@ Code built together with the app is frozen at the app it was built with: a newer
|
|
|
25
25
|
1. **The app is built once per release.** The admin app, the shell, is the same for every project. Each release of `@protobase/ui` ships it prebuilt, and `protobase build` copies it into the bundle beside the project's plugins and theme. A host that has the shell of a newer release can serve that one in its place (see [the shell](#the-shell)), so an app gets the release's fixes without a rebuild of its own code.
|
|
26
26
|
2. **The app shares its modules.** The admin app hands four modules to plugins: `react`, `react/jsx-runtime`, `react-dom` and `@protobase/ui`. Its `index.html` maps those names to the app's own files with an [import map](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap), so a plugin's `import { useList } from '@protobase/ui'` runs on the app's copy: one React, one query cache, one signed-in session and the app's version of every hook and component. A plugin carries only its own code, and gets the fixes of every release the app moves to.
|
|
27
27
|
3. **The plugin API is a promise.** What a plugin can import, the four modules and every export of `@protobase/ui`, is the plugin API, numbered: `pluginApi` is 1. Releases add to it but never remove or change what is in it; only a new plugin API does, as for a new major version of React. So a plugin keeps working on every release of the plugin API it was built for, with no rebuild. Below 1.0 a minor release may change how a project's config is written, but not the plugin API.
|
|
28
|
-
4. **The app checks before it loads.** A plugin's `plugin.json` says which plugin API and
|
|
28
|
+
4. **The app checks before it loads.** A plugin's `plugin.json` says which plugin API it is built for and what it uses: the names it imports from the shared modules and the extension points it fills. The app loads a plugin only when it has that plugin API and everything the plugin uses, whichever release built the plugin; it never runs the code of one that does not fit.
|
|
29
29
|
5. **A plugin that does not fit is turned off, not the app.** Each place it would fill draws a fallback, the app's admins see why it is off, and everything else works as before. A component that throws while drawing shows its fallback in its own place.
|
|
30
30
|
6. **The look is values, not rules.** A project themes the app with a [`protobase.theme.css`](theme.md) that holds only values of the app's tokens, and a plugin's stylesheet holds only utilities that read those tokens. Neither reaches into the app's markup, so neither breaks when the app's markup changes.
|
|
31
31
|
|
|
@@ -72,7 +72,7 @@ export default definePlugin({ name: 'sales-tools', actions: { remindCustomer } }
|
|
|
72
72
|
|
|
73
73
|
It is written as a project's `protobase.ui.tsx` is: each component exported under the PascalCase name the config declares, from a file of its own, and the rest in the default export, `definePlugin({ name, actions, fields, shell, beforeSignIn, extends, ... })` (`defineUi` is the same function), with the keys of [Extension points](#extension-points). Its components use the hooks and components of `@protobase/ui`, which read the API as the signed-in user, under the same access rules as everything else.
|
|
74
74
|
|
|
75
|
-
**Imports.** `react`, `react/jsx-runtime` (the JSX), `react-dom` and `@protobase/ui`, by those names, come from the app. Everything else a plugin imports, its own files, icons or a chart library, is built into it. Other modules of those packages, such as `react-dom/client` or a file inside `@protobase/ui`, fail the build: a copy of its own would not work with the app's. Read data with `@protobase/ui`'s hooks (`useList`, `useRecord`, `useClient`), which share the app's cache: a data library of the plugin's own keeps a cache of its own. For anything else, such as another API's answer, `useQuery` and `useQueryClient` from `@protobase/ui` are TanStack Query's, on the app's own client, so their answers are kept in the [start cache](installable-app.md#starting-from-the-last-pages-seen) and draw on the next start before the network answers.
|
|
75
|
+
**Imports.** `react`, `react/jsx-runtime` (the JSX), `react-dom` and `@protobase/ui`, by those names, come from the app. Everything else a plugin imports, its own files, icons or a chart library, is built into it. Other modules of those packages, such as `react-dom/client` or a file inside `@protobase/ui`, fail the build: a copy of its own would not work with the app's. So does taking all of `@protobase/ui` at once (`import * as`, `export *` or `import()`), since the app could not check that it has the names the plugin reads: import them by name. Read data with `@protobase/ui`'s hooks (`useList`, `useRecord`, `useClient`), which share the app's cache: a data library of the plugin's own keeps a cache of its own. For anything else, such as another API's answer, `useQuery` and `useQueryClient` from `@protobase/ui` are TanStack Query's, on the app's own client, so their answers are kept in the [start cache](installable-app.md#starting-from-the-last-pages-seen) and draw on the next start before the network answers.
|
|
76
76
|
|
|
77
77
|
**Styling.** Use Tailwind classes, as the app's own code does. The plugin's stylesheet holds the utilities its files use and nothing else, no reset and no global style, and each reads the app's [tokens](theme.md): `bg-primary` is the app's primary color and `rounded-md` its radius, whatever the app's version and whatever its theme, and a token the app does not set falls back to Tailwind's default.
|
|
78
78
|
|
|
@@ -233,7 +233,8 @@ The output folder is emptied first, so it must not hold the plugin's own files.
|
|
|
233
233
|
"name": "sales-tools",
|
|
234
234
|
"version": "1.0.0",
|
|
235
235
|
"api": 1,
|
|
236
|
-
"protobase": "
|
|
236
|
+
"imports": { "@protobase/ui": ["definePlugin", "useList"], "react/jsx-runtime": ["jsx", "jsxs"] },
|
|
237
|
+
"extensionPoints": ["components", "fields"],
|
|
237
238
|
"entry": "assets/index-DDnoullN.js",
|
|
238
239
|
"css": "assets/styles-CToS5pKa.css",
|
|
239
240
|
"fields": { "steps": ["enum"] }
|
|
@@ -245,7 +246,9 @@ The output folder is emptied first, so it must not hold the plugin's own files.
|
|
|
245
246
|
| `name` | The plugin's name: `--name`, else its `package.json`'s `name`, else its folder's. A project's own is `app`. |
|
|
246
247
|
| `version` | Its `package.json`'s `version`, when it has one. |
|
|
247
248
|
| `api` | The plugin API of the `@protobase/ui` it is built with. |
|
|
248
|
-
| `
|
|
249
|
+
| `imports` | The names its built code imports from each module the app shares, `*` for a whole module of React (`import * as`, `import()`); code the build leaves out does not count (see [versions](#versions)). |
|
|
250
|
+
| `extensionPoints` | The [extension points](#extension-points) it fills, such as `components` or `shell.rightPanel`. |
|
|
251
|
+
| `protobase` | The Protobase versions its `package.json` names in `engines.protobase`, only when it names some (see [versions](#versions)). |
|
|
249
252
|
| `entry`, `css` | The module and the stylesheet, relative to `plugin.json`. |
|
|
250
253
|
| `fields` | The field types it registers, each with the storage types it shows. Only when it registers some. |
|
|
251
254
|
|
|
@@ -345,18 +348,23 @@ A host that keeps the shells of its releases can serve the shell of a newer one
|
|
|
345
348
|
|
|
346
349
|
## Versions
|
|
347
350
|
|
|
348
|
-
A plugin is built for one plugin API and
|
|
351
|
+
A plugin is built for one plugin API and records what it uses, both written by `build-plugin` into `plugin.json`:
|
|
349
352
|
|
|
350
353
|
- `api` is the plugin API of the `@protobase/ui` installed for the plugin, else the CLI's own (always the CLI's for the UI of a bundled project).
|
|
351
|
-
- `
|
|
354
|
+
- `imports` names what the plugin's built code imports from `react`, `react/jsx-runtime`, `react-dom` and `@protobase/ui`, read from the build's output, so an import only an unused file or a re-export nobody reads makes is not in it, and one its own files make is.
|
|
355
|
+
- `extensionPoints` names the extension points its config fills, as that `@protobase/ui` reads them.
|
|
352
356
|
|
|
353
|
-
|
|
354
|
-
{ "engines": { "protobase": ">=0.12.0" } }
|
|
355
|
-
```
|
|
357
|
+
The app loads a plugin when the plugin's `api` is its own and it has every name in `imports` and every extension point in `extensionPoints`, whatever its version; only a plugin that names a `protobase` range also needs the app's version in it. A plugin built with a newer `@protobase/ui` loads in an app on an older release that checks what plugins use, as long as the older release has what the plugin uses; when something is missing, the plugin stays off and its notice names what, such as "it uses what this app does not have: NewPicker from @protobase/ui, the extension point shell.bell". Releases from before that check compare versions only: they need a `protobase` range in `plugin.json`, turn off a plugin without one, and do not read `imports` or `extensionPoints`.
|
|
356
358
|
|
|
357
|
-
|
|
359
|
+
A plugin author who wants to limit the plugin to some releases anyway names a range in its `package.json`, which the build copies into `plugin.json` as `protobase`:
|
|
358
360
|
|
|
359
|
-
|
|
361
|
+
```json
|
|
362
|
+
{ "engines": { "protobase": ">=0.12.0 <2.0.0" } }
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
The app then also needs its version in that range. A range is comparators separated by spaces, all of which must hold: `>=`, `>`, `<=`, `<` or `=` and an `x.y.z` version. The build checks only the range's form; which versions it holds is the app's to compare when it loads the plugin, where a prerelease such as a build from main counts too, just before its own release: `0.94.4-main.4f8859dd` is in `>=0.12.9`, and `0.13.0-main.4f8859dd` is in `<0.13.0` but not in `>=0.13.0`.
|
|
366
|
+
|
|
367
|
+
Protobase keeps the plugin API through its releases and starts a new one only when a plugin built for the old one could break:
|
|
360
368
|
|
|
361
369
|
- an export of `@protobase/ui` removed, or changed in a way its users would notice;
|
|
362
370
|
- an extension point's props changed in a way a plugin would notice;
|
|
@@ -371,10 +379,11 @@ Nothing a plugin does stops the app. Each of these turns off that plugin alone:
|
|
|
371
379
|
|
|
372
380
|
- its `plugin.json` cannot be read, or is not one;
|
|
373
381
|
- it is built for another plugin API, or for a range without the app's version;
|
|
382
|
+
- it uses an export, a shared module or an extension point the app does not have;
|
|
374
383
|
- its module cannot be loaded, or does not link: it imports something the app's `@protobase/ui` does not have;
|
|
375
384
|
- it defines a name an earlier plugin defines.
|
|
376
385
|
|
|
377
|
-
Every place it would fill then draws its fallback (see [Extension points](#extension-points)). The app's admins (the `admin` role) see a notice below the top bar naming each plugin that is off and why, such as "The plugin sales-tools is off: it
|
|
386
|
+
Every place it would fill then draws its fallback (see [Extension points](#extension-points)). The app's admins (the `admin` role) see a notice below the top bar naming each plugin that is off and why, such as "The plugin sales-tools is off: it uses what this app does not have: NewPicker from @protobase/ui." Everyone else sees only the fallbacks. An action handler that throws shows its error in a toast, as a project's does, and a part that throws while drawing shows its fallback in its own place.
|
|
378
387
|
|
|
379
388
|
## API
|
|
380
389
|
|
|
@@ -85,6 +85,8 @@ export default defineUi({
|
|
|
85
85
|
})
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
+
The rule `members` is built in and needs no function: `.titleFrom('members', (r) => [r.member_ids])` names the record after the people in a JSON field of user ids other than the reader, in the order they were added, joined by commas. A [conversation page](#conversation-pages) with `members` titles its record this way unless the view sets its own `.titleFrom`.
|
|
89
|
+
|
|
88
90
|
The derived title names the record wherever `.title` would: the sidebar's [recent records](sidebar.md#recent-records), whose list request reads the picked fields too, the record page's heading, the browser tab, the links of a record page's relation fields, related cards, the global search, unless the view's `.searchResult` gives a title, and every relation that points at such a record: a list's relation column and a card's relation field, which read the picked fields of a page's records in one request, the relation picker's options and a relation filter's values. The picker's typed text still matches the resource's search fields, or, without any, the derived titles of the records it loads. The record's key shows while the function returns nothing, such as while the members' names load, and when the reader cannot read a field it picks, or the UI config registers no function of that name. It is presentation only: no field, filter or sort reads it, and the search does not match it. Other members' names come only with organizations; without them, `member` finds no one.
|
|
89
91
|
|
|
90
92
|
<gap>An export of shown values and a chart grouped by a relation cannot name a record by its derived title because titling them per reader is not implemented.</gap>
|
|
@@ -770,6 +772,52 @@ view<typeof channels>('channels').record({ component: ChannelChat })
|
|
|
770
772
|
|
|
771
773
|
The standard record page, with the layout's sections, the related records, Edit and Delete, stays at the record's address with `?standard=true` (`{ kind: 'record', resource, key, standard: true }`), which the component links to. Links to the record, from relations, search and notifications, open the component's page. Without the component, from a plugin that is off for instance, and when it throws, the standard page shows instead. <gap>A full-area record component cannot take props from the view because props for `.record` are not implemented.</gap>
|
|
772
774
|
|
|
775
|
+
### Conversation pages
|
|
776
|
+
|
|
777
|
+
:::caution[Beta]
|
|
778
|
+
A conversation page shows each message's text with its mentions and keeps line breaks, without markdown; it has no replies in threads, reactions, editing, deleting, files or calls yet.
|
|
779
|
+
:::
|
|
780
|
+
|
|
781
|
+
`.record({ conversation })` makes the record page the record's conversation, for a record that holds one, such as a chat channel, a direct message or a support case, with no component of the app's own. It fills the content area as a [full-area record page](#full-area-record-pages) does, on the web and at mobile width: a header row, the messages that point at the record, and a box that sends one, which stays in view while the messages scroll above it.
|
|
782
|
+
|
|
783
|
+
```ts
|
|
784
|
+
view<typeof channels>('channels').record({
|
|
785
|
+
conversation: {
|
|
786
|
+
resource: 'messages',
|
|
787
|
+
field: 'channel_id',
|
|
788
|
+
sender: 'author_id',
|
|
789
|
+
time: 'sent_at',
|
|
790
|
+
text: 'body',
|
|
791
|
+
edited: 'edited_at',
|
|
792
|
+
mentions: 'mentions',
|
|
793
|
+
subtitle: 'topic',
|
|
794
|
+
readPosition: { resource: 'read_positions', field: 'channel_id', message: 'last_read_id' },
|
|
795
|
+
placeholder: 'Message the channel',
|
|
796
|
+
},
|
|
797
|
+
})
|
|
798
|
+
```
|
|
799
|
+
|
|
800
|
+
| `conversation` option | |
|
|
801
|
+
| --- | --- |
|
|
802
|
+
| `resource` | The message resource. |
|
|
803
|
+
| `field` | The filterable relation of the messages that holds the record's key; each message sent gets it too. |
|
|
804
|
+
| `sender` | Who wrote each message: a relation, named as the record it points at, or a text field of user ids, such as the resource's `.author()`, named after the organization's members. |
|
|
805
|
+
| `time` | When each message was sent: a sortable date or timestamp field. |
|
|
806
|
+
| `text` | The message: a text field the sender may set. |
|
|
807
|
+
| `edited` | A date or timestamp field set when a message changes: a changed message says "(edited)", with the time on hover. |
|
|
808
|
+
| `mentions` | A JSON field for the user ids a message mentions: `@` in the box lists the organization's members by name, the ids of those picked land in it, and the text shows each mention picked out. |
|
|
809
|
+
| `subtitle` | A text field of the record shown beside its title, such as a channel's topic. |
|
|
810
|
+
| `members` | A JSON field of the record holding user ids: the header names the other people in it, each with their presence and [status](status.md#in-the-app), the status text in full beside one person and on hover beside several. The record is titled after them everywhere, as the [`members` title rule](#titles-per-reader) does. |
|
|
811
|
+
| `readPosition` | Where each reader's read position is kept: `{ resource, field, message }`. |
|
|
812
|
+
| `placeholder` | The hint in the empty box. |
|
|
813
|
+
| `empty` | What the conversation says while it has no messages. |
|
|
814
|
+
|
|
815
|
+
The header shows the record's title, which the top bar repeats at mobile width and so shows there only with `members`, the subtitle, and *Details*, a link to the record's standard page at `?standard=true`, with its sections, Edit and Delete. The latest 50 messages show oldest first, with *Load earlier messages* at the top for more. A day divider opens each day, and one person's messages sent within five minutes of each other show under their name once. A message resource with [`.live()`](live.md) shows new, changed and deleted messages as they happen. Every read goes through the reader's own access: a message they may not read never shows, and a reader who may not read the messages or a field each one needs gets the standard page. The box shows for a reader who may create messages.
|
|
816
|
+
|
|
817
|
+
With `readPosition`, the conversation opens on a *New messages* line above the first message someone else wrote since the reader's position, and moves the position to the newest message whenever they read to the end. The read position resource keeps one record per reader and record: its `.author()` is the reader, `field` is a relation to the record and `message` an integer field holding the key of the newest message read, so the message resource's key is one integer column that grows as messages arrive. The page reads and writes only the reader's own position. Without `readPosition`, there is no line and nothing is written.
|
|
818
|
+
|
|
819
|
+
<gap>A conversation page cannot open at a given message, such as a search result, because opening a conversation at a message is not implemented.</gap> <gap>A conversation page cannot show a message's markdown because rendering markdown together with mentions is not implemented.</gap>
|
|
820
|
+
|
|
773
821
|
### Focus pages
|
|
774
822
|
|
|
775
823
|
:::caution[Beta]
|
|
@@ -87,7 +87,7 @@ Nothing else compares versions: not the build, not the serve runtime. `protobase
|
|
|
87
87
|
|
|
88
88
|
## Plugins
|
|
89
89
|
|
|
90
|
-
[Plugins](plugins.md) are versioned by a plugin API of their own: `@protobase/ui`'s `pluginApi`, 1 so far. A plugin's `plugin.json` names the plugin API it is built for and
|
|
90
|
+
[Plugins](plugins.md) are versioned by a plugin API of their own: `@protobase/ui`'s `pluginApi`, 1 so far. A plugin's `plugin.json` names the plugin API it is built for and what it uses: the names it imports from the modules the app shares and the extension points it fills. An app loads a plugin of its own plugin API when it has everything the plugin uses, whichever release built it, and turns off any other, telling its admins what is missing. A plugin whose author names a range of Protobase versions (`engines.protobase`) also needs the app's version in it (see [versions](plugins.md#versions)).
|
|
91
91
|
|
|
92
92
|
A project's own `protobase.ui.tsx` is a plugin of its bundle, so the same rule holds for it. The admin app it runs in, the shell, is prebuilt once per release; a host that serves a newer release's shell for a bundle whose plugins all load in it gives the app that release's fixes without a rebuild (see [the shell](plugins.md#the-shell)).
|
|
93
93
|
|