@peers-app/peers-ui 0.33.12 → 0.33.14
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/apps-home/app-menu.d.ts +3 -1
- package/dist/apps-home/app-menu.js +2 -2
- package/dist/apps-home/app-status.d.ts +7 -0
- package/dist/apps-home/app-status.js +16 -0
- package/dist/apps-home/app-tile.d.ts +3 -1
- package/dist/apps-home/app-tile.js +10 -5
- package/dist/apps-home/apps-home.js +5 -13
- package/dist/apps-home/current-group-name.d.ts +5 -0
- package/dist/apps-home/current-group-name.js +19 -0
- package/dist/components/group-switcher.js +1 -1
- package/dist/components/markdown-editor/editor.d.ts +11 -5
- package/dist/components/markdown-editor/editor.js +4 -3
- package/dist/components/markdown-editor/mentions-plugin.d.ts +29 -10
- package/dist/components/markdown-editor/mentions-plugin.js +108 -92
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/mentions/mention-chip.d.ts +1 -1
- package/dist/mentions/mention-chip.js +2 -1
- package/dist/mentions/mentions-client.d.ts +17 -3
- package/dist/mentions/mentions-client.js +36 -6
- package/dist/screens/packages/package-info.js +1 -1
- package/dist/screens/packages/package-runtime-status.d.ts +2 -2
- package/dist/screens/packages/package-runtime-status.js +3 -3
- package/dist/screens/packages/package-waiting.d.ts +31 -0
- package/dist/screens/packages/package-waiting.js +173 -0
- package/dist/screens/packages/packages-ipc.d.ts +62 -1
- package/dist/screens/packages/packages-ipc.js +105 -4
- package/dist/screens/setup-user.js +2 -2
- package/dist/theme.css +197 -0
- package/dist/ui-contracts/host-ui-contract.d.ts +28 -0
- package/dist/ui-contracts/host-ui-contract.js +45 -0
- package/dist/ui-contracts/implement-piece.d.ts +24 -0
- package/dist/ui-contracts/implement-piece.js +44 -0
- package/dist/ui-contracts/index.d.ts +6 -0
- package/dist/ui-contracts/index.js +17 -0
- package/dist/ui-contracts/mock-piece.d.ts +36 -0
- package/dist/ui-contracts/mock-piece.js +56 -0
- package/dist/ui-contracts/piece-host.d.ts +99 -0
- package/dist/ui-contracts/piece-host.js +266 -0
- package/dist/ui-contracts/piece-resolution.d.ts +55 -0
- package/dist/ui-contracts/piece-resolution.js +186 -0
- package/dist/ui-contracts/piece.d.ts +77 -0
- package/dist/ui-contracts/piece.js +358 -0
- package/dist/ui-contracts/popover-surface.d.ts +21 -0
- package/dist/ui-contracts/popover-surface.js +169 -0
- package/dist/ui-contracts/types.d.ts +113 -0
- package/dist/ui-contracts/types.js +2 -0
- package/dist/ui-router/runnable-version.d.ts +4 -1
- package/dist/ui-router/runnable-version.js +6 -3
- package/dist/ui-router/ui-loader.js +127 -37
- package/package.json +3 -3
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PackageWaitingScreen = PackageWaitingScreen;
|
|
4
|
+
exports.PackageWaitingNotice = PackageWaitingNotice;
|
|
5
|
+
exports.providersToAdd = providersToAdd;
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const current_group_name_1 = require("../../apps-home/current-group-name");
|
|
10
|
+
const get_apps_sheet_1 = require("../../apps-home/get-apps-sheet");
|
|
11
|
+
const use_observable_1 = require("../../hooks/use-observable");
|
|
12
|
+
const use_promise_1 = require("../../hooks/use-promise");
|
|
13
|
+
const tabs_state_1 = require("../../tabs-layout/tabs-state");
|
|
14
|
+
const app_catalog_1 = require("../../ui-router/app-catalog");
|
|
15
|
+
const routes_loader_1 = require("../../ui-router/routes-loader");
|
|
16
|
+
const package_helpers_1 = require("./package-helpers");
|
|
17
|
+
const packages_ipc_1 = require("./packages-ipc");
|
|
18
|
+
/**
|
|
19
|
+
* The system screen a package shows in place of its own while it waits for a contract it
|
|
20
|
+
* requires: what it needs, why it can't start, and the packages that provide it, to add from
|
|
21
|
+
* here. Once one runs here the package starts by itself, and its own screen replaces this one.
|
|
22
|
+
*/
|
|
23
|
+
function PackageWaitingScreen({ packageId, missing }) {
|
|
24
|
+
const groupName = (0, current_group_name_1.useCurrentGroupName)();
|
|
25
|
+
// Undefined until the role is read, so neither the admin note nor Add shows early.
|
|
26
|
+
const admin = (0, use_promise_1.usePromise)(package_helpers_1.isGroupAdmin, undefined, []);
|
|
27
|
+
const canAdd = admin === true;
|
|
28
|
+
const { report, error, refresh } = usePackageRequirements(packageId);
|
|
29
|
+
const app = useAppLook(packageId);
|
|
30
|
+
const needs = report?.missing ?? [];
|
|
31
|
+
// The report names contracts other contexts know; the runtime state may not have yet.
|
|
32
|
+
const names = (0, peers_sdk_1.missingContractsLabel)(report?.missing.length ? report.missing : missing);
|
|
33
|
+
const here = groupName || "this group";
|
|
34
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "peers-waiting", "data-testid": "package-waiting", children: [(0, jsx_runtime_1.jsxs)("div", { className: "peers-waiting-head", children: [(0, jsx_runtime_1.jsxs)("span", { className: `peers-app-icon peers-app-color-${app.color}`, "aria-hidden": "true", children: [(0, jsx_runtime_1.jsx)("i", { className: app.iconClassName }), (0, jsx_runtime_1.jsx)("span", { className: "peers-waiting-badge", children: (0, jsx_runtime_1.jsx)("i", { className: "bi-hourglass-split" }) })] }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("h2", { children: [app.name, " is waiting to start"] }), (0, jsx_runtime_1.jsxs)("p", { className: "peers-waiting-lead", children: ["It needs ", names, ", and no package in ", here, " provides ", missing.length > 1 ? "them" : "it", " ", "yet."] })] })] }), (0, jsx_runtime_1.jsxs)("p", { className: "peers-waiting-explain", children: [app.name, " is installed, and its data keeps syncing. It starts by itself as soon as a package that provides ", missing.length > 1 ? "them" : "it", " is running here."] }), admin === false && ((0, jsx_runtime_1.jsxs)("p", { className: "peers-waiting-explain", "data-testid": "package-waiting-admin-only", children: ["Only an admin of ", here, " can add packages here."] })), error ? ((0, jsx_runtime_1.jsx)("div", { className: "alert alert-danger py-2 px-3 small", role: "alert", children: error })) : !report ? ((0, jsx_runtime_1.jsx)("div", { className: "text-center py-3", children: (0, jsx_runtime_1.jsx)("output", { className: "spinner-border spinner-border-sm text-secondary", children: (0, jsx_runtime_1.jsx)("span", { className: "visually-hidden", children: "Loading" }) }) })) : (needs.map((need) => ((0, jsx_runtime_1.jsx)(RequiredContract, { need: need, appName: app.name, groupName: here, canAdd: canAdd, onAdded: refresh }, `${need.contractId}@${need.version}`)))), (0, jsx_runtime_1.jsx)("div", { className: "peers-waiting-foot", children: (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-link p-0", onClick: () => (0, tabs_state_1.navigateTo)(`packages/${packageId}`), "data-testid": "package-waiting-details", children: "Details and versions" }) })] }));
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The line a waiting package shows where another screen embeds one of its parts: what it waits
|
|
38
|
+
* for, and a way to open it and see why.
|
|
39
|
+
*/
|
|
40
|
+
function PackageWaitingNotice({ packageId, missing }) {
|
|
41
|
+
const app = useAppLook(packageId);
|
|
42
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "peers-waiting-notice", role: "status", "data-testid": "package-waiting-notice", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi-hourglass-split", "aria-hidden": "true" }), (0, jsx_runtime_1.jsxs)("span", { children: [app.name, " is waiting for ", (0, peers_sdk_1.missingContractsLabel)(missing), "."] }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-link btn-sm p-0", onClick: () => (app.path ? (0, tabs_state_1.goToTabPath)(app.path) : (0, tabs_state_1.navigateTo)(`packages/${packageId}`)), children: "See why" })] }));
|
|
43
|
+
}
|
|
44
|
+
/** One contract the package needs, with what could provide it. */
|
|
45
|
+
function RequiredContract({ need, appName, groupName, canAdd, onAdded, }) {
|
|
46
|
+
const nothing = need.installed.length === 0 && need.toAdd.length === 0;
|
|
47
|
+
return ((0, jsx_runtime_1.jsxs)("section", { className: "peers-waiting-need", "aria-label": `Needs ${(0, peers_sdk_1.missingContractLabel)(need)}`, children: [(0, jsx_runtime_1.jsxs)("h3", { children: [(0, jsx_runtime_1.jsx)("i", { className: "bi-plug", "aria-hidden": "true" }), (0, peers_sdk_1.missingContractLabel)(need)] }), need.description && (0, jsx_runtime_1.jsx)("p", { className: "peers-waiting-desc", children: need.description }), need.providerPackageIds?.length ? ((0, jsx_runtime_1.jsxs)("p", { className: "peers-waiting-desc", children: [appName, " names which packages may provide it."] })) : null, need.installed.map((provider) => ((0, jsx_runtime_1.jsx)(InstalledProvider, { provider: provider, appName: appName, groupName: groupName, canAdd: canAdd, onAdded: onAdded }, provider.packageId))), need.toAdd.map((entry) => ((0, jsx_runtime_1.jsx)(ProviderToAdd, { entry: entry, groupName: groupName, canAdd: canAdd, onAdded: onAdded }, entry.packageId))), nothing && ((0, jsx_runtime_1.jsx)("p", { className: "peers-waiting-none", "data-testid": "package-waiting-none", children: "None of your groups has a package that provides it." }))] }));
|
|
48
|
+
}
|
|
49
|
+
/** A package installed here that provides the contract but doesn't serve it, and why. */
|
|
50
|
+
function InstalledProvider({ provider, appName, groupName, canAdd, onAdded, }) {
|
|
51
|
+
const look = useAppLook(provider.packageId, provider.name);
|
|
52
|
+
const [state, add] = useAddAction(onAdded);
|
|
53
|
+
const turnOn = provider.status === "disabled" && canAdd;
|
|
54
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "peers-waiting-provider", children: [(0, jsx_runtime_1.jsxs)("div", { className: "peers-get-apps-row", "data-testid": `package-waiting-installed-${provider.packageId}`, children: [(0, jsx_runtime_1.jsx)("span", { className: `peers-app-icon peers-app-color-${look.color}`, "aria-hidden": "true", children: (0, jsx_runtime_1.jsx)("i", { className: look.iconClassName }) }), (0, jsx_runtime_1.jsxs)("div", { className: "peers-get-apps-text", children: [(0, jsx_runtime_1.jsx)("div", { className: "peers-get-apps-name", children: provider.name }), (0, jsx_runtime_1.jsx)("div", { className: "peers-get-apps-desc", children: provider.cycle
|
|
55
|
+
? `It needs ${appName} too, so neither can start. One of them has to stop requiring the other: tell their authors.`
|
|
56
|
+
: `Installed in ${groupName}, but ${installedPhrase(provider.status)}.` }), provider.reason && provider.status !== "waiting" && !provider.cycle && ((0, jsx_runtime_1.jsx)("div", { className: "peers-get-apps-desc", children: provider.reason })), state.error && ((0, jsx_runtime_1.jsx)("div", { className: "small text-danger mt-1", role: "alert", children: state.error }))] }), (0, jsx_runtime_1.jsx)("div", { className: "peers-get-apps-action", "aria-live": "polite", children: turnOn ? ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn peers-get-apps-add", disabled: state.adding, onClick: () => add([{ packageId: provider.packageId }]), children: state.adding ? "Turning on…" : "Turn on" })) : provider.status !== "waiting" ? ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-link btn-sm p-0", onClick: () => (0, tabs_state_1.navigateTo)(`packages/${provider.packageId}`), children: "Details" })) : null })] }), provider.missing?.length ? ((0, jsx_runtime_1.jsx)("div", { className: "peers-waiting-chain", children: provider.missing.map((need) => ((0, jsx_runtime_1.jsx)(RequiredContract, { need: need, appName: provider.name, groupName: groupName, canAdd: canAdd, onAdded: onAdded }, `${need.contractId}@${need.version}`))) })) : null] }));
|
|
57
|
+
}
|
|
58
|
+
/** A package in another of the user's groups that provides the contract, to add here. */
|
|
59
|
+
function ProviderToAdd({ entry, groupName, canAdd, onAdded, }) {
|
|
60
|
+
const display = (0, get_apps_sheet_1.packageToAddDisplay)(entry);
|
|
61
|
+
const [state, add] = useAddAction(onAdded);
|
|
62
|
+
const plan = providersToAdd(entry);
|
|
63
|
+
const also = plan.add.slice(0, -1).map((each) => (0, get_apps_sheet_1.packageToAddDisplay)(each).title);
|
|
64
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "peers-get-apps-row", "data-testid": `package-waiting-add-row-${entry.packageId}`, children: [(0, jsx_runtime_1.jsx)("span", { className: `peers-app-icon peers-app-color-${display.color}`, "aria-hidden": "true", children: (0, jsx_runtime_1.jsx)("i", { className: display.iconClassName }) }), (0, jsx_runtime_1.jsxs)("div", { className: "peers-get-apps-text", children: [(0, jsx_runtime_1.jsx)("div", { className: "peers-get-apps-name", children: display.title }), (0, jsx_runtime_1.jsxs)("div", { className: "peers-get-apps-desc", children: ["In ", entry.sourceName, entry.version ? ` · v${entry.version}` : "", entry.description ? ` · ${entry.description}` : ""] }), also.length > 0 && ((0, jsx_runtime_1.jsxs)("div", { className: "peers-get-apps-desc", children: ["Adding it adds ", (0, peers_sdk_1.joinNames)(also), " too, which it needs."] })), plan.unmet.length > 0 && ((0, jsx_runtime_1.jsxs)("div", { className: "peers-get-apps-desc", children: ["It needs ", (0, peers_sdk_1.joinNames)(plan.unmet), " as well, which none of your groups has."] })), state.error && ((0, jsx_runtime_1.jsx)("div", { className: "small text-danger mt-1", role: "alert", children: state.error }))] }), (0, jsx_runtime_1.jsx)("div", { className: "peers-get-apps-action", "aria-live": "polite", children: state.added ? ((0, jsx_runtime_1.jsxs)("span", { className: "peers-get-apps-done", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi-check-lg", "aria-hidden": "true" }), "Added"] })) : entry.unsupportedHere ? ((0, jsx_runtime_1.jsx)("span", { className: "peers-get-apps-note", children: "Not on this device" })) : canAdd ? ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn peers-get-apps-add", disabled: state.adding, onClick: () => add(plan.add.map((each) => ({
|
|
65
|
+
packageId: each.packageId,
|
|
66
|
+
fromDataContextId: each.sourceDataContextId,
|
|
67
|
+
}))), "aria-label": `Add ${display.title} to ${groupName}`, "data-testid": `package-waiting-add-${entry.packageId}`, children: state.adding ? "Adding…" : "Add" })) : null })] }));
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The packages to add, in order, so a provider starts as soon as it's added: what it needs first
|
|
71
|
+
* (the first provider listed for each of its needs, recursively), the provider last. `unmet` names
|
|
72
|
+
* the needs no group has a provider for, so adding it would leave it waiting.
|
|
73
|
+
*
|
|
74
|
+
* @param entry - The provider to add.
|
|
75
|
+
*/
|
|
76
|
+
function providersToAdd(entry) {
|
|
77
|
+
const add = [];
|
|
78
|
+
const unmet = [];
|
|
79
|
+
const visit = (provider) => {
|
|
80
|
+
if (add.some((each) => each.packageId === provider.packageId))
|
|
81
|
+
return;
|
|
82
|
+
for (const need of provider.missing ?? []) {
|
|
83
|
+
const next = need.toAdd.find((candidate) => !candidate.unsupportedHere && !candidate.cycle);
|
|
84
|
+
if (next)
|
|
85
|
+
visit(next);
|
|
86
|
+
else if (!need.installed.length)
|
|
87
|
+
unmet.push((0, peers_sdk_1.missingContractLabel)(need));
|
|
88
|
+
}
|
|
89
|
+
add.push(provider);
|
|
90
|
+
};
|
|
91
|
+
visit(entry);
|
|
92
|
+
return { add, unmet };
|
|
93
|
+
}
|
|
94
|
+
/** Add or turn on packages in order, then refresh; the button shows progress and failure. */
|
|
95
|
+
function useAddAction(onAdded) {
|
|
96
|
+
const [state, setState] = (0, react_1.useState)({
|
|
97
|
+
adding: false,
|
|
98
|
+
added: false,
|
|
99
|
+
});
|
|
100
|
+
const add = (packages) => {
|
|
101
|
+
setState({ adding: true, added: false });
|
|
102
|
+
void (async () => {
|
|
103
|
+
try {
|
|
104
|
+
const tools = await (0, packages_ipc_1.packagesTools)();
|
|
105
|
+
for (const each of packages)
|
|
106
|
+
await tools.installPackage(each);
|
|
107
|
+
setState({ adding: false, added: true });
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
setState({
|
|
111
|
+
adding: false,
|
|
112
|
+
added: false,
|
|
113
|
+
error: error instanceof Error ? error.message : String(error),
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
onAdded();
|
|
117
|
+
})();
|
|
118
|
+
};
|
|
119
|
+
return [state, add];
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The package's requirements report, read again whenever a package here changes state (a
|
|
123
|
+
* provider added, a link of the chain starting) and on `refresh`.
|
|
124
|
+
*/
|
|
125
|
+
function usePackageRequirements(packageId) {
|
|
126
|
+
const states = (0, packages_ipc_1.usePackageRuntimeStates)();
|
|
127
|
+
const [revision, setRevision] = (0, react_1.useState)(0);
|
|
128
|
+
const [result, setResult] = (0, react_1.useState)({});
|
|
129
|
+
(0, react_1.useEffect)(() => {
|
|
130
|
+
let current = true;
|
|
131
|
+
(0, packages_ipc_1.packagesTools)()
|
|
132
|
+
.then((tools) => tools.getPackageRequirements({ packageId }))
|
|
133
|
+
.then(({ requirements }) => current && setResult({ report: requirements }), (error) => current &&
|
|
134
|
+
setResult((previous) => ({
|
|
135
|
+
...previous,
|
|
136
|
+
error: error instanceof Error ? error.message : String(error),
|
|
137
|
+
})));
|
|
138
|
+
return () => {
|
|
139
|
+
current = false;
|
|
140
|
+
};
|
|
141
|
+
}, [packageId, states, revision]);
|
|
142
|
+
return { ...result, refresh: () => setRevision((value) => value + 1) };
|
|
143
|
+
}
|
|
144
|
+
/** How a package's app looks on the Apps screen: name, icon, color, and the path that opens it. */
|
|
145
|
+
function useAppLook(packageId, fallbackName) {
|
|
146
|
+
const [packages] = (0, use_observable_1.useObservable)(routes_loader_1.allPackages);
|
|
147
|
+
const pkg = packages.find((each) => each.packageId === packageId);
|
|
148
|
+
const nav = pkg?.appNavs?.[0];
|
|
149
|
+
const name = (pkg?.appNavs?.length === 1 && (nav?.displayName || nav?.name)) || pkg?.name;
|
|
150
|
+
return {
|
|
151
|
+
name: name || fallbackName || "This package",
|
|
152
|
+
iconClassName: nav?.iconClassName || "bi-box-seam",
|
|
153
|
+
color: (0, peers_sdk_1.resolveAppColor)(packageId, nav ?? { name: pkg?.name ?? packageId }),
|
|
154
|
+
...(nav ? { path: (0, app_catalog_1.appPath)(packageId, nav) } : {}),
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
/** Why an installed provider doesn't serve the contract, after "Installed in Home, but". */
|
|
158
|
+
function installedPhrase(status) {
|
|
159
|
+
switch (status) {
|
|
160
|
+
case "waiting":
|
|
161
|
+
return "it's waiting too";
|
|
162
|
+
case "disabled":
|
|
163
|
+
return "it's turned off";
|
|
164
|
+
case "failed":
|
|
165
|
+
return "it couldn't start on this device";
|
|
166
|
+
case "unsupported":
|
|
167
|
+
return "this device can't run it";
|
|
168
|
+
case "unavailable":
|
|
169
|
+
return "it's still downloading to this device";
|
|
170
|
+
default:
|
|
171
|
+
return "it isn't running on this device";
|
|
172
|
+
}
|
|
173
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type IHostContractConsumer, type IPackageObservedRuntime, type IPackagesConsumer, type PackageRuntimeStates } from "@peers-app/peers-sdk";
|
|
1
|
+
import { type IHostContractConsumer, type IPackageMissingContract, type IPackageObservedRuntime, type IPackagesConsumer, type IPackageWaiting, type PackageRuntimeStates } from "@peers-app/peers-sdk";
|
|
2
2
|
/**
|
|
3
3
|
* Shared System Packages handle for one data context; stable for `useHostContract`.
|
|
4
4
|
*
|
|
@@ -25,6 +25,67 @@ export declare function packagesTools(dataContextId?: string): Promise<IPackages
|
|
|
25
25
|
* @returns States keyed by package id, or `undefined` until the host answers.
|
|
26
26
|
*/
|
|
27
27
|
export declare function usePackageRuntimeStates(dataContextId?: string): PackageRuntimeStates | undefined;
|
|
28
|
+
/** A context's live package runtime states, and why they couldn't be read. */
|
|
29
|
+
export interface IPackageRuntimeStatesResult {
|
|
30
|
+
/** States keyed by package id; `undefined` until the host answers. */
|
|
31
|
+
states: PackageRuntimeStates | undefined;
|
|
32
|
+
/** Set when System Packages can't be reached, so a caller needn't wait for the states. */
|
|
33
|
+
error: Error | undefined;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Live runtime state of a context's packages on this device, with the failure to reach System
|
|
37
|
+
* Packages, for a caller that must not wait forever for an answer.
|
|
38
|
+
*
|
|
39
|
+
* @param dataContextId - Context to watch; defaults to the active group.
|
|
40
|
+
* @param enabled - Whether to watch at all; `false` reads nothing (a built-in screen).
|
|
41
|
+
*/
|
|
42
|
+
export declare function usePackageRuntimeStatesResult(dataContextId?: string, enabled?: boolean): IPackageRuntimeStatesResult;
|
|
43
|
+
/**
|
|
44
|
+
* What a package waits for when it can't start on this device because a contract it requires has
|
|
45
|
+
* no provider here, or `undefined` when it isn't held back. A package whose older version keeps
|
|
46
|
+
* serving while the selected one waits isn't counted: its screens still work.
|
|
47
|
+
*
|
|
48
|
+
* @param runtime - The package's observed runtime state on this device.
|
|
49
|
+
*/
|
|
50
|
+
export declare function packageWaiting(runtime: Pick<IPackageObservedRuntime, "status" | "running" | "waiting"> | undefined): IPackageWaiting | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* The version that still serves while a newer one waits for a contract it requires ("Update
|
|
53
|
+
* waiting"), or `undefined` when the package runs the version selected for it. Its UI is the one
|
|
54
|
+
* to show, so screens match the worker that answers them.
|
|
55
|
+
*
|
|
56
|
+
* @param runtime - The package's observed runtime state on this device.
|
|
57
|
+
*/
|
|
58
|
+
export declare function servingVersionWhileUpdateWaits(runtime: Pick<IPackageObservedRuntime, "status" | "running"> | undefined): string | undefined;
|
|
59
|
+
/** Whether a package's UI code may run, and which version's, from {@link usePackageScreenGate}. */
|
|
60
|
+
export interface IPackageScreenGate {
|
|
61
|
+
/**
|
|
62
|
+
* The host has said whether the package waits, or can't say. Until then a screen shows UI it
|
|
63
|
+
* already loaded, but runs no bundle it hasn't run yet.
|
|
64
|
+
*/
|
|
65
|
+
ready: boolean;
|
|
66
|
+
/** Set while it waits with nothing running: show why instead of its screens. */
|
|
67
|
+
missing?: IPackageMissingContract[];
|
|
68
|
+
/**
|
|
69
|
+
* Set while a newer version waits and this older one still serves: load this version's UI
|
|
70
|
+
* rather than the selected one's ({@link servingVersionWhileUpdateWaits}).
|
|
71
|
+
*/
|
|
72
|
+
servingPackageVersionId?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Whether a package's UI code may run on this device, and which version's: none of it runs while
|
|
76
|
+
* the package waits for a contract it requires, and while an update waits, the version that still
|
|
77
|
+
* serves is the one whose UI runs. Nothing waits on this hook: a screen reads its bundle at once
|
|
78
|
+
* and runs it once `ready` says the package isn't waiting, and UI it already loaded renders
|
|
79
|
+
* straight away. `ready` is set at once when System Packages can't be reached (a host that
|
|
80
|
+
* doesn't serve it), so no screen hangs on it. A built-in screen passes no package and reads
|
|
81
|
+
* nothing.
|
|
82
|
+
*
|
|
83
|
+
* A screen renders again only when its own package's gate changes, not on every change to the
|
|
84
|
+
* context's package states.
|
|
85
|
+
*
|
|
86
|
+
* @param packageId - The package that owns the screen, if a package does.
|
|
87
|
+
*/
|
|
88
|
+
export declare function usePackageScreenGate(packageId: string | undefined): IPackageScreenGate;
|
|
28
89
|
/** Display label and Bootstrap badge color for an observed package status. */
|
|
29
90
|
export interface IPackageStatusBadge {
|
|
30
91
|
/** Short status label. */
|
|
@@ -4,6 +4,10 @@ exports.packagesContractFor = packagesContractFor;
|
|
|
4
4
|
exports.getPackagesConsumer = getPackagesConsumer;
|
|
5
5
|
exports.packagesTools = packagesTools;
|
|
6
6
|
exports.usePackageRuntimeStates = usePackageRuntimeStates;
|
|
7
|
+
exports.usePackageRuntimeStatesResult = usePackageRuntimeStatesResult;
|
|
8
|
+
exports.packageWaiting = packageWaiting;
|
|
9
|
+
exports.servingVersionWhileUpdateWaits = servingVersionWhileUpdateWaits;
|
|
10
|
+
exports.usePackageScreenGate = usePackageScreenGate;
|
|
7
11
|
exports.packageStatusBadge = packageStatusBadge;
|
|
8
12
|
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
9
13
|
const react_1 = require("react");
|
|
@@ -55,8 +59,33 @@ const pendingHandle = {
|
|
|
55
59
|
* @returns States keyed by package id, or `undefined` until the host answers.
|
|
56
60
|
*/
|
|
57
61
|
function usePackageRuntimeStates(dataContextId) {
|
|
62
|
+
return usePackageRuntimeStatesResult(dataContextId).states;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Live runtime state of a context's packages on this device, with the failure to reach System
|
|
66
|
+
* Packages, for a caller that must not wait forever for an answer.
|
|
67
|
+
*
|
|
68
|
+
* @param dataContextId - Context to watch; defaults to the active group.
|
|
69
|
+
* @param enabled - Whether to watch at all; `false` reads nothing (a built-in screen).
|
|
70
|
+
*/
|
|
71
|
+
function usePackageRuntimeStatesResult(dataContextId, enabled = true) {
|
|
72
|
+
const { consumer, error } = usePackagesConsumer(dataContextId, enabled);
|
|
73
|
+
const [states] = (0, hooks_1.useObservable)(consumer?.observables.runtimeStates);
|
|
74
|
+
return { states, error };
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The System Packages consumer for a context, kept current across reconnects.
|
|
78
|
+
*
|
|
79
|
+
* @param dataContextId - Context to bind; defaults to the active group.
|
|
80
|
+
* @param enabled - Whether to connect at all.
|
|
81
|
+
*/
|
|
82
|
+
function usePackagesConsumer(dataContextId, enabled) {
|
|
58
83
|
const [handle, setHandle] = (0, react_1.useState)();
|
|
59
84
|
(0, react_1.useEffect)(() => {
|
|
85
|
+
if (!enabled) {
|
|
86
|
+
setHandle(undefined);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
60
89
|
let cancelled = false;
|
|
61
90
|
(dataContextId
|
|
62
91
|
? Promise.resolve(dataContextId)
|
|
@@ -67,10 +96,77 @@ function usePackageRuntimeStates(dataContextId) {
|
|
|
67
96
|
return () => {
|
|
68
97
|
cancelled = true;
|
|
69
98
|
};
|
|
70
|
-
}, [dataContextId]);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
99
|
+
}, [dataContextId, enabled]);
|
|
100
|
+
return (0, use_host_contract_1.useHostContract)(handle ?? pendingHandle);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* What a package waits for when it can't start on this device because a contract it requires has
|
|
104
|
+
* no provider here, or `undefined` when it isn't held back. A package whose older version keeps
|
|
105
|
+
* serving while the selected one waits isn't counted: its screens still work.
|
|
106
|
+
*
|
|
107
|
+
* @param runtime - The package's observed runtime state on this device.
|
|
108
|
+
*/
|
|
109
|
+
function packageWaiting(runtime) {
|
|
110
|
+
return runtime?.status === "waiting" && !runtime.running ? runtime.waiting : undefined;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The version that still serves while a newer one waits for a contract it requires ("Update
|
|
114
|
+
* waiting"), or `undefined` when the package runs the version selected for it. Its UI is the one
|
|
115
|
+
* to show, so screens match the worker that answers them.
|
|
116
|
+
*
|
|
117
|
+
* @param runtime - The package's observed runtime state on this device.
|
|
118
|
+
*/
|
|
119
|
+
function servingVersionWhileUpdateWaits(runtime) {
|
|
120
|
+
return runtime?.status === "waiting" ? runtime.running?.packageVersionId : undefined;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Whether a package's UI code may run on this device, and which version's: none of it runs while
|
|
124
|
+
* the package waits for a contract it requires, and while an update waits, the version that still
|
|
125
|
+
* serves is the one whose UI runs. Nothing waits on this hook: a screen reads its bundle at once
|
|
126
|
+
* and runs it once `ready` says the package isn't waiting, and UI it already loaded renders
|
|
127
|
+
* straight away. `ready` is set at once when System Packages can't be reached (a host that
|
|
128
|
+
* doesn't serve it), so no screen hangs on it. A built-in screen passes no package and reads
|
|
129
|
+
* nothing.
|
|
130
|
+
*
|
|
131
|
+
* A screen renders again only when its own package's gate changes, not on every change to the
|
|
132
|
+
* context's package states.
|
|
133
|
+
*
|
|
134
|
+
* @param packageId - The package that owns the screen, if a package does.
|
|
135
|
+
*/
|
|
136
|
+
function usePackageScreenGate(packageId) {
|
|
137
|
+
const { consumer, error } = usePackagesConsumer(undefined, !!packageId);
|
|
138
|
+
const runtimeStates = consumer?.observables.runtimeStates;
|
|
139
|
+
const subscribe = (0, react_1.useCallback)((onChange) => {
|
|
140
|
+
if (!runtimeStates)
|
|
141
|
+
return () => undefined;
|
|
142
|
+
const subscription = runtimeStates.subscribe(onChange);
|
|
143
|
+
return () => subscription.dispose();
|
|
144
|
+
}, [runtimeStates]);
|
|
145
|
+
// A string, so an unrelated state change gives the same snapshot and renders nothing.
|
|
146
|
+
const gate = (0, react_1.useSyncExternalStore)(subscribe, () => JSON.stringify(screenGate(packageId, runtimeStates?.(), !!error)));
|
|
147
|
+
return (0, react_1.useMemo)(() => JSON.parse(gate), [gate]);
|
|
148
|
+
}
|
|
149
|
+
/** One package's gate, from its context's states; only the fields a screen reads, in one order. */
|
|
150
|
+
function screenGate(packageId, states, unreachable) {
|
|
151
|
+
if (!packageId)
|
|
152
|
+
return { ready: true };
|
|
153
|
+
if (!states)
|
|
154
|
+
return { ready: unreachable };
|
|
155
|
+
const state = states[packageId];
|
|
156
|
+
const waiting = packageWaiting(state);
|
|
157
|
+
if (waiting) {
|
|
158
|
+
return {
|
|
159
|
+
ready: true,
|
|
160
|
+
missing: waiting.missing.map(({ contractId, version, name, providerPackageIds }) => ({
|
|
161
|
+
contractId,
|
|
162
|
+
version,
|
|
163
|
+
...(name ? { name } : {}),
|
|
164
|
+
...(providerPackageIds?.length ? { providerPackageIds } : {}),
|
|
165
|
+
})),
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
const serving = servingVersionWhileUpdateWaits(state);
|
|
169
|
+
return serving ? { ready: true, servingPackageVersionId: serving } : { ready: true };
|
|
74
170
|
}
|
|
75
171
|
/**
|
|
76
172
|
* Describe a package's observed runtime status for a badge.
|
|
@@ -86,6 +182,11 @@ function packageStatusBadge(runtime) {
|
|
|
86
182
|
switch (runtime.status) {
|
|
87
183
|
case "running":
|
|
88
184
|
return { label: "Running", color: "success" };
|
|
185
|
+
case "waiting":
|
|
186
|
+
// An older version may keep serving while the selected one waits.
|
|
187
|
+
return runtime.running
|
|
188
|
+
? { label: "Update waiting", color: "warning" }
|
|
189
|
+
: { label: "Waiting", color: "warning" };
|
|
89
190
|
case "failed":
|
|
90
191
|
return runtime.running
|
|
91
192
|
? { label: "Update failed", color: "warning" }
|
|
@@ -27,8 +27,8 @@ const SetupUser = () => {
|
|
|
27
27
|
// Generate new user credentials
|
|
28
28
|
const keys = (0, peers_sdk_1.newKeys)();
|
|
29
29
|
const _userId = (0, peers_sdk_1.newid)();
|
|
30
|
-
// signIn triggers device init, which installs peers-core into the personal
|
|
31
|
-
// context
|
|
30
|
+
// signIn triggers device init, which installs peers-core (Tasks) into the personal
|
|
31
|
+
// context from S3. Without S3, a later start installs it.
|
|
32
32
|
await (await (0, identity_ipc_1.identityTools)()).signIn({ userId: _userId, secretKey: keys.secretKey });
|
|
33
33
|
// Success - reload the app (peers-services registration runs after Welcome modal)
|
|
34
34
|
window.location.reload();
|
package/dist/theme.css
CHANGED
|
@@ -159,6 +159,38 @@
|
|
|
159
159
|
margin-right: 3px;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
+
/* A mention source's palette color (a label's, say), from its `color` setting. */
|
|
163
|
+
.peers-mention-icon[data-color="blue"] {
|
|
164
|
+
color: var(--peers-app-blue-bg);
|
|
165
|
+
}
|
|
166
|
+
.peers-mention-icon[data-color="teal"] {
|
|
167
|
+
color: var(--peers-app-teal-bg);
|
|
168
|
+
}
|
|
169
|
+
.peers-mention-icon[data-color="red"] {
|
|
170
|
+
color: var(--peers-app-red-bg);
|
|
171
|
+
}
|
|
172
|
+
.peers-mention-icon[data-color="amber"] {
|
|
173
|
+
color: var(--peers-app-amber-bg);
|
|
174
|
+
}
|
|
175
|
+
.peers-mention-icon[data-color="purple"] {
|
|
176
|
+
color: var(--peers-app-purple-bg);
|
|
177
|
+
}
|
|
178
|
+
.peers-mention-icon[data-color="orange"] {
|
|
179
|
+
color: var(--peers-app-orange-bg);
|
|
180
|
+
}
|
|
181
|
+
.peers-mention-icon[data-color="green"] {
|
|
182
|
+
color: var(--peers-app-green-bg);
|
|
183
|
+
}
|
|
184
|
+
.peers-mention-icon[data-color="pink"] {
|
|
185
|
+
color: var(--peers-app-pink-bg);
|
|
186
|
+
}
|
|
187
|
+
.peers-mention-icon[data-color="violet"] {
|
|
188
|
+
color: var(--peers-app-violet-bg);
|
|
189
|
+
}
|
|
190
|
+
.peers-mention-icon[data-color="slate"] {
|
|
191
|
+
color: var(--peers-app-slate-bg);
|
|
192
|
+
}
|
|
193
|
+
|
|
162
194
|
.peers-mention-done {
|
|
163
195
|
opacity: 0.7;
|
|
164
196
|
text-decoration: line-through;
|
|
@@ -704,6 +736,22 @@
|
|
|
704
736
|
opacity: 0.6;
|
|
705
737
|
}
|
|
706
738
|
|
|
739
|
+
/* A package waiting for a contract it requires: an hourglass, and a quieter icon. */
|
|
740
|
+
.peers-app-status-waiting {
|
|
741
|
+
background-color: #b86e00;
|
|
742
|
+
border: 2px solid var(--bs-body-bg);
|
|
743
|
+
color: #ffffff;
|
|
744
|
+
font-size: 11px;
|
|
745
|
+
height: 22px;
|
|
746
|
+
padding: 0;
|
|
747
|
+
width: 22px;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
.peers-app-tile-waiting .peers-app-icon {
|
|
751
|
+
filter: grayscale(0.5);
|
|
752
|
+
opacity: 0.7;
|
|
753
|
+
}
|
|
754
|
+
|
|
707
755
|
.peers-app-tile-dev .peers-app-icon {
|
|
708
756
|
border: 1px dashed var(--bs-secondary-color);
|
|
709
757
|
}
|
|
@@ -795,6 +843,10 @@
|
|
|
795
843
|
color: inherit;
|
|
796
844
|
}
|
|
797
845
|
|
|
846
|
+
.peers-app-menu-waiting {
|
|
847
|
+
color: var(--bs-warning-text-emphasis);
|
|
848
|
+
}
|
|
849
|
+
|
|
798
850
|
/* The confirmation before removing an app from the group. */
|
|
799
851
|
.peers-apps-dialog-backdrop {
|
|
800
852
|
align-items: flex-start;
|
|
@@ -1153,3 +1205,148 @@
|
|
|
1153
1205
|
display: -webkit-box;
|
|
1154
1206
|
overflow: hidden;
|
|
1155
1207
|
}
|
|
1208
|
+
|
|
1209
|
+
/*
|
|
1210
|
+
* The screen a package shows in place of its own while it waits for a contract it requires:
|
|
1211
|
+
* what it needs, and the packages that provide it. Its rows are the Get apps sheet's.
|
|
1212
|
+
*/
|
|
1213
|
+
.peers-waiting {
|
|
1214
|
+
margin: 0 auto;
|
|
1215
|
+
max-width: 640px;
|
|
1216
|
+
padding: 28px 8px 48px;
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
.peers-waiting-head {
|
|
1220
|
+
align-items: center;
|
|
1221
|
+
display: flex;
|
|
1222
|
+
gap: 18px;
|
|
1223
|
+
margin-bottom: 14px;
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
.peers-waiting-head .peers-app-icon {
|
|
1227
|
+
--peers-tile-size: 64px;
|
|
1228
|
+
position: relative;
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
.peers-waiting-badge {
|
|
1232
|
+
align-items: center;
|
|
1233
|
+
background-color: #b86e00;
|
|
1234
|
+
border: 2px solid var(--bs-body-bg);
|
|
1235
|
+
border-radius: 50%;
|
|
1236
|
+
bottom: -6px;
|
|
1237
|
+
color: #ffffff;
|
|
1238
|
+
display: flex;
|
|
1239
|
+
font-size: 12px;
|
|
1240
|
+
height: 26px;
|
|
1241
|
+
justify-content: center;
|
|
1242
|
+
position: absolute;
|
|
1243
|
+
right: -6px;
|
|
1244
|
+
width: 26px;
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
.peers-waiting-head h2 {
|
|
1248
|
+
color: var(--bs-emphasis-color);
|
|
1249
|
+
font-size: 22px;
|
|
1250
|
+
font-weight: 650;
|
|
1251
|
+
margin: 0 0 4px;
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
.peers-waiting-lead {
|
|
1255
|
+
font-size: 15px;
|
|
1256
|
+
margin: 0;
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
.peers-waiting-explain {
|
|
1260
|
+
color: var(--bs-secondary-color);
|
|
1261
|
+
font-size: 13.5px;
|
|
1262
|
+
line-height: 1.5;
|
|
1263
|
+
margin: 0 0 16px;
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
.peers-waiting-need {
|
|
1267
|
+
border: 1px solid var(--bs-border-color);
|
|
1268
|
+
border-radius: 14px;
|
|
1269
|
+
margin: 0 0 14px;
|
|
1270
|
+
padding: 14px 16px 4px;
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
.peers-waiting-need h3 {
|
|
1274
|
+
align-items: center;
|
|
1275
|
+
color: var(--bs-emphasis-color);
|
|
1276
|
+
display: flex;
|
|
1277
|
+
font-size: 15px;
|
|
1278
|
+
font-weight: 650;
|
|
1279
|
+
gap: 8px;
|
|
1280
|
+
margin: 0 0 4px;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
.peers-waiting-desc {
|
|
1284
|
+
color: var(--bs-secondary-color);
|
|
1285
|
+
font-size: 13px;
|
|
1286
|
+
line-height: 1.45;
|
|
1287
|
+
margin: 0 0 4px;
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
.peers-waiting-none {
|
|
1291
|
+
color: var(--bs-secondary-color);
|
|
1292
|
+
font-size: 13.5px;
|
|
1293
|
+
margin: 8px 0 12px;
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
.peers-waiting-need .peers-get-apps-row .peers-app-icon {
|
|
1297
|
+
--peers-tile-size: 44px;
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
.peers-waiting-need .peers-get-apps-row:last-child,
|
|
1301
|
+
.peers-waiting-provider:last-child > .peers-get-apps-row {
|
|
1302
|
+
border-bottom: none;
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
/* The next link of a chain: what a waiting provider waits for, indented under it. */
|
|
1306
|
+
.peers-waiting-chain {
|
|
1307
|
+
border-left: 2px solid var(--bs-border-color);
|
|
1308
|
+
margin: 0 0 10px 22px;
|
|
1309
|
+
padding-left: 14px;
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
.peers-waiting-chain .peers-waiting-need {
|
|
1313
|
+
border: none;
|
|
1314
|
+
margin: 0;
|
|
1315
|
+
padding: 6px 0 0;
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
.peers-waiting-foot {
|
|
1319
|
+
font-size: 14px;
|
|
1320
|
+
margin-top: 18px;
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
/* Where another screen embeds a part of a waiting package. */
|
|
1324
|
+
.peers-waiting-notice {
|
|
1325
|
+
align-items: center;
|
|
1326
|
+
border: 1px dashed var(--bs-border-color);
|
|
1327
|
+
border-radius: 10px;
|
|
1328
|
+
color: var(--bs-secondary-color);
|
|
1329
|
+
display: flex;
|
|
1330
|
+
flex-wrap: wrap;
|
|
1331
|
+
font-size: 13.5px;
|
|
1332
|
+
gap: 8px;
|
|
1333
|
+
padding: 10px 12px;
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
@media (max-width: 575.98px) {
|
|
1337
|
+
.peers-waiting {
|
|
1338
|
+
padding: 14px 0 32px;
|
|
1339
|
+
}
|
|
1340
|
+
.peers-waiting-head {
|
|
1341
|
+
gap: 14px;
|
|
1342
|
+
}
|
|
1343
|
+
.peers-waiting-head .peers-app-icon {
|
|
1344
|
+
--peers-tile-size: 52px;
|
|
1345
|
+
}
|
|
1346
|
+
.peers-waiting-head h2 {
|
|
1347
|
+
font-size: 19px;
|
|
1348
|
+
}
|
|
1349
|
+
.peers-waiting-need {
|
|
1350
|
+
padding: 12px 12px 2px;
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { IUIContractDeclaration } from "@peers-app/peers-sdk";
|
|
2
|
+
import type { IHostUIContractClient, IHostUIContractOptions, IPieceHandle } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* A client for a UI contract, to embed its pieces: `<Piece of={client.pieces.picker} …>`. It's
|
|
5
|
+
* made like an API contract client, and its group and provider apply to every piece.
|
|
6
|
+
*
|
|
7
|
+
* ```tsx
|
|
8
|
+
* import type { LabelPickerUI } from "../contracts/label-picker.v1"; // types only
|
|
9
|
+
* const labelPicker = hostUIContract<typeof LabelPickerUI>(labelPickerUIId, 1, { dataContextId: task.groupId });
|
|
10
|
+
* <Piece of={labelPicker.pieces.picker} props={{ itemId: task.taskId }} anchor={plus} open={open} onClose={close} />
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* The package must consume the UI contract (`pkg.consumes(LabelPickerUI, { optional: true })`).
|
|
14
|
+
* Making a client loads nothing; a piece's provider UI loads when it first shows.
|
|
15
|
+
*
|
|
16
|
+
* @param contractId - The UI contract's id, or its declaration.
|
|
17
|
+
* @param version - The version the screen consumes (omit when passing a declaration).
|
|
18
|
+
* @param options - The group (default: the active one) and, for a hub, one provider.
|
|
19
|
+
*/
|
|
20
|
+
export declare function hostUIContract<T extends IUIContractDeclaration<any, any, any>>(contract: T, options?: IHostUIContractOptions): IHostUIContractClient<T>;
|
|
21
|
+
export declare function hostUIContract<T = unknown>(contractId: string, version: number, options?: IHostUIContractOptions): IHostUIContractClient<T>;
|
|
22
|
+
/**
|
|
23
|
+
* A stable string for a handle, for effects and caches: its UI contract version, piece, provider
|
|
24
|
+
* and named group.
|
|
25
|
+
*
|
|
26
|
+
* @param handle - A piece handle.
|
|
27
|
+
*/
|
|
28
|
+
export declare function pieceHandleKey(handle: IPieceHandle): string;
|