@skillcdn/console 0.4.0 → 0.4.2
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/README.md +20 -2
- package/SKILLCDN.md +7 -5
- package/dist/api.d.ts +5 -4
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +5 -4
- package/dist/api.js.map +1 -1
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +579 -45
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/format.d.ts +34 -3
- package/dist/cli/format.d.ts.map +1 -1
- package/dist/cli/format.js +277 -6
- package/dist/cli/format.js.map +1 -1
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +60 -7
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/plugin-check.d.ts +21 -0
- package/dist/cli/plugin-check.d.ts.map +1 -0
- package/dist/cli/plugin-check.js +374 -0
- package/dist/cli/plugin-check.js.map +1 -0
- package/dist/cli/plugin-cli.d.ts +20 -0
- package/dist/cli/plugin-cli.d.ts.map +1 -0
- package/dist/cli/plugin-cli.js +123 -0
- package/dist/cli/plugin-cli.js.map +1 -0
- package/dist/cli/plugin-init.d.ts +20 -0
- package/dist/cli/plugin-init.d.ts.map +1 -0
- package/dist/cli/plugin-init.js +74 -0
- package/dist/cli/plugin-init.js.map +1 -0
- package/dist/cli/plugin-main.d.ts +3 -0
- package/dist/cli/plugin-main.d.ts.map +1 -0
- package/dist/cli/plugin-main.js +28 -0
- package/dist/cli/plugin-main.js.map +1 -0
- package/dist/client.d.ts +109 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +67 -2
- package/dist/client.js.map +1 -1
- package/dist/compat.d.ts +1 -1
- package/dist/compat.js +2 -2
- package/dist/components/board.d.ts +8 -0
- package/dist/components/board.d.ts.map +1 -1
- package/dist/components/board.js +59 -15
- package/dist/components/board.js.map +1 -1
- package/dist/components/event-feed.d.ts +1 -1
- package/dist/components/event-feed.d.ts.map +1 -1
- package/dist/components/event-feed.js +33 -1
- package/dist/components/event-feed.js.map +1 -1
- package/dist/components/markdown.d.ts.map +1 -1
- package/dist/components/markdown.js +6 -3
- package/dist/components/markdown.js.map +1 -1
- package/dist/components/pack-connect.d.ts +3 -1
- package/dist/components/pack-connect.d.ts.map +1 -1
- package/dist/components/pack-connect.js +4 -4
- package/dist/components/pack-connect.js.map +1 -1
- package/dist/components/pack-token.d.ts +3 -1
- package/dist/components/pack-token.d.ts.map +1 -1
- package/dist/components/pack-token.js +1 -1
- package/dist/components/pack-token.js.map +1 -1
- package/dist/components/people.d.ts.map +1 -1
- package/dist/components/people.js +14 -3
- package/dist/components/people.js.map +1 -1
- package/dist/components/plugin-frame.d.ts +52 -0
- package/dist/components/plugin-frame.d.ts.map +1 -0
- package/dist/components/plugin-frame.js +314 -0
- package/dist/components/plugin-frame.js.map +1 -0
- package/dist/components/plugin-settings.d.ts +38 -0
- package/dist/components/plugin-settings.d.ts.map +1 -0
- package/dist/components/plugin-settings.js +348 -0
- package/dist/components/plugin-settings.js.map +1 -0
- package/dist/components/remote-pictures.d.ts +6 -0
- package/dist/components/remote-pictures.d.ts.map +1 -0
- package/dist/components/remote-pictures.js +8 -0
- package/dist/components/remote-pictures.js.map +1 -0
- package/dist/components/shell.d.ts +2 -0
- package/dist/components/shell.d.ts.map +1 -1
- package/dist/components/shell.js +26 -1
- package/dist/components/shell.js.map +1 -1
- package/dist/components/sign-in.d.ts.map +1 -1
- package/dist/components/sign-in.js +49 -2
- package/dist/components/sign-in.js.map +1 -1
- package/dist/components/ui.d.ts +3 -2
- package/dist/components/ui.d.ts.map +1 -1
- package/dist/components/ui.js +6 -3
- package/dist/components/ui.js.map +1 -1
- package/dist/components/workspace.d.ts +7 -1
- package/dist/components/workspace.d.ts.map +1 -1
- package/dist/components/workspace.js +1 -1
- package/dist/components/workspace.js.map +1 -1
- package/dist/console.css +384 -5
- package/dist/console.d.ts.map +1 -1
- package/dist/console.js +146 -29
- package/dist/console.js.map +1 -1
- package/dist/data.d.ts +11 -2
- package/dist/data.d.ts.map +1 -1
- package/dist/data.js +35 -21
- package/dist/data.js.map +1 -1
- package/dist/i18n/en.d.ts +163 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +174 -1
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/ko.d.ts.map +1 -1
- package/dist/i18n/ko.js +154 -1
- package/dist/i18n/ko.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/limits.d.ts +14 -0
- package/dist/limits.d.ts.map +1 -1
- package/dist/limits.js +14 -0
- package/dist/limits.js.map +1 -1
- package/dist/plugin/args.d.ts +148 -0
- package/dist/plugin/args.d.ts.map +1 -0
- package/dist/plugin/args.js +369 -0
- package/dist/plugin/args.js.map +1 -0
- package/dist/plugin/bridge.d.ts +146 -0
- package/dist/plugin/bridge.d.ts.map +1 -0
- package/dist/plugin/bridge.js +125 -0
- package/dist/plugin/bridge.js.map +1 -0
- package/dist/plugin/capabilities.d.ts +20 -0
- package/dist/plugin/capabilities.d.ts.map +1 -0
- package/dist/plugin/capabilities.js +133 -0
- package/dist/plugin/capabilities.js.map +1 -0
- package/dist/plugin/context.d.ts +374 -0
- package/dist/plugin/context.d.ts.map +1 -0
- package/dist/plugin/context.js +2 -0
- package/dist/plugin/context.js.map +1 -0
- package/dist/plugin/define.d.ts +208 -0
- package/dist/plugin/define.d.ts.map +1 -0
- package/dist/plugin/define.js +482 -0
- package/dist/plugin/define.js.map +1 -0
- package/dist/plugin/definition-error.d.ts +11 -0
- package/dist/plugin/definition-error.d.ts.map +1 -0
- package/dist/plugin/definition-error.js +17 -0
- package/dist/plugin/definition-error.js.map +1 -0
- package/dist/plugin/limits.d.ts +67 -0
- package/dist/plugin/limits.d.ts.map +1 -0
- package/dist/plugin/limits.js +70 -0
- package/dist/plugin/limits.js.map +1 -0
- package/dist/plugin/load-worker.d.ts +7 -0
- package/dist/plugin/load-worker.d.ts.map +1 -0
- package/dist/plugin/load-worker.js +41 -0
- package/dist/plugin/load-worker.js.map +1 -0
- package/dist/plugin/load.d.ts +18 -0
- package/dist/plugin/load.d.ts.map +1 -0
- package/dist/plugin/load.js +62 -0
- package/dist/plugin/load.js.map +1 -0
- package/dist/plugin/manifest.d.ts +237 -0
- package/dist/plugin/manifest.d.ts.map +1 -0
- package/dist/plugin/manifest.js +411 -0
- package/dist/plugin/manifest.js.map +1 -0
- package/dist/plugin/refusals.d.ts +49 -0
- package/dist/plugin/refusals.d.ts.map +1 -0
- package/dist/plugin/refusals.js +79 -0
- package/dist/plugin/refusals.js.map +1 -0
- package/dist/plugin/rest-schemas.d.ts +556 -0
- package/dist/plugin/rest-schemas.d.ts.map +1 -0
- package/dist/plugin/rest-schemas.js +262 -0
- package/dist/plugin/rest-schemas.js.map +1 -0
- package/dist/plugin/sandbox.d.ts +23 -0
- package/dist/plugin/sandbox.d.ts.map +1 -0
- package/dist/plugin/sandbox.js +99 -0
- package/dist/plugin/sandbox.js.map +1 -0
- package/dist/plugin/testing.d.ts +45 -0
- package/dist/plugin/testing.d.ts.map +1 -0
- package/dist/plugin/testing.js +420 -0
- package/dist/plugin/testing.js.map +1 -0
- package/dist/plugin/web-react.d.ts +11 -0
- package/dist/plugin/web-react.d.ts.map +1 -0
- package/dist/plugin/web-react.js +34 -0
- package/dist/plugin/web-react.js.map +1 -0
- package/dist/plugin/web.d.ts +95 -0
- package/dist/plugin/web.d.ts.map +1 -0
- package/dist/plugin/web.js +245 -0
- package/dist/plugin/web.js.map +1 -0
- package/dist/plugin-nav.d.ts +29 -0
- package/dist/plugin-nav.d.ts.map +1 -0
- package/dist/plugin-nav.js +92 -0
- package/dist/plugin-nav.js.map +1 -0
- package/dist/plugin-testing.d.ts +2 -0
- package/dist/plugin-testing.d.ts.map +1 -0
- package/dist/plugin-testing.js +4 -0
- package/dist/plugin-testing.js.map +1 -0
- package/dist/plugin-web-react.d.ts +3 -0
- package/dist/plugin-web-react.d.ts.map +1 -0
- package/dist/plugin-web-react.js +3 -0
- package/dist/plugin-web-react.js.map +1 -0
- package/dist/plugin-web.d.ts +4 -0
- package/dist/plugin-web.d.ts.map +1 -0
- package/dist/plugin-web.js +5 -0
- package/dist/plugin-web.js.map +1 -0
- package/dist/plugin.d.ts +11 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +15 -0
- package/dist/plugin.js.map +1 -0
- package/dist/router.d.ts +28 -0
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +47 -0
- package/dist/router.js.map +1 -1
- package/dist/routes.d.ts +6 -0
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +8 -0
- package/dist/routes.js.map +1 -1
- package/dist/schemas.d.ts +147 -1
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +55 -5
- package/dist/schemas.js.map +1 -1
- package/dist/tokens.d.ts +2 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +101 -0
- package/dist/tokens.js.map +1 -0
- package/dist/vocabulary.d.ts +11 -1
- package/dist/vocabulary.d.ts.map +1 -1
- package/dist/vocabulary.js +24 -0
- package/dist/vocabulary.js.map +1 -1
- package/dist/web.d.ts.map +1 -1
- package/dist/web.js +5 -2
- package/dist/web.js.map +1 -1
- package/docs/specs/cli.md +16 -9
- package/docs/specs/plugins.md +487 -0
- package/docs/specs/rest.md +25 -13
- package/package.json +21 -3
- package/skills/building-a-console/SKILL.md +25 -26
- package/skills/building-a-console/references/configuring.md +40 -0
- package/skills/building-a-console/references/the-default-console.md +1 -1
- package/skills/building-a-console/references/the-look-from-a-website.md +5 -5
- package/skills/building-a-plugin/SKILL.md +137 -0
- package/skills/deploying-a-console/SKILL.md +24 -26
- package/skills/deploying-a-console/references/access.md +13 -9
- package/skills/deploying-a-console/references/resources.md +25 -10
- package/skills/deploying-a-console/references/running-it-again.md +15 -0
- package/skills/deploying-a-console/references/sizing.md +2 -0
- package/skills/planning-the-board/SKILL.md +96 -0
- package/skills/planning-the-board/references/a-task.md +36 -0
- package/skills/planning-the-board/references/setting-up.md +44 -0
- package/skills/working-the-board/SKILL.md +43 -34
- package/skills/working-the-board/references/the-pack.md +19 -0
- package/src/api.ts +16 -0
- package/src/cli/cli.ts +736 -45
- package/src/cli/format.ts +356 -9
- package/src/cli/help.ts +71 -6
- package/src/cli/plugin-check.ts +470 -0
- package/src/cli/plugin-cli.ts +148 -0
- package/src/cli/plugin-init.ts +90 -0
- package/src/cli/plugin-main.ts +30 -0
- package/src/client.ts +324 -1
- package/src/compat.ts +2 -2
- package/src/components/board.tsx +62 -14
- package/src/components/event-feed.tsx +42 -1
- package/src/components/markdown.tsx +6 -3
- package/src/components/pack-connect.tsx +10 -7
- package/src/components/pack-token.tsx +4 -1
- package/src/components/people.tsx +17 -7
- package/src/components/plugin-frame.tsx +437 -0
- package/src/components/plugin-settings.tsx +1111 -0
- package/src/components/remote-pictures.ts +19 -0
- package/src/components/shell.tsx +82 -14
- package/src/components/sign-in.tsx +114 -13
- package/src/components/ui.tsx +6 -3
- package/src/components/workspace.tsx +18 -0
- package/src/console.tsx +309 -23
- package/src/data.ts +47 -22
- package/src/i18n/en.ts +183 -1
- package/src/i18n/ko.ts +159 -1
- package/src/index.ts +12 -0
- package/src/limits.ts +14 -0
- package/src/plugin/args.ts +526 -0
- package/src/plugin/bridge.ts +314 -0
- package/src/plugin/capabilities.ts +150 -0
- package/src/plugin/context.ts +416 -0
- package/src/plugin/define.ts +792 -0
- package/src/plugin/definition-error.ts +19 -0
- package/src/plugin/limits.ts +70 -0
- package/src/plugin/load-worker.ts +50 -0
- package/src/plugin/load.ts +82 -0
- package/src/plugin/manifest.ts +561 -0
- package/src/plugin/refusals.ts +94 -0
- package/src/plugin/rest-schemas.ts +354 -0
- package/src/plugin/sandbox.ts +123 -0
- package/src/plugin/testing.ts +612 -0
- package/src/plugin/web-react.ts +45 -0
- package/src/plugin/web.ts +403 -0
- package/src/plugin-nav.ts +132 -0
- package/src/plugin-testing.ts +10 -0
- package/src/plugin-web-react.ts +4 -0
- package/src/plugin-web.ts +35 -0
- package/src/plugin.ts +126 -0
- package/src/router.ts +73 -0
- package/src/routes.ts +9 -0
- package/src/schemas.ts +60 -4
- package/src/styles/console.css +384 -5
- package/src/tokens.ts +101 -0
- package/src/vocabulary.ts +30 -0
- package/src/web.ts +5 -2
- package/template/plugin/.gitignore +2 -0
- package/template/plugin/README.md +26 -0
- package/template/plugin/SKILLCDN.md +13 -0
- package/template/plugin/build.mjs +40 -0
- package/template/plugin/console-plugin.json +50 -0
- package/template/plugin/package.json +27 -0
- package/template/plugin/skills/__key__/SKILL.md +23 -0
- package/template/plugin/src/check.test.ts +34 -0
- package/template/plugin/src/server/index.test.ts +41 -0
- package/template/plugin/src/server/index.ts +72 -0
- package/template/plugin/src/web/index.css +51 -0
- package/template/plugin/src/web/index.ts +115 -0
- package/template/plugin/tsconfig.json +17 -0
- package/skills/working-the-board/references/setting-up.md +0 -3
- /package/skills/{working-the-board → planning-the-board}/references/project-rules.md +0 -0
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { isBridgePath, isBridgeToPage, PLUGIN_BRIDGE_VERSION, } from "../plugin/bridge.js";
|
|
4
|
+
import { MAX_PLUGIN_WIDGET_HEIGHT } from "../plugin/limits.js";
|
|
5
|
+
import { CONSOLE_TOKENS } from "../tokens.js";
|
|
6
|
+
// A plugin's page or widget on the console's page (ADR-0054, docs/specs/plugins.md, "Pages"):
|
|
7
|
+
// a sandboxed frame whose document the console serves, and the console's side of the bridge.
|
|
8
|
+
// The frame speaks over postMessage alone; this component accepts the frame's window alone,
|
|
9
|
+
// performs every call under the plugin's own routes with the person's session, and refuses the
|
|
10
|
+
// rest before any request. Nothing the frame says is rendered as HTML.
|
|
11
|
+
/** How tall a page's frame may grow: far above any page, below what would break the layout. */
|
|
12
|
+
const MAX_PAGE_HEIGHT = 20_000;
|
|
13
|
+
/** How often the plugin's own events are asked for while a frame listens for them. */
|
|
14
|
+
const EVENTS_POLL_MS = 5_000;
|
|
15
|
+
/** A refusal of the bridge, as the frame receives it: the console's code and a message. */
|
|
16
|
+
export class BridgeRefusal extends Error {
|
|
17
|
+
code;
|
|
18
|
+
constructor(code, message) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = "BridgeRefusal";
|
|
21
|
+
this.code = code;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const text = (value, what) => {
|
|
25
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
26
|
+
throw new BridgeRefusal("plugin.invalid_args", `${what} is text`);
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
};
|
|
30
|
+
const record = (value) => typeof value === "object" && value !== null && !Array.isArray(value)
|
|
31
|
+
? value
|
|
32
|
+
: {};
|
|
33
|
+
/**
|
|
34
|
+
* Performs one `call` of the frame through the plugin's own routes and nothing else: a command,
|
|
35
|
+
* a query, the records, the files. The answer, and what to transfer with it; a method the bridge
|
|
36
|
+
* does not know, or a request outside the plugin, is refused before anything is sent.
|
|
37
|
+
*/
|
|
38
|
+
export async function performBridgeCall(plugin, projectKey, call) {
|
|
39
|
+
const params = record(call.params);
|
|
40
|
+
const project = projectKey === undefined ? {} : { project: projectKey };
|
|
41
|
+
switch (call.method) {
|
|
42
|
+
case "command": {
|
|
43
|
+
const name = text(params.name, "name");
|
|
44
|
+
return {
|
|
45
|
+
value: await plugin.command(name, { args: record(params.args), ...project }),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
case "query": {
|
|
49
|
+
const name = text(params.name, "name");
|
|
50
|
+
return { value: await plugin.query(name, record(params.args), project) };
|
|
51
|
+
}
|
|
52
|
+
case "records.list": {
|
|
53
|
+
const collection = text(params.collection, "collection");
|
|
54
|
+
return {
|
|
55
|
+
value: await plugin.records(collection, {
|
|
56
|
+
where: params.where === undefined ? undefined : record(params.where),
|
|
57
|
+
order: typeof params.order === "string" ? params.order : undefined,
|
|
58
|
+
limit: typeof params.limit === "number" ? params.limit : undefined,
|
|
59
|
+
after: typeof params.after === "string" ? params.after : undefined,
|
|
60
|
+
q: typeof params.q === "string" ? params.q : undefined,
|
|
61
|
+
project: typeof params.project === "string" ? params.project : undefined,
|
|
62
|
+
}),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
case "records.get": {
|
|
66
|
+
const collection = text(params.collection, "collection");
|
|
67
|
+
const id = text(params.id, "id");
|
|
68
|
+
return {
|
|
69
|
+
value: await plugin.record(collection, id, typeof params.version === "number" ? params.version : undefined),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
case "records.versions": {
|
|
73
|
+
const collection = text(params.collection, "collection");
|
|
74
|
+
const id = text(params.id, "id");
|
|
75
|
+
return { value: (await plugin.recordVersions(collection, id)).items };
|
|
76
|
+
}
|
|
77
|
+
case "files.get": {
|
|
78
|
+
const id = text(params.id, "id");
|
|
79
|
+
const file = await plugin.readFile(id);
|
|
80
|
+
const bytes = new Uint8Array(file.bytes).buffer;
|
|
81
|
+
return {
|
|
82
|
+
value: { name: file.name, type: file.contentType, bytes },
|
|
83
|
+
transfer: [bytes],
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
case "files.put": {
|
|
87
|
+
const name = text(params.name, "name");
|
|
88
|
+
const type = text(params.type, "type");
|
|
89
|
+
const bytes = params.bytes;
|
|
90
|
+
if (!(bytes instanceof ArrayBuffer)) {
|
|
91
|
+
throw new BridgeRefusal("plugin.invalid_args", "bytes is an ArrayBuffer");
|
|
92
|
+
}
|
|
93
|
+
const handle = await plugin.upload({ name, bytes: new Uint8Array(bytes), contentType: type });
|
|
94
|
+
return { value: { handle: handle.handle } };
|
|
95
|
+
}
|
|
96
|
+
default:
|
|
97
|
+
throw new BridgeRefusal("plugin.forbidden", `${String(call.method)} is not a method of the bridge`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/** The console's computed design tokens, as the page's root has them: what a frame is told to look like. */
|
|
101
|
+
export function readTheme() {
|
|
102
|
+
if (typeof document === "undefined" || typeof getComputedStyle === "undefined") {
|
|
103
|
+
return {};
|
|
104
|
+
}
|
|
105
|
+
const style = getComputedStyle(document.documentElement);
|
|
106
|
+
const theme = {};
|
|
107
|
+
for (const token of CONSOLE_TOKENS) {
|
|
108
|
+
const value = style.getPropertyValue(token).trim();
|
|
109
|
+
if (value.length > 0) {
|
|
110
|
+
theme[token] = value.slice(0, 200);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return theme;
|
|
114
|
+
}
|
|
115
|
+
/** What a failure of a call says to the frame: the console's code and words, or the console's own failure. */
|
|
116
|
+
function errorOf(error) {
|
|
117
|
+
if (error instanceof BridgeRefusal) {
|
|
118
|
+
return { code: error.code, message: error.message };
|
|
119
|
+
}
|
|
120
|
+
if (typeof error === "object" &&
|
|
121
|
+
error !== null &&
|
|
122
|
+
"code" in error &&
|
|
123
|
+
typeof error.code === "string" &&
|
|
124
|
+
"message" in error &&
|
|
125
|
+
typeof error.message === "string") {
|
|
126
|
+
return { code: error.code, message: error.message };
|
|
127
|
+
}
|
|
128
|
+
return { code: "plugin.failed", message: "the call failed" };
|
|
129
|
+
}
|
|
130
|
+
export function PluginFrame(props) {
|
|
131
|
+
const { plugin, page, widget, project, me, language, client, navigation, events } = props;
|
|
132
|
+
const frame = useRef(null);
|
|
133
|
+
const isWidget = widget !== undefined;
|
|
134
|
+
const [height, setHeight] = useState(isWidget ? 160 : 480);
|
|
135
|
+
const subscribed = useRef(new Set());
|
|
136
|
+
const ready = useRef(false);
|
|
137
|
+
const lastPluginEvent = useRef(0);
|
|
138
|
+
const seenEvents = useRef(0);
|
|
139
|
+
const path = props.path ?? "";
|
|
140
|
+
const scoped = useMemo(() => client.plugin(plugin.key), [client, plugin.key]);
|
|
141
|
+
const src = useMemo(() => scoped.frameUrl({
|
|
142
|
+
...(page === undefined ? {} : { page }),
|
|
143
|
+
...(widget === undefined ? {} : { widget }),
|
|
144
|
+
...(project === undefined ? {} : { project: project.key }),
|
|
145
|
+
}), [scoped, page, widget, project]);
|
|
146
|
+
const post = useCallback((message, transfer) => {
|
|
147
|
+
// The frame's origin is opaque, so the target is any: the frame itself checks the sender.
|
|
148
|
+
frame.current?.contentWindow?.postMessage(message, "*", transfer ?? []);
|
|
149
|
+
}, []);
|
|
150
|
+
// The frame's messages: from its own window alone, each as the bridge spells it.
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
if (typeof window === "undefined") {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const onMessage = (event) => {
|
|
156
|
+
const target = frame.current?.contentWindow;
|
|
157
|
+
if (target === null || target === undefined || event.source !== target) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if (!isBridgeToPage(event.data)) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const message = event.data;
|
|
164
|
+
switch (message.t) {
|
|
165
|
+
case "ready":
|
|
166
|
+
ready.current = true;
|
|
167
|
+
post({
|
|
168
|
+
v: PLUGIN_BRIDGE_VERSION,
|
|
169
|
+
t: "init",
|
|
170
|
+
plugin: { key: plugin.key, version: plugin.version },
|
|
171
|
+
...(page === undefined ? {} : { page }),
|
|
172
|
+
...(widget === undefined ? {} : { widget }),
|
|
173
|
+
project: project === undefined ? null : { key: project.key, name: project.name },
|
|
174
|
+
person: {
|
|
175
|
+
id: me.person?.id ?? "",
|
|
176
|
+
login: me.person?.login ?? "",
|
|
177
|
+
name: me.person?.name ?? null,
|
|
178
|
+
language,
|
|
179
|
+
admin: me.person?.role === "admin",
|
|
180
|
+
},
|
|
181
|
+
roles: plugin.roles,
|
|
182
|
+
path,
|
|
183
|
+
language,
|
|
184
|
+
theme: readTheme(),
|
|
185
|
+
});
|
|
186
|
+
return;
|
|
187
|
+
case "call":
|
|
188
|
+
void performBridgeCall(scoped, project?.key, message)
|
|
189
|
+
.then(({ value, transfer }) => post({ v: PLUGIN_BRIDGE_VERSION, t: "result", id: message.id, ok: true, value }, transfer))
|
|
190
|
+
.catch((error) => post({
|
|
191
|
+
v: PLUGIN_BRIDGE_VERSION,
|
|
192
|
+
t: "result",
|
|
193
|
+
id: message.id,
|
|
194
|
+
ok: false,
|
|
195
|
+
error: errorOf(error),
|
|
196
|
+
}));
|
|
197
|
+
return;
|
|
198
|
+
case "navigate":
|
|
199
|
+
if (isBridgePath(message.path)) {
|
|
200
|
+
navigation.go(message.path);
|
|
201
|
+
}
|
|
202
|
+
return;
|
|
203
|
+
case "resize":
|
|
204
|
+
setHeight(Math.max(40, Math.min(Math.ceil(message.height), isWidget ? MAX_PLUGIN_WIDGET_HEIGHT : MAX_PAGE_HEIGHT)));
|
|
205
|
+
return;
|
|
206
|
+
case "title":
|
|
207
|
+
if (!isWidget && typeof document !== "undefined") {
|
|
208
|
+
document.title = message.text;
|
|
209
|
+
}
|
|
210
|
+
return;
|
|
211
|
+
case "download": {
|
|
212
|
+
const anchor = document.createElement("a");
|
|
213
|
+
anchor.href = scoped.fileUrl(message.id);
|
|
214
|
+
anchor.download = "";
|
|
215
|
+
anchor.rel = "noopener";
|
|
216
|
+
anchor.click();
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
case "subscribe":
|
|
220
|
+
subscribed.current = new Set(message.kinds);
|
|
221
|
+
return;
|
|
222
|
+
default:
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
window.addEventListener("message", onMessage);
|
|
227
|
+
return () => window.removeEventListener("message", onMessage);
|
|
228
|
+
});
|
|
229
|
+
// The console's look and language reach the frame as they change.
|
|
230
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: the language is the trigger; the tokens change with it
|
|
231
|
+
useEffect(() => {
|
|
232
|
+
if (ready.current) {
|
|
233
|
+
post({ v: PLUGIN_BRIDGE_VERSION, t: "theme", theme: readTheme() });
|
|
234
|
+
}
|
|
235
|
+
}, [language, post]);
|
|
236
|
+
// The address moved within the page: the frame is told what follows the page now.
|
|
237
|
+
useEffect(() => {
|
|
238
|
+
if (ready.current) {
|
|
239
|
+
post({ v: PLUGIN_BRIDGE_VERSION, t: "path", path });
|
|
240
|
+
}
|
|
241
|
+
}, [path, post]);
|
|
242
|
+
// The plugin's commands, as the project's feed tells of them: a frame that listens hears of each.
|
|
243
|
+
useEffect(() => {
|
|
244
|
+
if (events === undefined) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
const fresh = events.slice(seenEvents.current);
|
|
248
|
+
seenEvents.current = events.length;
|
|
249
|
+
if (!ready.current) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
for (const event of fresh) {
|
|
253
|
+
if (event.kind === "plugin.command" && event.plugin === plugin.key) {
|
|
254
|
+
if (subscribed.current.has("command")) {
|
|
255
|
+
post({ v: PLUGIN_BRIDGE_VERSION, t: "event", kind: "command", data: event.data });
|
|
256
|
+
}
|
|
257
|
+
if (subscribed.current.has("records")) {
|
|
258
|
+
post({ v: PLUGIN_BRIDGE_VERSION, t: "event", kind: "records", data: event.data });
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}, [events, plugin.key, post]);
|
|
263
|
+
// The plugin's own events, asked for while a frame listens for them.
|
|
264
|
+
useEffect(() => {
|
|
265
|
+
if (typeof window === "undefined") {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
const timer = setInterval(() => {
|
|
269
|
+
if (!ready.current || !subscribed.current.has("plugin")) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
scoped
|
|
273
|
+
.pluginEvents({ after: lastPluginEvent.current, limit: 50 })
|
|
274
|
+
.then((page) => {
|
|
275
|
+
for (const event of page.items) {
|
|
276
|
+
lastPluginEvent.current = Math.max(lastPluginEvent.current, event.id);
|
|
277
|
+
post({ v: PLUGIN_BRIDGE_VERSION, t: "event", kind: "plugin", data: event });
|
|
278
|
+
}
|
|
279
|
+
})
|
|
280
|
+
.catch(() => undefined);
|
|
281
|
+
}, EVENTS_POLL_MS);
|
|
282
|
+
return () => clearInterval(timer);
|
|
283
|
+
}, [scoped, post]);
|
|
284
|
+
// What the plugin emitted before the frame came is not replayed: the stream is read from now.
|
|
285
|
+
useEffect(() => {
|
|
286
|
+
scoped
|
|
287
|
+
.pluginEvents({ after: 0, limit: 1 })
|
|
288
|
+
.then((page) => {
|
|
289
|
+
if (page.more || page.items.length > 0) {
|
|
290
|
+
// The newest number is past the first page; a frame hears of what comes after it listens.
|
|
291
|
+
return scoped.pluginEvents({ after: 0, limit: 200 }).then((all) => {
|
|
292
|
+
lastPluginEvent.current = all.items.at(-1)?.id ?? 0;
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
return undefined;
|
|
296
|
+
})
|
|
297
|
+
.catch(() => undefined);
|
|
298
|
+
}, [scoped]);
|
|
299
|
+
return (_jsx("iframe", { ref: frame, className: isWidget ? "sc-plugin-frame sc-plugin-frame-widget" : "sc-plugin-frame", src: src, title: props.title,
|
|
300
|
+
// As the document's own policy says: scripts, and forms firing their submit event, which
|
|
301
|
+
// the policy's form-action 'none' keeps from going anywhere.
|
|
302
|
+
sandbox: "allow-scripts allow-forms", referrerPolicy: "origin", style: { height: `${height}px` } }));
|
|
303
|
+
}
|
|
304
|
+
/** The widgets at a place of the front page, in a grid of six columns: a third takes two, a half three, the full six. */
|
|
305
|
+
export function PluginWidgets(props) {
|
|
306
|
+
const shown = props.plugins.flatMap((plugin) => plugin.widgets
|
|
307
|
+
.filter((widget) => widget.place === props.place)
|
|
308
|
+
.map((widget) => ({ plugin, widget })));
|
|
309
|
+
if (shown.length === 0) {
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
return (_jsx("section", { className: `sc-widgets ${props.place === "home:top" ? "sc-widgets-top" : "sc-widgets-bottom"}`, children: shown.map(({ plugin, widget }) => (_jsxs("article", { className: `sc-widget sc-widget-${widget.size}`, children: [_jsx("h2", { className: "sc-widget-title", children: props.nameOf(widget.name) }), _jsx(PluginFrame, { plugin: plugin, widget: widget.key, me: props.me, language: props.language, client: props.client, navigation: props.navigation, title: props.nameOf(widget.name) })] }, `${plugin.key}:${widget.key}`))) }));
|
|
313
|
+
}
|
|
314
|
+
//# sourceMappingURL=plugin-frame.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-frame.js","sourceRoot":"","sources":["../../src/components/plugin-frame.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE1E,OAAO,EAIL,YAAY,EACZ,cAAc,EACd,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAG/D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,8FAA8F;AAC9F,6FAA6F;AAC7F,4FAA4F;AAC5F,+FAA+F;AAC/F,uEAAuE;AAEvE,+FAA+F;AAC/F,MAAM,eAAe,GAAG,MAAM,CAAC;AAC/B,sFAAsF;AACtF,MAAM,cAAc,GAAG,KAAK,CAAC;AAqB7B,2FAA2F;AAC3F,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC7B,IAAI,CAAS;IAEtB,YAAY,IAAY,EAAE,OAAe;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,MAAM,IAAI,GAAG,CAAC,KAAc,EAAE,IAAY,EAAU,EAAE;IACpD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,aAAa,CAAC,qBAAqB,EAAE,GAAG,IAA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AAE,KAAK,CAAC,MAAM,EACpB,UAAU,EAAE,KAAK,CAAC,UAAU,EAC5B,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,GAChC,KAZG,GAAG,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,GAAG,EAAE,CAa1B,CACX,CAAC,GACM,CACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ConsoleClient } from "../client.js";
|
|
2
|
+
import type { Messages } from "../i18n/en.js";
|
|
3
|
+
import type { RestPerson, RestPlugin, RestPluginDetail, RestProject } from "../schemas.js";
|
|
4
|
+
/** A text in the person's language, else in English, else the first the manifest has. */
|
|
5
|
+
export declare function pluginWord(texts: Readonly<Record<string, string>> | null | undefined, language: string): string;
|
|
6
|
+
export interface CapabilityText {
|
|
7
|
+
/** What the capability is called on the pages. */
|
|
8
|
+
readonly name: string;
|
|
9
|
+
/** The sentence of what it opens, as the administrator reads it before consenting. */
|
|
10
|
+
readonly opens: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A capability by the name the pages give it and the sentence of what it opens, in the person's
|
|
14
|
+
* language; one the packs do not know, by its key alone.
|
|
15
|
+
*/
|
|
16
|
+
export declare function capabilityText(words: Messages, capability: string): CapabilityText;
|
|
17
|
+
export interface PluginSettingsListProps {
|
|
18
|
+
readonly plugins: readonly RestPlugin[];
|
|
19
|
+
readonly language: string;
|
|
20
|
+
readonly href: (plugin: RestPlugin) => string;
|
|
21
|
+
}
|
|
22
|
+
/** Every plugin in a row: its name, its key, its version, how it stands. */
|
|
23
|
+
export declare function PluginSettingsList(props: PluginSettingsListProps): import("react").JSX.Element;
|
|
24
|
+
export interface PluginSettingsViewProps {
|
|
25
|
+
readonly detail: RestPluginDetail;
|
|
26
|
+
readonly projects: readonly RestProject[];
|
|
27
|
+
/** The people of the workspace, to grant a role to; an administrator sees everyone. */
|
|
28
|
+
readonly people: readonly RestPerson[];
|
|
29
|
+
readonly language: string;
|
|
30
|
+
readonly client: ConsoleClient;
|
|
31
|
+
/** Called after a change, so that the page reads the plugin again. */
|
|
32
|
+
readonly onChanged: () => Promise<void>;
|
|
33
|
+
/** Where the list is, for after a purge. */
|
|
34
|
+
readonly onPurged: () => void;
|
|
35
|
+
}
|
|
36
|
+
/** One plugin, whole, for an administrator. */
|
|
37
|
+
export declare function PluginSettingsView(props: PluginSettingsViewProps): import("react").JSX.Element;
|
|
38
|
+
//# sourceMappingURL=plugin-settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-settings.d.ts","sourceRoot":"","sources":["../../src/components/plugin-settings.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG9C,OAAO,KAAK,EAEV,UAAU,EACV,UAAU,EACV,gBAAgB,EAKhB,WAAW,EACZ,MAAM,eAAe,CAAC;AAsBvB,yFAAyF;AACzF,wBAAgB,UAAU,CACxB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,EAC1D,QAAQ,EAAE,MAAM,GACf,MAAM,CAWR;AAED,MAAM,WAAW,cAAc;IAC7B,kDAAkD;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,sFAAsF;IACtF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,GAAG,cAAc,CAalF;AAaD,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;IACxC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,CAAC,MA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