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