@dxos/react-client 0.8.4-main.84f28bd → 0.8.4-main.8baae0fced

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 (399) hide show
  1. package/.storybook/main.mts +9 -0
  2. package/.storybook/preview.mts +8 -0
  3. package/LICENSE +102 -5
  4. package/README.md +1 -1
  5. package/dist/lib/browser/chunk-3LVU7RNK.mjs +16 -0
  6. package/dist/lib/browser/chunk-3LVU7RNK.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-CZMIVAGI.mjs +8 -0
  8. package/dist/lib/browser/chunk-CZMIVAGI.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-XT352YI6.mjs +134 -0
  10. package/dist/lib/browser/chunk-XT352YI6.mjs.map +7 -0
  11. package/dist/lib/browser/{chunk-O5SEVDJG.mjs → chunk-YHE6WD44.mjs} +5 -15
  12. package/dist/lib/browser/chunk-YHE6WD44.mjs.map +7 -0
  13. package/dist/lib/browser/devtools/index.mjs +4 -8
  14. package/dist/lib/browser/devtools/index.mjs.map +3 -3
  15. package/dist/lib/browser/echo/index.mjs +54 -175
  16. package/dist/lib/browser/echo/index.mjs.map +4 -4
  17. package/dist/lib/browser/halo/index.mjs +5 -3
  18. package/dist/lib/browser/halo/index.mjs.map +3 -3
  19. package/dist/lib/browser/index.mjs +99 -12
  20. package/dist/lib/browser/index.mjs.map +4 -4
  21. package/dist/lib/browser/invitations/index.mjs +1 -1
  22. package/dist/lib/browser/mesh/index.mjs +2 -1
  23. package/dist/lib/browser/mesh/index.mjs.map +1 -1
  24. package/dist/lib/browser/meta.json +1 -1
  25. package/dist/lib/browser/testing/index.mjs +112 -155
  26. package/dist/lib/browser/testing/index.mjs.map +3 -3
  27. package/dist/lib/node-esm/chunk-CUDKNAMV.mjs +17 -0
  28. package/dist/lib/node-esm/chunk-CUDKNAMV.mjs.map +7 -0
  29. package/dist/lib/node-esm/{chunk-TU2JJLZK.mjs → chunk-RQJPEHDY.mjs} +5 -15
  30. package/dist/lib/node-esm/chunk-RQJPEHDY.mjs.map +7 -0
  31. package/dist/lib/node-esm/chunk-WL3Z5HOH.mjs +135 -0
  32. package/dist/lib/node-esm/chunk-WL3Z5HOH.mjs.map +7 -0
  33. package/dist/lib/node-esm/chunk-WUTK2IJF.mjs +10 -0
  34. package/dist/lib/node-esm/chunk-WUTK2IJF.mjs.map +7 -0
  35. package/dist/lib/node-esm/devtools/index.mjs +4 -8
  36. package/dist/lib/node-esm/devtools/index.mjs.map +3 -3
  37. package/dist/lib/node-esm/echo/index.mjs +54 -175
  38. package/dist/lib/node-esm/echo/index.mjs.map +4 -4
  39. package/dist/lib/node-esm/halo/index.mjs +5 -3
  40. package/dist/lib/node-esm/halo/index.mjs.map +3 -3
  41. package/dist/lib/node-esm/index.mjs +99 -12
  42. package/dist/lib/node-esm/index.mjs.map +4 -4
  43. package/dist/lib/node-esm/invitations/index.mjs +1 -1
  44. package/dist/lib/node-esm/mesh/index.mjs +2 -1
  45. package/dist/lib/node-esm/mesh/index.mjs.map +1 -1
  46. package/dist/lib/node-esm/meta.json +1 -1
  47. package/dist/lib/node-esm/testing/index.mjs +112 -155
  48. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  49. package/dist/types/src/banner.d.ts.map +1 -1
  50. package/dist/types/src/client/AgentHostingProvider.d.ts.map +1 -1
  51. package/dist/types/src/client/ClientProvider.d.ts +1 -11
  52. package/dist/types/src/client/ClientProvider.d.ts.map +1 -1
  53. package/dist/types/src/client/useClientStatus.d.ts.map +1 -1
  54. package/dist/types/src/devtools/useStream.d.ts.map +1 -1
  55. package/dist/types/src/echo/index.d.ts +2 -3
  56. package/dist/types/src/echo/index.d.ts.map +1 -1
  57. package/dist/types/src/echo/useMembers.d.ts +2 -2
  58. package/dist/types/src/echo/useMembers.d.ts.map +1 -1
  59. package/dist/types/src/echo/useSpaceInvitations.d.ts +3 -2
  60. package/dist/types/src/echo/useSpaceInvitations.d.ts.map +1 -1
  61. package/dist/types/src/echo/useSpaceProperties.d.ts +13 -0
  62. package/dist/types/src/echo/useSpaceProperties.d.ts.map +1 -0
  63. package/dist/types/src/echo/useSpaces.d.ts +19 -8
  64. package/dist/types/src/echo/useSpaces.d.ts.map +1 -1
  65. package/dist/types/src/echo/useSubscription.d.ts +1 -1
  66. package/dist/types/src/echo/useSubscription.d.ts.map +1 -1
  67. package/dist/types/src/echo/useSyncState.d.ts +1 -1
  68. package/dist/types/src/echo/useSyncState.d.ts.map +1 -1
  69. package/dist/types/src/halo/Passkey.stories.d.ts +5 -5
  70. package/dist/types/src/halo/Passkey.stories.d.ts.map +1 -1
  71. package/dist/types/src/halo/useHaloInvitations.d.ts.map +1 -1
  72. package/dist/types/src/halo/useKeyStore.d.ts.map +1 -1
  73. package/dist/types/src/invitations/useInvitationStatus.d.ts +1 -1
  74. package/dist/types/src/invitations/useInvitationStatus.d.ts.map +1 -1
  75. package/dist/types/src/testing/ClientRepeater.d.ts +6 -5
  76. package/dist/types/src/testing/ClientRepeater.d.ts.map +1 -1
  77. package/dist/types/src/testing/ClientRepeater.stories.d.ts +6 -10
  78. package/dist/types/src/testing/ClientRepeater.stories.d.ts.map +1 -1
  79. package/dist/types/src/testing/context.d.ts +4 -1
  80. package/dist/types/src/testing/context.d.ts.map +1 -1
  81. package/dist/types/src/testing/util.d.ts.map +1 -1
  82. package/dist/types/src/testing/withClientProvider.d.ts +6 -10
  83. package/dist/types/src/testing/withClientProvider.d.ts.map +1 -1
  84. package/dist/types/src/testing/withClientProvider.stories.d.ts +8 -9
  85. package/dist/types/src/testing/withClientProvider.stories.d.ts.map +1 -1
  86. package/dist/types/tsconfig.tsbuildinfo +1 -1
  87. package/docs/README.md +38 -38
  88. package/moon.yml +3 -2
  89. package/package.json +46 -59
  90. package/src/client/AgentHostingProvider.tsx +1 -1
  91. package/src/client/ClientProvider.test.tsx +2 -2
  92. package/src/client/ClientProvider.tsx +32 -50
  93. package/src/client/useConfig.test.tsx +1 -1
  94. package/src/devtools/useStream.ts +1 -1
  95. package/src/echo/index.ts +2 -3
  96. package/src/echo/useMembers.ts +5 -3
  97. package/src/echo/useSpaceInvitations.ts +10 -5
  98. package/src/echo/useSpaceProperties.ts +28 -0
  99. package/src/echo/useSpaces.test.tsx +8 -14
  100. package/src/echo/useSpaces.ts +32 -29
  101. package/src/echo/useSubscription.ts +1 -1
  102. package/src/echo/useSyncState.ts +4 -8
  103. package/src/halo/Passkey.stories.tsx +20 -20
  104. package/src/halo/useDevices.test.tsx +1 -1
  105. package/src/halo/useHaloInvitations.ts +1 -1
  106. package/src/invitations/useInvitationStatus.ts +9 -8
  107. package/src/testing/ClientRepeater.stories.tsx +22 -16
  108. package/src/testing/ClientRepeater.tsx +29 -37
  109. package/src/testing/context.tsx +4 -2
  110. package/src/testing/util.tsx +0 -1
  111. package/src/testing/withClientProvider.stories.tsx +34 -20
  112. package/src/testing/withClientProvider.tsx +77 -93
  113. package/tsconfig.json +7 -4
  114. package/typedoc.json +1 -1
  115. package/vitest.config.ts +10 -16
  116. package/.eslintrc.cjs +0 -12
  117. package/.swc/plugins/v7_linux_x86_64_13.0.0/f45bdff002284d9e8f9ef3f0be909de12da36c049cbcf261ac78fc00abb09a2d +0 -0
  118. package/dist/lib/browser/chunk-AAR7V3KL.mjs +0 -312
  119. package/dist/lib/browser/chunk-AAR7V3KL.mjs.map +0 -7
  120. package/dist/lib/browser/chunk-O5SEVDJG.mjs.map +0 -7
  121. package/dist/lib/node-esm/chunk-TU2JJLZK.mjs.map +0 -7
  122. package/dist/lib/node-esm/chunk-ZTD6HPV2.mjs +0 -314
  123. package/dist/lib/node-esm/chunk-ZTD6HPV2.mjs.map +0 -7
  124. package/dist/types/src/echo/useQuery.d.ts +0 -11
  125. package/dist/types/src/echo/useQuery.d.ts.map +0 -1
  126. package/dist/types/src/echo/useQuery.test.d.ts +0 -2
  127. package/dist/types/src/echo/useQuery.test.d.ts.map +0 -1
  128. package/dist/types/src/echo/useQueue.d.ts +0 -11
  129. package/dist/types/src/echo/useQueue.d.ts.map +0 -1
  130. package/dist/types/src/echo/useSchema.d.ts +0 -8
  131. package/dist/types/src/echo/useSchema.d.ts.map +0 -1
  132. package/dist/types/src/playwright/playwright.config.d.ts +0 -3
  133. package/dist/types/src/playwright/playwright.config.d.ts.map +0 -1
  134. package/dist/types/src/playwright/smoke.spec.d.ts +0 -2
  135. package/dist/types/src/playwright/smoke.spec.d.ts.map +0 -1
  136. package/src/echo/useQuery.test.tsx +0 -128
  137. package/src/echo/useQuery.ts +0 -56
  138. package/src/echo/useQueue.ts +0 -74
  139. package/src/echo/useSchema.ts +0 -54
  140. package/src/playwright/playwright.config.ts +0 -17
  141. package/src/playwright/smoke.spec.ts +0 -24
  142. package/typedoc/.nojekyll +0 -1
  143. package/typedoc/assets/hierarchy.js +0 -1
  144. package/typedoc/assets/highlight.css +0 -99
  145. package/typedoc/assets/icons.js +0 -18
  146. package/typedoc/assets/icons.svg +0 -1
  147. package/typedoc/assets/main.js +0 -60
  148. package/typedoc/assets/navigation.js +0 -1
  149. package/typedoc/assets/search.js +0 -1
  150. package/typedoc/assets/style.css +0 -1640
  151. package/typedoc/classes/echo.Hypergraph.html +0 -17
  152. package/typedoc/classes/echo.PropertiesType.html +0 -19
  153. package/typedoc/classes/echo.QueryResult.html +0 -18
  154. package/typedoc/classes/halo.KeyStore.html +0 -6
  155. package/typedoc/classes/index.AgentClientServiceProvider.html +0 -10
  156. package/typedoc/classes/index.AgentManagerClient.html +0 -22
  157. package/typedoc/classes/index.AlreadyJoinedError.html +0 -15
  158. package/typedoc/classes/index.ApiError.html +0 -16
  159. package/typedoc/classes/index.CancelledError.html +0 -16
  160. package/typedoc/classes/index.Client.html +0 -51
  161. package/typedoc/classes/index.ClientServicesProxy.html +0 -12
  162. package/typedoc/classes/index.Config.html +0 -17
  163. package/typedoc/classes/index.DataCorruptionError.html +0 -16
  164. package/typedoc/classes/index.DatabaseError.html +0 -15
  165. package/typedoc/classes/index.EntityNotFoundError.html +0 -15
  166. package/typedoc/classes/index.FakeAgentHostingProvider.html +0 -7
  167. package/typedoc/classes/index.IFrameManager.html +0 -6
  168. package/typedoc/classes/index.IdentityNotInitializedError.html +0 -15
  169. package/typedoc/classes/index.InvalidConfigError.html +0 -16
  170. package/typedoc/classes/index.InvalidInvitationError.html +0 -15
  171. package/typedoc/classes/index.InvalidInvitationExtensionRoleError.html +0 -16
  172. package/typedoc/classes/index.InvalidStorageVersionError.html +0 -15
  173. package/typedoc/classes/index.LocalClientServices.html +0 -12
  174. package/typedoc/classes/index.PublicKey.html +0 -55
  175. package/typedoc/classes/index.RemoteServiceConnectionError.html +0 -15
  176. package/typedoc/classes/index.RemoteServiceConnectionTimeout.html +0 -15
  177. package/typedoc/classes/index.RpcClosedError.html +0 -15
  178. package/typedoc/classes/index.RpcNotOpenError.html +0 -15
  179. package/typedoc/classes/index.SharedWorkerConnection.html +0 -5
  180. package/typedoc/classes/index.Shell.html +0 -35
  181. package/typedoc/classes/index.ShellManager.html +0 -9
  182. package/typedoc/classes/index.SystemError.html +0 -16
  183. package/typedoc/classes/index.UnknownModelError.html +0 -15
  184. package/typedoc/classes/index.WorkerClientServices.html +0 -12
  185. package/typedoc/classes/invitations.AuthenticatingInvitationObservable.html +0 -30
  186. package/typedoc/classes/invitations.CancellableInvitationObservable.html +0 -29
  187. package/typedoc/classes/invitations.InvitationEncoder.html +0 -5
  188. package/typedoc/classes/invitations.InvitationsProxy.html +0 -12
  189. package/typedoc/enums/devtools.KeyType.html +0 -9
  190. package/typedoc/enums/echo.HaloSpaceMember.Role.html +0 -9
  191. package/typedoc/enums/echo.IndexKind.Kind.html +0 -8
  192. package/typedoc/enums/echo.QueryOptions.DataLocation.html +0 -6
  193. package/typedoc/enums/echo.QueryOptions.ShowDeletedOption.html +0 -6
  194. package/typedoc/enums/echo.SpaceMember.PresenceState.html +0 -5
  195. package/typedoc/enums/echo.SpaceState.html +0 -13
  196. package/typedoc/enums/echo.TextKind.html +0 -5
  197. package/typedoc/enums/halo.Device.PresenceState.html +0 -6
  198. package/typedoc/enums/halo.DeviceKind.html +0 -5
  199. package/typedoc/enums/halo.DeviceType.html +0 -9
  200. package/typedoc/enums/index.ShellDisplay.html +0 -5
  201. package/typedoc/enums/index.ShellLayout.html +0 -13
  202. package/typedoc/enums/index.SystemStatus.html +0 -5
  203. package/typedoc/enums/invitations.Invitation.AuthMethod.html +0 -6
  204. package/typedoc/enums/invitations.Invitation.Kind.html +0 -5
  205. package/typedoc/enums/invitations.Invitation.State.html +0 -13
  206. package/typedoc/enums/invitations.Invitation.Type.html +0 -6
  207. package/typedoc/enums/mesh.ConnectionState.html +0 -5
  208. package/typedoc/functions/devtools.useDevtools.html +0 -1
  209. package/typedoc/functions/devtools.useStream.html +0 -2
  210. package/typedoc/functions/echo.useMembers.html +0 -1
  211. package/typedoc/functions/echo.useQueue.html +0 -2
  212. package/typedoc/functions/echo.useSchema.html +0 -2
  213. package/typedoc/functions/echo.useSpace.html +0 -6
  214. package/typedoc/functions/echo.useSpaceInvitation.html +0 -1
  215. package/typedoc/functions/echo.useSpaceInvitations.html +0 -1
  216. package/typedoc/functions/echo.useSpaceSyncState.html +0 -2
  217. package/typedoc/functions/echo.useSpaces.html +0 -5
  218. package/typedoc/functions/echo.useSubscription.html +0 -3
  219. package/typedoc/functions/echo.useSyncState.html +0 -2
  220. package/typedoc/functions/halo.useContacts.html +0 -4
  221. package/typedoc/functions/halo.useCredentials.html +0 -1
  222. package/typedoc/functions/halo.useDevices.html +0 -1
  223. package/typedoc/functions/halo.useHaloInvitation.html +0 -1
  224. package/typedoc/functions/halo.useHaloInvitations.html +0 -1
  225. package/typedoc/functions/halo.useIdentity.html +0 -3
  226. package/typedoc/functions/halo.useKeyStore.html +0 -3
  227. package/typedoc/functions/index.AgentHostingProvider.html +0 -2
  228. package/typedoc/functions/index.useAgentHostingClient.html +0 -1
  229. package/typedoc/functions/index.useClient.html +0 -3
  230. package/typedoc/functions/index.useClientStatus.html +0 -1
  231. package/typedoc/functions/index.useConfig.html +0 -3
  232. package/typedoc/functions/index.useShell.html +0 -2
  233. package/typedoc/functions/index.useShellDisplay.html +0 -2
  234. package/typedoc/functions/index.useStatus.html +0 -1
  235. package/typedoc/functions/invitations.useInvitationStatus.html +0 -1
  236. package/typedoc/functions/mesh.useNetworkStatus.html +0 -2
  237. package/typedoc/hierarchy.html +0 -1
  238. package/typedoc/index.html +0 -23
  239. package/typedoc/interfaces/devtools.DevtoolsHook.html +0 -22
  240. package/typedoc/interfaces/devtools.DevtoolsHost.html +0 -26
  241. package/typedoc/interfaces/echo.DocAccessor.html +0 -3
  242. package/typedoc/interfaces/echo.Echo.html +0 -39
  243. package/typedoc/interfaces/echo.EchoDatabase.html +0 -30
  244. package/typedoc/interfaces/echo.Expando.html +0 -3
  245. package/typedoc/interfaces/echo.Filter.html +0 -3
  246. package/typedoc/interfaces/echo.HaloSpaceMember.html +0 -18
  247. package/typedoc/interfaces/echo.IDocHandle.html +0 -6
  248. package/typedoc/interfaces/echo.IndexKind.html +0 -9
  249. package/typedoc/interfaces/echo.Query.html +0 -34
  250. package/typedoc/interfaces/echo.QueryOptions.html +0 -39
  251. package/typedoc/interfaces/echo.Queue.html +0 -17
  252. package/typedoc/interfaces/echo.Ref.html +0 -32
  253. package/typedoc/interfaces/echo.Space.html +0 -36
  254. package/typedoc/interfaces/echo.SpaceMember.html +0 -7
  255. package/typedoc/interfaces/echo.SpaceSyncState.PeerState.html +0 -14
  256. package/typedoc/interfaces/echo.SpaceSyncState.html +0 -4
  257. package/typedoc/interfaces/echo.SubscriptionHandle.html +0 -5
  258. package/typedoc/interfaces/echo.TypedObject.html +0 -16
  259. package/typedoc/interfaces/halo.Contact.html +0 -10
  260. package/typedoc/interfaces/halo.Credential.html +0 -27
  261. package/typedoc/interfaces/halo.Device.html +0 -11
  262. package/typedoc/interfaces/halo.Halo.html +0 -16
  263. package/typedoc/interfaces/halo.Identity.html +0 -15
  264. package/typedoc/interfaces/index.AgentHostingProviderClient.html +0 -6
  265. package/typedoc/interfaces/index.AppContextRequest.html +0 -33
  266. package/typedoc/interfaces/index.ClientServicesProvider.html +0 -9
  267. package/typedoc/interfaces/index.InvitationUrlRequest.html +0 -9
  268. package/typedoc/interfaces/index.LayoutRequest.html +0 -29
  269. package/typedoc/interfaces/index.ShellRuntime.html +0 -15
  270. package/typedoc/interfaces/invitations.Invitation.html +0 -92
  271. package/typedoc/interfaces/invitations.Invitations.html +0 -5
  272. package/typedoc/interfaces/mesh.GossipMessage.html +0 -10
  273. package/typedoc/interfaces/mesh.NetworkStatus.Signal.html +0 -5
  274. package/typedoc/interfaces/mesh.NetworkStatus.html +0 -6
  275. package/typedoc/media/LICENSE +0 -8
  276. package/typedoc/modules/devtools.html +0 -1
  277. package/typedoc/modules/echo.Filter.html +0 -1
  278. package/typedoc/modules/echo.HaloSpaceMember.html +0 -1
  279. package/typedoc/modules/echo.IndexKind.html +0 -1
  280. package/typedoc/modules/echo.Query.html +0 -1
  281. package/typedoc/modules/echo.QueryOptions.html +0 -1
  282. package/typedoc/modules/echo.Ref.html +0 -2
  283. package/typedoc/modules/echo.SpaceMember.html +0 -1
  284. package/typedoc/modules/echo.SpaceSyncState.html +0 -1
  285. package/typedoc/modules/echo.html +0 -1
  286. package/typedoc/modules/halo.Device.html +0 -1
  287. package/typedoc/modules/halo.html +0 -1
  288. package/typedoc/modules/index.html +0 -1
  289. package/typedoc/modules/invitations.Invitation.html +0 -1
  290. package/typedoc/modules/invitations.html +0 -1
  291. package/typedoc/modules/mesh.NetworkStatus.html +0 -1
  292. package/typedoc/modules/mesh.html +0 -1
  293. package/typedoc/modules/worker.html +0 -1
  294. package/typedoc/modules.html +0 -1
  295. package/typedoc/types/devtools.MountOptions.html +0 -3
  296. package/typedoc/types/echo.AnyLiveObject.html +0 -2
  297. package/typedoc/types/echo.Filter.And.html +0 -1
  298. package/typedoc/types/echo.Filter.Any.html +0 -1
  299. package/typedoc/types/echo.Filter.Or.html +0 -1
  300. package/typedoc/types/echo.Filter.Props.html +0 -1
  301. package/typedoc/types/echo.Filter.Type.html +0 -1
  302. package/typedoc/types/echo.Live.html +0 -5
  303. package/typedoc/types/echo.ObjectMeta.html +0 -1
  304. package/typedoc/types/echo.ObjectMigration.html +0 -7
  305. package/typedoc/types/echo.ObjectVersion.html +0 -2
  306. package/typedoc/types/echo.PeerSyncState.html +0 -1
  307. package/typedoc/types/echo.Progress.html +0 -3
  308. package/typedoc/types/echo.PropertiesTypeProps.html +0 -1
  309. package/typedoc/types/echo.Query.Any.html +0 -1
  310. package/typedoc/types/echo.Query.TextSearchOptions.html +0 -2
  311. package/typedoc/types/echo.Query.Type.html +0 -1
  312. package/typedoc/types/echo.Ref.Target.html +0 -2
  313. package/typedoc/types/echo.Selection.html +0 -1
  314. package/typedoc/types/echo.SpaceId.html +0 -6
  315. package/typedoc/types/echo.SpaceSyncStateMap.html +0 -1
  316. package/typedoc/types/echo.UseQueueOptions.html +0 -2
  317. package/typedoc/types/echo.UseSpacesParams.html +0 -3
  318. package/typedoc/types/index.AgentHostingProviderProps.html +0 -3
  319. package/typedoc/types/index.ClientContextProps.html +0 -3
  320. package/typedoc/types/index.ClientOptions.html +0 -12
  321. package/typedoc/types/index.ClientProviderProps.html +0 -2
  322. package/typedoc/types/index.ClientServices.html +0 -15
  323. package/typedoc/types/index.FromAgentOptions.html +0 -2
  324. package/typedoc/types/index.PublicKeyLike.html +0 -2
  325. package/typedoc/types/invitations.InvitationAction.html +0 -1
  326. package/typedoc/types/invitations.InvitationResult.html +0 -5
  327. package/typedoc/types/invitations.InvitationStatus.html +0 -15
  328. package/typedoc/variables/devtools.mountDevtoolsHooks.html +0 -1
  329. package/typedoc/variables/devtools.unmountDevtoolsHooks.html +0 -1
  330. package/typedoc/variables/echo.DocAccessor.html +0 -1
  331. package/typedoc/variables/echo.EchoObjectSchema.html +0 -1
  332. package/typedoc/variables/echo.Expando.html +0 -1
  333. package/typedoc/variables/echo.FQ_ID_LENGTH.html +0 -1
  334. package/typedoc/variables/echo.Filter.html +0 -1
  335. package/typedoc/variables/echo.OBJECT_ID_LENGTH.html +0 -1
  336. package/typedoc/variables/echo.ObjectVersion.html +0 -1
  337. package/typedoc/variables/echo.Query.html +0 -1
  338. package/typedoc/variables/echo.Queue.html +0 -1
  339. package/typedoc/variables/echo.ReactiveObjectSchema.html +0 -1
  340. package/typedoc/variables/echo.Ref.html +0 -2
  341. package/typedoc/variables/echo.RefArray.html +0 -2
  342. package/typedoc/variables/echo.SPACE_ID_LENGTH.html +0 -1
  343. package/typedoc/variables/echo.SpaceId.html +0 -1
  344. package/typedoc/variables/echo.SpaceSchema.html +0 -1
  345. package/typedoc/variables/echo.TypedObject.html +0 -3
  346. package/typedoc/variables/echo.compareForeignKeys.html +0 -1
  347. package/typedoc/variables/echo.createDocAccessor.html +0 -1
  348. package/typedoc/variables/echo.createEmptyEdgeSyncState.html +0 -1
  349. package/typedoc/variables/echo.createObject.html +0 -1
  350. package/typedoc/variables/echo.createQueueDXN.html +0 -2
  351. package/typedoc/variables/echo.createSubscription.html +0 -5
  352. package/typedoc/variables/echo.defineObjectMigration.html +0 -1
  353. package/typedoc/variables/echo.fromCursor.html +0 -1
  354. package/typedoc/variables/echo.fullyQualifiedId.html +0 -4
  355. package/typedoc/variables/echo.getMeta.html +0 -1
  356. package/typedoc/variables/echo.getObjectCore.html +0 -1
  357. package/typedoc/variables/echo.getRangeFromCursor.html +0 -1
  358. package/typedoc/variables/echo.getSchema.html +0 -2
  359. package/typedoc/variables/echo.getSource.html +0 -4
  360. package/typedoc/variables/echo.getSpace.html +0 -1
  361. package/typedoc/variables/echo.getSyncSummary.html +0 -1
  362. package/typedoc/variables/echo.getTarget.html +0 -4
  363. package/typedoc/variables/echo.getTextInRange.html +0 -2
  364. package/typedoc/variables/echo.getType.html +0 -5
  365. package/typedoc/variables/echo.getTypename.html +0 -6
  366. package/typedoc/variables/echo.getVersion.html +0 -3
  367. package/typedoc/variables/echo.importSpace.html +0 -1
  368. package/typedoc/variables/echo.internalDecodeReference.html +0 -2
  369. package/typedoc/variables/echo.isEchoObject.html +0 -2
  370. package/typedoc/variables/echo.isLiveObject.html +0 -3
  371. package/typedoc/variables/echo.isRelation.html +0 -2
  372. package/typedoc/variables/echo.isSpace.html +0 -1
  373. package/typedoc/variables/echo.live.html +0 -3
  374. package/typedoc/variables/echo.loadObjectReferences.html +0 -7
  375. package/typedoc/variables/echo.parseFullyQualifiedId.html +0 -2
  376. package/typedoc/variables/echo.parseId.html +0 -1
  377. package/typedoc/variables/echo.toCursor.html +0 -1
  378. package/typedoc/variables/echo.toCursorRange.html +0 -1
  379. package/typedoc/variables/echo.updateText.html +0 -6
  380. package/typedoc/variables/echo.useQuery.html +0 -2
  381. package/typedoc/variables/index.AgentHostingContext.html +0 -1
  382. package/typedoc/variables/index.ClientProvider.html +0 -3
  383. package/typedoc/variables/index.DXOS_VERSION.html +0 -1
  384. package/typedoc/variables/index.Defaults.html +0 -2
  385. package/typedoc/variables/index.Dynamics.html +0 -2
  386. package/typedoc/variables/index.Envs.html +0 -2
  387. package/typedoc/variables/index.Local.html +0 -2
  388. package/typedoc/variables/index.Remote.html +0 -1
  389. package/typedoc/variables/index.Storage.html +0 -2
  390. package/typedoc/variables/index.createClientServices.html +0 -4
  391. package/typedoc/variables/index.fromAgent.html +0 -2
  392. package/typedoc/variables/index.fromHost.html +0 -2
  393. package/typedoc/variables/index.fromSocket.html +0 -2
  394. package/typedoc/variables/index.fromWorker.html +0 -2
  395. package/typedoc/variables/index.getUnixSocket.html +0 -1
  396. package/typedoc/variables/index.resolveRef.html +0 -1
  397. package/typedoc/variables/index.useMulticastObservable.html +0 -3
  398. package/typedoc/variables/worker.getWorkerServiceHost.html +0 -1
  399. package/typedoc/variables/worker.onconnect.html +0 -1
@@ -1,46 +1,42 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
  import {
3
3
  useInvitationStatus
4
- } from "../chunk-TU2JJLZK.mjs";
4
+ } from "../chunk-RQJPEHDY.mjs";
5
5
  import {
6
6
  useClient
7
- } from "../chunk-ZTD6HPV2.mjs";
7
+ } from "../chunk-CUDKNAMV.mjs";
8
+ import "../chunk-WUTK2IJF.mjs";
8
9
 
9
10
  // src/echo/index.ts
10
11
  export * from "@dxos/client/echo";
12
+ export * from "@dxos/echo-react";
11
13
 
12
14
  // src/echo/useMembers.ts
13
15
  import { MulticastObservable } from "@dxos/async";
16
+ import { PublicKey as PublicKey2 } from "@dxos/client";
14
17
  import { HaloSpaceMember } from "@dxos/client/echo";
15
18
  import { useMulticastObservable as useMulticastObservable2 } from "@dxos/react-hooks";
16
19
 
17
20
  // src/echo/useSpaces.ts
18
- import { useEffect, useState } from "react";
21
+ import { PublicKey } from "@dxos/client";
19
22
  import { SpaceState } from "@dxos/client/echo";
20
23
  import { useMulticastObservable } from "@dxos/react-hooks";
21
- var useSpace = (spaceKeyLike) => {
24
+ var useSpace = (spaceId) => {
22
25
  const client = useClient();
23
26
  const spaces = useMulticastObservable(client.spaces);
24
- const [ready, setReady] = useState(false);
25
- useEffect(() => {
26
- if (spaceKeyLike) {
27
- return;
28
- }
29
- const timeout = setTimeout(async () => {
30
- await client.spaces.waitUntilReady();
31
- setReady(true);
32
- });
33
- return () => clearTimeout(timeout);
34
- }, [
35
- client,
36
- spaceKeyLike
37
- ]);
38
- if (spaceKeyLike) {
39
- return spaces.find((space) => space.key.equals(spaceKeyLike) || space.id === spaceKeyLike);
40
- }
41
- if (ready && client.halo.identity.get()) {
42
- return client.spaces.default;
27
+ if (!spaceId) {
28
+ return void 0;
43
29
  }
30
+ return spaces.find((space) => {
31
+ if (spaceId instanceof PublicKey) {
32
+ return space.key.equals(spaceId);
33
+ }
34
+ return space.id === spaceId;
35
+ });
36
+ };
37
+ var useDatabase = (spaceId) => {
38
+ const space = useSpace(spaceId);
39
+ return space?.db;
44
40
  };
45
41
  var useSpaces = ({ all = false } = {}) => {
46
42
  const client = useClient();
@@ -53,156 +49,47 @@ var useMembers = (spaceKey) => {
53
49
  const spaces = useSpaces({
54
50
  all: true
55
51
  });
56
- const space = spaceKey ? spaces.find((space2) => space2.key.equals(spaceKey)) : void 0;
52
+ const space = spaceKey ? spaces.find((space2) => spaceKey instanceof PublicKey2 ? space2.key.equals(spaceKey) : space2.id === spaceKey) : void 0;
57
53
  const members = useMulticastObservable2(space?.members ?? MulticastObservable.empty()) ?? [];
58
54
  return members.filter((member) => member.role !== HaloSpaceMember.Role.REMOVED);
59
55
  };
60
56
 
61
- // src/echo/useQuery.ts
62
- import { useMemo, useSyncExternalStore } from "react";
63
- import { Filter, Query, isSpace } from "@dxos/client/echo";
64
- var EMPTY_ARRAY = [];
65
- var noop = () => {
66
- };
67
- var useQuery = (spaceOrEcho, queryOrFilter, deps) => {
68
- const query = Filter.is(queryOrFilter) ? Query.select(queryOrFilter) : queryOrFilter;
69
- const { getObjects, subscribe } = useMemo(() => {
70
- let subscribed = false;
71
- const queryResult = spaceOrEcho === void 0 ? void 0 : isSpace(spaceOrEcho) ? spaceOrEcho.db.query(query) : spaceOrEcho.query(query);
72
- return {
73
- getObjects: () => subscribed && queryResult ? queryResult.objects : EMPTY_ARRAY,
74
- subscribe: (cb) => {
75
- subscribed = true;
76
- const unsubscribe = queryResult?.subscribe(cb) ?? noop;
77
- return () => {
78
- unsubscribe?.();
79
- subscribed = false;
80
- };
81
- }
82
- };
83
- }, [
84
- spaceOrEcho,
85
- JSON.stringify(query.ast),
86
- ...deps ?? []
87
- ]);
88
- const objects = useSyncExternalStore(subscribe, getObjects);
89
- return objects ?? [];
90
- };
91
-
92
- // src/echo/useQueue.ts
93
- import { useEffect as useEffect2, useMemo as useMemo2, useRef } from "react";
94
- import { raise } from "@dxos/debug";
95
- var MIN_POLL_INTERVAL = 1e3;
96
- var useQueue = (queueDxn, options = {}) => {
97
- const client = useClient();
98
- const mountedRef = useRef(true);
99
- const queue = useMemo2(() => {
100
- if (!queueDxn) {
101
- return void 0;
102
- }
103
- const { spaceId } = queueDxn.asQueueDXN() ?? raise(new TypeError("Invalid queue DXN"));
104
- return client.spaces.get(spaceId)?.queues.get(queueDxn);
105
- }, [
106
- client,
107
- queueDxn?.toString()
108
- ]);
109
- useEffect2(() => {
110
- void queue?.refresh();
111
- }, [
112
- queue
113
- ]);
114
- useEffect2(() => {
115
- let timeout;
116
- mountedRef.current = true;
117
- const poll = () => {
118
- if (!mountedRef.current) {
119
- return;
120
- }
121
- void queue?.refresh().finally(() => {
122
- if (mountedRef.current && options.pollInterval) {
123
- timeout = setTimeout(poll, Math.max(options.pollInterval ?? 0, MIN_POLL_INTERVAL));
124
- }
125
- });
126
- };
127
- if (options.pollInterval) {
128
- poll();
129
- }
130
- return () => {
131
- mountedRef.current = false;
132
- clearTimeout(timeout);
133
- };
134
- }, [
135
- queue,
136
- options.pollInterval
137
- ]);
138
- return queue;
139
- };
140
-
141
- // src/echo/useSchema.ts
142
- import { useMemo as useMemo3, useSyncExternalStore as useSyncExternalStore2 } from "react";
143
- var useSchema = (client, space, typename) => {
144
- const { subscribe, getSchema } = useMemo3(() => {
145
- if (!typename || !space) {
146
- return {
147
- subscribe: () => () => {
148
- },
149
- getSchema: () => void 0
150
- };
151
- }
152
- const staticSchema = client.graph.schemaRegistry.getSchema(typename);
153
- if (staticSchema) {
154
- return {
155
- subscribe: () => () => {
156
- },
157
- getSchema: () => staticSchema
158
- };
159
- }
160
- const query = space.db.schemaRegistry.query({
161
- typename
162
- });
163
- const initialResult = query.runSync()[0];
164
- let currentSchema = initialResult;
165
- return {
166
- subscribe: (onStoreChange) => {
167
- const unsubscribe = query.subscribe(() => {
168
- currentSchema = query.results[0];
169
- onStoreChange();
170
- });
171
- return unsubscribe;
172
- },
173
- getSchema: () => currentSchema
174
- };
175
- }, [
176
- typename,
177
- space
178
- ]);
179
- return useSyncExternalStore2(subscribe, getSchema);
180
- };
181
-
182
57
  // src/echo/useSpaceInvitations.ts
183
- import { useMemo as useMemo4 } from "react";
58
+ import { useMemo } from "react";
184
59
  import { MulticastObservable as MulticastObservable2 } from "@dxos/async";
185
60
  import { useMulticastObservable as useMulticastObservable3 } from "@dxos/react-hooks";
186
- var useSpaceInvitations = (spaceKey) => {
187
- const space = useSpace(spaceKey);
61
+ var useSpaceInvitations = (spaceId) => {
62
+ const space = useSpace(spaceId);
188
63
  return useMulticastObservable3(space?.invitations ?? MulticastObservable2.empty()) ?? [];
189
64
  };
190
- var useSpaceInvitation = (spaceKey, invitationId) => {
191
- const invitations = useSpaceInvitations(spaceKey);
192
- const invitation = useMemo4(() => invitations.find((invitation2) => invitation2.get().invitationId === invitationId), [
65
+ var useSpaceInvitation = (spaceId, invitationId) => {
66
+ const invitations = useSpaceInvitations(spaceId);
67
+ const invitation = useMemo(() => invitations.find((invitation2) => invitation2.get().invitationId === invitationId), [
193
68
  invitations
194
69
  ]);
195
70
  return useInvitationStatus(invitation);
196
71
  };
197
72
 
73
+ // src/echo/useSpaceProperties.ts
74
+ import { MulticastObservable as MulticastObservable3 } from "@dxos/async";
75
+ import { SpaceState as SpaceState2 } from "@dxos/client/echo";
76
+ import { useObject } from "@dxos/echo-react";
77
+ import { useMulticastObservable as useMulticastObservable4 } from "@dxos/react-hooks";
78
+ var useSpaceProperties = (spaceId) => {
79
+ const space = useSpace(spaceId);
80
+ const spaceState = useMulticastObservable4(space?.state ?? MulticastObservable3.empty());
81
+ const properties = spaceState === SpaceState2.SPACE_READY ? space?.properties : void 0;
82
+ return useObject(properties);
83
+ };
84
+
198
85
  // src/echo/useSubscription.ts
199
- import { useEffect as useEffect3, useRef as useRef2 } from "react";
86
+ import { useEffect, useRef } from "react";
200
87
  import { createSubscription } from "@dxos/client/echo";
201
88
  var useSubscription = (cb, selection) => {
202
- const callbackRef = useRef2(cb);
89
+ const callbackRef = useRef(cb);
203
90
  callbackRef.current = cb;
204
- const subscriptionRef = useRef2();
205
- useEffect3(() => {
91
+ const subscriptionRef = useRef(null);
92
+ useEffect(() => {
206
93
  subscriptionRef.current = createSubscription(() => {
207
94
  callbackRef.current();
208
95
  });
@@ -213,25 +100,21 @@ var useSubscription = (cb, selection) => {
213
100
  };
214
101
 
215
102
  // src/echo/useSyncState.ts
216
- import { useEffect as useEffect4, useState as useState2 } from "react";
103
+ import { useEffect as useEffect2, useState } from "react";
217
104
  import { Context } from "@dxos/context";
218
- import { EdgeService } from "@dxos/protocols";
105
+ import { isEdgePeerId } from "@dxos/echo-protocol";
219
106
  var __dxlog_file = "/__w/dxos/dxos/packages/sdk/react-client/src/echo/useSyncState.ts";
220
- var isEdgePeerId = (peerId, spaceId) => peerId.startsWith(`${EdgeService.AUTOMERGE_REPLICATOR}:${spaceId}`);
221
107
  var useSyncState = () => {
222
108
  const client = useClient();
223
- const [spaceState, setSpaceState] = useState2({});
224
- useEffect4(() => {
225
- const ctx = new Context(void 0, {
226
- F: __dxlog_file,
227
- L: 25
228
- });
109
+ const [spaceState, setSpaceState] = useState({});
110
+ useEffect2(() => {
111
+ const ctx = new Context(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 14 });
229
112
  const createSubscriptions = (spaces) => {
230
113
  for (const space of spaces) {
231
114
  if (spaceState[space.id]) {
232
115
  continue;
233
116
  }
234
- ctx.onDispose(space.db.subscribeToSyncState(ctx, ({ peers = [] }) => {
117
+ ctx.onDispose(space.internal.db.subscribeToSyncState(ctx, ({ peers = [] }) => {
235
118
  const syncState = peers.find((state) => isEdgePeerId(state.peerId, space.id));
236
119
  if (syncState) {
237
120
  setSpaceState((spaceState2) => ({
@@ -255,13 +138,10 @@ var useSyncState = () => {
255
138
  return spaceState;
256
139
  };
257
140
  var useSpaceSyncState = (space) => {
258
- const [spaceState, setSpaceState] = useState2();
259
- useEffect4(() => {
260
- const ctx = new Context(void 0, {
261
- F: __dxlog_file,
262
- L: 64
263
- });
264
- space.db.subscribeToSyncState(ctx, ({ peers = [] }) => {
141
+ const [spaceState, setSpaceState] = useState();
142
+ useEffect2(() => {
143
+ const ctx = new Context(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 49 });
144
+ space.internal.db.subscribeToSyncState(ctx, ({ peers = [] }) => {
265
145
  const syncState = peers.find((state) => isEdgePeerId(state.peerId, space.id));
266
146
  if (syncState) {
267
147
  setSpaceState(syncState);
@@ -276,13 +156,12 @@ var useSpaceSyncState = (space) => {
276
156
  return spaceState;
277
157
  };
278
158
  export {
159
+ useDatabase,
279
160
  useMembers,
280
- useQuery,
281
- useQueue,
282
- useSchema,
283
161
  useSpace,
284
162
  useSpaceInvitation,
285
163
  useSpaceInvitations,
164
+ useSpaceProperties,
286
165
  useSpaceSyncState,
287
166
  useSpaces,
288
167
  useSubscription,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../../src/echo/index.ts", "../../../../src/echo/useMembers.ts", "../../../../src/echo/useSpaces.ts", "../../../../src/echo/useQuery.ts", "../../../../src/echo/useQueue.ts", "../../../../src/echo/useSchema.ts", "../../../../src/echo/useSpaceInvitations.ts", "../../../../src/echo/useSubscription.ts", "../../../../src/echo/useSyncState.ts"],
4
- "sourcesContent": ["//\n// Copyright 2020 DXOS.org\n//\n\nexport * from '@dxos/client/echo';\n\nexport * from './useMembers';\nexport * from './useQuery';\nexport * from './useQueue';\nexport * from './useSchema';\nexport * from './useSpaces';\nexport * from './useSpaceInvitations';\nexport * from './useSubscription';\nexport * from './useSyncState';\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { MulticastObservable } from '@dxos/async';\nimport { type PublicKey } from '@dxos/client';\nimport { HaloSpaceMember, type SpaceMember } from '@dxos/client/echo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useSpaces } from './useSpaces';\n\nexport const useMembers = (spaceKey: PublicKey | undefined): SpaceMember[] => {\n // TODO(dmaretskyi): useSpace hook for spaces that are not ready.\n const spaces = useSpaces({ all: true });\n const space = spaceKey ? spaces.find((space) => space.key.equals(spaceKey)) : undefined;\n\n // EMPTY_OBSERVABLE needs to be a stable reference to avoid re-subscribing on every render.\n const members = useMulticastObservable(space?.members ?? MulticastObservable.empty()) ?? [];\n return members.filter((member) => member.role !== HaloSpaceMember.Role.REMOVED);\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { useEffect, useState } from 'react';\n\nimport { type PublicKeyLike } from '@dxos/client';\nimport { type Space, SpaceState } from '@dxos/client/echo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\n\n/**\n * Get a specific Space using its key.\n * The space is not guaranteed to be in the ready state.\n * Returns the default space if no key is provided.\n * Requires a ClientProvider somewhere in the parent tree.\n *\n * @param spaceKeyLike the key of the space to look for\n */\nexport const useSpace = (spaceKeyLike?: PublicKeyLike): Space | undefined => {\n const client = useClient();\n const spaces = useMulticastObservable<Space[]>(client.spaces);\n const [ready, setReady] = useState(false);\n\n useEffect(() => {\n // Only wait for ready if looking for the default space.\n if (spaceKeyLike) {\n return;\n }\n\n const timeout = setTimeout(async () => {\n await client.spaces.waitUntilReady();\n setReady(true);\n });\n\n return () => clearTimeout(timeout);\n }, [client, spaceKeyLike]);\n\n if (spaceKeyLike) {\n return spaces.find((space) => space.key.equals(spaceKeyLike) || space.id === spaceKeyLike);\n }\n\n if (ready && client.halo.identity.get()) {\n return client.spaces.default;\n }\n};\n\nexport type UseSpacesParams = {\n /**\n * Return uninitialized spaces as well.\n */\n all?: boolean;\n};\n\n/**\n * Get all Spaces available to current user.\n * Requires a ClientProvider somewhere in the parent tree.\n * By default, only ready spaces are returned.\n * @returns an array of Spaces\n */\nexport const useSpaces = ({ all = false }: UseSpacesParams = {}): Space[] => {\n const client = useClient();\n const spaces = useMulticastObservable<Space[]>(client.spaces);\n\n // TODO(dmaretskyi): Array reference equality.\n return spaces.filter((space) => all || space.state.get() === SpaceState.SPACE_READY);\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { useMemo, useSyncExternalStore } from 'react';\n\nimport { type Echo, Filter, type Live, Query, type Space, isSpace } from '@dxos/client/echo';\n\nconst EMPTY_ARRAY: never[] = [];\n\nconst noop = () => {};\n\n// TODO(dmaretskyi): Queries are fully serializable, so we can remove `deps` argument.\ninterface UseQueryFn {\n <Q extends Query.Any>(spaceOrEcho: Space | Echo | undefined, query: Q, deps?: any[]): Live<Query.Type<Q>>[];\n\n <F extends Filter.Any>(spaceOrEcho: Space | Echo | undefined, filter: F, deps?: any[]): Live<Filter.Type<F>>[];\n}\n\n/**\n * Create subscription.\n */\nexport const useQuery: UseQueryFn = (\n spaceOrEcho: Space | Echo | undefined,\n queryOrFilter: Query.Any | Filter.Any,\n deps?: any[],\n): Live<unknown>[] => {\n const query = Filter.is(queryOrFilter) ? Query.select(queryOrFilter) : queryOrFilter;\n\n const { getObjects, subscribe } = useMemo(() => {\n let subscribed = false;\n const queryResult =\n spaceOrEcho === undefined\n ? undefined\n : isSpace(spaceOrEcho)\n ? spaceOrEcho.db.query(query)\n : spaceOrEcho.query(query);\n\n return {\n getObjects: () => (subscribed && queryResult ? queryResult.objects : EMPTY_ARRAY),\n subscribe: (cb: () => void) => {\n subscribed = true;\n const unsubscribe = queryResult?.subscribe(cb) ?? noop;\n return () => {\n unsubscribe?.();\n subscribed = false;\n };\n },\n };\n }, [spaceOrEcho, JSON.stringify(query.ast), ...(deps ?? [])]);\n\n // https://beta.reactjs.org/reference/react/useSyncExternalStore\n // NOTE: This hook will resubscribe whenever the callback passed to the first argument changes; make sure it is stable.\n const objects = useSyncExternalStore<Live<unknown>[] | undefined>(subscribe, getObjects);\n return objects ?? [];\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useEffect, useMemo, useRef } from 'react';\n\nimport { type Queue } from '@dxos/client/echo';\nimport { raise } from '@dxos/debug';\nimport { type Obj, type Relation } from '@dxos/echo';\nimport { type DXN } from '@dxos/keys';\n\nimport { useClient } from '../client';\n\nconst MIN_POLL_INTERVAL = 1_000;\n\nexport type UseQueueOptions = {\n pollInterval?: number;\n};\n\n/**\n * Polls the given Edge queue.\n */\n// TODO(burdon): Replace polling with socket?\n// TODO(dmaretskyi): Move into client package.\n// TODO(dmaretskyi): Consider passing the space into the hook to support queue DXNs without space id.\n// TODO(ZaymonFC): If queue is unchanged returned object should be refferentially stable on poll.\nexport const useQueue = <T extends Obj.Any | Relation.Any>(\n queueDxn?: DXN,\n options: UseQueueOptions = {},\n): Queue<T> | undefined => {\n const client = useClient();\n const mountedRef = useRef(true);\n\n const queue = useMemo<Queue<T> | undefined>(() => {\n if (!queueDxn) {\n return undefined;\n }\n\n const { spaceId } = queueDxn.asQueueDXN() ?? raise(new TypeError('Invalid queue DXN'));\n return client.spaces.get(spaceId)?.queues.get<T>(queueDxn);\n }, [client, queueDxn?.toString()]);\n\n useEffect(() => {\n void queue?.refresh();\n }, [queue]);\n\n useEffect(() => {\n let timeout: NodeJS.Timeout;\n mountedRef.current = true;\n\n const poll = () => {\n if (!mountedRef.current) {\n return;\n }\n\n void queue?.refresh().finally(() => {\n if (mountedRef.current && options.pollInterval) {\n timeout = setTimeout(poll, Math.max(options.pollInterval ?? 0, MIN_POLL_INTERVAL));\n }\n });\n };\n\n if (options.pollInterval) {\n poll();\n }\n\n return () => {\n mountedRef.current = false;\n clearTimeout(timeout);\n };\n }, [queue, options.pollInterval]);\n\n return queue;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Schema } from 'effect';\nimport { useMemo, useSyncExternalStore } from 'react';\n\nimport { type Client } from '@dxos/client';\nimport { type Space } from '@dxos/client/echo';\nimport { type BaseSchema } from '@dxos/echo-schema';\n\n/**\n * Subscribe to and retrieve schema changes from a space's schema registry.\n */\nexport const useSchema = (\n client: Client,\n space: Space | undefined,\n typename: string | undefined,\n): Schema.Schema.AnyNoContext | undefined => {\n const { subscribe, getSchema } = useMemo(() => {\n if (!typename || !space) {\n return {\n subscribe: () => () => {},\n getSchema: () => undefined,\n };\n }\n\n const staticSchema = client.graph.schemaRegistry.getSchema(typename);\n if (staticSchema) {\n return {\n subscribe: () => () => {},\n getSchema: () => staticSchema,\n };\n }\n\n const query = space.db.schemaRegistry.query({ typename });\n const initialResult: BaseSchema = query.runSync()[0];\n let currentSchema = initialResult;\n\n return {\n subscribe: (onStoreChange: () => void) => {\n const unsubscribe = query.subscribe(() => {\n currentSchema = query.results[0];\n onStoreChange();\n });\n\n return unsubscribe;\n },\n getSchema: () => currentSchema,\n };\n }, [typename, space]);\n\n return useSyncExternalStore(subscribe, getSchema);\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { useMemo } from 'react';\n\nimport { MulticastObservable } from '@dxos/async';\nimport { type PublicKey } from '@dxos/client';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useSpace } from './useSpaces';\nimport { type CancellableInvitationObservable, useInvitationStatus } from '../invitations';\n\nexport const useSpaceInvitations = (spaceKey?: PublicKey): CancellableInvitationObservable[] => {\n const space = useSpace(spaceKey);\n return useMulticastObservable(space?.invitations ?? MulticastObservable.empty()) ?? [];\n};\n\nexport const useSpaceInvitation = (spaceKey?: PublicKey, invitationId?: string) => {\n const invitations = useSpaceInvitations(spaceKey);\n const invitation = useMemo(\n () => invitations.find((invitation) => invitation.get().invitationId === invitationId),\n [invitations],\n );\n return useInvitationStatus(invitation);\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { useEffect, useRef } from 'react';\n\nimport { type Selection, type SubscriptionHandle, createSubscription } from '@dxos/client/echo';\n\n/**\n * Create reactive selection.\n * Calls the callback when the selection changes and during the first render.\n */\n// TODO(wittjosiah): Is this still needed with signals reactivity? If not, remove or update jsdoc with usage info.\nexport const useSubscription = (cb: () => void, selection: Selection) => {\n // Make sure that the callback is always the one from the latest render.\n // Without this, we would always call the callback from the initial render,\n // which might contain stale data.\n const callbackRef = useRef(cb);\n callbackRef.current = cb;\n\n const subscriptionRef = useRef<SubscriptionHandle>();\n\n useEffect(() => {\n subscriptionRef.current = createSubscription(() => {\n callbackRef.current();\n });\n\n return () => subscriptionRef.current?.unsubscribe();\n }, []);\n\n subscriptionRef.current?.update(selection);\n return subscriptionRef.current;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useEffect, useState } from 'react';\n\nimport { type PeerSyncState, type SpaceSyncStateMap, type Space } from '@dxos/client/echo';\nimport { Context } from '@dxos/context';\nimport { type SpaceId } from '@dxos/keys';\nimport { EdgeService } from '@dxos/protocols';\n\nimport { useClient } from '../client';\n\nconst isEdgePeerId = (peerId: string, spaceId: SpaceId) =>\n peerId.startsWith(`${EdgeService.AUTOMERGE_REPLICATOR}:${spaceId}`);\n\n/**\n * Hook Subscribes to sync state for each space.\n */\nexport const useSyncState = (): SpaceSyncStateMap => {\n const client = useClient();\n const [spaceState, setSpaceState] = useState<SpaceSyncStateMap>({});\n\n useEffect(() => {\n const ctx = new Context();\n const createSubscriptions = (spaces: Space[]) => {\n for (const space of spaces) {\n if (spaceState[space.id]) {\n continue;\n }\n\n ctx.onDispose(\n space.db.subscribeToSyncState(ctx, ({ peers = [] }) => {\n const syncState = peers.find((state) => isEdgePeerId(state.peerId, space.id));\n if (syncState) {\n setSpaceState((spaceState) => ({ ...spaceState, [space.id]: syncState }));\n }\n }),\n );\n }\n };\n\n createSubscriptions(client.spaces.get());\n client.spaces.subscribe((spaces) => {\n createSubscriptions(spaces);\n });\n\n return () => {\n void ctx.dispose();\n };\n }, [client]);\n\n return spaceState;\n};\n\n/**\n * Hook Subscribes to sync state for a single space.\n */\n// TODO(wittjosiah): Reconcile w/ useSyncState.\nexport const useSpaceSyncState = (space: Space): PeerSyncState | undefined => {\n const [spaceState, setSpaceState] = useState<PeerSyncState>();\n\n useEffect(() => {\n const ctx = new Context();\n space.db.subscribeToSyncState(ctx, ({ peers = [] }) => {\n const syncState = peers.find((state) => isEdgePeerId(state.peerId, space.id));\n if (syncState) {\n setSpaceState(syncState);\n }\n });\n\n return () => {\n void ctx.dispose();\n };\n }, [space]);\n\n return spaceState;\n};\n"],
5
- "mappings": ";;;;;;;;;AAIA,cAAc;;;ACAd,SAASA,2BAA2B;AAEpC,SAASC,uBAAyC;AAClD,SAASC,0BAAAA,+BAA8B;;;ACHvC,SAASC,WA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B,MAAMC,EAAE,CAAA;AAC3E,UAAIK,WAAW;AACbb,sBAAca,SAAAA;MAChB;IACF,CAAA;AAEA,WAAO,MAAA;AACL,WAAKV,IAAIe,QAAO;IAClB;EACF,GAAG;IAACX;GAAM;AAEV,SAAOR;AACT;",
6
- "names": ["MulticastObservable", "HaloSpaceMember", "useMulticastObservable", "useEffect", "useState", "SpaceState", "useMulticastObservable", "useSpace", "spaceKeyLike", "client", "useClient", "spaces", "useMulticastObservable", "ready", "setReady", "useState", "useEffect", "timeout", "setTimeout", "waitUntilReady", "clearTimeout", "find", "space", "key", "equals", "id", "halo", "identity", "get", "default", "useSpaces", "all", "filter", "state", "SpaceState", "SPACE_READY", "useMembers", "spaceKey", "spaces", "useSpaces", "all", "space", "find", "key", "equals", "undefined", "members", "useMulticastObservable", "MulticastObservable", "empty", "filter", "member", "role", "HaloSpaceMember", "Role", "REMOVED", "useMemo", "useSyncExternalStore", "Filter", "Query", "isSpace", "EMPTY_ARRAY", "noop", "useQuery", "spaceOrEcho", "queryOrFilter", "deps", "query", "Filter", "is", "Query", "select", "getObjects", "subscribe", "useMemo", "subscribed", "queryResult", "undefined", "isSpace", "db", "objects", "cb", "unsubscribe", "JSON", "stringify", "ast", "useSyncExternalStore", "useEffect", "useMemo", "useRef", "raise", "MIN_POLL_INTERVAL", "useQueue", "queueDxn", "options", "client", "useClient", "mountedRef", "useRef", "queue", "useMemo", "undefined", "spaceId", "asQueueDXN", "raise", "TypeError", "spaces", "get", "queues", "toString", "useEffect", "refresh", "timeout", "current", "poll", "finally", "pollInterval", "setTimeout", "Math", "max", "clearTimeout", "useMemo", "useSyncExternalStore", "useSchema", "client", "space", "typename", "subscribe", "getSchema", "useMemo", "undefined", "staticSchema", "graph", "schemaRegistry", "query", "db", "initialResult", "runSync", "currentSchema", "onStoreChange", "unsubscribe", "results", "useSyncExternalStore", "useMemo", "MulticastObservable", "useMulticastObservable", "useSpaceInvitations", "spaceKey", "space", "useSpace", "useMulticastObservable", "invitations", "MulticastObservable", "empty", "useSpaceInvitation", "invitationId", "invitation", "useMemo", "find", "get", "useInvitationStatus", "useEffect", "useRef", "createSubscription", "useSubscription", "cb", "selection", "callbackRef", "useRef", "current", "subscriptionRef", "useEffect", "createSubscription", "unsubscribe", "update", "useEffect", "useState", "Context", "EdgeService", "isEdgePeerId", "peerId", "spaceId", "startsWith", "EdgeService", "AUTOMERGE_REPLICATOR", "useSyncState", "client", "useClient", "spaceState", "setSpaceState", "useState", "useEffect", "ctx", "Context", "createSubscriptions", "spaces", "space", "id", "onDispose", "db", "subscribeToSyncState", "peers", "syncState", "find", "state", "get", "subscribe", "dispose", "useSpaceSyncState"]
3
+ "sources": ["../../../../src/echo/index.ts", "../../../../src/echo/useMembers.ts", "../../../../src/echo/useSpaces.ts", "../../../../src/echo/useSpaceInvitations.ts", "../../../../src/echo/useSpaceProperties.ts", "../../../../src/echo/useSubscription.ts", "../../../../src/echo/useSyncState.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2020 DXOS.org\n//\n\nexport * from '@dxos/client/echo';\nexport * from '@dxos/echo-react';\n\nexport * from './useMembers';\nexport * from './useSpaces';\nexport * from './useSpaceInvitations';\nexport * from './useSpaceProperties';\nexport * from './useSubscription';\nexport * from './useSyncState';\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { MulticastObservable } from '@dxos/async';\nimport { PublicKey, type PublicKeyLike } from '@dxos/client';\nimport { HaloSpaceMember, type SpaceMember } from '@dxos/client/echo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useSpaces } from './useSpaces';\n\nexport const useMembers = (spaceKey: PublicKeyLike | undefined): SpaceMember[] => {\n // TODO(dmaretskyi): useSpace hook for spaces that are not ready.\n const spaces = useSpaces({ all: true });\n const space = spaceKey\n ? spaces.find((space) => (spaceKey instanceof PublicKey ? space.key.equals(spaceKey) : space.id === spaceKey))\n : undefined;\n\n // EMPTY_OBSERVABLE needs to be a stable reference to avoid re-subscribing on every render.\n const members = useMulticastObservable(space?.members ?? MulticastObservable.empty()) ?? [];\n return members.filter((member) => member.role !== HaloSpaceMember.Role.REMOVED);\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { PublicKey } from '@dxos/client';\nimport { type Space, SpaceState } from '@dxos/client/echo';\nimport { type SpaceId } from '@dxos/keys';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\n\n/**\n * Get a specific Space using its id.\n * The space is not guaranteed to be in the ready state.\n * Returns undefined if no id is provided.\n * Requires a ClientProvider somewhere in the parent tree.\n *\n * @param spaceId the id of the space to look for.\n */\n// TODO(wittjosiah): Currently unable to remove `PublicKey` from this api.\n// When initially joining a space that is all that is returned.\nexport const useSpace = (spaceId?: SpaceId | PublicKey): Space | undefined => {\n const client = useClient();\n const spaces = useMulticastObservable<Space[]>(client.spaces);\n if (!spaceId) {\n return undefined;\n }\n\n return spaces.find((space) => {\n if (spaceId instanceof PublicKey) {\n return space.key.equals(spaceId);\n }\n\n return space.id === spaceId;\n });\n};\n\n/**\n * Get a Space database by the id of the space.\n * The space is not guaranteed to be in the ready state.\n * Returns undefined if no id is provided.\n * Requires a ClientProvider somewhere in the parent tree.\n *\n * @param spaceId the id of the space to look for.\n * @deprecated Use useSpace.\n */\nexport const useDatabase = (spaceId?: SpaceId): Space['db'] | undefined => {\n const space = useSpace(spaceId);\n return space?.db;\n};\n\nexport type UseSpacesProps = {\n /**\n * Return uninitialized spaces as well.\n */\n all?: boolean;\n};\n\n/**\n * Get all Spaces available to current user.\n * Requires a ClientProvider somewhere in the parent tree.\n * By default, only ready spaces are returned.\n * @returns an array of Spaces.\n */\nexport const useSpaces = ({ all = false }: UseSpacesProps = {}): Space[] => {\n const client = useClient();\n const spaces = useMulticastObservable<Space[]>(client.spaces);\n\n // TODO(dmaretskyi): Array reference equality.\n return spaces.filter((space) => all || space.state.get() === SpaceState.SPACE_READY);\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { useMemo } from 'react';\n\nimport { MulticastObservable } from '@dxos/async';\nimport { type PublicKey } from '@dxos/client';\nimport { type SpaceId } from '@dxos/keys';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { type CancellableInvitationObservable, useInvitationStatus } from '../invitations';\nimport { useSpace } from './useSpaces';\n\n// TODO(wittjosiah): Currently unable to remove `PublicKey` from this api.\n// When initially joining a space that is all that is returned.\nexport const useSpaceInvitations = (spaceId?: SpaceId | PublicKey): CancellableInvitationObservable[] => {\n const space = useSpace(spaceId);\n return useMulticastObservable(space?.invitations ?? MulticastObservable.empty()) ?? [];\n};\n\n// TODO(wittjosiah): Currently unable to remove `PublicKey` from this api.\n// When initially joining a space that is all that is returned.\nexport const useSpaceInvitation = (spaceId?: SpaceId | PublicKey, invitationId?: string) => {\n const invitations = useSpaceInvitations(spaceId);\n const invitation = useMemo(\n () => invitations.find((invitation) => invitation.get().invitationId === invitationId),\n [invitations],\n );\n return useInvitationStatus(invitation);\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { MulticastObservable } from '@dxos/async';\nimport { type SpaceProperties, SpaceState } from '@dxos/client/echo';\nimport { type Key, type Obj } from '@dxos/echo';\nimport { type ObjectUpdateCallback, useObject } from '@dxos/echo-react';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useSpace } from './useSpaces';\n\n/**\n * Subscribe to a space's properties with reactive updates.\n * Returns undefined if the space is undefined or not ready yet.\n * Automatically waits for the space to be ready before returning properties.\n *\n * @param spaceId - The space ID to get properties from (can be undefined).\n * @returns A tuple of [snapshot, updateCallback] or [undefined, no-op] if not ready.\n */\nexport const useSpaceProperties = (\n spaceId: Key.SpaceId | undefined,\n): [Obj.Snapshot<SpaceProperties> | undefined, ObjectUpdateCallback<SpaceProperties>] => {\n const space = useSpace(spaceId);\n const spaceState = useMulticastObservable(space?.state ?? MulticastObservable.empty());\n const properties = spaceState === SpaceState.SPACE_READY ? space?.properties : undefined;\n return useObject(properties);\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { useEffect, useRef } from 'react';\n\nimport { type Selection, type SubscriptionHandle, createSubscription } from '@dxos/client/echo';\n\n/**\n * Create reactive selection.\n * Calls the callback when the selection changes and during the first render.\n */\n// TODO(wittjosiah): Is this still needed with signals reactivity? If not, remove or update jsdoc with usage info.\nexport const useSubscription = (cb: () => void, selection: Selection) => {\n // Make sure that the callback is always the one from the latest render.\n // Without this, we would always call the callback from the initial render,\n // which might contain stale data.\n const callbackRef = useRef(cb);\n callbackRef.current = cb;\n\n const subscriptionRef = useRef<SubscriptionHandle>(null);\n\n useEffect(() => {\n subscriptionRef.current = createSubscription(() => {\n callbackRef.current();\n });\n\n return () => subscriptionRef.current?.unsubscribe();\n }, []);\n\n subscriptionRef.current?.update(selection);\n return subscriptionRef.current;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useEffect, useState } from 'react';\n\nimport { type PeerSyncState, type Space, type SpaceSyncStateMap } from '@dxos/client/echo';\nimport { Context } from '@dxos/context';\nimport { isEdgePeerId } from '@dxos/echo-protocol';\n\nimport { useClient } from '../client';\n\n/**\n * Hook Subscribes to sync state for each space.\n */\nexport const useSyncState = (): SpaceSyncStateMap => {\n const client = useClient();\n const [spaceState, setSpaceState] = useState<SpaceSyncStateMap>({});\n\n useEffect(() => {\n const ctx = new Context();\n const createSubscriptions = (spaces: Space[]) => {\n for (const space of spaces) {\n if (spaceState[space.id]) {\n continue;\n }\n\n ctx.onDispose(\n space.internal.db.subscribeToSyncState(ctx, ({ peers = [] }) => {\n const syncState = peers.find((state) => isEdgePeerId(state.peerId, space.id));\n if (syncState) {\n setSpaceState((spaceState) => ({ ...spaceState, [space.id]: syncState }));\n }\n }),\n );\n }\n };\n\n createSubscriptions(client.spaces.get());\n client.spaces.subscribe((spaces) => {\n createSubscriptions(spaces);\n });\n\n return () => {\n void ctx.dispose();\n };\n }, [client]);\n\n return spaceState;\n};\n\n/**\n * Hook Subscribes to sync state for a single space.\n */\n// TODO(wittjosiah): Reconcile w/ useSyncState.\nexport const useSpaceSyncState = (space: Space): PeerSyncState | undefined => {\n const [spaceState, setSpaceState] = useState<PeerSyncState>();\n\n useEffect(() => {\n const ctx = new Context();\n space.internal.db.subscribeToSyncState(ctx, ({ peers = [] }) => {\n const syncState = peers.find((state) => isEdgePeerId(state.peerId, space.id));\n if (syncState) {\n setSpaceState(syncState);\n }\n });\n\n return () => {\n void ctx.dispose();\n };\n }, [space]);\n\n return spaceState;\n};\n"],
5
+ "mappings": ";;;;;;;;;;AAIA,cAAc;AACd,cAAc;;;ACDd,SAASA,2BAA2B;AACpC,SAASC,aAAAA,kBAAqC;AAC9C,SAASC,uBAAyC;AAClD,SAASC,0BAAAA,+BAA8B;;;ACHvC,SAASC,iBAAiB;AAC1B,SAAqBC,kBAAkB;AAEvC,SAASC,8BAA8B;AAchC,IAAMC,WAAW,CAACC,YAAAA;AACvB,QAAMC,SAASC,UAAAA;AACf,QAAMC,SAASC,uBAAgCH,OAAOE,MAAM;AAC5D,MAAI,CAACH,SAAS;AACZ,WAAOK;EACT;AAEA,SAAOF,OAAOG,KAAK,CAACC,UAAAA;AAClB,QAAIP,mBAAmBQ,WAAW;AAChC,aAAOD,MAAME,IAAIC,OAAOV,OAAAA;IAC1B;AAEA,WAAOO,MAAMI,OAAOX;EACtB,CAAA;AACF;AAWO,IAAMY,cAAc,CAACZ,YAAAA;AAC1B,QAAMO,QAAQR,SAASC,OAAAA;AACvB,SAAOO,OAAOM;AAChB;AAeO,IAAMC,YAAY,CAAC,EAAEC,MAAM,MAAK,IAAqB,CAAC,MAAC;AAC5D,QAAMd,SAASC,UAAAA;AACf,QAAMC,SAASC,uBAAgCH,OAAOE,MAAM;AAG5D,SAAOA,OAAOa,OAAO,CAACT,UAAUQ,OAAOR,MAAMU,MAAMC,IAAG,MAAOC,WAAWC,WAAW;AACrF;;;AD3DO,IAAMC,aAAa,CAACC,aAAAA;AAEzB,QAAMC,SAASC,UAAU;IAAEC,KAAK;EAAK,CAAA;AACrC,QAAMC,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AYG,QAAMC,EAAI,YAAYC,YAAAA,GAAaC,cAAcV,GAAAA,GAAAA,CAAAA;UACnE,SAAII,GAAAA,qBAAW,KAAA,CAAA,EAAA,QAAA,CAAA,EAAA,MAAA;YACbR,YAAcQ,MAAAA,KAAAA,CAAAA,UAAAA,aAAAA,MAAAA,QAAAA,MAAAA,EAAAA,CAAAA;AAChB,UAAA,WAAA;AACF,sBAAA,SAAA;MAEA;;AAEA,WAAA,MAAA;AACC,WAAA,IAAA,QAAA;IAACJ;KAAM;IAEV;EACA,CAAA;;;",
6
+ "names": ["MulticastObservable", "PublicKey", "HaloSpaceMember", "useMulticastObservable", "PublicKey", "SpaceState", "useMulticastObservable", "useSpace", "spaceId", "client", "useClient", "spaces", "useMulticastObservable", "undefined", "find", "space", "PublicKey", "key", "equals", "id", "useDatabase", "db", "useSpaces", "all", "filter", "state", "get", "SpaceState", "SPACE_READY", "useMembers", "spaceKey", "spaces", "useSpaces", "all", "space", "find", "PublicKey", "key", "equals", "id", "undefined", "members", "useMulticastObservable", "MulticastObservable", "empty", "filter", "member", "role", "HaloSpaceMember", "Role", "REMOVED", "useMemo", "MulticastObservable", "useMulticastObservable", "useSpaceInvitations", "spaceId", "space", "useSpace", "useMulticastObservable", "invitations", "MulticastObservable", "empty", "useSpaceInvitation", "invitationId", "invitation", "useMemo", "find", "get", "useInvitationStatus", "MulticastObservable", "SpaceState", "useObject", "useMulticastObservable", "useSpaceProperties", "spaceId", "space", "useSpace", "spaceState", "useMulticastObservable", "state", "MulticastObservable", "empty", "properties", "SpaceState", "SPACE_READY", "undefined", "useObject", "useEffect", "useRef", "createSubscription", "useSubscription", "cb", "selection", "callbackRef", "current", "subscriptionRef", "unsubscribe", "update", "useEffect", "useState", "Context", "isEdgePeerId", "spaceState", "setSpaceState", "useEffect", "Context", "createSubscriptions", "space", "spaces", "id", "onDispose", "syncState", "client", "internal", "peers", "find", "isEdgePeerId", "state"]
7
7
  }
@@ -1,10 +1,11 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
  import {
3
3
  useInvitationStatus
4
- } from "../chunk-TU2JJLZK.mjs";
4
+ } from "../chunk-RQJPEHDY.mjs";
5
5
  import {
6
6
  useClient
7
- } from "../chunk-ZTD6HPV2.mjs";
7
+ } from "../chunk-CUDKNAMV.mjs";
8
+ import "../chunk-WUTK2IJF.mjs";
8
9
 
9
10
  // src/halo/index.ts
10
11
  import { Device, DeviceKind, DeviceType } from "@dxos/client/halo";
@@ -55,9 +56,10 @@ var useIdentity = () => {
55
56
  // src/halo/useKeyStore.ts
56
57
  import { useMemo as useMemo2, useReducer } from "react";
57
58
  var KeyStore = class {
59
+ _defaultKeys;
60
+ _keyMap = /* @__PURE__ */ new Map();
58
61
  constructor(_defaultKeys = []) {
59
62
  this._defaultKeys = _defaultKeys;
60
- this._keyMap = /* @__PURE__ */ new Map();
61
63
  }
62
64
  get map() {
63
65
  return this._keyMap;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/halo/index.ts", "../../../../src/halo/useContacts.ts", "../../../../src/halo/useCredentials.ts", "../../../../src/halo/useDevices.ts", "../../../../src/halo/useHaloInvitations.ts", "../../../../src/halo/useIdentity.ts", "../../../../src/halo/useKeyStore.ts"],
4
- "sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\n// NOTE: Export * fails here.\nexport {\n type Credential,\n type Contact,\n type Identity,\n type Halo,\n Device,\n DeviceKind,\n DeviceType,\n} from '@dxos/client/halo';\n\nexport * from './useContacts';\nexport * from './useCredentials';\nexport * from './useDevices';\nexport * from './useHaloInvitations';\nexport * from './useIdentity';\nexport * from './useKeyStore';\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport type { Contact } from '@dxos/client/halo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\n\n/**\n * Returns all known Contacts across all Spaces.\n * Contacts are known members of a common Space.\n * Requires ClientContext to be set via ClientProvider.\n */\nexport const useContacts = (): Contact[] => {\n const client = useClient();\n return useMulticastObservable(client.halo.contacts);\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport type { Credential } from '@dxos/client/halo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\n\nexport const useCredentials = (): Credential[] => {\n const client = useClient();\n return useMulticastObservable(client.halo.credentials);\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport type { Device } from '@dxos/client/halo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\n\nexport const useDevices = (): Device[] => {\n const client = useClient();\n return useMulticastObservable(client.halo.devices);\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { useMemo } from 'react';\n\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\nimport { useInvitationStatus, type CancellableInvitationObservable } from '../invitations';\n\nexport const useHaloInvitations = (): CancellableInvitationObservable[] => {\n const client = useClient();\n return useMulticastObservable(client.halo.invitations);\n};\n\nexport const useHaloInvitation = (invitationId?: string) => {\n const invitations = useHaloInvitations();\n const invitation = useMemo(\n () => invitations.find((invitation) => invitation.get().invitationId === invitationId),\n [invitations],\n );\n return useInvitationStatus(invitation);\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { type Identity } from '@dxos/client/halo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\n\n/**\n * Hook returning DXOS identity object.\n * Requires ClientContext to be set via ClientProvider.\n */\nexport const useIdentity = (): Identity | null => {\n const client = useClient();\n return useMulticastObservable(client.halo.identity);\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { useMemo, useReducer } from 'react';\n\n// TODO(burdon): Move to settings plugin.\nexport class KeyStore {\n private _keyMap = new Map<string, string>();\n\n constructor(private readonly _defaultKeys: string[] = []) {}\n\n get map() {\n return this._keyMap;\n }\n\n // TODO(burdon): Create subkeys.\n initialize(): this {\n this._defaultKeys.forEach((key) => {\n const value = localStorage.getItem(key);\n this.setKey(key, value ?? '');\n });\n\n return this;\n }\n\n getKey(key: string): void {\n localStorage.getItem(key);\n }\n\n setKey(key: string, value: string): void {\n localStorage.setItem(key, '');\n this._keyMap.set(key, value);\n }\n}\n\n/**\n * Settings store.\n * @deprecated Replace with HALO key store when available.\n */\nexport const useKeyStore = (\n defaultKeys: string[] = [],\n): [Map<string, string>, (key: string, value: string) => void] => {\n const [, forceUpdate] = useReducer((x) => x + 1, 0);\n const store = useMemo(() => new KeyStore(defaultKeys).initialize(), [defaultKeys]);\n const setKey = (key: string, value: string) => {\n store.setKey(key, value);\n forceUpdate();\n };\n\n return [store.map, setKey];\n};\n"],
5
- "mappings": ";;;;;;;;;AAKA,SAKEA,QACAC,YACAC,kBACK;;;ACRP,SAASC,8BAA8B;AAShC,IAAMC,cAAc,MAAA;AACzB,QAAMC,SAASC,UAAAA;AACf,SAAOC,uBAAuBF,OAAOG,KAAKC,QAAQ;AACpD;;;ACZA,SAASC,0BAAAA,+BAA8B;AAIhC,IAAMC,iBAAiB,MAAA;AAC5B,QAAMC,SAASC,UAAAA;AACf,SAAOC,wBAAuBF,OAAOG,KAAKC,WAAW;AACvD;;;ACPA,SAASC,0BAAAA,+BAA8B;AAIhC,IAAMC,aAAa,MAAA;AACxB,QAAMC,SAASC,UAAAA;AACf,SAAOC,wBAAuBF,OAAOG,KAAKC,OAAO;AACnD;;;ACRA,SAASC,eAAe;AAExB,SAASC,0BAAAA,+BAA8B;AAKhC,IAAMC,qBAAqB,MAAA;AAChC,QAAMC,SAASC,UAAAA;AACf,SAAOC,wBAAuBF,OAAOG,KAAKC,WAAW;AACvD;AAEO,IAAMC,oBAAoB,CAACC,iBAAAA;AAChC,QAAMF,cAAcL,mBAAAA;AACpB,QAAMQ,aAAaC,QACjB,MAAMJ,YAAYK,KAAK,CAACF,gBAAeA,YAAWG,IAAG,EAAGJ,iBAAiBA,YAAAA,GACzE;IAACF;GAAY;AAEf,SAAOO,oBAAoBJ,UAAAA;AAC7B;;;AClBA,SAASK,0BAAAA,+BAA8B;AAQhC,IAAMC,cAAc,MAAA;AACzB,QAAMC,SAASC,UAAAA;AACf,SAAOC,wBAAuBF,OAAOG,KAAKC,QAAQ;AACpD;;;ACZA,SAASC,WAAAA,UAASC,kBAAkB;AAG7B,IAAMC,WAAN,MAAMA;EAGX,YAA6BC,eAAyB,CAAA,GAAI;SAA7BA,eAAAA;SAFrBC,UAAU,oBAAIC,IAAAA;EAEqC;EAE3D,IAAIC,MAAM;AACR,WAAO,KAAKF;EACd;;EAGAG,aAAmB;AACjB,SAAKJ,aAAaK,QAAQ,CAACC,QAAAA;AACzB,YAAMC,QAAQC,aAAaC,QAAQH,GAAAA;AACnC,WAAKI,OAAOJ,KAAKC,SAAS,EAAA;IAC5B,CAAA;AAEA,WAAO;EACT;EAEAI,OAAOL,KAAmB;AACxBE,iBAAaC,QAAQH,GAAAA;EACvB;EAEAI,OAAOJ,KAAaC,OAAqB;AACvCC,iBAAaI,QAAQN,KAAK,EAAA;AAC1B,SAAKL,QAAQY,IAAIP,KAAKC,KAAAA;EACxB;AACF;AAMO,IAAMO,cAAc,CACzBC,cAAwB,CAAA,MAAE;AAE1B,QAAM,CAAA,EAAGC,WAAAA,IAAeC,WAAW,CAACC,MAAMA,IAAI,GAAG,CAAA;AACjD,QAAMC,QAAQC,SAAQ,MAAM,IAAIrB,SAASgB,WAAAA,EAAaX,WAAU,GAAI;IAACW;GAAY;AACjF,QAAML,SAAS,CAACJ,KAAaC,UAAAA;AAC3BY,UAAMT,OAAOJ,KAAKC,KAAAA;AAClBS,gBAAAA;EACF;AAEA,SAAO;IAACG,MAAMhB;IAAKO;;AACrB;",
6
- "names": ["Device", "DeviceKind", "DeviceType", "useMulticastObservable", "useContacts", "client", "useClient", "useMulticastObservable", "halo", "contacts", "useMulticastObservable", "useCredentials", "client", "useClient", "useMulticastObservable", "halo", "credentials", "useMulticastObservable", "useDevices", "client", "useClient", "useMulticastObservable", "halo", "devices", "useMemo", "useMulticastObservable", "useHaloInvitations", "client", "useClient", "useMulticastObservable", "halo", "invitations", "useHaloInvitation", "invitationId", "invitation", "useMemo", "find", "get", "useInvitationStatus", "useMulticastObservable", "useIdentity", "client", "useClient", "useMulticastObservable", "halo", "identity", "useMemo", "useReducer", "KeyStore", "_defaultKeys", "_keyMap", "Map", "map", "initialize", "forEach", "key", "value", "localStorage", "getItem", "setKey", "getKey", "setItem", "set", "useKeyStore", "defaultKeys", "forceUpdate", "useReducer", "x", "store", "useMemo"]
4
+ "sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\n// NOTE: Export * fails here.\nexport {\n type Credential,\n type Contact,\n type Identity,\n type Halo,\n Device,\n DeviceKind,\n DeviceType,\n} from '@dxos/client/halo';\n\nexport * from './useContacts';\nexport * from './useCredentials';\nexport * from './useDevices';\nexport * from './useHaloInvitations';\nexport * from './useIdentity';\nexport * from './useKeyStore';\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport type { Contact } from '@dxos/client/halo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\n\n/**\n * Returns all known Contacts across all Spaces.\n * Contacts are known members of a common Space.\n * Requires ClientContext to be set via ClientProvider.\n */\nexport const useContacts = (): Contact[] => {\n const client = useClient();\n return useMulticastObservable(client.halo.contacts);\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport type { Credential } from '@dxos/client/halo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\n\nexport const useCredentials = (): Credential[] => {\n const client = useClient();\n return useMulticastObservable(client.halo.credentials);\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport type { Device } from '@dxos/client/halo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\n\nexport const useDevices = (): Device[] => {\n const client = useClient();\n return useMulticastObservable(client.halo.devices);\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { useMemo } from 'react';\n\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\nimport { type CancellableInvitationObservable, useInvitationStatus } from '../invitations';\n\nexport const useHaloInvitations = (): CancellableInvitationObservable[] => {\n const client = useClient();\n return useMulticastObservable(client.halo.invitations);\n};\n\nexport const useHaloInvitation = (invitationId?: string) => {\n const invitations = useHaloInvitations();\n const invitation = useMemo(\n () => invitations.find((invitation) => invitation.get().invitationId === invitationId),\n [invitations],\n );\n return useInvitationStatus(invitation);\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { type Identity } from '@dxos/client/halo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\n\n/**\n * Hook returning DXOS identity object.\n * Requires ClientContext to be set via ClientProvider.\n */\nexport const useIdentity = (): Identity | null => {\n const client = useClient();\n return useMulticastObservable(client.halo.identity);\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { useMemo, useReducer } from 'react';\n\n// TODO(burdon): Move to settings plugin.\nexport class KeyStore {\n private _keyMap = new Map<string, string>();\n\n constructor(private readonly _defaultKeys: string[] = []) {}\n\n get map() {\n return this._keyMap;\n }\n\n // TODO(burdon): Create subkeys.\n initialize(): this {\n this._defaultKeys.forEach((key) => {\n const value = localStorage.getItem(key);\n this.setKey(key, value ?? '');\n });\n\n return this;\n }\n\n getKey(key: string): void {\n localStorage.getItem(key);\n }\n\n setKey(key: string, value: string): void {\n localStorage.setItem(key, '');\n this._keyMap.set(key, value);\n }\n}\n\n/**\n * Settings store.\n * @deprecated Replace with HALO key store when available.\n */\nexport const useKeyStore = (\n defaultKeys: string[] = [],\n): [Map<string, string>, (key: string, value: string) => void] => {\n const [, forceUpdate] = useReducer((x) => x + 1, 0);\n const store = useMemo(() => new KeyStore(defaultKeys).initialize(), [defaultKeys]);\n const setKey = (key: string, value: string) => {\n store.setKey(key, value);\n forceUpdate();\n };\n\n return [store.map, setKey];\n};\n"],
5
+ "mappings": ";;;;;;;;;;AAKA,SAKEA,QACAC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AKC,SAAS,EAAA;IAC5B,CAAA;AAEA,WAAO;EACT;EAEAI,OAAOL,KAAmB;AACxBE,iBAAaC,QAAQH,GAAAA;EACvB;EAEAI,OAAOJ,KAAaC,OAAqB;AACvCC,iBAAaI,QAAQN,KAAK,EAAA;AAC1B,SAAKN,QAAQa,IAAIP,KAAKC,KAAAA;EACxB;AACF;AAMO,IAAMO,cAAc,CACzBC,cAAwB,CAAA,MAAE;AAE1B,QAAM,CAAA,EAAGC,WAAAA,IAAelB,WAAW,CAACmB,MAAMA,IAAI,GAAG,CAAA;AACjD,QAAMC,QAAQrB,SAAQ,MAAM,IAAIE,SAASgB,WAAAA,EAAaX,WAAU,GAAI;IAACW;GAAY;AACjF,QAAML,SAAS,CAACJ,KAAaC,UAAAA;AAC3BW,UAAMR,OAAOJ,KAAKC,KAAAA;AAClBS,gBAAAA;EACF;AAEA,SAAO;IAACE,MAAMf;IAAKO;;AACrB;",
6
+ "names": ["Device", "DeviceKind", "DeviceType", "useMulticastObservable", "useContacts", "client", "useClient", "useMulticastObservable", "halo", "contacts", "useMulticastObservable", "useCredentials", "client", "useClient", "useMulticastObservable", "halo", "credentials", "useMulticastObservable", "useDevices", "client", "useClient", "useMulticastObservable", "halo", "devices", "useMemo", "useMulticastObservable", "useHaloInvitations", "client", "useClient", "useMulticastObservable", "halo", "invitations", "useHaloInvitation", "invitationId", "invitation", "useMemo", "find", "get", "useInvitationStatus", "useMulticastObservable", "useIdentity", "client", "useClient", "useMulticastObservable", "halo", "identity", "useMemo", "useReducer", "KeyStore", "_keyMap", "Map", "_defaultKeys", "map", "initialize", "forEach", "key", "value", "localStorage", "getItem", "setKey", "getKey", "setItem", "set", "useKeyStore", "defaultKeys", "forceUpdate", "x", "store"]
7
7
  }
@@ -1,21 +1,108 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
  import {
3
- AgentHostingContext,
4
- AgentHostingProvider,
5
- ClientContext,
6
- ClientProvider,
7
- useAgentHostingClient,
8
- useClient,
9
- useClientStatus,
10
- useConfig,
11
- useShell,
12
- useShellDisplay,
13
- useStatus
14
- } from "./chunk-ZTD6HPV2.mjs";
3
+ useClient
4
+ } from "./chunk-CUDKNAMV.mjs";
5
+ import {
6
+ ClientProvider
7
+ } from "./chunk-WL3Z5HOH.mjs";
8
+ import {
9
+ ClientContext
10
+ } from "./chunk-WUTK2IJF.mjs";
15
11
 
16
12
  // src/index.ts
17
13
  export * from "@dxos/client";
18
14
  import { useMulticastObservable } from "@dxos/react-hooks";
15
+
16
+ // src/client/AgentHostingProvider.tsx
17
+ import React, { createContext, useContext, useState } from "react";
18
+ import { AgentManagerClient, FakeAgentHostingProvider } from "@dxos/client";
19
+ import { log } from "@dxos/log";
20
+ var __dxlog_file = "/__w/dxos/dxos/packages/sdk/react-client/src/client/AgentHostingProvider.tsx";
21
+ var AgentHostingContext = /* @__PURE__ */ createContext(null);
22
+ var AgentHostingProvider = (props) => {
23
+ const client = useClient();
24
+ const [agentHostingProviderClient] = useState(makeClient(client));
25
+ return /* @__PURE__ */ React.createElement(AgentHostingContext.Provider, {
26
+ value: agentHostingProviderClient
27
+ }, " ", props.children);
28
+ };
29
+ var useAgentHostingClient = () => {
30
+ return useContext(AgentHostingContext);
31
+ };
32
+ var makeClient = ({ config, halo }) => {
33
+ const agentHostingConfig = config.get("runtime.services.agentHosting");
34
+ if (!agentHostingConfig) {
35
+ log("no agent hosting configured", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 27, S: void 0 });
36
+ return null;
37
+ }
38
+ let agentHostingProviderClient = null;
39
+ switch (agentHostingConfig.type) {
40
+ case "LOCAL_TESTING": {
41
+ log("using FakeAgentHostingProvider", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 35, S: void 0 });
42
+ return new FakeAgentHostingProvider();
43
+ }
44
+ case "AGENTHOSTING_API": {
45
+ agentHostingProviderClient = new AgentManagerClient(config, halo);
46
+ if (agentHostingProviderClient.init()) {
47
+ return agentHostingProviderClient;
48
+ } else {
49
+ return null;
50
+ }
51
+ }
52
+ default: {
53
+ log.error("Unknown agent hosting provider type: " + agentHostingConfig.type, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 50, S: void 0 });
54
+ return null;
55
+ }
56
+ }
57
+ };
58
+
59
+ // src/client/useClientStatus.ts
60
+ import { useEffect, useState as useState2 } from "react";
61
+ var useClientStatus = (client) => {
62
+ const [status, setStatus] = useState2();
63
+ useEffect(() => {
64
+ if (!client) {
65
+ return;
66
+ }
67
+ const subscription = client.status.subscribe((status2) => setStatus(status2));
68
+ return () => subscription.unsubscribe();
69
+ }, [
70
+ client,
71
+ setStatus
72
+ ]);
73
+ return status;
74
+ };
75
+
76
+ // src/client/useConfig.ts
77
+ import { useContext as useContext2 } from "react";
78
+ import { raise } from "@dxos/debug";
79
+ var useConfig = () => {
80
+ const { client } = useContext2(ClientContext) ?? raise(new Error("Missing ClientContext."));
81
+ return client.config;
82
+ };
83
+
84
+ // src/client/useShell.ts
85
+ import { useEffect as useEffect2, useState as useState3 } from "react";
86
+ var useShell = () => {
87
+ const client = useClient();
88
+ return client.shell;
89
+ };
90
+ var useShellDisplay = () => {
91
+ const client = useClient();
92
+ const [display, setDisplay] = useState3(client.shell.display);
93
+ useEffect2(() => client.shell.onDisplayChange(setDisplay), [
94
+ client
95
+ ]);
96
+ return display;
97
+ };
98
+
99
+ // src/client/useStatus.ts
100
+ import { useContext as useContext3 } from "react";
101
+ import { raise as raise2 } from "@dxos/debug";
102
+ var useStatus = () => {
103
+ const { status } = useContext3(ClientContext) ?? raise2(new Error("Missing ClientContext."));
104
+ return status;
105
+ };
19
106
  export {
20
107
  AgentHostingContext,
21
108
  AgentHostingProvider,