@dxos/react-client 0.4.10-main.fa5a270 → 0.4.10-main.fd8ea31

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 (61) hide show
  1. package/dist/lib/browser/{chunk-Y64VSVTU.mjs → chunk-BQ4BAP42.mjs} +4 -3
  2. package/dist/lib/browser/chunk-BQ4BAP42.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-6SW7V4VI.mjs → chunk-HJDLXXEZ.mjs} +3 -3
  4. package/dist/lib/browser/{chunk-6SW7V4VI.mjs.map → chunk-HJDLXXEZ.mjs.map} +3 -3
  5. package/dist/lib/browser/devtools/index.mjs +1 -1
  6. package/dist/lib/browser/echo/index.mjs +29 -18
  7. package/dist/lib/browser/echo/index.mjs.map +3 -3
  8. package/dist/lib/browser/halo/index.mjs +12 -24
  9. package/dist/lib/browser/halo/index.mjs.map +3 -3
  10. package/dist/lib/browser/index.mjs +1 -1
  11. package/dist/lib/browser/invitations/index.mjs +1 -1
  12. package/dist/lib/browser/mesh/index.mjs +3 -7
  13. package/dist/lib/browser/mesh/index.mjs.map +3 -3
  14. package/dist/lib/browser/meta.json +1 -1
  15. package/dist/lib/browser/testing/index.mjs +3 -3
  16. package/dist/lib/browser/testing/index.mjs.map +3 -3
  17. package/dist/lib/node/{chunk-IRRRZ2KE.cjs → chunk-3GRHATJ3.cjs} +5 -5
  18. package/dist/lib/node/{chunk-IRRRZ2KE.cjs.map → chunk-3GRHATJ3.cjs.map} +3 -3
  19. package/dist/lib/node/{chunk-PNDYOCJA.cjs → chunk-X5URYLUS.cjs} +7 -6
  20. package/dist/lib/node/chunk-X5URYLUS.cjs.map +7 -0
  21. package/dist/lib/node/devtools/index.cjs +2 -2
  22. package/dist/lib/node/echo/index.cjs +31 -20
  23. package/dist/lib/node/echo/index.cjs.map +3 -3
  24. package/dist/lib/node/halo/index.cjs +18 -31
  25. package/dist/lib/node/halo/index.cjs.map +3 -3
  26. package/dist/lib/node/index.cjs +9 -9
  27. package/dist/lib/node/invitations/index.cjs +7 -7
  28. package/dist/lib/node/invitations/index.cjs.map +1 -1
  29. package/dist/lib/node/mesh/index.cjs +4 -8
  30. package/dist/lib/node/mesh/index.cjs.map +3 -3
  31. package/dist/lib/node/meta.json +1 -1
  32. package/dist/lib/node/testing/index.cjs +4 -4
  33. package/dist/lib/node/testing/index.cjs.map +3 -3
  34. package/dist/types/src/echo/useQuery.d.ts +2 -2
  35. package/dist/types/src/echo/useQuery.d.ts.map +1 -1
  36. package/dist/types/src/echo/useSpaceInvitations.d.ts +2 -1
  37. package/dist/types/src/echo/useSpaceInvitations.d.ts.map +1 -1
  38. package/dist/types/src/halo/index.d.ts +1 -1
  39. package/dist/types/src/halo/index.d.ts.map +1 -1
  40. package/dist/types/src/halo/useContacts.d.ts.map +1 -1
  41. package/dist/types/src/halo/useDevices.d.ts.map +1 -1
  42. package/dist/types/src/halo/useHaloInvitations.d.ts +2 -1
  43. package/dist/types/src/halo/useHaloInvitations.d.ts.map +1 -1
  44. package/dist/types/src/invitations/useInvitationStatus.d.ts +1 -0
  45. package/dist/types/src/invitations/useInvitationStatus.d.ts.map +1 -1
  46. package/dist/types/src/mesh/useNetworkStatus.d.ts.map +1 -1
  47. package/dist/types/src/testing/ClientRepeater.d.ts +3 -3
  48. package/dist/types/src/testing/ClientRepeater.d.ts.map +1 -1
  49. package/package.json +33 -25
  50. package/src/client/useAgentHostingProvider.ts +2 -2
  51. package/src/echo/useQuery.ts +46 -15
  52. package/src/echo/useSpaceInvitations.ts +6 -18
  53. package/src/halo/index.ts +1 -10
  54. package/src/halo/useContacts.ts +2 -11
  55. package/src/halo/useDevices.ts +2 -11
  56. package/src/halo/useHaloInvitations.ts +6 -13
  57. package/src/invitations/useInvitationStatus.ts +3 -0
  58. package/src/mesh/useNetworkStatus.ts +2 -11
  59. package/src/testing/ClientRepeater.tsx +6 -8
  60. package/dist/lib/browser/chunk-Y64VSVTU.mjs.map +0 -7
  61. package/dist/lib/node/chunk-PNDYOCJA.cjs.map +0 -7
@@ -1,4 +1,5 @@
1
1
  import { type PublicKey } from '@dxos/client';
2
- export declare const useSpaceInvitations: (spaceKey?: PublicKey) => import("../invitations").CancellableInvitationObservable[];
2
+ import { type CancellableInvitationObservable } from '../invitations';
3
+ export declare const useSpaceInvitations: (spaceKey?: PublicKey) => CancellableInvitationObservable[];
3
4
  export declare const useSpaceInvitation: (spaceKey?: PublicKey, invitationId?: string) => import("../invitations").InvitationStatus;
4
5
  //# sourceMappingURL=useSpaceInvitations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSpaceInvitations.d.ts","sourceRoot":"","sources":["../../../../src/echo/useSpaceInvitations.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAM9C,eAAO,MAAM,mBAAmB,cAAe,SAAS,+DAgBvD,CAAC;AAEF,eAAO,MAAM,kBAAkB,cAAe,SAAS,iBAAiB,MAAM,8CAO7E,CAAC"}
1
+ {"version":3,"file":"useSpaceInvitations.d.ts","sourceRoot":"","sources":["../../../../src/echo/useSpaceInvitations.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAI9C,OAAO,EAAE,KAAK,+BAA+B,EAAuB,MAAM,gBAAgB,CAAC;AAE3F,eAAO,MAAM,mBAAmB,cAAe,SAAS,KAAG,+BAA+B,EAGzF,CAAC;AAEF,eAAO,MAAM,kBAAkB,cAAe,SAAS,iBAAiB,MAAM,8CAO7E,CAAC"}
@@ -1,4 +1,4 @@
1
- export { type Contact, Device, DeviceKind, DeviceType, type Identity, type Halo, HaloProxy, } from '@dxos/client/halo';
1
+ export { type Contact, type Identity, type Halo, Device, DeviceKind, DeviceType } from '@dxos/client/halo';
2
2
  export * from './useContacts';
3
3
  export * from './useDevices';
4
4
  export * from './useHaloInvitations';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/halo/index.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,OAAO,EACZ,MAAM,EACN,UAAU,EACV,UAAU,EACV,KAAK,QAAQ,EAEb,KAAK,IAAI,EACT,SAAS,GACV,MAAM,mBAAmB,CAAC;AAE3B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/halo/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE3G,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useContacts.d.ts","sourceRoot":"","sources":["../../../../src/halo/useContacts.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAIjD;;;;GAIG;AACH,eAAO,MAAM,WAAW,QAAO,OAAO,EAWrC,CAAC"}
1
+ {"version":3,"file":"useContacts.d.ts","sourceRoot":"","sources":["../../../../src/halo/useContacts.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAKjD;;;;GAIG;AACH,eAAO,MAAM,WAAW,QAAO,OAAO,EAGrC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDevices.d.ts","sourceRoot":"","sources":["../../../../src/halo/useDevices.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAIhD,eAAO,MAAM,UAAU,QAAO,MAAM,EAWnC,CAAC"}
1
+ {"version":3,"file":"useDevices.d.ts","sourceRoot":"","sources":["../../../../src/halo/useDevices.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAKhD,eAAO,MAAM,UAAU,QAAO,MAAM,EAGnC,CAAC"}
@@ -1,3 +1,4 @@
1
- export declare const useHaloInvitations: () => import("../invitations").CancellableInvitationObservable[];
1
+ import { type CancellableInvitationObservable } from '../invitations';
2
+ export declare const useHaloInvitations: () => CancellableInvitationObservable[];
2
3
  export declare const useHaloInvitation: (invitationId?: string) => import("../invitations").InvitationStatus;
3
4
  //# sourceMappingURL=useHaloInvitations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useHaloInvitations.d.ts","sourceRoot":"","sources":["../../../../src/halo/useHaloInvitations.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,kBAAkB,kEAY9B,CAAC;AAEF,eAAO,MAAM,iBAAiB,kBAAmB,MAAM,8CAOtD,CAAC"}
1
+ {"version":3,"file":"useHaloInvitations.d.ts","sourceRoot":"","sources":["../../../../src/halo/useHaloInvitations.ts"],"names":[],"mappings":"AASA,OAAO,EAAuB,KAAK,+BAA+B,EAAE,MAAM,gBAAgB,CAAC;AAE3F,eAAO,MAAM,kBAAkB,QAAO,+BAA+B,EAGpE,CAAC;AAEF,eAAO,MAAM,iBAAiB,kBAAmB,MAAM,8CAOtD,CAAC"}
@@ -30,6 +30,7 @@ export type InvitationStatus = {
30
30
  type?: Invitation.Type;
31
31
  status: Invitation.State;
32
32
  haltedAt?: Invitation.State;
33
+ multiUse?: boolean;
33
34
  result: InvitationResult;
34
35
  error?: number;
35
36
  cancel(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"useInvitationStatus.d.ts","sourceRoot":"","sources":["../../../../src/invitations/useInvitationStatus.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,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,EAAE,UAAU,CAAC,KAAK,CAAC,SAAS,GAAG,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC;IAC9D,QAAQ,EAAE,UAAU,CAAC,KAAK,CAAC;CAC5B,GACD;IACE,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC;IAC/B,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,QAAQ,EAAE,UAAU,CAAC,KAAK,CAAC;CAC5B,CAAC;AAEN,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC;IACnC,IAAI,CAAC,EAAE,UAAU,CAAC,IAAI,CAAC;IACvB,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC;IACzB,QAAQ,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,gBAAgB,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,IAAI,IAAI,CAAC;IAEf,OAAO,CAAC,UAAU,EAAE,+BAA+B,GAAG,IAAI,CAAC;IAC3D,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/C,CAAC;AAEF,eAAO,MAAM,mBAAmB,uBAAwB,+BAA+B,KAAG,gBAmHzF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useNetworkStatus.d.ts","sourceRoot":"","sources":["../../../../src/mesh/useNetworkStatus.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAIvD;;GAEG;AACH,eAAO,MAAM,gBAAgB,QAAO,aAWnC,CAAC"}
1
+ {"version":3,"file":"useNetworkStatus.d.ts","sourceRoot":"","sources":["../../../../src/mesh/useNetworkStatus.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAKvD;;GAEG;AACH,eAAO,MAAM,gBAAgB,QAAO,aAGnC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { type FC } from 'react';
2
2
  import { Client } from '@dxos/client';
3
- import { type Space, type TypeCollection } from '@dxos/client/echo';
3
+ import { type Space } from '@dxos/client/echo';
4
4
  import { type MaybePromise } from '@dxos/util';
5
5
  export type RepeatedComponentProps = {
6
6
  id: number;
@@ -8,14 +8,14 @@ export type RepeatedComponentProps = {
8
8
  };
9
9
  export type ClientRepeaterProps<P extends RepeatedComponentProps> = {
10
10
  component: FC<any>;
11
+ className?: string;
11
12
  controls?: FC<{
12
13
  clients: Client[];
13
14
  }>;
14
15
  clients?: Client[];
15
16
  count?: number;
16
17
  registerSignalFactory?: boolean;
17
- className?: string;
18
- types?: TypeCollection;
18
+ schema?: Parameters<Client['addSchema']>;
19
19
  createIdentity?: boolean;
20
20
  createSpace?: boolean;
21
21
  onCreateSpace?: (space: Space) => MaybePromise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"ClientRepeater.d.ts","sourceRoot":"","sources":["../../../../src/testing/ClientRepeater.tsx"],"names":[],"mappings":"AAIA,OAAc,EAAY,KAAK,EAAE,EAAa,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAE,MAAM,EAAkB,MAAM,cAAc,CAAC;AACtD,OAAO,EAAmB,KAAK,KAAK,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAIrF,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAM/C,MAAM,MAAM,sBAAsB,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnE,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,sBAAsB,IAAI;IAClE,SAAS,EAAE,EAAE,CAAC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AE,CAAC,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,MAAM,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;IACzC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;IACrD,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,CAAC;CAChC,CAAC;AAEF;;;GAGG;AAMH,eAAO,MAAM,cAAc,yFAyD1B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-client",
3
- "version": "0.4.10-main.fa5a270",
3
+ "version": "0.4.10-main.fd8ea31",
4
4
  "description": "React client API",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -11,49 +11,57 @@
11
11
  "browser": "./dist/lib/browser/index.mjs",
12
12
  "import": "./dist/lib/browser/index.mjs",
13
13
  "require": "./dist/lib/node/index.cjs",
14
- "node": "./dist/lib/node/index.cjs"
14
+ "node": "./dist/lib/node/index.cjs",
15
+ "types": "./dist/types/src/index.d.ts"
15
16
  },
16
17
  "./devtools": {
17
18
  "browser": "./dist/lib/browser/devtools/index.mjs",
18
19
  "import": "./dist/lib/browser/devtools/index.mjs",
19
20
  "require": "./dist/lib/node/devtools/index.cjs",
20
- "node": "./dist/lib/node/devtools/index.cjs"
21
+ "node": "./dist/lib/node/devtools/index.cjs",
22
+ "types": "./dist/types/src/devtools/index.d.ts"
21
23
  },
22
24
  "./echo": {
23
25
  "browser": "./dist/lib/browser/echo/index.mjs",
24
26
  "import": "./dist/lib/browser/echo/index.mjs",
25
27
  "require": "./dist/lib/node/echo/index.cjs",
26
- "node": "./dist/lib/node/echo/index.cjs"
28
+ "node": "./dist/lib/node/echo/index.cjs",
29
+ "types": "./dist/types/src/echo/index.d.ts"
27
30
  },
28
31
  "./halo": {
29
32
  "browser": "./dist/lib/browser/halo/index.mjs",
30
33
  "import": "./dist/lib/browser/halo/index.mjs",
31
34
  "require": "./dist/lib/node/halo/index.cjs",
32
- "node": "./dist/lib/node/halo/index.cjs"
35
+ "node": "./dist/lib/node/halo/index.cjs",
36
+ "types": "./dist/types/src/halo/index.d.ts"
33
37
  },
34
38
  "./invitations": {
35
39
  "browser": "./dist/lib/browser/invitations/index.mjs",
36
40
  "import": "./dist/lib/browser/invitations/index.mjs",
37
41
  "require": "./dist/lib/node/invitations/index.cjs",
38
- "node": "./dist/lib/node/invitations/index.cjs"
42
+ "node": "./dist/lib/node/invitations/index.cjs",
43
+ "types": "./dist/types/src/invitations/index.d.ts"
39
44
  },
40
45
  "./mesh": {
41
46
  "browser": "./dist/lib/browser/mesh/index.mjs",
42
47
  "import": "./dist/lib/browser/mesh/index.mjs",
43
48
  "require": "./dist/lib/node/mesh/index.cjs",
44
- "node": "./dist/lib/node/mesh/index.cjs"
49
+ "node": "./dist/lib/node/mesh/index.cjs",
50
+ "types": "./dist/types/src/mesh/index.d.ts"
45
51
  },
46
52
  "./testing": {
47
53
  "browser": "./dist/lib/browser/testing/index.mjs",
48
54
  "import": "./dist/lib/browser/testing/index.mjs",
49
55
  "require": "./dist/lib/node/testing/index.cjs",
50
- "node": "./dist/lib/node/testing/index.cjs"
56
+ "node": "./dist/lib/node/testing/index.cjs",
57
+ "types": "./dist/types/src/testing/index.d.ts"
51
58
  },
52
59
  "./worker": {
53
60
  "browser": "./dist/lib/browser/worker.mjs",
54
61
  "import": "./dist/lib/browser/worker.mjs",
55
62
  "require": "./dist/lib/node/worker.cjs",
56
- "node": "./dist/lib/node/worker.cjs"
63
+ "node": "./dist/lib/node/worker.cjs",
64
+ "types": "./dist/types/src/worker.d.ts"
57
65
  }
58
66
  },
59
67
  "types": "dist/types/src/index.d.ts",
@@ -83,17 +91,17 @@
83
91
  }
84
92
  },
85
93
  "dependencies": {
86
- "@dxos/async": "0.4.10-main.fa5a270",
87
- "@dxos/codec-protobuf": "0.4.10-main.fa5a270",
88
- "@dxos/client": "0.4.10-main.fa5a270",
89
- "@dxos/config": "0.4.10-main.fa5a270",
90
- "@dxos/debug": "0.4.10-main.fa5a270",
91
- "@dxos/log": "0.4.10-main.fa5a270",
92
- "@dxos/echo-signals": "0.4.10-main.fa5a270",
93
- "@dxos/invariant": "0.4.10-main.fa5a270",
94
- "@dxos/node-std": "0.4.10-main.fa5a270",
95
- "@dxos/util": "0.4.10-main.fa5a270",
96
- "@dxos/react-async": "0.4.10-main.fa5a270"
94
+ "@dxos/client": "0.4.10-main.fd8ea31",
95
+ "@dxos/debug": "0.4.10-main.fd8ea31",
96
+ "@dxos/codec-protobuf": "0.4.10-main.fd8ea31",
97
+ "@dxos/echo-signals": "0.4.10-main.fd8ea31",
98
+ "@dxos/config": "0.4.10-main.fd8ea31",
99
+ "@dxos/log": "0.4.10-main.fd8ea31",
100
+ "@dxos/async": "0.4.10-main.fd8ea31",
101
+ "@dxos/node-std": "0.4.10-main.fd8ea31",
102
+ "@dxos/react-async": "0.4.10-main.fd8ea31",
103
+ "@dxos/invariant": "0.4.10-main.fd8ea31",
104
+ "@dxos/util": "0.4.10-main.fd8ea31"
97
105
  },
98
106
  "devDependencies": {
99
107
  "@testing-library/dom": "^8.17.1",
@@ -104,10 +112,10 @@
104
112
  "react": "^18.2.0",
105
113
  "react-dom": "^18.2.0",
106
114
  "yjs": "^13.6.10",
107
- "@dxos/random": "0.4.10-main.fa5a270",
108
- "@dxos/react-ui": "0.4.10-main.fa5a270",
109
- "@dxos/react-ui-theme": "0.4.10-main.fa5a270",
110
- "@dxos/storybook-utils": "0.4.10-main.fa5a270"
115
+ "@dxos/random": "0.4.10-main.fd8ea31",
116
+ "@dxos/react-ui-theme": "0.4.10-main.fd8ea31",
117
+ "@dxos/storybook-utils": "0.4.10-main.fd8ea31",
118
+ "@dxos/react-ui": "0.4.10-main.fd8ea31"
111
119
  },
112
120
  "peerDependencies": {
113
121
  "react": "*",
@@ -115,7 +123,7 @@
115
123
  },
116
124
  "optionalDependencies": {
117
125
  "yjs": "^13.6.10",
118
- "@dxos/random": "0.4.10-main.fa5a270"
126
+ "@dxos/random": "0.4.10-main.fd8ea31"
119
127
  },
120
128
  "publishConfig": {
121
129
  "access": "public"
@@ -4,7 +4,7 @@
4
4
 
5
5
  import {
6
6
  type AgentHostingProviderClient,
7
- EldonAgentHostingProviderClient,
7
+ DXOSAgentHostingProviderClient,
8
8
  FakeAgentHostingProvider,
9
9
  } from '@dxos/client/services';
10
10
  import { type Config } from '@dxos/config';
@@ -33,5 +33,5 @@ export const useAgentHostingProviderClient = (config: Config): AgentHostingProvi
33
33
  return new FakeAgentHostingProvider(config);
34
34
  }
35
35
 
36
- return new EldonAgentHostingProviderClient(config);
36
+ return new DXOSAgentHostingProviderClient(config);
37
37
  };
@@ -4,34 +4,65 @@
4
4
 
5
5
  import { useMemo, useSyncExternalStore } from 'react';
6
6
 
7
- import type { QueryOptions, TypedObject, Query, FilterSource, Space } from '@dxos/client/echo';
7
+ import {
8
+ type QueryOptions,
9
+ type Query,
10
+ type FilterSource,
11
+ type Space,
12
+ type EchoReactiveObject,
13
+ type Echo,
14
+ isSpace,
15
+ } from '@dxos/client/echo';
8
16
 
9
17
  type UseQuery = {
10
- <T extends TypedObject>(space?: Space, filter?: FilterSource<T>, options?: QueryOptions, deps?: any[]): T[];
18
+ <T extends EchoReactiveObject<any>>(
19
+ spaceOrEcho?: Space | Echo,
20
+ filter?: FilterSource<T>,
21
+ options?: QueryOptions,
22
+ deps?: any[],
23
+ ): T[];
11
24
  };
12
25
 
13
26
  /**
14
27
  * Create subscription.
15
28
  */
16
29
  // TODO(burdon): Support typed operator filters (e.g., Note.filter(note => ...)).
17
- export const useQuery: UseQuery = <T extends TypedObject>(
18
- space?: Space,
30
+ export const useQuery: UseQuery = <T extends EchoReactiveObject<any>>(
31
+ spaceOrEcho?: Space | Echo,
19
32
  filter?: FilterSource<T>,
20
33
  options?: QueryOptions,
21
34
  deps?: any[],
22
35
  ) => {
23
- const query = useMemo(
24
- () => space?.db.query(filter, options) as Query<T> | undefined,
25
- [space?.db, ...(typeof filter === 'function' ? [] : filterToDepsArray(filter)), ...(deps ?? [])],
26
- );
36
+ const { subscribe, getObjects } = useMemo(() => {
37
+ const query = isSpace(spaceOrEcho)
38
+ ? spaceOrEcho.db.query(filter, options)
39
+ : (spaceOrEcho?.query(filter, options) as Query<T> | undefined);
40
+ let subscribed = false;
41
+
42
+ return {
43
+ subscribe: (cb: () => void) => {
44
+ subscribed = true;
45
+ const unsubscribe = query?.subscribe(cb) ?? noop;
46
+ return () => {
47
+ unsubscribe?.();
48
+ subscribed = false;
49
+ };
50
+ },
51
+ getObjects: () => (subscribed && query ? query.objects : EMPTY_ARRAY),
52
+ };
53
+ }, [spaceOrEcho, ...(typeof filter === 'function' ? [] : filterToDepsArray(filter)), ...(deps ?? [])]);
27
54
 
28
55
  // https://beta.reactjs.org/reference/react/useSyncExternalStore
29
- return (
30
- useSyncExternalStore<T[] | undefined>(
31
- (cb) => query?.subscribe?.(cb) ?? cb,
32
- () => query?.objects,
33
- ) ?? []
34
- );
56
+ // NOTE: This hook will resubscribe whenever the callback passed to the first argument changes -- make sure it is stable.
57
+ return useSyncExternalStore<T[] | undefined>(subscribe, getObjects) ?? [];
35
58
  };
36
59
 
37
- const filterToDepsArray = (filter?: FilterSource<any>) => Object.entries(filter ?? {}).flat();
60
+ // TODO(dmaretskyi): Serialize the filter here instead.
61
+ const filterToDepsArray = (filter?: FilterSource<any>) =>
62
+ Object.entries(filter ?? {})
63
+ .flat(10)
64
+ .map((x) => (typeof x === 'function' || typeof x === 'object' ? null : x));
65
+
66
+ const noop = () => {};
67
+
68
+ const EMPTY_ARRAY: never[] = [];
@@ -2,30 +2,18 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import { useMemo, useSyncExternalStore } from 'react';
5
+ import { useMemo } from 'react';
6
6
 
7
+ import { MulticastObservable } from '@dxos/async';
7
8
  import { type PublicKey } from '@dxos/client';
8
- import { SpaceProxy } from '@dxos/client/echo';
9
+ import { useMulticastObservable } from '@dxos/react-async';
9
10
 
10
11
  import { useSpace } from './useSpaces';
11
- import { useInvitationStatus } from '../invitations';
12
+ import { type CancellableInvitationObservable, useInvitationStatus } from '../invitations';
12
13
 
13
- export const useSpaceInvitations = (spaceKey?: PublicKey) => {
14
+ export const useSpaceInvitations = (spaceKey?: PublicKey): CancellableInvitationObservable[] => {
14
15
  const space = useSpace(spaceKey);
15
- const invitations =
16
- useSyncExternalStore(
17
- (listener) => {
18
- if (!(space instanceof SpaceProxy)) {
19
- return () => {};
20
- }
21
-
22
- const subscription = space.invitations.subscribe(() => listener());
23
- return () => subscription.unsubscribe();
24
- },
25
- () => space?.invitations.get(),
26
- ) ?? [];
27
-
28
- return invitations;
16
+ return useMulticastObservable(space?.invitations ?? MulticastObservable.empty()) ?? [];
29
17
  };
30
18
 
31
19
  export const useSpaceInvitation = (spaceKey?: PublicKey, invitationId?: string) => {
package/src/halo/index.ts CHANGED
@@ -3,16 +3,7 @@
3
3
  //
4
4
 
5
5
  // NOTE: Export * fails here.
6
- export {
7
- type Contact,
8
- Device,
9
- DeviceKind,
10
- DeviceType,
11
- type Identity,
12
- // generateSeedPhrase,
13
- type Halo,
14
- HaloProxy,
15
- } from '@dxos/client/halo';
6
+ export { type Contact, type Identity, type Halo, Device, DeviceKind, DeviceType } from '@dxos/client/halo';
16
7
 
17
8
  export * from './useContacts';
18
9
  export * from './useDevices';
@@ -2,9 +2,8 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- import { useSyncExternalStore } from 'react';
6
-
7
5
  import type { Contact } from '@dxos/client/halo';
6
+ import { useMulticastObservable } from '@dxos/react-async';
8
7
 
9
8
  import { useClient } from '../client';
10
9
 
@@ -15,13 +14,5 @@ import { useClient } from '../client';
15
14
  */
16
15
  export const useContacts = (): Contact[] => {
17
16
  const client = useClient();
18
- const contacts = useSyncExternalStore(
19
- (listener) => {
20
- const subscription = client.halo.contacts.subscribe(listener);
21
- return () => subscription.unsubscribe();
22
- },
23
- () => client.halo.contacts.get(),
24
- );
25
-
26
- return contacts;
17
+ return useMulticastObservable(client.halo.contacts);
27
18
  };
@@ -2,21 +2,12 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- import { useSyncExternalStore } from 'react';
6
-
7
5
  import type { Device } from '@dxos/client/halo';
6
+ import { useMulticastObservable } from '@dxos/react-async';
8
7
 
9
8
  import { useClient } from '../client';
10
9
 
11
10
  export const useDevices = (): Device[] => {
12
11
  const client = useClient();
13
- const devices = useSyncExternalStore(
14
- (listener) => {
15
- const subscription = client.halo.devices.subscribe(listener);
16
- return () => subscription.unsubscribe();
17
- },
18
- () => client.halo.devices.get(),
19
- );
20
-
21
- return devices;
12
+ return useMulticastObservable(client.halo.devices);
22
13
  };
@@ -2,23 +2,16 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import { useMemo, useSyncExternalStore } from 'react';
5
+ import { useMemo } from 'react';
6
+
7
+ import { useMulticastObservable } from '@dxos/react-async';
6
8
 
7
9
  import { useClient } from '../client';
8
- import { useInvitationStatus } from '../invitations';
10
+ import { useInvitationStatus, type CancellableInvitationObservable } from '../invitations';
9
11
 
10
- export const useHaloInvitations = () => {
12
+ export const useHaloInvitations = (): CancellableInvitationObservable[] => {
11
13
  const client = useClient();
12
- const invitations =
13
- useSyncExternalStore(
14
- (listener) => {
15
- const subscription = client.halo.invitations.subscribe(() => listener());
16
- return () => subscription.unsubscribe();
17
- },
18
- () => client.halo.invitations.get(),
19
- ) ?? [];
20
-
21
- return invitations;
14
+ return useMulticastObservable(client.halo.invitations);
22
15
  };
23
16
 
24
17
  export const useHaloInvitation = (invitationId?: string) => {
@@ -29,6 +29,7 @@ interface InvitationReducerState {
29
29
  id?: string;
30
30
  invitationCode?: string;
31
31
  authCode?: string;
32
+ multiUse?: boolean;
32
33
  }
33
34
 
34
35
  export type InvitationAction =
@@ -65,6 +66,7 @@ export type InvitationStatus = {
65
66
  type?: Invitation.Type;
66
67
  status: Invitation.State;
67
68
  haltedAt?: Invitation.State;
69
+ multiUse?: boolean;
68
70
  result: InvitationResult;
69
71
  error?: number;
70
72
  cancel(): void;
@@ -179,6 +181,7 @@ export const useInvitationStatus = (initialObservable?: CancellableInvitationObs
179
181
  connect,
180
182
  authenticate,
181
183
  id: invitation?.invitationId,
184
+ multiUse: invitation?.multiUse,
182
185
  invitationCode: invitation ? InvitationEncoder.encode(invitation) : undefined,
183
186
  authCode: invitation?.authCode,
184
187
  authMethod: invitation?.authMethod,
@@ -2,9 +2,8 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- import { useSyncExternalStore } from 'react';
6
-
7
5
  import { type NetworkStatus } from '@dxos/client/mesh';
6
+ import { useMulticastObservable } from '@dxos/react-async';
8
7
 
9
8
  import { useClient } from '../client';
10
9
 
@@ -13,13 +12,5 @@ import { useClient } from '../client';
13
12
  */
14
13
  export const useNetworkStatus = (): NetworkStatus => {
15
14
  const client = useClient();
16
- const networkStatus = useSyncExternalStore(
17
- (listener) => {
18
- const subscription = client.mesh.networkStatus.subscribe(listener);
19
- return () => subscription.unsubscribe();
20
- },
21
- () => client.mesh.networkStatus.get(),
22
- );
23
-
24
- return networkStatus;
15
+ return useMulticastObservable(client.mesh.networkStatus);
25
16
  };
@@ -5,7 +5,7 @@
5
5
  import React, { useState, type FC, useEffect } from 'react';
6
6
 
7
7
  import { Client, type PublicKey } from '@dxos/client';
8
- import { type SpaceProxy, type Space, type TypeCollection } from '@dxos/client/echo';
8
+ import { type Space } from '@dxos/client/echo';
9
9
  import { TestBuilder, performInvitation } from '@dxos/client/testing';
10
10
  import { registerSignalFactory } from '@dxos/echo-signals/react';
11
11
  import { faker } from '@dxos/random';
@@ -19,12 +19,12 @@ export type RepeatedComponentProps = { id: number; count: number };
19
19
 
20
20
  export type ClientRepeaterProps<P extends RepeatedComponentProps> = {
21
21
  component: FC<any>;
22
+ className?: string;
22
23
  controls?: FC<{ clients: Client[] }>;
23
24
  clients?: Client[];
24
25
  count?: number;
25
26
  registerSignalFactory?: boolean;
26
- className?: string;
27
- types?: TypeCollection;
27
+ schema?: Parameters<Client['addSchema']>;
28
28
  createIdentity?: boolean;
29
29
  createSpace?: boolean;
30
30
  onCreateSpace?: (space: Space) => MaybePromise<void>;
@@ -46,7 +46,7 @@ export const ClientRepeater = <P extends RepeatedComponentProps>(props: ClientRe
46
46
  controls: Controls,
47
47
  count = 1,
48
48
  className = 'flex w-full place-content-evenly',
49
- types,
49
+ schema,
50
50
  createIdentity,
51
51
  createSpace,
52
52
  onCreateSpace,
@@ -62,7 +62,7 @@ export const ClientRepeater = <P extends RepeatedComponentProps>(props: ClientRe
62
62
  const timeout = setTimeout(async () => {
63
63
  const clients = [...Array(count)].map((_) => new Client({ services: testBuilder.createLocal() }));
64
64
  await Promise.all(clients.map((client) => client.initialize()));
65
- types && clients.map((client) => client.spaces.addSchema(types));
65
+ schema && clients.map((client) => client.addSchema(...schema));
66
66
 
67
67
  if (createIdentity || createSpace) {
68
68
  await Promise.all(clients.map((client) => client.halo.createIdentity()));
@@ -72,9 +72,7 @@ export const ClientRepeater = <P extends RepeatedComponentProps>(props: ClientRe
72
72
  const space = await clients[0].spaces.create({ name: faker.commerce.productName() });
73
73
  setSpaceKey(space.key);
74
74
  await onCreateSpace?.(space);
75
- await Promise.all(
76
- clients.slice(1).map((client) => performInvitation({ host: space as SpaceProxy, guest: client.spaces })),
77
- );
75
+ await Promise.all(clients.slice(1).map((client) => performInvitation({ host: space, guest: client.spaces })));
78
76
  }
79
77
 
80
78
  setClients(clients);
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/invitations/index.ts", "../../../src/invitations/useInvitationStatus.ts"],
4
- "sourcesContent": ["//\n// Copyright 2020 DXOS.org\n//\n\n// NOTE: Export * fails here.\nexport {\n AuthenticatingInvitationObservable,\n CancellableInvitationObservable,\n InvitationEncoder,\n Invitation,\n type Invitations,\n InvitationsProxy,\n} from '@dxos/client/invitations';\n\nexport * from './useInvitationStatus';\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { useReducer, type Reducer, useMemo, useCallback, useEffect } from 'react';\n\nimport { type PublicKey } from '@dxos/client';\nimport {\n type AuthenticatingInvitationObservable,\n type CancellableInvitationObservable,\n Invitation,\n InvitationEncoder,\n} from '@dxos/client/invitations';\nimport { log } from '@dxos/log';\n\nexport type InvitationResult = {\n spaceKey: PublicKey | null;\n identityKey: PublicKey | null;\n swarmKey: PublicKey | null;\n target: string | null;\n};\n\ninterface InvitationReducerState {\n status: Invitation.State; // TODO(burdon): Rename state.\n haltedAt?: Invitation.State;\n result: InvitationResult;\n error?: number;\n observable?: CancellableInvitationObservable | AuthenticatingInvitationObservable;\n id?: string;\n invitationCode?: string;\n authCode?: string;\n}\n\nexport type InvitationAction =\n | {\n status:\n | Invitation.State.INIT\n | Invitation.State.CONNECTED\n | Invitation.State.READY_FOR_AUTHENTICATION\n | Invitation.State.AUTHENTICATING;\n }\n | {\n status: Invitation.State.CONNECTING;\n observable: CancellableInvitationObservable;\n }\n | {\n status: Invitation.State.SUCCESS;\n result: InvitationResult;\n }\n | {\n status: Invitation.State.CANCELLED | Invitation.State.TIMEOUT;\n haltedAt: Invitation.State;\n }\n | {\n status: Invitation.State.ERROR;\n error?: Error;\n haltedAt: Invitation.State;\n };\n\nexport type InvitationStatus = {\n id?: string;\n invitationCode?: string;\n authCode?: string;\n authMethod?: Invitation.AuthMethod;\n type?: Invitation.Type;\n status: Invitation.State;\n haltedAt?: Invitation.State;\n result: InvitationResult;\n error?: number;\n cancel(): void;\n // TODO(wittjosiah): Remove?\n connect(observable: CancellableInvitationObservable): void;\n authenticate(authCode: string): Promise<void>;\n};\n\nexport const useInvitationStatus = (initialObservable?: CancellableInvitationObservable): InvitationStatus => {\n const [state, dispatch] = useReducer<Reducer<InvitationReducerState, InvitationAction>, null>(\n (prev, action) => {\n log('useInvitationStatus', { action });\n return {\n ...prev,\n // TODO(burdon): State.\n status: action.status,\n // `invitationObservable`, `secret`, and `result` is persisted between the status-actions that set them.\n result: action.status === Invitation.State.SUCCESS ? action.result : prev.result,\n // `error` gets set each time we enter the error state\n ...(action.status === Invitation.State.ERROR && { error: action.error }),\n // `haltedAt` gets set on only the first error/cancelled/timeout action and reset on any others.\n ...((action.status === Invitation.State.ERROR ||\n action.status === Invitation.State.CANCELLED ||\n action.status === Invitation.State.TIMEOUT) && {\n haltedAt: typeof prev.haltedAt === 'undefined' ? action.haltedAt : prev.haltedAt,\n }),\n observable:\n action.status === Invitation.State.CONNECTING ? action.observable ?? prev.observable : prev.observable,\n } as InvitationReducerState;\n },\n null,\n (_arg: null) => {\n return {\n status: Invitation.State.INIT,\n result: { spaceKey: null, identityKey: null, swarmKey: null, target: null },\n observable: initialObservable,\n };\n },\n );\n\n // Handle unmount.\n\n useEffect(() => {\n const update = (invitation: Invitation) => {\n switch (invitation.state) {\n case Invitation.State.CONNECTED:\n case Invitation.State.READY_FOR_AUTHENTICATION:\n case Invitation.State.AUTHENTICATING: {\n dispatch({\n status: invitation.state,\n });\n break;\n }\n\n case Invitation.State.SUCCESS: {\n dispatch({\n status: invitation.state,\n result: {\n spaceKey: invitation.spaceKey || null,\n identityKey: invitation.identityKey || null,\n swarmKey: invitation.swarmKey || null,\n target: invitation.target || null,\n },\n });\n break;\n }\n\n case Invitation.State.CANCELLED:\n case Invitation.State.TIMEOUT: {\n dispatch({ status: invitation.state, haltedAt: state.status });\n break;\n }\n }\n };\n\n const subscription = state.observable?.subscribe(update, (err: Error) => {\n dispatch({ status: Invitation.State.ERROR, error: err, haltedAt: state.status });\n });\n\n const currentState = state.observable?.get();\n if (currentState) {\n update(currentState);\n }\n\n return () => subscription?.unsubscribe();\n }, [state.observable, state.status]);\n\n // Return memoized callbacks & values.\n\n const connect = useCallback((observable: CancellableInvitationObservable) => {\n dispatch({ status: Invitation.State.CONNECTING, observable });\n }, []);\n\n const authenticate = useCallback(\n (authCode: string) => {\n log('authenticating...', { authCode });\n return (state.observable as AuthenticatingInvitationObservable).authenticate(authCode);\n },\n [state.observable],\n );\n\n const cancel = useCallback(async () => state.observable?.cancel(), [state.observable]);\n\n return useMemo(() => {\n const invitation = state.observable?.get();\n const result = {\n status: state.status,\n haltedAt: state.haltedAt,\n result: state.result,\n error: state.error,\n cancel,\n connect,\n authenticate,\n id: invitation?.invitationId,\n invitationCode: invitation ? InvitationEncoder.encode(invitation) : undefined,\n authCode: invitation?.authCode,\n authMethod: invitation?.authMethod,\n type: invitation?.type,\n };\n\n return result;\n }, [state, cancel, connect, authenticate]);\n};\n"],
5
- "mappings": ";AAKA,SACEA,oCACAC,iCACAC,qBAAAA,oBACAC,cAAAA,aAEAC,wBACK;;;ACRP,SAASC,YAA0BC,SAASC,aAAaC,iBAAiB;AAG1E,SAGEC,YACAC,yBACK;AACP,SAASC,WAAW;;AA8Db,IAAMC,sBAAsB,CAACC,sBAAAA;AAClC,QAAM,CAACC,OAAOC,QAAAA,IAAYV,WACxB,CAACW,MAAMC,WAAAA;AACLN,QAAI,uBAAuB;MAAEM;IAAO,GAAA;;;;;;AACpC,WAAO;MACL,GAAGD;;MAEHE,QAAQD,OAAOC;;MAEfC,QAAQF,OAAOC,WAAWT,WAAWW,MAAMC,UAAUJ,OAAOE,SAASH,KAAKG;;MAE1E,GAAIF,OAAOC,WAAWT,WAAWW,MAAME,SAAS;QAAEC,OAAON,OAAOM;MAAM;;MAEtE,IAAKN,OAAOC,WAAWT,WAAWW,MAAME,SACtCL,OAAOC,WAAWT,WAAWW,MAAMI,aACnCP,OAAOC,WAAWT,WAAWW,MAAMK,YAAY;QAC/CC,UAAU,OAAOV,KAAKU,aAAa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AC/B,MAAMa;IAAYb,MAAMI;GAAO;AAInC,QAAM4B,UAAUvC,YAAY,CAACoB,eAAAA;AAC3BZ,aAAS;MAAEG,QAAQT,WAAWW,MAAMQ;MAAYD;IAAW,CAAA;EAC7D,GAAG,CAAA,CAAE;AAEL,QAAMoB,eAAexC,YACnB,CAACyC,aAAAA;AACCrC,QAAI,qBAAqB;MAAEqC;IAAS,GAAA;;;;;;AACpC,WAAQlC,MAAMa,WAAkDoB,aAAaC,QAAAA;EAC/E,GACA;IAAClC,MAAMa;GAAW;AAGpB,QAAMsB,SAAS1C,YAAY,YAAYO,MAAMa,YAAYsB,OAAAA,GAAU;IAACnC,MAAMa;GAAW;AAErF,SAAOrB,QAAQ,MAAA;AACb,UAAM8B,aAAatB,MAAMa,YAAYiB,IAAAA;AACrC,UAAMzB,SAAS;MACbD,QAAQJ,MAAMI;MACdQ,UAAUZ,MAAMY;MAChBP,QAAQL,MAAMK;MACdI,OAAOT,MAAMS;MACb0B;MACAH;MACAC;MACAG,IAAId,YAAYe;MAChBC,gBAAgBhB,aAAa1B,kBAAkB2C,OAAOjB,UAAAA,IAAckB;MACpEN,UAAUZ,YAAYY;MACtBO,YAAYnB,YAAYmB;MACxBC,MAAMpB,YAAYoB;IACpB;AAEA,WAAOrC;EACT,GAAG;IAACL;IAAOmC;IAAQH;IAASC;GAAa;AAC3C;",
6
- "names": ["AuthenticatingInvitationObservable", "CancellableInvitationObservable", "InvitationEncoder", "Invitation", "InvitationsProxy", "useReducer", "useMemo", "useCallback", "useEffect", "Invitation", "InvitationEncoder", "log", "useInvitationStatus", "initialObservable", "state", "dispatch", "prev", "action", "status", "result", "State", "SUCCESS", "ERROR", "error", "CANCELLED", "TIMEOUT", "haltedAt", "observable", "CONNECTING", "_arg", "INIT", "spaceKey", "identityKey", "swarmKey", "target", "update", "invitation", "CONNECTED", "READY_FOR_AUTHENTICATION", "AUTHENTICATING", "subscription", "subscribe", "err", "currentState", "get", "unsubscribe", "connect", "authenticate", "authCode", "cancel", "id", "invitationId", "invitationCode", "encode", "undefined", "authMethod", "type"]
7
- }