@calimero-network/mero-react 11.4.0 → 11.5.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/index.cjs +33 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +33 -24
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1166,6 +1166,8 @@ declare function useCreateWorkspaceResume({ onCreated }: Pick<UseCreateWorkspace
|
|
|
1166
1166
|
|
|
1167
1167
|
/** The dialog's wording, so each app keeps its own. */
|
|
1168
1168
|
interface CreateWorkspaceLabels {
|
|
1169
|
+
/** What is being created (`lobby`, `world`): the default sentences use it. Default `workspace`. */
|
|
1170
|
+
noun?: string;
|
|
1169
1171
|
title?: string;
|
|
1170
1172
|
subtitle?: string;
|
|
1171
1173
|
nameLabel?: string;
|
|
@@ -1188,6 +1190,10 @@ interface CreateWorkspaceDialogProps {
|
|
|
1188
1190
|
/** Where the node's consent page sends the person back. Default: this origin's root, where the app mounts `ConsentPopupReturn`. */
|
|
1189
1191
|
returnTo?: string;
|
|
1190
1192
|
labels?: CreateWorkspaceLabels;
|
|
1193
|
+
/** Extra inputs under the name fields; the app owns their state and reads it in `onCreated`. */
|
|
1194
|
+
fields?: ReactNode;
|
|
1195
|
+
/** Continue waits until this is true (default true): the validity of `fields`. */
|
|
1196
|
+
fieldsValid?: boolean;
|
|
1191
1197
|
/** Prefills "your name" (an app's last used name). */
|
|
1192
1198
|
defaultSelfName?: string;
|
|
1193
1199
|
/** The label under "Where it runs". Default: the cluster named by the node in use. */
|
|
@@ -1212,6 +1218,8 @@ interface WorkspaceReviewProps {
|
|
|
1212
1218
|
cluster?: string;
|
|
1213
1219
|
/** A local development node: its label already says how many nodes there are. */
|
|
1214
1220
|
local?: boolean;
|
|
1221
|
+
/** What is being created, in the sentences around the review. Default `workspace`. */
|
|
1222
|
+
noun?: string;
|
|
1215
1223
|
/** The package release the workspace will run. */
|
|
1216
1224
|
release: ReviewRelease | UnreleasedApp;
|
|
1217
1225
|
/** The workspace is being created: both buttons wait. */
|
|
@@ -1227,7 +1235,7 @@ interface WorkspaceReviewProps {
|
|
|
1227
1235
|
* card and the node's own check. Read by the person before "Create workspace",
|
|
1228
1236
|
* which stays disabled while the node has refused its check.
|
|
1229
1237
|
*/
|
|
1230
|
-
declare function WorkspaceReview({ client, cluster, local, release, creating, disabled, onBack, onCreate }: WorkspaceReviewProps): react_jsx_runtime.JSX.Element;
|
|
1238
|
+
declare function WorkspaceReview({ client, cluster, local, noun, release, creating, disabled, onBack, onCreate }: WorkspaceReviewProps): react_jsx_runtime.JSX.Element;
|
|
1231
1239
|
|
|
1232
1240
|
/** The `postMessage` type the consent pop-up sends its opener when the node sends it back. */
|
|
1233
1241
|
declare const CONSENT_RETURN_MESSAGE = "mero:consent-return";
|
package/dist/index.d.ts
CHANGED
|
@@ -1166,6 +1166,8 @@ declare function useCreateWorkspaceResume({ onCreated }: Pick<UseCreateWorkspace
|
|
|
1166
1166
|
|
|
1167
1167
|
/** The dialog's wording, so each app keeps its own. */
|
|
1168
1168
|
interface CreateWorkspaceLabels {
|
|
1169
|
+
/** What is being created (`lobby`, `world`): the default sentences use it. Default `workspace`. */
|
|
1170
|
+
noun?: string;
|
|
1169
1171
|
title?: string;
|
|
1170
1172
|
subtitle?: string;
|
|
1171
1173
|
nameLabel?: string;
|
|
@@ -1188,6 +1190,10 @@ interface CreateWorkspaceDialogProps {
|
|
|
1188
1190
|
/** Where the node's consent page sends the person back. Default: this origin's root, where the app mounts `ConsentPopupReturn`. */
|
|
1189
1191
|
returnTo?: string;
|
|
1190
1192
|
labels?: CreateWorkspaceLabels;
|
|
1193
|
+
/** Extra inputs under the name fields; the app owns their state and reads it in `onCreated`. */
|
|
1194
|
+
fields?: ReactNode;
|
|
1195
|
+
/** Continue waits until this is true (default true): the validity of `fields`. */
|
|
1196
|
+
fieldsValid?: boolean;
|
|
1191
1197
|
/** Prefills "your name" (an app's last used name). */
|
|
1192
1198
|
defaultSelfName?: string;
|
|
1193
1199
|
/** The label under "Where it runs". Default: the cluster named by the node in use. */
|
|
@@ -1212,6 +1218,8 @@ interface WorkspaceReviewProps {
|
|
|
1212
1218
|
cluster?: string;
|
|
1213
1219
|
/** A local development node: its label already says how many nodes there are. */
|
|
1214
1220
|
local?: boolean;
|
|
1221
|
+
/** What is being created, in the sentences around the review. Default `workspace`. */
|
|
1222
|
+
noun?: string;
|
|
1215
1223
|
/** The package release the workspace will run. */
|
|
1216
1224
|
release: ReviewRelease | UnreleasedApp;
|
|
1217
1225
|
/** The workspace is being created: both buttons wait. */
|
|
@@ -1227,7 +1235,7 @@ interface WorkspaceReviewProps {
|
|
|
1227
1235
|
* card and the node's own check. Read by the person before "Create workspace",
|
|
1228
1236
|
* which stays disabled while the node has refused its check.
|
|
1229
1237
|
*/
|
|
1230
|
-
declare function WorkspaceReview({ client, cluster, local, release, creating, disabled, onBack, onCreate }: WorkspaceReviewProps): react_jsx_runtime.JSX.Element;
|
|
1238
|
+
declare function WorkspaceReview({ client, cluster, local, noun, release, creating, disabled, onBack, onCreate }: WorkspaceReviewProps): react_jsx_runtime.JSX.Element;
|
|
1231
1239
|
|
|
1232
1240
|
/** The `postMessage` type the consent pop-up sends its opener when the node sends it back. */
|
|
1233
1241
|
declare const CONSENT_RETURN_MESSAGE = "mero:consent-return";
|
package/dist/index.js
CHANGED
|
@@ -1947,7 +1947,7 @@ var EVERY_UNITS = { s: "second", m: "minute", h: "hour" };
|
|
|
1947
1947
|
var INVITED_ONLY = "Only people invited to it can open it";
|
|
1948
1948
|
var NOT_READABLE = "Calimero can't read it.";
|
|
1949
1949
|
var TEST_SERVER_ENFORCES = ", as this test server enforces it";
|
|
1950
|
-
var
|
|
1950
|
+
var control = (viewer, noun) => "Only you control it" ;
|
|
1951
1951
|
var MAX_DOC_CHARS = 4e3;
|
|
1952
1952
|
var WORD_TAIL = 8;
|
|
1953
1953
|
var ABBREVIATIONS = /* @__PURE__ */ new Set(["e.g", "i.e", "etc", "vs", "cf"]);
|
|
@@ -2151,9 +2151,10 @@ function codeLine(card, evidence, signed = true) {
|
|
|
2151
2151
|
const fromRelease = `bundle ${shortHash(card.bundle)}, from ${signed ? "the signed release" : "the release as this test server lists it"}`;
|
|
2152
2152
|
return { text: fromRelease };
|
|
2153
2153
|
}
|
|
2154
|
-
function dataStatements(kind, viewer) {
|
|
2155
|
-
|
|
2156
|
-
if (kind === "
|
|
2154
|
+
function dataStatements(kind, viewer, noun = "workspace") {
|
|
2155
|
+
const CONTROL = control();
|
|
2156
|
+
if (kind === "verified") return [`${CONTROL}.`, `${INVITED_ONLY}.`, NOT_READABLE];
|
|
2157
|
+
if (kind === "unsealed") return [`${CONTROL}${TEST_SERVER_ENFORCES}`, `${INVITED_ONLY}${TEST_SERVER_ENFORCES}`];
|
|
2157
2158
|
return [];
|
|
2158
2159
|
}
|
|
2159
2160
|
var OPEN_GROUP_MAX = 3;
|
|
@@ -2275,7 +2276,7 @@ function Diverged({ divergence }) {
|
|
|
2275
2276
|
/* @__PURE__ */ jsx("span", { children: "This node runs different code than the release, so no statement about your data is made here." })
|
|
2276
2277
|
] }) });
|
|
2277
2278
|
}
|
|
2278
|
-
function ReviewBody({ review, release, cluster, local }) {
|
|
2279
|
+
function ReviewBody({ review, release, cluster, local, noun }) {
|
|
2279
2280
|
const { client, state, loaded, retry } = review;
|
|
2280
2281
|
const view = describeShield(state, { code: null });
|
|
2281
2282
|
const card = loaded.status === "ready" ? loaded.card : null;
|
|
@@ -2284,7 +2285,7 @@ function ReviewBody({ review, release, cluster, local }) {
|
|
|
2284
2285
|
const code = card ? codeLine(card, null, sealed) : null;
|
|
2285
2286
|
const summary = card ? summarize(card, sealed) : [];
|
|
2286
2287
|
const risks = card ? exceptions(card, sealed) : [];
|
|
2287
|
-
const statements = dataStatements(view.kind, "creator");
|
|
2288
|
+
const statements = dataStatements(view.kind, "creator", noun);
|
|
2288
2289
|
const nodes = client && !local ? `${client.nodes.length} ${client.nodes.length === 1 ? "node" : "nodes"}` : "";
|
|
2289
2290
|
const unreleased = loaded.status === "none";
|
|
2290
2291
|
const unknown = unreleased ? "This build has no signed release, so what it can do and what leaves the sealed hardware is not known." : !card ? "What leaves the sealed hardware is not known until the app's details load." : !card.abi ? "This app publishes no action list, so what it makes visible to anyone is not known." : null;
|
|
@@ -2292,7 +2293,7 @@ function ReviewBody({ review, release, cluster, local }) {
|
|
|
2292
2293
|
loaded.status === "error" && /* @__PURE__ */ jsxs("div", { className: "mero-cw-review__alert", role: "alert", children: [
|
|
2293
2294
|
/* @__PURE__ */ jsxs("p", { children: [
|
|
2294
2295
|
loaded.message,
|
|
2295
|
-
client ?
|
|
2296
|
+
client ? ` You can still create the ${noun}.` : ""
|
|
2296
2297
|
] }),
|
|
2297
2298
|
/* @__PURE__ */ jsx("button", { type: "button", className: "mero-cw-review__btn", onClick: retry, children: "Try again" })
|
|
2298
2299
|
] }),
|
|
@@ -2388,19 +2389,19 @@ function ReviewBody({ review, release, cluster, local }) {
|
|
|
2388
2389
|
] }) })
|
|
2389
2390
|
] });
|
|
2390
2391
|
}
|
|
2391
|
-
function WorkspaceReview({ client, cluster, local, release, creating = false, disabled = false, onBack, onCreate }) {
|
|
2392
|
+
function WorkspaceReview({ client, cluster, local, noun = "workspace", release, creating = false, disabled = false, onBack, onCreate }) {
|
|
2392
2393
|
const heading = useRef(null);
|
|
2393
2394
|
useEffect(() => heading.current?.focus(), []);
|
|
2394
2395
|
const review = useReview(client, release);
|
|
2395
2396
|
const refused = review.state.status === "refused";
|
|
2396
2397
|
return /* @__PURE__ */ jsxs("div", { className: "mero-cw-review", children: [
|
|
2397
2398
|
/* @__PURE__ */ jsx("h2", { ref: heading, tabIndex: -1, className: "mero-cw-review__title", children: "Review before creating" }),
|
|
2398
|
-
/* @__PURE__ */ jsx("p", { className: "mero-cw-review__lede", children:
|
|
2399
|
-
/* @__PURE__ */ jsx(ReviewBody, { review, release, cluster, local }),
|
|
2399
|
+
/* @__PURE__ */ jsx("p", { className: "mero-cw-review__lede", children: `Check what this app can do and where it will run before you create the ${noun}.` }),
|
|
2400
|
+
/* @__PURE__ */ jsx(ReviewBody, { review, release, cluster, local, noun }),
|
|
2400
2401
|
refused && /* @__PURE__ */ jsx("p", { className: "mero-cw-review__muted", children: "Create is unavailable: this node did not pass its check." }),
|
|
2401
2402
|
/* @__PURE__ */ jsxs("div", { className: "mero-cw-review__buttons", children: [
|
|
2402
2403
|
/* @__PURE__ */ jsx("button", { type: "button", className: "mero-cw-review__btn", disabled: creating, onClick: onBack, children: "Back" }),
|
|
2403
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "mero-cw-review__btn mero-cw-review__btn--primary", disabled: creating || disabled || refused, onClick: onCreate, children: creating ? "Creating\u2026" :
|
|
2404
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "mero-cw-review__btn mero-cw-review__btn--primary", disabled: creating || disabled || refused, onClick: onCreate, children: creating ? "Creating\u2026" : `Create ${noun}` })
|
|
2404
2405
|
] })
|
|
2405
2406
|
] });
|
|
2406
2407
|
}
|
|
@@ -2613,15 +2614,21 @@ function useCreateWorkspaceResume({ onCreated }) {
|
|
|
2613
2614
|
}, [client]);
|
|
2614
2615
|
return { message };
|
|
2615
2616
|
}
|
|
2616
|
-
var
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2617
|
+
var NOUN = "workspace";
|
|
2618
|
+
function wording(labels) {
|
|
2619
|
+
const noun = labels?.noun ?? NOUN;
|
|
2620
|
+
return {
|
|
2621
|
+
noun,
|
|
2622
|
+
title: `Create ${noun}`,
|
|
2623
|
+
subtitle: `Name your ${noun}, and choose how others in it will see you.`,
|
|
2624
|
+
nameLabel: `${noun.charAt(0).toUpperCase()}${noun.slice(1)} name`,
|
|
2625
|
+
namePlaceholder: "",
|
|
2626
|
+
selfLabel: "Your name",
|
|
2627
|
+
selfPlaceholder: "",
|
|
2628
|
+
next: "Continue",
|
|
2629
|
+
...labels
|
|
2630
|
+
};
|
|
2631
|
+
}
|
|
2625
2632
|
var subscribeNothing = () => () => void 0;
|
|
2626
2633
|
var useMounted = () => useSyncExternalStore(subscribeNothing, () => true, () => false);
|
|
2627
2634
|
function ResumeNotice({ onCreated }) {
|
|
@@ -2644,8 +2651,8 @@ function CreateWorkspaceDialog({ client, passkey, ...props }) {
|
|
|
2644
2651
|
const inner = /* @__PURE__ */ jsx(Dialog, { ...props });
|
|
2645
2652
|
return client ? /* @__PURE__ */ jsx(MeroProvider, { client, sessionStore, passkey, children: inner }) : inner;
|
|
2646
2653
|
}
|
|
2647
|
-
function Dialog({ open, onClose, release, onCreated, returnTo, labels, defaultSelfName = "", cluster }) {
|
|
2648
|
-
const text =
|
|
2654
|
+
function Dialog({ open, onClose, release, onCreated, returnTo, labels, defaultSelfName = "", cluster, fields, fieldsValid = true }) {
|
|
2655
|
+
const text = wording(labels);
|
|
2649
2656
|
const { client, cluster: ambientCluster, nodeUrl } = useMero();
|
|
2650
2657
|
const flow = useCreateWorkspace({ returnTo: returnTo ?? `${typeof window === "undefined" ? "" : window.location.origin}/`, onCreated });
|
|
2651
2658
|
const [step, setStep] = useState("names");
|
|
@@ -2684,7 +2691,7 @@ function Dialog({ open, onClose, release, onCreated, returnTo, labels, defaultSe
|
|
|
2684
2691
|
{
|
|
2685
2692
|
onSubmit: (e) => {
|
|
2686
2693
|
e.preventDefault();
|
|
2687
|
-
if (trimmed.name && trimmed.self) setStep("review");
|
|
2694
|
+
if (trimmed.name && trimmed.self && fieldsValid) setStep("review");
|
|
2688
2695
|
},
|
|
2689
2696
|
children: [
|
|
2690
2697
|
/* @__PURE__ */ jsx("h2", { className: "mero-cw-title", children: text.title }),
|
|
@@ -2697,7 +2704,8 @@ function Dialog({ open, onClose, release, onCreated, returnTo, labels, defaultSe
|
|
|
2697
2704
|
/* @__PURE__ */ jsx("label", { htmlFor: ids[1], children: text.selfLabel }),
|
|
2698
2705
|
/* @__PURE__ */ jsx("input", { id: ids[1], value: selfName, placeholder: text.selfPlaceholder, onChange: (e) => setSelfName(e.target.value) })
|
|
2699
2706
|
] }),
|
|
2700
|
-
|
|
2707
|
+
fields,
|
|
2708
|
+
/* @__PURE__ */ jsx("button", { type: "submit", className: "mero-cw-btn mero-cw-btn--primary mero-cw-btn--full", disabled: !trimmed.name || !trimmed.self || !fieldsValid, children: text.next })
|
|
2701
2709
|
]
|
|
2702
2710
|
}
|
|
2703
2711
|
) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -2708,6 +2716,7 @@ function Dialog({ open, onClose, release, onCreated, returnTo, labels, defaultSe
|
|
|
2708
2716
|
client,
|
|
2709
2717
|
cluster: where,
|
|
2710
2718
|
local: !!node && clusterName(node) === "merod local",
|
|
2719
|
+
noun: text.noun,
|
|
2711
2720
|
release,
|
|
2712
2721
|
creating: flow.phase === "creating",
|
|
2713
2722
|
disabled: !flow.ready,
|