@dxos/react-client 0.7.4 → 0.7.5-feature-compute.4d9d99a

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 (50) hide show
  1. package/dist/lib/browser/{chunk-U4MCIYKN.mjs → chunk-Z6OJATVN.mjs} +58 -41
  2. package/dist/lib/browser/chunk-Z6OJATVN.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 -1
  7. package/dist/lib/browser/mesh/index.mjs +1 -1
  8. package/dist/lib/browser/meta.json +1 -1
  9. package/dist/lib/browser/testing/index.mjs +32 -33
  10. package/dist/lib/browser/testing/index.mjs.map +4 -4
  11. package/dist/lib/node/{chunk-UJLDNXPC.cjs → chunk-DITMVTAF.cjs} +61 -44
  12. package/dist/lib/node/chunk-DITMVTAF.cjs.map +7 -0
  13. package/dist/lib/node/devtools/index.cjs +2 -2
  14. package/dist/lib/node/echo/index.cjs +3 -3
  15. package/dist/lib/node/halo/index.cjs +5 -5
  16. package/dist/lib/node/index.cjs +12 -12
  17. package/dist/lib/node/mesh/index.cjs +2 -2
  18. package/dist/lib/node/meta.json +1 -1
  19. package/dist/lib/node/testing/index.cjs +61 -63
  20. package/dist/lib/node/testing/index.cjs.map +4 -4
  21. package/dist/lib/node-esm/{chunk-4J4SI7XJ.mjs → chunk-6QHTUQ4Z.mjs} +58 -41
  22. package/dist/lib/node-esm/chunk-6QHTUQ4Z.mjs.map +7 -0
  23. package/dist/lib/node-esm/devtools/index.mjs +1 -1
  24. package/dist/lib/node-esm/echo/index.mjs +1 -1
  25. package/dist/lib/node-esm/halo/index.mjs +1 -1
  26. package/dist/lib/node-esm/index.mjs +1 -1
  27. package/dist/lib/node-esm/mesh/index.mjs +1 -1
  28. package/dist/lib/node-esm/meta.json +1 -1
  29. package/dist/lib/node-esm/testing/index.mjs +32 -33
  30. package/dist/lib/node-esm/testing/index.mjs.map +4 -4
  31. package/dist/types/src/client/ClientProvider.d.ts.map +1 -1
  32. package/dist/types/src/testing/ClientRepeater.d.ts +2 -2
  33. package/dist/types/src/testing/ClientRepeater.d.ts.map +1 -1
  34. package/dist/types/src/testing/context.d.ts +7 -0
  35. package/dist/types/src/testing/context.d.ts.map +1 -0
  36. package/dist/types/src/testing/index.d.ts +1 -0
  37. package/dist/types/src/testing/index.d.ts.map +1 -1
  38. package/dist/types/src/testing/withClientProvider.d.ts +4 -8
  39. package/dist/types/src/testing/withClientProvider.d.ts.map +1 -1
  40. package/dist/types/tsconfig.tsbuildinfo +1 -0
  41. package/package.json +23 -23
  42. package/src/client/ClientProvider.tsx +26 -14
  43. package/src/testing/ClientRepeater.tsx +3 -3
  44. package/src/testing/context.tsx +19 -0
  45. package/src/testing/index.ts +1 -0
  46. package/src/testing/withClientProvider.tsx +37 -39
  47. package/tsconfig.json +61 -2
  48. package/dist/lib/browser/chunk-U4MCIYKN.mjs.map +0 -7
  49. package/dist/lib/node/chunk-UJLDNXPC.cjs.map +0 -7
  50. package/dist/lib/node-esm/chunk-4J4SI7XJ.mjs.map +0 -7
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 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 { TestBuilder, performInvitation } from '@dxos/client/testing';\nimport { type AbstractTypedObject } from '@dxos/echo-schema';\nimport { registerSignalsRuntime } from '@dxos/echo-signals/react';\nimport { faker } from '@dxos/random';\n\nimport { type WithClientProviderProps } from './withClientProvider';\nimport { ClientProvider } from '../client';\n\nexport type ClientRepeatedComponentProps = { id: number; count: number; spaceKey?: PublicKey };\n\nexport type ClientRepeaterControlsProps = { clients: Client[] };\n\n// TODO(burdon): Reconcile with ClientProviderProps.\nexport type ClientRepeaterProps<P extends ClientRepeatedComponentProps> = {\n className?: string;\n component: FC<ClientRepeatedComponentProps>;\n controls?: FC<ClientRepeaterControlsProps>;\n count?: number;\n clients?: Client[];\n types?: AbstractTypedObject[];\n args?: Omit<P, 'id' | 'count'>;\n} & Pick<WithClientProviderProps, 'createIdentity' | 'createSpace' | 'onSpaceCreated'>;\n\n/**\n * Utility component for Storybook stories which sets up clients for n peers.\n * The `Component` property is rendered n times, once for each peer.\n * @deprecated use `withClientProvider`.\n */\n// TODO(burdon): To discuss: evolve ClientRepeater with optional decorator that uses it.\n// NOTE: This is specifically not a storybook decorator because it broke stories as a decorator.\n// This seems primarily due to the fact that it required top-level await for the clients to initialize.\n// Storybook seemed to handle it alright, but Chromatic had a lot of trouble with it.\n// There was also a question of whether or not calling the story function multiple times was a good idea.\nexport const ClientRepeater = <P extends ClientRepeatedComponentProps>(props: ClientRepeaterProps<P>) => {\n const {\n component: Component,\n controls: Controls,\n count = 1,\n types,\n createIdentity,\n createSpace,\n onSpaceCreated,\n } = props;\n useEffect(() => {\n registerSignalsRuntime();\n }, []);\n\n const [clients, setClients] = useState(props.clients ?? []);\n const [spaceKey, setSpaceKey] = useState<PublicKey>();\n\n const testBuilder = useRef(new TestBuilder());\n useEffect(() => {\n const timeout = setTimeout(async () => {\n const clients = [...Array(count)].map(\n (_) => new Client({ services: testBuilder.current.createLocalClientServices(), types }),\n );\n\n await Promise.all(clients.map((client) => client.initialize()));\n if (createIdentity || createSpace) {\n await Promise.all(clients.map((client) => client.halo.createIdentity()));\n }\n\n if (createSpace) {\n const client = clients[0];\n const space = await client.spaces.create({ name: faker.commerce.productName() });\n setSpaceKey(space.key);\n await onSpaceCreated?.({ client, space });\n await Promise.all(\n clients.slice(1).flatMap((client) => performInvitation({ host: space, guest: client.spaces })),\n );\n }\n\n setClients(clients);\n });\n\n return () => clearTimeout(timeout);\n }, []);\n\n if (clients.length === 0) {\n return null;\n }\n\n return (\n <>\n {Controls && <Controls clients={clients} />}\n {clients.map((client, index) => (\n <ClientProvider key={index} client={client}>\n <Component id={index} count={clients.length} spaceKey={spaceKey} {...{ ...props.args }} />\n </ClientProvider>\n ))}\n </>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type Decorator } from '@storybook/react';\nimport React, { createContext, type PropsWithChildren, useContext, useEffect, useRef, useState } from 'react';\nimport { type FallbackProps, ErrorBoundary as NativeErrorBoundary } from 'react-error-boundary';\n\nimport { Trigger } from '@dxos/async';\nimport { type Client } from '@dxos/client';\nimport { type Space } from '@dxos/client/echo';\nimport { performInvitation, TestBuilder } from '@dxos/client/testing';\nimport { raise } from '@dxos/debug';\nimport { log } from '@dxos/log';\nimport { type MaybePromise } from '@dxos/util';\n\nimport { ClientProvider, type ClientProviderProps } from '../client';\n\ntype InitializeProps = {\n createIdentity?: boolean;\n createSpace?: boolean;\n onInitialized?: (client: Client) => MaybePromise<Record<string, any> | void>;\n onIdentityCreated?: (props: { client: Client }) => MaybePromise<Record<string, any> | void>;\n onSpaceCreated?: (props: { client: Client; space: Space }) => MaybePromise<Record<string, any> | void>;\n};\n\n/**\n * Initialize client, identity and first space.\n */\nconst initializeClient = async (\n client: Client,\n { createIdentity, createSpace, onSpaceCreated, onIdentityCreated, onInitialized }: InitializeProps,\n): Promise<StoryClientProps> => {\n const clientData = await onInitialized?.(client);\n\n let identityData: Record<string, any> | void = {};\n if (createIdentity || createSpace) {\n if (!client.halo.identity.get()) {\n await client.halo.createIdentity();\n identityData = await onIdentityCreated?.({ client });\n }\n }\n\n let space: Space | undefined;\n let spaceData: Record<string, any> | void = {};\n if (createSpace) {\n space = await client.spaces.create({ name: 'Test Space' });\n spaceData = await onSpaceCreated?.({ client, space });\n }\n\n return { space, ...clientData, ...identityData, ...spaceData };\n};\n\ntype StoryClientProps<T extends Record<string, any> = Record<string, unknown>> = T & { space?: Space };\n\n// TODO(wittjosiah): Add to multi-client as well.\nconst StoryClientContext = createContext<StoryClientProps | undefined>(undefined);\n\nexport const useStoryClientData = <T extends Record<string, any> = Record<string, unknown>>() => {\n const data = useContext(StoryClientContext) ?? raise(new Error('Missing withClientProvider decorator.'));\n return data as StoryClientProps<T>;\n};\n\nexport type WithClientProviderProps = InitializeProps & Omit<ClientProviderProps, 'onInitialized'>;\n\n/**\n * Decorator that provides the client context.\n */\nexport const withClientProvider = ({\n createIdentity,\n createSpace,\n onSpaceCreated,\n onIdentityCreated,\n onInitialized,\n ...props\n}: WithClientProviderProps = {}): Decorator => {\n return (Story) => {\n const [data, setData] = useState<StoryClientProps>({});\n\n const handleInitialized = async (client: Client) => {\n setData(\n await initializeClient(client, {\n createIdentity,\n createSpace,\n onSpaceCreated,\n onIdentityCreated,\n onInitialized,\n }),\n );\n };\n\n return (\n <ErrorBoundary>\n <ClientProvider onInitialized={handleInitialized} {...props}>\n <StoryClientContext.Provider value={data}>\n <Story />\n </StoryClientContext.Provider>\n </ClientProvider>\n </ErrorBoundary>\n );\n };\n};\n\n// TODO(burdon): Implement context per client for context.\n// TODO(burdon): Callback once all invitations have completed.\n// TODO(burdon): Delay/jitter for creation of other clients.\nexport type WithMultiClientProviderProps = InitializeProps &\n Omit<ClientProviderProps, 'onInitialized'> & { numClients?: number };\n\nconst MultiClientContext = createContext<{ id: number }>({ id: 0 });\n\nexport const useMultiClient = () => useContext(MultiClientContext);\n\n/**\n * Decorator that creates a scaffold for multiple clients.\n * Orchestrates invitations between a randomly selected host and the remaining clients.\n * NOTE: Should come before withLayout.\n */\nexport const withMultiClientProvider = ({\n numClients = 2,\n createIdentity,\n createSpace,\n onSpaceCreated,\n onIdentityCreated,\n onInitialized,\n ...props\n}: WithMultiClientProviderProps): Decorator => {\n return (Story) => {\n const builder = useRef(new TestBuilder());\n const hostRef = useRef<Client>();\n const spaceReady = useRef(new Trigger<Space | undefined>());\n\n // Handle invitations.\n // NOTE: The zeroth client isn't necessarily the first to be initialized.\n const handleInitialized = async (client: Client, index: number) => {\n log.info('initialized', { index });\n if (createSpace) {\n if (!hostRef.current) {\n hostRef.current = client;\n const { space } = await initializeClient(client, {\n createIdentity,\n createSpace,\n onSpaceCreated,\n onIdentityCreated,\n onInitialized,\n });\n spaceReady.current.wake(space);\n log.info('inviting', { index });\n } else {\n await initializeClient(client, { createIdentity, onInitialized });\n const space = await spaceReady.current.wait();\n if (space) {\n log.info('joining', { index });\n await Promise.all(performInvitation({ host: space, guest: client.spaces }));\n }\n }\n }\n };\n\n return (\n <ErrorBoundary>\n {Array.from({ length: numClients }).map((_, index) => (\n <MultiClientContext.Provider key={index} value={{ id: index }}>\n <ClientProvider\n services={builder.current.createLocalClientServices()}\n onInitialized={(client) => handleInitialized(client, index)}\n {...props}\n >\n <Story />\n </ClientProvider>\n </MultiClientContext.Provider>\n ))}\n </ErrorBoundary>\n );\n };\n};\n\nconst ErrorBoundary = ({ children }: PropsWithChildren) => {\n const [error, setError] = useState<Error>();\n useEffect(() => {\n const handleError = (event: PromiseRejectionEvent) => {\n setError(event.reason);\n };\n\n window.addEventListener('unhandledrejection', handleError);\n return () => window.removeEventListener('unhandledrejection', handleError);\n }, []);\n\n if (error) {\n return <ErrorFallback error={error} resetErrorBoundary={() => setError(undefined)} />;\n }\n\n return <NativeErrorBoundary FallbackComponent={ErrorFallback}>{children}</NativeErrorBoundary>;\n};\n\nconst ErrorFallback = ({ error }: FallbackProps) => {\n const { name, message, stack } =\n error instanceof Error ? error : { name: 'Error', message: String(error), stack: undefined };\n return (\n <div role='alert' className='flex flex-col p-4 gap-4 overflow-auto'>\n <h1 className='text-xl text-red-500'>{name}</h1>\n <div className='text-lg'>{message}</div>\n {stack && <pre className='whitespace-pre-wrap text-sm text-subdued'>{stack}</pre>}\n </div>\n );\n};\n"],
5
- "mappings": ";;;;;AAIA,cAAc;;;ACAd,O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BAAiB,sBAAsBJ,WAAAA;AAC9C,WAAO,MAAMG,OAAOE,oBAAoB,sBAAsBL,WAAAA;EAChE,GAAG,CAAA,CAAE;AAEL,MAAIH,OAAO;AACT,WAAO,gBAAApC,OAAA,cAAC6C,eAAAA;MAAcT;MAAcU,oBAAoB,MAAMT,SAASjD,MAAAA;;EACzE;AAEA,SAAO,gBAAAY,OAAA,cAAC+C,qBAAAA;IAAoBC,mBAAmBH;KAAgBV,QAAAA;AACjE;AAEA,IAAMU,gBAAgB,CAAC,EAAET,MAAK,MAAiB;AAC7C,QAAM,EAAEnD,MAAMgE,SAASC,MAAK,IAC1Bd,iBAAiB3C,QAAQ2C,QAAQ;IAAEnD,MAAM;IAASgE,SAASE,OAAOf,KAAAA;IAAQc,OAAO9D;EAAU;AAC7F,SACE,gBAAAY,OAAA,cAACoD,OAAAA;IAAIC,MAAK;IAAQC,WAAU;KAC1B,gBAAAtD,OAAA,cAACuD,MAAAA;IAAGD,WAAU;KAAwBrE,IAAAA,GACtC,gBAAAe,OAAA,cAACoD,OAAAA;IAAIE,WAAU;KAAWL,OAAAA,GACzBC,SAAS,gBAAAlD,OAAA,cAACwD,OAAAA;IAAIF,WAAU;KAA4CJ,KAAAA,CAAAA;AAG3E;",
6
- "names": ["React", "useState", "useEffect", "useRef", "Client", "TestBuilder", "performInvitation", "registerSignalsRuntime", "faker", "ClientRepeater", "props", "component", "Component", "controls", "Controls", "count", "types", "createIdentity", "createSpace", "onSpaceCreated", "useEffect", "registerSignalsRuntime", "clients", "setClients", "useState", "spaceKey", "setSpaceKey", "testBuilder", "useRef", "TestBuilder", "timeout", "setTimeout", "Array", "map", "_", "Client", "services", "current", "createLocalClientServices", "Promise", "all", "client", "initialize", "halo", "space", "spaces", "create", "name", "faker", "commerce", "productName", "key", "slice", "flatMap", "performInvitation", "host", "guest", "clearTimeout", "length", "index", "ClientProvider", "id", "args", "React", "createContext", "useContext", "useEffect", "useRef", "useState", "ErrorBoundary", "NativeErrorBoundary", "Trigger", "performInvitation", "TestBuilder", "raise", "log", "initializeClient", "client", "createIdentity", "createSpace", "onSpaceCreated", "onIdentityCreated", "onInitialized", "clientData", "identityData", "halo", "identity", "get", "space", "spaceData", "spaces", "create", "name", "StoryClientContext", "createContext", "undefined", "useStoryClientData", "data", "useContext", "raise", "Error", "withClientProvider", "props", "Story", "setData", "useState", "handleInitialized", "React", "ErrorBoundary", "ClientProvider", "Provider", "value", "MultiClientContext", "id", "useMultiClient", "withMultiClientProvider", "numClients", "builder", "useRef", "TestBuilder", "hostRef", "spaceReady", "Trigger", "index", "log", "info", "current", "wake", "wait", "Promise", "all", "performInvitation", "host", "guest", "Array", "from", "length", "map", "_", "key", "services", "createLocalClientServices", "children", "error", "setError", "useEffect", "handleError", "event", "reason", "window", "addEventListener", "removeEventListener", "ErrorFallback", "resetErrorBoundary", "NativeErrorBoundary", "FallbackComponent", "message", "stack", "String", "div", "role", "className", "h1", "pre"]
3
+ "sources": ["../../../../src/testing/index.ts", "../../../../src/testing/context.tsx", "../../../../src/testing/ClientRepeater.tsx", "../../../../src/testing/withClientProvider.tsx"],
4
+ "sourcesContent": ["//\n// Copyright 2020 DXOS.org\n//\n\nexport * from '@dxos/client/testing';\n\nexport * from './context';\nexport * from './ClientRepeater';\nexport * from './withClientProvider';\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { createContext, useContext } from 'react';\n\nimport { type Space } from '@dxos/client/echo';\nimport { raise } from '@dxos/debug';\n\nexport type ClientStory = {\n space?: Space;\n};\n\n// TODO(wittjosiah): Add to multi-client as well.\nexport const ClientStory = createContext<ClientStory | undefined>(undefined);\n\nexport const useClientProvider = (): ClientStory => {\n return useContext(ClientStory) ?? raise(new Error('Missing ClientStory'));\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport React, { useState, type FC, useEffect, useRef } from 'react';\n\nimport { Client, type PublicKey } from '@dxos/client';\nimport { TestBuilder, performInvitation } from '@dxos/client/testing';\nimport { type TypedObject } from '@dxos/echo-schema';\nimport { registerSignalsRuntime } from '@dxos/echo-signals/react';\nimport { faker } from '@dxos/random';\n\nimport { type WithClientProviderProps } from './withClientProvider';\nimport { ClientProvider } from '../client';\n\nexport type ClientRepeatedComponentProps = { id: number; count: number; spaceKey?: PublicKey };\n\nexport type ClientRepeaterControlsProps = { clients: Client[] };\n\n// TODO(burdon): Reconcile with ClientProviderProps.\nexport type ClientRepeaterProps<P extends ClientRepeatedComponentProps> = {\n className?: string;\n component: FC<ClientRepeatedComponentProps>;\n controls?: FC<ClientRepeaterControlsProps>;\n count?: number;\n clients?: Client[];\n types?: TypedObject[];\n args?: Omit<P, 'id' | 'count'>;\n} & Pick<WithClientProviderProps, 'createIdentity' | 'createSpace' | 'onSpaceCreated'>;\n\n/**\n * Utility component for Storybook stories which sets up clients for n peers.\n * The `Component` property is rendered n times, once for each peer.\n * @deprecated use `withClientProvider`.\n */\n// TODO(burdon): To discuss: evolve ClientRepeater with optional decorator that uses it.\n// NOTE: This is specifically not a storybook decorator because it broke stories as a decorator.\n// This seems primarily due to the fact that it required top-level await for the clients to initialize.\n// Storybook seemed to handle it alright, but Chromatic had a lot of trouble with it.\n// There was also a question of whether or not calling the story function multiple times was a good idea.\nexport const ClientRepeater = <P extends ClientRepeatedComponentProps>(props: ClientRepeaterProps<P>) => {\n const {\n component: Component,\n controls: Controls,\n count = 1,\n types,\n createIdentity,\n createSpace,\n onSpaceCreated,\n } = props;\n useEffect(() => {\n registerSignalsRuntime();\n }, []);\n\n const [clients, setClients] = useState(props.clients ?? []);\n const [spaceKey, setSpaceKey] = useState<PublicKey>();\n\n const testBuilder = useRef(new TestBuilder());\n useEffect(() => {\n const timeout = setTimeout(async () => {\n const clients = [...Array(count)].map(\n (_) => new Client({ services: testBuilder.current.createLocalClientServices(), types }),\n );\n\n await Promise.all(clients.map((client) => client.initialize()));\n if (createIdentity || createSpace) {\n await Promise.all(clients.map((client) => client.halo.createIdentity()));\n }\n\n if (createSpace) {\n const client = clients[0];\n const space = await client.spaces.create({ name: faker.commerce.productName() });\n setSpaceKey(space.key);\n await onSpaceCreated?.({ client, space }, {});\n await Promise.all(\n clients.slice(1).flatMap((client) => performInvitation({ host: space, guest: client.spaces })),\n );\n }\n\n setClients(clients);\n });\n\n return () => clearTimeout(timeout);\n }, []);\n\n if (clients.length === 0) {\n return null;\n }\n\n return (\n <>\n {Controls && <Controls clients={clients} />}\n {clients.map((client, index) => (\n <ClientProvider key={index} client={client}>\n <Component id={index} count={clients.length} spaceKey={spaceKey} {...{ ...props.args }} />\n </ClientProvider>\n ))}\n </>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type StoryContext, type Decorator } from '@storybook/react';\nimport React, { createContext, type PropsWithChildren, useContext, useEffect, useRef, useState } from 'react';\nimport { type FallbackProps, ErrorBoundary as NativeErrorBoundary } from 'react-error-boundary';\n\nimport { Trigger } from '@dxos/async';\nimport { type Client } from '@dxos/client';\nimport { type Space } from '@dxos/client/echo';\nimport { performInvitation, TestBuilder } from '@dxos/client/testing';\nimport { log } from '@dxos/log';\nimport { type MaybePromise } from '@dxos/util';\n\nimport { ClientStory } from './context';\nimport { ClientProvider, type ClientProviderProps } from '../client';\n\ntype InitializeProps = {\n createIdentity?: boolean;\n createSpace?: boolean;\n onInitialized?: (client: Client) => MaybePromise<void>;\n onIdentityCreated?: (props: { client: Client }) => MaybePromise<void>;\n // NOTE: context must be untyped until ClientRepeater is removed.\n onSpaceCreated?: (props: { client: Client; space: Space }, context: StoryContext | any) => MaybePromise<void>;\n};\n\n/**\n * Initialize client, identity and first space.\n */\nconst initializeClient = async (\n client: Client,\n { createIdentity, createSpace, onSpaceCreated, onIdentityCreated, onInitialized }: InitializeProps,\n context: StoryContext,\n): Promise<ClientStory> => {\n await onInitialized?.(client);\n\n if (createIdentity || createSpace) {\n if (!client.halo.identity.get()) {\n await client.halo.createIdentity();\n await onIdentityCreated?.({ client });\n }\n }\n\n let space: Space | undefined;\n if (createSpace) {\n space = await client.spaces.create({ name: 'Test Space' });\n await onSpaceCreated?.({ client, space }, context);\n }\n\n return { space };\n};\n\nexport type WithClientProviderProps = InitializeProps & Omit<ClientProviderProps, 'onInitialized'>;\n\n/**\n * Decorator that provides the client context.\n */\nexport const withClientProvider = ({\n createIdentity,\n createSpace,\n onSpaceCreated,\n onIdentityCreated,\n onInitialized,\n ...props\n}: WithClientProviderProps = {}): Decorator => {\n return (Story, context) => {\n const [data, setData] = useState<ClientStory>({});\n const handleInitialized = async (client: Client) => {\n const data = await initializeClient(\n client,\n {\n createIdentity,\n createSpace,\n onSpaceCreated,\n onIdentityCreated,\n onInitialized,\n },\n context,\n );\n\n setData(data);\n };\n\n return (\n <ErrorBoundary>\n <ClientProvider onInitialized={handleInitialized} {...props}>\n <ClientStory.Provider value={data}>\n <Story />\n </ClientStory.Provider>\n </ClientProvider>\n </ErrorBoundary>\n );\n };\n};\n\n// TODO(burdon): Implement context per client for context.\n// TODO(burdon): Callback once all invitations have completed.\n// TODO(burdon): Delay/jitter for creation of other clients.\nexport type WithMultiClientProviderProps = InitializeProps &\n Omit<ClientProviderProps, 'onInitialized'> & { numClients?: number };\n\nconst MultiClientContext = createContext<{ id: number }>({ id: 0 });\n\nexport const useMultiClient = () => useContext(MultiClientContext);\n\n/**\n * Decorator that creates a scaffold for multiple clients.\n * Orchestrates invitations between a randomly selected host and the remaining clients.\n * NOTE: Should come before withLayout.\n */\nexport const withMultiClientProvider = ({\n numClients = 2,\n createIdentity,\n createSpace,\n onSpaceCreated,\n onIdentityCreated,\n onInitialized,\n ...props\n}: WithMultiClientProviderProps): Decorator => {\n return (Story, context) => {\n const builder = useRef(new TestBuilder());\n const hostRef = useRef<Client>();\n const spaceReady = useRef(new Trigger<Space | undefined>());\n\n // Handle invitations.\n // NOTE: The zeroth client isn't necessarily the first to be initialized.\n const handleInitialized = async (client: Client, index: number) => {\n log.info('initialized', { index });\n if (createSpace) {\n if (!hostRef.current) {\n hostRef.current = client;\n const { space } = await initializeClient(\n client,\n {\n createIdentity,\n createSpace,\n onSpaceCreated,\n onIdentityCreated,\n onInitialized,\n },\n context,\n );\n\n spaceReady.current.wake(space);\n log.info('inviting', { index });\n } else {\n await initializeClient(client, { createIdentity, onInitialized }, context);\n const space = await spaceReady.current.wait();\n if (space) {\n log.info('joining', { index });\n await Promise.all(performInvitation({ host: space, guest: client.spaces }));\n }\n }\n }\n };\n\n return (\n <ErrorBoundary>\n {Array.from({ length: numClients }).map((_, index) => (\n <MultiClientContext.Provider key={index} value={{ id: index }}>\n <ClientProvider\n services={builder.current.createLocalClientServices()}\n onInitialized={(client) => handleInitialized(client, index)}\n {...props}\n >\n <Story />\n </ClientProvider>\n </MultiClientContext.Provider>\n ))}\n </ErrorBoundary>\n );\n };\n};\n\nconst ErrorBoundary = ({ children }: PropsWithChildren) => {\n const [error, setError] = useState<Error>();\n useEffect(() => {\n const handleError = (event: PromiseRejectionEvent) => {\n setError(event.reason);\n };\n\n window.addEventListener('unhandledrejection', handleError);\n return () => window.removeEventListener('unhandledrejection', handleError);\n }, []);\n\n if (error) {\n return <ErrorFallback error={error} resetErrorBoundary={() => setError(undefined)} />;\n }\n\n return <NativeErrorBoundary FallbackComponent={ErrorFallback}>{children}</NativeErrorBoundary>;\n};\n\nconst ErrorFallback = ({ error }: FallbackProps) => {\n const { name, message, stack } =\n error instanceof Error ? error : { name: 'Error', message: String(error), stack: undefined };\n return (\n <div role='alert' className='flex flex-col p-4 gap-4 overflow-auto'>\n <h1 className='text-xl text-red-500'>{name}</h1>\n <div className='text-lg'>{message}</div>\n {stack && <pre className='whitespace-pre-wrap text-sm text-subdued'>{stack}</pre>}\n </div>\n );\n};\n"],
5
+ "mappings": ";;;;;AAIA,cAAc;;;ACAd,SAASA,eAAeC,kBAAkB;AAG1C,SAASC,aAAa;AAOf,IAAMC,cAAcC,8BAAuCC,MAAAA;AAE3D,IAAMC,oBAAoB,MAAA;AAC/B,SAAOC,WAAWJ,WAAAA,KAAgBK,MAAM,IAAIC,MAAM,qBAAA,CAAA;AACp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EA,SAAO,gBAAAlD,OAAA,cAACmD,qBAAAA;IAAoBC,mBAAmBJ;KAAgBV,QAAAA;AACjE;AAEA,IAAMU,gBAAgB,CAAC,EAAET,MAAK,MAAiB;AAC7C,QAAM,EAAE/C,MAAM6D,SAASC,MAAK,IAC1Bf,iBAAiBgB,QAAQhB,QAAQ;IAAE/C,MAAM;IAAS6D,SAASG,OAAOjB,KAAAA;IAAQe,OAAOJ;EAAU;AAC7F,SACE,gBAAAlD,OAAA,cAACyD,OAAAA;IAAIC,MAAK;IAAQC,WAAU;KAC1B,gBAAA3D,OAAA,cAAC4D,MAAAA;IAAGD,WAAU;KAAwBnE,IAAAA,GACtC,gBAAAQ,OAAA,cAACyD,OAAAA;IAAIE,WAAU;KAAWN,OAAAA,GACzBC,SAAS,gBAAAtD,OAAA,cAAC6D,OAAAA;IAAIF,WAAU;KAA4CL,KAAAA,CAAAA;AAG3E;",
6
+ "names": ["createContext", "useContext", "raise", "ClientStory", "createContext", "undefined", "useClientProvider", "useContext", "raise", "Error", "React", "useState", "useEffect", "useRef", "Client", "TestBuilder", "performInvitation", "registerSignalsRuntime", "faker", "ClientRepeater", "props", "component", "Component", "controls", "Controls", "count", "types", "createIdentity", "createSpace", "onSpaceCreated", "useEffect", "registerSignalsRuntime", "clients", "setClients", "useState", "spaceKey", "setSpaceKey", "testBuilder", "useRef", "TestBuilder", "timeout", "setTimeout", "Array", "map", "_", "Client", "services", "current", "createLocalClientServices", "Promise", "all", "client", "initialize", "halo", "space", "spaces", "create", "name", "faker", "commerce", "productName", "key", "slice", "flatMap", "performInvitation", "host", "guest", "clearTimeout", "length", "index", "ClientProvider", "id", "args", "React", "createContext", "useContext", "useEffect", "useRef", "useState", "ErrorBoundary", "NativeErrorBoundary", "Trigger", "performInvitation", "TestBuilder", "log", "initializeClient", "client", "createIdentity", "createSpace", "onSpaceCreated", "onIdentityCreated", "onInitialized", "context", "halo", "identity", "get", "space", "spaces", "create", "name", "withClientProvider", "props", "Story", "data", "setData", "useState", "handleInitialized", "React", "ErrorBoundary", "ClientProvider", "ClientStory", "Provider", "value", "MultiClientContext", "createContext", "id", "useMultiClient", "useContext", "withMultiClientProvider", "numClients", "builder", "useRef", "TestBuilder", "hostRef", "spaceReady", "Trigger", "index", "log", "info", "current", "wake", "wait", "Promise", "all", "performInvitation", "host", "guest", "Array", "from", "length", "map", "_", "key", "services", "createLocalClientServices", "children", "error", "setError", "useEffect", "handleError", "event", "reason", "window", "addEventListener", "removeEventListener", "ErrorFallback", "resetErrorBoundary", "undefined", "NativeErrorBoundary", "FallbackComponent", "message", "stack", "Error", "String", "div", "role", "className", "h1", "pre"]
7
7
  }
@@ -26,8 +26,8 @@ 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_UJLDNXPC_exports = {};
30
- __export(chunk_UJLDNXPC_exports, {
29
+ var chunk_DITMVTAF_exports = {};
30
+ __export(chunk_DITMVTAF_exports, {
31
31
  AgentHostingContext: () => AgentHostingContext,
32
32
  AgentHostingProvider: () => AgentHostingProvider,
33
33
  ClientContext: () => ClientContext,
@@ -40,7 +40,7 @@ __export(chunk_UJLDNXPC_exports, {
40
40
  useShellDisplay: () => useShellDisplay,
41
41
  useStatus: () => useStatus
42
42
  });
43
- module.exports = __toCommonJS(chunk_UJLDNXPC_exports);
43
+ module.exports = __toCommonJS(chunk_DITMVTAF_exports);
44
44
  var import_react = __toESM(require("react"));
45
45
  var import_client = require("@dxos/client");
46
46
  var import_log = require("@dxos/log");
@@ -106,19 +106,24 @@ var ClientProvider = /* @__PURE__ */ (0, import_react2.forwardRef)(({ children,
106
106
  client
107
107
  ]);
108
108
  (0, import_react2.useEffect)(() => {
109
+ let disposed = false;
109
110
  const initialize = async (client3) => {
110
111
  if (!client3.initialized) {
111
- await client3.initialize().catch(setError);
112
+ await client3.initialize().catch((err) => {
113
+ if (!disposed) {
114
+ setError(err);
115
+ }
116
+ });
112
117
  (0, import_log2.log)("client ready", void 0, {
113
118
  F: __dxlog_file,
114
- L: 132,
119
+ L: 137,
115
120
  S: void 0,
116
121
  C: (f, a) => f(...a)
117
122
  });
118
123
  await onInitialized?.(client3);
119
124
  (0, import_log2.log)("initialization complete", void 0, {
120
125
  F: __dxlog_file,
121
- L: 134,
126
+ L: 139,
122
127
  S: void 0,
123
128
  C: (f, a) => f(...a)
124
129
  });
@@ -130,60 +135,72 @@ var ClientProvider = /* @__PURE__ */ (0, import_react2.forwardRef)(({ children,
130
135
  };
131
136
  let client2;
132
137
  const t = setTimeout(async () => {
133
- if (clientProvider) {
134
- client2 = await (0, import_util.getAsyncProviderValue)(clientProvider);
135
- await initialize(client2);
136
- } else {
137
- const config = await (0, import_util.getAsyncProviderValue)(configProvider);
138
- (0, import_log2.log)("resolved config", {
139
- config
140
- }, {
141
- F: __dxlog_file,
142
- L: 153,
143
- S: void 0,
144
- C: (f, a) => f(...a)
145
- });
146
- const services = await (0, import_util.getAsyncProviderValue)(servicesProvider, config);
147
- (0, import_log2.log)("created services", {
148
- services
149
- }, {
150
- F: __dxlog_file,
151
- L: 155,
152
- S: void 0,
153
- C: (f, a) => f(...a)
154
- });
155
- client2 = new import_client2.Client({
156
- config,
157
- services,
158
- ...options
159
- });
160
- (0, import_log2.log)("created client", void 0, {
161
- F: __dxlog_file,
162
- L: 157,
163
- S: void 0,
164
- C: (f, a) => f(...a)
165
- });
166
- await initialize(client2);
138
+ try {
139
+ if (clientProvider) {
140
+ client2 = await (0, import_util.getAsyncProviderValue)(clientProvider);
141
+ await initialize(client2);
142
+ } else {
143
+ const config = await (0, import_util.getAsyncProviderValue)(configProvider);
144
+ (0, import_log2.log)("resolved config", {
145
+ config
146
+ }, {
147
+ F: __dxlog_file,
148
+ L: 159,
149
+ S: void 0,
150
+ C: (f, a) => f(...a)
151
+ });
152
+ const services = await (0, import_util.getAsyncProviderValue)(servicesProvider, config);
153
+ (0, import_log2.log)("created services", {
154
+ services
155
+ }, {
156
+ F: __dxlog_file,
157
+ L: 161,
158
+ S: void 0,
159
+ C: (f, a) => f(...a)
160
+ });
161
+ client2 = new import_client2.Client({
162
+ config,
163
+ services,
164
+ ...options
165
+ });
166
+ (0, import_log2.log)("created client", void 0, {
167
+ F: __dxlog_file,
168
+ L: 163,
169
+ S: void 0,
170
+ C: (f, a) => f(...a)
171
+ });
172
+ await initialize(client2);
173
+ }
174
+ } catch (err) {
175
+ if (!disposed) {
176
+ import_log2.log.catch(err, void 0, {
177
+ F: __dxlog_file,
178
+ L: 168,
179
+ S: void 0,
180
+ C: (f, a) => f(...a)
181
+ });
182
+ }
167
183
  }
168
184
  });
169
185
  return () => {
170
186
  (0, import_log2.log)("clean up", void 0, {
171
187
  F: __dxlog_file,
172
- L: 163,
188
+ L: 174,
173
189
  S: void 0,
174
190
  C: (f, a) => f(...a)
175
191
  });
192
+ disposed = true;
176
193
  clearTimeout(t);
177
194
  void client2?.destroy().then(() => {
178
195
  (0, import_log2.log)("destroyed", void 0, {
179
196
  F: __dxlog_file,
180
- L: 168,
197
+ L: 180,
181
198
  S: void 0,
182
199
  C: (f, a) => f(...a)
183
200
  });
184
201
  }).catch((err) => import_log2.log.catch(err, void 0, {
185
202
  F: __dxlog_file,
186
- L: 170,
203
+ L: 182,
187
204
  S: void 0,
188
205
  C: (f, a) => f(...a)
189
206
  }));
@@ -312,4 +329,4 @@ var makeClient = ({ config, halo }) => {
312
329
  useShellDisplay,
313
330
  useStatus
314
331
  });
315
- //# sourceMappingURL=chunk-UJLDNXPC.cjs.map
332
+ //# sourceMappingURL=chunk-DITMVTAF.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 PropsWithChildren,\n useEffect,\n useImperativeHandle,\n useState,\n} from 'react';\n\nimport { Client, type ClientOptions, type ClientServicesProvider, SystemStatus } from '@dxos/client';\nimport { type Config } from '@dxos/config';\nimport { registerSignalsRuntime } from '@dxos/echo-signals/react';\nimport { log } from '@dxos/log';\nimport { 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 = Omit<ClientOptions, 'config' | 'services'> &\n Pick<ClientContextProps, 'status'> &\n PropsWithChildren<{\n /**\n * Client object or async provider to enable to caller to do custom initialization.\n *\n * NOTE: For advanced use cases only.\n */\n client?: Client | Provider<Promise<Client>>;\n\n /**\n * Config object or async provider.\n *\n * NOTE: If a `client` is provided then `config` is ignored.\n */\n // TODO(burdon): Reconcile with ClientOptions.\n config?: Config | Provider<Promise<Config>>;\n\n /**\n * Callback to enable the caller to create a custom ClientServicesProvider.\n *\n * NOTE: If a `client` is provided then `services` is ignored.\n */\n // TODO(burdon): Reconcile with ClientOptions.\n services?: ClientServicesProvider | ((config?: Config) => MaybePromise<ClientServicesProvider>);\n\n /**\n * ReactNode to display until the client is available.\n */\n fallback?: FunctionComponent<Partial<ClientContextProps>>;\n\n /**\n * Enable (by default) registration of Preact signals runtime for reactive ECHO objects.\n * @see https://www.npmjs.com/package/@preact/signals-react\n */\n signalsRuntime?: boolean;\n\n /**\n * Skip the DXOS banner.\n */\n noBanner?: boolean;\n\n /**\n * Post initialization hook to enable to caller to do custom initialization.\n */\n onInitialized?: (client: Client) => MaybePromise<void>;\n }>;\n\n/**\n * Root component that provides the DXOS client instance to child components.\n * To be used with the `useClient` hook.\n */\nexport const ClientProvider = forwardRef<Client | undefined, ClientProviderProps>(\n (\n {\n children,\n config: configProvider,\n client: clientProvider,\n services: servicesProvider,\n status: controlledStatus,\n fallback: Fallback = () => null,\n signalsRuntime = true,\n noBanner,\n onInitialized,\n ...options\n },\n forwardedRef,\n ) => {\n useEffect(() => {\n // TODO(wittjosiah): Ideally this should be imported asynchronously because it is optional.\n // Unfortunately, async import seemed to break signals React instrumentation.\n signalsRuntime && registerSignalsRuntime();\n }, []);\n\n // The client is initialized asynchronously.\n // If an error occurs during initialization, it is caught and the state is set.\n // This allows the error to be thrown in the render method.\n // The assumption is that a client initialization error is fatal to the app.\n // This error will be caught by the nearest error boundary.\n const [error, setError] = useState();\n if (error) {\n throw error;\n }\n\n const [client, setClient] = useState(clientProvider instanceof Client ? clientProvider : undefined);\n\n // Provide external access.\n useImperativeHandle(forwardedRef, () => client, [client]);\n\n // Client status subscription.\n const [status, setStatus] = 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 let disposed = false;\n const initialize = async (client: Client) => {\n if (!client.initialized) {\n await client.initialize().catch((err) => {\n if (!disposed) {\n setError(err);\n }\n });\n log('client ready');\n await onInitialized?.(client);\n log('initialization complete');\n }\n\n setClient(client);\n\n if (!noBanner) {\n printBanner(client);\n }\n };\n\n let client: Client;\n const t = setTimeout(async () => {\n try {\n if (clientProvider) {\n // Asynchronously request client.\n client = await getAsyncProviderValue(clientProvider);\n await initialize(client);\n } else {\n // Asynchronously construct client (config may be undefined).\n const config = await getAsyncProviderValue(configProvider);\n log('resolved config', { config });\n const services = await getAsyncProviderValue(servicesProvider, config);\n log('created services', { services });\n client = new Client({ config, services, ...options });\n log('created client');\n await initialize(client);\n }\n } catch (err) {\n if (!disposed) {\n log.catch(err);\n }\n }\n });\n\n return () => {\n log('clean up');\n disposed = true;\n clearTimeout(t);\n void client\n ?.destroy()\n .then(() => {\n log('destroyed');\n })\n .catch((err) => log.catch(err));\n };\n }, [configProvider, clientProvider, servicesProvider, noBanner]);\n\n if (!client?.initialized || status !== SystemStatus.ACTIVE) {\n return <Fallback client={client} status={status} />;\n }\n\n return <ClientContext.Provider value={{ client, status }}>{children}</ClientContext.Provider>;\n },\n);\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { type Context, createContext } from 'react';\n\nimport { type Client, type SystemStatus } from '@dxos/client';\n\nexport type ClientContextProps = {\n client: Client;\n status?: SystemStatus | null;\n};\n\n/**\n * @internal Use ClientProvider to create or initialize the Client.\n */\nexport const ClientContext: Context<ClientContextProps | undefined> = createContext<ClientContextProps | undefined>(\n undefined,\n);\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport { type Client } from '@dxos/client';\n\n// http://patorjk.com/software/taag/#p=testall&f=Patorjk-HeX&t=DXOS\nconst BANNER = (client: Client) => {\n const commitHash = client.config.get('runtime.app.build.commitHash');\n const hash = commitHash ? ` App Commit ${commitHash} \\n` : '';\n\n return (\n '\\n' +\n '_/\\\\/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\______/\\\\/\\\\/\\\\/\\\\/\\\\_\\n' +\n '_/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\__/\\\\/\\\\_________\\n' +\n '_/\\\\/\\\\____/\\\\/\\\\______/\\\\/\\\\______/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\___\\n' +\n '_/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\__________/\\\\/\\\\_\\n' +\n '_/\\\\/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\/\\\\___\\n' +\n `\\n DXOS Client ${client.version} \\n${hash}`\n );\n};\n\nlet bannerPrinted = false;\n\nexport const printBanner = (client: Client) => {\n if (bannerPrinted || window.location.hostname === 'localhost') {\n return;\n }\n\n bannerPrinted = true;\n // eslint-disable-next-line no-console\n console.log(`%c${BANNER(client)}`, 'font-family: monospace;');\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { useContext } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { ClientContext } from '../client/context';\n\n/**\n * Hook returning instance of DXOS client.\n * Requires ClientContext to be set via ClientProvider.\n */\nexport const useClient = () => {\n const { client } = useContext(ClientContext) ?? raise(new Error('Missing ClientContext.'));\n return client;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { useEffect, useState } from 'react';\n\nimport { type Client, type SystemStatus } from '@dxos/client';\n\nexport const useClientStatus = (client: Client) => {\n const [status, setStatus] = useState<SystemStatus | null>();\n useEffect(() => {\n if (!client) {\n return;\n }\n\n const subscription = client.status.subscribe((status) => setStatus(status));\n return () => subscription.unsubscribe();\n }, [client, setStatus]);\n\n return status;\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { useContext } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { ClientContext } from './context';\n\n/**\n * Hook returning config object used to initialize the DXOS client instance.\n * Requires ClientContext to be set via ClientProvider.\n */\nexport const useConfig = () => {\n const { client } = useContext(ClientContext) ?? raise(new Error('Missing ClientContext.'));\n return client.config;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { useEffect, useState } from 'react';\n\nimport { type Shell, type ShellDisplay } from '@dxos/client';\n\nimport { useClient } from './useClient';\n\n/**\n * Helper hook to access the shell.\n */\nexport const useShell = (): Shell => {\n const client = useClient();\n return client.shell;\n};\n\n/**\n * Hook to access the shell’s display state.\n */\nexport const useShellDisplay = (): ShellDisplay => {\n const client = useClient();\n const [display, setDisplay] = useState(client.shell.display);\n useEffect(() => client.shell.onDisplayChange(setDisplay), [client]);\n return display;\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { useContext } from 'react';\n\nimport { type SystemStatus } from '@dxos/client';\nimport { raise } from '@dxos/debug';\n\nimport { ClientContext } from './context';\n\nexport const useStatus = (): SystemStatus | null | undefined => {\n const { status } = useContext(ClientContext) ?? raise(new Error('Missing ClientContext.'));\n return status;\n};\n"],
5
+ "m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KAAI,kCAAA,QAAA;;;;;;AACJ,aAAO,IAAIoE,uCAAAA;IACb;IAEA,KAAK,oBAAoB;AACvBN,mCAA6B,IAAIO,iCAAmB/E,QAAQ2E,IAAAA;AAC5D,UAAIH,2BAA2BQ,KAAI,GAAI;AACrC,eAAOR;MACT,OAAO;AAEL,eAAO;MACT;IACF;IAEA,SAAS;AACP9D,iBAAAA,IAAImB,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", "window", "location", "hostname", "console", "log", "ClientProvider", "forwardRef", "children", "configProvider", "clientProvider", "services", "servicesProvider", "status", "controlledStatus", "fallback", "Fallback", "signalsRuntime", "noBanner", "onInitialized", "options", "forwardedRef", "useEffect", "registerSignalsRuntime", "error", "setError", "useState", "setClient", "Client", "useImperativeHandle", "setStatus", "useControlledValue", "subscription", "subscribe", "unsubscribe", "disposed", "initialize", "initialized", "catch", "err", "t", "setTimeout", "getAsyncProviderValue", "clearTimeout", "destroy", "then", "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_UJLDNXPC = require("../chunk-UJLDNXPC.cjs");
26
+ var import_chunk_DITMVTAF = require("../chunk-DITMVTAF.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_UJLDNXPC.useClient)();
32
+ const client = (0, import_chunk_DITMVTAF.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_UJLDNXPC = require("../chunk-UJLDNXPC.cjs");
32
+ var import_chunk_DITMVTAF = require("../chunk-DITMVTAF.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_UJLDNXPC.useClient)();
48
+ const client = (0, import_chunk_DITMVTAF.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_UJLDNXPC.useClient)();
72
+ const client = (0, import_chunk_DITMVTAF.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_UJLDNXPC = require("../chunk-UJLDNXPC.cjs");
34
+ var import_chunk_DITMVTAF = require("../chunk-DITMVTAF.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_UJLDNXPC.useClient)();
43
+ const client = (0, import_chunk_DITMVTAF.useClient)();
44
44
  return (0, import_react_hooks.useMulticastObservable)(client.halo.contacts);
45
45
  };
46
46
  var useDevices = () => {
47
- const client = (0, import_chunk_UJLDNXPC.useClient)();
47
+ const client = (0, import_chunk_DITMVTAF.useClient)();
48
48
  return (0, import_react_hooks2.useMulticastObservable)(client.halo.devices);
49
49
  };
50
50
  var useHaloInvitations = () => {
51
- const client = (0, import_chunk_UJLDNXPC.useClient)();
51
+ const client = (0, import_chunk_DITMVTAF.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_UJLDNXPC.useClient)();
62
+ const client = (0, import_chunk_DITMVTAF.useClient)();
63
63
  return (0, import_react_hooks4.useMulticastObservable)(client.halo.identity);
64
64
  };
65
65
  var KeyStore = class {
@@ -19,21 +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_UJLDNXPC.AgentHostingContext,
23
- AgentHostingProvider: () => import_chunk_UJLDNXPC.AgentHostingProvider,
24
- ClientContext: () => import_chunk_UJLDNXPC.ClientContext,
25
- ClientProvider: () => import_chunk_UJLDNXPC.ClientProvider,
26
- useAgentHostingClient: () => import_chunk_UJLDNXPC.useAgentHostingClient,
27
- useClient: () => import_chunk_UJLDNXPC.useClient,
28
- useClientStatus: () => import_chunk_UJLDNXPC.useClientStatus,
29
- useConfig: () => import_chunk_UJLDNXPC.useConfig,
22
+ AgentHostingContext: () => import_chunk_DITMVTAF.AgentHostingContext,
23
+ AgentHostingProvider: () => import_chunk_DITMVTAF.AgentHostingProvider,
24
+ ClientContext: () => import_chunk_DITMVTAF.ClientContext,
25
+ ClientProvider: () => import_chunk_DITMVTAF.ClientProvider,
26
+ useAgentHostingClient: () => import_chunk_DITMVTAF.useAgentHostingClient,
27
+ useClient: () => import_chunk_DITMVTAF.useClient,
28
+ useClientStatus: () => import_chunk_DITMVTAF.useClientStatus,
29
+ useConfig: () => import_chunk_DITMVTAF.useConfig,
30
30
  useMulticastObservable: () => import_react_hooks.useMulticastObservable,
31
- useShell: () => import_chunk_UJLDNXPC.useShell,
32
- useShellDisplay: () => import_chunk_UJLDNXPC.useShellDisplay,
33
- useStatus: () => import_chunk_UJLDNXPC.useStatus
31
+ useShell: () => import_chunk_DITMVTAF.useShell,
32
+ useShellDisplay: () => import_chunk_DITMVTAF.useShellDisplay,
33
+ useStatus: () => import_chunk_DITMVTAF.useStatus
34
34
  });
35
35
  module.exports = __toCommonJS(node_exports);
36
- var import_chunk_UJLDNXPC = require("./chunk-UJLDNXPC.cjs");
36
+ var import_chunk_DITMVTAF = require("./chunk-DITMVTAF.cjs");
37
37
  __reExport(node_exports, require("@dxos/client"), module.exports);
38
38
  var import_react_hooks = require("@dxos/react-hooks");
39
39
  // Annotate the CommonJS export names for ESM import in node:
@@ -22,11 +22,11 @@ __export(mesh_exports, {
22
22
  useNetworkStatus: () => useNetworkStatus
23
23
  });
24
24
  module.exports = __toCommonJS(mesh_exports);
25
- var import_chunk_UJLDNXPC = require("../chunk-UJLDNXPC.cjs");
25
+ var import_chunk_DITMVTAF = require("../chunk-DITMVTAF.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_UJLDNXPC.useClient)();
29
+ const client = (0, import_chunk_DITMVTAF.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: