@dxos/react-client 0.12.0-next-73daef452f1464b62efdbca75fb0067c1066f264 → 0.13.0
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/CHANGELOG.md +176 -14
- package/dist/lib/chunk-ClientProvider.mjs +23 -20
- package/dist/lib/chunk-ClientProvider.mjs.map +1 -1
- package/dist/lib/chunk-useClient.mjs.map +1 -1
- package/dist/lib/devtools.mjs.map +1 -1
- package/dist/lib/echo.mjs +23 -8
- package/dist/lib/echo.mjs.map +1 -1
- package/dist/lib/halo.mjs +11 -2
- package/dist/lib/halo.mjs.map +1 -1
- package/dist/lib/index.mjs +10 -2
- package/dist/lib/index.mjs.map +1 -1
- package/dist/lib/invitations.mjs +22 -21
- package/dist/lib/invitations.mjs.map +1 -1
- package/dist/lib/mesh.mjs.map +1 -1
- package/dist/lib/testing.mjs +13 -10
- package/dist/lib/testing.mjs.map +1 -1
- package/dist/types/src/client/ClientProvider.d.ts +1 -1
- package/dist/types/src/client/ClientProvider.d.ts.map +1 -1
- package/dist/types/src/client/index.d.ts +9 -9
- package/dist/types/src/client/index.d.ts.map +1 -1
- package/dist/types/src/client/useEdgeServiceEndpoint.d.ts +6 -1
- package/dist/types/src/client/useEdgeServiceEndpoint.d.ts.map +1 -1
- package/dist/types/src/devtools/index.d.ts +2 -2
- package/dist/types/src/devtools/index.d.ts.map +1 -1
- package/dist/types/src/echo/ECHO.stories.d.ts +15 -0
- package/dist/types/src/echo/ECHO.stories.d.ts.map +1 -0
- package/dist/types/src/echo/index.d.ts +9 -9
- package/dist/types/src/echo/index.d.ts.map +1 -1
- package/dist/types/src/echo/useFeedSyncState.d.ts +1 -1
- package/dist/types/src/echo/useFeedSyncState.d.ts.map +1 -1
- package/dist/types/src/echo/useFeedSyncState.test.d.ts +2 -0
- package/dist/types/src/echo/useFeedSyncState.test.d.ts.map +1 -0
- package/dist/types/src/echo/useMembers.d.ts.map +1 -1
- package/dist/types/src/echo/useSpaceInvitations.d.ts +2 -2
- package/dist/types/src/echo/useSpaceInvitations.d.ts.map +1 -1
- package/dist/types/src/halo/Passkey.stories.d.ts.map +1 -1
- package/dist/types/src/halo/index.d.ts +8 -7
- package/dist/types/src/halo/index.d.ts.map +1 -1
- package/dist/types/src/halo/useHaloInvitations.d.ts +2 -2
- package/dist/types/src/halo/useHaloInvitations.d.ts.map +1 -1
- package/dist/types/src/halo/useInboxMessages.d.ts +6 -0
- package/dist/types/src/halo/useInboxMessages.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/invitations/index.d.ts +2 -2
- package/dist/types/src/invitations/index.d.ts.map +1 -1
- package/dist/types/src/invitations/useInvitationStatus.d.ts +13 -13
- package/dist/types/src/invitations/useInvitationStatus.d.ts.map +1 -1
- package/dist/types/src/mesh/index.d.ts +1 -1
- package/dist/types/src/mesh/index.d.ts.map +1 -1
- package/dist/types/src/testing/ClientRepeater.d.ts +1 -1
- package/dist/types/src/testing/ClientRepeater.d.ts.map +1 -1
- package/dist/types/src/testing/ClientRepeater.stories.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +3 -3
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/withClientProvider.d.ts +14 -2
- package/dist/types/src/testing/withClientProvider.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +26 -23
- package/src/client/AgentHostingProvider.tsx +2 -2
- package/src/client/ClientProvider.test.tsx +108 -11
- package/src/client/ClientProvider.tsx +73 -64
- package/src/client/index.ts +9 -9
- package/src/client/useClient.ts +1 -1
- package/src/client/useConfig.test.tsx +5 -7
- package/src/client/useConfig.ts +1 -1
- package/src/client/useEdgeServiceEndpoint.ts +13 -4
- package/src/client/useShell.ts +1 -1
- package/src/client/useStatus.ts +1 -1
- package/src/devtools/index.ts +2 -2
- package/src/devtools/useDevtools.ts +1 -1
- package/src/echo/ECHO.stories.tsx +134 -0
- package/src/echo/index.ts +9 -9
- package/src/echo/useFeedSyncState.test.tsx +54 -0
- package/src/echo/useFeedSyncState.ts +38 -7
- package/src/echo/useMembers.ts +3 -3
- package/src/echo/useRegistry.ts +1 -1
- package/src/echo/useSpaceInvitations.ts +2 -2
- package/src/echo/useSpaceProperties.ts +1 -1
- package/src/echo/useSpaces.test.tsx +2 -2
- package/src/echo/useSpaces.ts +1 -1
- package/src/echo/useSyncState.ts +1 -1
- package/src/halo/Passkey.stories.tsx +33 -23
- package/src/halo/index.ts +9 -7
- package/src/halo/useContacts.ts +1 -1
- package/src/halo/useCredentials.ts +1 -1
- package/src/halo/useDevices.test.tsx +2 -2
- package/src/halo/useDevices.ts +1 -1
- package/src/halo/useHaloInvitations.ts +2 -2
- package/src/halo/useIdentity.ts +1 -1
- package/src/halo/useInboxMessages.ts +16 -0
- package/src/index.ts +1 -1
- package/src/invitations/index.ts +7 -2
- package/src/invitations/useInvitationStatus.ts +42 -39
- package/src/mesh/index.ts +1 -1
- package/src/mesh/useNetworkStatus.ts +1 -1
- package/src/testing/ClientRepeater.stories.tsx +9 -8
- package/src/testing/ClientRepeater.tsx +2 -2
- package/src/testing/index.ts +3 -3
- package/src/testing/util.tsx +1 -1
- package/src/testing/withClientProvider.stories.tsx +4 -4
- package/src/testing/withClientProvider.tsx +31 -12
- package/tsconfig.json +6 -0
package/dist/lib/halo.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"halo.mjs","names":[],"sources":["../../src/halo/useContacts.ts","../../src/halo/useCredentials.ts","../../src/halo/useDevices.ts","../../src/halo/useHaloInvitations.ts","../../src/halo/useIdentity.ts","../../src/halo/useKeyStore.ts"],"sourcesContent":["//\n// Copyright 2020 DXOS.org\n//\n\nimport type { Contact } from '@dxos/client/halo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\n\n/**\n * Returns all known Contacts across all Spaces.\n * Contacts are known members of a common Space.\n * Requires ClientContext to be set via ClientProvider.\n */\nexport const useContacts = (): Contact[] => {\n const client = useClient();\n return useMulticastObservable(client.halo.contacts);\n};\n","//\n// Copyright 2020 DXOS.org\n//\n\nimport type { Credential } from '@dxos/client/halo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\n\nexport const useCredentials = (): Credential[] => {\n const client = useClient();\n return useMulticastObservable(client.halo.credentials);\n};\n","//\n// Copyright 2020 DXOS.org\n//\n\nimport type { Device } from '@dxos/client/halo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\n\nexport const useDevices = (): Device[] => {\n const client = useClient();\n return useMulticastObservable(client.halo.devices);\n};\n","//\n// Copyright 2022 DXOS.org\n//\n\nimport { useMemo } from 'react';\n\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\nimport { type CancellableInvitationObservable, useInvitationStatus } from '../invitations';\n\nexport const useHaloInvitations = (): CancellableInvitationObservable[] => {\n const client = useClient();\n return useMulticastObservable(client.halo.invitations);\n};\n\nexport const useHaloInvitation = (invitationId?: string) => {\n const invitations = useHaloInvitations();\n const invitation = useMemo(\n () => invitations.find((invitation) => invitation.get().invitationId === invitationId),\n [invitations],\n );\n return useInvitationStatus(invitation);\n};\n","//\n// Copyright 2020 DXOS.org\n//\n\nimport { type Identity } from '@dxos/client/halo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\n\n/**\n * Hook returning DXOS identity object.\n * Requires ClientContext to be set via ClientProvider.\n */\nexport const useIdentity = (): Identity | null => {\n const client = useClient();\n return useMulticastObservable(client.halo.identity);\n};\n","//\n// Copyright 2023 DXOS.org\n//\n\nimport { useMemo, useReducer } from 'react';\n\n// TODO(burdon): Move to settings plugin.\nexport class KeyStore {\n private _keyMap = new Map<string, string>();\n\n constructor(private readonly _defaultKeys: string[] = []) {}\n\n get map() {\n return this._keyMap;\n }\n\n // TODO(burdon): Create subkeys.\n initialize(): this {\n this._defaultKeys.forEach((key) => {\n const value = localStorage.getItem(key);\n this.setKey(key, value ?? '');\n });\n\n return this;\n }\n\n getKey(key: string): void {\n localStorage.getItem(key);\n }\n\n setKey(key: string, value: string): void {\n localStorage.setItem(key, '');\n this._keyMap.set(key, value);\n }\n}\n\n/**\n * Settings store.\n * @deprecated Replace with HALO key store when available.\n */\nexport const useKeyStore = (\n defaultKeys: string[] = [],\n): [Map<string, string>, (key: string, value: string) => void] => {\n const [, forceUpdate] = useReducer((x) => x + 1, 0);\n const store = useMemo(() => new KeyStore(defaultKeys).initialize(), [defaultKeys]);\n const setKey = (key: string, value: string) => {\n store.setKey(key, value);\n forceUpdate();\n };\n\n return [store.map, setKey];\n};\n"],"mappings":";;;;;;;;;;;AAcA,IAAa,oBAA+B;CAC1C,MAAM,SAAS,UAAU;CACzB,OAAO,uBAAuB,OAAO,KAAK,QAAQ;AACpD;;;ACRA,IAAa,uBAAqC;CAChD,MAAM,SAAS,UAAU;CACzB,OAAO,uBAAuB,OAAO,KAAK,WAAW;AACvD;;;ACHA,IAAa,mBAA6B;CACxC,MAAM,SAAS,UAAU;CACzB,OAAO,uBAAuB,OAAO,KAAK,OAAO;AACnD;;;ACDA,IAAa,2BAA8D;CACzE,MAAM,SAAS,UAAU;CACzB,OAAO,uBAAuB,OAAO,KAAK,WAAW;AACvD;AAEA,IAAa,qBAAqB,iBAA0B;CAC1D,MAAM,cAAc,mBAAmB;CACvC,MAAM,aAAa,cACX,YAAY,MAAM,eAAe,WAAW,IAAI,CAAC,CAAC,iBAAiB,YAAY,GACrF,CAAC,WAAW,CACd;CACA,OAAO,oBAAoB,UAAU;AACvC;;;;;;;ACVA,IAAa,oBAAqC;CAChD,MAAM,SAAS,UAAU;CACzB,OAAO,uBAAuB,OAAO,KAAK,QAAQ;AACpD;;;
|
|
1
|
+
{"version":3,"file":"halo.mjs","names":[],"sources":["../../src/halo/useContacts.ts","../../src/halo/useCredentials.ts","../../src/halo/useDevices.ts","../../src/halo/useHaloInvitations.ts","../../src/halo/useIdentity.ts","../../src/halo/useInboxMessages.ts","../../src/halo/useKeyStore.ts"],"sourcesContent":["//\n// Copyright 2020 DXOS.org\n//\n\nimport type { Contact } from '@dxos/client/halo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client/index.ts';\n\n/**\n * Returns all known Contacts across all Spaces.\n * Contacts are known members of a common Space.\n * Requires ClientContext to be set via ClientProvider.\n */\nexport const useContacts = (): Contact[] => {\n const client = useClient();\n return useMulticastObservable(client.halo.contacts);\n};\n","//\n// Copyright 2020 DXOS.org\n//\n\nimport type { Credential } from '@dxos/client/halo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client/index.ts';\n\nexport const useCredentials = (): Credential[] => {\n const client = useClient();\n return useMulticastObservable(client.halo.credentials);\n};\n","//\n// Copyright 2020 DXOS.org\n//\n\nimport type { Device } from '@dxos/client/halo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client/index.ts';\n\nexport const useDevices = (): Device[] => {\n const client = useClient();\n return useMulticastObservable(client.halo.devices);\n};\n","//\n// Copyright 2022 DXOS.org\n//\n\nimport { useMemo } from 'react';\n\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client/index.ts';\nimport { type CancellableInvitationObservable, useInvitationStatus } from '../invitations/index.ts';\n\nexport const useHaloInvitations = (): CancellableInvitationObservable[] => {\n const client = useClient();\n return useMulticastObservable(client.halo.invitations);\n};\n\nexport const useHaloInvitation = (invitationId?: string) => {\n const invitations = useHaloInvitations();\n const invitation = useMemo(\n () => invitations.find((invitation) => invitation.get().invitationId === invitationId),\n [invitations],\n );\n return useInvitationStatus(invitation);\n};\n","//\n// Copyright 2020 DXOS.org\n//\n\nimport { type Identity } from '@dxos/client/halo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client/index.ts';\n\n/**\n * Hook returning DXOS identity object.\n * Requires ClientContext to be set via ClientProvider.\n */\nexport const useIdentity = (): Identity | null => {\n const client = useClient();\n return useMulticastObservable(client.halo.identity);\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport { type InboxService } from '@dxos/protocols/rpc';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client/index.ts';\n\n/**\n * Pending verified inbox messages for the local identity; not filtered by sender.\n */\nexport const useInboxMessages = (): readonly InboxService.InboxMessage[] => {\n const client = useClient();\n return useMulticastObservable(client.halo.inbox.messages);\n};\n","//\n// Copyright 2023 DXOS.org\n//\n\nimport { useMemo, useReducer } from 'react';\n\n// TODO(burdon): Move to settings plugin.\nexport class KeyStore {\n private _keyMap = new Map<string, string>();\n\n constructor(private readonly _defaultKeys: string[] = []) {}\n\n get map() {\n return this._keyMap;\n }\n\n // TODO(burdon): Create subkeys.\n initialize(): this {\n this._defaultKeys.forEach((key) => {\n const value = localStorage.getItem(key);\n this.setKey(key, value ?? '');\n });\n\n return this;\n }\n\n getKey(key: string): void {\n localStorage.getItem(key);\n }\n\n setKey(key: string, value: string): void {\n localStorage.setItem(key, '');\n this._keyMap.set(key, value);\n }\n}\n\n/**\n * Settings store.\n * @deprecated Replace with HALO key store when available.\n */\nexport const useKeyStore = (\n defaultKeys: string[] = [],\n): [Map<string, string>, (key: string, value: string) => void] => {\n const [, forceUpdate] = useReducer((x) => x + 1, 0);\n const store = useMemo(() => new KeyStore(defaultKeys).initialize(), [defaultKeys]);\n const setKey = (key: string, value: string) => {\n store.setKey(key, value);\n forceUpdate();\n };\n\n return [store.map, setKey];\n};\n"],"mappings":";;;;;;;;;;;AAcA,IAAa,oBAA+B;CAC1C,MAAM,SAAS,UAAU;CACzB,OAAO,uBAAuB,OAAO,KAAK,QAAQ;AACpD;;;ACRA,IAAa,uBAAqC;CAChD,MAAM,SAAS,UAAU;CACzB,OAAO,uBAAuB,OAAO,KAAK,WAAW;AACvD;;;ACHA,IAAa,mBAA6B;CACxC,MAAM,SAAS,UAAU;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K,KAAK;EACvB,YAAY;CACd;CAEA,OAAO,CAAC,MAAM,KAAK,MAAM;AAC3B"}
|
package/dist/lib/index.mjs
CHANGED
|
@@ -85,9 +85,17 @@ var useConfig = () => {
|
|
|
85
85
|
//#region src/client/useEdgeServiceEndpoint.ts
|
|
86
86
|
/**
|
|
87
87
|
* Hook resolving an EDGE service endpoint from the client config; `undefined` when the service is
|
|
88
|
-
* not configured.
|
|
88
|
+
* not configured.
|
|
89
|
+
*
|
|
90
|
+
* Returns `undefined` outside a `ClientProvider` rather than throwing: the callers are app-wide
|
|
91
|
+
* drivers mounted by `Capabilities.ReactContext`, which render during startup and on any path where
|
|
92
|
+
* the client never arrives — a throw there takes the whole app to the fatal dialog over an endpoint
|
|
93
|
+
* the driver only needs once it has work to do.
|
|
89
94
|
*/
|
|
90
|
-
var useEdgeServiceEndpoint = (serviceName) =>
|
|
95
|
+
var useEdgeServiceEndpoint = (serviceName) => {
|
|
96
|
+
const context = useContext(ClientContext);
|
|
97
|
+
return context ? getEdgeServiceEndpoint(context.client.config, serviceName) : void 0;
|
|
98
|
+
};
|
|
91
99
|
//#endregion
|
|
92
100
|
//#region src/client/useShell.ts
|
|
93
101
|
/**
|
package/dist/lib/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/client/AgentHostingProvider.tsx","../../src/client/useClientStatus.ts","../../src/client/useConfig.ts","../../src/client/useEdgeServiceEndpoint.ts","../../src/client/useShell.ts","../../src/client/useStatus.ts"],"sourcesContent":["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { type PropsWithChildren, 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\n// Imported from the defining module, not the directory barrel: `'../client'` is this file's own\n// barrel, and that cycle made every downstream edit a full page reload.\nimport { AgentHostingContext } from './context';\nimport { useClient } from './useClient';\n\nexport type AgentHostingProviderProps = { config: Config; halo: Halo };\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\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 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 2026 DXOS.org\n//\n\nimport { type EdgeServiceName, getEdgeServiceEndpoint } from '@dxos/config';\n\nimport {
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/client/AgentHostingProvider.tsx","../../src/client/useClientStatus.ts","../../src/client/useConfig.ts","../../src/client/useEdgeServiceEndpoint.ts","../../src/client/useShell.ts","../../src/client/useStatus.ts"],"sourcesContent":["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { type PropsWithChildren, 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\n// Imported from the defining module, not the directory barrel: `'../client'` is this file's own\n// barrel, and that cycle made every downstream edit a full page reload.\nimport { AgentHostingContext } from './context.ts';\nimport { useClient } from './useClient.ts';\n\nexport type AgentHostingProviderProps = { config: Config; halo: Halo };\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\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 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.ts';\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 2026 DXOS.org\n//\n\nimport { useContext } from 'react';\n\nimport { type EdgeServiceName, getEdgeServiceEndpoint } from '@dxos/config';\n\nimport { ClientContext } from './context.ts';\n\n/**\n * Hook resolving an EDGE service endpoint from the client config; `undefined` when the service is\n * not configured.\n *\n * Returns `undefined` outside a `ClientProvider` rather than throwing: the callers are app-wide\n * drivers mounted by `Capabilities.ReactContext`, which render during startup and on any path where\n * the client never arrives — a throw there takes the whole app to the fatal dialog over an endpoint\n * the driver only needs once it has work to do.\n */\nexport const useEdgeServiceEndpoint = (serviceName: EdgeServiceName): string | undefined => {\n const context = useContext(ClientContext);\n return context ? getEdgeServiceEndpoint(context.client.config, serviceName) : undefined;\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.ts';\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.ts';\n\nexport const useStatus = (): SystemStatus | null | undefined => {\n const { status } = useContext(ClientContext) ?? raise(new Error('Missing ClientContext.'));\n return status;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwBA,IAAa,wBAAwB,UAA6B;CAChE,MAAM,SAAS,UAAU;CACzB,MAAM,CAAC,8BAA8B,SAAS,WAAW,MAAM,CAAC;CAChE,OACE,qBAAC,oBAAoB,UAArB;EAA8B,OAAO;EAArC,UAAA,CAAiE,KAAE,MAAM,QAAuC;;AAEpH;AAEA,IAAM,cAAc,EAAE,QAAQ,WAAsC;CAClE,MAAM,qBAAqB,OAAO,IAAI,+BAA+B;CACrE,IAAI,CAAC,oBAAoB;EACvB,IAAI,+BAA4B,KAAA,GAAA;GAAA,YAAA;GAAA,GAAA;GAAA,GAAA;GAAA,GAAA,KAAA;EAAA,CAAC;EACjC,OAAO;CACT;CAGA,IAAI,6BAAgE;CACpE,QAAQ,mBAAmB,MAA3B;EACE,KAAK;GACH,IAAI,kCAA+B,KAAA,GAAA;IAAA,YAAA;IAAA,GAAA;IAAA,GAAA;IAAA,GAAA,KAAA;GAAA,CAAC;GACpC,OAAO,IAAI,yBAAyB;EAGtC,KAAK;GACH,6BAA6B,IAAI,mBAAmB,QAAQ,IAAI;GAChE,IAAI,2BAA2B,KAAK,GAClC,OAAO;QAGP,OAAO;EAIX;GACE,IAAI,MAAM,0CAA0C,mBAAmB,MAAG,KAAA,GAAA;IAAA,YAAA;IAAA,GAAA;IAAA,GAAA;IAAA,GAAA,KAAA;GAAA,CAAC;GAC3E,OAAO;CAEX;AACF;;;ACtDA,IAAa,mBAAmB,WAAmB;CACjD,MAAM,CAAC,QAAQ,aAAa,SAA8B;CAC1D,gBAAgB;EACd,IAAI,CAAC,QACH;EAGF,MAAM,eAAe,OAAO,OAAO,WAAW,WAAW,UAAU,MAAM,CAAC;EAC1E,aAAa,aAAa,YAAY;CACxC,GAAG,CAAC,QAAQ,SAAS,CAAC;CAEtB,OAAO;AACT;;;;;;;ACNA,IAAa,kBAAkB;CAC7B,MAAM,EAAE,WAAW,WAAW,aAAa,KAAK,sBAAM,IAAI,MAAM,wBAAwB,CAAC;CACzF,OAAO,OAAO;AAChB;;;;;;;;;;;;ACEA,IAAa,0BAA0B,gBAAqD;CAC1F,MAAM,UAAU,WAAW,aAAa;CACxC,OAAO,UAAU,uBAAuB,QAAQ,OAAO,QAAQ,WAAW,IAAI,KAAA;AAChF;;;;;;ACTA,IAAa,iBAAwB;CAEnC,OADe,UACR,CAAA,CAAO;AAChB;;;;AAKA,IAAa,wBAAsC;CACjD,MAAM,SAAS,UAAU;CACzB,MAAM,CAAC,SAAS,cAAc,SAAS,OAAO,MAAM,OAAO;CAC3D,gBAAgB,OAAO,MAAM,gBAAgB,UAAU,GAAG,CAAC,MAAM,CAAC;CAClE,OAAO;AACT;;;ACfA,IAAa,kBAAmD;CAC9D,MAAM,EAAE,WAAW,WAAW,aAAa,KAAK,sBAAM,IAAI,MAAM,wBAAwB,CAAC;CACzF,OAAO;AACT"}
|
package/dist/lib/invitations.mjs
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useReducer } from "react";
|
|
2
|
+
import { PublicKey } from "@dxos/client";
|
|
2
3
|
import { log } from "@dxos/log";
|
|
3
|
-
import { AuthenticatingInvitationObservable, CancellableInvitationObservable,
|
|
4
|
+
import { AuthenticatingInvitationObservable, CancellableInvitationObservable, InvitationEncoder, InvitationEncoder as InvitationEncoder$1, InvitationSchema, Invitation_AuthMethod, Invitation_AuthMethod as Invitation_AuthMethod$1, Invitation_Kind, Invitation_State, Invitation_State as Invitation_State$1, Invitation_Type, InvitationsProxy } from "@dxos/client/invitations";
|
|
4
5
|
//#region src/invitations/useInvitationStatus.ts
|
|
5
6
|
var __dxlog_file = "/__w/dxos/dxos/packages/sdk/react-client/src/invitations/useInvitationStatus.ts";
|
|
6
|
-
var isShareableInvitation = (invitation) => invitation.authMethod !==
|
|
7
|
+
var isShareableInvitation = (invitation) => invitation.authMethod !== Invitation_AuthMethod$1.KNOWN_PUBLIC_KEY || !!invitation.guestKeypair?.privateKey;
|
|
7
8
|
var useInvitationStatus = (observable) => {
|
|
8
9
|
const [state, dispatch] = useReducer((prev, action) => {
|
|
9
10
|
log("useInvitationStatus", { action }, {
|
|
10
11
|
"~LogMeta": "~LogMeta",
|
|
11
12
|
F: __dxlog_file,
|
|
12
|
-
L:
|
|
13
|
+
L: 94,
|
|
13
14
|
S: void 0
|
|
14
15
|
});
|
|
15
16
|
const invitationProps = "invitation" in action ? {
|
|
@@ -25,14 +26,14 @@ var useInvitationStatus = (observable) => {
|
|
|
25
26
|
...prev,
|
|
26
27
|
...invitationProps,
|
|
27
28
|
status: action.status,
|
|
28
|
-
result: action.status ===
|
|
29
|
-
...action.status ===
|
|
30
|
-
...(action.status ===
|
|
29
|
+
result: action.status === Invitation_State$1.SUCCESS ? action.result : prev.result,
|
|
30
|
+
...action.status === Invitation_State$1.ERROR && { error: action.error },
|
|
31
|
+
...(action.status === Invitation_State$1.ERROR || action.status === Invitation_State$1.CANCELLED || action.status === Invitation_State$1.TIMEOUT) && { haltedAt: typeof prev.haltedAt === "undefined" ? action.haltedAt : prev.haltedAt }
|
|
31
32
|
};
|
|
32
33
|
}, null, (_arg) => {
|
|
33
34
|
const invitation = observable?.get();
|
|
34
35
|
return {
|
|
35
|
-
status:
|
|
36
|
+
status: Invitation_State$1.INIT,
|
|
36
37
|
result: {
|
|
37
38
|
spaceKey: null,
|
|
38
39
|
identityKey: null,
|
|
@@ -51,29 +52,29 @@ var useInvitationStatus = (observable) => {
|
|
|
51
52
|
useEffect(() => {
|
|
52
53
|
const update = (invitation) => {
|
|
53
54
|
switch (invitation.state) {
|
|
54
|
-
case
|
|
55
|
-
case
|
|
56
|
-
case
|
|
57
|
-
case
|
|
55
|
+
case Invitation_State$1.INIT:
|
|
56
|
+
case Invitation_State$1.CONNECTED:
|
|
57
|
+
case Invitation_State$1.READY_FOR_AUTHENTICATION:
|
|
58
|
+
case Invitation_State$1.AUTHENTICATING:
|
|
58
59
|
dispatch({
|
|
59
60
|
invitation,
|
|
60
61
|
status: invitation.state
|
|
61
62
|
});
|
|
62
63
|
break;
|
|
63
|
-
case
|
|
64
|
+
case Invitation_State$1.SUCCESS:
|
|
64
65
|
dispatch({
|
|
65
66
|
invitation,
|
|
66
67
|
status: invitation.state,
|
|
67
68
|
result: {
|
|
68
|
-
spaceKey: invitation.spaceKey
|
|
69
|
-
identityKey: invitation.identityKey
|
|
70
|
-
swarmKey: invitation.swarmKey
|
|
69
|
+
spaceKey: invitation.spaceKey ? PublicKey.from(invitation.spaceKey.data) : null,
|
|
70
|
+
identityKey: invitation.identityKey ? PublicKey.from(invitation.identityKey.data) : null,
|
|
71
|
+
swarmKey: invitation.swarmKey ? PublicKey.from(invitation.swarmKey.data) : null,
|
|
71
72
|
target: invitation.target || null
|
|
72
73
|
}
|
|
73
74
|
});
|
|
74
75
|
break;
|
|
75
|
-
case
|
|
76
|
-
case
|
|
76
|
+
case Invitation_State$1.CANCELLED:
|
|
77
|
+
case Invitation_State$1.TIMEOUT: dispatch({
|
|
77
78
|
invitation,
|
|
78
79
|
status: invitation.state,
|
|
79
80
|
haltedAt: state.status
|
|
@@ -82,7 +83,7 @@ var useInvitationStatus = (observable) => {
|
|
|
82
83
|
};
|
|
83
84
|
const subscription = observable?.subscribe(update, (err) => {
|
|
84
85
|
dispatch({
|
|
85
|
-
status:
|
|
86
|
+
status: Invitation_State$1.ERROR,
|
|
86
87
|
error: err,
|
|
87
88
|
haltedAt: state.status
|
|
88
89
|
});
|
|
@@ -94,7 +95,7 @@ var useInvitationStatus = (observable) => {
|
|
|
94
95
|
const connect = useCallback((observable) => {
|
|
95
96
|
dispatch({
|
|
96
97
|
invitation: observable.get(),
|
|
97
|
-
status:
|
|
98
|
+
status: Invitation_State$1.CONNECTING,
|
|
98
99
|
observable
|
|
99
100
|
});
|
|
100
101
|
}, []);
|
|
@@ -102,7 +103,7 @@ var useInvitationStatus = (observable) => {
|
|
|
102
103
|
log("authenticating...", { authCode }, {
|
|
103
104
|
"~LogMeta": "~LogMeta",
|
|
104
105
|
F: __dxlog_file,
|
|
105
|
-
L:
|
|
106
|
+
L: 199,
|
|
106
107
|
S: void 0
|
|
107
108
|
});
|
|
108
109
|
return observable.authenticate(authCode);
|
|
@@ -123,6 +124,6 @@ var useInvitationStatus = (observable) => {
|
|
|
123
124
|
]);
|
|
124
125
|
};
|
|
125
126
|
//#endregion
|
|
126
|
-
export { AuthenticatingInvitationObservable, CancellableInvitationObservable,
|
|
127
|
+
export { AuthenticatingInvitationObservable, CancellableInvitationObservable, InvitationEncoder, InvitationSchema, Invitation_AuthMethod, Invitation_Kind, Invitation_State, Invitation_Type, InvitationsProxy, useInvitationStatus };
|
|
127
128
|
|
|
128
129
|
//# sourceMappingURL=invitations.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invitations.mjs","names":[],"sources":["../../src/invitations/useInvitationStatus.ts"],"sourcesContent":["//\n// Copyright 2022 DXOS.org\n//\n\nimport { useCallback, useEffect, useMemo, useReducer } from 'react';\n\nimport {
|
|
1
|
+
{"version":3,"file":"invitations.mjs","names":[],"sources":["../../src/invitations/useInvitationStatus.ts"],"sourcesContent":["//\n// Copyright 2022 DXOS.org\n//\n\nimport { useCallback, useEffect, useMemo, useReducer } from 'react';\n\nimport { PublicKey } from '@dxos/client';\nimport {\n type AuthenticatingInvitationObservable,\n type CancellableInvitationObservable,\n type Invitation,\n Invitation_AuthMethod,\n Invitation_State,\n Invitation_Type,\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 ? PublicKey.from(invitation.spaceKey.data) : null,\n identityKey: invitation.identityKey ? PublicKey.from(invitation.identityKey.data) : null,\n swarmKey: invitation.swarmKey ? PublicKey.from(invitation.swarmKey.data) : 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"],"mappings":";;;;;;AAuFA,IAAM,yBAAyB,eAC7B,WAAW,eAAe,wBAAsB,oBAAoB,CAAC,CAAC,WAAW,cAAc;AAEjG,IAAa,uBAAuB,eAAmE;CACrG,MAAM,CAAC,OAAO,YAAY,YACvB,MAA8B,WAAqD;EAClF,IAAI,uBAAuB,EAAE,OAAO,GAAA;GAAA,YAAA;GAAA,GAAA;GAAA,GAAA;GAAA,GAAA,KAAA;EAAA,CAAC;EACrC,MAAM,kBACJ,gBAAgB,SACZ;GACE,IAAI,OAAO,WAAW;GACtB,UAAU,OAAO,WAAW;GAC5B,gBAAgB,oBAAkB,OAAO,OAAO,UAAU;GAC1D,UAAU,OAAO,WAAW;GAC5B,YAAY,OAAO,WAAW;GAC9B,WAAW,sBAAsB,OAAO,UAAU;GAClD,MAAM,OAAO,WAAW;EAC1B,IACA,CAAC;EACP,OAAO;GACL,GAAG;GACH,GAAG;GAEH,QAAQ,OAAO;GAEf,QAAQ,OAAO,WAAW,mBA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,eAAe,YAAY,UAAU,SAAS,QAAe;GACjE,SAAS;IAAE,QAAQ,mBAAiB;IAAO,OAAO;IAAK,UAAU,MAAM;GAAO,CAAC;EACjF,CAAC;EAED,MAAM,eAAe,YAAY,IAAI;EACrC,IAAI,cACF,OAAO,YAAY;EAGrB,aAAa,cAAc,YAAY;CACzC,GAAG,CAAC,YAAY,MAAM,MAAM,CAAC;CAI7B,MAAM,UAAU,aAAa,eAAgD;EAC3E,SAAS;GAAE,YAAY,WAAW,IAAI;GAAG,QAAQ,mBAAiB;GAAY;EAAW,CAAC;CAC5F,GAAG,CAAC,CAAC;CAEL,MAAM,eAAe,aAClB,aAAqB;EACpB,IAAI,qBAAqB,EAAE,SAAS,GAAA;GAAA,YAAA;GAAA,GAAA;GAAA,GAAA;GAAA,GAAA,KAAA;EAAA,CAAC;EACrC,OAAQ,WAAkD,aAAa,QAAQ;CACjF,GACA,CAAC,UAAU,CACb;CAEA,MAAM,SAAS,YAAY,YAAY,YAAY,OAAO,GAAG,CAAC,UAAU,CAAC;CAEzE,OAAO,cAAc;EACnB,OAAO;GACL,GAAG;GACH;GACA;GACA;EACF;CACF,GAAG;EAAC;EAAO;EAAQ;EAAS;CAAY,CAAC;AAC3C"}
|
package/dist/lib/mesh.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mesh.mjs","names":[],"sources":["../../src/mesh/useNetworkStatus.ts"],"sourcesContent":["//\n// Copyright 2020 DXOS.org\n//\n\nimport { type NetworkStatus } from '@dxos/client/mesh';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\n\n/**\n * Creates a network status subscription.\n */\nexport const useNetworkStatus = (): NetworkStatus => {\n const client = useClient();\n return useMulticastObservable(client.mesh.networkStatus);\n};\n"],"mappings":";;;;;;;AAYA,IAAa,yBAAwC;CACnD,MAAM,SAAS,UAAU;CACzB,OAAO,uBAAuB,OAAO,KAAK,aAAa;AACzD"}
|
|
1
|
+
{"version":3,"file":"mesh.mjs","names":[],"sources":["../../src/mesh/useNetworkStatus.ts"],"sourcesContent":["//\n// Copyright 2020 DXOS.org\n//\n\nimport { type NetworkStatus } from '@dxos/client/mesh';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client/index.ts';\n\n/**\n * Creates a network status subscription.\n */\nexport const useNetworkStatus = (): NetworkStatus => {\n const client = useClient();\n return useMulticastObservable(client.mesh.networkStatus);\n};\n"],"mappings":";;;;;;;AAYA,IAAa,yBAAwC;CACnD,MAAM,SAAS,UAAU;CACzB,OAAO,uBAAuB,OAAO,KAAK,aAAa;AACzD"}
|
package/dist/lib/testing.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { useAsyncEffect } from "@dxos/react-hooks";
|
|
|
8
8
|
import { Trigger } from "@dxos/async";
|
|
9
9
|
import { TestBuilder, performInvitation } from "@dxos/client/testing";
|
|
10
10
|
import { random } from "@dxos/random";
|
|
11
|
-
import
|
|
11
|
+
import * as Status from "@dxos/react-ui/Status";
|
|
12
12
|
export * from "@dxos/client/testing";
|
|
13
13
|
//#region src/testing/context.tsx
|
|
14
14
|
var ClientStory = createContext(void 0);
|
|
@@ -104,7 +104,7 @@ var withClientProvider = ({ createIdentity, createSpace, onCreateSpace, onCreate
|
|
|
104
104
|
}, context);
|
|
105
105
|
setData(data);
|
|
106
106
|
};
|
|
107
|
-
return /* @__PURE__ */ jsx(ErrorBoundary, {
|
|
107
|
+
return /* @__PURE__ */ jsx(Status.ErrorBoundary, {
|
|
108
108
|
name: "client-provider",
|
|
109
109
|
children: /* @__PURE__ */ jsx(ClientProvider, {
|
|
110
110
|
onInitialized: handleInitialized,
|
|
@@ -121,14 +121,14 @@ var withClientProvider = ({ createIdentity, createSpace, onCreateSpace, onCreate
|
|
|
121
121
|
* Decorator that creates a scaffold for multiple clients.
|
|
122
122
|
* Orchestrates invitations between a randomly selected host and the remaining clients.
|
|
123
123
|
*/
|
|
124
|
-
var withMultiClientProvider = ({ numClients = 2, createIdentity, createSpace, onCreateSpace, onCreateIdentity, onInitialized, ...props }) => {
|
|
124
|
+
var withMultiClientProvider = ({ numClients = 2, createIdentity, createSpace, onCreateSpace, onCreateIdentity, onInitialized, inboxRelay, wrapper: Wrapper, ...props }) => {
|
|
125
125
|
return (Story, context) => {
|
|
126
126
|
const spaceReady = useRef(new Trigger());
|
|
127
127
|
const [spaceId, setSpaceId] = useState();
|
|
128
128
|
const clients = useMemo(() => {
|
|
129
129
|
const buidler = new TestBuilder();
|
|
130
130
|
return Array.from({ length: numClients }).map(() => {
|
|
131
|
-
return { services: buidler.createLocalClientServices() };
|
|
131
|
+
return { services: buidler.createLocalClientServices({ inboxRelay }) };
|
|
132
132
|
});
|
|
133
133
|
}, [numClients]);
|
|
134
134
|
const handleInitialized = useCallback(async (client, index) => {
|
|
@@ -146,7 +146,7 @@ var withMultiClientProvider = ({ numClients = 2, createIdentity, createSpace, on
|
|
|
146
146
|
}, {
|
|
147
147
|
"~LogMeta": "~LogMeta",
|
|
148
148
|
F: __dxlog_file,
|
|
149
|
-
L:
|
|
149
|
+
L: 161,
|
|
150
150
|
S: void 0
|
|
151
151
|
});
|
|
152
152
|
setSpaceId(space?.id);
|
|
@@ -159,7 +159,7 @@ var withMultiClientProvider = ({ numClients = 2, createIdentity, createSpace, on
|
|
|
159
159
|
log.info("waiting", { index }, {
|
|
160
160
|
"~LogMeta": "~LogMeta",
|
|
161
161
|
F: __dxlog_file,
|
|
162
|
-
L:
|
|
162
|
+
L: 168,
|
|
163
163
|
S: void 0
|
|
164
164
|
});
|
|
165
165
|
const space = await spaceReady.current.wait();
|
|
@@ -170,7 +170,7 @@ var withMultiClientProvider = ({ numClients = 2, createIdentity, createSpace, on
|
|
|
170
170
|
}, {
|
|
171
171
|
"~LogMeta": "~LogMeta",
|
|
172
172
|
F: __dxlog_file,
|
|
173
|
-
L:
|
|
173
|
+
L: 171,
|
|
174
174
|
S: void 0
|
|
175
175
|
});
|
|
176
176
|
await Promise.all(performInvitation({
|
|
@@ -181,7 +181,7 @@ var withMultiClientProvider = ({ numClients = 2, createIdentity, createSpace, on
|
|
|
181
181
|
}
|
|
182
182
|
}, []);
|
|
183
183
|
return /* @__PURE__ */ jsx("div", {
|
|
184
|
-
className: "
|
|
184
|
+
className: "dx-cover grid grid-flow-col auto-cols-fr gap-4 overflow-hidden",
|
|
185
185
|
children: clients.map((client, index) => /* @__PURE__ */ jsx(ClientProvider, {
|
|
186
186
|
services: client.services,
|
|
187
187
|
onInitialized: (client) => handleInitialized(client, index),
|
|
@@ -191,9 +191,12 @@ var withMultiClientProvider = ({ numClients = 2, createIdentity, createSpace, on
|
|
|
191
191
|
index,
|
|
192
192
|
spaceId
|
|
193
193
|
},
|
|
194
|
-
children: /* @__PURE__ */ jsx(ErrorBoundary, {
|
|
194
|
+
children: /* @__PURE__ */ jsx(Status.ErrorBoundary, {
|
|
195
195
|
name: "client-provider",
|
|
196
|
-
children: /* @__PURE__ */ jsx(
|
|
196
|
+
children: Wrapper ? /* @__PURE__ */ jsx(Wrapper, {
|
|
197
|
+
index,
|
|
198
|
+
children: /* @__PURE__ */ jsx(Story, {})
|
|
199
|
+
}) : /* @__PURE__ */ jsx(Story, {})
|
|
197
200
|
})
|
|
198
201
|
})
|
|
199
202
|
}, index))
|
package/dist/lib/testing.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.mjs","names":[],"sources":["../../src/testing/context.tsx","../../src/testing/ClientRepeater.tsx","../../src/testing/withClientProvider.tsx"],"sourcesContent":["//\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';\nimport { type SpaceId } from '@dxos/keys';\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 { type SpaceId } from '@dxos/keys';\nimport { random } from '@dxos/random';\nimport { useAsyncEffect } from '@dxos/react-hooks';\n\nimport { ClientProvider } from '../client';\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-vite';\nimport React, { useCallback, useMemo, useRef, useState } from 'react';\n\nimport { Trigger } from '@dxos/async';\nimport { type Client } from '@dxos/client';\nimport { type Space } from '@dxos/client/echo';\nimport { TestBuilder, performInvitation } from '@dxos/client/testing';\nimport { type SpaceId } from '@dxos/keys';\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"],"mappings":";;;;;;;;;;;;;AAgBA,IAAa,cAAc,cAAuC,KAAA,CAAS;AAE3E,IAAa,uBAAoC;CAC/C,OAAO,WAAW,WAAW,KAAK,sBAAM,IAAI,MAAM,qBAAqB,CAAC;AAC1E;;;;;;;;ACqBA,IAAa,kBAA0D,UAAkC;CACvG,MAAM,EACJ,WAAW,WACX,UAAU,UACV,QAAQ,GACR,OACA,gBACA,aACA,kBACE;CAEJ,MAAM,CAAC,SAAS,cAAc,SAAS,MAAM,WAAW,CAAC,CAAC;CAC1D,MAAM,CAAC,SAAS,cAAc,SAAkB;CAEhD,MAAM,cAAc,OAAO,IAAI,YAAY,CAAC;CAC5C,eAAe,YAAY;EACzB,MAAM,UAAU,CAAC,GAAG,MAAM,KAAK,CAAC,CAAC,CAAC,KAC/B,MAAM,IAAI,OAAO;GAAE,UAAU,YAAY,QAAQ,0BAA0B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Y;KAAE;KAAO,SAAS,OAAO;IAAG,GAAA;KAAA,YAAA;KAAA,GAAA;KAAA,GAAA;KAAA,GAAA,KAAA;IAAA,CAAC;IAClD,WAAW,OAAO,EAAE;IACpB,WAAW,QAAQ,KAAK,KAAK;GAC/B,OAAO;IAEL,MAAM,iBAAiB,QAAQ;KAAE;KAAgB;IAAc,GAAG,OAAO;IAEzE,IAAI,KAAK,WAAW,EAAE,MAAM,GAAA;KAAA,YAAA;KAAA,GAAA;KAAA,GAAA;KAAA,GAAA,KAAA;IAAA,CAAC;IAC7B,MAAM,QAAQ,MAAM,WAAW,QAAQ,KAAK;IAC5C,IAAI,OAAO;KACT,IAAI,KAAK,WAAW;MAAE;MAAO,SAAS,MAAM;KAAG,GAAA;MAAA,YAAA;MAAA,GAAA;MAAA,GAAA;MAAA,GAAA,KAAA;KAAA,CAAC;KAChD,MAAM,QAAQ,IACZ,kBAAkB;MAChB,MAAM;MACN,OAAO,OAAO;KAChB,CAAC,CACH;IACF;GACF;EACF,GAAG,CAAC,CAAC;EAEL,OACE,oBAAC,OAAD;GAAK,WAAU;GACZ,UAAA,QAAQ,KAAK,QAAQ,UACpB,oBAAC,gBAAD;IAEE,UAAU,OAAO;IACjB,gBAAgB,WAAW,kBAAkB,QAAQ,KAAK;IAC1D,GAAI;IAEJ,UAAA,oBAAC,YAAY,UAAb;KAAsB,OAAO;MAAE;MAAO;KAAQ;KAC5C,UAAA,oBAAC,eAAD;MAAe,MAAK;MAClB,UAAA,oBAAC,OAAD,CAAQ,CAAA;KACK,CAAA;IACK,CAAA;GACR,GAVT,KAUS,CACjB;EACE,CAAA;CAET;AACF"}
|
|
1
|
+
{"version":3,"file":"testing.mjs","names":[],"sources":["../../src/testing/context.tsx","../../src/testing/ClientRepeater.tsx","../../src/testing/withClientProvider.tsx"],"sourcesContent":["//\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';\nimport { type SpaceId } from '@dxos/keys';\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 { type SpaceId } from '@dxos/keys';\nimport { random } from '@dxos/random';\nimport { useAsyncEffect } from '@dxos/react-hooks';\n\nimport { ClientProvider } from '../client/index.ts';\nimport { type WithClientProviderProps } from './withClientProvider.tsx';\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-vite';\nimport React, { type ComponentType, type PropsWithChildren, useCallback, useMemo, useRef, useState } from 'react';\n\nimport { Trigger } from '@dxos/async';\nimport { type Client } from '@dxos/client';\nimport { type Space } from '@dxos/client/echo';\nimport { TestBuilder, performInvitation } from '@dxos/client/testing';\nimport { type SpaceId } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport * as Status from '@dxos/react-ui/Status';\nimport { type MaybePromise } from '@dxos/util';\n\nimport { ClientProvider, type ClientProviderProps } from '../client/index.ts';\nimport { ClientStory } from './context.tsx';\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 <Status.ErrorBoundary name='client-provider'>\n <ClientProvider onInitialized={handleInitialized} {...props}>\n <ClientStory.Provider value={data}>\n <Story />\n </ClientStory.Provider>\n </ClientProvider>\n </Status.ErrorBoundary>\n );\n };\n};\n\ntype LocalServicesOptions = NonNullable<Parameters<TestBuilder['createLocalClientServices']>[0]>;\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'> & {\n numClients?: number;\n /** One relay (e.g. `MemoryEdgeInbox`) shared by every client, so they can message each other without EDGE. */\n inboxRelay?: LocalServicesOptions['inboxRelay'];\n /**\n * Wraps each client's story inside its `ClientProvider`, so the client can host what the story\n * needs per client — e.g. a plugin manager adopting it (see plugin-client's `ClientPluginManager`).\n */\n wrapper?: ComponentType<PropsWithChildren<{ index: number }>>;\n };\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 inboxRelay,\n wrapper: Wrapper,\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({ inboxRelay }),\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='dx-cover 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 <Status.ErrorBoundary name='client-provider'>\n {Wrapper ? (\n <Wrapper index={index}>\n <Story />\n </Wrapper>\n ) : (\n <Story />\n )}\n </Status.Error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AAO,OAAO;KAChB,CAAC,CACH;IACF;GACF;EACF,GAAG,CAAC,CAAC;EAEL,OACE,oBAAC,OAAD;GAAK,WAAU;GACZ,UAAA,QAAQ,KAAK,QAAQ,UACpB,oBAAC,gBAAD;IAEE,UAAU,OAAO;IACjB,gBAAgB,WAAW,kBAAkB,QAAQ,KAAK;IAC1D,GAAI;IAEJ,UAAA,oBAAC,YAAY,UAAb;KAAsB,OAAO;MAAE;MAAO;KAAQ;KAC5C,UAAA,oBAAC,OAAO,eAAR;MAAsB,MAAK;MACxB,UAAA,UACC,oBAAC,SAAD;OAAgB;OACd,UAAA,oBAAC,OAAD,CAAQ,CAAA;MACD,CAAA,IAET,oBAAC,OAAD,CAAQ,CAAA;KAEU,CAAA;IACF,CAAA;GACR,GAhBT,KAgBS,CACjB;EACE,CAAA;CAET;AACF"}
|
|
@@ -2,7 +2,7 @@ import React, { type FunctionComponent, type PropsWithChildren } from 'react';
|
|
|
2
2
|
import { Client, type ClientOptions, type ClientServicesProvider } from '@dxos/client';
|
|
3
3
|
import { type Config } from '@dxos/config';
|
|
4
4
|
import { type MaybePromise, type Provider } from '@dxos/util';
|
|
5
|
-
import { type ClientContextProps } from './context';
|
|
5
|
+
import { type ClientContextProps } from './context.ts';
|
|
6
6
|
/**
|
|
7
7
|
* Properties for the ClientProvider.
|
|
8
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientProvider.d.ts","sourceRoot":"","sources":["../../../../src/client/ClientProvider.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EACZ,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EAKvB,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,KAAK,sBAAsB,EAAgB,MAAM,cAAc,CAAC;AACrG,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,QAAQ,E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B;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;CACxD,CAAC,CAAC;AAEL;;;GAGG;AACH,eAAO,MAAM,cAAc;IApDvB;;;;OAIG;aACM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAE3C;;;;OAIG;aAEM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAE3C;;;;OAIG;eAEQ,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,YAAY,CAAC,sBAAsB,CAAC,CAAC;IAE/F;;OAEG;eACQ,iBAAiB,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAEzD;;;;;;OAMG;cACO,OAAO;IAEjB;;OAEG;eACQ,OAAO;IAElB;;OAEG;oBACa,CAAC,MAAM,EAAE,MAAM,KAAK,YAAY,CAAC,IAAI,CAAC;;;4CAoIzD,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * from './AgentHostingProvider';
|
|
2
|
-
export * from './ClientProvider';
|
|
3
|
-
export * from './context';
|
|
4
|
-
export * from './useClient';
|
|
5
|
-
export * from './useClientStatus';
|
|
6
|
-
export * from './useConfig';
|
|
7
|
-
export * from './useEdgeServiceEndpoint';
|
|
8
|
-
export * from './useShell';
|
|
9
|
-
export * from './useStatus';
|
|
1
|
+
export * from './AgentHostingProvider.tsx';
|
|
2
|
+
export * from './ClientProvider.tsx';
|
|
3
|
+
export * from './context.ts';
|
|
4
|
+
export * from './useClient.ts';
|
|
5
|
+
export * from './useClientStatus.ts';
|
|
6
|
+
export * from './useConfig.ts';
|
|
7
|
+
export * from './useEdgeServiceEndpoint.ts';
|
|
8
|
+
export * from './useShell.ts';
|
|
9
|
+
export * from './useStatus.ts';
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/index.ts"],"names":[],"mappings":"AAIA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/index.ts"],"names":[],"mappings":"AAIA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAE7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC"}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { type EdgeServiceName } from '@dxos/config';
|
|
2
2
|
/**
|
|
3
3
|
* Hook resolving an EDGE service endpoint from the client config; `undefined` when the service is
|
|
4
|
-
* not configured.
|
|
4
|
+
* not configured.
|
|
5
|
+
*
|
|
6
|
+
* Returns `undefined` outside a `ClientProvider` rather than throwing: the callers are app-wide
|
|
7
|
+
* drivers mounted by `Capabilities.ReactContext`, which render during startup and on any path where
|
|
8
|
+
* the client never arrives — a throw there takes the whole app to the fatal dialog over an endpoint
|
|
9
|
+
* the driver only needs once it has work to do.
|
|
5
10
|
*/
|
|
6
11
|
export declare const useEdgeServiceEndpoint: (serviceName: EdgeServiceName) => string | undefined;
|
|
7
12
|
//# sourceMappingURL=useEdgeServiceEndpoint.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEdgeServiceEndpoint.d.ts","sourceRoot":"","sources":["../../../../src/client/useEdgeServiceEndpoint.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useEdgeServiceEndpoint.d.ts","sourceRoot":"","sources":["../../../../src/client/useEdgeServiceEndpoint.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,eAAe,EAA0B,MAAM,cAAc,CAAC;AAI5E;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,gBAAiB,eAAe,KAAG,MAAM,GAAG,SAG9E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/devtools/index.ts"],"names":[],"mappings":"AAIA,cAAc,uBAAuB,CAAC;AAEtC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/devtools/index.ts"],"names":[],"mappings":"AAIA,cAAc,uBAAuB,CAAC;AAEtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
declare const DefaultStory: () => React.JSX.Element;
|
|
4
|
+
declare const meta: {
|
|
5
|
+
title: string;
|
|
6
|
+
render: typeof DefaultStory;
|
|
7
|
+
decorators: import("@storybook/react").Decorator[];
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export default meta;
|
|
13
|
+
type Story = StoryObj<typeof meta>;
|
|
14
|
+
export declare const Default: Story;
|
|
15
|
+
//# sourceMappingURL=ECHO.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ECHO.stories.d.ts","sourceRoot":"","sources":["../../../../src/echo/ECHO.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAmB,MAAM,OAAO,CAAC;AAqBxC,QAAA,MAAM,YAAY,yBA2EjB,CAAC;AAEF,QAAA,MAAM,IAAI;;;;;QAsBN,MAAM;;CAE2B,CAAC;eAEvB,IAAI;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAAU,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export * from '@dxos/client/echo';
|
|
2
2
|
export * from '@dxos/echo-react';
|
|
3
|
-
export * from './useMembers';
|
|
4
|
-
export * from './useSpaces';
|
|
5
|
-
export * from './useSpaceInvitations';
|
|
6
|
-
export * from './useSpaceProperties';
|
|
7
|
-
export * from './useFlush';
|
|
8
|
-
export * from './useSubscription';
|
|
9
|
-
export * from './useSyncState';
|
|
10
|
-
export * from './useFeedSyncState';
|
|
11
|
-
export * from './useRegistry';
|
|
3
|
+
export * from './useMembers.ts';
|
|
4
|
+
export * from './useSpaces.ts';
|
|
5
|
+
export * from './useSpaceInvitations.ts';
|
|
6
|
+
export * from './useSpaceProperties.ts';
|
|
7
|
+
export * from './useFlush.ts';
|
|
8
|
+
export * from './useSubscription.ts';
|
|
9
|
+
export * from './useSyncState.ts';
|
|
10
|
+
export * from './useFeedSyncState.ts';
|
|
11
|
+
export * from './useRegistry.ts';
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/echo/index.ts"],"names":[],"mappings":"AAIA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/echo/index.ts"],"names":[],"mappings":"AAIA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC"}
|
|
@@ -7,7 +7,7 @@ export type FeedSyncState = {
|
|
|
7
7
|
};
|
|
8
8
|
export type FeedSyncStateMap = Record<SpaceId, FeedSyncState>;
|
|
9
9
|
/**
|
|
10
|
-
* Polls feed replication state per space.
|
|
10
|
+
* Polls feed replication state per space, while the document is visible.
|
|
11
11
|
*/
|
|
12
12
|
export declare const useFeedSyncState: (pollIntervalMs?: number) => FeedSyncStateMap;
|
|
13
13
|
//# sourceMappingURL=useFeedSyncState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFeedSyncState.d.ts","sourceRoot":"","sources":["../../../../src/echo/useFeedSyncState.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"useFeedSyncState.d.ts","sourceRoot":"","sources":["../../../../src/echo/useFeedSyncState.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAQ1C,MAAM,MAAM,aAAa,GAAG;IAC1B,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;AAI9D;;GAEG;AACH,eAAO,MAAM,gBAAgB,+BAAgD,gBAgF5E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFeedSyncState.test.d.ts","sourceRoot":"","sources":["../../../../src/echo/useFeedSyncState.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMembers.d.ts","sourceRoot":"","sources":["../../../../src/echo/useMembers.ts"],"names":[],"mappings":"AAKA,OAAO,EAAa,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,
|
|
1
|
+
{"version":3,"file":"useMembers.d.ts","sourceRoot":"","sources":["../../../../src/echo/useMembers.ts"],"names":[],"mappings":"AAKA,OAAO,EAAa,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,KAAK,WAAW,EAAoB,MAAM,mBAAmB,CAAC;AAKvE,eAAO,MAAM,UAAU,aAAc,aAAa,GAAG,SAAS,KAAG,WAAW,EAU3E,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type PublicKey } from '@dxos/client';
|
|
2
2
|
import { type SpaceId } from '@dxos/keys';
|
|
3
|
-
import { type CancellableInvitationObservable } from '../invitations';
|
|
3
|
+
import { type CancellableInvitationObservable } from '../invitations/index.ts';
|
|
4
4
|
export declare const useSpaceInvitations: (spaceId?: SpaceId | PublicKey) => CancellableInvitationObservable[];
|
|
5
|
-
export declare const useSpaceInvitation: (spaceId?: SpaceId | PublicKey, invitationId?: string) => import("../invitations").InvitationStatus;
|
|
5
|
+
export declare const useSpaceInvitation: (spaceId?: SpaceId | PublicKey, invitationId?: string) => import("../invitations/useInvitationStatus.ts").InvitationStatus;
|
|
6
6
|
//# sourceMappingURL=useSpaceInvitations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSpaceInvitations.d.ts","sourceRoot":"","sources":["../../../../src/echo/useSpaceInvitations.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAG1C,OAAO,EAAE,KAAK,+BAA+B,EAAuB,MAAM,
|
|
1
|
+
{"version":3,"file":"useSpaceInvitations.d.ts","sourceRoot":"","sources":["../../../../src/echo/useSpaceInvitations.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAG1C,OAAO,EAAE,KAAK,+BAA+B,EAAuB,MAAM,yBAAyB,CAAC;AAKpG,eAAO,MAAM,mBAAmB,aAAc,OAAO,GAAG,SAAS,KAAG,+BAA+B,EAGlG,CAAC;AAIF,eAAO,MAAM,kBAAkB,aAAc,OAAO,GAAG,SAAS,iBAAiB,MAAM,qEAOtF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Passkey.stories.d.ts","sourceRoot":"","sources":["../../../../src/halo/Passkey.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAsB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Passkey.stories.d.ts","sourceRoot":"","sources":["../../../../src/halo/Passkey.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAsB,MAAM,OAAO,CAAC;AAqB3C,QAAA,MAAM,IAAI,yBA0GT,CAAC;AAsBF,QAAA,MAAM,IAAI;;;;CAIM,CAAC;eAEF,IAAI;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAAU,CAAC"}
|