@dxos/react-client 0.8.3 → 0.8.4-main.03d5cd7b56
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.
- package/.storybook/main.mts +9 -0
- package/.storybook/preview.mts +8 -0
- package/dist/lib/browser/chunk-3LVU7RNK.mjs +16 -0
- package/dist/lib/browser/chunk-3LVU7RNK.mjs.map +7 -0
- package/dist/lib/browser/chunk-CZMIVAGI.mjs +8 -0
- package/dist/lib/browser/chunk-CZMIVAGI.mjs.map +7 -0
- package/dist/lib/browser/chunk-XT352YI6.mjs +134 -0
- package/dist/lib/browser/chunk-XT352YI6.mjs.map +7 -0
- package/dist/lib/browser/{chunk-AL2CUQ46.mjs → chunk-YHE6WD44.mjs} +8 -18
- package/dist/lib/browser/chunk-YHE6WD44.mjs.map +7 -0
- package/dist/lib/browser/devtools/index.mjs +8 -12
- package/dist/lib/browser/devtools/index.mjs.map +3 -3
- package/dist/lib/browser/echo/index.mjs +67 -136
- package/dist/lib/browser/echo/index.mjs.map +4 -4
- package/dist/lib/browser/halo/index.mjs +12 -10
- package/dist/lib/browser/halo/index.mjs.map +3 -3
- package/dist/lib/browser/index.mjs +100 -13
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/invitations/index.mjs +1 -1
- package/dist/lib/browser/mesh/index.mjs +4 -3
- package/dist/lib/browser/mesh/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +117 -160
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/browser/worker.mjs +1 -1
- package/dist/lib/node-esm/chunk-CUDKNAMV.mjs +17 -0
- package/dist/lib/node-esm/chunk-CUDKNAMV.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-UYJUBYMU.mjs → chunk-RQJPEHDY.mjs} +8 -18
- package/dist/lib/node-esm/chunk-RQJPEHDY.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-WL3Z5HOH.mjs +135 -0
- package/dist/lib/node-esm/chunk-WL3Z5HOH.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-WUTK2IJF.mjs +10 -0
- package/dist/lib/node-esm/chunk-WUTK2IJF.mjs.map +7 -0
- package/dist/lib/node-esm/devtools/index.mjs +8 -12
- package/dist/lib/node-esm/devtools/index.mjs.map +3 -3
- package/dist/lib/node-esm/echo/index.mjs +67 -136
- package/dist/lib/node-esm/echo/index.mjs.map +4 -4
- package/dist/lib/node-esm/halo/index.mjs +12 -10
- package/dist/lib/node-esm/halo/index.mjs.map +3 -3
- package/dist/lib/node-esm/index.mjs +100 -13
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/invitations/index.mjs +1 -1
- package/dist/lib/node-esm/mesh/index.mjs +4 -3
- package/dist/lib/node-esm/mesh/index.mjs.map +1 -1
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +117 -160
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/worker.mjs +1 -1
- package/dist/types/src/banner.d.ts.map +1 -1
- package/dist/types/src/client/AgentHostingProvider.d.ts.map +1 -1
- package/dist/types/src/client/ClientProvider.d.ts +1 -11
- package/dist/types/src/client/ClientProvider.d.ts.map +1 -1
- package/dist/types/src/client/useClientStatus.d.ts.map +1 -1
- package/dist/types/src/devtools/useStream.d.ts.map +1 -1
- package/dist/types/src/echo/index.d.ts +2 -2
- package/dist/types/src/echo/index.d.ts.map +1 -1
- package/dist/types/src/echo/useMembers.d.ts +2 -2
- package/dist/types/src/echo/useMembers.d.ts.map +1 -1
- package/dist/types/src/echo/useQueue.d.ts +3 -2
- package/dist/types/src/echo/useQueue.d.ts.map +1 -1
- package/dist/types/src/echo/useSpaceInvitations.d.ts +3 -2
- package/dist/types/src/echo/useSpaceInvitations.d.ts.map +1 -1
- package/dist/types/src/echo/useSpaceProperties.d.ts +13 -0
- package/dist/types/src/echo/useSpaceProperties.d.ts.map +1 -0
- package/dist/types/src/echo/useSpaces.d.ts +19 -9
- package/dist/types/src/echo/useSpaces.d.ts.map +1 -1
- package/dist/types/src/echo/useSubscription.d.ts +1 -1
- package/dist/types/src/echo/useSubscription.d.ts.map +1 -1
- package/dist/types/src/echo/useSyncState.d.ts +1 -1
- package/dist/types/src/echo/useSyncState.d.ts.map +1 -1
- package/dist/types/src/halo/Passkey.stories.d.ts +5 -5
- package/dist/types/src/halo/Passkey.stories.d.ts.map +1 -1
- package/dist/types/src/halo/useHaloInvitations.d.ts.map +1 -1
- package/dist/types/src/halo/useKeyStore.d.ts.map +1 -1
- package/dist/types/src/invitations/useInvitationStatus.d.ts +1 -1
- package/dist/types/src/invitations/useInvitationStatus.d.ts.map +1 -1
- package/dist/types/src/testing/ClientRepeater.d.ts +6 -5
- package/dist/types/src/testing/ClientRepeater.d.ts.map +1 -1
- package/dist/types/src/testing/ClientRepeater.stories.d.ts +6 -10
- package/dist/types/src/testing/ClientRepeater.stories.d.ts.map +1 -1
- package/dist/types/src/testing/context.d.ts +4 -2
- package/dist/types/src/testing/context.d.ts.map +1 -1
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/dist/types/src/testing/withClientProvider.d.ts +6 -10
- package/dist/types/src/testing/withClientProvider.d.ts.map +1 -1
- package/dist/types/src/testing/withClientProvider.stories.d.ts +8 -9
- package/dist/types/src/testing/withClientProvider.stories.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/docs/README.md +38 -38
- package/moon.yml +20 -0
- package/package.json +43 -58
- package/src/client/AgentHostingProvider.tsx +1 -1
- package/src/client/ClientProvider.test.tsx +2 -2
- package/src/client/ClientProvider.tsx +32 -50
- package/src/client/useConfig.test.tsx +1 -1
- package/src/devtools/useStream.ts +1 -1
- package/src/echo/index.ts +2 -2
- package/src/echo/useMembers.ts +5 -3
- package/src/echo/useQueue.ts +3 -4
- package/src/echo/useSpaceInvitations.ts +10 -5
- package/src/echo/useSpaceProperties.ts +28 -0
- package/src/echo/useSpaces.test.tsx +8 -14
- package/src/echo/useSpaces.ts +32 -30
- package/src/echo/useSubscription.ts +1 -1
- package/src/echo/useSyncState.ts +5 -4
- package/src/halo/Passkey.stories.tsx +20 -20
- package/src/halo/useDevices.test.tsx +1 -1
- package/src/halo/useHaloInvitations.ts +1 -1
- package/src/invitations/useInvitationStatus.ts +9 -8
- package/src/testing/ClientRepeater.stories.tsx +22 -16
- package/src/testing/ClientRepeater.tsx +29 -37
- package/src/testing/context.tsx +4 -3
- package/src/testing/util.tsx +0 -1
- package/src/testing/withClientProvider.stories.tsx +34 -20
- package/src/testing/withClientProvider.tsx +77 -94
- package/tsconfig.json +3 -6
- package/typedoc.json +1 -1
- package/vitest.config.ts +10 -16
- package/.eslintrc.cjs +0 -12
- package/README.yml +0 -33
- package/dist/lib/browser/chunk-72QD3PXL.mjs +0 -312
- package/dist/lib/browser/chunk-72QD3PXL.mjs.map +0 -7
- package/dist/lib/browser/chunk-AL2CUQ46.mjs.map +0 -7
- package/dist/lib/node/chunk-5RUIFUEC.cjs +0 -334
- package/dist/lib/node/chunk-5RUIFUEC.cjs.map +0 -7
- package/dist/lib/node/chunk-FYOAVV65.cjs +0 -188
- package/dist/lib/node/chunk-FYOAVV65.cjs.map +0 -7
- package/dist/lib/node/devtools/index.cjs +0 -62
- package/dist/lib/node/devtools/index.cjs.map +0 -7
- package/dist/lib/node/echo/index.cjs +0 -302
- package/dist/lib/node/echo/index.cjs.map +0 -7
- package/dist/lib/node/halo/index.cjs +0 -123
- package/dist/lib/node/halo/index.cjs.map +0 -7
- package/dist/lib/node/index.cjs +0 -55
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/invitations/index.cjs +0 -39
- package/dist/lib/node/invitations/index.cjs.map +0 -7
- package/dist/lib/node/mesh/index.cjs +0 -37
- package/dist/lib/node/mesh/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/lib/node/testing/index.cjs +0 -278
- package/dist/lib/node/testing/index.cjs.map +0 -7
- package/dist/lib/node/worker.cjs +0 -23
- package/dist/lib/node/worker.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-NBTZZNQ5.mjs +0 -314
- package/dist/lib/node-esm/chunk-NBTZZNQ5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UYJUBYMU.mjs.map +0 -7
- package/dist/types/src/echo/useQuery.d.ts +0 -11
- package/dist/types/src/echo/useQuery.d.ts.map +0 -1
- package/dist/types/src/echo/useQuery.test.d.ts +0 -2
- package/dist/types/src/echo/useQuery.test.d.ts.map +0 -1
- package/dist/types/src/echo/useSchema.d.ts +0 -8
- package/dist/types/src/echo/useSchema.d.ts.map +0 -1
- package/dist/types/src/playwright/playwright.config.d.cts +0 -3
- package/dist/types/src/playwright/playwright.config.d.cts.map +0 -1
- package/dist/types/src/playwright/smoke.spec.d.ts +0 -2
- package/dist/types/src/playwright/smoke.spec.d.ts.map +0 -1
- package/project.json +0 -40
- package/src/echo/useQuery.test.tsx +0 -128
- package/src/echo/useQuery.ts +0 -56
- package/src/echo/useSchema.ts +0 -54
- package/src/playwright/playwright.config.cts +0 -18
- package/src/playwright/smoke.spec.ts +0 -26
- package/typedoc/.nojekyll +0 -1
- package/typedoc/assets/hierarchy.js +0 -1
- package/typedoc/assets/highlight.css +0 -99
- package/typedoc/assets/icons.js +0 -18
- package/typedoc/assets/icons.svg +0 -1
- package/typedoc/assets/main.js +0 -60
- package/typedoc/assets/navigation.js +0 -1
- package/typedoc/assets/search.js +0 -1
- package/typedoc/assets/style.css +0 -1640
- package/typedoc/classes/echo.Hypergraph.html +0 -17
- package/typedoc/classes/echo.PropertiesType.html +0 -19
- package/typedoc/classes/echo.QueryResult.html +0 -18
- package/typedoc/classes/halo.KeyStore.html +0 -6
- package/typedoc/classes/index.AgentClientServiceProvider.html +0 -10
- package/typedoc/classes/index.AgentManagerClient.html +0 -22
- package/typedoc/classes/index.AlreadyJoinedError.html +0 -15
- package/typedoc/classes/index.ApiError.html +0 -16
- package/typedoc/classes/index.CancelledError.html +0 -16
- package/typedoc/classes/index.Client.html +0 -51
- package/typedoc/classes/index.ClientServicesProxy.html +0 -12
- package/typedoc/classes/index.Config.html +0 -17
- package/typedoc/classes/index.DataCorruptionError.html +0 -16
- package/typedoc/classes/index.DatabaseError.html +0 -15
- package/typedoc/classes/index.EntityNotFoundError.html +0 -15
- package/typedoc/classes/index.FakeAgentHostingProvider.html +0 -7
- package/typedoc/classes/index.IFrameManager.html +0 -6
- package/typedoc/classes/index.IdentityNotInitializedError.html +0 -15
- package/typedoc/classes/index.InvalidConfigError.html +0 -16
- package/typedoc/classes/index.InvalidInvitationError.html +0 -15
- package/typedoc/classes/index.InvalidInvitationExtensionRoleError.html +0 -16
- package/typedoc/classes/index.InvalidStorageVersionError.html +0 -15
- package/typedoc/classes/index.LocalClientServices.html +0 -12
- package/typedoc/classes/index.PublicKey.html +0 -55
- package/typedoc/classes/index.RemoteServiceConnectionError.html +0 -15
- package/typedoc/classes/index.RemoteServiceConnectionTimeout.html +0 -15
- package/typedoc/classes/index.RpcClosedError.html +0 -15
- package/typedoc/classes/index.RpcNotOpenError.html +0 -15
- package/typedoc/classes/index.SharedWorkerConnection.html +0 -5
- package/typedoc/classes/index.Shell.html +0 -35
- package/typedoc/classes/index.ShellManager.html +0 -9
- package/typedoc/classes/index.SystemError.html +0 -16
- package/typedoc/classes/index.UnknownModelError.html +0 -15
- package/typedoc/classes/index.WorkerClientServices.html +0 -12
- package/typedoc/classes/invitations.AuthenticatingInvitationObservable.html +0 -30
- package/typedoc/classes/invitations.CancellableInvitationObservable.html +0 -29
- package/typedoc/classes/invitations.InvitationEncoder.html +0 -5
- package/typedoc/classes/invitations.InvitationsProxy.html +0 -12
- package/typedoc/enums/devtools.KeyType.html +0 -9
- package/typedoc/enums/echo.HaloSpaceMember.Role.html +0 -9
- package/typedoc/enums/echo.IndexKind.Kind.html +0 -8
- package/typedoc/enums/echo.QueryOptions.DataLocation.html +0 -6
- package/typedoc/enums/echo.QueryOptions.ShowDeletedOption.html +0 -6
- package/typedoc/enums/echo.ResultFormat.html +0 -10
- package/typedoc/enums/echo.SpaceMember.PresenceState.html +0 -5
- package/typedoc/enums/echo.SpaceState.html +0 -13
- package/typedoc/enums/echo.TextKind.html +0 -5
- package/typedoc/enums/halo.Device.PresenceState.html +0 -6
- package/typedoc/enums/halo.DeviceKind.html +0 -5
- package/typedoc/enums/halo.DeviceType.html +0 -9
- package/typedoc/enums/index.ShellDisplay.html +0 -5
- package/typedoc/enums/index.ShellLayout.html +0 -13
- package/typedoc/enums/index.SystemStatus.html +0 -5
- package/typedoc/enums/invitations.Invitation.AuthMethod.html +0 -6
- package/typedoc/enums/invitations.Invitation.Kind.html +0 -5
- package/typedoc/enums/invitations.Invitation.State.html +0 -13
- package/typedoc/enums/invitations.Invitation.Type.html +0 -6
- package/typedoc/enums/mesh.ConnectionState.html +0 -5
- package/typedoc/functions/devtools.useDevtools.html +0 -1
- package/typedoc/functions/devtools.useStream.html +0 -2
- package/typedoc/functions/echo.useMembers.html +0 -1
- package/typedoc/functions/echo.useQueue.html +0 -2
- package/typedoc/functions/echo.useSchema.html +0 -2
- package/typedoc/functions/echo.useSpace.html +0 -6
- package/typedoc/functions/echo.useSpaceInvitation.html +0 -1
- package/typedoc/functions/echo.useSpaceInvitations.html +0 -1
- package/typedoc/functions/echo.useSpaceSyncState.html +0 -2
- package/typedoc/functions/echo.useSpaces.html +0 -5
- package/typedoc/functions/echo.useSubscription.html +0 -3
- package/typedoc/functions/echo.useSyncState.html +0 -2
- package/typedoc/functions/halo.useContacts.html +0 -4
- package/typedoc/functions/halo.useCredentials.html +0 -1
- package/typedoc/functions/halo.useDevices.html +0 -1
- package/typedoc/functions/halo.useHaloInvitation.html +0 -1
- package/typedoc/functions/halo.useHaloInvitations.html +0 -1
- package/typedoc/functions/halo.useIdentity.html +0 -3
- package/typedoc/functions/halo.useKeyStore.html +0 -3
- package/typedoc/functions/index.AgentHostingProvider.html +0 -2
- package/typedoc/functions/index.useAgentHostingClient.html +0 -1
- package/typedoc/functions/index.useClient.html +0 -3
- package/typedoc/functions/index.useClientStatus.html +0 -1
- package/typedoc/functions/index.useConfig.html +0 -3
- package/typedoc/functions/index.useShell.html +0 -2
- package/typedoc/functions/index.useShellDisplay.html +0 -2
- package/typedoc/functions/index.useStatus.html +0 -1
- package/typedoc/functions/invitations.useInvitationStatus.html +0 -1
- package/typedoc/functions/mesh.useNetworkStatus.html +0 -2
- package/typedoc/hierarchy.html +0 -1
- package/typedoc/index.html +0 -23
- package/typedoc/interfaces/devtools.DevtoolsHook.html +0 -22
- package/typedoc/interfaces/devtools.DevtoolsHost.html +0 -26
- package/typedoc/interfaces/echo.DocAccessor.html +0 -3
- package/typedoc/interfaces/echo.Echo.html +0 -39
- package/typedoc/interfaces/echo.EchoDatabase.html +0 -25
- package/typedoc/interfaces/echo.Expando.html +0 -3
- package/typedoc/interfaces/echo.Filter.html +0 -3
- package/typedoc/interfaces/echo.HaloSpaceMember.html +0 -18
- package/typedoc/interfaces/echo.IDocHandle.html +0 -6
- package/typedoc/interfaces/echo.IndexKind.html +0 -9
- package/typedoc/interfaces/echo.Query.html +0 -34
- package/typedoc/interfaces/echo.QueryOptions.html +0 -39
- package/typedoc/interfaces/echo.Queue.html +0 -17
- package/typedoc/interfaces/echo.Ref.html +0 -32
- package/typedoc/interfaces/echo.Space.html +0 -39
- package/typedoc/interfaces/echo.SpaceMember.html +0 -7
- package/typedoc/interfaces/echo.SpaceSyncState.PeerState.html +0 -14
- package/typedoc/interfaces/echo.SpaceSyncState.html +0 -4
- package/typedoc/interfaces/echo.SubscriptionHandle.html +0 -5
- package/typedoc/interfaces/echo.TypedObject.html +0 -16
- package/typedoc/interfaces/halo.Contact.html +0 -10
- package/typedoc/interfaces/halo.Credential.html +0 -27
- package/typedoc/interfaces/halo.Device.html +0 -11
- package/typedoc/interfaces/halo.Halo.html +0 -16
- package/typedoc/interfaces/halo.Identity.html +0 -15
- package/typedoc/interfaces/index.AgentHostingProviderClient.html +0 -6
- package/typedoc/interfaces/index.AppContextRequest.html +0 -33
- package/typedoc/interfaces/index.ClientServicesProvider.html +0 -9
- package/typedoc/interfaces/index.InvitationUrlRequest.html +0 -9
- package/typedoc/interfaces/index.LayoutRequest.html +0 -29
- package/typedoc/interfaces/index.ShellRuntime.html +0 -15
- package/typedoc/interfaces/invitations.Invitation.html +0 -92
- package/typedoc/interfaces/invitations.Invitations.html +0 -5
- package/typedoc/interfaces/mesh.GossipMessage.html +0 -10
- package/typedoc/interfaces/mesh.NetworkStatus.Signal.html +0 -5
- package/typedoc/interfaces/mesh.NetworkStatus.html +0 -6
- package/typedoc/media/LICENSE +0 -8
- package/typedoc/modules/devtools.html +0 -1
- package/typedoc/modules/echo.Filter.html +0 -1
- package/typedoc/modules/echo.HaloSpaceMember.html +0 -1
- package/typedoc/modules/echo.IndexKind.html +0 -1
- package/typedoc/modules/echo.Query.html +0 -1
- package/typedoc/modules/echo.QueryOptions.html +0 -1
- package/typedoc/modules/echo.Ref.html +0 -2
- package/typedoc/modules/echo.SpaceMember.html +0 -1
- package/typedoc/modules/echo.SpaceSyncState.html +0 -1
- package/typedoc/modules/echo.html +0 -1
- package/typedoc/modules/halo.Device.html +0 -1
- package/typedoc/modules/halo.html +0 -1
- package/typedoc/modules/index.html +0 -1
- package/typedoc/modules/invitations.Invitation.html +0 -1
- package/typedoc/modules/invitations.html +0 -1
- package/typedoc/modules/mesh.NetworkStatus.html +0 -1
- package/typedoc/modules/mesh.html +0 -1
- package/typedoc/modules/worker.html +0 -1
- package/typedoc/modules.html +0 -1
- package/typedoc/types/devtools.MountOptions.html +0 -3
- package/typedoc/types/echo.AnyLiveObject.html +0 -2
- package/typedoc/types/echo.Filter.And.html +0 -1
- package/typedoc/types/echo.Filter.Any.html +0 -1
- package/typedoc/types/echo.Filter.Or.html +0 -1
- package/typedoc/types/echo.Filter.Props.html +0 -1
- package/typedoc/types/echo.Filter.Type.html +0 -1
- package/typedoc/types/echo.Live.html +0 -5
- package/typedoc/types/echo.ObjectMeta.html +0 -1
- package/typedoc/types/echo.ObjectMigration.html +0 -7
- package/typedoc/types/echo.ObjectVersion.html +0 -2
- package/typedoc/types/echo.PeerSyncState.html +0 -1
- package/typedoc/types/echo.Progress.html +0 -3
- package/typedoc/types/echo.PropertiesTypeProps.html +0 -1
- package/typedoc/types/echo.Query.Any.html +0 -1
- package/typedoc/types/echo.Query.TextSearchOptions.html +0 -2
- package/typedoc/types/echo.Query.Type.html +0 -1
- package/typedoc/types/echo.Ref.Target.html +0 -2
- package/typedoc/types/echo.Selection.html +0 -1
- package/typedoc/types/echo.SpaceId.html +0 -6
- package/typedoc/types/echo.SpaceSyncStateMap.html +0 -1
- package/typedoc/types/echo.UseQueueOptions.html +0 -2
- package/typedoc/types/echo.UseSpacesParams.html +0 -3
- package/typedoc/types/index.AgentHostingProviderProps.html +0 -3
- package/typedoc/types/index.ClientContextProps.html +0 -3
- package/typedoc/types/index.ClientOptions.html +0 -12
- package/typedoc/types/index.ClientProviderProps.html +0 -2
- package/typedoc/types/index.ClientServices.html +0 -15
- package/typedoc/types/index.FromAgentOptions.html +0 -2
- package/typedoc/types/index.PublicKeyLike.html +0 -2
- package/typedoc/types/invitations.InvitationAction.html +0 -1
- package/typedoc/types/invitations.InvitationResult.html +0 -5
- package/typedoc/types/invitations.InvitationStatus.html +0 -15
- package/typedoc/variables/devtools.mountDevtoolsHooks.html +0 -1
- package/typedoc/variables/devtools.unmountDevtoolsHooks.html +0 -1
- package/typedoc/variables/echo.DocAccessor.html +0 -1
- package/typedoc/variables/echo.EchoObjectSchema.html +0 -1
- package/typedoc/variables/echo.Expando.html +0 -1
- package/typedoc/variables/echo.FQ_ID_LENGTH.html +0 -1
- package/typedoc/variables/echo.Filter.html +0 -1
- package/typedoc/variables/echo.OBJECT_ID_LENGTH.html +0 -1
- package/typedoc/variables/echo.ObjectVersion.html +0 -1
- package/typedoc/variables/echo.Query.html +0 -1
- package/typedoc/variables/echo.Queue.html +0 -1
- package/typedoc/variables/echo.ReactiveObjectSchema.html +0 -1
- package/typedoc/variables/echo.Ref.html +0 -2
- package/typedoc/variables/echo.RefArray.html +0 -2
- package/typedoc/variables/echo.SPACE_ID_LENGTH.html +0 -1
- package/typedoc/variables/echo.SpaceId.html +0 -1
- package/typedoc/variables/echo.SpaceSchema.html +0 -1
- package/typedoc/variables/echo.TypedObject.html +0 -3
- package/typedoc/variables/echo.compareForeignKeys.html +0 -1
- package/typedoc/variables/echo.createDocAccessor.html +0 -1
- package/typedoc/variables/echo.createEmptyEdgeSyncState.html +0 -1
- package/typedoc/variables/echo.createObject.html +0 -1
- package/typedoc/variables/echo.createQueueDXN.html +0 -2
- package/typedoc/variables/echo.createSubscription.html +0 -5
- package/typedoc/variables/echo.defineObjectMigration.html +0 -1
- package/typedoc/variables/echo.fromCursor.html +0 -1
- package/typedoc/variables/echo.fullyQualifiedId.html +0 -4
- package/typedoc/variables/echo.getMeta.html +0 -1
- package/typedoc/variables/echo.getObjectCore.html +0 -1
- package/typedoc/variables/echo.getRangeFromCursor.html +0 -1
- package/typedoc/variables/echo.getSchema.html +0 -2
- package/typedoc/variables/echo.getSource.html +0 -4
- package/typedoc/variables/echo.getSpace.html +0 -1
- package/typedoc/variables/echo.getSyncSummary.html +0 -1
- package/typedoc/variables/echo.getTarget.html +0 -4
- package/typedoc/variables/echo.getTextInRange.html +0 -2
- package/typedoc/variables/echo.getType.html +0 -5
- package/typedoc/variables/echo.getTypename.html +0 -6
- package/typedoc/variables/echo.getVersion.html +0 -3
- package/typedoc/variables/echo.importSpace.html +0 -1
- package/typedoc/variables/echo.internalDecodeReference.html +0 -1
- package/typedoc/variables/echo.isEchoObject.html +0 -2
- package/typedoc/variables/echo.isLiveObject.html +0 -2
- package/typedoc/variables/echo.isRelation.html +0 -2
- package/typedoc/variables/echo.isSpace.html +0 -1
- package/typedoc/variables/echo.live.html +0 -3
- package/typedoc/variables/echo.loadObjectReferences.html +0 -7
- package/typedoc/variables/echo.makeRef.html +0 -2
- package/typedoc/variables/echo.parseFullyQualifiedId.html +0 -2
- package/typedoc/variables/echo.parseId.html +0 -1
- package/typedoc/variables/echo.refFromDXN.html +0 -2
- package/typedoc/variables/echo.toCursor.html +0 -1
- package/typedoc/variables/echo.toCursorRange.html +0 -1
- package/typedoc/variables/echo.updateText.html +0 -6
- package/typedoc/variables/echo.useQuery.html +0 -2
- package/typedoc/variables/index.AgentHostingContext.html +0 -1
- package/typedoc/variables/index.ClientProvider.html +0 -3
- package/typedoc/variables/index.DXOS_VERSION.html +0 -1
- package/typedoc/variables/index.Defaults.html +0 -2
- package/typedoc/variables/index.Dynamics.html +0 -2
- package/typedoc/variables/index.Envs.html +0 -2
- package/typedoc/variables/index.Local.html +0 -2
- package/typedoc/variables/index.Remote.html +0 -1
- package/typedoc/variables/index.Storage.html +0 -2
- package/typedoc/variables/index.createClientServices.html +0 -4
- package/typedoc/variables/index.fromAgent.html +0 -2
- package/typedoc/variables/index.fromHost.html +0 -2
- package/typedoc/variables/index.fromSocket.html +0 -2
- package/typedoc/variables/index.fromWorker.html +0 -2
- package/typedoc/variables/index.getUnixSocket.html +0 -1
- package/typedoc/variables/index.resolveRef.html +0 -1
- package/typedoc/variables/index.useMulticastObservable.html +0 -3
- package/typedoc/variables/worker.getWorkerServiceHost.html +0 -1
- package/typedoc/variables/worker.onconnect.html +0 -1
|
@@ -1,62 +1,57 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ClientProvider
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-XT352YI6.mjs";
|
|
4
|
+
import "../chunk-CZMIVAGI.mjs";
|
|
4
5
|
|
|
5
|
-
//
|
|
6
|
+
// src/testing/index.ts
|
|
6
7
|
export * from "@dxos/client/testing";
|
|
7
8
|
|
|
8
|
-
//
|
|
9
|
+
// src/testing/context.tsx
|
|
9
10
|
import { createContext, useContext } from "react";
|
|
10
11
|
import { raise } from "@dxos/debug";
|
|
11
12
|
var ClientStory = /* @__PURE__ */ createContext(void 0);
|
|
12
|
-
var
|
|
13
|
+
var useClientStory = () => {
|
|
13
14
|
return useContext(ClientStory) ?? raise(new Error("Missing ClientStory"));
|
|
14
15
|
};
|
|
15
16
|
|
|
16
|
-
//
|
|
17
|
-
import React, {
|
|
17
|
+
// src/testing/ClientRepeater.tsx
|
|
18
|
+
import React, { useRef, useState } from "react";
|
|
18
19
|
import { Client } from "@dxos/client";
|
|
19
20
|
import { TestBuilder, performInvitation } from "@dxos/client/testing";
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
21
|
+
import { random } from "@dxos/random";
|
|
22
|
+
import { useAsyncEffect } from "@dxos/react-hooks";
|
|
22
23
|
var ClientRepeater = (props) => {
|
|
23
|
-
const { component: Component, controls: Controls, count = 1, types, createIdentity, createSpace,
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
registerSignalsRuntime();
|
|
26
|
-
}, []);
|
|
24
|
+
const { component: Component, controls: Controls, count = 1, types, createIdentity, createSpace, onCreateSpace } = props;
|
|
27
25
|
const [clients, setClients] = useState(props.clients ?? []);
|
|
28
|
-
const [
|
|
26
|
+
const [spaceId, setSpaceId] = useState();
|
|
29
27
|
const testBuilder = useRef(new TestBuilder());
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
setClients(clients2);
|
|
58
|
-
});
|
|
59
|
-
return () => clearTimeout(timeout);
|
|
28
|
+
useAsyncEffect(async () => {
|
|
29
|
+
const clients2 = [
|
|
30
|
+
...Array(count)
|
|
31
|
+
].map((_) => new Client({
|
|
32
|
+
services: testBuilder.current.createLocalClientServices(),
|
|
33
|
+
types
|
|
34
|
+
}));
|
|
35
|
+
await Promise.all(clients2.map((client) => client.initialize()));
|
|
36
|
+
if (createIdentity || createSpace) {
|
|
37
|
+
await Promise.all(clients2.map((client) => client.halo.createIdentity()));
|
|
38
|
+
}
|
|
39
|
+
if (createSpace) {
|
|
40
|
+
const client = clients2[0];
|
|
41
|
+
const space = await client.spaces.create({
|
|
42
|
+
name: random.commerce.productName()
|
|
43
|
+
});
|
|
44
|
+
setSpaceId(space.id);
|
|
45
|
+
await onCreateSpace?.({
|
|
46
|
+
client,
|
|
47
|
+
space
|
|
48
|
+
}, {});
|
|
49
|
+
await Promise.all(clients2.slice(1).flatMap((client2) => performInvitation({
|
|
50
|
+
host: space,
|
|
51
|
+
guest: client2.spaces
|
|
52
|
+
})));
|
|
53
|
+
}
|
|
54
|
+
setClients(clients2);
|
|
60
55
|
}, []);
|
|
61
56
|
if (clients.length === 0) {
|
|
62
57
|
return null;
|
|
@@ -69,26 +64,26 @@ var ClientRepeater = (props) => {
|
|
|
69
64
|
}, /* @__PURE__ */ React.createElement(Component, {
|
|
70
65
|
id: index,
|
|
71
66
|
count: clients.length,
|
|
72
|
-
|
|
67
|
+
spaceId,
|
|
73
68
|
...props.args
|
|
74
69
|
}))));
|
|
75
70
|
};
|
|
76
71
|
|
|
77
|
-
//
|
|
78
|
-
import React2, {
|
|
79
|
-
import { ErrorBoundary as NativeErrorBoundary } from "react-error-boundary";
|
|
72
|
+
// src/testing/withClientProvider.tsx
|
|
73
|
+
import React2, { useCallback, useMemo, useRef as useRef2, useState as useState2 } from "react";
|
|
80
74
|
import { Trigger } from "@dxos/async";
|
|
81
|
-
import {
|
|
75
|
+
import { TestBuilder as TestBuilder2, performInvitation as performInvitation2 } from "@dxos/client/testing";
|
|
82
76
|
import { log } from "@dxos/log";
|
|
83
|
-
|
|
84
|
-
var
|
|
77
|
+
import { ErrorBoundary } from "@dxos/react-ui";
|
|
78
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/sdk/react-client/src/testing/withClientProvider.tsx";
|
|
79
|
+
var initializeClient = async (client, { createIdentity, createSpace, onCreateIdentity, onCreateSpace, onInitialized }, context) => {
|
|
85
80
|
await onInitialized?.(client);
|
|
86
81
|
if (createIdentity || createSpace) {
|
|
87
82
|
if (!client.halo.identity.get()) {
|
|
88
83
|
await client.halo.createIdentity();
|
|
89
|
-
await
|
|
84
|
+
await onCreateIdentity?.({
|
|
90
85
|
client
|
|
91
|
-
});
|
|
86
|
+
}, context);
|
|
92
87
|
}
|
|
93
88
|
}
|
|
94
89
|
let space;
|
|
@@ -96,29 +91,33 @@ var initializeClient = async (client, { createIdentity, createSpace, onSpaceCrea
|
|
|
96
91
|
space = await client.spaces.create({
|
|
97
92
|
name: "Test Space"
|
|
98
93
|
});
|
|
99
|
-
await
|
|
94
|
+
await space.waitUntilReady();
|
|
95
|
+
await onCreateSpace?.({
|
|
100
96
|
client,
|
|
101
97
|
space
|
|
102
98
|
}, context);
|
|
103
99
|
}
|
|
104
100
|
return {
|
|
105
|
-
space
|
|
101
|
+
space,
|
|
102
|
+
spaceId: space?.id
|
|
106
103
|
};
|
|
107
104
|
};
|
|
108
|
-
var withClientProvider = ({ createIdentity, createSpace,
|
|
105
|
+
var withClientProvider = ({ createIdentity, createSpace, onCreateSpace, onCreateIdentity, onInitialized, ...props } = {}) => {
|
|
109
106
|
return (Story, context) => {
|
|
110
107
|
const [data, setData] = useState2({});
|
|
111
108
|
const handleInitialized = async (client) => {
|
|
112
109
|
const data2 = await initializeClient(client, {
|
|
113
110
|
createIdentity,
|
|
114
111
|
createSpace,
|
|
115
|
-
|
|
116
|
-
|
|
112
|
+
onCreateSpace,
|
|
113
|
+
onCreateIdentity,
|
|
117
114
|
onInitialized
|
|
118
115
|
}, context);
|
|
119
116
|
setData(data2);
|
|
120
117
|
};
|
|
121
|
-
return /* @__PURE__ */ React2.createElement(ErrorBoundary,
|
|
118
|
+
return /* @__PURE__ */ React2.createElement(ErrorBoundary, {
|
|
119
|
+
name: "client-provider"
|
|
120
|
+
}, /* @__PURE__ */ React2.createElement(ClientProvider, {
|
|
122
121
|
onInitialized: handleInitialized,
|
|
123
122
|
...props
|
|
124
123
|
}, /* @__PURE__ */ React2.createElement(ClientStory.Provider, {
|
|
@@ -126,121 +125,79 @@ var withClientProvider = ({ createIdentity, createSpace, onSpaceCreated, onIdent
|
|
|
126
125
|
}, /* @__PURE__ */ React2.createElement(Story, null))));
|
|
127
126
|
};
|
|
128
127
|
};
|
|
129
|
-
var
|
|
130
|
-
id: 0
|
|
131
|
-
});
|
|
132
|
-
var useMultiClient = () => useContext2(MultiClientContext);
|
|
133
|
-
var withMultiClientProvider = ({ numClients = 2, createIdentity, createSpace, onSpaceCreated, onIdentityCreated, onInitialized, ...props }) => {
|
|
128
|
+
var withMultiClientProvider = ({ numClients = 2, createIdentity, createSpace, onCreateSpace, onCreateIdentity, onInitialized, ...props }) => {
|
|
134
129
|
return (Story, context) => {
|
|
135
|
-
const builder = useRef2(new TestBuilder2());
|
|
136
|
-
const hostRef = useRef2();
|
|
137
130
|
const spaceReady = useRef2(new Trigger());
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
131
|
+
const [spaceId, setSpaceId] = useState2();
|
|
132
|
+
const clients = useMemo(() => {
|
|
133
|
+
const buidler = new TestBuilder2();
|
|
134
|
+
return Array.from({
|
|
135
|
+
length: numClients
|
|
136
|
+
}).map(() => {
|
|
137
|
+
return {
|
|
138
|
+
services: buidler.createLocalClientServices()
|
|
139
|
+
};
|
|
146
140
|
});
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
guest: client.spaces
|
|
184
|
-
}));
|
|
185
|
-
}
|
|
141
|
+
}, [
|
|
142
|
+
numClients
|
|
143
|
+
]);
|
|
144
|
+
const handleInitialized = useCallback(async (client, index) => {
|
|
145
|
+
if (index === 0) {
|
|
146
|
+
const { space } = await initializeClient(client, {
|
|
147
|
+
createIdentity,
|
|
148
|
+
createSpace,
|
|
149
|
+
onCreateSpace,
|
|
150
|
+
onCreateIdentity,
|
|
151
|
+
onInitialized
|
|
152
|
+
}, context);
|
|
153
|
+
log.info("inviting", {
|
|
154
|
+
index,
|
|
155
|
+
spaceId: space?.id
|
|
156
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 95, S: void 0 });
|
|
157
|
+
setSpaceId(space?.id);
|
|
158
|
+
spaceReady.current.wake(space);
|
|
159
|
+
} else {
|
|
160
|
+
await initializeClient(client, {
|
|
161
|
+
createIdentity,
|
|
162
|
+
onInitialized
|
|
163
|
+
}, context);
|
|
164
|
+
log.info("waiting", {
|
|
165
|
+
index
|
|
166
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 107, S: void 0 });
|
|
167
|
+
const space = await spaceReady.current.wait();
|
|
168
|
+
if (space) {
|
|
169
|
+
log.info("joining", {
|
|
170
|
+
index,
|
|
171
|
+
spaceId: space.id
|
|
172
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 112, S: void 0 });
|
|
173
|
+
await Promise.all(performInvitation2({
|
|
174
|
+
host: space,
|
|
175
|
+
guest: client.spaces
|
|
176
|
+
}));
|
|
186
177
|
}
|
|
187
178
|
}
|
|
188
|
-
};
|
|
189
|
-
return /* @__PURE__ */ React2.createElement(
|
|
190
|
-
|
|
191
|
-
}
|
|
179
|
+
}, []);
|
|
180
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
181
|
+
className: "absolute inset-0 grid grid-flow-col auto-cols-fr gap-4 overflow-hidden"
|
|
182
|
+
}, clients.map((client, index) => /* @__PURE__ */ React2.createElement(ClientProvider, {
|
|
192
183
|
key: index,
|
|
184
|
+
services: client.services,
|
|
185
|
+
onInitialized: (client2) => handleInitialized(client2, index),
|
|
186
|
+
...props
|
|
187
|
+
}, /* @__PURE__ */ React2.createElement(ClientStory.Provider, {
|
|
193
188
|
value: {
|
|
194
|
-
|
|
189
|
+
index,
|
|
190
|
+
spaceId
|
|
195
191
|
}
|
|
196
|
-
}, /* @__PURE__ */ React2.createElement(
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
...props
|
|
200
|
-
}, /* @__PURE__ */ React2.createElement(Story, null)))));
|
|
201
|
-
};
|
|
202
|
-
};
|
|
203
|
-
var ErrorBoundary = ({ children }) => {
|
|
204
|
-
const [error, setError] = useState2();
|
|
205
|
-
useEffect2(() => {
|
|
206
|
-
const handleError = (event) => {
|
|
207
|
-
setError(event.reason);
|
|
208
|
-
};
|
|
209
|
-
window.addEventListener("unhandledrejection", handleError);
|
|
210
|
-
return () => window.removeEventListener("unhandledrejection", handleError);
|
|
211
|
-
}, []);
|
|
212
|
-
if (error) {
|
|
213
|
-
return /* @__PURE__ */ React2.createElement(ErrorFallback, {
|
|
214
|
-
error,
|
|
215
|
-
resetErrorBoundary: () => setError(void 0)
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
return /* @__PURE__ */ React2.createElement(NativeErrorBoundary, {
|
|
219
|
-
FallbackComponent: ErrorFallback
|
|
220
|
-
}, children);
|
|
221
|
-
};
|
|
222
|
-
var ErrorFallback = ({ error }) => {
|
|
223
|
-
const { name, message, stack } = error instanceof Error ? error : {
|
|
224
|
-
name: "Error",
|
|
225
|
-
message: String(error),
|
|
226
|
-
stack: void 0
|
|
192
|
+
}, /* @__PURE__ */ React2.createElement(ErrorBoundary, {
|
|
193
|
+
name: "client-provider"
|
|
194
|
+
}, /* @__PURE__ */ React2.createElement(Story, null))))));
|
|
227
195
|
};
|
|
228
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
229
|
-
role: "alert",
|
|
230
|
-
className: "flex flex-col p-4 gap-4 overflow-auto"
|
|
231
|
-
}, /* @__PURE__ */ React2.createElement("h1", {
|
|
232
|
-
className: "text-xl text-red-500"
|
|
233
|
-
}, name), /* @__PURE__ */ React2.createElement("div", {
|
|
234
|
-
className: "text-lg"
|
|
235
|
-
}, message), stack && /* @__PURE__ */ React2.createElement("pre", {
|
|
236
|
-
className: "whitespace-pre-wrap text-sm text-subdued"
|
|
237
|
-
}, stack));
|
|
238
196
|
};
|
|
239
197
|
export {
|
|
240
198
|
ClientRepeater,
|
|
241
199
|
ClientStory,
|
|
242
|
-
|
|
243
|
-
useMultiClient,
|
|
200
|
+
useClientStory,
|
|
244
201
|
withClientProvider,
|
|
245
202
|
withMultiClientProvider
|
|
246
203
|
};
|
|
@@ -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": "
|
|
6
|
-
"names": ["createContext", "useContext", "raise", "ClientStory", "
|
|
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, type SpaceId } from '@dxos/client/echo';\nimport { raise } from '@dxos/debug';\n\nexport type ClientStory = {\n index?: number;\n spaceId?: SpaceId;\n space?: Space;\n};\n\nexport const ClientStory = createContext<ClientStory | undefined>(undefined);\n\nexport const useClientStory = (): ClientStory => {\n return useContext(ClientStory) ?? raise(new Error('Missing ClientStory'));\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport React, { type FC, useRef, useState } from 'react';\n\nimport { Client } from '@dxos/client';\nimport { TestBuilder, performInvitation } from '@dxos/client/testing';\nimport { type Type } from '@dxos/echo';\nimport { random } from '@dxos/random';\nimport { useAsyncEffect } from '@dxos/react-hooks';\n\nimport { ClientProvider } from '../client';\nimport { type SpaceId } from '../echo';\nimport { type WithClientProviderProps } from './withClientProvider';\n\nexport type ClientRepeatedComponentProps = { id: number; count: number; spaceId?: SpaceId };\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?: Type.AnyObj[];\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\n const [clients, setClients] = useState(props.clients ?? []);\n const [spaceId, setSpaceId] = useState<SpaceId>();\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: random.commerce.productName() });\n setSpaceId(space.id);\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} spaceId={spaceId} {...{ ...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, { useCallback, useMemo, useRef, useState } from 'react';\n\nimport { Trigger } from '@dxos/async';\nimport { type Client } from '@dxos/client';\nimport { type Space, type SpaceId } from '@dxos/client/echo';\nimport { TestBuilder, performInvitation } from '@dxos/client/testing';\nimport { log } from '@dxos/log';\nimport { ErrorBoundary } from '@dxos/react-ui';\nimport { type MaybePromise } from '@dxos/util';\n\nimport { ClientProvider, type ClientProviderProps } from '../client';\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 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, spaceId: space?.id };\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 name='client-provider'>\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\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 spaceReady = useRef(new Trigger<Space | undefined>());\n const [spaceId, setSpaceId] = useState<SpaceId>();\n\n const clients = useMemo(() => {\n const buidler = new TestBuilder();\n return Array.from({ length: numClients }).map(() => {\n return {\n services: buidler.createLocalClientServices(),\n };\n });\n }, [numClients]);\n\n // Handle invitations.\n // NOTE: The zeroth client isn't necessarily the first to be initialized.\n const handleInitialized = useCallback(async (client: Client, index: number) => {\n if (index === 0) {\n // Initialize host.\n const { space } = await initializeClient(\n client,\n {\n createIdentity,\n createSpace,\n onCreateSpace,\n onCreateIdentity,\n onInitialized,\n },\n context,\n );\n\n log.info('inviting', { index, spaceId: space?.id });\n setSpaceId(space?.id);\n spaceReady.current.wake(space);\n } else {\n // Initialize guest.\n await initializeClient(client, { createIdentity, onInitialized }, context);\n\n log.info('waiting', { index });\n const space = await spaceReady.current.wait();\n if (space) {\n log.info('joining', { index, spaceId: space.id });\n await Promise.all(\n performInvitation({\n host: space,\n guest: client.spaces,\n }),\n );\n }\n }\n }, []);\n\n return (\n <div className='absolute inset-0 grid grid-flow-col auto-cols-fr gap-4 overflow-hidden'>\n {clients.map((client, index) => (\n <ClientProvider\n key={index}\n services={client.services}\n onInitialized={(client) => handleInitialized(client, index)}\n {...props}\n >\n <ClientStory.Provider value={{ index, spaceId }}>\n <ErrorBoundary name='client-provider'>\n <Story />\n </ErrorBoundary>\n </ClientStory.Provider>\n </ClientProvider>\n ))}\n </div>\n );\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;AAIA,cAAc;;;ACAd,SAASA,eAAeC,kBAAkB;AAG1C,SAASC,aAAa;AAQf,IAAMC,cAAcH,8BAAuCI,MAAAA;AA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AA,GAAA,cAAA,GAAA,KAAA,GAAA,OAAA,CAAA;cACTG,QAAS,MAAA,WAAW,QAAA,KAAA;mBAAEH;cAAOxB,KAAAA,WAAeyB;YAAG;YAC/C,SAAMG,MACJC;2BACQ9B,YAAAA,GAAAA,cAAAA,GAAAA,KAAAA,GAAAA,OAAAA,CAAAA;gBACN+B,QAAOjC,IAAOkC,mBAAM;YACtB,MAAA;YAEJ,OAAA,OAAA;UACF,CAAA,CAAA;QACG;MAEL;QACOC,CAAAA;WACWnC,gBAAAA,OAAQ2B,cAAAA,OACpB;iBACOA;eACLF,IAAAA,CAAAA,QAAUzB,UAAe,gBAAAW,OAAA,cAAA,gBAAA;MACzBF,KAAAA;MACC,UAAQ,OAAA;qBAET,CAAAT,YAAA,kBAACoC,SAAYC,KAAQ;MAACxB,GAAAA;OAASc,gBAAAA,OAAAA,cAAAA,YAAAA,UAAAA;aAAOxB;QAAQ;;MAC7BmC;OACb,gBAAA3B,OAAA,cAACG,eAAAA;MAOf,MAAA;IACA,GAAA,gBAAAH,OAAA,cAAA,OAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;;",
|
|
6
|
+
"names": ["createContext", "useContext", "raise", "ClientStory", "undefined", "useClientStory", "Error", "React", "useRef", "useState", "Client", "TestBuilder", "performInvitation", "random", "useAsyncEffect", "ClientRepeater", "props", "component", "Component", "controls", "Controls", "count", "types", "createIdentity", "createSpace", "onCreateSpace", "clients", "setClients", "useState", "spaceId", "setSpaceId", "testBuilder", "useRef", "TestBuilder", "useAsyncEffect", "Array", "map", "_", "Client", "services", "current", "createLocalClientServices", "Promise", "all", "client", "initialize", "halo", "space", "spaces", "create", "name", "random", "commerce", "productName", "id", "slice", "flatMap", "performInvitation", "host", "guest", "length", "index", "ClientProvider", "key", "args", "React", "useCallback", "useMemo", "useRef", "useState", "Trigger", "TestBuilder", "performInvitation", "log", "ErrorBoundary", "createIdentity", "createSpace", "identity", "halo", "onCreateIdentity", "client", "context", "space", "spaceId", "data", "useState", "handleInitialized", "initializeClient", "onCreateSpace", "onInitialized", "setData", "React", "ClientProvider", "value", "Story", "spaceReady", "Trigger", "setSpaceId", "clients", "useMemo", "buidler", "TestBuilder", "Array", "length", "numClients", "services", "info", "index", "id", "current", "log", "Promise", "performInvitation", "guest", "spaces", "className", "ClientStory", "Provider", "name"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
ClientContext
|
|
4
|
+
} from "./chunk-WUTK2IJF.mjs";
|
|
5
|
+
|
|
6
|
+
// src/client/useClient.ts
|
|
7
|
+
import { useContext } from "react";
|
|
8
|
+
import { raise } from "@dxos/debug";
|
|
9
|
+
var useClient = () => {
|
|
10
|
+
const { client } = useContext(ClientContext) ?? raise(new Error("Missing ClientContext."));
|
|
11
|
+
return client;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
useClient
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=chunk-CUDKNAMV.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/client/useClient.ts"],
|
|
4
|
+
"sourcesContent": ["//\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"],
|
|
5
|
+
"mappings": ";;;;;;AAIA,SAASA,kBAAkB;AAE3B,SAASC,aAAa;AAQf,IAAMC,YAAY,MAAA;AACvB,QAAM,EAAEC,OAAM,IAAKC,WAAWC,aAAAA,KAAkBC,MAAM,IAAIC,MAAM,wBAAA,CAAA;AAChE,SAAOJ;AACT;",
|
|
6
|
+
"names": ["useContext", "raise", "useClient", "client", "useContext", "ClientContext", "raise", "Error"]
|
|
7
|
+
}
|
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
|
|
3
|
-
//
|
|
3
|
+
// src/invitations/index.ts
|
|
4
4
|
import { AuthenticatingInvitationObservable, CancellableInvitationObservable, InvitationEncoder as InvitationEncoder2, Invitation as Invitation2, InvitationsProxy } from "@dxos/client/invitations";
|
|
5
5
|
|
|
6
|
-
//
|
|
7
|
-
import {
|
|
6
|
+
// src/invitations/useInvitationStatus.ts
|
|
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
|
-
var __dxlog_file = "/
|
|
11
|
-
var isShareableInvitation = (invitation) => invitation.authMethod !== Invitation.AuthMethod.KNOWN_PUBLIC_KEY || invitation.guestKeypair?.privateKey;
|
|
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;
|
|
12
12
|
var useInvitationStatus = (observable) => {
|
|
13
13
|
const [state, dispatch] = useReducer((prev, action) => {
|
|
14
14
|
log("useInvitationStatus", {
|
|
15
15
|
action
|
|
16
|
-
}, {
|
|
17
|
-
F: __dxlog_file,
|
|
18
|
-
L: 90,
|
|
19
|
-
S: void 0,
|
|
20
|
-
C: (f, a) => f(...a)
|
|
21
|
-
});
|
|
16
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 12, S: void 0 });
|
|
22
17
|
const invitationProps = "invitation" in action ? {
|
|
23
18
|
id: action.invitation.invitationId,
|
|
24
19
|
multiUse: action.invitation.multiUse,
|
|
@@ -126,12 +121,7 @@ var useInvitationStatus = (observable) => {
|
|
|
126
121
|
const authenticate = useCallback((authCode) => {
|
|
127
122
|
log("authenticating...", {
|
|
128
123
|
authCode
|
|
129
|
-
}, {
|
|
130
|
-
F: __dxlog_file,
|
|
131
|
-
L: 195,
|
|
132
|
-
S: void 0,
|
|
133
|
-
C: (f, a) => f(...a)
|
|
134
|
-
});
|
|
124
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 125, S: void 0 });
|
|
135
125
|
return observable.authenticate(authCode);
|
|
136
126
|
}, [
|
|
137
127
|
observable
|
|
@@ -162,4 +152,4 @@ export {
|
|
|
162
152
|
Invitation2 as Invitation,
|
|
163
153
|
InvitationsProxy
|
|
164
154
|
};
|
|
165
|
-
//# sourceMappingURL=chunk-
|
|
155
|
+
//# sourceMappingURL=chunk-RQJPEHDY.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, authenticate]);\n};\n"],
|
|
5
|
+
"mappings": ";;;AAKA,SACEA,oCACAC,iCACAC,qBAAAA,oBACAC,cAAAA,aAEAC,wBACK;;;ACRP,SAASC,aAAaC,WAAWC,SAASC,kBAAkB;AAG5D,SAGEC,YACAC,yBACK;AACP,SAASC,WAAW;AAqEpB,IAAA,eAAA;IAME,wBAA0BH,CAAAA,eACvBI,WAA8BC,eAAAA,WAAAA,WAAAA,oBAAAA,CAAAA,CAAAA,WAAAA,cAAAA;IACzB,sBAAuB,CAAA,eAAA;gBAAEA,QAAAA,IAAAA,WAAAA,CAAAA,MAAAA,WAAAA;AAAO,QAAA,uBAAA;MACpC;qBAGYA,YAAiB,GAACC,cAAY,GAAA,IAAA,GAAA,OAAA,CAAA;UAClCC,kBAAiBC,gBAAmB,SAAA;MACpCC,IAAAA,OAAAA,WAAgBP;MAChBQ,UAAUL,OAAOG,WAAWE;MAC5BC,gBAAYN,kBAAkBM,OAAU,OAAA,UAAA;MACxCC,UAAAA,OAAWC,WAAAA;MACXC,YAAMT,OAAOG,WAAe;MAE9B,WAAC,sBAAA,OAAA,UAAA;MACP,MAAO,OAAA,WAAA;QACL,CAAA;WACGO;MACH,GAAA;MACAC,GAAAA;;MAEAC,QAAQZ,OAAOW;;MAEf,QAAIX,OAAOW,WAAWf,WAAgB,MAAM,UAAI,OAAA,SAAA,KAAA;;MAAsB,GAAC,OA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A,IAAAA;AACT,QAAA,cAAA;AAEA,aAAaC,YAAAA;IACZ;AAACC,WAAAA,MAAAA,cAAAA,YAAAA;;IAAyB;IAE7B,MAAA;EAEA,CAAA;kBACazB,YAAYyB,CAAAA,gBAAc;aAAIjB;MAAqCiB,YAAAA,YAAAA,IAAAA;MAAW,QAAA,WAAA,MAAA;MACtF,YAAAA;IAEL,CAAA;MAEI9B,CAAAA;uBAA2BO,YAAAA,CAAAA,aAAAA;AAAS,QAAA,qBAAA;MACpC;IAEF,GAAA,EAAA,YAAA,YAAA,GAAA,cAAA,GAAA,KAAA,GAAA,OAAA,CAAA;AAACuB,WAAAA,WAAAA,aAAAA,QAAAA;KAAW;IAGd;;QAAyE,SAAA,YAAA,YAAA,YAAA,OAAA,GAAA;IAEzE;;iBAEOC,MAAK;WACRC;MACAC,GAAAA;MACAC;MACF;MACC;IAACH;;IAAeE;IAASC;IAAa;IACzC;;;",
|
|
6
|
+
"names": ["AuthenticatingInvitationObservable", "CancellableInvitationObservable", "InvitationEncoder", "Invitation", "InvitationsProxy", "useCallback", "useEffect", "useMemo", "useReducer", "Invitation", "InvitationEncoder", "log", "prev", "action", "invitationId", "multiUse", "invitation", "invitationCode", "authCode", "authMethod", "shareable", "isShareableInvitation", "type", "invitationProps", "status", "result", "INIT", "spaceKey", "identityKey", "swarmKey", "target", "State", "READY_FOR_AUTHENTICATION", "AUTHENTICATING", "dispatch", "haltedAt", "ERROR", "error", "update", "currentState", "subscription", "observable", "state", "cancel", "connect", "authenticate"]
|
|
7
|
+
}
|