@dxos/react-client 0.6.11 → 0.6.12-main.5cc132e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/lib/browser/{chunk-CL7JDETM.mjs → chunk-ESSNDYBJ.mjs} +70 -61
  2. package/dist/lib/browser/chunk-ESSNDYBJ.mjs.map +7 -0
  3. package/dist/lib/browser/devtools/index.mjs +1 -1
  4. package/dist/lib/browser/echo/index.mjs +1 -1
  5. package/dist/lib/browser/halo/index.mjs +1 -1
  6. package/dist/lib/browser/index.mjs +1 -3
  7. package/dist/lib/browser/index.mjs.map +1 -1
  8. package/dist/lib/browser/mesh/index.mjs +1 -1
  9. package/dist/lib/browser/meta.json +1 -1
  10. package/dist/lib/browser/testing/index.mjs +1 -1
  11. package/dist/lib/browser/testing/index.mjs.map +2 -2
  12. package/dist/lib/node/{chunk-C4EWAKPZ.cjs → chunk-N474KOAU.cjs} +71 -61
  13. package/dist/lib/node/chunk-N474KOAU.cjs.map +7 -0
  14. package/dist/lib/node/devtools/index.cjs +2 -2
  15. package/dist/lib/node/echo/index.cjs +3 -3
  16. package/dist/lib/node/halo/index.cjs +5 -5
  17. package/dist/lib/node/index.cjs +12 -14
  18. package/dist/lib/node/index.cjs.map +1 -1
  19. package/dist/lib/node/mesh/index.cjs +2 -2
  20. package/dist/lib/node/meta.json +1 -1
  21. package/dist/lib/node/testing/index.cjs +4 -4
  22. package/dist/lib/node/testing/index.cjs.map +2 -2
  23. package/dist/lib/node-esm/chunk-AL2CUQ46.mjs +163 -0
  24. package/dist/lib/node-esm/chunk-AL2CUQ46.mjs.map +7 -0
  25. package/dist/lib/node-esm/chunk-ESSNDYBJ.mjs +300 -0
  26. package/dist/lib/node-esm/chunk-ESSNDYBJ.mjs.map +7 -0
  27. package/dist/lib/node-esm/devtools/index.mjs +43 -0
  28. package/dist/lib/node-esm/devtools/index.mjs.map +7 -0
  29. package/dist/lib/node-esm/echo/index.mjs +131 -0
  30. package/dist/lib/node-esm/echo/index.mjs.map +7 -0
  31. package/dist/lib/node-esm/halo/index.mjs +99 -0
  32. package/dist/lib/node-esm/halo/index.mjs.map +7 -0
  33. package/dist/lib/node-esm/index.mjs +32 -0
  34. package/dist/lib/node-esm/index.mjs.map +7 -0
  35. package/dist/lib/node-esm/invitations/index.mjs +17 -0
  36. package/dist/lib/node-esm/invitations/index.mjs.map +7 -0
  37. package/dist/lib/node-esm/mesh/index.mjs +17 -0
  38. package/dist/lib/node-esm/mesh/index.mjs.map +7 -0
  39. package/dist/lib/node-esm/meta.json +1 -0
  40. package/dist/lib/node-esm/testing/index.mjs +165 -0
  41. package/dist/lib/node-esm/testing/index.mjs.map +7 -0
  42. package/dist/lib/node-esm/worker.mjs +3 -0
  43. package/dist/lib/node-esm/worker.mjs.map +7 -0
  44. package/dist/types/src/client/ClientProvider.d.ts +65 -9
  45. package/dist/types/src/client/ClientProvider.d.ts.map +1 -1
  46. package/dist/types/src/client/context.d.ts +1 -4
  47. package/dist/types/src/client/context.d.ts.map +1 -1
  48. package/dist/types/src/client/index.d.ts +0 -1
  49. package/dist/types/src/client/index.d.ts.map +1 -1
  50. package/dist/types/src/playwright/playwright.config.d.ts +2 -2
  51. package/dist/types/src/playwright/playwright.config.d.ts.map +1 -1
  52. package/dist/types/src/testing/util.d.ts +5 -3
  53. package/dist/types/src/testing/util.d.ts.map +1 -1
  54. package/dist/types/src/testing/withClientProvider.d.ts.map +1 -1
  55. package/package.json +45 -36
  56. package/project.json +3 -23
  57. package/src/client/ClientProvider.test.tsx +7 -4
  58. package/src/client/ClientProvider.tsx +130 -90
  59. package/src/client/context.ts +4 -4
  60. package/src/client/index.ts +0 -3
  61. package/src/client/useConfig.test.tsx +7 -11
  62. package/src/echo/useSpaces.test.tsx +6 -8
  63. package/src/halo/useDevices.test.tsx +3 -5
  64. package/src/playwright/playwright.config.ts +13 -2
  65. package/src/playwright/smoke.spec.ts +5 -10
  66. package/src/testing/util.tsx +11 -6
  67. package/src/testing/withClientProvider.tsx +1 -0
  68. package/tsconfig.json +4 -2
  69. package/vitest.config.ts +22 -0
  70. package/dist/lib/browser/chunk-CL7JDETM.mjs.map +0 -7
  71. package/dist/lib/node/chunk-C4EWAKPZ.cjs.map +0 -7
  72. package/dist/types/src/client/useClientServices.d.ts +0 -3
  73. package/dist/types/src/client/useClientServices.d.ts.map +0 -1
  74. package/src/client/useClientServices.ts +0 -15
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/testing/index.ts", "../../../../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 './ClientRepeater';\nexport * from './withClientProvider';\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 { type Space } from '@dxos/client/echo';\nimport { TestBuilder, performInvitation } from '@dxos/client/testing';\nimport { type S } from '@dxos/echo-schema';\nimport { registerSignalFactory } from '@dxos/echo-signals/react';\nimport { faker } from '@dxos/random';\nimport { type MaybePromise } from '@dxos/util';\n\nimport { ClientProvider } from '../client';\n\nexport type ClientRepeatedComponentProps = { id: number; count: number; spaceKey?: PublicKey };\n\nexport type ClientRepeaterProps<P extends ClientRepeatedComponentProps> = {\n className?: string;\n component: FC<ClientRepeatedComponentProps>;\n controls?: FC<{ clients: Client[] }>;\n clients?: Client[];\n count?: number;\n registerSignalFactory?: boolean;\n types?: S.Schema<any>[];\n createIdentity?: boolean;\n createSpace?: boolean;\n onCreateSpace?: (space: Space) => MaybePromise<void>;\n args?: Omit<P, 'id' | 'count'>;\n};\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 */\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 if (props.registerSignalFactory ?? true) {\n registerSignalFactory();\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() }),\n );\n await Promise.all(clients.map((client) => client.initialize()));\n types && clients.map((client) => client.addTypes(types));\n\n if (createIdentity || createSpace) {\n await Promise.all(clients.map((client) => client.halo.createIdentity()));\n }\n\n if (createSpace) {\n const space = await clients[0].spaces.create({ name: faker.commerce.productName() });\n setSpaceKey(space.key);\n await onCreateSpace?.(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 Decorator } from '@storybook/react';\nimport React, { useRef } from 'react';\nimport { type FallbackProps, ErrorBoundary } 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 { type MaybePromise } from '@dxos/util';\n\nimport { ClientProvider, type ClientProviderProps } from '../client';\n\ntype InitializeProps = {\n createIdentity?: boolean;\n createSpace?: boolean;\n onSpaceCreated?: (client: Client, space: Space) => MaybePromise<void>;\n};\n\n/**\n * Initialize client, identity and first space.\n */\nconst initializeClient = async (\n client: Client,\n {\n createIdentity,\n createSpace,\n onSpaceCreated,\n onInitialized,\n }: InitializeProps & Pick<WithClientProviderProps, 'onInitialized'>,\n): Promise<Space | undefined> => {\n if (createIdentity) {\n await client.halo.createIdentity();\n }\n\n let space: Space | undefined;\n if (createSpace) {\n space = await client.spaces.create({ name: 'Test Space' });\n await onSpaceCreated?.(client, space);\n }\n\n await onInitialized?.(client);\n return space;\n};\n\nexport type WithClientProviderProps = InitializeProps & ClientProviderProps;\n\n/**\n * Decorator that provides the client context.\n */\nexport const withClientProvider = ({\n createIdentity,\n createSpace,\n onSpaceCreated,\n onInitialized,\n ...props\n}: WithClientProviderProps = {}): Decorator => {\n const handleInitialized = async (client: Client) => {\n await initializeClient(client, { createIdentity, createSpace, onSpaceCreated, onInitialized });\n };\n\n return (Story) => (\n <ErrorBoundary FallbackComponent={ErrorFallback}>\n <ClientProvider onInitialized={handleInitialized} {...props}>\n <Story />\n </ClientProvider>\n </ErrorBoundary>\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 & ClientProviderProps & { 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 * NOTE: Should come before withLayout.\n */\nexport const withMultiClientProvider = ({\n numClients = 2,\n createIdentity,\n createSpace,\n onSpaceCreated,\n onInitialized,\n ...props\n}: WithMultiClientProviderProps): Decorator => {\n return (Story) => {\n const builder = useRef(new TestBuilder());\n const hostRef = useRef<Client>();\n const spaceReady = useRef(new Trigger<Space | undefined>());\n\n // Handle invitations.\n const handleClientInitialized = async (client: Client) => {\n if (createSpace) {\n if (!hostRef.current) {\n hostRef.current = client;\n const space = await initializeClient(client, { createIdentity, createSpace, onSpaceCreated, onInitialized });\n spaceReady.current.wake(space);\n } else {\n await initializeClient(client, { createIdentity, onInitialized });\n const space = await spaceReady.current.wait();\n if (space) {\n await Promise.all(performInvitation({ host: space, guest: client.spaces }));\n }\n }\n }\n };\n\n return (\n <>\n {Array.from({ length: numClients }).map((_, index) => (\n <ErrorBoundary key={index} FallbackComponent={ErrorFallback}>\n <ClientProvider\n services={builder.current.createLocalClientServices()}\n onInitialized={handleClientInitialized}\n {...props}\n >\n <Story />\n </ClientProvider>\n </ErrorBoundary>\n ))}\n </>\n );\n };\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 gap-4'>\n <h1 className='text-xl text-red-500'>{name}</h1>\n <div className='text-lg'>{message}</div>\n {stack && <pre className='text-sm text-subdued'>{stack}</pre>}\n </div>\n );\n};\n"],
5
- "mappings": ";;;;;AAIA,cAAc;;;ACAd,OAAOA,SAASC,UAAmBC,WAAWC,cAAc;AAE5D,SAASC,cAA8B;AAEvC,SAASC,aAAaC,yBAAyB;AAE/C,SAASC,6BAA6B;AACtC,SAASC,aAAa;AA8Bf,IAAMC,iBAAiB,CAAyCC,UAAAA;AACrE,QAAM,EACJC,WAAWC,WACXC,UAAUC,UACVC,QAAQ,GACRC,OACAC,gBACAC,aACAC,cAAa,IACXT;AACJ,MAAIA,MAAMU,yBAAyB,MAAM;AACvCA,0BAAAA;EACF;AAEA,QAAM,CAACC,SAASC,UAAAA,IAAcC,SAASb,MAAMW,WAAW,CAAA,CAAE;AAC1D,QAAM,CAACG,UAAUC,WAAAA,IAAeF,SAAAA;AAEhC,QAAMG,cAAcC,OAAO,IAAIC,YAAAA,CAAAA;AAC/BC,YAAU,MAAA;AACR,UAAMC,UAAUC,WAAW,YAAA;AACzB,YA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client/testing';\n\nexport * from './ClientRepeater';\nexport * from './withClientProvider';\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 { type Space } from '@dxos/client/echo';\nimport { TestBuilder, performInvitation } from '@dxos/client/testing';\nimport { type S } from '@dxos/echo-schema';\nimport { registerSignalFactory } from '@dxos/echo-signals/react';\nimport { faker } from '@dxos/random';\nimport { type MaybePromise } from '@dxos/util';\n\nimport { ClientProvider } from '../client';\n\nexport type ClientRepeatedComponentProps = { id: number; count: number; spaceKey?: PublicKey };\n\nexport type ClientRepeaterProps<P extends ClientRepeatedComponentProps> = {\n className?: string;\n component: FC<ClientRepeatedComponentProps>;\n controls?: FC<{ clients: Client[] }>;\n clients?: Client[];\n count?: number;\n registerSignalFactory?: boolean;\n types?: S.Schema<any>[];\n createIdentity?: boolean;\n createSpace?: boolean;\n onCreateSpace?: (space: Space) => MaybePromise<void>;\n args?: Omit<P, 'id' | 'count'>;\n};\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 */\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 if (props.registerSignalFactory ?? true) {\n registerSignalFactory();\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() }),\n );\n await Promise.all(clients.map((client) => client.initialize()));\n types && clients.map((client) => client.addTypes(types));\n\n if (createIdentity || createSpace) {\n await Promise.all(clients.map((client) => client.halo.createIdentity()));\n }\n\n if (createSpace) {\n const space = await clients[0].spaces.create({ name: faker.commerce.productName() });\n setSpaceKey(space.key);\n await onCreateSpace?.(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 Decorator } from '@storybook/react';\nimport React, { useRef } from 'react';\nimport { type FallbackProps, ErrorBoundary } 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 { type MaybePromise } from '@dxos/util';\n\nimport { ClientProvider, type ClientProviderProps } from '../client';\n\ntype InitializeProps = {\n createIdentity?: boolean;\n createSpace?: boolean;\n onSpaceCreated?: (client: Client, space: Space) => MaybePromise<void>;\n};\n\n/**\n * Initialize client, identity and first space.\n */\nconst initializeClient = async (\n client: Client,\n {\n createIdentity,\n createSpace,\n onSpaceCreated,\n onInitialized,\n }: InitializeProps & Pick<WithClientProviderProps, 'onInitialized'>,\n): Promise<Space | undefined> => {\n if (createIdentity) {\n await client.halo.createIdentity();\n }\n\n let space: Space | undefined;\n if (createSpace) {\n space = await client.spaces.create({ name: 'Test Space' });\n await onSpaceCreated?.(client, space);\n }\n\n await onInitialized?.(client);\n return space;\n};\n\nexport type WithClientProviderProps = InitializeProps & ClientProviderProps;\n\n/**\n * Decorator that provides the client context.\n */\nexport const withClientProvider = ({\n createIdentity,\n createSpace,\n onSpaceCreated,\n onInitialized,\n ...props\n}: WithClientProviderProps = {}): Decorator => {\n const handleInitialized = async (client: Client) => {\n await initializeClient(client, { createIdentity, createSpace, onSpaceCreated, onInitialized });\n };\n\n return (Story) => (\n <ErrorBoundary FallbackComponent={ErrorFallback}>\n <ClientProvider onInitialized={handleInitialized} {...props}>\n <Story />\n </ClientProvider>\n </ErrorBoundary>\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 & ClientProviderProps & { 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 * NOTE: Should come before withLayout.\n */\n// TODO(burdon): Create test.\nexport const withMultiClientProvider = ({\n numClients = 2,\n createIdentity,\n createSpace,\n onSpaceCreated,\n onInitialized,\n ...props\n}: WithMultiClientProviderProps): Decorator => {\n return (Story) => {\n const builder = useRef(new TestBuilder());\n const hostRef = useRef<Client>();\n const spaceReady = useRef(new Trigger<Space | undefined>());\n\n // Handle invitations.\n const handleClientInitialized = async (client: Client) => {\n if (createSpace) {\n if (!hostRef.current) {\n hostRef.current = client;\n const space = await initializeClient(client, { createIdentity, createSpace, onSpaceCreated, onInitialized });\n spaceReady.current.wake(space);\n } else {\n await initializeClient(client, { createIdentity, onInitialized });\n const space = await spaceReady.current.wait();\n if (space) {\n await Promise.all(performInvitation({ host: space, guest: client.spaces }));\n }\n }\n }\n };\n\n return (\n <>\n {Array.from({ length: numClients }).map((_, index) => (\n <ErrorBoundary key={index} FallbackComponent={ErrorFallback}>\n <ClientProvider\n services={builder.current.createLocalClientServices()}\n onInitialized={handleClientInitialized}\n {...props}\n >\n <Story />\n </ClientProvider>\n </ErrorBoundary>\n ))}\n </>\n );\n };\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 gap-4'>\n <h1 className='text-xl text-red-500'>{name}</h1>\n <div className='text-lg'>{message}</div>\n {stack && <pre className='text-sm text-subdued'>{stack}</pre>}\n </div>\n );\n};\n"],
5
+ "mappings": ";;;;;AAIA,cAAc;;;ACAd,OAAOA,SAASC,UAAmBC,WAAWC,cAAc;AAE5D,SAASC,cAA8B;AAEvC,SAASC,aAAaC,yBAAyB;AAE/C,SAASC,6BAA6B;AACtC,SAASC,aAAa;AA8Bf,IAAMC,iBAAiB,CAAyCC,UAAAA;AACrE,QAAM,EACJC,WAAWC,WACXC,UAAUC,UACVC,QAAQ,GACRC,OACAC,gBACAC,aACAC,cAAa,IACXT;AACJ,MAAIA,MAAMU,yBAAyB,MAAM;AACvCA,0BAAAA;EACF;AAEA,QAAM,CAACC,SAASC,UAAAA,IAAcC,SAASb,MAAMW,WAAW,CAAA,CAAE;AAC1D,QAAM,CAACG,UAAUC,WAAAA,IAAeF,SAAAA;AAEhC,QAAMG,cAAcC,OAAO,IAAIC,YAAAA,CAAAA;AAC/BC,YAAU,MAAA;AACR,UAAMC,UAAUC,WAAW,YAAA;AACzB,YAAMV,WAAU;WAAIW,MAAMjB,KAAAA;QAAQkB,IAChC,CAACC,MAAM,IAAIC,OAAO;QAAEC,UAAUV,YAAYW,QAAQC,0BAAyB;MAAG,CAAA,CAAA;AAEhF,YAAMC,QAAQC,IAAInB,SAAQY,IAAI,CAACQ,WAAWA,OAAOC,WAAU,CAAA,CAAA;AAC3D1B,eAASK,SAAQY,IAAI,CAACQ,WAAWA,OAAOE,SAAS3B,KAAAA,CAAAA;AAEjD,UAAIC,kBAAkBC,aAAa;AACjC,cAAMqB,QAAQC,IAAInB,SAAQY,IAAI,CAACQ,WAAWA,OAAOG,KAAK3B,eAAc,CAAA,CAAA;MACtE;AAEA,UAAIC,aAAa;AACf,cAA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GC,UAC1C,gBAAA3B,OAAA,cAACC,eAAAA;MAAc2B,KAAKD;MAAOzB,mBAAmBC;OAC5C,gBAAAH,OAAA,cAACI,gBAAAA;MACCyB,UAAUtB,QAAQO,QAAQgB,0BAAyB;MACnDxC,eAAeuB;MACd,GAAGhB;OAEJ,gBAAAG,OAAA,cAACD,OAAAA,IAAAA,CAAAA,CAAAA,CAAAA,CAAAA;EAMb;AACF;AAEA,IAAMI,gBAAgB,CAAC,EAAE4B,MAAK,MAAiB;AAC7C,QAAM,EAAEpC,MAAMqC,SAASC,MAAK,IAC1BF,iBAAiBG,QAAQH,QAAQ;IAAEpC,MAAM;IAASqC,SAASG,OAAOJ,KAAAA;IAAQE,OAAOG;EAAU;AAC7F,SACE,gBAAApC,OAAA,cAACqC,OAAAA;IAAIC,MAAK;IAAQC,WAAU;KAC1B,gBAAAvC,OAAA,cAACwC,MAAAA;IAAGD,WAAU;KAAwB5C,IAAAA,GACtC,gBAAAK,OAAA,cAACqC,OAAAA;IAAIE,WAAU;KAAWP,OAAAA,GACzBC,SAAS,gBAAAjC,OAAA,cAACyC,OAAAA;IAAIF,WAAU;KAAwBN,KAAAA,CAAAA;AAGvD;",
6
6
  "names": ["React", "useState", "useEffect", "useRef", "Client", "TestBuilder", "performInvitation", "registerSignalFactory", "faker", "ClientRepeater", "props", "component", "Component", "controls", "Controls", "count", "types", "createIdentity", "createSpace", "onCreateSpace", "registerSignalFactory", "clients", "setClients", "useState", "spaceKey", "setSpaceKey", "testBuilder", "useRef", "TestBuilder", "useEffect", "timeout", "setTimeout", "Array", "map", "_", "Client", "services", "current", "createLocalClientServices", "Promise", "all", "client", "initialize", "addTypes", "halo", "space", "spaces", "create", "name", "faker", "commerce", "productName", "key", "slice", "flatMap", "performInvitation", "host", "guest", "clearTimeout", "length", "index", "ClientProvider", "id", "args", "React", "useRef", "ErrorBoundary", "Trigger", "performInvitation", "TestBuilder", "initializeClient", "client", "createIdentity", "createSpace", "onSpaceCreated", "onInitialized", "halo", "space", "spaces", "create", "name", "withClientProvider", "props", "handleInitialized", "Story", "React", "ErrorBoundary", "FallbackComponent", "ErrorFallback", "ClientProvider", "withMultiClientProvider", "numClients", "builder", "useRef", "TestBuilder", "hostRef", "spaceReady", "Trigger", "handleClientInitialized", "current", "wake", "wait", "Promise", "all", "performInvitation", "host", "guest", "Array", "from", "length", "map", "_", "index", "key", "services", "createLocalClientServices", "error", "message", "stack", "Error", "String", "undefined", "div", "role", "className", "h1", "pre"]
7
7
  }
@@ -26,22 +26,21 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_C4EWAKPZ_exports = {};
30
- __export(chunk_C4EWAKPZ_exports, {
29
+ var chunk_N474KOAU_exports = {};
30
+ __export(chunk_N474KOAU_exports, {
31
31
  AgentHostingContext: () => AgentHostingContext,
32
32
  AgentHostingProvider: () => AgentHostingProvider,
33
33
  ClientContext: () => ClientContext,
34
34
  ClientProvider: () => ClientProvider,
35
35
  useAgentHostingClient: () => useAgentHostingClient,
36
36
  useClient: () => useClient,
37
- useClientServices: () => useClientServices,
38
37
  useClientStatus: () => useClientStatus,
39
38
  useConfig: () => useConfig,
40
39
  useShell: () => useShell,
41
40
  useShellDisplay: () => useShellDisplay,
42
41
  useStatus: () => useStatus
43
42
  });
44
- module.exports = __toCommonJS(chunk_C4EWAKPZ_exports);
43
+ module.exports = __toCommonJS(chunk_N474KOAU_exports);
45
44
  var import_react = __toESM(require("react"));
46
45
  var import_client = require("@dxos/client");
47
46
  var import_log = require("@dxos/log");
@@ -55,13 +54,11 @@ var import_react4 = require("react");
55
54
  var import_react5 = require("react");
56
55
  var import_debug = require("@dxos/debug");
57
56
  var import_react6 = require("react");
58
- var import_debug2 = require("@dxos/debug");
59
57
  var import_react7 = require("react");
58
+ var import_debug2 = require("@dxos/debug");
60
59
  var import_react8 = require("react");
61
- var import_debug3 = require("@dxos/debug");
62
60
  var import_react9 = require("react");
63
- var import_react10 = require("react");
64
- var import_debug4 = require("@dxos/debug");
61
+ var import_debug3 = require("@dxos/debug");
65
62
  var ClientContext = (0, import_react4.createContext)(void 0);
66
63
  var BANNER = (client) => {
67
64
  const commitHash = client.config.get("runtime.app.build.commitHash");
@@ -86,15 +83,20 @@ var printBanner = (client) => {
86
83
  console.log(`%c${BANNER(client)}`, "font-family: monospace;");
87
84
  };
88
85
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/react-client/src/client/ClientProvider.tsx";
89
- var ClientProvider = ({ children, config: configProvider, client: clientProvider, services: servicesProvider, types, status: controlledStatus, fallback: Fallback = () => null, registerSignalFactory: _registerSignalFactory = true, onInitialized, ...options }) => {
90
- (0, import_react2.useMemo)(() => {
91
- _registerSignalFactory && (0, import_react3.registerSignalFactory)();
92
- }, []);
93
- const [client, setClient] = (0, import_react2.useState)(clientProvider instanceof import_client2.Client ? clientProvider : void 0);
86
+ var ClientProvider = /* @__PURE__ */ (0, import_react2.forwardRef)(({ children, config: configProvider, client: clientProvider, services: servicesProvider, types, status: controlledStatus, fallback: Fallback = () => null, registerSignalRuntime: _registerSignalRuntime = true, disableBanner, onInitialized, ...options }, forwardedRef) => {
87
+ (0, import_react2.useEffect)(() => {
88
+ _registerSignalRuntime && (0, import_react3.registerSignalRuntime)();
89
+ }, [
90
+ _registerSignalRuntime
91
+ ]);
94
92
  const [error, setError] = (0, import_react2.useState)();
95
93
  if (error) {
96
94
  throw error;
97
95
  }
96
+ const [client, setClient] = (0, import_react2.useState)(clientProvider instanceof import_client2.Client ? clientProvider : void 0);
97
+ (0, import_react2.useImperativeHandle)(forwardedRef, () => client, [
98
+ client
99
+ ]);
98
100
  const [status, setStatus] = (0, import_react_hooks.useControlledValue)(controlledStatus);
99
101
  (0, import_react2.useEffect)(() => {
100
102
  if (!client) {
@@ -103,43 +105,48 @@ var ClientProvider = ({ children, config: configProvider, client: clientProvider
103
105
  const subscription = client.status.subscribe((status2) => setStatus(status2));
104
106
  return () => subscription.unsubscribe();
105
107
  }, [
106
- client,
107
- setStatus
108
+ client
108
109
  ]);
109
110
  (0, import_react2.useEffect)(() => {
110
- const done = async (client2) => {
111
- await client2.initialize().catch(setError);
112
- (0, import_log2.log)("client ready", void 0, {
113
- F: __dxlog_file,
114
- L: 115,
115
- S: void 0,
116
- C: (f, a) => f(...a)
117
- });
118
- await onInitialized?.(client2);
119
- (0, import_log2.log)("initialization complete", void 0, {
120
- F: __dxlog_file,
121
- L: 117,
122
- S: void 0,
123
- C: (f, a) => f(...a)
124
- });
125
- if (types) {
126
- client2.addTypes(types);
111
+ const initialize = async (client3) => {
112
+ if (!client3.initialized) {
113
+ await client3.initialize().catch(setError);
114
+ (0, import_log2.log)("client ready", void 0, {
115
+ F: __dxlog_file,
116
+ L: 143,
117
+ S: void 0,
118
+ C: (f, a) => f(...a)
119
+ });
120
+ if (types) {
121
+ client3.addTypes(types);
122
+ }
123
+ await onInitialized?.(client3);
124
+ (0, import_log2.log)("initialization complete", void 0, {
125
+ F: __dxlog_file,
126
+ L: 148,
127
+ S: void 0,
128
+ C: (f, a) => f(...a)
129
+ });
130
+ } else if (types) {
131
+ client3.addTypes(types);
132
+ }
133
+ setClient(client3);
134
+ if (!disableBanner) {
135
+ printBanner(client3);
127
136
  }
128
- setClient(client2);
129
- setStatus(client2.status.get() ?? import_client2.SystemStatus.ACTIVE);
130
- printBanner(client2);
131
137
  };
138
+ let client2;
132
139
  const t = setTimeout(async () => {
133
140
  if (clientProvider) {
134
- const client2 = await (0, import_util.getAsyncProviderValue)(clientProvider);
135
- await done(client2);
141
+ client2 = await (0, import_util.getAsyncProviderValue)(clientProvider);
142
+ await initialize(client2);
136
143
  } else {
137
144
  const config = await (0, import_util.getAsyncProviderValue)(configProvider);
138
145
  (0, import_log2.log)("resolved config", {
139
146
  config
140
147
  }, {
141
148
  F: __dxlog_file,
142
- L: 135,
149
+ L: 169,
143
150
  S: void 0,
144
151
  C: (f, a) => f(...a)
145
152
  });
@@ -148,45 +155,53 @@ var ClientProvider = ({ children, config: configProvider, client: clientProvider
148
155
  services
149
156
  }, {
150
157
  F: __dxlog_file,
151
- L: 137,
158
+ L: 171,
152
159
  S: void 0,
153
160
  C: (f, a) => f(...a)
154
161
  });
155
- const client2 = new import_client2.Client({
162
+ client2 = new import_client2.Client({
156
163
  config,
157
164
  services,
158
165
  ...options
159
166
  });
160
167
  (0, import_log2.log)("created client", void 0, {
161
168
  F: __dxlog_file,
162
- L: 139,
169
+ L: 173,
163
170
  S: void 0,
164
171
  C: (f, a) => f(...a)
165
172
  });
166
- await done(client2);
173
+ await initialize(client2);
167
174
  }
168
175
  });
169
176
  return () => {
170
177
  (0, import_log2.log)("clean up", void 0, {
171
178
  F: __dxlog_file,
172
- L: 145,
179
+ L: 179,
173
180
  S: void 0,
174
181
  C: (f, a) => f(...a)
175
182
  });
176
183
  clearTimeout(t);
177
- void client?.destroy().catch((err) => import_log2.log.catch(err, void 0, {
184
+ void client2?.destroy().then(() => {
185
+ (0, import_log2.log)("destroyed", void 0, {
186
+ F: __dxlog_file,
187
+ L: 184,
188
+ S: void 0,
189
+ C: (f, a) => f(...a)
190
+ });
191
+ }).catch((err) => import_log2.log.catch(err, void 0, {
178
192
  F: __dxlog_file,
179
- L: 147,
193
+ L: 186,
180
194
  S: void 0,
181
195
  C: (f, a) => f(...a)
182
196
  }));
183
197
  };
184
198
  }, [
185
- clientProvider,
186
199
  configProvider,
187
- servicesProvider
200
+ clientProvider,
201
+ servicesProvider,
202
+ disableBanner
188
203
  ]);
189
- if (!client || status !== import_client2.SystemStatus.ACTIVE) {
204
+ if (!client?.initialized || status !== import_client2.SystemStatus.ACTIVE) {
190
205
  return /* @__PURE__ */ import_react2.default.createElement(Fallback, {
191
206
  client,
192
207
  status
@@ -198,18 +213,14 @@ var ClientProvider = ({ children, config: configProvider, client: clientProvider
198
213
  status
199
214
  }
200
215
  }, children);
201
- };
216
+ });
202
217
  var useClient = () => {
203
218
  const { client } = (0, import_react5.useContext)(ClientContext) ?? (0, import_debug.raise)(new Error("Missing ClientContext."));
204
219
  return client;
205
220
  };
206
- var useClientServices = () => {
207
- const { services } = (0, import_react6.useContext)(ClientContext) ?? (0, import_debug2.raise)(new Error("Missing ClientContext."));
208
- return services;
209
- };
210
221
  var useClientStatus = (client) => {
211
- const [status, setStatus] = (0, import_react7.useState)();
212
- (0, import_react7.useEffect)(() => {
222
+ const [status, setStatus] = (0, import_react6.useState)();
223
+ (0, import_react6.useEffect)(() => {
213
224
  if (!client) {
214
225
  return;
215
226
  }
@@ -222,7 +233,7 @@ var useClientStatus = (client) => {
222
233
  return status;
223
234
  };
224
235
  var useConfig = () => {
225
- const { client } = (0, import_react8.useContext)(ClientContext) ?? (0, import_debug3.raise)(new Error("Missing ClientContext."));
236
+ const { client } = (0, import_react7.useContext)(ClientContext) ?? (0, import_debug2.raise)(new Error("Missing ClientContext."));
226
237
  return client.config;
227
238
  };
228
239
  var useShell = () => {
@@ -231,14 +242,14 @@ var useShell = () => {
231
242
  };
232
243
  var useShellDisplay = () => {
233
244
  const client = useClient();
234
- const [display, setDisplay] = (0, import_react9.useState)(client.shell.display);
235
- (0, import_react9.useEffect)(() => client.shell.onDisplayChange(setDisplay), [
245
+ const [display, setDisplay] = (0, import_react8.useState)(client.shell.display);
246
+ (0, import_react8.useEffect)(() => client.shell.onDisplayChange(setDisplay), [
236
247
  client
237
248
  ]);
238
249
  return display;
239
250
  };
240
251
  var useStatus = () => {
241
- const { status } = (0, import_react10.useContext)(ClientContext) ?? (0, import_debug4.raise)(new Error("Missing ClientContext."));
252
+ const { status } = (0, import_react9.useContext)(ClientContext) ?? (0, import_debug3.raise)(new Error("Missing ClientContext."));
242
253
  return status;
243
254
  };
244
255
  var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/react-client/src/client/AgentHostingProvider.tsx";
@@ -302,11 +313,10 @@ var makeClient = ({ config, halo }) => {
302
313
  ClientProvider,
303
314
  useAgentHostingClient,
304
315
  useClient,
305
- useClientServices,
306
316
  useClientStatus,
307
317
  useConfig,
308
318
  useShell,
309
319
  useShellDisplay,
310
320
  useStatus
311
321
  });
312
- //# sourceMappingURL=chunk-C4EWAKPZ.cjs.map
322
+ //# sourceMappingURL=chunk-N474KOAU.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/client/AgentHostingProvider.tsx", "../../../src/client/ClientProvider.tsx", "../../../src/client/context.ts", "../../../src/banner.ts", "../../../src/client/useClient.ts", "../../../src/client/useClientStatus.ts", "../../../src/client/useConfig.ts", "../../../src/client/useShell.ts", "../../../src/client/useStatus.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { createContext, type PropsWithChildren, useContext, useState } from 'react';\n\nimport { type AgentHostingProviderClient, AgentManagerClient, FakeAgentHostingProvider } from '@dxos/client';\nimport { type Halo } from '@dxos/client/halo';\nimport { type Config } from '@dxos/config';\nimport { log } from '@dxos/log';\n\nimport { useClient } from '../client';\n\nexport type AgentHostingProviderProps = { config: Config; halo: Halo };\n\nexport const AgentHostingContext = createContext<AgentHostingProviderClient | null>(null);\n\n/**\n * Experimental agent hosting provider.\n * @param props\n * @constructor\n * @deprecated\n */\nexport const AgentHostingProvider = (props: PropsWithChildren<{}>) => {\n const client = useClient();\n const [agentHostingProviderClient] = useState(makeClient(client));\n return (\n <AgentHostingContext.Provider value={agentHostingProviderClient}> {props.children}</AgentHostingContext.Provider>\n );\n};\n\nexport const useAgentHostingClient = () => {\n return useContext(AgentHostingContext);\n};\n\nconst makeClient = ({ config, halo }: AgentHostingProviderProps) => {\n const agentHostingConfig = config.get('runtime.services.agentHosting');\n if (!agentHostingConfig) {\n log('no agent hosting configured');\n return null;\n }\n\n // TODO(nf): Dynamically discover based on runtime config.\n let agentHostingProviderClient: AgentHostingProviderClient | null = null;\n switch (agentHostingConfig.type) {\n case 'LOCAL_TESTING': {\n log('using FakeAgentHostingProvider');\n return new FakeAgentHostingProvider();\n }\n\n case 'AGENTHOSTING_API': {\n agentHostingProviderClient = new AgentManagerClient(config, halo);\n if (agentHostingProviderClient.init()) {\n return agentHostingProviderClient;\n } else {\n // Not authorized or error initializing.\n return null;\n }\n }\n\n default: {\n log.error('Unknown agent hosting provider type: ' + agentHostingConfig.type);\n return null;\n }\n }\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport React, {\n forwardRef,\n type FunctionComponent,\n type ReactNode,\n useEffect,\n useImperativeHandle,\n useState,\n} from 'react';\n\nimport { Client, type ClientOptions, type ClientServicesProvider, SystemStatus } from '@dxos/client';\nimport { type Config } from '@dxos/config';\nimport { type S } from '@dxos/echo-schema';\nimport { registerSignalRuntime } from '@dxos/echo-signals/react';\nimport { log } from '@dxos/log';\nimport { useControlledValue } from '@dxos/react-hooks';\nimport { getAsyncProviderValue, type MaybePromise, type Provider } from '@dxos/util';\n\nimport { ClientContext, type ClientContextProps } from './context';\nimport { printBanner } from '../banner';\n\n/**\n * Properties for the ClientProvider.\n */\nexport type ClientProviderProps = Pick<ClientContextProps, 'status'> &\n Omit<ClientOptions, 'config' | 'services'> & {\n children?: ReactNode;\n\n /**\n * Client object or async provider to enable to caller to do custom initialization.\n *\n * NOTE: For advanced use cases only.\n */\n client?: Client | Provider<Promise<Client>>;\n\n /**\n * Config object or async provider.\n *\n * NOTE: If a `client` is provided then `config` is ignored.\n */\n config?: Config | Provider<Promise<Config>>;\n\n /**\n * Callback to enable the caller to create a custom ClientServicesProvider.\n *\n * NOTE: If a `client` is provided then `services` is ignored.\n */\n services?: ClientServicesProvider | ((config?: Config) => MaybePromise<ClientServicesProvider>);\n\n /**\n * List of schema to register.\n *\n * NOTE: If a `client` is provided then `types` will not be added until after the children are first rendered.\n */\n types?: S.Schema<any>[];\n\n /**\n * ReactNode to display until the client is available.\n */\n fallback?: FunctionComponent<Partial<ClientContextProps>>;\n\n /**\n * Set to false to stop default signal runtime from being registered.\n *\n * The signals runtime is used to provide reactive updates to ECHO objects.\n */\n registerSignalRuntime?: boolean;\n\n /**\n * Skip the DXOS banner print.\n */\n disableBanner?: boolean;\n\n /**\n * Post initialization hook to enable to caller to do custom initialization.\n *\n * @param Client\n */\n onInitialized?: (client: Client) => MaybePromise<void>;\n };\n\n/**\n * Root component that provides the DXOS client instance to child components.\n * To be used with the `useClient` hook.\n */\nexport const ClientProvider = forwardRef<Client | undefined, ClientProviderProps>(\n (\n {\n children,\n config: configProvider,\n client: clientProvider,\n services: servicesProvider,\n types,\n status: controlledStatus,\n fallback: Fallback = () => null,\n registerSignalRuntime: _registerSignalRuntime = true,\n disableBanner,\n onInitialized,\n ...options\n },\n forwardedRef,\n ) => {\n useEffect(() => {\n // TODO(wittjosiah): Ideally this should be imported asynchronously because it is optional.\n // Unfortunately, async import seemed to break signals React instrumentation.\n _registerSignalRuntime && registerSignalRuntime();\n }, [_registerSignalRuntime]);\n\n // The client is initialized asynchronously.\n // If an error occurs during initialization, it is caught and the state is set.\n // This allows the error to be thrown in the render method.\n // The assumption is that a client initialization error is fatal to the app.\n // This error will be caught by the nearest error boundary.\n const [error, setError] = useState();\n if (error) {\n throw error;\n }\n\n const [client, setClient] = useState(clientProvider instanceof Client ? clientProvider : undefined);\n\n // Provide external access.\n useImperativeHandle(forwardedRef, () => client, [client]);\n\n // Client status subscription.\n const [status, setStatus] = useControlledValue(controlledStatus);\n useEffect(() => {\n if (!client) {\n return;\n }\n\n const subscription = client.status.subscribe((status) => setStatus(status));\n return () => subscription.unsubscribe();\n }, [client]);\n\n // Create and/or initialize client.\n useEffect(() => {\n const initialize = async (client: Client) => {\n if (!client.initialized) {\n await client.initialize().catch(setError);\n log('client ready');\n if (types) {\n client.addTypes(types);\n }\n await onInitialized?.(client);\n log('initialization complete');\n } else if (types) {\n client.addTypes(types);\n }\n\n setClient(client);\n\n if (!disableBanner) {\n printBanner(client);\n }\n };\n\n let client: Client;\n const t = setTimeout(async () => {\n if (clientProvider) {\n // Asynchronously request client.\n client = await getAsyncProviderValue(clientProvider);\n await initialize(client);\n } else {\n // Asynchronously construct client (config may be undefined).\n const config = await getAsyncProviderValue(configProvider);\n log('resolved config', { config });\n const services = await getAsyncProviderValue(servicesProvider, config);\n log('created services', { services });\n client = new Client({ config, services, ...options });\n log('created client');\n await initialize(client);\n }\n });\n\n return () => {\n log('clean up');\n clearTimeout(t);\n void client\n ?.destroy()\n .then(() => {\n log('destroyed');\n })\n .catch((err) => log.catch(err));\n };\n }, [configProvider, clientProvider, servicesProvider, disableBanner]);\n\n if (!client?.initialized || status !== SystemStatus.ACTIVE) {\n return <Fallback client={client} status={status} />;\n }\n\n return <ClientContext.Provider value={{ client, status }}>{children}</ClientContext.Provider>;\n },\n);\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { type Context, createContext } from 'react';\n\nimport { type Client, type SystemStatus } from '@dxos/client';\n\nexport type ClientContextProps = {\n client: Client;\n\n status?: SystemStatus | null;\n};\n\n/**\n * @internal Use ClientProvider to create or initialize the Client.\n */\nexport const ClientContext: Context<ClientContextProps | undefined> = createContext<ClientContextProps | undefined>(\n undefined,\n);\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport { type Client } from '@dxos/client';\n\n// http://patorjk.com/software/taag/#p=testall&f=Patorjk-HeX&t=DXOS\nconst BANNER = (client: Client) => {\n const commitHash = client.config.get('runtime.app.build.commitHash');\n const hash = commitHash ? ` App Commit ${commitHash} \\n` : '';\n\n return (\n '\\n' +\n '_/\\\\/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\______/\\\\/\\\\/\\\\/\\\\/\\\\_\\n' +\n '_/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\__/\\\\/\\\\_________\\n' +\n '_/\\\\/\\\\____/\\\\/\\\\______/\\\\/\\\\______/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\___\\n' +\n '_/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\__________/\\\\/\\\\_\\n' +\n '_/\\\\/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\/\\\\___\\n' +\n `\\n DXOS Client ${client.version} \\n${hash}`\n );\n};\n\nlet bannerPrinted = false;\n\nexport const printBanner = (client: Client) => {\n if (bannerPrinted) {\n return;\n }\n\n bannerPrinted = true;\n // eslint-disable-next-line no-console\n console.log(`%c${BANNER(client)}`, 'font-family: monospace;');\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { useContext } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { ClientContext } from '../client/context';\n\n/**\n * Hook returning instance of DXOS client.\n * Requires ClientContext to be set via ClientProvider.\n */\nexport const useClient = () => {\n const { client } = useContext(ClientContext) ?? raise(new Error('Missing ClientContext.'));\n return client;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { useEffect, useState } from 'react';\n\nimport { type Client, type SystemStatus } from '@dxos/client';\n\nexport const useClientStatus = (client: Client) => {\n const [status, setStatus] = useState<SystemStatus | null>();\n useEffect(() => {\n if (!client) {\n return;\n }\n\n const subscription = client.status.subscribe((status) => setStatus(status));\n return () => subscription.unsubscribe();\n }, [client, setStatus]);\n\n return status;\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { useContext } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { ClientContext } from './context';\n\n/**\n * Hook returning config object used to initialize the DXOS client instance.\n * Requires ClientContext to be set via ClientProvider.\n */\nexport const useConfig = () => {\n const { client } = useContext(ClientContext) ?? raise(new Error('Missing ClientContext.'));\n return client.config;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { useEffect, useState } from 'react';\n\nimport { type Shell, type ShellDisplay } from '@dxos/client';\n\nimport { useClient } from './useClient';\n\n/**\n * Helper hook to access the shell.\n */\nexport const useShell = (): Shell => {\n const client = useClient();\n return client.shell;\n};\n\n/**\n * Hook to access the shell’s display state.\n */\nexport const useShellDisplay = (): ShellDisplay => {\n const client = useClient();\n const [display, setDisplay] = useState(client.shell.display);\n useEffect(() => client.shell.onDisplayChange(setDisplay), [client]);\n return display;\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { useContext } from 'react';\n\nimport { type SystemStatus } from '@dxos/client';\nimport { raise } from '@dxos/debug';\n\nimport { ClientContext } from './context';\n\nexport const useStatus = (): SystemStatus | null | undefined => {\n const { status } = useContext(ClientContext) ?? raise(new Error('Missing ClientContext.'));\n return status;\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mBAAmF;AAEnF,oBAA8F;AAG9F,iBAAoB;ACLpB,IAAAA,gBAOO;AAEP,IAAAC,iBAAsF;AAGtF,IAAAD,gBAAsC;AACtC,IAAAE,cAAoB;AACpB,yBAAmC;AACnC,kBAAwE;ACfxE,IAAAF,gBAA4C;AEA5C,IAAAA,gBAA2B;AAE3B,mBAAsB;ACFtB,IAAAA,gBAAoC;ACApC,IAAAA,gBAA2B;AAE3B,IAAAG,gBAAsB;ACFtB,IAAAH,gBAAoC;ACApC,IAAAA,gBAA2B;AAG3B,IAAAG,gBAAsB;ANUf,IAAMC,oBAAyDC,6BACpEC,MAAAA;ACXF,IAAMC,SAAS,CAACC,WAAAA;AACd,QAAMC,aAAaD,OAAOE,OAAOC,IAAI,8BAAA;AACrC,QAAMC,OAAOH,aAAa,eAAeA,UAAAA;IAAkB;AAE3D,SACE;;;;;;;eAMkBD,OAAOK,OAAO;EAAMD,IAAAA;AAE1C;AAEA,IAAIE,gBAAgB;AAEb,IAAMC,cAAc,CAACP,WAAAA;AAC1B,MAAIM,eAAe;AACjB;EACF;AAEAA,kBAAgB;AAEhBE,UAAQC,IAAI,KAAKV,OAAOC,MAAAA,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nC,aAAOjB,aAAAA,YAAWY,mBAAAA;AACpB;AAEA,IAAMI,aAAa,CAAC,EAAEvE,QAAQyE,KAAI,MAA6B;AAC7D,QAAMC,qBAAqB1E,OAAOC,IAAI,+BAAA;AACtC,MAAI,CAACyE,oBAAoB;AACvBnE,mBAAAA,KAAI,+BAAA,QAAA;;;;;;AACJ,WAAO;EACT;AAGA,MAAI+D,6BAAgE;AACpE,UAAQI,mBAAmBC,MAAI;IAC7B,KAAK,iBAAiB;AACpBpE,qBAAAA,KAAI,kCAAA,QAAA;;;;;;AACJ,aAAO,IAAIqE,uCAAAA;IACb;IAEA,KAAK,oBAAoB;AACvBN,mCAA6B,IAAIO,iCAAmB7E,QAAQyE,IAAAA;AAC5D,UAAIH,2BAA2BQ,KAAI,GAAI;AACrC,eAAOR;MACT,OAAO;AAEL,eAAO;MACT;IACF;IAEA,SAAS;AACP/D,iBAAAA,IAAIoB,MAAM,0CAA0C+C,mBAAmBC,MAAI,QAAA;;;;;;AAC3E,aAAO;IACT;EACF;AACF;",
6
+ "names": ["import_react", "import_client", "import_log", "import_debug", "ClientContext", "createContext", "undefined", "BANNER", "client", "commitHash", "config", "get", "hash", "version", "bannerPrinted", "printBanner", "console", "log", "ClientProvider", "forwardRef", "children", "configProvider", "clientProvider", "services", "servicesProvider", "types", "status", "controlledStatus", "fallback", "Fallback", "registerSignalRuntime", "_registerSignalRuntime", "disableBanner", "onInitialized", "options", "forwardedRef", "useEffect", "error", "setError", "useState", "setClient", "Client", "useImperativeHandle", "setStatus", "useControlledValue", "subscription", "subscribe", "unsubscribe", "initialize", "initialized", "catch", "addTypes", "t", "setTimeout", "getAsyncProviderValue", "clearTimeout", "destroy", "then", "err", "SystemStatus", "ACTIVE", "React", "Provider", "value", "useClient", "useContext", "raise", "Error", "useClientStatus", "useConfig", "useShell", "shell", "useShellDisplay", "display", "setDisplay", "onDisplayChange", "useStatus", "AgentHostingContext", "AgentHostingProvider", "props", "agentHostingProviderClient", "makeClient", "useAgentHostingClient", "halo", "agentHostingConfig", "type", "FakeAgentHostingProvider", "AgentManagerClient", "init"]
7
+ }
@@ -23,13 +23,13 @@ __export(devtools_exports, {
23
23
  useStream: () => useStream
24
24
  });
25
25
  module.exports = __toCommonJS(devtools_exports);
26
- var import_chunk_C4EWAKPZ = require("../chunk-C4EWAKPZ.cjs");
26
+ var import_chunk_N474KOAU = require("../chunk-N474KOAU.cjs");
27
27
  __reExport(devtools_exports, require("@dxos/client/devtools"), module.exports);
28
28
  var import_debug = require("@dxos/debug");
29
29
  var import_react = require("react");
30
30
  var import_log = require("@dxos/log");
31
31
  var useDevtools = () => {
32
- const client = (0, import_chunk_C4EWAKPZ.useClient)();
32
+ const client = (0, import_chunk_N474KOAU.useClient)();
33
33
  return client.services.services.DevtoolsHost ?? (0, import_debug.raise)(new Error("DevtoolsHost not available."));
34
34
  };
35
35
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/react-client/src/devtools/useStream.ts";
@@ -29,7 +29,7 @@ __export(echo_exports, {
29
29
  });
30
30
  module.exports = __toCommonJS(echo_exports);
31
31
  var import_chunk_FYOAVV65 = require("../chunk-FYOAVV65.cjs");
32
- var import_chunk_C4EWAKPZ = require("../chunk-C4EWAKPZ.cjs");
32
+ var import_chunk_N474KOAU = require("../chunk-N474KOAU.cjs");
33
33
  __reExport(echo_exports, require("@dxos/client/echo"), module.exports);
34
34
  var import_async = require("@dxos/async");
35
35
  var import_echo = require("@dxos/client/echo");
@@ -45,7 +45,7 @@ var import_react_hooks3 = require("@dxos/react-hooks");
45
45
  var import_react4 = require("react");
46
46
  var import_echo4 = require("@dxos/client/echo");
47
47
  var useSpace = (spaceKeyLike) => {
48
- const client = (0, import_chunk_C4EWAKPZ.useClient)();
48
+ const client = (0, import_chunk_N474KOAU.useClient)();
49
49
  const spaces = (0, import_react_hooks2.useMulticastObservable)(client.spaces);
50
50
  const [ready, setReady] = (0, import_react.useState)(false);
51
51
  (0, import_react.useEffect)(() => {
@@ -69,7 +69,7 @@ var useSpace = (spaceKeyLike) => {
69
69
  }
70
70
  };
71
71
  var useSpaces = ({ all = false } = {}) => {
72
- const client = (0, import_chunk_C4EWAKPZ.useClient)();
72
+ const client = (0, import_chunk_N474KOAU.useClient)();
73
73
  const spaces = (0, import_react_hooks2.useMulticastObservable)(client.spaces);
74
74
  return spaces.filter((space) => all || space.state.get() === import_echo2.SpaceState.SPACE_READY);
75
75
  };
@@ -31,7 +31,7 @@ __export(halo_exports, {
31
31
  });
32
32
  module.exports = __toCommonJS(halo_exports);
33
33
  var import_chunk_FYOAVV65 = require("../chunk-FYOAVV65.cjs");
34
- var import_chunk_C4EWAKPZ = require("../chunk-C4EWAKPZ.cjs");
34
+ var import_chunk_N474KOAU = require("../chunk-N474KOAU.cjs");
35
35
  var import_halo = require("@dxos/client/halo");
36
36
  var import_react_hooks = require("@dxos/react-hooks");
37
37
  var import_react_hooks2 = require("@dxos/react-hooks");
@@ -40,15 +40,15 @@ var import_react_hooks3 = require("@dxos/react-hooks");
40
40
  var import_react_hooks4 = require("@dxos/react-hooks");
41
41
  var import_react2 = require("react");
42
42
  var useContacts = () => {
43
- const client = (0, import_chunk_C4EWAKPZ.useClient)();
43
+ const client = (0, import_chunk_N474KOAU.useClient)();
44
44
  return (0, import_react_hooks.useMulticastObservable)(client.halo.contacts);
45
45
  };
46
46
  var useDevices = () => {
47
- const client = (0, import_chunk_C4EWAKPZ.useClient)();
47
+ const client = (0, import_chunk_N474KOAU.useClient)();
48
48
  return (0, import_react_hooks2.useMulticastObservable)(client.halo.devices);
49
49
  };
50
50
  var useHaloInvitations = () => {
51
- const client = (0, import_chunk_C4EWAKPZ.useClient)();
51
+ const client = (0, import_chunk_N474KOAU.useClient)();
52
52
  return (0, import_react_hooks3.useMulticastObservable)(client.halo.invitations);
53
53
  };
54
54
  var useHaloInvitation = (invitationId) => {
@@ -59,7 +59,7 @@ var useHaloInvitation = (invitationId) => {
59
59
  return (0, import_chunk_FYOAVV65.useInvitationStatus)(invitation);
60
60
  };
61
61
  var useIdentity = () => {
62
- const client = (0, import_chunk_C4EWAKPZ.useClient)();
62
+ const client = (0, import_chunk_N474KOAU.useClient)();
63
63
  return (0, import_react_hooks4.useMulticastObservable)(client.halo.identity);
64
64
  };
65
65
  var KeyStore = class {
@@ -19,22 +19,21 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
19
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
20
  var node_exports = {};
21
21
  __export(node_exports, {
22
- AgentHostingContext: () => import_chunk_C4EWAKPZ.AgentHostingContext,
23
- AgentHostingProvider: () => import_chunk_C4EWAKPZ.AgentHostingProvider,
24
- ClientContext: () => import_chunk_C4EWAKPZ.ClientContext,
25
- ClientProvider: () => import_chunk_C4EWAKPZ.ClientProvider,
26
- useAgentHostingClient: () => import_chunk_C4EWAKPZ.useAgentHostingClient,
27
- useClient: () => import_chunk_C4EWAKPZ.useClient,
28
- useClientServices: () => import_chunk_C4EWAKPZ.useClientServices,
29
- useClientStatus: () => import_chunk_C4EWAKPZ.useClientStatus,
30
- useConfig: () => import_chunk_C4EWAKPZ.useConfig,
22
+ AgentHostingContext: () => import_chunk_N474KOAU.AgentHostingContext,
23
+ AgentHostingProvider: () => import_chunk_N474KOAU.AgentHostingProvider,
24
+ ClientContext: () => import_chunk_N474KOAU.ClientContext,
25
+ ClientProvider: () => import_chunk_N474KOAU.ClientProvider,
26
+ useAgentHostingClient: () => import_chunk_N474KOAU.useAgentHostingClient,
27
+ useClient: () => import_chunk_N474KOAU.useClient,
28
+ useClientStatus: () => import_chunk_N474KOAU.useClientStatus,
29
+ useConfig: () => import_chunk_N474KOAU.useConfig,
31
30
  useMulticastObservable: () => import_react_hooks.useMulticastObservable,
32
- useShell: () => import_chunk_C4EWAKPZ.useShell,
33
- useShellDisplay: () => import_chunk_C4EWAKPZ.useShellDisplay,
34
- useStatus: () => import_chunk_C4EWAKPZ.useStatus
31
+ useShell: () => import_chunk_N474KOAU.useShell,
32
+ useShellDisplay: () => import_chunk_N474KOAU.useShellDisplay,
33
+ useStatus: () => import_chunk_N474KOAU.useStatus
35
34
  });
36
35
  module.exports = __toCommonJS(node_exports);
37
- var import_chunk_C4EWAKPZ = require("./chunk-C4EWAKPZ.cjs");
36
+ var import_chunk_N474KOAU = require("./chunk-N474KOAU.cjs");
38
37
  __reExport(node_exports, require("@dxos/client"), module.exports);
39
38
  var import_react_hooks = require("@dxos/react-hooks");
40
39
  // Annotate the CommonJS export names for ESM import in node:
@@ -45,7 +44,6 @@ var import_react_hooks = require("@dxos/react-hooks");
45
44
  ClientProvider,
46
45
  useAgentHostingClient,
47
46
  useClient,
48
- useClientServices,
49
47
  useClientStatus,
50
48
  useConfig,
51
49
  useMulticastObservable,
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/index.ts"],
4
4
  "sourcesContent": ["//\n// Copyright 2020 DXOS.org\n//\n\nexport * from '@dxos/client';\nexport { useMulticastObservable } from '@dxos/react-hooks';\n\nexport * from './client';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,yBAAc;AACd,yBAAuC;",
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,yBAAc;AACd,yBAAuC;",
6
6
  "names": []
7
7
  }
@@ -22,11 +22,11 @@ __export(mesh_exports, {
22
22
  useNetworkStatus: () => useNetworkStatus
23
23
  });
24
24
  module.exports = __toCommonJS(mesh_exports);
25
- var import_chunk_C4EWAKPZ = require("../chunk-C4EWAKPZ.cjs");
25
+ var import_chunk_N474KOAU = require("../chunk-N474KOAU.cjs");
26
26
  __reExport(mesh_exports, require("@dxos/client/mesh"), module.exports);
27
27
  var import_react_hooks = require("@dxos/react-hooks");
28
28
  var useNetworkStatus = () => {
29
- const client = (0, import_chunk_C4EWAKPZ.useClient)();
29
+ const client = (0, import_chunk_N474KOAU.useClient)();
30
30
  return (0, import_react_hooks.useMulticastObservable)(client.mesh.networkStatus);
31
31
  };
32
32
  // Annotate the CommonJS export names for ESM import in node: