@dxos/plugin-client 0.8.2-staging.7ac8446 → 0.8.2

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