@dxos/plugin-client 0.7.4 → 0.7.5-main.9cb18ac

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 (57) hide show
  1. package/dist/lib/browser/chunk-52IJQ35F.mjs +78 -0
  2. package/dist/lib/browser/chunk-52IJQ35F.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-X4QUPYC6.mjs +12 -0
  4. package/dist/lib/browser/chunk-X4QUPYC6.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +163 -221
  6. package/dist/lib/browser/index.mjs.map +3 -3
  7. package/dist/lib/browser/meta.json +1 -1
  8. package/dist/lib/browser/meta.mjs +1 -5
  9. package/dist/lib/browser/types.mjs +10 -0
  10. package/dist/lib/browser/types.mjs.map +7 -0
  11. package/dist/lib/node/chunk-NFO3ADQC.cjs +98 -0
  12. package/dist/lib/node/chunk-NFO3ADQC.cjs.map +7 -0
  13. package/dist/lib/node/chunk-RUA5KXVW.cjs +35 -0
  14. package/dist/lib/node/chunk-RUA5KXVW.cjs.map +7 -0
  15. package/dist/lib/node/index.cjs +165 -224
  16. package/dist/lib/node/index.cjs.map +3 -3
  17. package/dist/lib/node/meta.cjs +4 -8
  18. package/dist/lib/node/meta.cjs.map +2 -2
  19. package/dist/lib/node/meta.json +1 -1
  20. package/dist/lib/node/types.cjs +32 -0
  21. package/dist/lib/node/types.cjs.map +7 -0
  22. package/dist/lib/node-esm/chunk-GMGRQ5Q7.mjs +14 -0
  23. package/dist/lib/node-esm/chunk-GMGRQ5Q7.mjs.map +7 -0
  24. package/dist/lib/node-esm/chunk-TI4GNGMM.mjs +79 -0
  25. package/dist/lib/node-esm/chunk-TI4GNGMM.mjs.map +7 -0
  26. package/dist/lib/node-esm/index.mjs +163 -221
  27. package/dist/lib/node-esm/index.mjs.map +3 -3
  28. package/dist/lib/node-esm/meta.json +1 -1
  29. package/dist/lib/node-esm/meta.mjs +1 -5
  30. package/dist/lib/node-esm/types.mjs +11 -0
  31. package/dist/lib/node-esm/types.mjs.map +7 -0
  32. package/dist/types/src/ClientPlugin.d.ts +2 -35
  33. package/dist/types/src/ClientPlugin.d.ts.map +1 -1
  34. package/dist/types/src/components/IdentityDialog.d.ts +1 -0
  35. package/dist/types/src/components/IdentityDialog.d.ts.map +1 -1
  36. package/dist/types/src/components/JoinDialog.d.ts +1 -0
  37. package/dist/types/src/components/JoinDialog.d.ts.map +1 -1
  38. package/dist/types/src/components/RecoveryCodeDialog.d.ts +1 -0
  39. package/dist/types/src/components/RecoveryCodeDialog.d.ts.map +1 -1
  40. package/dist/types/src/meta.d.ts +0 -10
  41. package/dist/types/src/meta.d.ts.map +1 -1
  42. package/dist/types/src/types.d.ts +110 -0
  43. package/dist/types/src/types.d.ts.map +1 -0
  44. package/dist/types/tsconfig.tsbuildinfo +1 -0
  45. package/package.json +22 -13
  46. package/src/ClientPlugin.tsx +111 -200
  47. package/src/components/IdentityDialog.tsx +13 -11
  48. package/src/components/JoinDialog.tsx +13 -19
  49. package/src/components/RecoveryCodeDialog.tsx +3 -1
  50. package/src/meta.ts +0 -14
  51. package/src/types.ts +115 -0
  52. package/dist/lib/browser/chunk-FGUXUNOK.mjs +0 -26
  53. package/dist/lib/browser/chunk-FGUXUNOK.mjs.map +0 -7
  54. package/dist/lib/node/chunk-XYLDQWFV.cjs +0 -51
  55. package/dist/lib/node/chunk-XYLDQWFV.cjs.map +0 -7
  56. package/dist/lib/node-esm/chunk-C6X363FK.mjs +0 -28
  57. package/dist/lib/node-esm/chunk-C6X363FK.mjs.map +0 -7
@@ -1,65 +1,57 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+ import {
3
+ ClientAction
4
+ } from "./chunk-TI4GNGMM.mjs";
2
5
  import {
3
6
  CLIENT_PLUGIN,
4
- ClientAction,
5
- OBSERVABILITY_ACTION,
6
7
  meta_default
7
- } from "./chunk-C6X363FK.mjs";
8
+ } from "./chunk-GMGRQ5Q7.mjs";
8
9
 
9
10
  // packages/plugins/plugin-client/src/ClientPlugin.tsx
10
11
  import React4 from "react";
11
- import { LayoutAction as LayoutAction3, parseIntentPlugin, resolvePlugin } from "@dxos/app-framework";
12
+ import { LayoutAction as LayoutAction3, parseIntentPlugin, resolvePlugin, createSurface, createIntent as createIntent3, createResolver } from "@dxos/app-framework";
12
13
  import { Config, Defaults, Envs, Local, Storage } from "@dxos/config";
13
14
  import { registerSignalsRuntime } from "@dxos/echo-signals/react";
14
15
  import { invariant } from "@dxos/invariant";
15
16
  import { createExtension } from "@dxos/plugin-graph";
17
+ import { ObservabilityAction as ObservabilityAction2 } from "@dxos/plugin-observability/types";
16
18
  import { Client, ClientProvider } from "@dxos/react-client";
17
19
 
18
20
  // packages/plugins/plugin-client/src/components/IdentityDialog.tsx
19
21
  import React, { useCallback } from "react";
20
- import { LayoutAction, useIntentDispatcher } from "@dxos/app-framework";
22
+ import { createIntent, LayoutAction, useIntentDispatcher } from "@dxos/app-framework";
21
23
  import { useClient } from "@dxos/react-client";
22
24
  import { Clipboard, Dialog } from "@dxos/react-ui";
23
25
  import { IdentityPanel } from "@dxos/shell/react";
26
+ var IDENTITY_DIALOG = `${CLIENT_PLUGIN}/IdentityDialog`;
24
27
  var IdentityDialog = (props) => {
25
- const dispatch = useIntentDispatcher();
28
+ const { dispatchPromise: dispatch } = useIntentDispatcher();
26
29
  const client = useClient();
27
- const handleDone = useCallback(() => dispatch({
28
- action: LayoutAction.SET_LAYOUT,
29
- data: {
30
- element: "dialog",
31
- state: false
32
- }
33
- }), [
30
+ const handleDone = useCallback(() => dispatch(createIntent(LayoutAction.SetLayout, {
31
+ element: "dialog",
32
+ state: false
33
+ })), [
34
34
  dispatch
35
35
  ]);
36
36
  const handleResetStorage = useCallback(async () => {
37
37
  await client.reset();
38
- await dispatch({
39
- action: ClientAction.RESET_STORAGE
40
- });
38
+ await dispatch(createIntent(ClientAction.ResetStorage));
41
39
  }, [
42
40
  dispatch
43
41
  ]);
44
42
  const handleRecover = useCallback(async () => {
45
43
  await client.reset();
46
- await dispatch({
47
- action: ClientAction.RESET_STORAGE,
48
- data: {
49
- target: "recoverIdentity"
50
- }
51
- });
44
+ await dispatch(createIntent(ClientAction.ResetStorage, {
45
+ target: "recoverIdentity"
46
+ }));
52
47
  }, [
53
48
  dispatch
54
49
  ]);
55
50
  const handleJoinNewIdentity = useCallback(async () => {
56
51
  await client.reset();
57
- await dispatch({
58
- action: ClientAction.RESET_STORAGE,
59
- data: {
60
- target: "deviceInvitation"
61
- }
62
- });
52
+ await dispatch(createIntent(ClientAction.ResetStorage, {
53
+ target: "deviceInvitation"
54
+ }));
63
55
  }, [
64
56
  dispatch
65
57
  ]);
@@ -77,33 +69,26 @@ var IdentityDialog = (props) => {
77
69
 
78
70
  // packages/plugins/plugin-client/src/components/JoinDialog.tsx
79
71
  import React2, { useCallback as useCallback2 } from "react";
80
- import { LayoutAction as LayoutAction2, useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework";
72
+ import { createIntent as createIntent2, LayoutAction as LayoutAction2, useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework";
73
+ import { ObservabilityAction } from "@dxos/plugin-observability/types";
81
74
  import { Dialog as Dialog2 } from "@dxos/react-ui";
82
75
  import { JoinPanel } from "@dxos/shell/react";
76
+ var JOIN_DIALOG = `${CLIENT_PLUGIN}/JoinDialog`;
83
77
  var JoinDialog = (props) => {
84
- const dispatch = useIntentDispatcher2();
85
- const handleCancelResetStorage = useCallback2(() => dispatch({
86
- plugin: CLIENT_PLUGIN,
87
- action: ClientAction.SHARE_IDENTITY
88
- }), [
78
+ const { dispatchPromise: dispatch } = useIntentDispatcher2();
79
+ const handleCancelResetStorage = useCallback2(() => dispatch(createIntent2(ClientAction.ShareIdentity)), [
89
80
  dispatch
90
81
  ]);
91
82
  const handleDone = useCallback2(async (result) => {
92
83
  if (result?.identityKey) {
93
84
  await Promise.all([
94
- dispatch({
95
- action: LayoutAction2.SET_LAYOUT,
96
- data: {
97
- element: "dialog",
98
- state: false
99
- }
100
- }),
101
- dispatch({
102
- action: OBSERVABILITY_ACTION,
103
- data: {
104
- name: props.initialDisposition === "recover-identity" ? "identity.recover" : "identity.join"
105
- }
106
- })
85
+ dispatch(createIntent2(LayoutAction2.SetLayout, {
86
+ element: "dialog",
87
+ state: false
88
+ })),
89
+ dispatch(createIntent2(ObservabilityAction.SendEvent, {
90
+ name: props.initialDisposition === "recover-identity" ? "identity.recover" : "identity.join"
91
+ }))
107
92
  ]);
108
93
  }
109
94
  }, [
@@ -126,15 +111,14 @@ var JoinDialog = (props) => {
126
111
  // packages/plugins/plugin-client/src/components/RecoveryCodeDialog.tsx
127
112
  import React3, { useCallback as useCallback3, useState } from "react";
128
113
  import { AlertDialog, Button, Clipboard as Clipboard2, Input, useTranslation } from "@dxos/react-ui";
114
+ var RECOVER_CODE_DIALOG = `${CLIENT_PLUGIN}/RecoveryCodeDialog`;
129
115
  var RecoveryCodeDialog = ({ code }) => {
130
116
  const { t } = useTranslation(CLIENT_PLUGIN);
131
117
  const [confirmation, setConfirmation] = useState(false);
132
118
  const handleConfirmation = useCallback3((checked) => setConfirmation(checked), []);
133
119
  return /* @__PURE__ */ React3.createElement(AlertDialog.Content, {
134
120
  classNames: "bs-content min-bs-[15rem] max-bs-full md:max-is-[40rem] overflow-hidden"
135
- }, /* @__PURE__ */ React3.createElement(AlertDialog.Title, {
136
- classNames: ""
137
- }, t("recovery code dialog title")), /* @__PURE__ */ React3.createElement("p", {
121
+ }, /* @__PURE__ */ React3.createElement(AlertDialog.Title, null, t("recovery code dialog title")), /* @__PURE__ */ React3.createElement("p", {
138
122
  className: "py-4"
139
123
  }, t("recovery code dialog description")), /* @__PURE__ */ React3.createElement(Clipboard2.Provider, null, /* @__PURE__ */ React3.createElement(Code, {
140
124
  code
@@ -194,7 +178,6 @@ var translations_default = [
194
178
 
195
179
  // packages/plugins/plugin-client/src/ClientPlugin.tsx
196
180
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-client/src/ClientPlugin.tsx";
197
- var parseClientPlugin = (plugin) => (plugin?.provides).client instanceof Client ? plugin : void 0;
198
181
  var ClientPlugin = ({ appKey, invitationUrl = window.location.origin, invitationParam = "deviceInvitationCode", onClientInitialized, onReady, onReset, ...options }) => {
199
182
  registerSignalsRuntime();
200
183
  let client;
@@ -232,7 +215,7 @@ var ClientPlugin = ({ appKey, invitationUrl = window.location.origin, invitation
232
215
  }, children)
233
216
  };
234
217
  },
235
- ready: async (plugins) => {
218
+ ready: async ({ plugins }) => {
236
219
  if (error) {
237
220
  throw error;
238
221
  }
@@ -244,27 +227,33 @@ var ClientPlugin = ({ appKey, invitationUrl = window.location.origin, invitation
244
227
  provides: {
245
228
  translations: translations_default,
246
229
  surface: {
247
- component: ({ data, role, ...rest }) => {
248
- switch (role) {
249
- case "dialog":
250
- if (data.component === "dxos.org/plugin/client/IdentityDialog") {
251
- return /* @__PURE__ */ React4.createElement(IdentityDialog, {
252
- ...data.subject,
253
- createInvitationUrl: createDeviceInvitationUrl
254
- });
255
- } else if (data.component === "dxos.org/plugin/client/JoinDialog") {
256
- return /* @__PURE__ */ React4.createElement(JoinDialog, data.subject);
257
- } else if (data.component === "dxos.org/plugin/client/RecoveryCodeDialog") {
258
- return /* @__PURE__ */ React4.createElement(RecoveryCodeDialog, data.subject);
259
- }
260
- break;
261
- }
262
- return null;
263
- }
230
+ definitions: () => [
231
+ createSurface({
232
+ id: IDENTITY_DIALOG,
233
+ role: "dialog",
234
+ filter: (data) => data.component === IDENTITY_DIALOG,
235
+ component: ({ data }) => /* @__PURE__ */ React4.createElement(IdentityDialog, {
236
+ ...data.subject,
237
+ createInvitationUrl: createDeviceInvitationUrl
238
+ })
239
+ }),
240
+ createSurface({
241
+ id: JOIN_DIALOG,
242
+ role: "dialog",
243
+ filter: (data) => data.component === JOIN_DIALOG,
244
+ component: ({ data }) => /* @__PURE__ */ React4.createElement(JoinDialog, data.subject)
245
+ }),
246
+ createSurface({
247
+ id: RECOVER_CODE_DIALOG,
248
+ role: "dialog",
249
+ filter: (data) => data.component === RECOVER_CODE_DIALOG,
250
+ component: ({ data }) => /* @__PURE__ */ React4.createElement(RecoveryCodeDialog, data.subject)
251
+ })
252
+ ]
264
253
  },
265
254
  graph: {
266
255
  builder: (plugins) => {
267
- const intentPlugin = resolvePlugin(plugins, parseIntentPlugin);
256
+ const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.dispatchPromise;
268
257
  const id = `${CLIENT_PLUGIN}/open-shell`;
269
258
  return createExtension({
270
259
  id: CLIENT_PLUGIN,
@@ -273,12 +262,7 @@ var ClientPlugin = ({ appKey, invitationUrl = window.location.origin, invitation
273
262
  {
274
263
  id,
275
264
  data: async () => {
276
- await intentPlugin?.provides.intent.dispatch([
277
- {
278
- plugin: CLIENT_PLUGIN,
279
- action: ClientAction.SHARE_IDENTITY
280
- }
281
- ]);
265
+ await dispatch?.(createIntent3(ClientAction.ShareIdentity));
282
266
  },
283
267
  properties: {
284
268
  label: [
@@ -302,149 +286,108 @@ var ClientPlugin = ({ appKey, invitationUrl = window.location.origin, invitation
302
286
  }
303
287
  },
304
288
  intent: {
305
- resolver: async (intent) => {
306
- switch (intent.action) {
307
- case ClientAction.CREATE_IDENTITY: {
308
- const data = await client.halo.createIdentity();
309
- return {
310
- data,
311
- intents: [
312
- [
313
- {
314
- action: OBSERVABILITY_ACTION,
315
- data: {
316
- name: "identity.create"
317
- }
318
- }
319
- ]
320
- ]
321
- };
322
- }
323
- case ClientAction.JOIN_IDENTITY: {
324
- return {
325
- data: true,
326
- intents: [
327
- [
328
- {
329
- action: LayoutAction3.SET_LAYOUT,
330
- data: {
331
- element: "dialog",
332
- component: "dxos.org/plugin/client/JoinDialog",
333
- dialogBlockAlign: "start",
334
- subject: {
335
- initialInvitationCode: intent.data?.invitationCode,
336
- initialDisposition: "accept-halo-invitation"
337
- }
338
- }
339
- }
340
- ]
341
- ]
342
- };
343
- }
344
- case ClientAction.SHARE_IDENTITY: {
345
- return {
346
- data: true,
347
- intents: [
348
- [
349
- {
350
- action: LayoutAction3.SET_LAYOUT,
351
- data: {
352
- element: "dialog",
353
- component: "dxos.org/plugin/client/IdentityDialog",
354
- dialogBlockAlign: "start"
355
- }
356
- }
357
- ],
358
- [
359
- {
360
- action: OBSERVABILITY_ACTION,
361
- data: {
362
- name: "identity.share"
363
- }
364
- }
365
- ]
366
- ]
367
- };
368
- }
369
- case ClientAction.RECOVER_IDENTITY: {
370
- return {
371
- data: true,
372
- intents: [
373
- [
374
- {
375
- action: LayoutAction3.SET_LAYOUT,
376
- data: {
377
- element: "dialog",
378
- component: "dxos.org/plugin/client/JoinDialog",
379
- dialogBlockAlign: "start",
380
- subject: {
381
- initialDisposition: "recover-identity"
382
- }
383
- }
384
- }
385
- ]
386
- ]
387
- };
388
- }
389
- case ClientAction.RESET_STORAGE: {
390
- await onReset?.({
391
- target: intent.data?.target
392
- });
393
- return {
394
- data: true
395
- };
396
- }
397
- case ClientAction.CREATE_AGENT: {
398
- invariant(client.services.services.EdgeAgentService, "Missing EdgeAgentService", {
399
- F: __dxlog_file,
400
- L: 283,
401
- S: void 0,
402
- A: [
403
- "client.services.services.EdgeAgentService",
404
- "'Missing EdgeAgentService'"
405
- ]
406
- });
407
- await client.services.services.EdgeAgentService.createAgent(null, {
408
- timeout: 1e4
409
- });
410
- return {
411
- data: true
412
- };
413
- }
414
- case ClientAction.CREATE_RECOVERY_CODE: {
415
- invariant(client.services.services.IdentityService, "IdentityService not available", {
416
- F: __dxlog_file,
417
- L: 289,
418
- S: void 0,
419
- A: [
420
- "client.services.services.IdentityService",
421
- "'IdentityService not available'"
422
- ]
423
- });
424
- const { seedphrase } = await client.services.services.IdentityService.createRecoveryPhrase();
425
- return {
426
- data: true,
427
- intents: [
428
- [
429
- {
430
- action: LayoutAction3.SET_LAYOUT,
431
- data: {
432
- element: "dialog",
433
- dialogBlockAlign: "start",
434
- dialogType: "alert",
435
- state: true,
436
- component: "dxos.org/plugin/client/RecoveryCodeDialog",
437
- subject: {
438
- code: seedphrase
439
- }
440
- }
441
- }
442
- ]
443
- ]
444
- };
445
- }
446
- }
447
- }
289
+ resolvers: () => [
290
+ createResolver(ClientAction.CreateIdentity, async () => {
291
+ const data = await client.halo.createIdentity();
292
+ return {
293
+ data,
294
+ intents: [
295
+ createIntent3(ObservabilityAction2.SendEvent, {
296
+ name: "identity.create"
297
+ })
298
+ ]
299
+ };
300
+ }),
301
+ createResolver(ClientAction.JoinIdentity, async (data) => {
302
+ return {
303
+ intents: [
304
+ createIntent3(LayoutAction3.SetLayout, {
305
+ element: "dialog",
306
+ component: JOIN_DIALOG,
307
+ dialogBlockAlign: "start",
308
+ subject: {
309
+ initialInvitationCode: data.invitationCode,
310
+ initialDisposition: "accept-halo-invitation"
311
+ }
312
+ })
313
+ ]
314
+ };
315
+ }),
316
+ createResolver(ClientAction.ShareIdentity, async () => {
317
+ return {
318
+ intents: [
319
+ createIntent3(LayoutAction3.SetLayout, {
320
+ element: "dialog",
321
+ component: IDENTITY_DIALOG,
322
+ dialogBlockAlign: "start"
323
+ }),
324
+ createIntent3(ObservabilityAction2.SendEvent, {
325
+ name: "identity.share"
326
+ })
327
+ ]
328
+ };
329
+ }),
330
+ createResolver(ClientAction.RecoverIdentity, async () => {
331
+ return {
332
+ intents: [
333
+ createIntent3(LayoutAction3.SetLayout, {
334
+ element: "dialog",
335
+ component: JOIN_DIALOG,
336
+ dialogBlockAlign: "start",
337
+ subject: {
338
+ initialDisposition: "recover-identity"
339
+ }
340
+ })
341
+ ]
342
+ };
343
+ }),
344
+ createResolver(ClientAction.ResetStorage, async (data) => {
345
+ await onReset?.({
346
+ target: data.target
347
+ });
348
+ return {};
349
+ }),
350
+ createResolver(ClientAction.CreateAgent, async () => {
351
+ invariant(client.services.services.EdgeAgentService, "Missing EdgeAgentService", {
352
+ F: __dxlog_file,
353
+ L: 203,
354
+ S: void 0,
355
+ A: [
356
+ "client.services.services.EdgeAgentService",
357
+ "'Missing EdgeAgentService'"
358
+ ]
359
+ });
360
+ await client.services.services.EdgeAgentService.createAgent(null, {
361
+ timeout: 1e4
362
+ });
363
+ }),
364
+ createResolver(ClientAction.CreateRecoveryCode, async () => {
365
+ invariant(client.services.services.IdentityService, "IdentityService not available", {
366
+ F: __dxlog_file,
367
+ L: 207,
368
+ S: void 0,
369
+ A: [
370
+ "client.services.services.IdentityService",
371
+ "'IdentityService not available'"
372
+ ]
373
+ });
374
+ const { seedphrase } = await client.services.services.IdentityService.createRecoveryPhrase();
375
+ return {
376
+ intents: [
377
+ createIntent3(LayoutAction3.SetLayout, {
378
+ element: "dialog",
379
+ dialogBlockAlign: "start",
380
+ dialogType: "alert",
381
+ state: true,
382
+ component: RECOVER_CODE_DIALOG,
383
+ subject: {
384
+ code: seedphrase
385
+ }
386
+ })
387
+ ]
388
+ };
389
+ })
390
+ ]
448
391
  }
449
392
  }
450
393
  };
@@ -454,7 +397,6 @@ var ClientPlugin = ({ appKey, invitationUrl = window.location.origin, invitation
454
397
  var src_default = ClientPlugin;
455
398
  export {
456
399
  ClientPlugin,
457
- src_default as default,
458
- parseClientPlugin
400
+ src_default as default
459
401
  };
460
402
  //# sourceMappingURL=index.mjs.map