@dxos/plugin-client 0.8.1 → 0.8.2-main.10c050d
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/lib/browser/{app-graph-builder-WAS4YZNA.mjs → app-graph-builder-CBRN2DMK.mjs} +36 -32
- package/dist/lib/browser/app-graph-builder-CBRN2DMK.mjs.map +7 -0
- package/dist/lib/browser/chunk-DCUIJY75.mjs +694 -0
- package/dist/lib/browser/chunk-DCUIJY75.mjs.map +7 -0
- package/dist/lib/browser/chunk-IA3AVM4I.mjs +111 -0
- package/dist/lib/browser/chunk-IA3AVM4I.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BGY6BSUC.mjs → chunk-PSSNS4C6.mjs} +2 -2
- package/dist/lib/{node-esm/chunk-K3KGGSJZ.mjs.map → browser/chunk-PSSNS4C6.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-4PLF3BEB.mjs → chunk-UCVFWBKT.mjs} +2 -2
- package/dist/lib/{node-esm/chunk-BP56BGZR.mjs.map → browser/chunk-UCVFWBKT.mjs.map} +1 -1
- package/dist/lib/browser/{client-LV67Q3R7.mjs → client-NMS3MSFP.mjs} +5 -4
- package/dist/lib/browser/client-NMS3MSFP.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +12 -12
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-NCISOZW4.mjs → intent-resolver-KGM6A3BF.mjs} +14 -14
- package/dist/lib/browser/intent-resolver-KGM6A3BF.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/migrations-QRQV6ZAM.mjs +23 -0
- package/dist/lib/browser/migrations-QRQV6ZAM.mjs.map +7 -0
- package/dist/lib/browser/{react-context-WEH7SL4I.mjs → react-context-IE2O2OYK.mjs} +2 -2
- package/dist/lib/browser/{react-surface-J7SZR2J6.mjs → react-surface-CKZHHWY3.mjs} +3 -3
- package/dist/lib/browser/schema-defs-DNRDVQQJ.mjs +25 -0
- package/dist/lib/browser/schema-defs-DNRDVQQJ.mjs.map +7 -0
- package/dist/lib/browser/types.mjs +1 -1
- package/dist/lib/node/{app-graph-builder-PXOJZJO5.cjs → app-graph-builder-BEEYM3A5.cjs} +45 -41
- package/dist/lib/node/app-graph-builder-BEEYM3A5.cjs.map +7 -0
- package/dist/lib/node/chunk-73HHNJMV.cjs +719 -0
- package/dist/lib/node/chunk-73HHNJMV.cjs.map +7 -0
- package/dist/lib/node/chunk-BL6EBWOS.cjs +131 -0
- package/dist/lib/node/chunk-BL6EBWOS.cjs.map +7 -0
- package/dist/lib/node/{chunk-ZVQIICEN.cjs → chunk-CIYUKY3J.cjs} +5 -5
- package/dist/lib/node/{chunk-ZVQIICEN.cjs.map → chunk-CIYUKY3J.cjs.map} +1 -1
- package/dist/lib/node/{chunk-W64EOF2B.cjs → chunk-DNKJCPU7.cjs} +5 -5
- package/dist/lib/node/{chunk-W64EOF2B.cjs.map → chunk-DNKJCPU7.cjs.map} +1 -1
- package/dist/lib/node/{client-BKTGRBYM.cjs → client-Q3EQS4HA.cjs} +10 -9
- package/dist/lib/node/client-Q3EQS4HA.cjs.map +7 -0
- package/dist/lib/node/index.cjs +19 -19
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/{intent-resolver-U2576ALY.cjs → intent-resolver-Q4QBA5B2.cjs} +34 -34
- package/dist/lib/node/intent-resolver-Q4QBA5B2.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{migrations-TGNI4FVL.cjs → migrations-6FEWMF7U.cjs} +12 -10
- package/dist/lib/node/migrations-6FEWMF7U.cjs.map +7 -0
- package/dist/lib/node/{react-context-SF3M3YLR.cjs → react-context-JS7Y5ZOK.cjs} +6 -6
- package/dist/lib/node/{react-surface-BSTIXMER.cjs → react-surface-GHKLUOKW.cjs} +24 -24
- package/dist/lib/node/{schema-INQ72F54.cjs → schema-defs-TA52ARBO.cjs} +14 -12
- package/dist/lib/node/schema-defs-TA52ARBO.cjs.map +7 -0
- package/dist/lib/node/types.cjs +3 -3
- package/dist/lib/node/types.cjs.map +1 -1
- package/dist/lib/node-esm/{app-graph-builder-KIN6NWFI.mjs → app-graph-builder-OZEAAKNT.mjs} +36 -32
- package/dist/lib/node-esm/app-graph-builder-OZEAAKNT.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-K3KGGSJZ.mjs → chunk-37E3EI46.mjs} +2 -2
- package/dist/lib/{browser/chunk-BGY6BSUC.mjs.map → node-esm/chunk-37E3EI46.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-BP56BGZR.mjs → chunk-FJYSQRBO.mjs} +2 -2
- package/dist/lib/{browser/chunk-4PLF3BEB.mjs.map → node-esm/chunk-FJYSQRBO.mjs.map} +1 -1
- package/dist/lib/node-esm/chunk-STGGUFV2.mjs +112 -0
- package/dist/lib/node-esm/chunk-STGGUFV2.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ULXZABZ4.mjs +695 -0
- package/dist/lib/node-esm/chunk-ULXZABZ4.mjs.map +7 -0
- package/dist/lib/node-esm/{client-QQD6WFOB.mjs → client-EBFQZRSF.mjs} +5 -4
- package/dist/lib/node-esm/client-EBFQZRSF.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +12 -12
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-G25U4UGI.mjs → intent-resolver-2GCG4LCE.mjs} +14 -14
- package/dist/lib/node-esm/intent-resolver-2GCG4LCE.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{migrations-IVGATGZR.mjs → migrations-AK43ZE6G.mjs} +9 -7
- package/dist/lib/node-esm/migrations-AK43ZE6G.mjs.map +7 -0
- package/dist/lib/node-esm/{react-context-EAKKTE5A.mjs → react-context-6N7NMUJE.mjs} +2 -2
- package/dist/lib/node-esm/{react-surface-ZPI7T4EM.mjs → react-surface-UCUL26AF.mjs} +3 -3
- package/dist/lib/node-esm/schema-defs-O2KQQXJH.mjs +26 -0
- package/dist/lib/node-esm/schema-defs-O2KQQXJH.mjs.map +7 -0
- package/dist/lib/node-esm/types.mjs +1 -1
- package/dist/types/src/ClientPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +2 -179
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/client.d.ts +3 -3
- package/dist/types/src/capabilities/client.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +5 -181
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +2 -2
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/migrations.d.ts +2 -2
- package/dist/types/src/capabilities/migrations.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/schema-defs.d.ts +4 -0
- package/dist/types/src/capabilities/schema-defs.d.ts.map +1 -0
- package/dist/types/src/components/DevicesContainer.d.ts +4 -3
- package/dist/types/src/components/DevicesContainer.d.ts.map +1 -1
- package/dist/types/src/components/DevicesContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/JoinDialog.d.ts.map +1 -1
- package/dist/types/src/components/ProfileContainer.d.ts.map +1 -1
- package/dist/types/src/components/RecoveryCodeDialog.d.ts.map +1 -1
- package/dist/types/src/components/RecoveryCredentialsContainer.d.ts.map +1 -1
- package/dist/types/src/components/ResetDialog.d.ts.map +1 -1
- package/dist/types/src/components/ResetDialog.stories.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +59 -53
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +33 -26
- package/src/ClientPlugin.ts +2 -2
- package/src/capabilities/app-graph-builder.ts +94 -76
- package/src/capabilities/client.ts +4 -3
- package/src/capabilities/index.ts +1 -1
- package/src/capabilities/intent-resolver.ts +11 -11
- package/src/capabilities/migrations.ts +14 -11
- package/src/capabilities/schema-defs.ts +29 -0
- package/src/components/DevicesContainer.stories.tsx +7 -3
- package/src/components/DevicesContainer.tsx +85 -61
- package/src/components/ProfileContainer.stories.tsx +1 -1
- package/src/components/ProfileContainer.tsx +30 -21
- package/src/components/RecoveryCodeDialog.stories.tsx +1 -1
- package/src/components/RecoveryCredentialsContainer.stories.tsx +2 -2
- package/src/components/RecoveryCredentialsContainer.tsx +48 -46
- package/src/components/ResetDialog.stories.tsx +7 -1
- package/src/translations.ts +2 -2
- package/src/types.ts +60 -47
- package/dist/lib/browser/app-graph-builder-WAS4YZNA.mjs.map +0 -7
- package/dist/lib/browser/chunk-AN7FJKIJ.mjs +0 -105
- package/dist/lib/browser/chunk-AN7FJKIJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-XZ4TQC56.mjs +0 -619
- package/dist/lib/browser/chunk-XZ4TQC56.mjs.map +0 -7
- package/dist/lib/browser/client-LV67Q3R7.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-NCISOZW4.mjs.map +0 -7
- package/dist/lib/browser/migrations-3DWFOL5Q.mjs +0 -21
- package/dist/lib/browser/migrations-3DWFOL5Q.mjs.map +0 -7
- package/dist/lib/browser/schema-JQAT6Q7S.mjs +0 -23
- package/dist/lib/browser/schema-JQAT6Q7S.mjs.map +0 -7
- package/dist/lib/node/app-graph-builder-PXOJZJO5.cjs.map +0 -7
- package/dist/lib/node/chunk-3JE5BFCT.cjs +0 -644
- package/dist/lib/node/chunk-3JE5BFCT.cjs.map +0 -7
- package/dist/lib/node/chunk-FROKBEVH.cjs +0 -125
- package/dist/lib/node/chunk-FROKBEVH.cjs.map +0 -7
- package/dist/lib/node/client-BKTGRBYM.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-U2576ALY.cjs.map +0 -7
- package/dist/lib/node/migrations-TGNI4FVL.cjs.map +0 -7
- package/dist/lib/node/schema-INQ72F54.cjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-KIN6NWFI.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AD5W5QCQ.mjs +0 -106
- package/dist/lib/node-esm/chunk-AD5W5QCQ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LZN2UNN7.mjs +0 -620
- package/dist/lib/node-esm/chunk-LZN2UNN7.mjs.map +0 -7
- package/dist/lib/node-esm/client-QQD6WFOB.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-G25U4UGI.mjs.map +0 -7
- package/dist/lib/node-esm/migrations-IVGATGZR.mjs.map +0 -7
- package/dist/lib/node-esm/schema-OK7HY3JJ.mjs +0 -24
- package/dist/lib/node-esm/schema-OK7HY3JJ.mjs.map +0 -7
- package/dist/types/src/capabilities/schema.d.ts +0 -4
- package/dist/types/src/capabilities/schema.d.ts.map +0 -1
- package/src/capabilities/schema.ts +0 -26
- /package/dist/lib/browser/{react-context-WEH7SL4I.mjs.map → react-context-IE2O2OYK.mjs.map} +0 -0
- /package/dist/lib/browser/{react-surface-J7SZR2J6.mjs.map → react-surface-CKZHHWY3.mjs.map} +0 -0
- /package/dist/lib/node/{react-context-SF3M3YLR.cjs.map → react-context-JS7Y5ZOK.cjs.map} +0 -0
- /package/dist/lib/node/{react-surface-BSTIXMER.cjs.map → react-surface-GHKLUOKW.cjs.map} +0 -0
- /package/dist/lib/node-esm/{react-context-EAKKTE5A.mjs.map → react-context-6N7NMUJE.mjs.map} +0 -0
- /package/dist/lib/node-esm/{react-surface-ZPI7T4EM.mjs.map → react-surface-UCUL26AF.mjs.map} +0 -0
|
@@ -0,0 +1,694 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ClientAction
|
|
3
|
+
} from "./chunk-IA3AVM4I.mjs";
|
|
4
|
+
import {
|
|
5
|
+
CLIENT_PLUGIN
|
|
6
|
+
} from "./chunk-MCEXD5XH.mjs";
|
|
7
|
+
|
|
8
|
+
// packages/plugins/plugin-client/src/components/DevicesContainer.tsx
|
|
9
|
+
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
10
|
+
import { Check, X } from "@phosphor-icons/react";
|
|
11
|
+
import React, { useCallback, useEffect, useState } from "react";
|
|
12
|
+
import { QR } from "react-qr-rounded";
|
|
13
|
+
import { createIntent, useIntentDispatcher } from "@dxos/app-framework";
|
|
14
|
+
import { log } from "@dxos/log";
|
|
15
|
+
import { useClient, useMulticastObservable } from "@dxos/react-client";
|
|
16
|
+
import { useDevices } from "@dxos/react-client/halo";
|
|
17
|
+
import { Invitation, InvitationEncoder } from "@dxos/react-client/invitations";
|
|
18
|
+
import { useNetworkStatus } from "@dxos/react-client/mesh";
|
|
19
|
+
import { Button, Clipboard, IconButton, List, useId, useTranslation } from "@dxos/react-ui";
|
|
20
|
+
import { ControlFrame, ControlFrameItem, ControlGroup, ControlItem, ControlPage, ControlSection } from "@dxos/react-ui-form";
|
|
21
|
+
import { StackItem } from "@dxos/react-ui-stack";
|
|
22
|
+
import { getSize, mx } from "@dxos/react-ui-theme";
|
|
23
|
+
import { AuthCode, Centered, DeviceListItem, Emoji, Viewport } from "@dxos/shell/react";
|
|
24
|
+
import { hexToEmoji } from "@dxos/util";
|
|
25
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-client/src/components/DevicesContainer.tsx";
|
|
26
|
+
var DevicesContainer = ({ createInvitationUrl }) => {
|
|
27
|
+
var _effect = _useSignals();
|
|
28
|
+
try {
|
|
29
|
+
const { t } = useTranslation("os");
|
|
30
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
31
|
+
const devices = useDevices();
|
|
32
|
+
const { swarm: connectionState } = useNetworkStatus();
|
|
33
|
+
const handleResetStorage = useCallback(() => dispatch(createIntent(ClientAction.ResetStorage)), [
|
|
34
|
+
dispatch
|
|
35
|
+
]);
|
|
36
|
+
const handleRecover = useCallback(() => dispatch(createIntent(ClientAction.ResetStorage, {
|
|
37
|
+
mode: "recover"
|
|
38
|
+
})), [
|
|
39
|
+
dispatch
|
|
40
|
+
]);
|
|
41
|
+
const handleJoinNewIdentity = useCallback(() => dispatch(createIntent(ClientAction.ResetStorage, {
|
|
42
|
+
mode: "join new identity"
|
|
43
|
+
})), [
|
|
44
|
+
dispatch
|
|
45
|
+
]);
|
|
46
|
+
return /* @__PURE__ */ React.createElement(Clipboard.Provider, null, /* @__PURE__ */ React.createElement(StackItem.Content, {
|
|
47
|
+
classNames: "block overflow-y-auto"
|
|
48
|
+
}, /* @__PURE__ */ React.createElement(ControlPage, null, /* @__PURE__ */ React.createElement(ControlSection, {
|
|
49
|
+
title: t("devices verbose label", {
|
|
50
|
+
ns: CLIENT_PLUGIN
|
|
51
|
+
}),
|
|
52
|
+
description: t("devices description", {
|
|
53
|
+
ns: CLIENT_PLUGIN
|
|
54
|
+
})
|
|
55
|
+
}, /* @__PURE__ */ React.createElement(ControlFrame, null, /* @__PURE__ */ React.createElement(ControlFrameItem, {
|
|
56
|
+
title: t("devices label", {
|
|
57
|
+
ns: CLIENT_PLUGIN
|
|
58
|
+
})
|
|
59
|
+
}, /* @__PURE__ */ React.createElement(List, null, devices.map((device) => {
|
|
60
|
+
return /* @__PURE__ */ React.createElement(DeviceListItem, {
|
|
61
|
+
key: device.deviceKey.toHex(),
|
|
62
|
+
device,
|
|
63
|
+
connectionState
|
|
64
|
+
});
|
|
65
|
+
}))), createInvitationUrl && /* @__PURE__ */ React.createElement(ControlFrameItem, {
|
|
66
|
+
title: "Add device"
|
|
67
|
+
}, /* @__PURE__ */ React.createElement(DeviceInvitation, {
|
|
68
|
+
createInvitationUrl
|
|
69
|
+
})))), /* @__PURE__ */ React.createElement(ControlSection, {
|
|
70
|
+
title: t("danger zone title", {
|
|
71
|
+
ns: CLIENT_PLUGIN
|
|
72
|
+
}),
|
|
73
|
+
description: t("danger zone description", {
|
|
74
|
+
ns: CLIENT_PLUGIN
|
|
75
|
+
})
|
|
76
|
+
}, /* @__PURE__ */ React.createElement(ControlGroup, null, /* @__PURE__ */ React.createElement(ControlItem, {
|
|
77
|
+
title: t("reset device label"),
|
|
78
|
+
description: t("reset device description", {
|
|
79
|
+
ns: CLIENT_PLUGIN
|
|
80
|
+
})
|
|
81
|
+
}, /* @__PURE__ */ React.createElement(Button, {
|
|
82
|
+
variant: "destructive",
|
|
83
|
+
onClick: handleResetStorage,
|
|
84
|
+
"data-testid": "devicesContainer.reset"
|
|
85
|
+
}, t("reset device label"))), /* @__PURE__ */ React.createElement(ControlItem, {
|
|
86
|
+
title: t("recover identity label"),
|
|
87
|
+
description: t("recover identity description", {
|
|
88
|
+
ns: CLIENT_PLUGIN
|
|
89
|
+
})
|
|
90
|
+
}, /* @__PURE__ */ React.createElement(Button, {
|
|
91
|
+
variant: "destructive",
|
|
92
|
+
onClick: handleRecover,
|
|
93
|
+
"data-testid": "devicesContainer.recover"
|
|
94
|
+
}, t("recover identity label"))), /* @__PURE__ */ React.createElement(ControlItem, {
|
|
95
|
+
title: t("join new identity label"),
|
|
96
|
+
description: t("join new identity description", {
|
|
97
|
+
ns: CLIENT_PLUGIN
|
|
98
|
+
})
|
|
99
|
+
}, /* @__PURE__ */ React.createElement(Button, {
|
|
100
|
+
variant: "destructive",
|
|
101
|
+
onClick: handleJoinNewIdentity,
|
|
102
|
+
"data-testid": "devicesContainer.joinExisting"
|
|
103
|
+
}, t("join new identity label"))))))));
|
|
104
|
+
} finally {
|
|
105
|
+
_effect.f();
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
var DeviceInvitation = (props) => {
|
|
109
|
+
var _effect = _useSignals();
|
|
110
|
+
try {
|
|
111
|
+
const client = useClient();
|
|
112
|
+
const [invitation, setInvitation] = useState();
|
|
113
|
+
const onInvitationCreate = useCallback(() => {
|
|
114
|
+
const invitation2 = client.halo.share();
|
|
115
|
+
if (client.config.values.runtime?.app?.env?.DX_ENVIRONMENT !== "production") {
|
|
116
|
+
const subscription = invitation2.subscribe((invitation3) => {
|
|
117
|
+
const invitationCode = InvitationEncoder.encode(invitation3);
|
|
118
|
+
if (invitation3.state === Invitation.State.CONNECTING) {
|
|
119
|
+
log.info(JSON.stringify({
|
|
120
|
+
invitationCode,
|
|
121
|
+
authCode: invitation3.authCode
|
|
122
|
+
}), void 0, {
|
|
123
|
+
F: __dxlog_file,
|
|
124
|
+
L: 141,
|
|
125
|
+
S: void 0,
|
|
126
|
+
C: (f, a) => f(...a)
|
|
127
|
+
});
|
|
128
|
+
subscription.unsubscribe();
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
setInvitation(invitation2);
|
|
133
|
+
}, [
|
|
134
|
+
client
|
|
135
|
+
]);
|
|
136
|
+
const onInvitationDone = useCallback(() => {
|
|
137
|
+
setInvitation(void 0);
|
|
138
|
+
}, []);
|
|
139
|
+
if (invitation) {
|
|
140
|
+
return /* @__PURE__ */ React.createElement(DeviceInvitationImpl, {
|
|
141
|
+
...props,
|
|
142
|
+
invitation,
|
|
143
|
+
onInvitationCreate,
|
|
144
|
+
onInvitationDone
|
|
145
|
+
});
|
|
146
|
+
} else {
|
|
147
|
+
return /* @__PURE__ */ React.createElement(InvitationSection, {
|
|
148
|
+
...props,
|
|
149
|
+
onInvitationCreate,
|
|
150
|
+
onInvitationDone
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
} finally {
|
|
154
|
+
_effect.f();
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
var DeviceInvitationImpl = ({ invitation: invitationObservable, createInvitationUrl, onInvitationDone, onInvitationCreate }) => {
|
|
158
|
+
var _effect = _useSignals();
|
|
159
|
+
try {
|
|
160
|
+
const invitation = useMulticastObservable(invitationObservable);
|
|
161
|
+
const url = createInvitationUrl(InvitationEncoder.encode(invitation));
|
|
162
|
+
useEffect(() => {
|
|
163
|
+
if (invitation.state >= Invitation.State.SUCCESS) {
|
|
164
|
+
onInvitationDone();
|
|
165
|
+
}
|
|
166
|
+
}, [
|
|
167
|
+
invitation.state
|
|
168
|
+
]);
|
|
169
|
+
return /* @__PURE__ */ React.createElement(InvitationSection, {
|
|
170
|
+
...invitation,
|
|
171
|
+
url,
|
|
172
|
+
onInvitationDone,
|
|
173
|
+
onInvitationCreate
|
|
174
|
+
});
|
|
175
|
+
} finally {
|
|
176
|
+
_effect.f();
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
var InvitationSection = ({ state = -1, authCode, invitationId = "never", url = "never", onInvitationDone = () => {
|
|
180
|
+
}, onInvitationCreate = () => {
|
|
181
|
+
} }) => {
|
|
182
|
+
var _effect = _useSignals();
|
|
183
|
+
try {
|
|
184
|
+
const { t } = useTranslation(CLIENT_PLUGIN);
|
|
185
|
+
const activeView = state < 0 ? "init" : state >= Invitation.State.CANCELLED ? "complete" : state >= Invitation.State.READY_FOR_AUTHENTICATION && authCode ? "auth-code" : "qr-code";
|
|
186
|
+
return activeView === "init" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", {
|
|
187
|
+
className: "text-description mbe-2"
|
|
188
|
+
}, t("add device description")), /* @__PURE__ */ React.createElement(IconButton, {
|
|
189
|
+
icon: "ph--plus--regular",
|
|
190
|
+
label: t("create device invitation label"),
|
|
191
|
+
disabled: state >= 0,
|
|
192
|
+
classNames: "is-full",
|
|
193
|
+
"data-testid": "devicesContainer.createInvitation",
|
|
194
|
+
onClick: onInvitationCreate
|
|
195
|
+
})) : /* @__PURE__ */ React.createElement(Viewport.Root, {
|
|
196
|
+
activeView
|
|
197
|
+
}, /* @__PURE__ */ React.createElement(Viewport.Views, null, /* @__PURE__ */ React.createElement(Viewport.View, {
|
|
198
|
+
id: "init"
|
|
199
|
+
}), /* @__PURE__ */ React.createElement(Viewport.View, {
|
|
200
|
+
id: "complete"
|
|
201
|
+
}, /* @__PURE__ */ React.createElement(InvitationComplete, {
|
|
202
|
+
statusValue: state
|
|
203
|
+
})), /* @__PURE__ */ React.createElement(Viewport.View, {
|
|
204
|
+
id: "auth-code"
|
|
205
|
+
}, /* @__PURE__ */ React.createElement(InvitationAuthCode, {
|
|
206
|
+
id: invitationId,
|
|
207
|
+
code: authCode ?? "never",
|
|
208
|
+
onCancel: onInvitationDone
|
|
209
|
+
})), /* @__PURE__ */ React.createElement(Viewport.View, {
|
|
210
|
+
id: "qr-code"
|
|
211
|
+
}, /* @__PURE__ */ React.createElement(InvitationQR, {
|
|
212
|
+
id: invitationId,
|
|
213
|
+
url,
|
|
214
|
+
onCancel: onInvitationDone
|
|
215
|
+
}))));
|
|
216
|
+
} finally {
|
|
217
|
+
_effect.f();
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
var InvitationQR = ({ id, url, onCancel }) => {
|
|
221
|
+
var _effect = _useSignals();
|
|
222
|
+
try {
|
|
223
|
+
const { t } = useTranslation("os");
|
|
224
|
+
const qrLabel = useId("devices-container__qr-code");
|
|
225
|
+
const emoji = hexToEmoji(id);
|
|
226
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", {
|
|
227
|
+
className: "text-description"
|
|
228
|
+
}, t("qr code description", {
|
|
229
|
+
ns: CLIENT_PLUGIN
|
|
230
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
231
|
+
role: "group",
|
|
232
|
+
className: "grid grid-cols-[1fr_min-content] mlb-2 gap-2"
|
|
233
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
234
|
+
role: "none",
|
|
235
|
+
className: "is-full aspect-square relative text-description"
|
|
236
|
+
}, /* @__PURE__ */ React.createElement(QR, {
|
|
237
|
+
rounding: 100,
|
|
238
|
+
backgroundColor: "transparent",
|
|
239
|
+
color: "currentColor",
|
|
240
|
+
"aria-labelledby": qrLabel,
|
|
241
|
+
errorCorrectionLevel: "Q",
|
|
242
|
+
cutout: true
|
|
243
|
+
}, url ?? "never"), /* @__PURE__ */ React.createElement(Centered, null, /* @__PURE__ */ React.createElement(Emoji, {
|
|
244
|
+
text: emoji
|
|
245
|
+
}))), /* @__PURE__ */ React.createElement("span", {
|
|
246
|
+
id: qrLabel,
|
|
247
|
+
className: "sr-only"
|
|
248
|
+
}, t("qr label"))), /* @__PURE__ */ React.createElement("div", {
|
|
249
|
+
className: "flex justify-center"
|
|
250
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
251
|
+
className: "flex gap-2"
|
|
252
|
+
}, /* @__PURE__ */ React.createElement(Clipboard.Button, {
|
|
253
|
+
value: url ?? "never"
|
|
254
|
+
}), /* @__PURE__ */ React.createElement(Button, {
|
|
255
|
+
variant: "ghost",
|
|
256
|
+
onClick: onCancel
|
|
257
|
+
}, t("cancel label")))));
|
|
258
|
+
} finally {
|
|
259
|
+
_effect.f();
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
var InvitationAuthCode = ({ id, code, onCancel }) => {
|
|
263
|
+
var _effect = _useSignals();
|
|
264
|
+
try {
|
|
265
|
+
const { t } = useTranslation("os");
|
|
266
|
+
const emoji = hexToEmoji(id);
|
|
267
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", {
|
|
268
|
+
className: "text-description"
|
|
269
|
+
}, t("auth other device emoji message")), emoji && /* @__PURE__ */ React.createElement(Emoji, {
|
|
270
|
+
text: emoji,
|
|
271
|
+
className: "mli-auto mlb-2 text-center"
|
|
272
|
+
}), /* @__PURE__ */ React.createElement("p", {
|
|
273
|
+
className: "text-description"
|
|
274
|
+
}, t("auth code message")), /* @__PURE__ */ React.createElement(AuthCode, {
|
|
275
|
+
code,
|
|
276
|
+
large: true,
|
|
277
|
+
classNames: "mli-auto mlb-2 text-center grow"
|
|
278
|
+
}), /* @__PURE__ */ React.createElement(Button, {
|
|
279
|
+
variant: "ghost",
|
|
280
|
+
onClick: onCancel
|
|
281
|
+
}, t("cancel label")));
|
|
282
|
+
} finally {
|
|
283
|
+
_effect.f();
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
var InvitationComplete = ({ statusValue }) => {
|
|
287
|
+
var _effect = _useSignals();
|
|
288
|
+
try {
|
|
289
|
+
return statusValue > 0 ? /* @__PURE__ */ React.createElement(Check, {
|
|
290
|
+
className: mx("m-1.5", getSize(6))
|
|
291
|
+
}) : /* @__PURE__ */ React.createElement(X, {
|
|
292
|
+
className: mx("m-1.5", getSize(6))
|
|
293
|
+
});
|
|
294
|
+
} finally {
|
|
295
|
+
_effect.f();
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
// packages/plugins/plugin-client/src/components/JoinDialog.tsx
|
|
300
|
+
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
301
|
+
import React2, { useCallback as useCallback2 } from "react";
|
|
302
|
+
import { createIntent as createIntent2, LayoutAction, useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework";
|
|
303
|
+
import { ObservabilityAction } from "@dxos/plugin-observability/types";
|
|
304
|
+
import { Dialog, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
305
|
+
import { JoinPanel } from "@dxos/shell/react";
|
|
306
|
+
var JOIN_DIALOG = `${CLIENT_PLUGIN}/JoinDialog`;
|
|
307
|
+
var JoinDialog = (props) => {
|
|
308
|
+
var _effect = _useSignals2();
|
|
309
|
+
try {
|
|
310
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher2();
|
|
311
|
+
const { t } = useTranslation2(CLIENT_PLUGIN);
|
|
312
|
+
const handleCancelResetStorage = useCallback2(() => dispatch(createIntent2(ClientAction.ShareIdentity)), [
|
|
313
|
+
dispatch
|
|
314
|
+
]);
|
|
315
|
+
const handleDone = useCallback2(async (result) => {
|
|
316
|
+
if (result?.identityKey) {
|
|
317
|
+
await Promise.all([
|
|
318
|
+
dispatch(createIntent2(LayoutAction.UpdateDialog, {
|
|
319
|
+
part: "dialog",
|
|
320
|
+
options: {
|
|
321
|
+
state: false
|
|
322
|
+
}
|
|
323
|
+
})),
|
|
324
|
+
dispatch(createIntent2(ObservabilityAction.SendEvent, {
|
|
325
|
+
name: props.initialDisposition === "recover-identity" ? "identity.recover" : "identity.join"
|
|
326
|
+
}))
|
|
327
|
+
]);
|
|
328
|
+
}
|
|
329
|
+
}, [
|
|
330
|
+
dispatch
|
|
331
|
+
]);
|
|
332
|
+
return /* @__PURE__ */ React2.createElement(Dialog.Content, null, /* @__PURE__ */ React2.createElement(Dialog.Title, {
|
|
333
|
+
classNames: "sr-only"
|
|
334
|
+
}, t("join space label", {
|
|
335
|
+
ns: "os"
|
|
336
|
+
})), /* @__PURE__ */ React2.createElement(JoinPanel, {
|
|
337
|
+
mode: "halo-only",
|
|
338
|
+
...props,
|
|
339
|
+
exitActionParent: /* @__PURE__ */ React2.createElement(Dialog.Close, {
|
|
340
|
+
asChild: true
|
|
341
|
+
}),
|
|
342
|
+
doneActionParent: /* @__PURE__ */ React2.createElement(Dialog.Close, {
|
|
343
|
+
asChild: true
|
|
344
|
+
}),
|
|
345
|
+
onCancelResetStorage: handleCancelResetStorage,
|
|
346
|
+
onDone: handleDone
|
|
347
|
+
}));
|
|
348
|
+
} finally {
|
|
349
|
+
_effect.f();
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
// packages/plugins/plugin-client/src/components/ProfileContainer.tsx
|
|
354
|
+
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
|
355
|
+
import { Schema } from "effect";
|
|
356
|
+
import React3, { useCallback as useCallback3, useMemo, useState as useState2 } from "react";
|
|
357
|
+
import { debounce } from "@dxos/async";
|
|
358
|
+
import { useClient as useClient2 } from "@dxos/react-client";
|
|
359
|
+
import { useIdentity } from "@dxos/react-client/halo";
|
|
360
|
+
import { ButtonGroup, Clipboard as Clipboard2, Input, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
361
|
+
import { Form, ControlItem as ControlItem2, ControlItemInput, ControlSection as ControlSection2, ControlPage as ControlPage2 } from "@dxos/react-ui-form";
|
|
362
|
+
import { EmojiPickerBlock, HuePicker } from "@dxos/react-ui-pickers";
|
|
363
|
+
import { StackItem as StackItem2 } from "@dxos/react-ui-stack";
|
|
364
|
+
import { hexToHue, hexToEmoji as hexToEmoji2 } from "@dxos/util";
|
|
365
|
+
var getDefaultHueValue = (identity) => hexToHue(identity?.identityKey.toHex() ?? "0");
|
|
366
|
+
var getDefaultEmojiValue = (identity) => hexToEmoji2(identity?.identityKey.toHex() ?? "0");
|
|
367
|
+
var getHueValue = (identity) => identity?.profile?.data?.hue || getDefaultHueValue(identity);
|
|
368
|
+
var getEmojiValue = (identity) => identity?.profile?.data?.emoji || getDefaultEmojiValue(identity);
|
|
369
|
+
var ProfileContainer = () => {
|
|
370
|
+
var _effect = _useSignals3();
|
|
371
|
+
try {
|
|
372
|
+
const { t } = useTranslation3(CLIENT_PLUGIN);
|
|
373
|
+
const client = useClient2();
|
|
374
|
+
const identity = useIdentity();
|
|
375
|
+
const [displayName, setDisplayNameDirectly] = useState2(identity?.profile?.displayName ?? "");
|
|
376
|
+
const [emoji, setEmojiDirectly] = useState2(getEmojiValue(identity));
|
|
377
|
+
const [hue, setHueDirectly] = useState2(getHueValue(identity));
|
|
378
|
+
const updateProfile = useMemo(() => debounce((profile) => client.halo.updateProfile({
|
|
379
|
+
displayName: profile.displayName,
|
|
380
|
+
data: {
|
|
381
|
+
emoji: profile.emoji,
|
|
382
|
+
hue: profile.hue
|
|
383
|
+
}
|
|
384
|
+
}), 2e3), []);
|
|
385
|
+
const handleSave = useCallback3((profile) => {
|
|
386
|
+
setDisplayNameDirectly(profile.displayName);
|
|
387
|
+
setEmojiDirectly(profile.emoji);
|
|
388
|
+
setHueDirectly(profile.hue);
|
|
389
|
+
updateProfile(profile);
|
|
390
|
+
}, [
|
|
391
|
+
identity
|
|
392
|
+
]);
|
|
393
|
+
const values = useMemo(() => ({
|
|
394
|
+
displayName,
|
|
395
|
+
emoji,
|
|
396
|
+
hue,
|
|
397
|
+
did: identity?.did
|
|
398
|
+
}), [
|
|
399
|
+
identity,
|
|
400
|
+
displayName,
|
|
401
|
+
emoji,
|
|
402
|
+
hue
|
|
403
|
+
]);
|
|
404
|
+
const customElements = useMemo(() => ({
|
|
405
|
+
displayName: ({ type, label, getValue, onValueChange }) => {
|
|
406
|
+
const handleChange = useCallback3(({ target: { value } }) => onValueChange(type, value), [
|
|
407
|
+
onValueChange,
|
|
408
|
+
type
|
|
409
|
+
]);
|
|
410
|
+
return /* @__PURE__ */ React3.createElement(ControlItemInput, {
|
|
411
|
+
title: label,
|
|
412
|
+
description: t("display name description")
|
|
413
|
+
}, /* @__PURE__ */ React3.createElement(Input.TextInput, {
|
|
414
|
+
value: getValue(),
|
|
415
|
+
onChange: handleChange,
|
|
416
|
+
placeholder: t("display name input placeholder"),
|
|
417
|
+
classNames: "min-is-64"
|
|
418
|
+
}));
|
|
419
|
+
},
|
|
420
|
+
emoji: ({ type, label, getValue, onValueChange }) => {
|
|
421
|
+
const handleChange = useCallback3((nextEmoji) => onValueChange(type, nextEmoji), [
|
|
422
|
+
onValueChange,
|
|
423
|
+
type
|
|
424
|
+
]);
|
|
425
|
+
const handleEmojiReset = useCallback3(() => onValueChange(type, getDefaultEmojiValue(identity)), [
|
|
426
|
+
onValueChange,
|
|
427
|
+
type
|
|
428
|
+
]);
|
|
429
|
+
return /* @__PURE__ */ React3.createElement(ControlItem2, {
|
|
430
|
+
title: label,
|
|
431
|
+
description: t("icon description")
|
|
432
|
+
}, /* @__PURE__ */ React3.createElement(EmojiPickerBlock, {
|
|
433
|
+
triggerVariant: "default",
|
|
434
|
+
emoji: getValue(),
|
|
435
|
+
onChangeEmoji: handleChange,
|
|
436
|
+
onClickClear: handleEmojiReset,
|
|
437
|
+
classNames: "justify-self-end"
|
|
438
|
+
}));
|
|
439
|
+
},
|
|
440
|
+
hue: ({ type, label, getValue, onValueChange }) => {
|
|
441
|
+
const handleChange = useCallback3((nextHue) => onValueChange(type, nextHue), [
|
|
442
|
+
onValueChange,
|
|
443
|
+
type
|
|
444
|
+
]);
|
|
445
|
+
const handleHueReset = useCallback3(() => onValueChange(type, getDefaultHueValue(identity)), [
|
|
446
|
+
onValueChange,
|
|
447
|
+
type
|
|
448
|
+
]);
|
|
449
|
+
return /* @__PURE__ */ React3.createElement(ControlItem2, {
|
|
450
|
+
title: label,
|
|
451
|
+
description: t("hue description")
|
|
452
|
+
}, /* @__PURE__ */ React3.createElement(HuePicker, {
|
|
453
|
+
value: getValue(),
|
|
454
|
+
onChange: handleChange,
|
|
455
|
+
onReset: handleHueReset,
|
|
456
|
+
classNames: "[--hue-preview-size:1.5rem] justify-self-end"
|
|
457
|
+
}));
|
|
458
|
+
},
|
|
459
|
+
// TODO(wittjosiah): We need text input annotations for disabled and copyable.
|
|
460
|
+
did: ({ label, getValue }) => {
|
|
461
|
+
return /* @__PURE__ */ React3.createElement(ControlItemInput, {
|
|
462
|
+
title: label,
|
|
463
|
+
description: t("did description")
|
|
464
|
+
}, /* @__PURE__ */ React3.createElement(ButtonGroup, null, /* @__PURE__ */ React3.createElement(Input.TextInput, {
|
|
465
|
+
value: getValue(),
|
|
466
|
+
disabled: true,
|
|
467
|
+
classNames: "min-is-64"
|
|
468
|
+
}), /* @__PURE__ */ React3.createElement(Clipboard2.IconButton, {
|
|
469
|
+
value: getValue() ?? ""
|
|
470
|
+
})));
|
|
471
|
+
}
|
|
472
|
+
}), [
|
|
473
|
+
t
|
|
474
|
+
]);
|
|
475
|
+
return /* @__PURE__ */ React3.createElement(StackItem2.Content, {
|
|
476
|
+
classNames: "block overflow-y-auto"
|
|
477
|
+
}, /* @__PURE__ */ React3.createElement(ControlPage2, null, /* @__PURE__ */ React3.createElement(Clipboard2.Provider, null, /* @__PURE__ */ React3.createElement(ControlSection2, {
|
|
478
|
+
title: t("profile label"),
|
|
479
|
+
description: t("profile description")
|
|
480
|
+
}, /* @__PURE__ */ React3.createElement(Form, {
|
|
481
|
+
schema: ProfileSchema,
|
|
482
|
+
values,
|
|
483
|
+
autoSave: true,
|
|
484
|
+
onSave: handleSave,
|
|
485
|
+
Custom: customElements,
|
|
486
|
+
classNames: 'p-0 container-max-width [&_[role="form"]]:grid [&_[role="form"]]:grid-cols-1 md:[&_[role="form"]]:grid-cols-[1fr_min-content] [&_[role="form"]]:gap-4'
|
|
487
|
+
})))));
|
|
488
|
+
} finally {
|
|
489
|
+
_effect.f();
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
var ProfileSchema = Schema.Struct({
|
|
493
|
+
displayName: Schema.String.annotations({
|
|
494
|
+
title: "Display name"
|
|
495
|
+
}),
|
|
496
|
+
emoji: Schema.String.annotations({
|
|
497
|
+
title: "Avatar"
|
|
498
|
+
}),
|
|
499
|
+
hue: Schema.String.annotations({
|
|
500
|
+
title: "Color"
|
|
501
|
+
}),
|
|
502
|
+
did: Schema.String.annotations({
|
|
503
|
+
title: "DID"
|
|
504
|
+
})
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
// packages/plugins/plugin-client/src/components/RecoveryCodeDialog.tsx
|
|
508
|
+
import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
|
|
509
|
+
import React4, { useCallback as useCallback4, useState as useState3 } from "react";
|
|
510
|
+
import { AlertDialog, Button as Button2, Clipboard as Clipboard3, Input as Input2, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
511
|
+
var RECOVERY_CODE_DIALOG = `${CLIENT_PLUGIN}/RecoveryCodeDialog`;
|
|
512
|
+
var RecoveryCodeDialog = ({ code }) => {
|
|
513
|
+
var _effect = _useSignals4();
|
|
514
|
+
try {
|
|
515
|
+
const { t } = useTranslation4(CLIENT_PLUGIN);
|
|
516
|
+
const [confirmation, setConfirmation] = useState3(false);
|
|
517
|
+
const handleConfirmation = useCallback4((checked) => setConfirmation(checked), []);
|
|
518
|
+
return /* @__PURE__ */ React4.createElement(AlertDialog.Content, {
|
|
519
|
+
classNames: "bs-content min-bs-[15rem] max-bs-full md:max-is-[40rem] overflow-hidden"
|
|
520
|
+
}, /* @__PURE__ */ React4.createElement(AlertDialog.Title, null, t("recovery code dialog title")), /* @__PURE__ */ React4.createElement("p", {
|
|
521
|
+
className: "py-4"
|
|
522
|
+
}, t("recovery code dialog description")), /* @__PURE__ */ React4.createElement(Clipboard3.Provider, null, /* @__PURE__ */ React4.createElement(Code, {
|
|
523
|
+
code
|
|
524
|
+
})), /* @__PURE__ */ React4.createElement("div", {
|
|
525
|
+
className: "flex flex-col py-4 gap-2"
|
|
526
|
+
}, /* @__PURE__ */ React4.createElement("p", null, t("recovery code dialog warning 1")), /* @__PURE__ */ React4.createElement("p", null, t("recovery code dialog warning 2"))), /* @__PURE__ */ React4.createElement("div", {
|
|
527
|
+
className: "flex items-center gap-2 pbe-4"
|
|
528
|
+
}, /* @__PURE__ */ React4.createElement(Input2.Root, null, /* @__PURE__ */ React4.createElement(Input2.Checkbox, {
|
|
529
|
+
"data-testid": "recoveryCode.confirm",
|
|
530
|
+
checked: confirmation,
|
|
531
|
+
onCheckedChange: handleConfirmation
|
|
532
|
+
}), /* @__PURE__ */ React4.createElement(Input2.Label, null, t("recovery code confirmation label")))), /* @__PURE__ */ React4.createElement("div", {
|
|
533
|
+
className: "flex justify-end"
|
|
534
|
+
}, /* @__PURE__ */ React4.createElement(AlertDialog.Action, {
|
|
535
|
+
asChild: true
|
|
536
|
+
}, /* @__PURE__ */ React4.createElement(Button2, {
|
|
537
|
+
"data-testid": "recoveryCode.continue",
|
|
538
|
+
variant: "primary",
|
|
539
|
+
disabled: !confirmation
|
|
540
|
+
}, t("continue label")))));
|
|
541
|
+
} finally {
|
|
542
|
+
_effect.f();
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
var Code = ({ code }) => {
|
|
546
|
+
var _effect = _useSignals4();
|
|
547
|
+
try {
|
|
548
|
+
const words = code.split(" ");
|
|
549
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
550
|
+
className: "relative p-2 border border-separator rounded group"
|
|
551
|
+
}, /* @__PURE__ */ React4.createElement(Clipboard3.IconButton, {
|
|
552
|
+
value: code,
|
|
553
|
+
classNames: "absolute top-2 right-2 invisible group-hover:visible"
|
|
554
|
+
}), /* @__PURE__ */ React4.createElement("div", {
|
|
555
|
+
className: "grid grid-cols-4"
|
|
556
|
+
}, words.map((word, i) => /* @__PURE__ */ React4.createElement("div", {
|
|
557
|
+
key: i,
|
|
558
|
+
className: "flex items-center p-2 gap-2"
|
|
559
|
+
}, /* @__PURE__ */ React4.createElement("div", {
|
|
560
|
+
className: "w-4 text-xs text-center text-subdued"
|
|
561
|
+
}, i + 1), /* @__PURE__ */ React4.createElement("div", {
|
|
562
|
+
className: "text-sm"
|
|
563
|
+
}, word)))));
|
|
564
|
+
} finally {
|
|
565
|
+
_effect.f();
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
// packages/plugins/plugin-client/src/components/RecoveryCredentialsContainer.tsx
|
|
570
|
+
import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
|
|
571
|
+
import React5 from "react";
|
|
572
|
+
import { createIntent as createIntent3, useIntentDispatcher as useIntentDispatcher3 } from "@dxos/app-framework";
|
|
573
|
+
import { useCredentials } from "@dxos/react-client/halo";
|
|
574
|
+
import { Icon, IconButton as IconButton2, List as List2, ListItem, useTranslation as useTranslation5, Message } from "@dxos/react-ui";
|
|
575
|
+
import { ControlGroup as ControlGroup2, ControlItem as ControlItem3, ControlPage as ControlPage3, ControlSection as ControlSection3 } from "@dxos/react-ui-form";
|
|
576
|
+
import { StackItem as StackItem3 } from "@dxos/react-ui-stack";
|
|
577
|
+
var MANAGE_CREDENTIALS_DIALOG = `${CLIENT_PLUGIN}/ManageCredentialsDialog`;
|
|
578
|
+
var RecoveryCredentialsContainer = () => {
|
|
579
|
+
var _effect = _useSignals5();
|
|
580
|
+
try {
|
|
581
|
+
const { t } = useTranslation5(CLIENT_PLUGIN);
|
|
582
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher3();
|
|
583
|
+
const credentials = useCredentials();
|
|
584
|
+
const recoveryCredentials = credentials.filter((credential) => credential.subject.assertion["@type"] === "dxos.halo.credentials.IdentityRecovery");
|
|
585
|
+
return /* @__PURE__ */ React5.createElement(StackItem3.Content, {
|
|
586
|
+
classNames: "block overflow-y-auto"
|
|
587
|
+
}, /* @__PURE__ */ React5.createElement(ControlPage3, null, /* @__PURE__ */ React5.createElement(ControlSection3, {
|
|
588
|
+
title: t("recovery setup dialog title"),
|
|
589
|
+
description: t("recovery setup dialog description")
|
|
590
|
+
}, /* @__PURE__ */ React5.createElement(ControlGroup2, null, /* @__PURE__ */ React5.createElement(ControlItem3, {
|
|
591
|
+
title: t("create passkey label"),
|
|
592
|
+
description: t("create passkey description")
|
|
593
|
+
}, /* @__PURE__ */ React5.createElement(IconButton2, {
|
|
594
|
+
label: t("create passkey label"),
|
|
595
|
+
icon: "ph--key--duotone",
|
|
596
|
+
variant: "primary",
|
|
597
|
+
size: 5,
|
|
598
|
+
onClick: () => dispatch(createIntent3(ClientAction.CreatePasskey))
|
|
599
|
+
})), /* @__PURE__ */ React5.createElement(ControlItem3, {
|
|
600
|
+
title: t("create recovery code label"),
|
|
601
|
+
description: t("create recovery code description")
|
|
602
|
+
}, /* @__PURE__ */ React5.createElement(IconButton2, {
|
|
603
|
+
label: t("create recovery code label"),
|
|
604
|
+
icon: "ph--receipt--duotone",
|
|
605
|
+
variant: "default",
|
|
606
|
+
size: 5,
|
|
607
|
+
onClick: () => dispatch(createIntent3(ClientAction.CreateRecoveryCode))
|
|
608
|
+
})))), /* @__PURE__ */ React5.createElement(ControlSection3, {
|
|
609
|
+
title: t("credentials list label")
|
|
610
|
+
}, recoveryCredentials.length < 1 ? /* @__PURE__ */ React5.createElement(Message.Root, {
|
|
611
|
+
valence: "error",
|
|
612
|
+
className: "container-max-width"
|
|
613
|
+
}, /* @__PURE__ */ React5.createElement(Message.Title, null, /* @__PURE__ */ React5.createElement(Icon, {
|
|
614
|
+
icon: "ph--shield-warning--duotone",
|
|
615
|
+
size: 5,
|
|
616
|
+
classNames: "inline-block align-top mbs-px mie-1"
|
|
617
|
+
}), t("no credentials title")), /* @__PURE__ */ React5.createElement(Message.Body, null, t("no credentials message"))) : /* @__PURE__ */ React5.createElement(List2, {
|
|
618
|
+
classNames: "container-max-width pli-2"
|
|
619
|
+
}, recoveryCredentials.map((credential) => /* @__PURE__ */ React5.createElement(ListItem.Root, {
|
|
620
|
+
key: credential.id?.toHex()
|
|
621
|
+
}, /* @__PURE__ */ React5.createElement(ListItem.Endcap, null, /* @__PURE__ */ React5.createElement(Icon, {
|
|
622
|
+
icon: "ph--key--regular",
|
|
623
|
+
size: 5
|
|
624
|
+
})), /* @__PURE__ */ React5.createElement(ListItem.Heading, null, credential.issuanceDate.toLocaleString())))))));
|
|
625
|
+
} finally {
|
|
626
|
+
_effect.f();
|
|
627
|
+
}
|
|
628
|
+
};
|
|
629
|
+
|
|
630
|
+
// packages/plugins/plugin-client/src/components/ResetDialog.tsx
|
|
631
|
+
import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
|
|
632
|
+
import React6, { useCallback as useCallback5 } from "react";
|
|
633
|
+
import { createIntent as createIntent4, LayoutAction as LayoutAction2, useIntentDispatcher as useIntentDispatcher4 } from "@dxos/app-framework";
|
|
634
|
+
import { useClient as useClient3 } from "@dxos/react-client";
|
|
635
|
+
import { Dialog as Dialog2, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
636
|
+
import { ConfirmReset } from "@dxos/shell/react";
|
|
637
|
+
var RESET_DIALOG = `${CLIENT_PLUGIN}/ResetDialog`;
|
|
638
|
+
var ResetDialog = ({ mode, onReset }) => {
|
|
639
|
+
var _effect = _useSignals6();
|
|
640
|
+
try {
|
|
641
|
+
const { t } = useTranslation6(CLIENT_PLUGIN);
|
|
642
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher4();
|
|
643
|
+
const client = useClient3();
|
|
644
|
+
const handleReset = useCallback5(async () => {
|
|
645
|
+
await client.reset();
|
|
646
|
+
const target = mode === "join new identity" ? "deviceInvitation" : mode === "recover" ? "recoverIdentity" : void 0;
|
|
647
|
+
await onReset?.({
|
|
648
|
+
target
|
|
649
|
+
});
|
|
650
|
+
}, [
|
|
651
|
+
dispatch,
|
|
652
|
+
client,
|
|
653
|
+
mode,
|
|
654
|
+
onReset
|
|
655
|
+
]);
|
|
656
|
+
const handleCancel = useCallback5(() => {
|
|
657
|
+
void dispatch(createIntent4(LayoutAction2.UpdateDialog, {
|
|
658
|
+
part: "dialog",
|
|
659
|
+
options: {
|
|
660
|
+
state: false
|
|
661
|
+
}
|
|
662
|
+
}));
|
|
663
|
+
}, [
|
|
664
|
+
dispatch
|
|
665
|
+
]);
|
|
666
|
+
return /* @__PURE__ */ React6.createElement(Dialog2.Content, {
|
|
667
|
+
classNames: "bs-content min-bs-[15rem] max-bs-full md:max-is-[40rem] overflow-hidden"
|
|
668
|
+
}, /* @__PURE__ */ React6.createElement(Dialog2.Title, {
|
|
669
|
+
classNames: "sr-only"
|
|
670
|
+
}, t("reset dialog title")), /* @__PURE__ */ React6.createElement(Dialog2.Description, {
|
|
671
|
+
classNames: "sr-only"
|
|
672
|
+
}, t("reset dialog description")), /* @__PURE__ */ React6.createElement(ConfirmReset, {
|
|
673
|
+
active: true,
|
|
674
|
+
mode,
|
|
675
|
+
onConfirm: handleReset,
|
|
676
|
+
onCancel: handleCancel
|
|
677
|
+
}));
|
|
678
|
+
} finally {
|
|
679
|
+
_effect.f();
|
|
680
|
+
}
|
|
681
|
+
};
|
|
682
|
+
|
|
683
|
+
export {
|
|
684
|
+
DevicesContainer,
|
|
685
|
+
JOIN_DIALOG,
|
|
686
|
+
JoinDialog,
|
|
687
|
+
ProfileContainer,
|
|
688
|
+
RECOVERY_CODE_DIALOG,
|
|
689
|
+
RecoveryCodeDialog,
|
|
690
|
+
RecoveryCredentialsContainer,
|
|
691
|
+
RESET_DIALOG,
|
|
692
|
+
ResetDialog
|
|
693
|
+
};
|
|
694
|
+
//# sourceMappingURL=chunk-DCUIJY75.mjs.map
|