@dxos/react-client 0.8.4-main.f9ba587 → 0.8.4-main.fcc0d83b33

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 (397) hide show
  1. package/.storybook/main.mts +9 -0
  2. package/.storybook/preview.mts +8 -0
  3. package/dist/lib/browser/chunk-3LVU7RNK.mjs +16 -0
  4. package/dist/lib/browser/chunk-3LVU7RNK.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-CZMIVAGI.mjs +8 -0
  6. package/dist/lib/browser/chunk-CZMIVAGI.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-XT352YI6.mjs +134 -0
  8. package/dist/lib/browser/chunk-XT352YI6.mjs.map +7 -0
  9. package/dist/lib/browser/{chunk-O5SEVDJG.mjs → chunk-YHE6WD44.mjs} +5 -15
  10. package/dist/lib/browser/chunk-YHE6WD44.mjs.map +7 -0
  11. package/dist/lib/browser/devtools/index.mjs +4 -8
  12. package/dist/lib/browser/devtools/index.mjs.map +3 -3
  13. package/dist/lib/browser/echo/index.mjs +58 -127
  14. package/dist/lib/browser/echo/index.mjs.map +4 -4
  15. package/dist/lib/browser/halo/index.mjs +5 -3
  16. package/dist/lib/browser/halo/index.mjs.map +3 -3
  17. package/dist/lib/browser/index.mjs +99 -12
  18. package/dist/lib/browser/index.mjs.map +4 -4
  19. package/dist/lib/browser/invitations/index.mjs +1 -1
  20. package/dist/lib/browser/mesh/index.mjs +2 -1
  21. package/dist/lib/browser/mesh/index.mjs.map +1 -1
  22. package/dist/lib/browser/meta.json +1 -1
  23. package/dist/lib/browser/testing/index.mjs +112 -155
  24. package/dist/lib/browser/testing/index.mjs.map +3 -3
  25. package/dist/lib/node-esm/chunk-CUDKNAMV.mjs +17 -0
  26. package/dist/lib/node-esm/chunk-CUDKNAMV.mjs.map +7 -0
  27. package/dist/lib/node-esm/{chunk-TU2JJLZK.mjs → chunk-RQJPEHDY.mjs} +5 -15
  28. package/dist/lib/node-esm/chunk-RQJPEHDY.mjs.map +7 -0
  29. package/dist/lib/node-esm/chunk-WL3Z5HOH.mjs +135 -0
  30. package/dist/lib/node-esm/chunk-WL3Z5HOH.mjs.map +7 -0
  31. package/dist/lib/node-esm/chunk-WUTK2IJF.mjs +10 -0
  32. package/dist/lib/node-esm/chunk-WUTK2IJF.mjs.map +7 -0
  33. package/dist/lib/node-esm/devtools/index.mjs +4 -8
  34. package/dist/lib/node-esm/devtools/index.mjs.map +3 -3
  35. package/dist/lib/node-esm/echo/index.mjs +58 -127
  36. package/dist/lib/node-esm/echo/index.mjs.map +4 -4
  37. package/dist/lib/node-esm/halo/index.mjs +5 -3
  38. package/dist/lib/node-esm/halo/index.mjs.map +3 -3
  39. package/dist/lib/node-esm/index.mjs +99 -12
  40. package/dist/lib/node-esm/index.mjs.map +4 -4
  41. package/dist/lib/node-esm/invitations/index.mjs +1 -1
  42. package/dist/lib/node-esm/mesh/index.mjs +2 -1
  43. package/dist/lib/node-esm/mesh/index.mjs.map +1 -1
  44. package/dist/lib/node-esm/meta.json +1 -1
  45. package/dist/lib/node-esm/testing/index.mjs +112 -155
  46. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  47. package/dist/types/src/banner.d.ts.map +1 -1
  48. package/dist/types/src/client/AgentHostingProvider.d.ts.map +1 -1
  49. package/dist/types/src/client/ClientProvider.d.ts +1 -11
  50. package/dist/types/src/client/ClientProvider.d.ts.map +1 -1
  51. package/dist/types/src/client/useClientStatus.d.ts.map +1 -1
  52. package/dist/types/src/devtools/useStream.d.ts.map +1 -1
  53. package/dist/types/src/echo/index.d.ts +2 -2
  54. package/dist/types/src/echo/index.d.ts.map +1 -1
  55. package/dist/types/src/echo/useMembers.d.ts +2 -2
  56. package/dist/types/src/echo/useMembers.d.ts.map +1 -1
  57. package/dist/types/src/echo/useQueue.d.ts +3 -2
  58. package/dist/types/src/echo/useQueue.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 -9
  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 -2
  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 +43 -58
  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 -2
  96. package/src/echo/useMembers.ts +5 -3
  97. package/src/echo/useQueue.ts +3 -4
  98. package/src/echo/useSpaceInvitations.ts +10 -5
  99. package/src/echo/useSpaceProperties.ts +28 -0
  100. package/src/echo/useSpaces.test.tsx +8 -14
  101. package/src/echo/useSpaces.ts +32 -30
  102. package/src/echo/useSubscription.ts +1 -1
  103. package/src/echo/useSyncState.ts +5 -4
  104. package/src/halo/Passkey.stories.tsx +20 -20
  105. package/src/halo/useDevices.test.tsx +1 -1
  106. package/src/halo/useHaloInvitations.ts +1 -1
  107. package/src/invitations/useInvitationStatus.ts +9 -8
  108. package/src/testing/ClientRepeater.stories.tsx +22 -16
  109. package/src/testing/ClientRepeater.tsx +29 -37
  110. package/src/testing/context.tsx +4 -3
  111. package/src/testing/util.tsx +0 -1
  112. package/src/testing/withClientProvider.stories.tsx +34 -20
  113. package/src/testing/withClientProvider.tsx +77 -94
  114. package/tsconfig.json +3 -6
  115. package/typedoc.json +1 -1
  116. package/vitest.config.ts +10 -16
  117. package/.eslintrc.cjs +0 -12
  118. package/.swc/plugins/v7_linux_x86_64_13.0.0/f45bdff002284d9e8f9ef3f0be909de12da36c049cbcf261ac78fc00abb09a2d +0 -0
  119. package/dist/lib/browser/chunk-AAR7V3KL.mjs +0 -312
  120. package/dist/lib/browser/chunk-AAR7V3KL.mjs.map +0 -7
  121. package/dist/lib/browser/chunk-O5SEVDJG.mjs.map +0 -7
  122. package/dist/lib/node-esm/chunk-TU2JJLZK.mjs.map +0 -7
  123. package/dist/lib/node-esm/chunk-ZTD6HPV2.mjs +0 -314
  124. package/dist/lib/node-esm/chunk-ZTD6HPV2.mjs.map +0 -7
  125. package/dist/types/src/echo/useQuery.d.ts +0 -11
  126. package/dist/types/src/echo/useQuery.d.ts.map +0 -1
  127. package/dist/types/src/echo/useQuery.test.d.ts +0 -2
  128. package/dist/types/src/echo/useQuery.test.d.ts.map +0 -1
  129. package/dist/types/src/echo/useSchema.d.ts +0 -8
  130. package/dist/types/src/echo/useSchema.d.ts.map +0 -1
  131. package/dist/types/src/playwright/playwright.config.d.ts +0 -3
  132. package/dist/types/src/playwright/playwright.config.d.ts.map +0 -1
  133. package/dist/types/src/playwright/smoke.spec.d.ts +0 -2
  134. package/dist/types/src/playwright/smoke.spec.d.ts.map +0 -1
  135. package/src/echo/useQuery.test.tsx +0 -128
  136. package/src/echo/useQuery.ts +0 -56
  137. package/src/echo/useSchema.ts +0 -54
  138. package/src/playwright/playwright.config.ts +0 -17
  139. package/src/playwright/smoke.spec.ts +0 -24
  140. package/typedoc/.nojekyll +0 -1
  141. package/typedoc/assets/hierarchy.js +0 -1
  142. package/typedoc/assets/highlight.css +0 -99
  143. package/typedoc/assets/icons.js +0 -18
  144. package/typedoc/assets/icons.svg +0 -1
  145. package/typedoc/assets/main.js +0 -60
  146. package/typedoc/assets/navigation.js +0 -1
  147. package/typedoc/assets/search.js +0 -1
  148. package/typedoc/assets/style.css +0 -1640
  149. package/typedoc/classes/echo.Hypergraph.html +0 -17
  150. package/typedoc/classes/echo.PropertiesType.html +0 -19
  151. package/typedoc/classes/echo.QueryResult.html +0 -18
  152. package/typedoc/classes/halo.KeyStore.html +0 -6
  153. package/typedoc/classes/index.AgentClientServiceProvider.html +0 -10
  154. package/typedoc/classes/index.AgentManagerClient.html +0 -22
  155. package/typedoc/classes/index.AlreadyJoinedError.html +0 -15
  156. package/typedoc/classes/index.ApiError.html +0 -16
  157. package/typedoc/classes/index.CancelledError.html +0 -16
  158. package/typedoc/classes/index.Client.html +0 -51
  159. package/typedoc/classes/index.ClientServicesProxy.html +0 -12
  160. package/typedoc/classes/index.Config.html +0 -17
  161. package/typedoc/classes/index.DataCorruptionError.html +0 -16
  162. package/typedoc/classes/index.DatabaseError.html +0 -15
  163. package/typedoc/classes/index.EntityNotFoundError.html +0 -15
  164. package/typedoc/classes/index.FakeAgentHostingProvider.html +0 -7
  165. package/typedoc/classes/index.IFrameManager.html +0 -6
  166. package/typedoc/classes/index.IdentityNotInitializedError.html +0 -15
  167. package/typedoc/classes/index.InvalidConfigError.html +0 -16
  168. package/typedoc/classes/index.InvalidInvitationError.html +0 -15
  169. package/typedoc/classes/index.InvalidInvitationExtensionRoleError.html +0 -16
  170. package/typedoc/classes/index.InvalidStorageVersionError.html +0 -15
  171. package/typedoc/classes/index.LocalClientServices.html +0 -12
  172. package/typedoc/classes/index.PublicKey.html +0 -55
  173. package/typedoc/classes/index.RemoteServiceConnectionError.html +0 -15
  174. package/typedoc/classes/index.RemoteServiceConnectionTimeout.html +0 -15
  175. package/typedoc/classes/index.RpcClosedError.html +0 -15
  176. package/typedoc/classes/index.RpcNotOpenError.html +0 -15
  177. package/typedoc/classes/index.SharedWorkerConnection.html +0 -5
  178. package/typedoc/classes/index.Shell.html +0 -35
  179. package/typedoc/classes/index.ShellManager.html +0 -9
  180. package/typedoc/classes/index.SystemError.html +0 -16
  181. package/typedoc/classes/index.UnknownModelError.html +0 -15
  182. package/typedoc/classes/index.WorkerClientServices.html +0 -12
  183. package/typedoc/classes/invitations.AuthenticatingInvitationObservable.html +0 -30
  184. package/typedoc/classes/invitations.CancellableInvitationObservable.html +0 -29
  185. package/typedoc/classes/invitations.InvitationEncoder.html +0 -5
  186. package/typedoc/classes/invitations.InvitationsProxy.html +0 -12
  187. package/typedoc/enums/devtools.KeyType.html +0 -9
  188. package/typedoc/enums/echo.HaloSpaceMember.Role.html +0 -9
  189. package/typedoc/enums/echo.IndexKind.Kind.html +0 -8
  190. package/typedoc/enums/echo.QueryOptions.DataLocation.html +0 -6
  191. package/typedoc/enums/echo.QueryOptions.ShowDeletedOption.html +0 -6
  192. package/typedoc/enums/echo.SpaceMember.PresenceState.html +0 -5
  193. package/typedoc/enums/echo.SpaceState.html +0 -13
  194. package/typedoc/enums/echo.TextKind.html +0 -5
  195. package/typedoc/enums/halo.Device.PresenceState.html +0 -6
  196. package/typedoc/enums/halo.DeviceKind.html +0 -5
  197. package/typedoc/enums/halo.DeviceType.html +0 -9
  198. package/typedoc/enums/index.ShellDisplay.html +0 -5
  199. package/typedoc/enums/index.ShellLayout.html +0 -13
  200. package/typedoc/enums/index.SystemStatus.html +0 -5
  201. package/typedoc/enums/invitations.Invitation.AuthMethod.html +0 -6
  202. package/typedoc/enums/invitations.Invitation.Kind.html +0 -5
  203. package/typedoc/enums/invitations.Invitation.State.html +0 -13
  204. package/typedoc/enums/invitations.Invitation.Type.html +0 -6
  205. package/typedoc/enums/mesh.ConnectionState.html +0 -5
  206. package/typedoc/functions/devtools.useDevtools.html +0 -1
  207. package/typedoc/functions/devtools.useStream.html +0 -2
  208. package/typedoc/functions/echo.useMembers.html +0 -1
  209. package/typedoc/functions/echo.useQueue.html +0 -2
  210. package/typedoc/functions/echo.useSchema.html +0 -2
  211. package/typedoc/functions/echo.useSpace.html +0 -6
  212. package/typedoc/functions/echo.useSpaceInvitation.html +0 -1
  213. package/typedoc/functions/echo.useSpaceInvitations.html +0 -1
  214. package/typedoc/functions/echo.useSpaceSyncState.html +0 -2
  215. package/typedoc/functions/echo.useSpaces.html +0 -5
  216. package/typedoc/functions/echo.useSubscription.html +0 -3
  217. package/typedoc/functions/echo.useSyncState.html +0 -2
  218. package/typedoc/functions/halo.useContacts.html +0 -4
  219. package/typedoc/functions/halo.useCredentials.html +0 -1
  220. package/typedoc/functions/halo.useDevices.html +0 -1
  221. package/typedoc/functions/halo.useHaloInvitation.html +0 -1
  222. package/typedoc/functions/halo.useHaloInvitations.html +0 -1
  223. package/typedoc/functions/halo.useIdentity.html +0 -3
  224. package/typedoc/functions/halo.useKeyStore.html +0 -3
  225. package/typedoc/functions/index.AgentHostingProvider.html +0 -2
  226. package/typedoc/functions/index.useAgentHostingClient.html +0 -1
  227. package/typedoc/functions/index.useClient.html +0 -3
  228. package/typedoc/functions/index.useClientStatus.html +0 -1
  229. package/typedoc/functions/index.useConfig.html +0 -3
  230. package/typedoc/functions/index.useShell.html +0 -2
  231. package/typedoc/functions/index.useShellDisplay.html +0 -2
  232. package/typedoc/functions/index.useStatus.html +0 -1
  233. package/typedoc/functions/invitations.useInvitationStatus.html +0 -1
  234. package/typedoc/functions/mesh.useNetworkStatus.html +0 -2
  235. package/typedoc/hierarchy.html +0 -1
  236. package/typedoc/index.html +0 -23
  237. package/typedoc/interfaces/devtools.DevtoolsHook.html +0 -22
  238. package/typedoc/interfaces/devtools.DevtoolsHost.html +0 -26
  239. package/typedoc/interfaces/echo.DocAccessor.html +0 -3
  240. package/typedoc/interfaces/echo.Echo.html +0 -39
  241. package/typedoc/interfaces/echo.EchoDatabase.html +0 -30
  242. package/typedoc/interfaces/echo.Expando.html +0 -3
  243. package/typedoc/interfaces/echo.Filter.html +0 -3
  244. package/typedoc/interfaces/echo.HaloSpaceMember.html +0 -18
  245. package/typedoc/interfaces/echo.IDocHandle.html +0 -6
  246. package/typedoc/interfaces/echo.IndexKind.html +0 -9
  247. package/typedoc/interfaces/echo.Query.html +0 -34
  248. package/typedoc/interfaces/echo.QueryOptions.html +0 -39
  249. package/typedoc/interfaces/echo.Queue.html +0 -17
  250. package/typedoc/interfaces/echo.Ref.html +0 -32
  251. package/typedoc/interfaces/echo.Space.html +0 -36
  252. package/typedoc/interfaces/echo.SpaceMember.html +0 -7
  253. package/typedoc/interfaces/echo.SpaceSyncState.PeerState.html +0 -14
  254. package/typedoc/interfaces/echo.SpaceSyncState.html +0 -4
  255. package/typedoc/interfaces/echo.SubscriptionHandle.html +0 -5
  256. package/typedoc/interfaces/echo.TypedObject.html +0 -16
  257. package/typedoc/interfaces/halo.Contact.html +0 -10
  258. package/typedoc/interfaces/halo.Credential.html +0 -27
  259. package/typedoc/interfaces/halo.Device.html +0 -11
  260. package/typedoc/interfaces/halo.Halo.html +0 -16
  261. package/typedoc/interfaces/halo.Identity.html +0 -15
  262. package/typedoc/interfaces/index.AgentHostingProviderClient.html +0 -6
  263. package/typedoc/interfaces/index.AppContextRequest.html +0 -33
  264. package/typedoc/interfaces/index.ClientServicesProvider.html +0 -9
  265. package/typedoc/interfaces/index.InvitationUrlRequest.html +0 -9
  266. package/typedoc/interfaces/index.LayoutRequest.html +0 -29
  267. package/typedoc/interfaces/index.ShellRuntime.html +0 -15
  268. package/typedoc/interfaces/invitations.Invitation.html +0 -92
  269. package/typedoc/interfaces/invitations.Invitations.html +0 -5
  270. package/typedoc/interfaces/mesh.GossipMessage.html +0 -10
  271. package/typedoc/interfaces/mesh.NetworkStatus.Signal.html +0 -5
  272. package/typedoc/interfaces/mesh.NetworkStatus.html +0 -6
  273. package/typedoc/media/LICENSE +0 -8
  274. package/typedoc/modules/devtools.html +0 -1
  275. package/typedoc/modules/echo.Filter.html +0 -1
  276. package/typedoc/modules/echo.HaloSpaceMember.html +0 -1
  277. package/typedoc/modules/echo.IndexKind.html +0 -1
  278. package/typedoc/modules/echo.Query.html +0 -1
  279. package/typedoc/modules/echo.QueryOptions.html +0 -1
  280. package/typedoc/modules/echo.Ref.html +0 -2
  281. package/typedoc/modules/echo.SpaceMember.html +0 -1
  282. package/typedoc/modules/echo.SpaceSyncState.html +0 -1
  283. package/typedoc/modules/echo.html +0 -1
  284. package/typedoc/modules/halo.Device.html +0 -1
  285. package/typedoc/modules/halo.html +0 -1
  286. package/typedoc/modules/index.html +0 -1
  287. package/typedoc/modules/invitations.Invitation.html +0 -1
  288. package/typedoc/modules/invitations.html +0 -1
  289. package/typedoc/modules/mesh.NetworkStatus.html +0 -1
  290. package/typedoc/modules/mesh.html +0 -1
  291. package/typedoc/modules/worker.html +0 -1
  292. package/typedoc/modules.html +0 -1
  293. package/typedoc/types/devtools.MountOptions.html +0 -3
  294. package/typedoc/types/echo.AnyLiveObject.html +0 -2
  295. package/typedoc/types/echo.Filter.And.html +0 -1
  296. package/typedoc/types/echo.Filter.Any.html +0 -1
  297. package/typedoc/types/echo.Filter.Or.html +0 -1
  298. package/typedoc/types/echo.Filter.Props.html +0 -1
  299. package/typedoc/types/echo.Filter.Type.html +0 -1
  300. package/typedoc/types/echo.Live.html +0 -5
  301. package/typedoc/types/echo.ObjectMeta.html +0 -1
  302. package/typedoc/types/echo.ObjectMigration.html +0 -7
  303. package/typedoc/types/echo.ObjectVersion.html +0 -2
  304. package/typedoc/types/echo.PeerSyncState.html +0 -1
  305. package/typedoc/types/echo.Progress.html +0 -3
  306. package/typedoc/types/echo.PropertiesTypeProps.html +0 -1
  307. package/typedoc/types/echo.Query.Any.html +0 -1
  308. package/typedoc/types/echo.Query.TextSearchOptions.html +0 -2
  309. package/typedoc/types/echo.Query.Type.html +0 -1
  310. package/typedoc/types/echo.Ref.Target.html +0 -2
  311. package/typedoc/types/echo.Selection.html +0 -1
  312. package/typedoc/types/echo.SpaceId.html +0 -6
  313. package/typedoc/types/echo.SpaceSyncStateMap.html +0 -1
  314. package/typedoc/types/echo.UseQueueOptions.html +0 -2
  315. package/typedoc/types/echo.UseSpacesParams.html +0 -3
  316. package/typedoc/types/index.AgentHostingProviderProps.html +0 -3
  317. package/typedoc/types/index.ClientContextProps.html +0 -3
  318. package/typedoc/types/index.ClientOptions.html +0 -12
  319. package/typedoc/types/index.ClientProviderProps.html +0 -2
  320. package/typedoc/types/index.ClientServices.html +0 -15
  321. package/typedoc/types/index.FromAgentOptions.html +0 -2
  322. package/typedoc/types/index.PublicKeyLike.html +0 -2
  323. package/typedoc/types/invitations.InvitationAction.html +0 -1
  324. package/typedoc/types/invitations.InvitationResult.html +0 -5
  325. package/typedoc/types/invitations.InvitationStatus.html +0 -15
  326. package/typedoc/variables/devtools.mountDevtoolsHooks.html +0 -1
  327. package/typedoc/variables/devtools.unmountDevtoolsHooks.html +0 -1
  328. package/typedoc/variables/echo.DocAccessor.html +0 -1
  329. package/typedoc/variables/echo.EchoObjectSchema.html +0 -1
  330. package/typedoc/variables/echo.Expando.html +0 -1
  331. package/typedoc/variables/echo.FQ_ID_LENGTH.html +0 -1
  332. package/typedoc/variables/echo.Filter.html +0 -1
  333. package/typedoc/variables/echo.OBJECT_ID_LENGTH.html +0 -1
  334. package/typedoc/variables/echo.ObjectVersion.html +0 -1
  335. package/typedoc/variables/echo.Query.html +0 -1
  336. package/typedoc/variables/echo.Queue.html +0 -1
  337. package/typedoc/variables/echo.ReactiveObjectSchema.html +0 -1
  338. package/typedoc/variables/echo.Ref.html +0 -2
  339. package/typedoc/variables/echo.RefArray.html +0 -2
  340. package/typedoc/variables/echo.SPACE_ID_LENGTH.html +0 -1
  341. package/typedoc/variables/echo.SpaceId.html +0 -1
  342. package/typedoc/variables/echo.SpaceSchema.html +0 -1
  343. package/typedoc/variables/echo.TypedObject.html +0 -3
  344. package/typedoc/variables/echo.compareForeignKeys.html +0 -1
  345. package/typedoc/variables/echo.createDocAccessor.html +0 -1
  346. package/typedoc/variables/echo.createEmptyEdgeSyncState.html +0 -1
  347. package/typedoc/variables/echo.createObject.html +0 -1
  348. package/typedoc/variables/echo.createQueueDXN.html +0 -2
  349. package/typedoc/variables/echo.createSubscription.html +0 -5
  350. package/typedoc/variables/echo.defineObjectMigration.html +0 -1
  351. package/typedoc/variables/echo.fromCursor.html +0 -1
  352. package/typedoc/variables/echo.fullyQualifiedId.html +0 -4
  353. package/typedoc/variables/echo.getMeta.html +0 -1
  354. package/typedoc/variables/echo.getObjectCore.html +0 -1
  355. package/typedoc/variables/echo.getRangeFromCursor.html +0 -1
  356. package/typedoc/variables/echo.getSchema.html +0 -2
  357. package/typedoc/variables/echo.getSource.html +0 -4
  358. package/typedoc/variables/echo.getSpace.html +0 -1
  359. package/typedoc/variables/echo.getSyncSummary.html +0 -1
  360. package/typedoc/variables/echo.getTarget.html +0 -4
  361. package/typedoc/variables/echo.getTextInRange.html +0 -2
  362. package/typedoc/variables/echo.getType.html +0 -5
  363. package/typedoc/variables/echo.getTypename.html +0 -6
  364. package/typedoc/variables/echo.getVersion.html +0 -3
  365. package/typedoc/variables/echo.importSpace.html +0 -1
  366. package/typedoc/variables/echo.internalDecodeReference.html +0 -2
  367. package/typedoc/variables/echo.isEchoObject.html +0 -2
  368. package/typedoc/variables/echo.isLiveObject.html +0 -3
  369. package/typedoc/variables/echo.isRelation.html +0 -2
  370. package/typedoc/variables/echo.isSpace.html +0 -1
  371. package/typedoc/variables/echo.live.html +0 -3
  372. package/typedoc/variables/echo.loadObjectReferences.html +0 -7
  373. package/typedoc/variables/echo.parseFullyQualifiedId.html +0 -2
  374. package/typedoc/variables/echo.parseId.html +0 -1
  375. package/typedoc/variables/echo.toCursor.html +0 -1
  376. package/typedoc/variables/echo.toCursorRange.html +0 -1
  377. package/typedoc/variables/echo.updateText.html +0 -6
  378. package/typedoc/variables/echo.useQuery.html +0 -2
  379. package/typedoc/variables/index.AgentHostingContext.html +0 -1
  380. package/typedoc/variables/index.ClientProvider.html +0 -3
  381. package/typedoc/variables/index.DXOS_VERSION.html +0 -1
  382. package/typedoc/variables/index.Defaults.html +0 -2
  383. package/typedoc/variables/index.Dynamics.html +0 -2
  384. package/typedoc/variables/index.Envs.html +0 -2
  385. package/typedoc/variables/index.Local.html +0 -2
  386. package/typedoc/variables/index.Remote.html +0 -1
  387. package/typedoc/variables/index.Storage.html +0 -2
  388. package/typedoc/variables/index.createClientServices.html +0 -4
  389. package/typedoc/variables/index.fromAgent.html +0 -2
  390. package/typedoc/variables/index.fromHost.html +0 -2
  391. package/typedoc/variables/index.fromSocket.html +0 -2
  392. package/typedoc/variables/index.fromWorker.html +0 -2
  393. package/typedoc/variables/index.getUnixSocket.html +0 -1
  394. package/typedoc/variables/index.resolveRef.html +0 -1
  395. package/typedoc/variables/index.useMulticastObservable.html +0 -3
  396. package/typedoc/variables/worker.getWorkerServiceHost.html +0 -1
  397. package/typedoc/variables/worker.onconnect.html +0 -1
@@ -1,314 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
-
3
- // src/client/AgentHostingProvider.tsx
4
- import React2, { createContext as createContext2, useContext as useContext4, useState as useState4 } from "react";
5
- import { AgentManagerClient, FakeAgentHostingProvider } from "@dxos/client";
6
- import { log as log2 } from "@dxos/log";
7
-
8
- // src/client/ClientProvider.tsx
9
- import React, { forwardRef, useEffect, useImperativeHandle, useState } from "react";
10
- import { Client, SystemStatus } from "@dxos/client";
11
- import { registerSignalsRuntime } from "@dxos/echo-signals/react";
12
- import { log } from "@dxos/log";
13
- import { useControlledState } from "@dxos/react-hooks";
14
- import { getAsyncProviderValue } from "@dxos/util";
15
-
16
- // src/client/context.ts
17
- import { createContext } from "react";
18
- var ClientContext = createContext(void 0);
19
-
20
- // src/banner.ts
21
- var BANNER = (client) => {
22
- const commitHash = client.config.get("runtime.app.build.commitHash");
23
- const hash = commitHash ? ` App Commit ${commitHash}
24
- ` : "";
25
- return `
26
- _/\\/\\/\\/\\/\\____/\\/\\____/\\/\\____/\\/\\/\\/\\______/\\/\\/\\/\\/\\_
27
- _/\\/\\____/\\/\\____/\\/\\/\\/\\____/\\/\\____/\\/\\__/\\/\\_________
28
- _/\\/\\____/\\/\\______/\\/\\______/\\/\\____/\\/\\____/\\/\\/\\/\\___
29
- _/\\/\\____/\\/\\____/\\/\\/\\/\\____/\\/\\____/\\/\\__________/\\/\\_
30
- _/\\/\\/\\/\\/\\____/\\/\\____/\\/\\____/\\/\\/\\/\\____/\\/\\/\\/\\/\\___
31
-
32
- DXOS Client ${client.version}
33
- ${hash}`;
34
- };
35
- var bannerPrinted = false;
36
- var printBanner = (client) => {
37
- if (bannerPrinted || window.location.hostname === "localhost") {
38
- return;
39
- }
40
- bannerPrinted = true;
41
- console.log(`%c${BANNER(client)}`, "font-family: monospace;");
42
- };
43
-
44
- // src/client/ClientProvider.tsx
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) => {
47
- useEffect(() => {
48
- signalsRuntime && registerSignalsRuntime();
49
- }, []);
50
- const [error, setError] = useState();
51
- if (error) {
52
- throw error;
53
- }
54
- const [client, setClient] = useState(clientProvider instanceof Client ? clientProvider : void 0);
55
- useImperativeHandle(forwardedRef, () => client, [
56
- client
57
- ]);
58
- const [status, setStatus] = useControlledState(controlledStatus);
59
- useEffect(() => {
60
- if (!client) {
61
- return;
62
- }
63
- const subscription = client.status.subscribe((status2) => setStatus(status2));
64
- return () => subscription.unsubscribe();
65
- }, [
66
- client
67
- ]);
68
- useEffect(() => {
69
- let disposed = false;
70
- const initialize = async (client3) => {
71
- if (!client3.initialized) {
72
- await client3.initialize().catch((err) => {
73
- if (!disposed) {
74
- setError(err);
75
- }
76
- });
77
- log("client ready", void 0, {
78
- F: __dxlog_file,
79
- L: 137,
80
- S: void 0,
81
- C: (f, a) => f(...a)
82
- });
83
- await onInitialized?.(client3);
84
- log("initialization complete", void 0, {
85
- F: __dxlog_file,
86
- L: 139,
87
- S: void 0,
88
- C: (f, a) => f(...a)
89
- });
90
- }
91
- setClient(client3);
92
- if (!noBanner) {
93
- printBanner(client3);
94
- }
95
- };
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
- }
143
- }
144
- });
145
- return () => {
146
- log("clean up", void 0, {
147
- F: __dxlog_file,
148
- L: 174,
149
- S: void 0,
150
- C: (f, a) => f(...a)
151
- });
152
- disposed = true;
153
- clearTimeout(t);
154
- if (!clientProvider) {
155
- void client2?.destroy().then(() => {
156
- log("destroyed", void 0, {
157
- F: __dxlog_file,
158
- L: 182,
159
- S: void 0,
160
- C: (f, a) => f(...a)
161
- });
162
- }).catch((err) => log.catch(err, void 0, {
163
- F: __dxlog_file,
164
- L: 184,
165
- S: void 0,
166
- C: (f, a) => f(...a)
167
- }));
168
- }
169
- };
170
- }, [
171
- configProvider,
172
- clientProvider,
173
- servicesProvider,
174
- noBanner
175
- ]);
176
- if (!client?.initialized || status !== SystemStatus.ACTIVE) {
177
- return /* @__PURE__ */ React.createElement(Fallback, {
178
- client,
179
- status
180
- });
181
- }
182
- return /* @__PURE__ */ React.createElement(ClientContext.Provider, {
183
- value: {
184
- client,
185
- status
186
- }
187
- }, children);
188
- });
189
-
190
- // src/client/useClient.ts
191
- import { useContext } from "react";
192
- import { raise } from "@dxos/debug";
193
- var useClient = () => {
194
- const { client } = useContext(ClientContext) ?? raise(new Error("Missing ClientContext."));
195
- return client;
196
- };
197
-
198
- // src/client/useClientStatus.ts
199
- import { useEffect as useEffect2, useState as useState2 } from "react";
200
- var useClientStatus = (client) => {
201
- const [status, setStatus] = useState2();
202
- useEffect2(() => {
203
- if (!client) {
204
- return;
205
- }
206
- const subscription = client.status.subscribe((status2) => setStatus(status2));
207
- return () => subscription.unsubscribe();
208
- }, [
209
- client,
210
- setStatus
211
- ]);
212
- return status;
213
- };
214
-
215
- // src/client/useConfig.ts
216
- import { useContext as useContext2 } from "react";
217
- import { raise as raise2 } from "@dxos/debug";
218
- var useConfig = () => {
219
- const { client } = useContext2(ClientContext) ?? raise2(new Error("Missing ClientContext."));
220
- return client.config;
221
- };
222
-
223
- // src/client/useShell.ts
224
- import { useEffect as useEffect3, useState as useState3 } from "react";
225
- var useShell = () => {
226
- const client = useClient();
227
- return client.shell;
228
- };
229
- var useShellDisplay = () => {
230
- const client = useClient();
231
- const [display, setDisplay] = useState3(client.shell.display);
232
- useEffect3(() => client.shell.onDisplayChange(setDisplay), [
233
- client
234
- ]);
235
- return display;
236
- };
237
-
238
- // src/client/useStatus.ts
239
- import { useContext as useContext3 } from "react";
240
- import { raise as raise3 } from "@dxos/debug";
241
- var useStatus = () => {
242
- const { status } = useContext3(ClientContext) ?? raise3(new Error("Missing ClientContext."));
243
- return status;
244
- };
245
-
246
- // src/client/AgentHostingProvider.tsx
247
- var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/react-client/src/client/AgentHostingProvider.tsx";
248
- var AgentHostingContext = /* @__PURE__ */ createContext2(null);
249
- var AgentHostingProvider = (props) => {
250
- const client = useClient();
251
- const [agentHostingProviderClient] = useState4(makeClient(client));
252
- return /* @__PURE__ */ React2.createElement(AgentHostingContext.Provider, {
253
- value: agentHostingProviderClient
254
- }, " ", props.children);
255
- };
256
- var useAgentHostingClient = () => {
257
- return useContext4(AgentHostingContext);
258
- };
259
- var makeClient = ({ config, halo }) => {
260
- const agentHostingConfig = config.get("runtime.services.agentHosting");
261
- if (!agentHostingConfig) {
262
- log2("no agent hosting configured", void 0, {
263
- F: __dxlog_file2,
264
- L: 39,
265
- S: void 0,
266
- C: (f, a) => f(...a)
267
- });
268
- return null;
269
- }
270
- let agentHostingProviderClient = null;
271
- switch (agentHostingConfig.type) {
272
- case "LOCAL_TESTING": {
273
- log2("using FakeAgentHostingProvider", void 0, {
274
- F: __dxlog_file2,
275
- L: 47,
276
- S: void 0,
277
- C: (f, a) => f(...a)
278
- });
279
- return new FakeAgentHostingProvider();
280
- }
281
- case "AGENTHOSTING_API": {
282
- agentHostingProviderClient = new AgentManagerClient(config, halo);
283
- if (agentHostingProviderClient.init()) {
284
- return agentHostingProviderClient;
285
- } else {
286
- return null;
287
- }
288
- }
289
- default: {
290
- log2.error("Unknown agent hosting provider type: " + agentHostingConfig.type, void 0, {
291
- F: __dxlog_file2,
292
- L: 62,
293
- S: void 0,
294
- C: (f, a) => f(...a)
295
- });
296
- return null;
297
- }
298
- }
299
- };
300
-
301
- export {
302
- AgentHostingContext,
303
- AgentHostingProvider,
304
- useAgentHostingClient,
305
- ClientContext,
306
- ClientProvider,
307
- useClient,
308
- useClientStatus,
309
- useConfig,
310
- useShell,
311
- useShellDisplay,
312
- useStatus
313
- };
314
- //# sourceMappingURL=chunk-ZTD6HPV2.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/client/AgentHostingProvider.tsx", "../../../src/client/ClientProvider.tsx", "../../../src/client/context.ts", "../../../src/banner.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, { createContext, type PropsWithChildren, 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 forwardRef,\n type FunctionComponent,\n type PropsWithChildren,\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 { useControlledState } from '@dxos/react-hooks';\nimport { getAsyncProviderValue, type MaybePromise, type Provider } from '@dxos/util';\n\nimport { ClientContext, type ClientContextProps } from './context';\nimport { printBanner } from '../banner';\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: configProvider,\n client: clientProvider,\n services: servicesProvider,\n status: controlledStatus,\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(clientProvider instanceof Client ? clientProvider : undefined);\n\n // Provide external access.\n useImperativeHandle(forwardedRef, () => client, [client]);\n\n // Client status subscription.\n const [status, setStatus] = useControlledState(controlledStatus);\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 useEffect(() => {\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\n if (!noBanner) {\n printBanner(client);\n }\n };\n\n let client: Client;\n const t = setTimeout(async () => {\n try {\n if (clientProvider) {\n // Asynchronously request client.\n client = await getAsyncProviderValue(clientProvider);\n await initialize(client);\n } else {\n // Asynchronously construct client (config may be undefined).\n const config = await getAsyncProviderValue(configProvider);\n log('resolved config', { config });\n const services = await getAsyncProviderValue(servicesProvider, 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\n return () => {\n log('clean up');\n disposed = true;\n clearTimeout(t);\n // Only destroy if the client is not provided by the parent.\n if (!clientProvider) {\n void client\n ?.destroy()\n .then(() => {\n log('destroyed');\n })\n .catch((err) => log.catch(err));\n }\n };\n }, [configProvider, clientProvider, servicesProvider, 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 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 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 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": "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",
6
- "names": ["React", "createContext", "useContext", "useState", "AgentManagerClient", "FakeAgentHostingProvider", "log", "React", "forwardRef", "useEffect", "useImperativeHandle", "useState", "Client", "SystemStatus", "registerSignalsRuntime", "log", "useControlledState", "getAsyncProviderValue", "createContext", "ClientContext", "createContext", "undefined", "BANNER", "client", "commitHash", "config", "get", "hash", "version", "bannerPrinted", "printBanner", "window", "location", "hostname", "console", "log", "ClientProvider", "forwardRef", "children", "config", "configProvider", "client", "clientProvider", "services", "servicesProvider", "status", "controlledStatus", "fallback", "Fallback", "signalsRuntime", "noBanner", "onInitialized", "options", "forwardedRef", "useEffect", "registerSignalsRuntime", "error", "setError", "useState", "setClient", "Client", "undefined", "useImperativeHandle", "setStatus", "useControlledState", "subscription", "subscribe", "unsubscribe", "disposed", "initialize", "initialized", "catch", "err", "log", "printBanner", "t", "setTimeout", "getAsyncProviderValue", "clearTimeout", "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,11 +0,0 @@
1
- import { type Echo, Filter, type Live, Query, type Space } from '@dxos/client/echo';
2
- interface UseQueryFn {
3
- <Q extends Query.Any>(spaceOrEcho: Space | Echo | undefined, query: Q, deps?: any[]): Live<Query.Type<Q>>[];
4
- <F extends Filter.Any>(spaceOrEcho: Space | Echo | undefined, filter: F, deps?: any[]): Live<Filter.Type<F>>[];
5
- }
6
- /**
7
- * Create subscription.
8
- */
9
- export declare const useQuery: UseQueryFn;
10
- export {};
11
- //# sourceMappingURL=useQuery.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useQuery.d.ts","sourceRoot":"","sources":["../../../../src/echo/useQuery.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,EAAE,KAAK,EAAE,KAAK,KAAK,EAAW,MAAM,mBAAmB,CAAC;AAO7F,UAAU,UAAU;IAClB,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,EAAE,WAAW,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAE5G,CAAC,CAAC,SAAS,MAAM,CAAC,GAAG,EAAE,WAAW,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;CAChH;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,UAiCtB,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=useQuery.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useQuery.test.d.ts","sourceRoot":"","sources":["../../../../src/echo/useQuery.test.tsx"],"names":[],"mappings":""}
@@ -1,8 +0,0 @@
1
- import { type Schema } from 'effect';
2
- import { type Client } from '@dxos/client';
3
- import { type Space } from '@dxos/client/echo';
4
- /**
5
- * Subscribe to and retrieve schema changes from a space's schema registry.
6
- */
7
- export declare const useSchema: (client: Client, space: Space | undefined, typename: string | undefined) => Schema.Schema.AnyNoContext | undefined;
8
- //# sourceMappingURL=useSchema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSchema.d.ts","sourceRoot":"","sources":["../../../../src/echo/useSchema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGrC,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG/C;;GAEG;AACH,eAAO,MAAM,SAAS,GACpB,QAAQ,MAAM,EACd,OAAO,KAAK,GAAG,SAAS,EACxB,UAAU,MAAM,GAAG,SAAS,KAC3B,MAAM,CAAC,MAAM,CAAC,YAAY,GAAG,SAmC/B,CAAC"}
@@ -1,3 +0,0 @@
1
- declare const _default: import("@playwright/test").PlaywrightTestConfig<{}, {}>;
2
- export default _default;
3
- //# sourceMappingURL=playwright.config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"playwright.config.d.ts","sourceRoot":"","sources":["../../../../src/playwright/playwright.config.ts"],"names":[],"mappings":";AAQA,wBAQG"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=smoke.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"smoke.spec.d.ts","sourceRoot":"","sources":["../../../../src/playwright/smoke.spec.ts"],"names":[],"mappings":""}
@@ -1,128 +0,0 @@
1
- //
2
- // Copyright 2022 DXOS.org
3
- //
4
-
5
- import { renderHook } from '@testing-library/react';
6
- import { describe, expect, test } from 'vitest';
7
-
8
- import { Expando, Filter, live } from '@dxos/client/echo';
9
-
10
- import { useQuery } from './useQuery';
11
- import { createClient, createClientContextProvider } from '../testing/util';
12
-
13
- describe('useQuery', () => {
14
- // TODO(dmaretskyi): Fix this test.
15
- test.skip('deleting an element should result in correct render sequence', async () => {
16
- // Setup: Create client and space.
17
- const { client, space } = await createClient({ createIdentity: true, createSpace: true });
18
- const wrapper = await createClientContextProvider(client);
19
-
20
- // Create 3 test objects: Alice, Bob, Charlie.
21
- const alice = live(Expando, { name: 'Alice' });
22
- const bob = live(Expando, { name: 'Bob' });
23
- const charlie = live(Expando, { name: 'Charlie' });
24
-
25
- space!.db.add(alice);
26
- space!.db.add(bob);
27
- space!.db.add(charlie);
28
- await space!.db.flush();
29
-
30
- // Track all renders to observe the bug.
31
- const allRenders: string[][] = [];
32
-
33
- // Setup useQuery hook that captures every render.
34
- renderHook(
35
- () => {
36
- const objects = useQuery(space, Filter.type(Expando));
37
-
38
- // Capture the names in this render.
39
- const namesInThisRender = objects.map((obj) => obj.name);
40
- allRenders.push([...namesInThisRender]);
41
-
42
- return objects;
43
- },
44
- { wrapper },
45
- );
46
-
47
- // Wait for initial renders to complete.
48
- await new Promise((resolve) => setTimeout(resolve, 100));
49
-
50
- // THE BUG REPRODUCTION: Delete Bob.
51
- space!.db.remove(bob);
52
-
53
- // Wait for all reactive updates to complete.
54
- await new Promise((resolve) => setTimeout(resolve, 500));
55
-
56
- // TODO(ZaymonFC): Remove this comment once the flash bug is resolved.
57
- /*
58
- * NOTE(ZaymonFC):
59
- * Expected: 3 renders
60
- * 1. [] (empty)
61
- * 2. ['Alice', 'Bob', 'Charlie'] (all loaded)
62
- * 3. ['Alice', 'Charlie'] (Bob removed, no flash)
63
- *
64
- * Actual: 4 renders
65
- * 1. [] (empty)
66
- * 2. ['Alice', 'Bob', 'Charlie'] (all loaded)
67
- * 3. ['Alice', 'Charlie', 'Bob'] (FLASH BUG - Bob moves to end!)
68
- * 4. ['Alice', 'Charlie'] (Bob finally removed)
69
- */
70
-
71
- expect(allRenders).toEqual([
72
- [], // Initial loading state.
73
- ['Alice', 'Bob', 'Charlie'], // All objects loaded.
74
- ['Alice', 'Charlie'], // Bob removed (no flash).
75
- ]);
76
- });
77
-
78
- test('bulk deleting multiple items should remove them from query results', async () => {
79
- // Setup: Create client and space.
80
- const { client, space } = await createClient({ createIdentity: true, createSpace: true });
81
- const wrapper = await createClientContextProvider(client);
82
-
83
- // Create 10 test objects: 1, 2, 3, ..., 10.
84
- const objects = Array.from({ length: 10 }, (_, i) => live(Expando, { value: i + 1 }));
85
-
86
- objects.forEach((obj) => space!.db.add(obj));
87
- await space!.db.flush();
88
-
89
- // Track all renders to observe the bug.
90
- const allRenders: number[][] = [];
91
-
92
- // Setup useQuery hook that captures every render.
93
- renderHook(
94
- () => {
95
- const queryObjects = useQuery(space, Filter.type(Expando));
96
-
97
- // Capture the values in this render.
98
- const valuesInThisRender = queryObjects.map((obj) => obj.value);
99
- allRenders.push([...valuesInThisRender]);
100
-
101
- return queryObjects;
102
- },
103
- { wrapper },
104
- );
105
-
106
- // Wait for initial renders to complete.
107
- await new Promise((resolve) => setTimeout(resolve, 100));
108
-
109
- // THE BUG REPRODUCTION: Delete all items in a loop.
110
- for (const item of objects) {
111
- space!.db.remove(item);
112
- }
113
-
114
- // Wait for all reactive updates to complete.
115
- await new Promise((resolve) => setTimeout(resolve, 500));
116
-
117
- // Convert to sets for order-independent comparison.
118
- const renderSets = allRenders.map((render) => new Set(render));
119
-
120
- expect(renderSets).toEqual([
121
- new Set([]), // Initial loading state.
122
- new Set([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), // All objects loaded.
123
- // TODO(dmaretskyi): Fix this with query ordering.
124
- new Set([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), // Getting another render for some reason.
125
- new Set([]), // All items deleted.
126
- ]);
127
- });
128
- });
@@ -1,56 +0,0 @@
1
- //
2
- // Copyright 2022 DXOS.org
3
- //
4
-
5
- import { useMemo, useSyncExternalStore } from 'react';
6
-
7
- import { type Echo, Filter, type Live, Query, type Space, isSpace } from '@dxos/client/echo';
8
-
9
- const EMPTY_ARRAY: never[] = [];
10
-
11
- const noop = () => {};
12
-
13
- // TODO(dmaretskyi): Queries are fully serializable, so we can remove `deps` argument.
14
- interface UseQueryFn {
15
- <Q extends Query.Any>(spaceOrEcho: Space | Echo | undefined, query: Q, deps?: any[]): Live<Query.Type<Q>>[];
16
-
17
- <F extends Filter.Any>(spaceOrEcho: Space | Echo | undefined, filter: F, deps?: any[]): Live<Filter.Type<F>>[];
18
- }
19
-
20
- /**
21
- * Create subscription.
22
- */
23
- export const useQuery: UseQueryFn = (
24
- spaceOrEcho: Space | Echo | undefined,
25
- queryOrFilter: Query.Any | Filter.Any,
26
- deps?: any[],
27
- ): Live<unknown>[] => {
28
- const query = Filter.is(queryOrFilter) ? Query.select(queryOrFilter) : queryOrFilter;
29
-
30
- const { getObjects, subscribe } = useMemo(() => {
31
- let subscribed = false;
32
- const queryResult =
33
- spaceOrEcho === undefined
34
- ? undefined
35
- : isSpace(spaceOrEcho)
36
- ? spaceOrEcho.db.query(query)
37
- : spaceOrEcho.query(query);
38
-
39
- return {
40
- getObjects: () => (subscribed && queryResult ? queryResult.objects : EMPTY_ARRAY),
41
- subscribe: (cb: () => void) => {
42
- subscribed = true;
43
- const unsubscribe = queryResult?.subscribe(cb) ?? noop;
44
- return () => {
45
- unsubscribe?.();
46
- subscribed = false;
47
- };
48
- },
49
- };
50
- }, [spaceOrEcho, JSON.stringify(query.ast), ...(deps ?? [])]);
51
-
52
- // https://beta.reactjs.org/reference/react/useSyncExternalStore
53
- // NOTE: This hook will resubscribe whenever the callback passed to the first argument changes; make sure it is stable.
54
- const objects = useSyncExternalStore<Live<unknown>[] | undefined>(subscribe, getObjects);
55
- return objects ?? [];
56
- };
@@ -1,54 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { type Schema } from 'effect';
6
- import { useMemo, useSyncExternalStore } from 'react';
7
-
8
- import { type Client } from '@dxos/client';
9
- import { type Space } from '@dxos/client/echo';
10
- import { type BaseSchema } from '@dxos/echo-schema';
11
-
12
- /**
13
- * Subscribe to and retrieve schema changes from a space's schema registry.
14
- */
15
- export const useSchema = (
16
- client: Client,
17
- space: Space | undefined,
18
- typename: string | undefined,
19
- ): Schema.Schema.AnyNoContext | undefined => {
20
- const { subscribe, getSchema } = useMemo(() => {
21
- if (!typename || !space) {
22
- return {
23
- subscribe: () => () => {},
24
- getSchema: () => undefined,
25
- };
26
- }
27
-
28
- const staticSchema = client.graph.schemaRegistry.getSchema(typename);
29
- if (staticSchema) {
30
- return {
31
- subscribe: () => () => {},
32
- getSchema: () => staticSchema,
33
- };
34
- }
35
-
36
- const query = space.db.schemaRegistry.query({ typename });
37
- const initialResult: BaseSchema = query.runSync()[0];
38
- let currentSchema = initialResult;
39
-
40
- return {
41
- subscribe: (onStoreChange: () => void) => {
42
- const unsubscribe = query.subscribe(() => {
43
- currentSchema = query.results[0];
44
- onStoreChange();
45
- });
46
-
47
- return unsubscribe;
48
- },
49
- getSchema: () => currentSchema,
50
- };
51
- }, [typename, space]);
52
-
53
- return useSyncExternalStore(subscribe, getSchema);
54
- };