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

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 (350) hide show
  1. package/.storybook/main.mts +11 -0
  2. package/.storybook/preview.mts +8 -0
  3. package/.swc/plugins/linux_x86_64_19.0.0/727453fb3a62f7f1d952a41e051ca8a6f88cadc45cee43c6a4d1aa45f9b75665.wasmer-v7 +0 -0
  4. package/dist/lib/browser/{chunk-O5SEVDJG.mjs → chunk-LO3TU5CK.mjs} +5 -5
  5. package/dist/lib/browser/chunk-LO3TU5CK.mjs.map +7 -0
  6. package/dist/lib/browser/{chunk-AAR7V3KL.mjs → chunk-TA2HGRAF.mjs} +64 -67
  7. package/dist/lib/browser/chunk-TA2HGRAF.mjs.map +7 -0
  8. package/dist/lib/browser/devtools/index.mjs +2 -2
  9. package/dist/lib/browser/devtools/index.mjs.map +3 -3
  10. package/dist/lib/browser/echo/index.mjs +22 -22
  11. package/dist/lib/browser/echo/index.mjs.map +3 -3
  12. package/dist/lib/browser/halo/index.mjs +4 -3
  13. package/dist/lib/browser/halo/index.mjs.map +3 -3
  14. package/dist/lib/browser/index.mjs +1 -1
  15. package/dist/lib/browser/invitations/index.mjs +1 -1
  16. package/dist/lib/browser/mesh/index.mjs +1 -1
  17. package/dist/lib/browser/meta.json +1 -1
  18. package/dist/lib/browser/testing/index.mjs +51 -50
  19. package/dist/lib/browser/testing/index.mjs.map +3 -3
  20. package/dist/lib/node-esm/{chunk-TU2JJLZK.mjs → chunk-AQJH2UNZ.mjs} +5 -5
  21. package/dist/lib/node-esm/chunk-AQJH2UNZ.mjs.map +7 -0
  22. package/dist/lib/node-esm/{chunk-ZTD6HPV2.mjs → chunk-ZJMNF7GC.mjs} +64 -67
  23. package/dist/lib/node-esm/chunk-ZJMNF7GC.mjs.map +7 -0
  24. package/dist/lib/node-esm/devtools/index.mjs +2 -2
  25. package/dist/lib/node-esm/devtools/index.mjs.map +3 -3
  26. package/dist/lib/node-esm/echo/index.mjs +22 -22
  27. package/dist/lib/node-esm/echo/index.mjs.map +3 -3
  28. package/dist/lib/node-esm/halo/index.mjs +4 -3
  29. package/dist/lib/node-esm/halo/index.mjs.map +3 -3
  30. package/dist/lib/node-esm/index.mjs +1 -1
  31. package/dist/lib/node-esm/invitations/index.mjs +1 -1
  32. package/dist/lib/node-esm/mesh/index.mjs +1 -1
  33. package/dist/lib/node-esm/meta.json +1 -1
  34. package/dist/lib/node-esm/testing/index.mjs +51 -50
  35. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  36. package/dist/types/src/client/AgentHostingProvider.d.ts.map +1 -1
  37. package/dist/types/src/client/ClientProvider.d.ts.map +1 -1
  38. package/dist/types/src/echo/useQuery.d.ts +3 -3
  39. package/dist/types/src/echo/useQuery.d.ts.map +1 -1
  40. package/dist/types/src/echo/useSchema.d.ts +1 -1
  41. package/dist/types/src/echo/useSchema.d.ts.map +1 -1
  42. package/dist/types/src/echo/useSpaceInvitations.d.ts.map +1 -1
  43. package/dist/types/src/echo/useSpaces.d.ts.map +1 -1
  44. package/dist/types/src/echo/useSubscription.d.ts +1 -1
  45. package/dist/types/src/echo/useSubscription.d.ts.map +1 -1
  46. package/dist/types/src/echo/useSyncState.d.ts +1 -1
  47. package/dist/types/src/echo/useSyncState.d.ts.map +1 -1
  48. package/dist/types/src/halo/Passkey.stories.d.ts +5 -5
  49. package/dist/types/src/halo/Passkey.stories.d.ts.map +1 -1
  50. package/dist/types/src/halo/useHaloInvitations.d.ts.map +1 -1
  51. package/dist/types/src/invitations/useInvitationStatus.d.ts +1 -1
  52. package/dist/types/src/invitations/useInvitationStatus.d.ts.map +1 -1
  53. package/dist/types/src/testing/ClientRepeater.d.ts +2 -2
  54. package/dist/types/src/testing/ClientRepeater.d.ts.map +1 -1
  55. package/dist/types/src/testing/ClientRepeater.stories.d.ts +6 -10
  56. package/dist/types/src/testing/ClientRepeater.stories.d.ts.map +1 -1
  57. package/dist/types/src/testing/withClientProvider.d.ts +6 -7
  58. package/dist/types/src/testing/withClientProvider.d.ts.map +1 -1
  59. package/dist/types/src/testing/withClientProvider.stories.d.ts +7 -9
  60. package/dist/types/src/testing/withClientProvider.stories.d.ts.map +1 -1
  61. package/dist/types/tsconfig.tsbuildinfo +1 -1
  62. package/moon.yml +4 -0
  63. package/package.json +38 -31
  64. package/src/client/AgentHostingProvider.tsx +1 -1
  65. package/src/client/ClientProvider.test.tsx +3 -2
  66. package/src/client/ClientProvider.tsx +33 -36
  67. package/src/client/useConfig.test.tsx +2 -1
  68. package/src/devtools/useStream.ts +1 -1
  69. package/src/echo/useQuery.test.tsx +9 -8
  70. package/src/echo/useQuery.ts +20 -13
  71. package/src/echo/useSchema.ts +2 -2
  72. package/src/echo/useSpaceInvitations.ts +2 -1
  73. package/src/echo/useSpaces.test.tsx +2 -1
  74. package/src/echo/useSpaces.ts +5 -9
  75. package/src/echo/useSubscription.ts +1 -1
  76. package/src/echo/useSyncState.ts +1 -1
  77. package/src/halo/Passkey.stories.tsx +16 -13
  78. package/src/halo/useDevices.test.tsx +2 -1
  79. package/src/halo/useHaloInvitations.ts +1 -1
  80. package/src/invitations/useInvitationStatus.ts +9 -8
  81. package/src/testing/ClientRepeater.stories.tsx +12 -8
  82. package/src/testing/ClientRepeater.tsx +23 -27
  83. package/src/testing/withClientProvider.stories.tsx +25 -16
  84. package/src/testing/withClientProvider.tsx +24 -21
  85. package/tsconfig.json +0 -3
  86. package/vitest.config.ts +12 -16
  87. package/.eslintrc.cjs +0 -12
  88. package/.swc/plugins/v7_linux_x86_64_13.0.0/f45bdff002284d9e8f9ef3f0be909de12da36c049cbcf261ac78fc00abb09a2d +0 -0
  89. package/dist/lib/browser/chunk-AAR7V3KL.mjs.map +0 -7
  90. package/dist/lib/browser/chunk-O5SEVDJG.mjs.map +0 -7
  91. package/dist/lib/node-esm/chunk-TU2JJLZK.mjs.map +0 -7
  92. package/dist/lib/node-esm/chunk-ZTD6HPV2.mjs.map +0 -7
  93. package/typedoc/.nojekyll +0 -1
  94. package/typedoc/assets/hierarchy.js +0 -1
  95. package/typedoc/assets/highlight.css +0 -99
  96. package/typedoc/assets/icons.js +0 -18
  97. package/typedoc/assets/icons.svg +0 -1
  98. package/typedoc/assets/main.js +0 -60
  99. package/typedoc/assets/navigation.js +0 -1
  100. package/typedoc/assets/search.js +0 -1
  101. package/typedoc/assets/style.css +0 -1640
  102. package/typedoc/classes/echo.Hypergraph.html +0 -17
  103. package/typedoc/classes/echo.PropertiesType.html +0 -19
  104. package/typedoc/classes/echo.QueryResult.html +0 -18
  105. package/typedoc/classes/halo.KeyStore.html +0 -6
  106. package/typedoc/classes/index.AgentClientServiceProvider.html +0 -10
  107. package/typedoc/classes/index.AgentManagerClient.html +0 -22
  108. package/typedoc/classes/index.AlreadyJoinedError.html +0 -15
  109. package/typedoc/classes/index.ApiError.html +0 -16
  110. package/typedoc/classes/index.CancelledError.html +0 -16
  111. package/typedoc/classes/index.Client.html +0 -51
  112. package/typedoc/classes/index.ClientServicesProxy.html +0 -12
  113. package/typedoc/classes/index.Config.html +0 -17
  114. package/typedoc/classes/index.DataCorruptionError.html +0 -16
  115. package/typedoc/classes/index.DatabaseError.html +0 -15
  116. package/typedoc/classes/index.EntityNotFoundError.html +0 -15
  117. package/typedoc/classes/index.FakeAgentHostingProvider.html +0 -7
  118. package/typedoc/classes/index.IFrameManager.html +0 -6
  119. package/typedoc/classes/index.IdentityNotInitializedError.html +0 -15
  120. package/typedoc/classes/index.InvalidConfigError.html +0 -16
  121. package/typedoc/classes/index.InvalidInvitationError.html +0 -15
  122. package/typedoc/classes/index.InvalidInvitationExtensionRoleError.html +0 -16
  123. package/typedoc/classes/index.InvalidStorageVersionError.html +0 -15
  124. package/typedoc/classes/index.LocalClientServices.html +0 -12
  125. package/typedoc/classes/index.PublicKey.html +0 -55
  126. package/typedoc/classes/index.RemoteServiceConnectionError.html +0 -15
  127. package/typedoc/classes/index.RemoteServiceConnectionTimeout.html +0 -15
  128. package/typedoc/classes/index.RpcClosedError.html +0 -15
  129. package/typedoc/classes/index.RpcNotOpenError.html +0 -15
  130. package/typedoc/classes/index.SharedWorkerConnection.html +0 -5
  131. package/typedoc/classes/index.Shell.html +0 -35
  132. package/typedoc/classes/index.ShellManager.html +0 -9
  133. package/typedoc/classes/index.SystemError.html +0 -16
  134. package/typedoc/classes/index.UnknownModelError.html +0 -15
  135. package/typedoc/classes/index.WorkerClientServices.html +0 -12
  136. package/typedoc/classes/invitations.AuthenticatingInvitationObservable.html +0 -30
  137. package/typedoc/classes/invitations.CancellableInvitationObservable.html +0 -29
  138. package/typedoc/classes/invitations.InvitationEncoder.html +0 -5
  139. package/typedoc/classes/invitations.InvitationsProxy.html +0 -12
  140. package/typedoc/enums/devtools.KeyType.html +0 -9
  141. package/typedoc/enums/echo.HaloSpaceMember.Role.html +0 -9
  142. package/typedoc/enums/echo.IndexKind.Kind.html +0 -8
  143. package/typedoc/enums/echo.QueryOptions.DataLocation.html +0 -6
  144. package/typedoc/enums/echo.QueryOptions.ShowDeletedOption.html +0 -6
  145. package/typedoc/enums/echo.SpaceMember.PresenceState.html +0 -5
  146. package/typedoc/enums/echo.SpaceState.html +0 -13
  147. package/typedoc/enums/echo.TextKind.html +0 -5
  148. package/typedoc/enums/halo.Device.PresenceState.html +0 -6
  149. package/typedoc/enums/halo.DeviceKind.html +0 -5
  150. package/typedoc/enums/halo.DeviceType.html +0 -9
  151. package/typedoc/enums/index.ShellDisplay.html +0 -5
  152. package/typedoc/enums/index.ShellLayout.html +0 -13
  153. package/typedoc/enums/index.SystemStatus.html +0 -5
  154. package/typedoc/enums/invitations.Invitation.AuthMethod.html +0 -6
  155. package/typedoc/enums/invitations.Invitation.Kind.html +0 -5
  156. package/typedoc/enums/invitations.Invitation.State.html +0 -13
  157. package/typedoc/enums/invitations.Invitation.Type.html +0 -6
  158. package/typedoc/enums/mesh.ConnectionState.html +0 -5
  159. package/typedoc/functions/devtools.useDevtools.html +0 -1
  160. package/typedoc/functions/devtools.useStream.html +0 -2
  161. package/typedoc/functions/echo.useMembers.html +0 -1
  162. package/typedoc/functions/echo.useQueue.html +0 -2
  163. package/typedoc/functions/echo.useSchema.html +0 -2
  164. package/typedoc/functions/echo.useSpace.html +0 -6
  165. package/typedoc/functions/echo.useSpaceInvitation.html +0 -1
  166. package/typedoc/functions/echo.useSpaceInvitations.html +0 -1
  167. package/typedoc/functions/echo.useSpaceSyncState.html +0 -2
  168. package/typedoc/functions/echo.useSpaces.html +0 -5
  169. package/typedoc/functions/echo.useSubscription.html +0 -3
  170. package/typedoc/functions/echo.useSyncState.html +0 -2
  171. package/typedoc/functions/halo.useContacts.html +0 -4
  172. package/typedoc/functions/halo.useCredentials.html +0 -1
  173. package/typedoc/functions/halo.useDevices.html +0 -1
  174. package/typedoc/functions/halo.useHaloInvitation.html +0 -1
  175. package/typedoc/functions/halo.useHaloInvitations.html +0 -1
  176. package/typedoc/functions/halo.useIdentity.html +0 -3
  177. package/typedoc/functions/halo.useKeyStore.html +0 -3
  178. package/typedoc/functions/index.AgentHostingProvider.html +0 -2
  179. package/typedoc/functions/index.useAgentHostingClient.html +0 -1
  180. package/typedoc/functions/index.useClient.html +0 -3
  181. package/typedoc/functions/index.useClientStatus.html +0 -1
  182. package/typedoc/functions/index.useConfig.html +0 -3
  183. package/typedoc/functions/index.useShell.html +0 -2
  184. package/typedoc/functions/index.useShellDisplay.html +0 -2
  185. package/typedoc/functions/index.useStatus.html +0 -1
  186. package/typedoc/functions/invitations.useInvitationStatus.html +0 -1
  187. package/typedoc/functions/mesh.useNetworkStatus.html +0 -2
  188. package/typedoc/hierarchy.html +0 -1
  189. package/typedoc/index.html +0 -23
  190. package/typedoc/interfaces/devtools.DevtoolsHook.html +0 -22
  191. package/typedoc/interfaces/devtools.DevtoolsHost.html +0 -26
  192. package/typedoc/interfaces/echo.DocAccessor.html +0 -3
  193. package/typedoc/interfaces/echo.Echo.html +0 -39
  194. package/typedoc/interfaces/echo.EchoDatabase.html +0 -30
  195. package/typedoc/interfaces/echo.Expando.html +0 -3
  196. package/typedoc/interfaces/echo.Filter.html +0 -3
  197. package/typedoc/interfaces/echo.HaloSpaceMember.html +0 -18
  198. package/typedoc/interfaces/echo.IDocHandle.html +0 -6
  199. package/typedoc/interfaces/echo.IndexKind.html +0 -9
  200. package/typedoc/interfaces/echo.Query.html +0 -34
  201. package/typedoc/interfaces/echo.QueryOptions.html +0 -39
  202. package/typedoc/interfaces/echo.Queue.html +0 -17
  203. package/typedoc/interfaces/echo.Ref.html +0 -32
  204. package/typedoc/interfaces/echo.Space.html +0 -36
  205. package/typedoc/interfaces/echo.SpaceMember.html +0 -7
  206. package/typedoc/interfaces/echo.SpaceSyncState.PeerState.html +0 -14
  207. package/typedoc/interfaces/echo.SpaceSyncState.html +0 -4
  208. package/typedoc/interfaces/echo.SubscriptionHandle.html +0 -5
  209. package/typedoc/interfaces/echo.TypedObject.html +0 -16
  210. package/typedoc/interfaces/halo.Contact.html +0 -10
  211. package/typedoc/interfaces/halo.Credential.html +0 -27
  212. package/typedoc/interfaces/halo.Device.html +0 -11
  213. package/typedoc/interfaces/halo.Halo.html +0 -16
  214. package/typedoc/interfaces/halo.Identity.html +0 -15
  215. package/typedoc/interfaces/index.AgentHostingProviderClient.html +0 -6
  216. package/typedoc/interfaces/index.AppContextRequest.html +0 -33
  217. package/typedoc/interfaces/index.ClientServicesProvider.html +0 -9
  218. package/typedoc/interfaces/index.InvitationUrlRequest.html +0 -9
  219. package/typedoc/interfaces/index.LayoutRequest.html +0 -29
  220. package/typedoc/interfaces/index.ShellRuntime.html +0 -15
  221. package/typedoc/interfaces/invitations.Invitation.html +0 -92
  222. package/typedoc/interfaces/invitations.Invitations.html +0 -5
  223. package/typedoc/interfaces/mesh.GossipMessage.html +0 -10
  224. package/typedoc/interfaces/mesh.NetworkStatus.Signal.html +0 -5
  225. package/typedoc/interfaces/mesh.NetworkStatus.html +0 -6
  226. package/typedoc/media/LICENSE +0 -8
  227. package/typedoc/modules/devtools.html +0 -1
  228. package/typedoc/modules/echo.Filter.html +0 -1
  229. package/typedoc/modules/echo.HaloSpaceMember.html +0 -1
  230. package/typedoc/modules/echo.IndexKind.html +0 -1
  231. package/typedoc/modules/echo.Query.html +0 -1
  232. package/typedoc/modules/echo.QueryOptions.html +0 -1
  233. package/typedoc/modules/echo.Ref.html +0 -2
  234. package/typedoc/modules/echo.SpaceMember.html +0 -1
  235. package/typedoc/modules/echo.SpaceSyncState.html +0 -1
  236. package/typedoc/modules/echo.html +0 -1
  237. package/typedoc/modules/halo.Device.html +0 -1
  238. package/typedoc/modules/halo.html +0 -1
  239. package/typedoc/modules/index.html +0 -1
  240. package/typedoc/modules/invitations.Invitation.html +0 -1
  241. package/typedoc/modules/invitations.html +0 -1
  242. package/typedoc/modules/mesh.NetworkStatus.html +0 -1
  243. package/typedoc/modules/mesh.html +0 -1
  244. package/typedoc/modules/worker.html +0 -1
  245. package/typedoc/modules.html +0 -1
  246. package/typedoc/types/devtools.MountOptions.html +0 -3
  247. package/typedoc/types/echo.AnyLiveObject.html +0 -2
  248. package/typedoc/types/echo.Filter.And.html +0 -1
  249. package/typedoc/types/echo.Filter.Any.html +0 -1
  250. package/typedoc/types/echo.Filter.Or.html +0 -1
  251. package/typedoc/types/echo.Filter.Props.html +0 -1
  252. package/typedoc/types/echo.Filter.Type.html +0 -1
  253. package/typedoc/types/echo.Live.html +0 -5
  254. package/typedoc/types/echo.ObjectMeta.html +0 -1
  255. package/typedoc/types/echo.ObjectMigration.html +0 -7
  256. package/typedoc/types/echo.ObjectVersion.html +0 -2
  257. package/typedoc/types/echo.PeerSyncState.html +0 -1
  258. package/typedoc/types/echo.Progress.html +0 -3
  259. package/typedoc/types/echo.PropertiesTypeProps.html +0 -1
  260. package/typedoc/types/echo.Query.Any.html +0 -1
  261. package/typedoc/types/echo.Query.TextSearchOptions.html +0 -2
  262. package/typedoc/types/echo.Query.Type.html +0 -1
  263. package/typedoc/types/echo.Ref.Target.html +0 -2
  264. package/typedoc/types/echo.Selection.html +0 -1
  265. package/typedoc/types/echo.SpaceId.html +0 -6
  266. package/typedoc/types/echo.SpaceSyncStateMap.html +0 -1
  267. package/typedoc/types/echo.UseQueueOptions.html +0 -2
  268. package/typedoc/types/echo.UseSpacesParams.html +0 -3
  269. package/typedoc/types/index.AgentHostingProviderProps.html +0 -3
  270. package/typedoc/types/index.ClientContextProps.html +0 -3
  271. package/typedoc/types/index.ClientOptions.html +0 -12
  272. package/typedoc/types/index.ClientProviderProps.html +0 -2
  273. package/typedoc/types/index.ClientServices.html +0 -15
  274. package/typedoc/types/index.FromAgentOptions.html +0 -2
  275. package/typedoc/types/index.PublicKeyLike.html +0 -2
  276. package/typedoc/types/invitations.InvitationAction.html +0 -1
  277. package/typedoc/types/invitations.InvitationResult.html +0 -5
  278. package/typedoc/types/invitations.InvitationStatus.html +0 -15
  279. package/typedoc/variables/devtools.mountDevtoolsHooks.html +0 -1
  280. package/typedoc/variables/devtools.unmountDevtoolsHooks.html +0 -1
  281. package/typedoc/variables/echo.DocAccessor.html +0 -1
  282. package/typedoc/variables/echo.EchoObjectSchema.html +0 -1
  283. package/typedoc/variables/echo.Expando.html +0 -1
  284. package/typedoc/variables/echo.FQ_ID_LENGTH.html +0 -1
  285. package/typedoc/variables/echo.Filter.html +0 -1
  286. package/typedoc/variables/echo.OBJECT_ID_LENGTH.html +0 -1
  287. package/typedoc/variables/echo.ObjectVersion.html +0 -1
  288. package/typedoc/variables/echo.Query.html +0 -1
  289. package/typedoc/variables/echo.Queue.html +0 -1
  290. package/typedoc/variables/echo.ReactiveObjectSchema.html +0 -1
  291. package/typedoc/variables/echo.Ref.html +0 -2
  292. package/typedoc/variables/echo.RefArray.html +0 -2
  293. package/typedoc/variables/echo.SPACE_ID_LENGTH.html +0 -1
  294. package/typedoc/variables/echo.SpaceId.html +0 -1
  295. package/typedoc/variables/echo.SpaceSchema.html +0 -1
  296. package/typedoc/variables/echo.TypedObject.html +0 -3
  297. package/typedoc/variables/echo.compareForeignKeys.html +0 -1
  298. package/typedoc/variables/echo.createDocAccessor.html +0 -1
  299. package/typedoc/variables/echo.createEmptyEdgeSyncState.html +0 -1
  300. package/typedoc/variables/echo.createObject.html +0 -1
  301. package/typedoc/variables/echo.createQueueDXN.html +0 -2
  302. package/typedoc/variables/echo.createSubscription.html +0 -5
  303. package/typedoc/variables/echo.defineObjectMigration.html +0 -1
  304. package/typedoc/variables/echo.fromCursor.html +0 -1
  305. package/typedoc/variables/echo.fullyQualifiedId.html +0 -4
  306. package/typedoc/variables/echo.getMeta.html +0 -1
  307. package/typedoc/variables/echo.getObjectCore.html +0 -1
  308. package/typedoc/variables/echo.getRangeFromCursor.html +0 -1
  309. package/typedoc/variables/echo.getSchema.html +0 -2
  310. package/typedoc/variables/echo.getSource.html +0 -4
  311. package/typedoc/variables/echo.getSpace.html +0 -1
  312. package/typedoc/variables/echo.getSyncSummary.html +0 -1
  313. package/typedoc/variables/echo.getTarget.html +0 -4
  314. package/typedoc/variables/echo.getTextInRange.html +0 -2
  315. package/typedoc/variables/echo.getType.html +0 -5
  316. package/typedoc/variables/echo.getTypename.html +0 -6
  317. package/typedoc/variables/echo.getVersion.html +0 -3
  318. package/typedoc/variables/echo.importSpace.html +0 -1
  319. package/typedoc/variables/echo.internalDecodeReference.html +0 -2
  320. package/typedoc/variables/echo.isEchoObject.html +0 -2
  321. package/typedoc/variables/echo.isLiveObject.html +0 -3
  322. package/typedoc/variables/echo.isRelation.html +0 -2
  323. package/typedoc/variables/echo.isSpace.html +0 -1
  324. package/typedoc/variables/echo.live.html +0 -3
  325. package/typedoc/variables/echo.loadObjectReferences.html +0 -7
  326. package/typedoc/variables/echo.parseFullyQualifiedId.html +0 -2
  327. package/typedoc/variables/echo.parseId.html +0 -1
  328. package/typedoc/variables/echo.toCursor.html +0 -1
  329. package/typedoc/variables/echo.toCursorRange.html +0 -1
  330. package/typedoc/variables/echo.updateText.html +0 -6
  331. package/typedoc/variables/echo.useQuery.html +0 -2
  332. package/typedoc/variables/index.AgentHostingContext.html +0 -1
  333. package/typedoc/variables/index.ClientProvider.html +0 -3
  334. package/typedoc/variables/index.DXOS_VERSION.html +0 -1
  335. package/typedoc/variables/index.Defaults.html +0 -2
  336. package/typedoc/variables/index.Dynamics.html +0 -2
  337. package/typedoc/variables/index.Envs.html +0 -2
  338. package/typedoc/variables/index.Local.html +0 -2
  339. package/typedoc/variables/index.Remote.html +0 -1
  340. package/typedoc/variables/index.Storage.html +0 -2
  341. package/typedoc/variables/index.createClientServices.html +0 -4
  342. package/typedoc/variables/index.fromAgent.html +0 -2
  343. package/typedoc/variables/index.fromHost.html +0 -2
  344. package/typedoc/variables/index.fromSocket.html +0 -2
  345. package/typedoc/variables/index.fromWorker.html +0 -2
  346. package/typedoc/variables/index.getUnixSocket.html +0 -1
  347. package/typedoc/variables/index.resolveRef.html +0 -1
  348. package/typedoc/variables/index.useMulticastObservable.html +0 -3
  349. package/typedoc/variables/worker.getWorkerServiceHost.html +0 -1
  350. package/typedoc/variables/worker.onconnect.html +0 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/testing/index.ts", "../../../../src/testing/context.tsx", "../../../../src/testing/ClientRepeater.tsx", "../../../../src/testing/withClientProvider.tsx"],
4
- "sourcesContent": ["//\n// Copyright 2020 DXOS.org\n//\n\nexport * from '@dxos/client/testing';\n\nexport * from './context';\nexport * from './ClientRepeater';\nexport * from './withClientProvider';\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { createContext, useContext } from 'react';\n\nimport { type Space } from '@dxos/client/echo';\nimport { raise } from '@dxos/debug';\n\nexport type ClientStory = {\n space?: Space;\n};\n\n// TODO(wittjosiah): Add to multi-client as well.\nexport const ClientStory = createContext<ClientStory | undefined>(undefined);\n\nexport const useClientProvider = (): ClientStory => {\n return useContext(ClientStory) ?? raise(new Error('Missing ClientStory'));\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport React, { useState, type FC, useEffect, useRef } from 'react';\n\nimport { Client, type PublicKey } from '@dxos/client';\nimport { TestBuilder, performInvitation } from '@dxos/client/testing';\nimport { type TypedObject } from '@dxos/echo-schema';\nimport { registerSignalsRuntime } from '@dxos/echo-signals/react';\nimport { faker } from '@dxos/random';\n\nimport { type WithClientProviderProps } from './withClientProvider';\nimport { ClientProvider } from '../client';\n\nexport type ClientRepeatedComponentProps = { id: number; count: number; spaceKey?: PublicKey };\n\nexport type ClientRepeaterControlsProps = { clients: Client[] };\n\n// TODO(burdon): Reconcile with ClientProviderProps.\nexport type ClientRepeaterProps<P extends ClientRepeatedComponentProps> = {\n className?: string;\n component: FC<ClientRepeatedComponentProps>;\n controls?: FC<ClientRepeaterControlsProps>;\n count?: number;\n clients?: Client[];\n types?: TypedObject[];\n args?: Omit<P, 'id' | 'count'>;\n} & Pick<WithClientProviderProps, 'createIdentity' | 'createSpace' | 'onSpaceCreated'>;\n\n/**\n * Utility component for Storybook stories which sets up clients for n peers.\n * The `Component` property is rendered n times, once for each peer.\n * @deprecated use `withClientProvider`.\n */\n// TODO(burdon): To discuss: evolve ClientRepeater with optional decorator that uses it.\n// NOTE: This is specifically not a storybook decorator because it broke stories as a decorator.\n// This seems primarily due to the fact that it required top-level await for the clients to initialize.\n// Storybook seemed to handle it alright, but Chromatic had a lot of trouble with it.\n// There was also a question of whether or not calling the story function multiple times was a good idea.\nexport const ClientRepeater = <P extends ClientRepeatedComponentProps>(props: ClientRepeaterProps<P>) => {\n const {\n component: Component,\n controls: Controls,\n count = 1,\n types,\n createIdentity,\n createSpace,\n onSpaceCreated,\n } = props;\n useEffect(() => {\n registerSignalsRuntime();\n }, []);\n\n const [clients, setClients] = useState(props.clients ?? []);\n const [spaceKey, setSpaceKey] = useState<PublicKey>();\n\n const testBuilder = useRef(new TestBuilder());\n useEffect(() => {\n const timeout = setTimeout(async () => {\n const clients = [...Array(count)].map(\n (_) => new Client({ services: testBuilder.current.createLocalClientServices(), types }),\n );\n\n await Promise.all(clients.map((client) => client.initialize()));\n if (createIdentity || createSpace) {\n await Promise.all(clients.map((client) => client.halo.createIdentity()));\n }\n\n if (createSpace) {\n const client = clients[0];\n const space = await client.spaces.create({ name: faker.commerce.productName() });\n setSpaceKey(space.key);\n await onSpaceCreated?.({ client, space }, {});\n await Promise.all(\n clients.slice(1).flatMap((client) => performInvitation({ host: space, guest: client.spaces })),\n );\n }\n\n setClients(clients);\n });\n\n return () => clearTimeout(timeout);\n }, []);\n\n if (clients.length === 0) {\n return null;\n }\n\n return (\n <>\n {Controls && <Controls clients={clients} />}\n {clients.map((client, index) => (\n <ClientProvider key={index} client={client}>\n <Component id={index} count={clients.length} spaceKey={spaceKey} {...{ ...props.args }} />\n </ClientProvider>\n ))}\n </>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type StoryContext, type Decorator } from '@storybook/react';\nimport React, { createContext, type PropsWithChildren, useContext, useEffect, useRef, useState } from 'react';\nimport { type FallbackProps, ErrorBoundary as NativeErrorBoundary } from 'react-error-boundary';\n\nimport { Trigger } from '@dxos/async';\nimport { type Client } from '@dxos/client';\nimport { type Space } from '@dxos/client/echo';\nimport { performInvitation, TestBuilder } from '@dxos/client/testing';\nimport { log } from '@dxos/log';\nimport { type MaybePromise } from '@dxos/util';\n\nimport { ClientStory } from './context';\nimport { ClientProvider, type ClientProviderProps } from '../client';\n\ntype InitializeProps = {\n createIdentity?: boolean;\n createSpace?: boolean;\n onInitialized?: (client: Client) => MaybePromise<void>;\n onIdentityCreated?: (props: { client: Client }) => MaybePromise<void>;\n // NOTE: context must be untyped until ClientRepeater is removed.\n onSpaceCreated?: (props: { client: Client; space: Space }, context: StoryContext | any) => MaybePromise<void>;\n};\n\n/**\n * Initialize client, identity and first space.\n */\nconst initializeClient = async (\n client: Client,\n { createIdentity, createSpace, onSpaceCreated, onIdentityCreated, onInitialized }: InitializeProps,\n context: StoryContext,\n): Promise<ClientStory> => {\n await onInitialized?.(client);\n\n if (createIdentity || createSpace) {\n if (!client.halo.identity.get()) {\n await client.halo.createIdentity();\n await onIdentityCreated?.({ client });\n }\n }\n\n let space: Space | undefined;\n if (createSpace) {\n space = await client.spaces.create({ name: 'Test Space' });\n await onSpaceCreated?.({ client, space }, context);\n }\n\n return { space };\n};\n\nexport type WithClientProviderProps = InitializeProps & Omit<ClientProviderProps, 'onInitialized'>;\n\n/**\n * Decorator that provides the client context.\n */\nexport const withClientProvider = ({\n createIdentity,\n createSpace,\n onSpaceCreated,\n onIdentityCreated,\n onInitialized,\n ...props\n}: WithClientProviderProps = {}): Decorator => {\n return (Story, context) => {\n const [data, setData] = useState<ClientStory>({});\n const handleInitialized = async (client: Client) => {\n const data = await initializeClient(\n client,\n {\n createIdentity,\n createSpace,\n onSpaceCreated,\n onIdentityCreated,\n onInitialized,\n },\n context,\n );\n\n setData(data);\n };\n\n return (\n <ErrorBoundary>\n <ClientProvider onInitialized={handleInitialized} {...props}>\n <ClientStory.Provider value={data}>\n <Story />\n </ClientStory.Provider>\n </ClientProvider>\n </ErrorBoundary>\n );\n };\n};\n\n// TODO(burdon): Implement context per client for context.\n// TODO(burdon): Callback once all invitations have completed.\n// TODO(burdon): Delay/jitter for creation of other clients.\nexport type WithMultiClientProviderProps = InitializeProps &\n Omit<ClientProviderProps, 'onInitialized'> & { numClients?: number };\n\nconst MultiClientContext = createContext<{ id: number }>({ id: 0 });\n\nexport const useMultiClient = () => useContext(MultiClientContext);\n\n/**\n * Decorator that creates a scaffold for multiple clients.\n * Orchestrates invitations between a randomly selected host and the remaining clients.\n * NOTE: Should come before withLayout.\n */\nexport const withMultiClientProvider = ({\n numClients = 2,\n createIdentity,\n createSpace,\n onSpaceCreated,\n onIdentityCreated,\n onInitialized,\n ...props\n}: WithMultiClientProviderProps): Decorator => {\n return (Story, context) => {\n const builder = useRef(new TestBuilder());\n const hostRef = useRef<Client>();\n const spaceReady = useRef(new Trigger<Space | undefined>());\n\n // Handle invitations.\n // NOTE: The zeroth client isn't necessarily the first to be initialized.\n const handleInitialized = async (client: Client, index: number) => {\n log.info('initialized', { index });\n if (createSpace) {\n if (!hostRef.current) {\n hostRef.current = client;\n const { space } = await initializeClient(\n client,\n {\n createIdentity,\n createSpace,\n onSpaceCreated,\n onIdentityCreated,\n onInitialized,\n },\n context,\n );\n\n spaceReady.current.wake(space);\n log.info('inviting', { index });\n } else {\n await initializeClient(client, { createIdentity, onInitialized }, context);\n const space = await spaceReady.current.wait();\n if (space) {\n log.info('joining', { index });\n await Promise.all(performInvitation({ host: space, guest: client.spaces }));\n }\n }\n }\n };\n\n return (\n <ErrorBoundary>\n {Array.from({ length: numClients }).map((_, index) => (\n <MultiClientContext.Provider key={index} value={{ id: index }}>\n <ClientProvider\n services={builder.current.createLocalClientServices()}\n onInitialized={(client) => handleInitialized(client, index)}\n {...props}\n >\n <Story />\n </ClientProvider>\n </MultiClientContext.Provider>\n ))}\n </ErrorBoundary>\n );\n };\n};\n\nconst ErrorBoundary = ({ children }: PropsWithChildren) => {\n const [error, setError] = useState<Error>();\n useEffect(() => {\n const handleError = (event: PromiseRejectionEvent) => {\n setError(event.reason);\n };\n\n window.addEventListener('unhandledrejection', handleError);\n return () => window.removeEventListener('unhandledrejection', handleError);\n }, []);\n\n if (error) {\n return <ErrorFallback error={error} resetErrorBoundary={() => setError(undefined)} />;\n }\n\n return <NativeErrorBoundary FallbackComponent={ErrorFallback}>{children}</NativeErrorBoundary>;\n};\n\nconst ErrorFallback = ({ error }: FallbackProps) => {\n const { name, message, stack } =\n error instanceof Error ? error : { name: 'Error', message: String(error), stack: undefined };\n return (\n <div role='alert' className='flex flex-col p-4 gap-4 overflow-auto'>\n <h1 className='text-xl text-red-500'>{name}</h1>\n <div className='text-lg'>{message}</div>\n {stack && <pre className='whitespace-pre-wrap text-sm text-subdued'>{stack}</pre>}\n </div>\n );\n};\n"],
5
- "mappings": ";;;;;AAIA,cAAc;;;ACAd,SAASA,eAAeC,kBAAkB;AAG1C,SAASC,aAAa;AAOf,IAAMC,cAAcC,8BAAuCC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AEL,MAAIH,OAAO;AACT,WAAO,gBAAAvC,OAAA,cAACgD,eAAAA;MAAcT;MAAcU,oBAAoB,MAAMT,SAASU,MAAAA;;EACzE;AAEA,SAAO,gBAAAlD,OAAA,cAACmD,qBAAAA;IAAoBC,mBAAmBJ;KAAgBV,QAAAA;AACjE;AAEA,IAAMU,gBAAgB,CAAC,EAAET,MAAK,MAAiB;AAC7C,QAAM,EAAE/C,MAAM6D,SAASC,MAAK,IAC1Bf,iBAAiBgB,QAAQhB,QAAQ;IAAE/C,MAAM;IAAS6D,SAASG,OAAOjB,KAAAA;IAAQe,OAAOJ;EAAU;AAC7F,SACE,gBAAAlD,OAAA,cAACyD,OAAAA;IAAIC,MAAK;IAAQC,WAAU;KAC1B,gBAAA3D,OAAA,cAAC4D,MAAAA;IAAGD,WAAU;KAAwBnE,IAAAA,GACtC,gBAAAQ,OAAA,cAACyD,OAAAA;IAAIE,WAAU;KAAWN,OAAAA,GACzBC,SAAS,gBAAAtD,OAAA,cAAC6D,OAAAA;IAAIF,WAAU;KAA4CL,KAAAA,CAAAA;AAG3E;",
6
- "names": ["createContext", "useContext", "raise", "ClientStory", "createContext", "undefined", "useClientProvider", "useContext", "raise", "Error", "React", "useState", "useEffect", "useRef", "Client", "TestBuilder", "performInvitation", "registerSignalsRuntime", "faker", "ClientRepeater", "props", "component", "Component", "controls", "Controls", "count", "types", "createIdentity", "createSpace", "onSpaceCreated", "useEffect", "registerSignalsRuntime", "clients", "setClients", "useState", "spaceKey", "setSpaceKey", "testBuilder", "useRef", "TestBuilder", "timeout", "setTimeout", "Array", "map", "_", "Client", "services", "current", "createLocalClientServices", "Promise", "all", "client", "initialize", "halo", "space", "spaces", "create", "name", "faker", "commerce", "productName", "key", "slice", "flatMap", "performInvitation", "host", "guest", "clearTimeout", "length", "index", "ClientProvider", "id", "args", "React", "createContext", "useContext", "useEffect", "useRef", "useState", "ErrorBoundary", "NativeErrorBoundary", "Trigger", "performInvitation", "TestBuilder", "log", "initializeClient", "client", "createIdentity", "createSpace", "onSpaceCreated", "onIdentityCreated", "onInitialized", "context", "halo", "identity", "get", "space", "spaces", "create", "name", "withClientProvider", "props", "Story", "data", "setData", "useState", "handleInitialized", "React", "ErrorBoundary", "ClientProvider", "ClientStory", "Provider", "value", "MultiClientContext", "createContext", "id", "useMultiClient", "useContext", "withMultiClientProvider", "numClients", "builder", "useRef", "TestBuilder", "hostRef", "spaceReady", "Trigger", "index", "log", "info", "current", "wake", "wait", "Promise", "all", "performInvitation", "host", "guest", "Array", "from", "length", "map", "_", "key", "services", "createLocalClientServices", "children", "error", "setError", "useEffect", "handleError", "event", "reason", "window", "addEventListener", "removeEventListener", "ErrorFallback", "resetErrorBoundary", "undefined", "NativeErrorBoundary", "FallbackComponent", "message", "stack", "Error", "String", "div", "role", "className", "h1", "pre"]
4
+ "sourcesContent": ["//\n// Copyright 2020 DXOS.org\n//\n\nexport * from '@dxos/client/testing';\n\nexport * from './context';\nexport * from './ClientRepeater';\nexport * from './withClientProvider';\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { createContext, useContext } from 'react';\n\nimport { type Space } from '@dxos/client/echo';\nimport { raise } from '@dxos/debug';\n\nexport type ClientStory = {\n space?: Space;\n};\n\n// TODO(wittjosiah): Add to multi-client as well.\nexport const ClientStory = createContext<ClientStory | undefined>(undefined);\n\nexport const useClientProvider = (): ClientStory => {\n return useContext(ClientStory) ?? raise(new Error('Missing ClientStory'));\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport React, { type FC, useEffect, useRef, useState } from 'react';\n\nimport { Client, type PublicKey } from '@dxos/client';\nimport { TestBuilder, performInvitation } from '@dxos/client/testing';\nimport { type TypedObject } from '@dxos/echo/internal';\nimport { registerSignalsRuntime } from '@dxos/echo-signals/react';\nimport { faker } from '@dxos/random';\nimport { useAsyncEffect } from '@dxos/react-hooks';\n\nimport { ClientProvider } from '../client';\n\nimport { type WithClientProviderProps } from './withClientProvider';\n\nexport type ClientRepeatedComponentProps = { id: number; count: number; spaceKey?: PublicKey };\n\nexport type ClientRepeaterControlsProps = { clients: Client[] };\n\n// TODO(burdon): Reconcile with ClientProviderProps.\nexport type ClientRepeaterProps<P extends ClientRepeatedComponentProps> = {\n className?: string;\n component: FC<ClientRepeatedComponentProps>;\n controls?: FC<ClientRepeaterControlsProps>;\n count?: number;\n clients?: Client[];\n types?: TypedObject[];\n args?: Omit<P, 'id' | 'count'>;\n} & Pick<WithClientProviderProps, 'createIdentity' | 'createSpace' | 'onCreateSpace'>;\n\n/**\n * Utility component for Storybook stories which sets up clients for n peers.\n * The `Component` property is rendered n times, once for each peer.\n * @deprecated use `withClientProvider`.\n */\n// TODO(burdon): To discuss: evolve ClientRepeater with optional decorator that uses it.\n// NOTE: This is specifically not a storybook decorator because it broke stories as a decorator.\n// This seems primarily due to the fact that it required top-level await for the clients to initialize.\n// Storybook seemed to handle it alright, but Chromatic had a lot of trouble with it.\n// There was also a question of whether or not calling the story function multiple times was a good idea.\nexport const ClientRepeater = <P extends ClientRepeatedComponentProps>(props: ClientRepeaterProps<P>) => {\n const {\n component: Component,\n controls: Controls,\n count = 1,\n types,\n createIdentity,\n createSpace,\n onCreateSpace,\n } = props;\n useEffect(() => {\n registerSignalsRuntime();\n }, []);\n\n const [clients, setClients] = useState(props.clients ?? []);\n const [spaceKey, setSpaceKey] = useState<PublicKey>();\n\n const testBuilder = useRef(new TestBuilder());\n useAsyncEffect(async () => {\n const clients = [...Array(count)].map(\n (_) => new Client({ services: testBuilder.current.createLocalClientServices(), types }),\n );\n\n await Promise.all(clients.map((client) => client.initialize()));\n if (createIdentity || createSpace) {\n await Promise.all(clients.map((client) => client.halo.createIdentity()));\n }\n\n if (createSpace) {\n const client = clients[0];\n const space = await client.spaces.create({ name: faker.commerce.productName() });\n setSpaceKey(space.key);\n await onCreateSpace?.({ client, space }, {});\n await Promise.all(clients.slice(1).flatMap((client) => performInvitation({ host: space, guest: client.spaces })));\n }\n\n setClients(clients);\n }, []);\n\n if (clients.length === 0) {\n return null;\n }\n\n return (\n <>\n {Controls && <Controls clients={clients} />}\n {clients.map((client, index) => (\n <ClientProvider key={index} client={client}>\n <Component id={index} count={clients.length} spaceKey={spaceKey} {...{ ...props.args }} />\n </ClientProvider>\n ))}\n </>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type Decorator, type StoryContext } from '@storybook/react';\nimport React, { type PropsWithChildren, createContext, useContext, useEffect, useRef, useState } from 'react';\nimport { type FallbackProps, ErrorBoundary as NaturalErrorBoundary } from 'react-error-boundary';\n\nimport { Trigger } from '@dxos/async';\nimport { type Client } from '@dxos/client';\nimport { type Space } from '@dxos/client/echo';\nimport { TestBuilder, performInvitation } from '@dxos/client/testing';\nimport { log } from '@dxos/log';\nimport { type MaybePromise } from '@dxos/util';\n\nimport { ClientProvider, type ClientProviderProps } from '../client';\n\nimport { ClientStory } from './context';\n\ntype InitializeProps = {\n createIdentity?: boolean;\n createSpace?: boolean;\n onInitialized?: (client: Client) => MaybePromise<void>;\n onCreateIdentity?: (props: { client: Client }, context: StoryContext | any) => MaybePromise<void>;\n // NOTE: context must be untyped until ClientRepeater is removed.\n onCreateSpace?: (props: { client: Client; space: Space }, context: StoryContext | any) => MaybePromise<void>;\n};\n\n/**\n * Initialize client, identity and first space.\n */\nconst initializeClient = async (\n client: Client,\n { createIdentity, createSpace, onCreateIdentity, onCreateSpace, onInitialized }: InitializeProps,\n context: StoryContext,\n): Promise<ClientStory> => {\n await onInitialized?.(client);\n\n if (createIdentity || createSpace) {\n if (!client.halo.identity.get()) {\n await client.halo.createIdentity();\n await client.spaces.waitUntilReady();\n await client.spaces.default.waitUntilReady();\n await onCreateIdentity?.({ client }, context);\n }\n }\n\n let space: Space | undefined;\n if (createSpace) {\n space = await client.spaces.create({ name: 'Test Space' });\n await space.waitUntilReady(); // Is this required?\n await onCreateSpace?.({ client, space }, context);\n }\n\n return { space };\n};\n\nexport type WithClientProviderProps = InitializeProps & Omit<ClientProviderProps, 'onInitialized'>;\n\n/**\n * Decorator that provides the client context.\n */\nexport const withClientProvider = ({\n createIdentity,\n createSpace,\n onCreateSpace,\n onCreateIdentity,\n onInitialized,\n ...props\n}: WithClientProviderProps = {}): Decorator => {\n return (Story, context) => {\n const [data, setData] = useState<ClientStory>({});\n const handleInitialized = async (client: Client) => {\n const data = await initializeClient(\n client,\n {\n createIdentity,\n createSpace,\n onCreateSpace,\n onCreateIdentity,\n onInitialized,\n },\n context,\n );\n\n setData(data);\n };\n\n return (\n <ErrorBoundary>\n <ClientProvider onInitialized={handleInitialized} {...props}>\n <ClientStory.Provider value={data}>\n <Story />\n </ClientStory.Provider>\n </ClientProvider>\n </ErrorBoundary>\n );\n };\n};\n\n// TODO(burdon): Implement context per client for context.\n// TODO(burdon): Callback once all invitations have completed.\n// TODO(burdon): Delay/jitter for creation of other clients.\nexport type WithMultiClientProviderProps = InitializeProps &\n Omit<ClientProviderProps, 'onInitialized'> & { numClients?: number };\n\nconst MultiClientContext = createContext<{ id: number }>({ id: 0 });\n\nexport const useMultiClient = () => useContext(MultiClientContext);\n\n/**\n * Decorator that creates a scaffold for multiple clients.\n * Orchestrates invitations between a randomly selected host and the remaining clients.\n */\nexport const withMultiClientProvider = ({\n numClients = 2,\n createIdentity,\n createSpace,\n onCreateSpace,\n onCreateIdentity,\n onInitialized,\n ...props\n}: WithMultiClientProviderProps): Decorator => {\n return (Story, context) => {\n const builder = useRef(new TestBuilder());\n const hostRef = useRef<Client>(null);\n const spaceReady = useRef(new Trigger<Space | undefined>());\n\n // Handle invitations.\n // NOTE: The zeroth client isn't necessarily the first to be initialized.\n const handleInitialized = async (client: Client, index: number) => {\n log.info('initialized', { index });\n if (createSpace) {\n if (!hostRef.current) {\n hostRef.current = client;\n const { space } = await initializeClient(\n client,\n {\n createIdentity,\n createSpace,\n onCreateSpace,\n onCreateIdentity,\n onInitialized,\n },\n context,\n );\n\n spaceReady.current.wake(space);\n log.info('inviting', { index });\n } else {\n await initializeClient(client, { createIdentity, onInitialized }, context);\n const space = await spaceReady.current.wait();\n if (space) {\n log.info('joining', { index });\n await Promise.all(performInvitation({ host: space, guest: client.spaces }));\n }\n }\n }\n };\n\n return (\n <ErrorBoundary>\n {Array.from({ length: numClients }).map((_, index) => (\n <MultiClientContext.Provider key={index} value={{ id: index }}>\n <ClientProvider\n services={builder.current.createLocalClientServices()}\n onInitialized={(client) => handleInitialized(client, index)}\n {...props}\n >\n <Story />\n </ClientProvider>\n </MultiClientContext.Provider>\n ))}\n </ErrorBoundary>\n );\n };\n};\n\nconst ErrorBoundary = ({ children }: PropsWithChildren) => {\n const [error, setError] = useState<Error>();\n useEffect(() => {\n const handleError = (event: PromiseRejectionEvent) => {\n setError(event.reason);\n };\n\n window.addEventListener('unhandledrejection', handleError);\n return () => window.removeEventListener('unhandledrejection', handleError);\n }, []);\n\n if (error) {\n return <ErrorFallback error={error} resetErrorBoundary={() => setError(undefined)} />;\n }\n\n return <NaturalErrorBoundary FallbackComponent={ErrorFallback}>{children}</NaturalErrorBoundary>;\n};\n\nconst ErrorFallback = ({ error }: FallbackProps) => {\n const { name, message, stack } =\n error instanceof Error ? error : { name: 'Error', message: String(error), stack: undefined };\n return (\n <div role='alert' className='flex flex-col p-4 gap-4 overflow-auto'>\n <h1 className='text-xl text-red-500'>{name}</h1>\n <div className='text-lg'>{message}</div>\n {stack && <pre className='whitespace-pre-wrap text-sm text-subdued'>{stack}</pre>}\n </div>\n );\n};\n"],
5
+ "mappings": ";;;;;AAIA,cAAc;;;ACAd,SAASA,eAAeC,kBAAkB;AAG1C,SAASC,aAAa;AAOf,IAAMC,cAAcC,8BAAuCC,MAAAA;AAE3D,IAAMC,oBAAoB,MAAA;AAC/B,SAAOC,WAAWJ,WAAAA,KAAgBK,MAAM,IAAIC,MAAM,qBAAA,CAAA;AACpD;;;ACdA,OAAOC,SAAkBC,WAAWC,QAAQC,gBAAgB;AAE5D,SAASC,cAA8B;AACvC,SAASC,aAAaC,yBAAyB;AAE/C,SAASC,8BAA8B;AACvC,SAAS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QAAAA;AAClE;AAEA,IAAMU,gBAAgB,CAAC,EAAET,MAAK,MAAiB;AAC7C,QAAM,EAAE/C,MAAM6D,SAASC,MAAK,IAC1Bf,iBAAiBgB,QAAQhB,QAAQ;IAAE/C,MAAM;IAAS6D,SAASG,OAAOjB,KAAAA;IAAQe,OAAOJ;EAAU;AAC7F,SACE,gBAAAlD,OAAA,cAACyD,OAAAA;IAAIC,MAAK;IAAQC,WAAU;KAC1B,gBAAA3D,OAAA,cAAC4D,MAAAA;IAAGD,WAAU;KAAwBnE,IAAAA,GACtC,gBAAAQ,OAAA,cAACyD,OAAAA;IAAIE,WAAU;KAAWN,OAAAA,GACzBC,SAAS,gBAAAtD,OAAA,cAAC6D,OAAAA;IAAIF,WAAU;KAA4CL,KAAAA,CAAAA;AAG3E;",
6
+ "names": ["createContext", "useContext", "raise", "ClientStory", "createContext", "undefined", "useClientProvider", "useContext", "raise", "Error", "React", "useEffect", "useRef", "useState", "Client", "TestBuilder", "performInvitation", "registerSignalsRuntime", "faker", "useAsyncEffect", "ClientRepeater", "props", "component", "Component", "controls", "Controls", "count", "types", "createIdentity", "createSpace", "onCreateSpace", "useEffect", "registerSignalsRuntime", "clients", "setClients", "useState", "spaceKey", "setSpaceKey", "testBuilder", "useRef", "TestBuilder", "useAsyncEffect", "Array", "map", "_", "Client", "services", "current", "createLocalClientServices", "Promise", "all", "client", "initialize", "halo", "space", "spaces", "create", "name", "faker", "commerce", "productName", "key", "slice", "flatMap", "performInvitation", "host", "guest", "length", "index", "ClientProvider", "id", "args", "React", "createContext", "useContext", "useEffect", "useRef", "useState", "ErrorBoundary", "NaturalErrorBoundary", "Trigger", "TestBuilder", "performInvitation", "log", "initializeClient", "client", "createIdentity", "createSpace", "onCreateIdentity", "onCreateSpace", "onInitialized", "context", "halo", "identity", "get", "spaces", "waitUntilReady", "default", "space", "create", "name", "withClientProvider", "props", "Story", "data", "setData", "useState", "handleInitialized", "React", "ErrorBoundary", "ClientProvider", "ClientStory", "Provider", "value", "MultiClientContext", "createContext", "id", "useMultiClient", "useContext", "withMultiClientProvider", "numClients", "builder", "useRef", "TestBuilder", "hostRef", "spaceReady", "Trigger", "index", "log", "info", "current", "wake", "wait", "Promise", "all", "performInvitation", "host", "guest", "Array", "from", "length", "map", "_", "key", "services", "createLocalClientServices", "children", "error", "setError", "useEffect", "handleError", "event", "reason", "window", "addEventListener", "removeEventListener", "ErrorFallback", "resetErrorBoundary", "undefined", "NaturalErrorBoundary", "FallbackComponent", "message", "stack", "Error", "String", "div", "role", "className", "h1", "pre"]
7
7
  }
@@ -4,18 +4,18 @@ import { createRequire } from 'node:module';const require = createRequire(import
4
4
  import { AuthenticatingInvitationObservable, CancellableInvitationObservable, InvitationEncoder as InvitationEncoder2, Invitation as Invitation2, InvitationsProxy } from "@dxos/client/invitations";
5
5
 
6
6
  // src/invitations/useInvitationStatus.ts
7
- import { useReducer, useMemo, useCallback, useEffect } from "react";
7
+ import { useCallback, useEffect, useMemo, useReducer } from "react";
8
8
  import { Invitation, InvitationEncoder } from "@dxos/client/invitations";
9
9
  import { log } from "@dxos/log";
10
10
  var __dxlog_file = "/__w/dxos/dxos/packages/sdk/react-client/src/invitations/useInvitationStatus.ts";
11
- var isShareableInvitation = (invitation) => invitation.authMethod !== Invitation.AuthMethod.KNOWN_PUBLIC_KEY || invitation.guestKeypair?.privateKey;
11
+ var isShareableInvitation = (invitation) => invitation.authMethod !== Invitation.AuthMethod.KNOWN_PUBLIC_KEY || !!invitation.guestKeypair?.privateKey;
12
12
  var useInvitationStatus = (observable) => {
13
13
  const [state, dispatch] = useReducer((prev, action) => {
14
14
  log("useInvitationStatus", {
15
15
  action
16
16
  }, {
17
17
  F: __dxlog_file,
18
- L: 90,
18
+ L: 91,
19
19
  S: void 0,
20
20
  C: (f, a) => f(...a)
21
21
  });
@@ -128,7 +128,7 @@ var useInvitationStatus = (observable) => {
128
128
  authCode
129
129
  }, {
130
130
  F: __dxlog_file,
131
- L: 195,
131
+ L: 196,
132
132
  S: void 0,
133
133
  C: (f, a) => f(...a)
134
134
  });
@@ -162,4 +162,4 @@ export {
162
162
  Invitation2 as Invitation,
163
163
  InvitationsProxy
164
164
  };
165
- //# sourceMappingURL=chunk-TU2JJLZK.mjs.map
165
+ //# sourceMappingURL=chunk-AQJH2UNZ.mjs.map
@@ -0,0 +1,7 @@
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 { useCallback, useEffect, useMemo, useReducer } 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?: Error;\n id?: string;\n multiUse?: boolean;\n shareable?: boolean;\n invitationCode?: string;\n authCode?: string;\n authMethod?: Invitation.AuthMethod;\n type?: Invitation.Type;\n}\n\ntype InvitationPayload = { invitation: Invitation };\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 } & InvitationPayload)\n | ({\n status: Invitation.State.CONNECTING;\n observable: CancellableInvitationObservable;\n } & InvitationPayload)\n | ({\n status: Invitation.State.SUCCESS;\n result: InvitationResult;\n } & InvitationPayload)\n | ({\n status: Invitation.State.CANCELLED | Invitation.State.TIMEOUT;\n haltedAt: Invitation.State;\n } & InvitationPayload)\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 multiUse?: boolean;\n shareable?: boolean;\n result: InvitationResult;\n error?: Error;\n cancel(): void;\n // TODO(wittjosiah): Remove?\n connect(observable: CancellableInvitationObservable): void;\n authenticate(authCode: string): Promise<void>;\n};\n\n// Without private key, the invitation code cannot be created.\n// These invitations are only available to be accepted but not shared.\nconst isShareableInvitation = (invitation: Invitation) =>\n invitation.authMethod !== Invitation.AuthMethod.KNOWN_PUBLIC_KEY || !!invitation.guestKeypair?.privateKey;\n\nexport const useInvitationStatus = (observable?: CancellableInvitationObservable): InvitationStatus => {\n const [state, dispatch] = useReducer(\n (prev: InvitationReducerState, action: InvitationAction): InvitationReducerState => {\n log('useInvitationStatus', { action });\n const invitationProps =\n 'invitation' in action\n ? {\n id: action.invitation.invitationId,\n multiUse: action.invitation.multiUse,\n invitationCode: InvitationEncoder.encode(action.invitation),\n authCode: action.invitation.authCode,\n authMethod: action.invitation.authMethod,\n shareable: isShareableInvitation(action.invitation),\n type: action.invitation.type,\n }\n : {};\n return {\n ...prev,\n ...invitationProps,\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 };\n },\n null,\n (_arg: null): InvitationReducerState => {\n const invitation = observable?.get();\n return {\n status: Invitation.State.INIT,\n result: { spaceKey: null, identityKey: null, swarmKey: null, target: null },\n id: invitation?.invitationId,\n multiUse: invitation?.multiUse,\n invitationCode: invitation ? InvitationEncoder.encode(invitation) : undefined,\n authCode: invitation?.authCode,\n authMethod: invitation?.authMethod,\n shareable: invitation ? isShareableInvitation(invitation) : false,\n type: invitation?.type,\n };\n },\n );\n\n // Handle unmount.\n\n useEffect(() => {\n const update = (invitation: Invitation) => {\n switch (invitation.state) {\n case Invitation.State.INIT:\n case Invitation.State.CONNECTED:\n case Invitation.State.READY_FOR_AUTHENTICATION:\n case Invitation.State.AUTHENTICATING: {\n dispatch({\n invitation,\n status: invitation.state,\n });\n break;\n }\n\n case Invitation.State.SUCCESS: {\n dispatch({\n invitation,\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({ invitation, status: invitation.state, haltedAt: state.status });\n break;\n }\n }\n };\n\n const subscription = observable?.subscribe(update, (err: Error) => {\n dispatch({ status: Invitation.State.ERROR, error: err, haltedAt: state.status });\n });\n\n const currentState = observable?.get();\n if (currentState) {\n update(currentState);\n }\n\n return () => subscription?.unsubscribe();\n }, [observable, state.status]);\n\n // Return memoized callbacks & values.\n\n const connect = useCallback((observable: CancellableInvitationObservable) => {\n dispatch({ invitation: observable.get(), status: Invitation.State.CONNECTING, observable });\n }, []);\n\n const authenticate = useCallback(\n (authCode: string) => {\n log('authenticating...', { authCode });\n return (observable as AuthenticatingInvitationObservable).authenticate(authCode);\n },\n [observable],\n );\n\n const cancel = useCallback(async () => observable?.cancel(), [observable]);\n\n return useMemo(() => {\n return {\n ...state,\n cancel,\n connect,\n authenticate,\n };\n }, [state, cancel, connect, authen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AYwB,IAAAA;AACjC,QAAIc,cAAc;AAChBP,aAAOO,YAAAA;IACT;AAEA,WAAO,MAAMH,cAAcI,YAAAA;EAC7B,GAAG;IAACvC;IAAYC,MAAMa;GAAO;AAI7B,QAAM0B,UAAUvD,YAAY,CAACe,gBAAAA;AAC3BE,aAAS;MAAET,YAAYO,YAAWwB,IAAG;MAAIV,QAAQzB,WAAW2B,MAAMyB;MAAYzC,YAAAA;IAAW,CAAA;EAC3F,GAAG,CAAA,CAAE;AAEL,QAAM0C,eAAezD,YACnB,CAAC0B,aAAAA;AACCpB,QAAI,qBAAqB;MAAEoB;IAAS,GAAA;;;;;;AACpC,WAAQX,WAAkD0C,aAAa/B,QAAAA;EACzE,GACA;IAACX;GAAW;AAGd,QAAM2C,SAAS1D,YAAY,YAAYe,YAAY2C,OAAAA,GAAU;IAAC3C;GAAW;AAEzE,SAAOb,QAAQ,MAAA;AACb,WAAO;MACL,GAAGc;MACH0C;MACAH;MACAE;IACF;EACF,GAAG;IAACzC;IAAO0C;IAAQH;IAASE;GAAa;AAC3C;",
6
+ "names": ["AuthenticatingInvitationObservable", "CancellableInvitationObservable", "InvitationEncoder", "Invitation", "InvitationsProxy", "useCallback", "useEffect", "useMemo", "useReducer", "Invitation", "InvitationEncoder", "log", "isShareableInvitation", "invitation", "authMethod", "AuthMethod", "KNOWN_PUBLIC_KEY", "guestKeypair", "privateKey", "useInvitationStatus", "observable", "state", "dispatch", "prev", "action", "invitationProps", "id", "invitationId", "multiUse", "invitationCode", "encode", "authCode", "shareable", "type", "status", "result", "State", "SUCCESS", "ERROR", "error", "CANCELLED", "TIMEOUT", "haltedAt", "_arg", "get", "INIT", "spaceKey", "identityKey", "swarmKey", "target", "undefined", "update", "CONNECTED", "READY_FOR_AUTHENTICATION", "AUTHENTICATING", "subscription", "subscribe", "err", "currentState", "unsubscribe", "connect", "CONNECTING", "authenticate", "cancel"]
7
+ }
@@ -10,13 +10,9 @@ import React, { forwardRef, useEffect, useImperativeHandle, useState } from "rea
10
10
  import { Client, SystemStatus } from "@dxos/client";
11
11
  import { registerSignalsRuntime } from "@dxos/echo-signals/react";
12
12
  import { log } from "@dxos/log";
13
- import { useControlledState } from "@dxos/react-hooks";
13
+ import { useAsyncEffect, useControlledState } from "@dxos/react-hooks";
14
14
  import { getAsyncProviderValue } from "@dxos/util";
15
15
 
16
- // src/client/context.ts
17
- import { createContext } from "react";
18
- var ClientContext = createContext(void 0);
19
-
20
16
  // src/banner.ts
21
17
  var BANNER = (client) => {
22
18
  const commitHash = client.config.get("runtime.app.build.commitHash");
@@ -41,9 +37,13 @@ var printBanner = (client) => {
41
37
  console.log(`%c${BANNER(client)}`, "font-family: monospace;");
42
38
  };
43
39
 
40
+ // src/client/context.ts
41
+ import { createContext } from "react";
42
+ var ClientContext = createContext(void 0);
43
+
44
44
  // src/client/ClientProvider.tsx
45
45
  var __dxlog_file = "/__w/dxos/dxos/packages/sdk/react-client/src/client/ClientProvider.tsx";
46
- var ClientProvider = /* @__PURE__ */ forwardRef(({ children, config: configProvider, client: clientProvider, services: servicesProvider, status: controlledStatus, fallback: Fallback = () => null, signalsRuntime = true, noBanner, onInitialized, ...options }, forwardedRef) => {
46
+ var ClientProvider = /* @__PURE__ */ forwardRef(({ children, config: configParam, client: clientParam, services: servicesParam, status: statusParam, fallback: Fallback = () => null, signalsRuntime = true, noBanner, onInitialized, ...options }, forwardedRef) => {
47
47
  useEffect(() => {
48
48
  signalsRuntime && registerSignalsRuntime();
49
49
  }, []);
@@ -51,11 +51,11 @@ var ClientProvider = /* @__PURE__ */ forwardRef(({ children, config: configProvi
51
51
  if (error) {
52
52
  throw error;
53
53
  }
54
- const [client, setClient] = useState(clientProvider instanceof Client ? clientProvider : void 0);
54
+ const [client, setClient] = useState(clientParam instanceof Client ? clientParam : void 0);
55
55
  useImperativeHandle(forwardedRef, () => client, [
56
56
  client
57
57
  ]);
58
- const [status, setStatus] = useControlledState(controlledStatus);
58
+ const [status, setStatus] = useControlledState(statusParam);
59
59
  useEffect(() => {
60
60
  if (!client) {
61
61
  return;
@@ -65,7 +65,7 @@ var ClientProvider = /* @__PURE__ */ forwardRef(({ children, config: configProvi
65
65
  }, [
66
66
  client
67
67
  ]);
68
- useEffect(() => {
68
+ useAsyncEffect(async () => {
69
69
  let disposed = false;
70
70
  const initialize = async (client3) => {
71
71
  if (!client3.initialized) {
@@ -76,14 +76,14 @@ var ClientProvider = /* @__PURE__ */ forwardRef(({ children, config: configProvi
76
76
  });
77
77
  log("client ready", void 0, {
78
78
  F: __dxlog_file,
79
- L: 137,
79
+ L: 138,
80
80
  S: void 0,
81
81
  C: (f, a) => f(...a)
82
82
  });
83
83
  await onInitialized?.(client3);
84
84
  log("initialization complete", void 0, {
85
85
  F: __dxlog_file,
86
- L: 139,
86
+ L: 140,
87
87
  S: void 0,
88
88
  C: (f, a) => f(...a)
89
89
  });
@@ -94,83 +94,80 @@ var ClientProvider = /* @__PURE__ */ forwardRef(({ children, config: configProvi
94
94
  }
95
95
  };
96
96
  let client2;
97
- const t = setTimeout(async () => {
98
- try {
99
- if (clientProvider) {
100
- client2 = await getAsyncProviderValue(clientProvider);
101
- await initialize(client2);
102
- } else {
103
- const config = await getAsyncProviderValue(configProvider);
104
- log("resolved config", {
105
- config
106
- }, {
107
- F: __dxlog_file,
108
- L: 159,
109
- S: void 0,
110
- C: (f, a) => f(...a)
111
- });
112
- const services = await getAsyncProviderValue(servicesProvider, config);
113
- log("created services", {
114
- services
115
- }, {
116
- F: __dxlog_file,
117
- L: 161,
118
- S: void 0,
119
- C: (f, a) => f(...a)
120
- });
121
- client2 = new Client({
122
- config,
123
- services,
124
- ...options
125
- });
126
- log("created client", void 0, {
127
- F: __dxlog_file,
128
- L: 163,
129
- S: void 0,
130
- C: (f, a) => f(...a)
131
- });
132
- await initialize(client2);
133
- }
134
- } catch (err) {
135
- if (!disposed) {
136
- log.catch(err, void 0, {
137
- F: __dxlog_file,
138
- L: 168,
139
- S: void 0,
140
- C: (f, a) => f(...a)
141
- });
142
- }
97
+ try {
98
+ if (clientParam) {
99
+ client2 = await getAsyncProviderValue(clientParam);
100
+ await initialize(client2);
101
+ } else {
102
+ const config = await getAsyncProviderValue(configParam);
103
+ log("resolved config", {
104
+ config
105
+ }, {
106
+ F: __dxlog_file,
107
+ L: 158,
108
+ S: void 0,
109
+ C: (f, a) => f(...a)
110
+ });
111
+ const services = await getAsyncProviderValue(servicesParam, config);
112
+ log("created services", {
113
+ services
114
+ }, {
115
+ F: __dxlog_file,
116
+ L: 160,
117
+ S: void 0,
118
+ C: (f, a) => f(...a)
119
+ });
120
+ client2 = new Client({
121
+ config,
122
+ services,
123
+ ...options
124
+ });
125
+ log("created client", void 0, {
126
+ F: __dxlog_file,
127
+ L: 162,
128
+ S: void 0,
129
+ C: (f, a) => f(...a)
130
+ });
131
+ await initialize(client2);
143
132
  }
144
- });
133
+ } catch (err) {
134
+ if (!disposed) {
135
+ log.catch(err, void 0, {
136
+ F: __dxlog_file,
137
+ L: 167,
138
+ S: void 0,
139
+ C: (f, a) => f(...a)
140
+ });
141
+ }
142
+ }
145
143
  return () => {
146
144
  log("clean up", void 0, {
147
145
  F: __dxlog_file,
148
- L: 174,
146
+ L: 172,
149
147
  S: void 0,
150
148
  C: (f, a) => f(...a)
151
149
  });
152
150
  disposed = true;
153
- clearTimeout(t);
154
- if (!clientProvider) {
151
+ if (!clientParam) {
155
152
  void client2?.destroy().then(() => {
156
153
  log("destroyed", void 0, {
157
154
  F: __dxlog_file,
158
- L: 182,
155
+ L: 179,
159
156
  S: void 0,
160
157
  C: (f, a) => f(...a)
161
158
  });
162
159
  }).catch((err) => log.catch(err, void 0, {
163
160
  F: __dxlog_file,
164
- L: 184,
161
+ L: 181,
165
162
  S: void 0,
166
163
  C: (f, a) => f(...a)
167
164
  }));
168
165
  }
169
166
  };
170
167
  }, [
171
- configProvider,
172
- clientProvider,
173
- servicesProvider,
168
+ configParam,
169
+ clientParam,
170
+ servicesParam,
174
171
  noBanner
175
172
  ]);
176
173
  if (!client?.initialized || status !== SystemStatus.ACTIVE) {
@@ -311,4 +308,4 @@ export {
311
308
  useShellDisplay,
312
309
  useStatus
313
310
  };
314
- //# sourceMappingURL=chunk-ZTD6HPV2.mjs.map
311
+ //# sourceMappingURL=chunk-ZJMNF7GC.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/client/AgentHostingProvider.tsx", "../../../src/client/ClientProvider.tsx", "../../../src/banner.ts", "../../../src/client/context.ts", "../../../src/client/useClient.ts", "../../../src/client/useClientStatus.ts", "../../../src/client/useConfig.ts", "../../../src/client/useShell.ts", "../../../src/client/useStatus.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { type PropsWithChildren, createContext, useContext, useState } from 'react';\n\nimport { type AgentHostingProviderClient, AgentManagerClient, FakeAgentHostingProvider } from '@dxos/client';\nimport { type Halo } from '@dxos/client/halo';\nimport { type Config } from '@dxos/config';\nimport { log } from '@dxos/log';\n\nimport { useClient } from '../client';\n\nexport type AgentHostingProviderProps = { config: Config; halo: Halo };\n\nexport const AgentHostingContext = createContext<AgentHostingProviderClient | null>(null);\n\n/**\n * Experimental agent hosting provider.\n * @param props\n * @constructor\n * @deprecated\n */\nexport const AgentHostingProvider = (props: PropsWithChildren) => {\n const client = useClient();\n const [agentHostingProviderClient] = useState(makeClient(client));\n return (\n <AgentHostingContext.Provider value={agentHostingProviderClient}> {props.children}</AgentHostingContext.Provider>\n );\n};\n\nexport const useAgentHostingClient = () => {\n return useContext(AgentHostingContext);\n};\n\nconst makeClient = ({ config, halo }: AgentHostingProviderProps) => {\n const agentHostingConfig = config.get('runtime.services.agentHosting');\n if (!agentHostingConfig) {\n log('no agent hosting configured');\n return null;\n }\n\n // TODO(nf): Dynamically discover based on runtime config.\n let agentHostingProviderClient: AgentHostingProviderClient | null = null;\n switch (agentHostingConfig.type) {\n case 'LOCAL_TESTING': {\n log('using FakeAgentHostingProvider');\n return new FakeAgentHostingProvider();\n }\n\n case 'AGENTHOSTING_API': {\n agentHostingProviderClient = new AgentManagerClient(config, halo);\n if (agentHostingProviderClient.init()) {\n return agentHostingProviderClient;\n } else {\n // Not authorized or error initializing.\n return null;\n }\n }\n\n default: {\n log.error('Unknown agent hosting provider type: ' + agentHostingConfig.type);\n return null;\n }\n }\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport React, {\n type FunctionComponent,\n type PropsWithChildren,\n forwardRef,\n useEffect,\n useImperativeHandle,\n useState,\n} from 'react';\n\nimport { Client, type ClientOptions, type ClientServicesProvider, SystemStatus } from '@dxos/client';\nimport { type Config } from '@dxos/config';\nimport { registerSignalsRuntime } from '@dxos/echo-signals/react';\nimport { log } from '@dxos/log';\nimport { useAsyncEffect, useControlledState } from '@dxos/react-hooks';\nimport { type MaybePromise, type Provider, getAsyncProviderValue } from '@dxos/util';\n\nimport { printBanner } from '../banner';\n\nimport { ClientContext, type ClientContextProps } from './context';\n\n/**\n * Properties for the ClientProvider.\n */\nexport type ClientProviderProps = Omit<ClientOptions, 'config' | 'services'> &\n Pick<ClientContextProps, 'status'> &\n PropsWithChildren<{\n /**\n * Client object or async provider to enable to caller to do custom initialization.\n *\n * NOTE: For advanced use cases only.\n */\n client?: Client | Provider<Promise<Client>>;\n\n /**\n * Config object or async provider.\n *\n * NOTE: If a `client` is provided then `config` is ignored.\n */\n // TODO(burdon): Reconcile with ClientOptions.\n config?: Config | Provider<Promise<Config>>;\n\n /**\n * Callback to enable the caller to create a custom ClientServicesProvider.\n *\n * NOTE: If a `client` is provided then `services` is ignored.\n */\n // TODO(burdon): Reconcile with ClientOptions.\n services?: ClientServicesProvider | ((config?: Config) => MaybePromise<ClientServicesProvider>);\n\n /**\n * ReactNode to display until the client is available.\n */\n fallback?: FunctionComponent<Partial<ClientContextProps>>;\n\n /**\n * Enable (by default) registration of Preact signals runtime for reactive ECHO objects.\n * @see https://www.npmjs.com/package/@preact/signals-react\n */\n signalsRuntime?: boolean;\n\n /**\n * Skip the DXOS banner.\n */\n noBanner?: boolean;\n\n /**\n * Post initialization hook to enable to caller to do custom initialization.\n */\n onInitialized?: (client: Client) => MaybePromise<void>;\n }>;\n\n/**\n * Root component that provides the DXOS client instance to child components.\n * To be used with the `useClient` hook.\n */\nexport const ClientProvider = forwardRef<Client | undefined, ClientProviderProps>(\n (\n {\n children,\n config: configParam,\n client: clientParam,\n services: servicesParam,\n status: statusParam,\n fallback: Fallback = () => null,\n signalsRuntime = true,\n noBanner,\n onInitialized,\n ...options\n },\n forwardedRef,\n ) => {\n useEffect(() => {\n // TODO(wittjosiah): Ideally this should be imported asynchronously because it is optional.\n // Unfortunately, async import seemed to break signals React instrumentation.\n signalsRuntime && registerSignalsRuntime();\n }, []);\n\n // The client is initialized asynchronously.\n // If an error occurs during initialization, it is caught and the state is set.\n // This allows the error to be thrown in the render method.\n // The assumption is that a client initialization error is fatal to the app.\n // This error will be caught by the nearest error boundary.\n const [error, setError] = useState();\n if (error) {\n throw error;\n }\n\n const [client, setClient] = useState(clientParam instanceof Client ? clientParam : undefined);\n\n // Provide external access.\n useImperativeHandle(forwardedRef, () => client, [client]);\n\n // Client status subscription.\n const [status, setStatus] = useControlledState(statusParam);\n useEffect(() => {\n if (!client) {\n return;\n }\n\n const subscription = client.status.subscribe((status) => setStatus(status));\n return () => subscription.unsubscribe();\n }, [client]);\n\n // Create and/or initialize client.\n useAsyncEffect(async () => {\n let disposed = false;\n const initialize = async (client: Client) => {\n if (!client.initialized) {\n await client.initialize().catch((err) => {\n if (!disposed) {\n setError(err);\n }\n });\n log('client ready');\n await onInitialized?.(client);\n log('initialization complete');\n }\n\n setClient(client);\n if (!noBanner) {\n printBanner(client);\n }\n };\n\n let client: Client;\n try {\n if (clientParam) {\n // Asynchronously request client.\n client = await getAsyncProviderValue(clientParam);\n await initialize(client);\n } else {\n // Asynchronously construct client (config may be undefined).\n const config = await getAsyncProviderValue(configParam);\n log('resolved config', { config });\n const services = await getAsyncProviderValue(servicesParam, config);\n log('created services', { services });\n client = new Client({ config, services, ...options });\n log('created client');\n await initialize(client);\n }\n } catch (err) {\n if (!disposed) {\n log.catch(err);\n }\n }\n\n return () => {\n log('clean up');\n disposed = true;\n // Only destroy if the client is not provided by the parent.\n if (!clientParam) {\n void client\n ?.destroy()\n .then(() => {\n log('destroyed');\n })\n .catch((err) => log.catch(err));\n }\n };\n }, [configParam, clientParam, servicesParam, noBanner]);\n\n if (!client?.initialized || status !== SystemStatus.ACTIVE) {\n return <Fallback client={client} status={status} />;\n }\n\n return <ClientContext.Provider value={{ client, status }}>{children}</ClientContext.Provider>;\n },\n);\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport { type Client } from '@dxos/client';\n\n// http://patorjk.com/software/taag/#p=testall&f=Patorjk-HeX&t=DXOS\nconst BANNER = (client: Client) => {\n const commitHash = client.config.get('runtime.app.build.commitHash');\n const hash = commitHash ? ` App Commit ${commitHash} \\n` : '';\n\n return (\n '\\n' +\n '_/\\\\/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\______/\\\\/\\\\/\\\\/\\\\/\\\\_\\n' +\n '_/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\__/\\\\/\\\\_________\\n' +\n '_/\\\\/\\\\____/\\\\/\\\\______/\\\\/\\\\______/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\___\\n' +\n '_/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\__________/\\\\/\\\\_\\n' +\n '_/\\\\/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\/\\\\___\\n' +\n `\\n DXOS Client ${client.version} \\n${hash}`\n );\n};\n\nlet bannerPrinted = false;\n\nexport const printBanner = (client: Client) => {\n if (bannerPrinted || window.location.hostname === 'localhost') {\n return;\n }\n\n bannerPrinted = true;\n // eslint-disable-next-line no-console\n console.log(`%c${BANNER(client)}`, 'font-family: monospace;');\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { type Context, createContext } from 'react';\n\nimport { type Client, type SystemStatus } from '@dxos/client';\n\nexport type ClientContextProps = {\n client: Client;\n status?: SystemStatus | null;\n};\n\n/**\n * @internal Use ClientProvider to create or initialize the Client.\n */\nexport const ClientContext: Context<ClientContextProps | undefined> = createContext<ClientContextProps | undefined>(\n undefined,\n);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { useContext } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { ClientContext } from '../client/context';\n\n/**\n * Hook returning instance of DXOS client.\n * Requires ClientContext to be set via ClientProvider.\n */\nexport const useClient = () => {\n const { client } = useContext(ClientContext) ?? raise(new Error('Missing ClientContext.'));\n return client;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { useEffect, useState } from 'react';\n\nimport { type Client, type SystemStatus } from '@dxos/client';\n\nexport const useClientStatus = (client: Client) => {\n const [status, setStatus] = useState<SystemStatus | null>();\n useEffect(() => {\n if (!client) {\n return;\n }\n\n const subscription = client.status.subscribe((status) => setStatus(status));\n return () => subscription.unsubscribe();\n }, [client, setStatus]);\n\n return status;\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { useContext } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { ClientContext } from './context';\n\n/**\n * Hook returning config object used to initialize the DXOS client instance.\n * Requires ClientContext to be set via ClientProvider.\n */\nexport const useConfig = () => {\n const { client } = useContext(ClientContext) ?? raise(new Error('Missing ClientContext.'));\n return client.config;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { useEffect, useState } from 'react';\n\nimport { type Shell, type ShellDisplay } from '@dxos/client';\n\nimport { useClient } from './useClient';\n\n/**\n * Helper hook to access the shell.\n */\nexport const useShell = (): Shell => {\n const client = useClient();\n return client.shell;\n};\n\n/**\n * Hook to access the shell’s display state.\n */\nexport const useShellDisplay = (): ShellDisplay => {\n const client = useClient();\n const [display, setDisplay] = useState(client.shell.display);\n useEffect(() => client.shell.onDisplayChange(setDisplay), [client]);\n return display;\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { useContext } from 'react';\n\nimport { type SystemStatus } from '@dxos/client';\nimport { raise } from '@dxos/debug';\n\nimport { ClientContext } from './context';\n\nexport const useStatus = (): SystemStatus | null | undefined => {\n const { status } = useContext(ClientContext) ?? raise(new Error('Missing ClientContext.'));\n return status;\n};\n"],
5
+ "mappings": ";;;AAIA,OAAOA,UAAiCC,iBAAAA,gBAAeC,cAAAA,aAAYC,YAAAA,iBAAgB;AAEnF,SAA0CC,oBAAoBC,gCAAgC;AAG9F,SAASC,OAAAA,YAAW;;;ACLpB,OAAOC,SAGLC,YACAC,WACAC,qBACAC,gBACK;AAEP,SAASC,QAAyDC,oBAAoB;AAEtF,SAASC,8BAA8B;AACvC,SAASC,WAAW;AACpB,SAASC,gBAAgBC,0BAA0B;AACnD,SAA2CC,6BAA6B;;;ACXxE,IAAMC,SAAS,CAACC,WAAAA;AACd,QAAMC,aAAaD,OAAOE,OAAOC,IAAI,8BAAA;AACrC,QAAMC,OAAOH,aAAa,eAAeA,UAAAA;IAAkB;AAE3D,SACE;;;;;;;eAMkBD,OAAOK,OAAO;EAAMD,IAAAA;AAE1C;AAEA,IAAIE,gBAAgB;AAEb,IAAMC,cAAc,CAACP,WAAAA;AAC1B,MAAIM,iBAAiBE,OAAOC,SAASC,aAAa,aAAa;AAC7D;EACF;AAEAJ,kBAAgB;AAEhBK,UAAQC,IAAI,KAAKb,OAAOC,MAAAA,CAAAA,IAAW,yBAAA;AACrC;;;AC5BA,SAAuBa,qBAAqB;AAYrC,IAAMC,gBAAyDC,cACpEC,MAAAA;;;;AF8DK,IAAMC,iBAAiBC,2BAC5B,CACE,EACEC,UACAC,QAAQC,aACRC,QAAQC,aAC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AA;AACnC,SAAOC,YAAWd,mBAAAA;AACpB;AAEA,IAAMQ,aAAa,CAAC,EAAEO,QAAQC,KAAI,MAA6B;AAC7D,QAAMC,qBAAqBF,OAAOG,IAAI,+BAAA;AACtC,MAAI,CAACD,oBAAoB;AACvBE,IAAAA,KAAI,+BAAA,QAAA;;;;;;AACJ,WAAO;EACT;AAGA,MAAIb,6BAAgE;AACpE,UAAQW,mBAAmBG,MAAI;IAC7B,KAAK,iBAAiB;AACpBD,MAAAA,KAAI,kCAAA,QAAA;;;;;;AACJ,aAAO,IAAIE,yBAAAA;IACb;IAEA,KAAK,oBAAoB;AACvBf,mCAA6B,IAAIgB,mBAAmBP,QAAQC,IAAAA;AAC5D,UAAIV,2BAA2BiB,KAAI,GAAI;AACrC,eAAOjB;MACT,OAAO;AAEL,eAAO;MACT;IACF;IAEA,SAAS;AACPa,MAAAA,KAAIK,MAAM,0CAA0CP,mBAAmBG,MAAI,QAAA;;;;;;AAC3E,aAAO;IACT;EACF;AACF;",
6
+ "names": ["React", "createContext", "useContext", "useState", "AgentManagerClient", "FakeAgentHostingProvider", "log", "React", "forwardRef", "useEffect", "useImperativeHandle", "useState", "Client", "SystemStatus", "registerSignalsRuntime", "log", "useAsyncEffect", "useControlledState", "getAsyncProviderValue", "BANNER", "client", "commitHash", "config", "get", "hash", "version", "bannerPrinted", "printBanner", "window", "location", "hostname", "console", "log", "createContext", "ClientContext", "createContext", "undefined", "ClientProvider", "forwardRef", "children", "config", "configParam", "client", "clientParam", "services", "servicesParam", "status", "statusParam", "fallback", "Fallback", "signalsRuntime", "noBanner", "onInitialized", "options", "forwardedRef", "useEffect", "registerSignalsRuntime", "error", "setError", "useState", "setClient", "Client", "undefined", "useImperativeHandle", "setStatus", "useControlledState", "subscription", "subscribe", "unsubscribe", "useAsyncEffect", "disposed", "initialize", "initialized", "catch", "err", "log", "printBanner", "getAsyncProviderValue", "destroy", "then", "SystemStatus", "ACTIVE", "ClientContext", "Provider", "value", "useContext", "raise", "useClient", "client", "useContext", "ClientContext", "raise", "Error", "useEffect", "useState", "useClientStatus", "client", "status", "setStatus", "useState", "useEffect", "subscription", "subscribe", "unsubscribe", "useContext", "raise", "useConfig", "client", "useContext", "ClientContext", "raise", "Error", "config", "useEffect", "useState", "useShell", "client", "useClient", "shell", "useShellDisplay", "display", "setDisplay", "useState", "useEffect", "onDisplayChange", "useContext", "raise", "useStatus", "status", "useContext", "ClientContext", "raise", "Error", "AgentHostingContext", "createContext", "AgentHostingProvider", "props", "client", "useClient", "agentHostingProviderClient", "useState", "makeClient", "React", "Provider", "value", "children", "useAgentHostingClient", "useContext", "config", "halo", "agentHostingConfig", "get", "log", "type", "FakeAgentHostingProvider", "AgentManagerClient", "init", "error"]
7
+ }
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
  import {
3
3
  useClient
4
- } from "../chunk-ZTD6HPV2.mjs";
4
+ } from "../chunk-ZJMNF7GC.mjs";
5
5
 
6
6
  // src/devtools/index.ts
7
7
  export * from "@dxos/client/devtools";
@@ -14,7 +14,7 @@ var useDevtools = () => {
14
14
  };
15
15
 
16
16
  // src/devtools/useStream.ts
17
- import { useState, useEffect } from "react";
17
+ import { useEffect, useState } from "react";
18
18
  import { log } from "@dxos/log";
19
19
  var __dxlog_file = "/__w/dxos/dxos/packages/sdk/react-client/src/devtools/useStream.ts";
20
20
  var useStream = (streamFactory, defaultValue, deps = []) => {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/devtools/index.ts", "../../../../src/devtools/useDevtools.ts", "../../../../src/devtools/useStream.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nexport * from '@dxos/client/devtools';\n\nexport * from './useDevtools';\nexport * from './useStream';\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { type DevtoolsHost } from '@dxos/client/devtools';\nimport { raise } from '@dxos/debug';\n\nimport { useClient } from '../client';\n\nexport const useDevtools = (): DevtoolsHost => {\n const client = useClient();\n return client.services.services.DevtoolsHost ?? raise(new Error('DevtoolsHost not available.'));\n};\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport { type DependencyList, useState, useEffect } from 'react';\n\nimport { type Stream } from '@dxos/codec-protobuf/stream';\nimport { log } from '@dxos/log';\n\n/**\n * Subscribe to service API streams.\n */\nexport const useStream = <T>(streamFactory: () => Stream<T>, defaultValue: T, deps: DependencyList = []): T => {\n const [value, setValue] = useState<T | undefined>(defaultValue);\n useEffect(() => {\n const stream = streamFactory();\n stream.subscribe(\n (response: T) => setValue(response),\n (err) => {\n if (err) {\n log.catch(err);\n }\n },\n );\n\n return () => {\n void stream.close();\n };\n }, deps);\n\n return value ?? defaultValue;\n};\n"],
5
- "mappings": ";;;;;;AAIA,cAAc;;;ACCd,SAASA,aAAa;AAIf,IAAMC,cAAc,MAAA;AACzB,QAAMC,SAASC,UAAAA;AACf,SAAOD,OAAOE,SAASA,SAASC,gBAAgBC,MAAM,IAAIC,MAAM,6BAAA,CAAA;AAClE;;;ACRA,SAA8BC,UAAUC,iBAAiB;AAGzD,SAASC,WAAW;;AAKb,IAAMC,YAAY,CAAIC,eAAgCC,cAAiBC,OAAuB,CAAA,MAAE;AACrG,QAAM,CAACC,OAAOC,QAAAA,IAAYR,SAAwBK,YAAAA;AAClDJ,YAAU,MAAA;AACR,UAAMQ,SAASL,cAAAA;AACfK,WAAOC,UACL,CAACC,aAAgBH,SAASG,QAAAA,GAC1B,CAACC,QAAAA;AACC,UAAIA,KAAK;AACPV,YAAIW,MAAMD,KAAAA,QAAAA;;;;;;MACZ;IACF,CAAA;AAGF,WAAO,MAAA;AACL,WAAKH,OAAOK,MAAK;IACnB;EACF,GAAGR,IAAAA;AAEH,SAAOC,SAASF;AAClB;",
6
- "names": ["raise", "useDevtools", "client", "useClient", "services", "DevtoolsHost", "raise", "Error", "useState", "useEffect", "log", "useStream", "streamFactory", "defaultValue", "deps", "value", "setValue", "stream", "subscribe", "response", "err", "catch", "close"]
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nexport * from '@dxos/client/devtools';\n\nexport * from './useDevtools';\nexport * from './useStream';\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { type DevtoolsHost } from '@dxos/client/devtools';\nimport { raise } from '@dxos/debug';\n\nimport { useClient } from '../client';\n\nexport const useDevtools = (): DevtoolsHost => {\n const client = useClient();\n return client.services.services.DevtoolsHost ?? raise(new Error('DevtoolsHost not available.'));\n};\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport { type DependencyList, useEffect, useState } from 'react';\n\nimport { type Stream } from '@dxos/codec-protobuf/stream';\nimport { log } from '@dxos/log';\n\n/**\n * Subscribe to service API streams.\n */\nexport const useStream = <T>(streamFactory: () => Stream<T>, defaultValue: T, deps: DependencyList = []): T => {\n const [value, setValue] = useState<T | undefined>(defaultValue);\n useEffect(() => {\n const stream = streamFactory();\n stream.subscribe(\n (response: T) => setValue(response),\n (err) => {\n if (err) {\n log.catch(err);\n }\n },\n );\n\n return () => {\n void stream.close();\n };\n }, deps);\n\n return value ?? defaultValue;\n};\n"],
5
+ "mappings": ";;;;;;AAIA,cAAc;;;ACCd,SAASA,aAAa;AAIf,IAAMC,cAAc,MAAA;AACzB,QAAMC,SAASC,UAAAA;AACf,SAAOD,OAAOE,SAASA,SAASC,gBAAgBC,MAAM,IAAIC,MAAM,6BAAA,CAAA;AAClE;;;ACRA,SAA8BC,WAAWC,gBAAgB;AAGzD,SAASC,WAAW;;AAKb,IAAMC,YAAY,CAAIC,eAAgCC,cAAiBC,OAAuB,CAAA,MAAE;AACrG,QAAM,CAACC,OAAOC,QAAAA,IAAYP,SAAwBI,YAAAA;AAClDL,YAAU,MAAA;AACR,UAAMS,SAASL,cAAAA;AACfK,WAAOC,UACL,CAACC,aAAgBH,SAASG,QAAAA,GAC1B,CAACC,QAAAA;AACC,UAAIA,KAAK;AACPV,YAAIW,MAAMD,KAAAA,QAAAA;;;;;;MACZ;IACF,CAAA;AAGF,WAAO,MAAA;AACL,WAAKH,OAAOK,MAAK;IACnB;EACF,GAAGR,IAAAA;AAEH,SAAOC,SAASF;AAClB;",
6
+ "names": ["raise", "useDevtools", "client", "useClient", "services", "DevtoolsHost", "raise", "Error", "useEffect", "useState", "log", "useStream", "streamFactory", "defaultValue", "deps", "value", "setValue", "stream", "subscribe", "response", "err", "catch", "close"]
7
7
  }
@@ -1,10 +1,10 @@
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-AQJH2UNZ.mjs";
5
5
  import {
6
6
  useClient
7
- } from "../chunk-ZTD6HPV2.mjs";
7
+ } from "../chunk-ZJMNF7GC.mjs";
8
8
 
9
9
  // src/echo/index.ts
10
10
  export * from "@dxos/client/echo";
@@ -15,22 +15,19 @@ import { HaloSpaceMember } from "@dxos/client/echo";
15
15
  import { useMulticastObservable as useMulticastObservable2 } from "@dxos/react-hooks";
16
16
 
17
17
  // src/echo/useSpaces.ts
18
- import { useEffect, useState } from "react";
18
+ import { useState } from "react";
19
19
  import { SpaceState } from "@dxos/client/echo";
20
- import { useMulticastObservable } from "@dxos/react-hooks";
20
+ import { useAsyncEffect, useMulticastObservable } from "@dxos/react-hooks";
21
21
  var useSpace = (spaceKeyLike) => {
22
22
  const client = useClient();
23
23
  const spaces = useMulticastObservable(client.spaces);
24
24
  const [ready, setReady] = useState(false);
25
- useEffect(() => {
25
+ useAsyncEffect(async () => {
26
26
  if (spaceKeyLike) {
27
27
  return;
28
28
  }
29
- const timeout = setTimeout(async () => {
30
- await client.spaces.waitUntilReady();
31
- setReady(true);
32
- });
33
- return () => clearTimeout(timeout);
29
+ await client.spaces.waitUntilReady();
30
+ setReady(true);
34
31
  }, [
35
32
  client,
36
33
  spaceKeyLike
@@ -64,11 +61,14 @@ import { Filter, Query, isSpace } from "@dxos/client/echo";
64
61
  var EMPTY_ARRAY = [];
65
62
  var noop = () => {
66
63
  };
67
- var useQuery = (spaceOrEcho, queryOrFilter, deps) => {
64
+ var useQuery = (resource, queryOrFilter, deps) => {
68
65
  const query = Filter.is(queryOrFilter) ? Query.select(queryOrFilter) : queryOrFilter;
69
66
  const { getObjects, subscribe } = useMemo(() => {
67
+ let queryResult = void 0;
68
+ if (resource) {
69
+ queryResult = isSpace(resource) ? resource.db.query(query) : resource.query(query);
70
+ }
70
71
  let subscribed = false;
71
- const queryResult = spaceOrEcho === void 0 ? void 0 : isSpace(spaceOrEcho) ? spaceOrEcho.db.query(query) : spaceOrEcho.query(query);
72
72
  return {
73
73
  getObjects: () => subscribed && queryResult ? queryResult.objects : EMPTY_ARRAY,
74
74
  subscribe: (cb) => {
@@ -81,7 +81,7 @@ var useQuery = (spaceOrEcho, queryOrFilter, deps) => {
81
81
  }
82
82
  };
83
83
  }, [
84
- spaceOrEcho,
84
+ resource,
85
85
  JSON.stringify(query.ast),
86
86
  ...deps ?? []
87
87
  ]);
@@ -90,7 +90,7 @@ var useQuery = (spaceOrEcho, queryOrFilter, deps) => {
90
90
  };
91
91
 
92
92
  // src/echo/useQueue.ts
93
- import { useEffect as useEffect2, useMemo as useMemo2, useRef } from "react";
93
+ import { useEffect, useMemo as useMemo2, useRef } from "react";
94
94
  import { raise } from "@dxos/debug";
95
95
  var MIN_POLL_INTERVAL = 1e3;
96
96
  var useQueue = (queueDxn, options = {}) => {
@@ -106,12 +106,12 @@ var useQueue = (queueDxn, options = {}) => {
106
106
  client,
107
107
  queueDxn?.toString()
108
108
  ]);
109
- useEffect2(() => {
109
+ useEffect(() => {
110
110
  void queue?.refresh();
111
111
  }, [
112
112
  queue
113
113
  ]);
114
- useEffect2(() => {
114
+ useEffect(() => {
115
115
  let timeout;
116
116
  mountedRef.current = true;
117
117
  const poll = () => {
@@ -196,13 +196,13 @@ var useSpaceInvitation = (spaceKey, invitationId) => {
196
196
  };
197
197
 
198
198
  // src/echo/useSubscription.ts
199
- import { useEffect as useEffect3, useRef as useRef2 } from "react";
199
+ import { useEffect as useEffect2, useRef as useRef2 } from "react";
200
200
  import { createSubscription } from "@dxos/client/echo";
201
201
  var useSubscription = (cb, selection) => {
202
202
  const callbackRef = useRef2(cb);
203
203
  callbackRef.current = cb;
204
- const subscriptionRef = useRef2();
205
- useEffect3(() => {
204
+ const subscriptionRef = useRef2(null);
205
+ useEffect2(() => {
206
206
  subscriptionRef.current = createSubscription(() => {
207
207
  callbackRef.current();
208
208
  });
@@ -213,7 +213,7 @@ var useSubscription = (cb, selection) => {
213
213
  };
214
214
 
215
215
  // src/echo/useSyncState.ts
216
- import { useEffect as useEffect4, useState as useState2 } from "react";
216
+ import { useEffect as useEffect3, useState as useState2 } from "react";
217
217
  import { Context } from "@dxos/context";
218
218
  import { EdgeService } from "@dxos/protocols";
219
219
  var __dxlog_file = "/__w/dxos/dxos/packages/sdk/react-client/src/echo/useSyncState.ts";
@@ -221,7 +221,7 @@ var isEdgePeerId = (peerId, spaceId) => peerId.startsWith(`${EdgeService.AUTOMER
221
221
  var useSyncState = () => {
222
222
  const client = useClient();
223
223
  const [spaceState, setSpaceState] = useState2({});
224
- useEffect4(() => {
224
+ useEffect3(() => {
225
225
  const ctx = new Context(void 0, {
226
226
  F: __dxlog_file,
227
227
  L: 25
@@ -256,7 +256,7 @@ var useSyncState = () => {
256
256
  };
257
257
  var useSpaceSyncState = (space) => {
258
258
  const [spaceState, setSpaceState] = useState2();
259
- useEffect4(() => {
259
+ useEffect3(() => {
260
260
  const ctx = new Context(void 0, {
261
261
  F: __dxlog_file,
262
262
  L: 64